typespec-rust-emitter 0.4.0 → 0.6.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.
- package/CHANGELOG.md +66 -0
- package/README.md +9 -4
- package/dist/src/emitter.js +47 -19
- package/dist/src/emitter.js.map +1 -1
- package/example/lib/learning/operations.tsp +27 -13
- package/example/output-rust/src/generated/server.rs +59 -56
- package/example/output-rust/src/generated/types.rs +15 -12
- package/example/package-lock.json +1 -1
- package/package.json +1 -1
- package/src/emitter.ts +61 -26
|
@@ -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,41 +13,41 @@ 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>>),
|
|
@@ -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 {
|
|
@@ -49,9 +51,9 @@ pub struct Group {
|
|
|
49
51
|
#[serde(rename = "accountId")]
|
|
50
52
|
pub account_id: uuid::Uuid,
|
|
51
53
|
#[serde(rename = "createdAt")]
|
|
52
|
-
pub created_at:
|
|
54
|
+
pub created_at: chrono::DateTime<chrono::Utc>,
|
|
53
55
|
#[serde(rename = "deletedAt")]
|
|
54
|
-
pub deleted_at: Option<
|
|
56
|
+
pub deleted_at: Option<chrono::DateTime<chrono::Utc>>,
|
|
55
57
|
pub name: String,
|
|
56
58
|
pub icon: String,
|
|
57
59
|
#[serde(rename = "colorText")]
|
|
@@ -66,9 +68,9 @@ pub struct GroupStatistics {
|
|
|
66
68
|
#[serde(rename = "accountId")]
|
|
67
69
|
pub account_id: uuid::Uuid,
|
|
68
70
|
#[serde(rename = "createdAt")]
|
|
69
|
-
pub created_at:
|
|
71
|
+
pub created_at: chrono::DateTime<chrono::Utc>,
|
|
70
72
|
#[serde(rename = "deletedAt")]
|
|
71
|
-
pub deleted_at: Option<
|
|
73
|
+
pub deleted_at: Option<chrono::DateTime<chrono::Utc>>,
|
|
72
74
|
pub name: String,
|
|
73
75
|
pub icon: String,
|
|
74
76
|
#[serde(rename = "colorText")]
|
|
@@ -120,9 +122,9 @@ pub struct Subject {
|
|
|
120
122
|
#[serde(rename = "groupId")]
|
|
121
123
|
pub group_id: i64,
|
|
122
124
|
#[serde(rename = "createdAt")]
|
|
123
|
-
pub created_at:
|
|
125
|
+
pub created_at: chrono::DateTime<chrono::Utc>,
|
|
124
126
|
#[serde(rename = "deletedAt")]
|
|
125
|
-
pub deleted_at: Option<
|
|
127
|
+
pub deleted_at: Option<chrono::DateTime<chrono::Utc>>,
|
|
126
128
|
pub name: String,
|
|
127
129
|
pub icon: String,
|
|
128
130
|
#[serde(rename = "colorText")]
|
|
@@ -139,9 +141,9 @@ pub struct SubjectStatistics {
|
|
|
139
141
|
#[serde(rename = "groupId")]
|
|
140
142
|
pub group_id: i64,
|
|
141
143
|
#[serde(rename = "createdAt")]
|
|
142
|
-
pub created_at:
|
|
144
|
+
pub created_at: chrono::DateTime<chrono::Utc>,
|
|
143
145
|
#[serde(rename = "deletedAt")]
|
|
144
|
-
pub deleted_at: Option<
|
|
146
|
+
pub deleted_at: Option<chrono::DateTime<chrono::Utc>>,
|
|
145
147
|
pub name: String,
|
|
146
148
|
pub icon: String,
|
|
147
149
|
#[serde(rename = "colorText")]
|
|
@@ -191,9 +193,9 @@ pub struct Log {
|
|
|
191
193
|
#[serde(rename = "subjectId")]
|
|
192
194
|
pub subject_id: i64,
|
|
193
195
|
#[serde(rename = "startedAt")]
|
|
194
|
-
pub started_at:
|
|
196
|
+
pub started_at: chrono::DateTime<chrono::Utc>,
|
|
195
197
|
#[serde(rename = "stoppedAt")]
|
|
196
|
-
pub stopped_at: Option<
|
|
198
|
+
pub stopped_at: Option<chrono::DateTime<chrono::Utc>>,
|
|
197
199
|
#[serde(rename = "logContent")]
|
|
198
200
|
pub log_content: Option<String>,
|
|
199
201
|
pub status: StudyStatus,
|
|
@@ -209,9 +211,9 @@ pub struct Timelog {
|
|
|
209
211
|
#[serde(rename = "subjectId")]
|
|
210
212
|
pub subject_id: i64,
|
|
211
213
|
#[serde(rename = "startedAt")]
|
|
212
|
-
pub started_at:
|
|
214
|
+
pub started_at: chrono::DateTime<chrono::Utc>,
|
|
213
215
|
#[serde(rename = "stoppedAt")]
|
|
214
|
-
pub stopped_at: Option<
|
|
216
|
+
pub stopped_at: Option<chrono::DateTime<chrono::Utc>>,
|
|
215
217
|
#[serde(rename = "durationInSeconds")]
|
|
216
218
|
pub duration_in_seconds: i64,
|
|
217
219
|
}
|
|
@@ -291,3 +293,4 @@ impl Default for HexColor {
|
|
|
291
293
|
Self(String::new())
|
|
292
294
|
}
|
|
293
295
|
}
|
|
296
|
+
|