typespec-rust-emitter 0.2.0 → 0.4.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.
@@ -136,5 +136,83 @@ describe("Rust emitter", () => {
136
136
  const output = results["types.rs"];
137
137
  strictEqual(output.includes("#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]"), true);
138
138
  });
139
+ it("emits custom rustDerive on enum", async () => {
140
+ const results = await emit(`
141
+ import "typespec-rust-emitter";
142
+
143
+ @rustDerive("strum::Display")
144
+ enum Status {
145
+ active,
146
+ inactive,
147
+ }
148
+ `);
149
+ const output = results["types.rs"];
150
+ strictEqual(output.includes("#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, strum::Display)]"), true);
151
+ });
152
+ it("emits multiple rustDerive macros on enum via $rustDerives", async () => {
153
+ const results = await emit(`
154
+ import "typespec-rust-emitter";
155
+
156
+ @rustDerives("strum::Display", "strum::EnumString")
157
+ enum Priority {
158
+ low,
159
+ high,
160
+ }
161
+ `);
162
+ const output = results["types.rs"];
163
+ strictEqual(output.includes("#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, strum::Display, strum::EnumString)]"), true);
164
+ });
165
+ it("emits custom rustAttr on model", async () => {
166
+ const results = await emit(`
167
+ import "typespec-rust-emitter";
168
+
169
+ @rustAttr("sqlx(type_name = \\"user\\")")
170
+ model User {
171
+ name: string;
172
+ }
173
+ `);
174
+ const output = results["types.rs"];
175
+ strictEqual(output.includes('#[sqlx(type_name = "user")]'), true);
176
+ });
177
+ it("emits multiple rustAttrs on model via $rustAttrs", async () => {
178
+ const results = await emit(`
179
+ import "typespec-rust-emitter";
180
+
181
+ @rustAttrs("sqlx(type_name = \\"user\\")", "cfg_attr(feature = \\"test\\", derive(Debug))")
182
+ model Person {
183
+ name: string;
184
+ }
185
+ `);
186
+ const output = results["types.rs"];
187
+ strictEqual(output.includes('#[sqlx(type_name = "user")]'), true);
188
+ strictEqual(output.includes('#[cfg_attr(feature = "test", derive(Debug))]'), true);
189
+ });
190
+ it("emits custom rustAttr on enum", async () => {
191
+ const results = await emit(`
192
+ import "typespec-rust-emitter";
193
+
194
+ @rustAttr("sqlx(type_name = \\"study_status\\")")
195
+ enum Status {
196
+ active,
197
+ inactive,
198
+ }
199
+ `);
200
+ const output = results["types.rs"];
201
+ strictEqual(output.includes('#[sqlx(type_name = "study_status")]'), true);
202
+ });
203
+ it("emits multiple rustAttrs on enum via $rustAttrs", async () => {
204
+ const results = await emit(`
205
+ import "typespec-rust-emitter";
206
+
207
+ @rustAttrs("sqlx(type_name = \\"priority\\")", "cfg_attr(feature = \\"test\\", derive(Debug))")
208
+ enum Priority {
209
+ low,
210
+ high,
211
+ }
212
+ `);
213
+ const output = results["types.rs"];
214
+ strictEqual(output.includes('#[sqlx(type_name = "priority")]'), true);
215
+ strictEqual(output.includes('#[cfg_attr(feature = "test", derive(Debug))]'), true);
216
+ });
139
217
  });
140
218
  //# sourceMappingURL=hello.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hello.test.js","sourceRoot":"","sources":["../../test/hello.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;QACjC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC;;;;;KAK1B,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACnC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC,CAAC;QACtD,WAAW,CAAC,MAAM,CAAC,QAAQ,C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E,KAAK,IAAI,EAAE;QAChE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC;;;;;;;KAO1B,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACnC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,6BAA6B,CAAC,EAAE,IAAI,CAAC,CAAC;QAClE,WAAW,CACT,MAAM,CAAC,QAAQ,CAAC,8CAA8C,CAAC,EAC/D,IAAI,CACL,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;QAC7C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC;;;;;;;;KAQ1B,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACnC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,qCAAqC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;QAC/D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC;;;;;;;;KAQ1B,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACnC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,iCAAiC,CAAC,EAAE,IAAI,CAAC,CAAC;QACtE,WAAW,CACT,MAAM,CAAC,QAAQ,CAAC,8CAA8C,CAAC,EAC/D,IAAI,CACL,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -30,6 +30,8 @@ namespace Mtlkms.Learning.Models {
30
30
  @pattern("^#[0-9A-Fa-f]{6}$")
31
31
  scalar HexColor extends string;
32
32
 
33
+ @rustDerive("sqlx::Type")
34
+ @rustAttr("sqlx(type_name = \"study_status\")")
33
35
  enum StudyStatus {
34
36
  Starting: "Starting",
35
37
  Paused: "Paused",
@@ -983,6 +983,7 @@ dependencies = [
983
983
  "serde",
984
984
  "serde_json",
985
985
  "sqlx",
986
+ "strum",
986
987
  "thiserror",
987
988
  "tokio",
988
989
  "tower",
@@ -1615,6 +1616,27 @@ dependencies = [
1615
1616
  "unicode-properties",
1616
1617
  ]
1617
1618
 
1619
+ [[package]]
1620
+ name = "strum"
1621
+ version = "0.27.2"
1622
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1623
+ checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf"
1624
+ dependencies = [
1625
+ "strum_macros",
1626
+ ]
1627
+
1628
+ [[package]]
1629
+ name = "strum_macros"
1630
+ version = "0.27.2"
1631
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1632
+ checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7"
1633
+ dependencies = [
1634
+ "heck",
1635
+ "proc-macro2",
1636
+ "quote",
1637
+ "syn",
1638
+ ]
1639
+
1618
1640
  [[package]]
1619
1641
  name = "subtle"
1620
1642
  version = "2.6.1"
@@ -17,3 +17,4 @@ tokio = { version = "1.50.0", features = ["full"] }
17
17
  chrono = { version = "0.4.44", features = ["serde"] }
18
18
  tower = "0.5"
19
19
  tower-http = { version = "0.6", features = ["auth"] }
20
+ strum = { version = "0.27", features = ["derive"] }
@@ -1,6 +1,8 @@
1
1
  use super::types::*;
2
2
  use async_trait::async_trait;
3
3
  use axum::{http::StatusCode, Json};
4
+ use axum::extract::Path;
5
+ use axum::Extension;
4
6
  use eyre::Result;
5
7
 
6
8
  #[async_trait]
@@ -9,147 +11,42 @@ pub trait Server: Send + Sync {
9
11
 
10
12
 
11
13
  /// Retrieve a list of all groups for the current account (from view_learning_group).
12
- async fn groups_list(&self, request: GroupsListRequest) -> Result<GroupsListResponse>;
14
+ async fn groups_list(&self) -> Result<GroupsListResponse>;
13
15
  /// Create a new group.
14
- async fn groups_create(&self, claims: Self::Claims, request: GroupsCreateRequest) -> Result<GroupsCreateResponse>;
16
+ async fn groups_create(&self, claims: Self::Claims, body: CreateGroupBody) -> Result<GroupsCreateResponse>;
15
17
  /// Get the details of a group by its ID.
16
- async fn groups_get_by_id(&self, request: GroupsGetByIdRequest) -> Result<GroupsGetByIdResponse>;
18
+ async fn groups_get_by_id(&self, id: i64) -> Result<GroupsGetByIdResponse>;
17
19
  /// Update a group. Only provide the fields that need to be changed.
18
- async fn groups_update(&self, claims: Self::Claims, request: GroupsUpdateRequest) -> Result<GroupsUpdateResponse>;
20
+ async fn groups_update(&self, claims: Self::Claims, id: i64, body: UpdateGroupBody) -> Result<GroupsUpdateResponse>;
19
21
  /// Soft delete a group. All subjects within the group will also be soft deleted.
20
- async fn groups_delete(&self, claims: Self::Claims, request: GroupsDeleteRequest) -> Result<GroupsDeleteResponse>;
22
+ async fn groups_delete(&self, claims: Self::Claims, id: i64) -> Result<GroupsDeleteResponse>;
21
23
  /// Retrieve a list of subjects for a group (from view_subject_statistics).
22
- async fn subjects_list(&self, request: SubjectsListRequest) -> Result<SubjectsListResponse>;
24
+ async fn subjects_list(&self, group_id: i64) -> Result<SubjectsListResponse>;
23
25
  /// Create a new subject within the specified group.
24
- async fn subjects_create(&self, claims: Self::Claims, request: SubjectsCreateRequest) -> Result<SubjectsCreateResponse>;
26
+ async fn subjects_create(&self, claims: Self::Claims, group_id: i64, body: CreateSubjectBody) -> Result<SubjectsCreateResponse>;
25
27
  /// Get the details of a subject by its ID.
26
- async fn subjects_get_by_id(&self, request: SubjectsGetByIdRequest) -> Result<SubjectsGetByIdResponse>;
28
+ async fn subjects_get_by_id(&self, group_id: i64, id: i64) -> Result<SubjectsGetByIdResponse>;
27
29
  /// Update a subject. Only provide the fields that need to be changed.
28
- async fn subjects_update(&self, claims: Self::Claims, request: SubjectsUpdateRequest) -> Result<SubjectsUpdateResponse>;
30
+ async fn subjects_update(&self, claims: Self::Claims, group_id: i64, id: i64, body: UpdateSubjectBody) -> Result<SubjectsUpdateResponse>;
29
31
  /// Soft delete a subject.
30
- async fn subjects_delete(&self, claims: Self::Claims, request: SubjectsDeleteRequest) -> Result<SubjectsDeleteResponse>;
32
+ async fn subjects_delete(&self, claims: Self::Claims, group_id: i64, id: i64) -> Result<SubjectsDeleteResponse>;
31
33
  /// Start a new study session for the subject.
32
34
  /// The server creates a Log (status=Starting) and the first Timelog.
33
35
  /// Returns 409 if the subject already has a session in Starting or Paused status.
34
- async fn sessions_start(&self, claims: Self::Claims, request: SessionsStartRequest) -> Result<SessionsStartResponse>;
36
+ async fn sessions_start(&self, claims: Self::Claims, subject_id: i64, body: SessionNoteBody) -> Result<SessionsStartResponse>;
35
37
  /// Pause the currently running session (transition from Starting to Paused).
36
38
  /// The server closes the current Timelog (sets stoppedAt and calculates durationInSeconds).
37
39
  /// Returns 409 if the session is not in the Starting state.
38
- async fn sessions_pause(&self, claims: Self::Claims, request: SessionsPauseRequest) -> Result<SessionsPauseResponse>;
40
+ async fn sessions_pause(&self, claims: Self::Claims, subject_id: i64, log_id: i64) -> Result<SessionsPauseResponse>;
39
41
  /// Resume a paused session (transition from Paused to Starting).
40
42
  /// The server creates a new Timelog.
41
43
  /// Returns 409 if the session is not in the Paused state.
42
- async fn sessions_resume(&self, claims: Self::Claims, request: SessionsResumeRequest) -> Result<SessionsResumeResponse>;
44
+ async fn sessions_resume(&self, claims: Self::Claims, subject_id: i64, log_id: i64) -> Result<SessionsResumeResponse>;
43
45
  /// End the session (transition from Starting or Paused to Stopped).
44
46
  /// The server closes the current Timelog if it is running, and updates Log.stoppedAt.
45
47
  /// Returns 409 if the session is already Stopped.
46
- async fn sessions_stop(&self, claims: Self::Claims, request: SessionsStopRequest) -> Result<SessionsStopResponse>;
48
+ async fn sessions_stop(&self, claims: Self::Claims, subject_id: i64, log_id: i64, body: SessionNoteBody) -> Result<SessionsStopResponse>;
47
49
  }
48
- #[derive(Debug, Clone, serde::Deserialize)]
49
- pub struct GroupsListRequest {
50
-
51
- }
52
-
53
- #[derive(Debug, Clone, serde::Deserialize)]
54
- pub struct GroupsCreateRequest {
55
- #[serde(rename = "body", flatten)]
56
- pub body: CreateGroupBody,
57
- }
58
-
59
- #[derive(Debug, Clone, serde::Deserialize)]
60
- pub struct GroupsGetByIdRequest {
61
- #[serde(rename = "id", flatten)]
62
- pub id: i64,
63
- }
64
-
65
- #[derive(Debug, Clone, serde::Deserialize)]
66
- pub struct GroupsUpdateRequest {
67
- #[serde(rename = "id", flatten)]
68
- pub id: i64,
69
- #[serde(rename = "body", flatten)]
70
- pub body: UpdateGroupBody,
71
- }
72
-
73
- #[derive(Debug, Clone, serde::Deserialize)]
74
- pub struct GroupsDeleteRequest {
75
- #[serde(rename = "id", flatten)]
76
- pub id: i64,
77
- }
78
-
79
- #[derive(Debug, Clone, serde::Deserialize)]
80
- pub struct SubjectsListRequest {
81
- #[serde(rename = "groupId", flatten)]
82
- pub group_id: i64,
83
- }
84
-
85
- #[derive(Debug, Clone, serde::Deserialize)]
86
- pub struct SubjectsCreateRequest {
87
- #[serde(rename = "groupId", flatten)]
88
- pub group_id: i64,
89
- #[serde(rename = "body", flatten)]
90
- pub body: CreateSubjectBody,
91
- }
92
-
93
- #[derive(Debug, Clone, serde::Deserialize)]
94
- pub struct SubjectsGetByIdRequest {
95
- #[serde(rename = "groupId", flatten)]
96
- pub group_id: i64,
97
- #[serde(rename = "id", flatten)]
98
- pub id: i64,
99
- }
100
-
101
- #[derive(Debug, Clone, serde::Deserialize)]
102
- pub struct SubjectsUpdateRequest {
103
- #[serde(rename = "groupId", flatten)]
104
- pub group_id: i64,
105
- #[serde(rename = "id", flatten)]
106
- pub id: i64,
107
- #[serde(rename = "body", flatten)]
108
- pub body: UpdateSubjectBody,
109
- }
110
-
111
- #[derive(Debug, Clone, serde::Deserialize)]
112
- pub struct SubjectsDeleteRequest {
113
- #[serde(rename = "groupId", flatten)]
114
- pub group_id: i64,
115
- #[serde(rename = "id", flatten)]
116
- pub id: i64,
117
- }
118
-
119
- #[derive(Debug, Clone, serde::Deserialize)]
120
- pub struct SessionsStartRequest {
121
- #[serde(rename = "subjectId", flatten)]
122
- pub subject_id: i64,
123
- #[serde(rename = "body", flatten)]
124
- pub body: SessionNoteBody,
125
- }
126
-
127
- #[derive(Debug, Clone, serde::Deserialize)]
128
- pub struct SessionsPauseRequest {
129
- #[serde(rename = "subjectId", flatten)]
130
- pub subject_id: i64,
131
- #[serde(rename = "logId", flatten)]
132
- pub log_id: i64,
133
- }
134
-
135
- #[derive(Debug, Clone, serde::Deserialize)]
136
- pub struct SessionsResumeRequest {
137
- #[serde(rename = "subjectId", flatten)]
138
- pub subject_id: i64,
139
- #[serde(rename = "logId", flatten)]
140
- pub log_id: i64,
141
- }
142
-
143
- #[derive(Debug, Clone, serde::Deserialize)]
144
- pub struct SessionsStopRequest {
145
- #[serde(rename = "subjectId", flatten)]
146
- pub subject_id: i64,
147
- #[serde(rename = "logId", flatten)]
148
- pub log_id: i64,
149
- #[serde(rename = "body", flatten)]
150
- pub body: SessionNoteBody,
151
- }
152
-
153
50
  pub enum GroupsListResponse {
154
51
  Ok(Json<Vec<GroupStatistics>>),
155
52
  Unauthorized,
@@ -413,7 +310,7 @@ where
413
310
  S: Server + Clone + Send + Sync + 'static,
414
311
  S::Claims: Send + Sync + Clone + 'static,
415
312
  {
416
- let result = service.groups_list(GroupsListRequest {}).await;
313
+ let result = service.groups_list().await;
417
314
  match result {
418
315
  Ok(response) => response.into_response(),
419
316
  Err(e) => (
@@ -426,14 +323,14 @@ where
426
323
 
427
324
  pub async fn groups_create_handler<S>(
428
325
  axum::extract::State(service): axum::extract::State<S>,
429
- axum::extract::Query(query): axum::extract::Query<GroupsCreateRequest>,
430
- axum::Extension(claims): axum::Extension<S::Claims>,
326
+ Extension(claims): Extension<S::Claims>,
327
+ Json(payload): Json<CreateGroupBody>,
431
328
  ) -> impl axum::response::IntoResponse
432
329
  where
433
330
  S: Server + Clone + Send + Sync + 'static,
434
331
  S::Claims: Send + Sync + Clone + 'static,
435
332
  {
436
- let result = service.groups_create(claims, query).await;
333
+ let result = service.groups_create(claims, payload).await;
437
334
  match result {
438
335
  Ok(response) => response.into_response(),
439
336
  Err(e) => (
@@ -446,13 +343,13 @@ where
446
343
 
447
344
  pub async fn groups_get_by_id_handler<S>(
448
345
  axum::extract::State(service): axum::extract::State<S>,
449
- axum::extract::Query(query): axum::extract::Query<GroupsGetByIdRequest>,
346
+ Path(id): Path<i64>,
450
347
  ) -> impl axum::response::IntoResponse
451
348
  where
452
349
  S: Server + Clone + Send + Sync + 'static,
453
350
  S::Claims: Send + Sync + Clone + 'static,
454
351
  {
455
- let result = service.groups_get_by_id(query).await;
352
+ let result = service.groups_get_by_id(id).await;
456
353
  match result {
457
354
  Ok(response) => response.into_response(),
458
355
  Err(e) => (
@@ -465,14 +362,15 @@ where
465
362
 
466
363
  pub async fn groups_update_handler<S>(
467
364
  axum::extract::State(service): axum::extract::State<S>,
468
- axum::extract::Query(query): axum::extract::Query<GroupsUpdateRequest>,
469
- axum::Extension(claims): axum::Extension<S::Claims>,
365
+ Extension(claims): Extension<S::Claims>,
366
+ Path(id): Path<i64>,
367
+ Json(payload): Json<UpdateGroupBody>,
470
368
  ) -> impl axum::response::IntoResponse
471
369
  where
472
370
  S: Server + Clone + Send + Sync + 'static,
473
371
  S::Claims: Send + Sync + Clone + 'static,
474
372
  {
475
- let result = service.groups_update(claims, query).await;
373
+ let result = service.groups_update(claims, id, payload).await;
476
374
  match result {
477
375
  Ok(response) => response.into_response(),
478
376
  Err(e) => (
@@ -485,14 +383,14 @@ where
485
383
 
486
384
  pub async fn groups_delete_handler<S>(
487
385
  axum::extract::State(service): axum::extract::State<S>,
488
- axum::extract::Query(query): axum::extract::Query<GroupsDeleteRequest>,
489
- axum::Extension(claims): axum::Extension<S::Claims>,
386
+ Extension(claims): Extension<S::Claims>,
387
+ Path(id): Path<i64>,
490
388
  ) -> impl axum::response::IntoResponse
491
389
  where
492
390
  S: Server + Clone + Send + Sync + 'static,
493
391
  S::Claims: Send + Sync + Clone + 'static,
494
392
  {
495
- let result = service.groups_delete(claims, query).await;
393
+ let result = service.groups_delete(claims, id).await;
496
394
  match result {
497
395
  Ok(response) => response.into_response(),
498
396
  Err(e) => (
@@ -505,13 +403,13 @@ where
505
403
 
506
404
  pub async fn subjects_list_handler<S>(
507
405
  axum::extract::State(service): axum::extract::State<S>,
508
- axum::extract::Query(query): axum::extract::Query<SubjectsListRequest>,
406
+ Path(group_id): Path<i64>,
509
407
  ) -> impl axum::response::IntoResponse
510
408
  where
511
409
  S: Server + Clone + Send + Sync + 'static,
512
410
  S::Claims: Send + Sync + Clone + 'static,
513
411
  {
514
- let result = service.subjects_list(query).await;
412
+ let result = service.subjects_list(group_id).await;
515
413
  match result {
516
414
  Ok(response) => response.into_response(),
517
415
  Err(e) => (
@@ -524,14 +422,15 @@ where
524
422
 
525
423
  pub async fn subjects_create_handler<S>(
526
424
  axum::extract::State(service): axum::extract::State<S>,
527
- axum::extract::Query(query): axum::extract::Query<SubjectsCreateRequest>,
528
- axum::Extension(claims): axum::Extension<S::Claims>,
425
+ Extension(claims): Extension<S::Claims>,
426
+ Path(group_id): Path<i64>,
427
+ Json(payload): Json<CreateSubjectBody>,
529
428
  ) -> impl axum::response::IntoResponse
530
429
  where
531
430
  S: Server + Clone + Send + Sync + 'static,
532
431
  S::Claims: Send + Sync + Clone + 'static,
533
432
  {
534
- let result = service.subjects_create(claims, query).await;
433
+ let result = service.subjects_create(claims, group_id, payload).await;
535
434
  match result {
536
435
  Ok(response) => response.into_response(),
537
436
  Err(e) => (
@@ -544,13 +443,13 @@ where
544
443
 
545
444
  pub async fn subjects_get_by_id_handler<S>(
546
445
  axum::extract::State(service): axum::extract::State<S>,
547
- axum::extract::Query(query): axum::extract::Query<SubjectsGetByIdRequest>,
446
+ Path((group_id, id)): Path<(i64, i64)>,
548
447
  ) -> impl axum::response::IntoResponse
549
448
  where
550
449
  S: Server + Clone + Send + Sync + 'static,
551
450
  S::Claims: Send + Sync + Clone + 'static,
552
451
  {
553
- let result = service.subjects_get_by_id(query).await;
452
+ let result = service.subjects_get_by_id(group_id, id).await;
554
453
  match result {
555
454
  Ok(response) => response.into_response(),
556
455
  Err(e) => (
@@ -563,14 +462,15 @@ where
563
462
 
564
463
  pub async fn subjects_update_handler<S>(
565
464
  axum::extract::State(service): axum::extract::State<S>,
566
- axum::extract::Query(query): axum::extract::Query<SubjectsUpdateRequest>,
567
- axum::Extension(claims): axum::Extension<S::Claims>,
465
+ Extension(claims): Extension<S::Claims>,
466
+ Path((group_id, id)): Path<(i64, i64)>,
467
+ Json(payload): Json<UpdateSubjectBody>,
568
468
  ) -> impl axum::response::IntoResponse
569
469
  where
570
470
  S: Server + Clone + Send + Sync + 'static,
571
471
  S::Claims: Send + Sync + Clone + 'static,
572
472
  {
573
- let result = service.subjects_update(claims, query).await;
473
+ let result = service.subjects_update(claims, group_id, id, payload).await;
574
474
  match result {
575
475
  Ok(response) => response.into_response(),
576
476
  Err(e) => (
@@ -583,14 +483,14 @@ where
583
483
 
584
484
  pub async fn subjects_delete_handler<S>(
585
485
  axum::extract::State(service): axum::extract::State<S>,
586
- axum::extract::Query(query): axum::extract::Query<SubjectsDeleteRequest>,
587
- axum::Extension(claims): axum::Extension<S::Claims>,
486
+ Extension(claims): Extension<S::Claims>,
487
+ Path((group_id, id)): Path<(i64, i64)>,
588
488
  ) -> impl axum::response::IntoResponse
589
489
  where
590
490
  S: Server + Clone + Send + Sync + 'static,
591
491
  S::Claims: Send + Sync + Clone + 'static,
592
492
  {
593
- let result = service.subjects_delete(claims, query).await;
493
+ let result = service.subjects_delete(claims, group_id, id).await;
594
494
  match result {
595
495
  Ok(response) => response.into_response(),
596
496
  Err(e) => (
@@ -603,14 +503,15 @@ where
603
503
 
604
504
  pub async fn sessions_start_handler<S>(
605
505
  axum::extract::State(service): axum::extract::State<S>,
606
- axum::extract::Query(query): axum::extract::Query<SessionsStartRequest>,
607
- axum::Extension(claims): axum::Extension<S::Claims>,
506
+ Extension(claims): Extension<S::Claims>,
507
+ Path(subject_id): Path<i64>,
508
+ Json(payload): Json<SessionNoteBody>,
608
509
  ) -> impl axum::response::IntoResponse
609
510
  where
610
511
  S: Server + Clone + Send + Sync + 'static,
611
512
  S::Claims: Send + Sync + Clone + 'static,
612
513
  {
613
- let result = service.sessions_start(claims, query).await;
514
+ let result = service.sessions_start(claims, subject_id, payload).await;
614
515
  match result {
615
516
  Ok(response) => response.into_response(),
616
517
  Err(e) => (
@@ -623,14 +524,14 @@ where
623
524
 
624
525
  pub async fn sessions_pause_handler<S>(
625
526
  axum::extract::State(service): axum::extract::State<S>,
626
- axum::extract::Query(query): axum::extract::Query<SessionsPauseRequest>,
627
- axum::Extension(claims): axum::Extension<S::Claims>,
527
+ Extension(claims): Extension<S::Claims>,
528
+ Path((subject_id, log_id)): Path<(i64, i64)>,
628
529
  ) -> impl axum::response::IntoResponse
629
530
  where
630
531
  S: Server + Clone + Send + Sync + 'static,
631
532
  S::Claims: Send + Sync + Clone + 'static,
632
533
  {
633
- let result = service.sessions_pause(claims, query).await;
534
+ let result = service.sessions_pause(claims, subject_id, log_id).await;
634
535
  match result {
635
536
  Ok(response) => response.into_response(),
636
537
  Err(e) => (
@@ -643,14 +544,14 @@ where
643
544
 
644
545
  pub async fn sessions_resume_handler<S>(
645
546
  axum::extract::State(service): axum::extract::State<S>,
646
- axum::extract::Query(query): axum::extract::Query<SessionsResumeRequest>,
647
- axum::Extension(claims): axum::Extension<S::Claims>,
547
+ Extension(claims): Extension<S::Claims>,
548
+ Path((subject_id, log_id)): Path<(i64, i64)>,
648
549
  ) -> impl axum::response::IntoResponse
649
550
  where
650
551
  S: Server + Clone + Send + Sync + 'static,
651
552
  S::Claims: Send + Sync + Clone + 'static,
652
553
  {
653
- let result = service.sessions_resume(claims, query).await;
554
+ let result = service.sessions_resume(claims, subject_id, log_id).await;
654
555
  match result {
655
556
  Ok(response) => response.into_response(),
656
557
  Err(e) => (
@@ -663,14 +564,15 @@ where
663
564
 
664
565
  pub async fn sessions_stop_handler<S>(
665
566
  axum::extract::State(service): axum::extract::State<S>,
666
- axum::extract::Query(query): axum::extract::Query<SessionsStopRequest>,
667
- axum::Extension(claims): axum::Extension<S::Claims>,
567
+ Extension(claims): Extension<S::Claims>,
568
+ Path((subject_id, log_id)): Path<(i64, i64)>,
569
+ Json(payload): Json<SessionNoteBody>,
668
570
  ) -> impl axum::response::IntoResponse
669
571
  where
670
572
  S: Server + Clone + Send + Sync + 'static,
671
573
  S::Claims: Send + Sync + Clone + 'static,
672
574
  {
673
- let result = service.sessions_stop(claims, query).await;
575
+ let result = service.sessions_stop(claims, subject_id, log_id, payload).await;
674
576
  match result {
675
577
  Ok(response) => response.into_response(),
676
578
  Err(e) => (
@@ -235,7 +235,8 @@ pub struct SessionNoteBody {
235
235
  pub log_content: Option<String>,
236
236
  }
237
237
 
238
- #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
238
+ #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, sqlx::Type)]
239
+ #[sqlx(type_name = "study_status")]
239
240
  pub enum StudyStatus {
240
241
  #[serde(rename = "Starting")]
241
242
  Starting,
@@ -17,8 +17,7 @@
17
17
  }
18
18
  },
19
19
  "..": {
20
- "name": "typespec-rust-emitter",
21
- "version": "0.1.0",
20
+ "version": "0.4.0",
22
21
  "license": "MIT",
23
22
  "devDependencies": {
24
23
  "@types/node": "latest",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typespec-rust-emitter",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "TypeSpec emitter that generates idiomatic Rust types and structs",
5
5
  "keywords": [
6
6
  "typespec",