Skip to content

Commit

Permalink
[NO-ISSUE] refactor/rs fix lints fmt files (#23)
Browse files Browse the repository at this point in the history
* refactor: adapt/update js client

* chore: update justfile

* ci: adapt JS client lib's CI

* test: start adding integration tests for our use cases

* ci: fix actions/setup-node usage for pnpm

* ci: update actions + install pnpm

* ci: remove cache on actions/setup-node as it's pretty fast

* test: add more tests to integration tests

* refactor: rename file + adapt requirements' tests

* feat(users): allow to provide external userId (uuid)

* chore: fix formatting

* test(requirements): provide userUuid

* feat(js lib): add format + lint biome + fixes

* feat: enable custom lint rules for workspace

* fix: remove usages of println

* refactor: fix lint & fmt files

* ci: install Nightly toolchain + fmt

* refactor: fmt more files

* ci: use same GH action for both stable & nightly

* ci: revert order of installs

* chore: remove unknown lint rule

* chore: fix format

* chore: add docs on rustfmt file
  • Loading branch information
GuillaumeDecMeetsMore authored Jul 26, 2024
1 parent 97734ee commit aa2a990
Show file tree
Hide file tree
Showing 138 changed files with 1,066 additions and 584 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/server-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
components: rustfmt
- uses: dtolnay/rust-toolchain@stable

- uses: actions/cache@v4
with:
path: |
Expand All @@ -53,16 +59,10 @@ jobs:
cargo install sqlx-cli --no-default-features --features postgres || true
(cd crates/infra && sqlx migrate run)
- name: Install nighly toolchain
run: |
rustup default nightly
# Go back to stable
rustup default stable
- name: Formatting
run: |
cd scheduler
cargo fmt --all -- --check
cargo +nightly fmt --all -- --check
- name: Clippy
run: |
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true
}
},
"rust-analyzer.rustfmt.extraArgs": ["+nightly"]
}
6 changes: 4 additions & 2 deletions scheduler/clients/rust/src/account.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::{APIResponse, BaseClient};
use std::sync::Arc;

use nettu_scheduler_api_structs::*;
use reqwest::StatusCode;
use std::sync::Arc;

use crate::{APIResponse, BaseClient};

#[derive(Clone)]
pub struct AccountClient {
Expand Down
19 changes: 12 additions & 7 deletions scheduler/clients/rust/src/calendar.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
use crate::{
base::{APIResponse, BaseClient},
shared::MetadataFindInput,
Tz, Weekday,
};
use std::sync::Arc;

use nettu_scheduler_api_structs::*;
use nettu_scheduler_domain::{
providers::{google::GoogleCalendarAccessRole, outlook::OutlookCalendarAccessRole},
IntegrationProvider, Metadata, ID,
IntegrationProvider,
Metadata,
ID,
};
use reqwest::StatusCode;
use std::sync::Arc;

use crate::{
base::{APIResponse, BaseClient},
shared::MetadataFindInput,
Tz,
Weekday,
};

#[derive(Clone)]
pub struct CalendarClient {
Expand Down
14 changes: 11 additions & 3 deletions scheduler/clients/rust/src/event.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
use crate::{shared::MetadataFindInput, APIResponse, BaseClient};
use crate::{CalendarEventReminder, RRuleOptions, ID};
use std::sync::Arc;

use nettu_scheduler_api_structs::*;
use nettu_scheduler_domain::Metadata;
use reqwest::StatusCode;
use serde::Serialize;
use std::sync::Arc;

use crate::{
shared::MetadataFindInput,
APIResponse,
BaseClient,
CalendarEventReminder,
RRuleOptions,
ID,
};

#[derive(Clone)]
pub struct CalendarEventClient {
Expand Down
86 changes: 59 additions & 27 deletions scheduler/clients/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,86 @@ mod shared;
mod status;
mod user;

use std::sync::Arc;

use account::AccountClient;
pub(crate) use base::BaseClient;
pub use base::{APIError, APIErrorVariant, APIResponse};
use calendar::CalendarClient;
pub use calendar::{
CreateCalendarInput, GetCalendarEventsInput, GetGoogleCalendars, GetOutlookCalendars,
StopCalendarSyncInput, SyncCalendarInput, UpdateCalendarInput,
CreateCalendarInput,
GetCalendarEventsInput,
GetGoogleCalendars,
GetOutlookCalendars,
StopCalendarSyncInput,
SyncCalendarInput,
UpdateCalendarInput,
};
use event::CalendarEventClient;
pub use event::{CreateEventInput, GetEventsInstancesInput, UpdateEventInput};
pub use nettu_scheduler_api_structs::dtos::*;
pub use nettu_scheduler_api_structs::send_event_reminders::AccountRemindersDTO as AccountReminders;
// Domain
pub use nettu_scheduler_api_structs::dtos::{
AccountDTO as Account,
AccountSettingsDTO as AccountSettings,
AccountWebhookSettingsDTO as AccountWebhookSettings,
CalendarDTO as Calendar,
CalendarEventDTO as CalendarEvent,
CalendarSettingsDTO as CalendarSettings,
EventWithInstancesDTO as EventWithIInstances,
ScheduleDTO as Schedule,
ServiceResourceDTO as ServiceResource,
ServiceWithUsersDTO as Service,
UserDTO as User,
};
pub use nettu_scheduler_api_structs::{
dtos::*,
send_event_reminders::AccountRemindersDTO as AccountReminders,
};
pub use nettu_scheduler_domain::{
providers::google::*, providers::outlook::*, scheduling::RoundRobinAlgorithm, BusyCalendar,
CalendarEventReminder, IntegrationProvider, Metadata, RRuleFrequency, RRuleOptions,
ScheduleRule, ServiceMultiPersonOptions, SyncedCalendar, TimePlan, ID,
providers::{google::*, outlook::*},
scheduling::RoundRobinAlgorithm,
BusyCalendar,
CalendarEventReminder,
IntegrationProvider,
Metadata,
Month,
RRuleFrequency,
RRuleOptions,
ScheduleRule,
ServiceMultiPersonOptions,
SyncedCalendar,
TimePlan,
Tz,
WeekDay,
Weekday,
ID,
};
use schedule::ScheduleClient;
pub use schedule::{CreateScheduleInput, UpdateScheduleInput};
use service::ServiceClient;
pub use service::{
AddBusyCalendar, AddServiceUserInput, CreateBookingIntendInput, CreateServiceInput,
GetServiceBookingSlotsInput, RemoveBookingIntendInput, RemoveBusyCalendar,
RemoveServiceUserInput, UpdateServiceInput, UpdateServiceUserInput,
AddBusyCalendar,
AddServiceUserInput,
CreateBookingIntendInput,
CreateServiceInput,
GetServiceBookingSlotsInput,
RemoveBookingIntendInput,
RemoveBusyCalendar,
RemoveServiceUserInput,
UpdateServiceInput,
UpdateServiceUserInput,
};
pub use shared::{KVMetadata, MetadataFindInput};
use status::StatusClient;
use std::sync::Arc;
use user::UserClient;
pub use user::{
CreateUserInput, GetUserFreeBusyInput, OAuthInput, RemoveUserIntegrationInput, UpdateUserInput,
CreateUserInput,
GetUserFreeBusyInput,
OAuthInput,
RemoveUserIntegrationInput,
UpdateUserInput,
};

// Domain
pub use nettu_scheduler_api_structs::dtos::AccountDTO as Account;
pub use nettu_scheduler_api_structs::dtos::AccountSettingsDTO as AccountSettings;
pub use nettu_scheduler_api_structs::dtos::AccountWebhookSettingsDTO as AccountWebhookSettings;
pub use nettu_scheduler_api_structs::dtos::CalendarDTO as Calendar;
pub use nettu_scheduler_api_structs::dtos::CalendarEventDTO as CalendarEvent;
pub use nettu_scheduler_api_structs::dtos::CalendarSettingsDTO as CalendarSettings;
pub use nettu_scheduler_api_structs::dtos::EventWithInstancesDTO as EventWithIInstances;
pub use nettu_scheduler_api_structs::dtos::ScheduleDTO as Schedule;
pub use nettu_scheduler_api_structs::dtos::ServiceResourceDTO as ServiceResource;
pub use nettu_scheduler_api_structs::dtos::ServiceWithUsersDTO as Service;
pub use nettu_scheduler_api_structs::dtos::UserDTO as User;

pub use nettu_scheduler_domain::{Month, Tz, WeekDay, Weekday};

/// Nettu Scheduler Server SDK
///
/// The SDK contains methods for interacting with the Nettu Scheduler server
Expand Down
9 changes: 5 additions & 4 deletions scheduler/clients/rust/src/schedule.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::{APIResponse, BaseClient, ScheduleRule, ID};
use std::sync::Arc;

use nettu_scheduler_api_structs::*;
use nettu_scheduler_domain::Metadata;
use nettu_scheduler_domain::Tz;
use nettu_scheduler_domain::{Metadata, Tz};
use reqwest::StatusCode;
use std::sync::Arc;

use crate::{APIResponse, BaseClient, ScheduleRule, ID};

#[derive(Clone)]
pub struct ScheduleClient {
Expand Down
6 changes: 4 additions & 2 deletions scheduler/clients/rust/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::{shared::MetadataFindInput, APIResponse, BaseClient, TimePlan, Tz, ID};
use std::sync::Arc;

use nettu_scheduler_api_structs::*;
use nettu_scheduler_domain::{BusyCalendar, Metadata, ServiceMultiPersonOptions};
use reqwest::StatusCode;
use std::sync::Arc;

use crate::{shared::MetadataFindInput, APIResponse, BaseClient, TimePlan, Tz, ID};

#[derive(Clone)]
pub struct ServiceClient {
Expand Down
6 changes: 4 additions & 2 deletions scheduler/clients/rust/src/status.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::{APIResponse, BaseClient};
use std::sync::Arc;

use nettu_scheduler_api_structs::*;
use reqwest::StatusCode;
use std::sync::Arc;

use crate::{APIResponse, BaseClient};

#[derive(Clone)]
pub struct StatusClient {
Expand Down
6 changes: 4 additions & 2 deletions scheduler/clients/rust/src/user.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::{shared::MetadataFindInput, APIResponse, BaseClient, ID};
use std::sync::Arc;

use nettu_scheduler_api_structs::*;
use nettu_scheduler_domain::{IntegrationProvider, Metadata};
use reqwest::StatusCode;
use std::sync::Arc;

use crate::{shared::MetadataFindInput, APIResponse, BaseClient, ID};

#[derive(Clone)]
pub struct UserClient {
Expand Down
10 changes: 8 additions & 2 deletions scheduler/crates/api/src/account/add_account_integration.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
use crate::shared::usecase::{execute, UseCase};
use crate::{error::NettuError, shared::auth::protect_account_route};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::add_account_integration::{APIResponse, RequestBody};
use nettu_scheduler_domain::{Account, AccountIntegration, IntegrationProvider};
use nettu_scheduler_infra::NettuContext;

use crate::{
error::NettuError,
shared::{
auth::protect_account_route,
usecase::{execute, UseCase},
},
};

pub async fn add_account_integration_controller(
http_req: HttpRequest,
body: web::Json<RequestBody>,
Expand Down
9 changes: 5 additions & 4 deletions scheduler/crates/api/src/account/create_account.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use crate::{
error::NettuError,
shared::usecase::{execute, UseCase},
};
use actix_web::{web, HttpResponse};
use nettu_scheduler_api_structs::create_account::{APIResponse, RequestBody};
use nettu_scheduler_domain::Account;
use nettu_scheduler_infra::NettuContext;

use crate::{
error::NettuError,
shared::usecase::{execute, UseCase},
};

pub async fn create_account_controller(
ctx: web::Data<NettuContext>,
body: web::Json<RequestBody>,
Expand Down
10 changes: 6 additions & 4 deletions scheduler/crates/api/src/account/delete_account_webhook.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use super::set_account_webhook::SetAccountWebhookUseCase;
use crate::error::NettuError;
use crate::shared::auth::protect_account_route;
use crate::shared::usecase::execute;
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::delete_account_webhook::APIResponse;
use nettu_scheduler_infra::NettuContext;

use super::set_account_webhook::SetAccountWebhookUseCase;
use crate::{
error::NettuError,
shared::{auth::protect_account_route, usecase::execute},
};

pub async fn delete_account_webhook_controller(
http_req: HttpRequest,
ctx: web::Data<NettuContext>,
Expand Down
4 changes: 2 additions & 2 deletions scheduler/crates/api/src/account/get_account.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::error::NettuError;
use crate::shared::auth::protect_account_route;
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::get_account::APIResponse;
use nettu_scheduler_infra::NettuContext;

use crate::{error::NettuError, shared::auth::protect_account_route};

pub async fn get_account_controller(
http_req: HttpRequest,
ctx: web::Data<NettuContext>,
Expand Down
10 changes: 8 additions & 2 deletions scheduler/crates/api/src/account/remove_account_integration.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
use crate::shared::usecase::{execute, UseCase};
use crate::{error::NettuError, shared::auth::protect_account_route};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::remove_account_integration::{APIResponse, PathParams};
use nettu_scheduler_domain::{Account, IntegrationProvider};
use nettu_scheduler_infra::NettuContext;

use crate::{
error::NettuError,
shared::{
auth::protect_account_route,
usecase::{execute, UseCase},
},
};

pub async fn remove_account_integration_controller(
http_req: HttpRequest,
mut path: web::Path<PathParams>,
Expand Down
10 changes: 8 additions & 2 deletions scheduler/crates/api/src/account/set_account_pub_key.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
use crate::shared::usecase::{execute, UseCase};
use crate::{error::NettuError, shared::auth::protect_account_route};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::set_account_pub_key::{APIResponse, RequestBody};
use nettu_scheduler_domain::{Account, PEMKey};
use nettu_scheduler_infra::NettuContext;

use crate::{
error::NettuError,
shared::{
auth::protect_account_route,
usecase::{execute, UseCase},
},
};

pub async fn set_account_pub_key_controller(
http_req: HttpRequest,
ctx: web::Data<NettuContext>,
Expand Down
10 changes: 8 additions & 2 deletions scheduler/crates/api/src/account/set_account_webhook.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
use crate::shared::usecase::{execute, UseCase};
use crate::{error::NettuError, shared::auth::protect_account_route};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::set_account_webhook::{APIResponse, RequestBody};
use nettu_scheduler_domain::Account;
use nettu_scheduler_infra::NettuContext;

use crate::{
error::NettuError,
shared::{
auth::protect_account_route,
usecase::{execute, UseCase},
},
};

pub async fn set_account_webhook_controller(
http_req: HttpRequest,
ctx: web::Data<NettuContext>,
Expand Down
Loading

0 comments on commit aa2a990

Please sign in to comment.