typespec-rust-emitter 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,5 @@
1
+ #![allow(unused)]
2
+
1
3
  use super::types::*;
2
4
  use async_trait::async_trait;
3
5
  use axum::{http::StatusCode, Json};
@@ -11,45 +13,45 @@ pub trait Server: Send + Sync {
11
13
 
12
14
 
13
15
  /// Retrieve a list of all groups for the current account (from view_learning_group).
14
- async fn groups_list(&self) -> Result<GroupsListResponse>;
16
+ async fn groups_list(&self, account_id: uuid::Uuid) -> Result<GroupsListResponse>;
15
17
  /// Create a new group.
16
- async fn groups_create(&self, claims: Self::Claims, body: CreateGroupBody) -> Result<GroupsCreateResponse>;
18
+ async fn groups_create(&self, claims: Self::Claims, account_id: uuid::Uuid, body: CreateGroupBody) -> Result<GroupsCreateResponse>;
17
19
  /// Get the details of a group by its ID.
18
- async fn groups_get_by_id(&self, id: i64) -> Result<GroupsGetByIdResponse>;
20
+ async fn groups_get_by_id(&self, account_id: uuid::Uuid, id: i64) -> Result<GroupsGetByIdResponse>;
19
21
  /// Update a group. Only provide the fields that need to be changed.
20
- async fn groups_update(&self, claims: Self::Claims, id: i64, body: UpdateGroupBody) -> Result<GroupsUpdateResponse>;
22
+ async fn groups_update(&self, claims: Self::Claims, account_id: uuid::Uuid, id: i64, body: UpdateGroupBody) -> Result<GroupsUpdateResponse>;
21
23
  /// Soft delete a group. All subjects within the group will also be soft deleted.
22
- async fn groups_delete(&self, claims: Self::Claims, id: i64) -> Result<GroupsDeleteResponse>;
24
+ async fn groups_delete(&self, claims: Self::Claims, account_id: uuid::Uuid, id: i64) -> Result<GroupsDeleteResponse>;
23
25
  /// Retrieve a list of subjects for a group (from view_subject_statistics).
24
- async fn subjects_list(&self, group_id: i64) -> Result<SubjectsListResponse>;
26
+ async fn subjects_list(&self, account_id: uuid::Uuid, group_id: i64) -> Result<SubjectsListResponse>;
25
27
  /// Create a new subject within the specified group.
26
- async fn subjects_create(&self, claims: Self::Claims, group_id: i64, body: CreateSubjectBody) -> Result<SubjectsCreateResponse>;
28
+ async fn subjects_create(&self, claims: Self::Claims, account_id: uuid::Uuid, group_id: i64, body: CreateSubjectBody) -> Result<SubjectsCreateResponse>;
27
29
  /// Get the details of a subject by its ID.
28
- async fn subjects_get_by_id(&self, group_id: i64, id: i64) -> Result<SubjectsGetByIdResponse>;
30
+ async fn subjects_get_by_id(&self, account_id: uuid::Uuid, group_id: i64, id: i64) -> Result<SubjectsGetByIdResponse>;
29
31
  /// Update a subject. Only provide the fields that need to be changed.
30
- async fn subjects_update(&self, claims: Self::Claims, group_id: i64, id: i64, body: UpdateSubjectBody) -> Result<SubjectsUpdateResponse>;
32
+ async fn subjects_update(&self, claims: Self::Claims, account_id: uuid::Uuid, group_id: i64, id: i64, body: UpdateSubjectBody) -> Result<SubjectsUpdateResponse>;
31
33
  /// Soft delete a subject.
32
- async fn subjects_delete(&self, claims: Self::Claims, group_id: i64, id: i64) -> Result<SubjectsDeleteResponse>;
34
+ async fn subjects_delete(&self, claims: Self::Claims, account_id: uuid::Uuid, group_id: i64, id: i64) -> Result<SubjectsDeleteResponse>;
33
35
  /// Start a new study session for the subject.
34
36
  /// The server creates a Log (status=Starting) and the first Timelog.
35
37
  /// Returns 409 if the subject already has a session in Starting or Paused status.
36
- async fn sessions_start(&self, claims: Self::Claims, subject_id: i64, body: SessionNoteBody) -> Result<SessionsStartResponse>;
38
+ async fn sessions_start(&self, claims: Self::Claims, account_id: uuid::Uuid, subject_id: i64, body: SessionNoteBody) -> Result<SessionsStartResponse>;
37
39
  /// Pause the currently running session (transition from Starting to Paused).
38
40
  /// The server closes the current Timelog (sets stoppedAt and calculates durationInSeconds).
39
41
  /// Returns 409 if the session is not in the Starting state.
40
- async fn sessions_pause(&self, claims: Self::Claims, subject_id: i64, log_id: i64) -> Result<SessionsPauseResponse>;
42
+ async fn sessions_pause(&self, claims: Self::Claims, account_id: uuid::Uuid, subject_id: i64, log_id: i64) -> Result<SessionsPauseResponse>;
41
43
  /// Resume a paused session (transition from Paused to Starting).
42
44
  /// The server creates a new Timelog.
43
45
  /// Returns 409 if the session is not in the Paused state.
44
- async fn sessions_resume(&self, claims: Self::Claims, subject_id: i64, log_id: i64) -> Result<SessionsResumeResponse>;
46
+ async fn sessions_resume(&self, claims: Self::Claims, account_id: uuid::Uuid, subject_id: i64, log_id: i64) -> Result<SessionsResumeResponse>;
45
47
  /// End the session (transition from Starting or Paused to Stopped).
46
48
  /// The server closes the current Timelog if it is running, and updates Log.stoppedAt.
47
49
  /// Returns 409 if the session is already Stopped.
48
- async fn sessions_stop(&self, claims: Self::Claims, subject_id: i64, log_id: i64, body: SessionNoteBody) -> Result<SessionsStopResponse>;
50
+ async fn sessions_stop(&self, claims: Self::Claims, account_id: uuid::Uuid, subject_id: i64, log_id: i64, body: SessionNoteBody) -> Result<SessionsStopResponse>;
49
51
  }
50
52
  pub enum GroupsListResponse {
51
53
  Ok(Json<Vec<GroupStatistics>>),
52
- Unauthorized,
54
+ Unauthorized(Json<ApiError>),
53
55
  }
54
56
 
55
57
  impl IntoResponse for GroupsListResponse {
@@ -57,15 +59,15 @@ impl IntoResponse for GroupsListResponse {
57
59
  match self {
58
60
 
59
61
  GroupsListResponse::Ok(body) => (StatusCode::OK, body).into_response(),
60
- GroupsListResponse::Unauthorized => StatusCode::UNAUTHORIZED.into_response(),
62
+ GroupsListResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
61
63
  }
62
64
  }
63
65
  }
64
66
 
65
67
  pub enum GroupsCreateResponse {
66
68
  Created(Json<Group>),
67
- BadRequest,
68
- Unauthorized,
69
+ BadRequest(Json<ValidationError>),
70
+ Unauthorized(Json<ApiError>),
69
71
  }
70
72
 
71
73
  impl IntoResponse for GroupsCreateResponse {
@@ -73,16 +75,16 @@ impl IntoResponse for GroupsCreateResponse {
73
75
  match self {
74
76
 
75
77
  GroupsCreateResponse::Created(body) => (StatusCode::CREATED, body).into_response(),
76
- GroupsCreateResponse::BadRequest => StatusCode::BAD_REQUEST.into_response(),
77
- GroupsCreateResponse::Unauthorized => StatusCode::UNAUTHORIZED.into_response(),
78
+ GroupsCreateResponse::BadRequest(body) => (StatusCode::BAD_REQUEST, body).into_response(),
79
+ GroupsCreateResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
78
80
  }
79
81
  }
80
82
  }
81
83
 
82
84
  pub enum GroupsGetByIdResponse {
83
85
  Ok(Json<GroupStatistics>),
84
- Unauthorized,
85
- NotFound,
86
+ Unauthorized(Json<ApiError>),
87
+ NotFound(Json<NotFoundError>),
86
88
  }
87
89
 
88
90
  impl IntoResponse for GroupsGetByIdResponse {
@@ -90,17 +92,17 @@ impl IntoResponse for GroupsGetByIdResponse {
90
92
  match self {
91
93
 
92
94
  GroupsGetByIdResponse::Ok(body) => (StatusCode::OK, body).into_response(),
93
- GroupsGetByIdResponse::Unauthorized => StatusCode::UNAUTHORIZED.into_response(),
94
- GroupsGetByIdResponse::NotFound => StatusCode::NOT_FOUND.into_response(),
95
+ GroupsGetByIdResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
96
+ GroupsGetByIdResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
95
97
  }
96
98
  }
97
99
  }
98
100
 
99
101
  pub enum GroupsUpdateResponse {
100
102
  Ok(Json<Group>),
101
- BadRequest,
102
- Unauthorized,
103
- NotFound,
103
+ BadRequest(Json<ValidationError>),
104
+ Unauthorized(Json<ApiError>),
105
+ NotFound(Json<NotFoundError>),
104
106
  }
105
107
 
106
108
  impl IntoResponse for GroupsUpdateResponse {
@@ -108,17 +110,17 @@ impl IntoResponse for GroupsUpdateResponse {
108
110
  match self {
109
111
 
110
112
  GroupsUpdateResponse::Ok(body) => (StatusCode::OK, body).into_response(),
111
- GroupsUpdateResponse::BadRequest => StatusCode::BAD_REQUEST.into_response(),
112
- GroupsUpdateResponse::Unauthorized => StatusCode::UNAUTHORIZED.into_response(),
113
- GroupsUpdateResponse::NotFound => StatusCode::NOT_FOUND.into_response(),
113
+ GroupsUpdateResponse::BadRequest(body) => (StatusCode::BAD_REQUEST, body).into_response(),
114
+ GroupsUpdateResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
115
+ GroupsUpdateResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
114
116
  }
115
117
  }
116
118
  }
117
119
 
118
120
  pub enum GroupsDeleteResponse {
119
121
  NoContent,
120
- Unauthorized,
121
- NotFound,
122
+ Unauthorized(Json<ApiError>),
123
+ NotFound(Json<NotFoundError>),
122
124
  }
123
125
 
124
126
  impl IntoResponse for GroupsDeleteResponse {
@@ -126,16 +128,16 @@ impl IntoResponse for GroupsDeleteResponse {
126
128
  match self {
127
129
 
128
130
  GroupsDeleteResponse::NoContent => StatusCode::NO_CONTENT.into_response(),
129
- GroupsDeleteResponse::Unauthorized => StatusCode::UNAUTHORIZED.into_response(),
130
- GroupsDeleteResponse::NotFound => StatusCode::NOT_FOUND.into_response(),
131
+ GroupsDeleteResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
132
+ GroupsDeleteResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
131
133
  }
132
134
  }
133
135
  }
134
136
 
135
137
  pub enum SubjectsListResponse {
136
138
  Ok(Json<Vec<SubjectStatistics>>),
137
- Unauthorized,
138
- NotFound,
139
+ Unauthorized(Json<ApiError>),
140
+ NotFound(Json<NotFoundError>),
139
141
  }
140
142
 
141
143
  impl IntoResponse for SubjectsListResponse {
@@ -143,17 +145,17 @@ impl IntoResponse for SubjectsListResponse {
143
145
  match self {
144
146
 
145
147
  SubjectsListResponse::Ok(body) => (StatusCode::OK, body).into_response(),
146
- SubjectsListResponse::Unauthorized => StatusCode::UNAUTHORIZED.into_response(),
147
- SubjectsListResponse::NotFound => StatusCode::NOT_FOUND.into_response(),
148
+ SubjectsListResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
149
+ SubjectsListResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
148
150
  }
149
151
  }
150
152
  }
151
153
 
152
154
  pub enum SubjectsCreateResponse {
153
155
  Created(Json<Subject>),
154
- BadRequest,
155
- Unauthorized,
156
- NotFound,
156
+ BadRequest(Json<ValidationError>),
157
+ Unauthorized(Json<ApiError>),
158
+ NotFound(Json<NotFoundError>),
157
159
  }
158
160
 
159
161
  impl IntoResponse for SubjectsCreateResponse {
@@ -161,17 +163,17 @@ impl IntoResponse for SubjectsCreateResponse {
161
163
  match self {
162
164
 
163
165
  SubjectsCreateResponse::Created(body) => (StatusCode::CREATED, body).into_response(),
164
- SubjectsCreateResponse::BadRequest => StatusCode::BAD_REQUEST.into_response(),
165
- SubjectsCreateResponse::Unauthorized => StatusCode::UNAUTHORIZED.into_response(),
166
- SubjectsCreateResponse::NotFound => StatusCode::NOT_FOUND.into_response(),
166
+ SubjectsCreateResponse::BadRequest(body) => (StatusCode::BAD_REQUEST, body).into_response(),
167
+ SubjectsCreateResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
168
+ SubjectsCreateResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
167
169
  }
168
170
  }
169
171
  }
170
172
 
171
173
  pub enum SubjectsGetByIdResponse {
172
174
  Ok(Json<SubjectStatistics>),
173
- Unauthorized,
174
- NotFound,
175
+ Unauthorized(Json<ApiError>),
176
+ NotFound(Json<NotFoundError>),
175
177
  }
176
178
 
177
179
  impl IntoResponse for SubjectsGetByIdResponse {
@@ -179,17 +181,17 @@ impl IntoResponse for SubjectsGetByIdResponse {
179
181
  match self {
180
182
 
181
183
  SubjectsGetByIdResponse::Ok(body) => (StatusCode::OK, body).into_response(),
182
- SubjectsGetByIdResponse::Unauthorized => StatusCode::UNAUTHORIZED.into_response(),
183
- SubjectsGetByIdResponse::NotFound => StatusCode::NOT_FOUND.into_response(),
184
+ SubjectsGetByIdResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
185
+ SubjectsGetByIdResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
184
186
  }
185
187
  }
186
188
  }
187
189
 
188
190
  pub enum SubjectsUpdateResponse {
189
191
  Ok(Json<Subject>),
190
- BadRequest,
191
- Unauthorized,
192
- NotFound,
192
+ BadRequest(Json<ValidationError>),
193
+ Unauthorized(Json<ApiError>),
194
+ NotFound(Json<NotFoundError>),
193
195
  }
194
196
 
195
197
  impl IntoResponse for SubjectsUpdateResponse {
@@ -197,17 +199,17 @@ impl IntoResponse for SubjectsUpdateResponse {
197
199
  match self {
198
200
 
199
201
  SubjectsUpdateResponse::Ok(body) => (StatusCode::OK, body).into_response(),
200
- SubjectsUpdateResponse::BadRequest => StatusCode::BAD_REQUEST.into_response(),
201
- SubjectsUpdateResponse::Unauthorized => StatusCode::UNAUTHORIZED.into_response(),
202
- SubjectsUpdateResponse::NotFound => StatusCode::NOT_FOUND.into_response(),
202
+ SubjectsUpdateResponse::BadRequest(body) => (StatusCode::BAD_REQUEST, body).into_response(),
203
+ SubjectsUpdateResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
204
+ SubjectsUpdateResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
203
205
  }
204
206
  }
205
207
  }
206
208
 
207
209
  pub enum SubjectsDeleteResponse {
208
210
  NoContent,
209
- Unauthorized,
210
- NotFound,
211
+ Unauthorized(Json<ApiError>),
212
+ NotFound(Json<NotFoundError>),
211
213
  }
212
214
 
213
215
  impl IntoResponse for SubjectsDeleteResponse {
@@ -215,17 +217,17 @@ impl IntoResponse for SubjectsDeleteResponse {
215
217
  match self {
216
218
 
217
219
  SubjectsDeleteResponse::NoContent => StatusCode::NO_CONTENT.into_response(),
218
- SubjectsDeleteResponse::Unauthorized => StatusCode::UNAUTHORIZED.into_response(),
219
- SubjectsDeleteResponse::NotFound => StatusCode::NOT_FOUND.into_response(),
220
+ SubjectsDeleteResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
221
+ SubjectsDeleteResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
220
222
  }
221
223
  }
222
224
  }
223
225
 
224
226
  pub enum SessionsStartResponse {
225
227
  Created(Json<SessionOpenedResponse>),
226
- Unauthorized,
227
- NotFound,
228
- Conflict,
228
+ Unauthorized(Json<ApiError>),
229
+ NotFound(Json<NotFoundError>),
230
+ Conflict(Json<ConflictError>),
229
231
  }
230
232
 
231
233
  impl IntoResponse for SessionsStartResponse {
@@ -233,18 +235,18 @@ impl IntoResponse for SessionsStartResponse {
233
235
  match self {
234
236
 
235
237
  SessionsStartResponse::Created(body) => (StatusCode::CREATED, body).into_response(),
236
- SessionsStartResponse::Unauthorized => StatusCode::UNAUTHORIZED.into_response(),
237
- SessionsStartResponse::NotFound => StatusCode::NOT_FOUND.into_response(),
238
- SessionsStartResponse::Conflict => StatusCode::CONFLICT.into_response(),
238
+ SessionsStartResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
239
+ SessionsStartResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
240
+ SessionsStartResponse::Conflict(body) => (StatusCode::CONFLICT, body).into_response(),
239
241
  }
240
242
  }
241
243
  }
242
244
 
243
245
  pub enum SessionsPauseResponse {
244
246
  Ok(Json<SessionClosedResponse>),
245
- Unauthorized,
246
- NotFound,
247
- Conflict,
247
+ Unauthorized(Json<ApiError>),
248
+ NotFound(Json<NotFoundError>),
249
+ Conflict(Json<ConflictError>),
248
250
  }
249
251
 
250
252
  impl IntoResponse for SessionsPauseResponse {
@@ -252,18 +254,18 @@ impl IntoResponse for SessionsPauseResponse {
252
254
  match self {
253
255
 
254
256
  SessionsPauseResponse::Ok(body) => (StatusCode::OK, body).into_response(),
255
- SessionsPauseResponse::Unauthorized => StatusCode::UNAUTHORIZED.into_response(),
256
- SessionsPauseResponse::NotFound => StatusCode::NOT_FOUND.into_response(),
257
- SessionsPauseResponse::Conflict => StatusCode::CONFLICT.into_response(),
257
+ SessionsPauseResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
258
+ SessionsPauseResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
259
+ SessionsPauseResponse::Conflict(body) => (StatusCode::CONFLICT, body).into_response(),
258
260
  }
259
261
  }
260
262
  }
261
263
 
262
264
  pub enum SessionsResumeResponse {
263
265
  Ok(Json<SessionOpenedResponse>),
264
- Unauthorized,
265
- NotFound,
266
- Conflict,
266
+ Unauthorized(Json<ApiError>),
267
+ NotFound(Json<NotFoundError>),
268
+ Conflict(Json<ConflictError>),
267
269
  }
268
270
 
269
271
  impl IntoResponse for SessionsResumeResponse {
@@ -271,18 +273,18 @@ impl IntoResponse for SessionsResumeResponse {
271
273
  match self {
272
274
 
273
275
  SessionsResumeResponse::Ok(body) => (StatusCode::OK, body).into_response(),
274
- SessionsResumeResponse::Unauthorized => StatusCode::UNAUTHORIZED.into_response(),
275
- SessionsResumeResponse::NotFound => StatusCode::NOT_FOUND.into_response(),
276
- SessionsResumeResponse::Conflict => StatusCode::CONFLICT.into_response(),
276
+ SessionsResumeResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
277
+ SessionsResumeResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
278
+ SessionsResumeResponse::Conflict(body) => (StatusCode::CONFLICT, body).into_response(),
277
279
  }
278
280
  }
279
281
  }
280
282
 
281
283
  pub enum SessionsStopResponse {
282
284
  Ok(Json<SessionClosedResponse>),
283
- Unauthorized,
284
- NotFound,
285
- Conflict,
285
+ Unauthorized(Json<ApiError>),
286
+ NotFound(Json<NotFoundError>),
287
+ Conflict(Json<ConflictError>),
286
288
  }
287
289
 
288
290
  impl IntoResponse for SessionsStopResponse {
@@ -290,9 +292,9 @@ impl IntoResponse for SessionsStopResponse {
290
292
  match self {
291
293
 
292
294
  SessionsStopResponse::Ok(body) => (StatusCode::OK, body).into_response(),
293
- SessionsStopResponse::Unauthorized => StatusCode::UNAUTHORIZED.into_response(),
294
- SessionsStopResponse::NotFound => StatusCode::NOT_FOUND.into_response(),
295
- SessionsStopResponse::Conflict => StatusCode::CONFLICT.into_response(),
295
+ SessionsStopResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
296
+ SessionsStopResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
297
+ SessionsStopResponse::Conflict(body) => (StatusCode::CONFLICT, body).into_response(),
296
298
  }
297
299
  }
298
300
  }
@@ -304,13 +306,13 @@ use axum::Router;
304
306
 
305
307
  pub async fn groups_list_handler<S>(
306
308
  axum::extract::State(service): axum::extract::State<S>,
307
-
309
+ Path(account_id): Path<uuid::Uuid>,
308
310
  ) -> impl axum::response::IntoResponse
309
311
  where
310
312
  S: Server + Clone + Send + Sync + 'static,
311
313
  S::Claims: Send + Sync + Clone + 'static,
312
314
  {
313
- let result = service.groups_list().await;
315
+ let result = service.groups_list(account_id).await;
314
316
  match result {
315
317
  Ok(response) => response.into_response(),
316
318
  Err(e) => (
@@ -324,13 +326,14 @@ where
324
326
  pub async fn groups_create_handler<S>(
325
327
  axum::extract::State(service): axum::extract::State<S>,
326
328
  Extension(claims): Extension<S::Claims>,
329
+ Path(account_id): Path<uuid::Uuid>,
327
330
  Json(payload): Json<CreateGroupBody>,
328
331
  ) -> impl axum::response::IntoResponse
329
332
  where
330
333
  S: Server + Clone + Send + Sync + 'static,
331
334
  S::Claims: Send + Sync + Clone + 'static,
332
335
  {
333
- let result = service.groups_create(claims, payload).await;
336
+ let result = service.groups_create(claims, account_id, payload).await;
334
337
  match result {
335
338
  Ok(response) => response.into_response(),
336
339
  Err(e) => (
@@ -343,13 +346,13 @@ where
343
346
 
344
347
  pub async fn groups_get_by_id_handler<S>(
345
348
  axum::extract::State(service): axum::extract::State<S>,
346
- Path(id): Path<i64>,
349
+ Path((account_id, id)): Path<(uuid::Uuid, i64)>,
347
350
  ) -> impl axum::response::IntoResponse
348
351
  where
349
352
  S: Server + Clone + Send + Sync + 'static,
350
353
  S::Claims: Send + Sync + Clone + 'static,
351
354
  {
352
- let result = service.groups_get_by_id(id).await;
355
+ let result = service.groups_get_by_id(account_id, id).await;
353
356
  match result {
354
357
  Ok(response) => response.into_response(),
355
358
  Err(e) => (
@@ -363,14 +366,14 @@ where
363
366
  pub async fn groups_update_handler<S>(
364
367
  axum::extract::State(service): axum::extract::State<S>,
365
368
  Extension(claims): Extension<S::Claims>,
366
- Path(id): Path<i64>,
369
+ Path((account_id, id)): Path<(uuid::Uuid, i64)>,
367
370
  Json(payload): Json<UpdateGroupBody>,
368
371
  ) -> impl axum::response::IntoResponse
369
372
  where
370
373
  S: Server + Clone + Send + Sync + 'static,
371
374
  S::Claims: Send + Sync + Clone + 'static,
372
375
  {
373
- let result = service.groups_update(claims, id, payload).await;
376
+ let result = service.groups_update(claims, account_id, id, payload).await;
374
377
  match result {
375
378
  Ok(response) => response.into_response(),
376
379
  Err(e) => (
@@ -384,13 +387,13 @@ where
384
387
  pub async fn groups_delete_handler<S>(
385
388
  axum::extract::State(service): axum::extract::State<S>,
386
389
  Extension(claims): Extension<S::Claims>,
387
- Path(id): Path<i64>,
390
+ Path((account_id, id)): Path<(uuid::Uuid, i64)>,
388
391
  ) -> impl axum::response::IntoResponse
389
392
  where
390
393
  S: Server + Clone + Send + Sync + 'static,
391
394
  S::Claims: Send + Sync + Clone + 'static,
392
395
  {
393
- let result = service.groups_delete(claims, id).await;
396
+ let result = service.groups_delete(claims, account_id, id).await;
394
397
  match result {
395
398
  Ok(response) => response.into_response(),
396
399
  Err(e) => (
@@ -403,13 +406,13 @@ where
403
406
 
404
407
  pub async fn subjects_list_handler<S>(
405
408
  axum::extract::State(service): axum::extract::State<S>,
406
- Path(group_id): Path<i64>,
409
+ Path((account_id, group_id)): Path<(uuid::Uuid, i64)>,
407
410
  ) -> impl axum::response::IntoResponse
408
411
  where
409
412
  S: Server + Clone + Send + Sync + 'static,
410
413
  S::Claims: Send + Sync + Clone + 'static,
411
414
  {
412
- let result = service.subjects_list(group_id).await;
415
+ let result = service.subjects_list(account_id, group_id).await;
413
416
  match result {
414
417
  Ok(response) => response.into_response(),
415
418
  Err(e) => (
@@ -423,14 +426,14 @@ where
423
426
  pub async fn subjects_create_handler<S>(
424
427
  axum::extract::State(service): axum::extract::State<S>,
425
428
  Extension(claims): Extension<S::Claims>,
426
- Path(group_id): Path<i64>,
429
+ Path((account_id, group_id)): Path<(uuid::Uuid, i64)>,
427
430
  Json(payload): Json<CreateSubjectBody>,
428
431
  ) -> impl axum::response::IntoResponse
429
432
  where
430
433
  S: Server + Clone + Send + Sync + 'static,
431
434
  S::Claims: Send + Sync + Clone + 'static,
432
435
  {
433
- let result = service.subjects_create(claims, group_id, payload).await;
436
+ let result = service.subjects_create(claims, account_id, group_id, payload).await;
434
437
  match result {
435
438
  Ok(response) => response.into_response(),
436
439
  Err(e) => (
@@ -443,13 +446,13 @@ where
443
446
 
444
447
  pub async fn subjects_get_by_id_handler<S>(
445
448
  axum::extract::State(service): axum::extract::State<S>,
446
- Path((group_id, id)): Path<(i64, i64)>,
449
+ Path((account_id, group_id, id)): Path<(uuid::Uuid, i64, i64)>,
447
450
  ) -> impl axum::response::IntoResponse
448
451
  where
449
452
  S: Server + Clone + Send + Sync + 'static,
450
453
  S::Claims: Send + Sync + Clone + 'static,
451
454
  {
452
- let result = service.subjects_get_by_id(group_id, id).await;
455
+ let result = service.subjects_get_by_id(account_id, group_id, id).await;
453
456
  match result {
454
457
  Ok(response) => response.into_response(),
455
458
  Err(e) => (
@@ -463,14 +466,14 @@ where
463
466
  pub async fn subjects_update_handler<S>(
464
467
  axum::extract::State(service): axum::extract::State<S>,
465
468
  Extension(claims): Extension<S::Claims>,
466
- Path((group_id, id)): Path<(i64, i64)>,
469
+ Path((account_id, group_id, id)): Path<(uuid::Uuid, i64, i64)>,
467
470
  Json(payload): Json<UpdateSubjectBody>,
468
471
  ) -> impl axum::response::IntoResponse
469
472
  where
470
473
  S: Server + Clone + Send + Sync + 'static,
471
474
  S::Claims: Send + Sync + Clone + 'static,
472
475
  {
473
- let result = service.subjects_update(claims, group_id, id, payload).await;
476
+ let result = service.subjects_update(claims, account_id, group_id, id, payload).await;
474
477
  match result {
475
478
  Ok(response) => response.into_response(),
476
479
  Err(e) => (
@@ -484,13 +487,13 @@ where
484
487
  pub async fn subjects_delete_handler<S>(
485
488
  axum::extract::State(service): axum::extract::State<S>,
486
489
  Extension(claims): Extension<S::Claims>,
487
- Path((group_id, id)): Path<(i64, i64)>,
490
+ Path((account_id, group_id, id)): Path<(uuid::Uuid, i64, i64)>,
488
491
  ) -> impl axum::response::IntoResponse
489
492
  where
490
493
  S: Server + Clone + Send + Sync + 'static,
491
494
  S::Claims: Send + Sync + Clone + 'static,
492
495
  {
493
- let result = service.subjects_delete(claims, group_id, id).await;
496
+ let result = service.subjects_delete(claims, account_id, group_id, id).await;
494
497
  match result {
495
498
  Ok(response) => response.into_response(),
496
499
  Err(e) => (
@@ -504,14 +507,14 @@ where
504
507
  pub async fn sessions_start_handler<S>(
505
508
  axum::extract::State(service): axum::extract::State<S>,
506
509
  Extension(claims): Extension<S::Claims>,
507
- Path(subject_id): Path<i64>,
510
+ Path((account_id, subject_id)): Path<(uuid::Uuid, i64)>,
508
511
  Json(payload): Json<SessionNoteBody>,
509
512
  ) -> impl axum::response::IntoResponse
510
513
  where
511
514
  S: Server + Clone + Send + Sync + 'static,
512
515
  S::Claims: Send + Sync + Clone + 'static,
513
516
  {
514
- let result = service.sessions_start(claims, subject_id, payload).await;
517
+ let result = service.sessions_start(claims, account_id, subject_id, payload).await;
515
518
  match result {
516
519
  Ok(response) => response.into_response(),
517
520
  Err(e) => (
@@ -525,13 +528,13 @@ where
525
528
  pub async fn sessions_pause_handler<S>(
526
529
  axum::extract::State(service): axum::extract::State<S>,
527
530
  Extension(claims): Extension<S::Claims>,
528
- Path((subject_id, log_id)): Path<(i64, i64)>,
531
+ Path((account_id, subject_id, log_id)): Path<(uuid::Uuid, i64, i64)>,
529
532
  ) -> impl axum::response::IntoResponse
530
533
  where
531
534
  S: Server + Clone + Send + Sync + 'static,
532
535
  S::Claims: Send + Sync + Clone + 'static,
533
536
  {
534
- let result = service.sessions_pause(claims, subject_id, log_id).await;
537
+ let result = service.sessions_pause(claims, account_id, subject_id, log_id).await;
535
538
  match result {
536
539
  Ok(response) => response.into_response(),
537
540
  Err(e) => (
@@ -545,13 +548,13 @@ where
545
548
  pub async fn sessions_resume_handler<S>(
546
549
  axum::extract::State(service): axum::extract::State<S>,
547
550
  Extension(claims): Extension<S::Claims>,
548
- Path((subject_id, log_id)): Path<(i64, i64)>,
551
+ Path((account_id, subject_id, log_id)): Path<(uuid::Uuid, i64, i64)>,
549
552
  ) -> impl axum::response::IntoResponse
550
553
  where
551
554
  S: Server + Clone + Send + Sync + 'static,
552
555
  S::Claims: Send + Sync + Clone + 'static,
553
556
  {
554
- let result = service.sessions_resume(claims, subject_id, log_id).await;
557
+ let result = service.sessions_resume(claims, account_id, subject_id, log_id).await;
555
558
  match result {
556
559
  Ok(response) => response.into_response(),
557
560
  Err(e) => (
@@ -565,14 +568,14 @@ where
565
568
  pub async fn sessions_stop_handler<S>(
566
569
  axum::extract::State(service): axum::extract::State<S>,
567
570
  Extension(claims): Extension<S::Claims>,
568
- Path((subject_id, log_id)): Path<(i64, i64)>,
571
+ Path((account_id, subject_id, log_id)): Path<(uuid::Uuid, i64, i64)>,
569
572
  Json(payload): Json<SessionNoteBody>,
570
573
  ) -> impl axum::response::IntoResponse
571
574
  where
572
575
  S: Server + Clone + Send + Sync + 'static,
573
576
  S::Claims: Send + Sync + Clone + 'static,
574
577
  {
575
- let result = service.sessions_stop(claims, subject_id, log_id, payload).await;
578
+ let result = service.sessions_stop(claims, account_id, subject_id, log_id, payload).await;
576
579
  match result {
577
580
  Ok(response) => response.into_response(),
578
581
  Err(e) => (
@@ -591,24 +594,24 @@ where
591
594
  {
592
595
  let mut router = Router::new();
593
596
  let public = Router::new()
594
- .route("/groups", get(groups_list_handler::<S>))
595
- .route("/groups/{id}", get(groups_get_by_id_handler::<S>))
596
- .route("/groups/{groupId}/subjects", get(subjects_list_handler::<S>))
597
- .route("/groups/{groupId}/subjects/{id}", get(subjects_get_by_id_handler::<S>))
597
+ .route("/accounts/{accountId}/learning/groups", get(groups_list_handler::<S>))
598
+ .route("/accounts/{accountId}/learning/groups/{id}", get(groups_get_by_id_handler::<S>))
599
+ .route("/accounts/{accountId}/learning/groups/{groupId}/subjects", get(subjects_list_handler::<S>))
600
+ .route("/accounts/{accountId}/learning/groups/{groupId}/subjects/{id}", get(subjects_get_by_id_handler::<S>))
598
601
  ;
599
602
  router = router.merge(public);
600
603
  let protected = Router::new()
601
- .route("/groups", post(groups_create_handler::<S>))
602
- .route("/groups/{id}", patch(groups_update_handler::<S>))
603
- .route("/groups/{id}", delete(groups_delete_handler::<S>))
604
- .route("/groups/{groupId}/subjects", post(subjects_create_handler::<S>))
605
- .route("/groups/{groupId}/subjects/{id}", patch(subjects_update_handler::<S>))
606
- .route("/groups/{groupId}/subjects/{id}", delete(subjects_delete_handler::<S>))
607
- .route("/subjects/{subjectId}/sessions", post(sessions_start_handler::<S>))
608
- .route("/subjects/{subjectId}/sessions/{logId}/pause", post(sessions_pause_handler::<S>))
609
- .route("/subjects/{subjectId}/sessions/{logId}/resume", post(sessions_resume_handler::<S>))
610
- .route("/subjects/{subjectId}/sessions/{logId}/stop", post(sessions_stop_handler::<S>))
604
+ .route("/accounts/{accountId}/learning/groups", post(groups_create_handler::<S>))
605
+ .route("/accounts/{accountId}/learning/groups/{id}", patch(groups_update_handler::<S>))
606
+ .route("/accounts/{accountId}/learning/groups/{id}", delete(groups_delete_handler::<S>))
607
+ .route("/accounts/{accountId}/learning/groups/{groupId}/subjects", post(subjects_create_handler::<S>))
608
+ .route("/accounts/{accountId}/learning/groups/{groupId}/subjects/{id}", patch(subjects_update_handler::<S>))
609
+ .route("/accounts/{accountId}/learning/groups/{groupId}/subjects/{id}", delete(subjects_delete_handler::<S>))
610
+ .route("/accounts/{accountId}/learning/subjects/{subjectId}/sessions", post(sessions_start_handler::<S>))
611
+ .route("/accounts/{accountId}/learning/subjects/{subjectId}/sessions/{logId}/pause", post(sessions_pause_handler::<S>))
612
+ .route("/accounts/{accountId}/learning/subjects/{subjectId}/sessions/{logId}/resume", post(sessions_resume_handler::<S>))
613
+ .route("/accounts/{accountId}/learning/subjects/{subjectId}/sessions/{logId}/stop", post(sessions_stop_handler::<S>))
611
614
  ;
612
615
  router = router.merge(middleware(protected));
613
616
  router.with_state(service)
614
- }
617
+ }
@@ -1,3 +1,5 @@
1
+ #![allow(unused)]
2
+
1
3
  #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, thiserror::Error)]
2
4
  #[error("{code}: {message}")]
3
5
  pub struct ApiError {
@@ -291,3 +293,4 @@ impl Default for HexColor {
291
293
  Self(String::new())
292
294
  }
293
295
  }
296
+
@@ -17,7 +17,7 @@
17
17
  }
18
18
  },
19
19
  "..": {
20
- "version": "0.5.0",
20
+ "version": "0.6.0",
21
21
  "license": "MIT",
22
22
  "devDependencies": {
23
23
  "@types/node": "latest",