typespec-rust-emitter 0.10.5 → 0.10.7
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 +13 -0
- package/dist/src/emitter.js +17 -3
- package/dist/src/emitter.js.map +1 -1
- package/dist/test/hello.test.js +1 -1
- package/dist/test/hello.test.js.map +1 -1
- package/example/main.tsp +30 -5
- package/example/output-rust/Cargo.lock +2 -0
- package/example/output-rust/Cargo.toml +2 -0
- package/example/output-rust/src/generated/server.rs +24 -627
- package/example/output-rust/src/generated/types.rs +3 -356
- package/example/output-rust/src/main.rs +114 -2
- package/example/package-lock.json +3 -1
- package/package.json +1 -1
- package/src/emitter.ts +28 -5
- package/test/hello.test.ts +1 -6
- package/example/lib/learning/models.tsp +0 -234
- package/example/lib/learning/operations.tsp +0 -364
- package/example/output-rust/src/mod.rs +0 -1
|
@@ -14,364 +14,61 @@ pub trait Server: Send + Sync {
|
|
|
14
14
|
type Claims: Send + Sync + 'static;
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
async fn
|
|
19
|
-
/// Get calendar heatmap data for a specific group by month.
|
|
20
|
-
async fn groups_calendar(&self, account_id: uuid::Uuid, group_id: uuid::Uuid, user_timezone: String, year: i32, month: i32) -> Result<GroupsCalendarResponse>;
|
|
21
|
-
/// Create a new group.
|
|
22
|
-
async fn groups_create(&self, claims: Self::Claims, account_id: uuid::Uuid, body: CreateGroupBody) -> Result<GroupsCreateResponse>;
|
|
23
|
-
/// Get the details of a group by its ID.
|
|
24
|
-
async fn groups_get_by_id(&self, account_id: uuid::Uuid, id: i64) -> Result<GroupsGetByIdResponse>;
|
|
25
|
-
/// Update a group. Only provide the fields that need to be changed.
|
|
26
|
-
async fn groups_update(&self, claims: Self::Claims, account_id: uuid::Uuid, id: i64, body: UpdateGroupBody) -> Result<GroupsUpdateResponse>;
|
|
27
|
-
/// Soft delete a group. All subjects within the group will also be soft deleted.
|
|
28
|
-
async fn groups_delete(&self, claims: Self::Claims, account_id: uuid::Uuid, id: i64) -> Result<GroupsDeleteResponse>;
|
|
29
|
-
/// Retrieve a list of subjects for a group (from view_subject_statistics).
|
|
30
|
-
async fn subjects_list(&self, account_id: uuid::Uuid, group_id: i64) -> Result<SubjectsListResponse>;
|
|
31
|
-
/// Create a new subject within the specified group.
|
|
32
|
-
async fn subjects_create(&self, claims: Self::Claims, account_id: uuid::Uuid, group_id: i64, body: CreateSubjectBody) -> Result<SubjectsCreateResponse>;
|
|
33
|
-
/// Get the details of a subject by its ID.
|
|
34
|
-
async fn subjects_get_by_id(&self, account_id: uuid::Uuid, group_id: i64, id: i64) -> Result<SubjectsGetByIdResponse>;
|
|
35
|
-
/// Update a subject. Only provide the fields that need to be changed.
|
|
36
|
-
async fn subjects_update(&self, claims: Self::Claims, account_id: uuid::Uuid, group_id: i64, id: i64, body: UpdateSubjectBody) -> Result<SubjectsUpdateResponse>;
|
|
37
|
-
/// Soft delete a subject.
|
|
38
|
-
async fn subjects_delete(&self, claims: Self::Claims, account_id: uuid::Uuid, group_id: i64, id: i64) -> Result<SubjectsDeleteResponse>;
|
|
39
|
-
/// Start a new study session for the subject.
|
|
40
|
-
/// The server creates a Log (status=Starting) and the first Timelog.
|
|
41
|
-
/// Returns 409 if the subject already has a session in Starting or Paused status.
|
|
42
|
-
async fn sessions_start(&self, claims: Self::Claims, account_id: uuid::Uuid, subject_id: i64, body: SessionNoteBody) -> Result<SessionsStartResponse>;
|
|
43
|
-
/// Pause the currently running session (transition from Starting to Paused).
|
|
44
|
-
/// The server closes the current Timelog (sets stoppedAt and calculates durationInSeconds).
|
|
45
|
-
/// Returns 409 if the session is not in the Starting state.
|
|
46
|
-
async fn sessions_pause(&self, claims: Self::Claims, account_id: uuid::Uuid, subject_id: i64, log_id: i64) -> Result<SessionsPauseResponse>;
|
|
47
|
-
/// Resume a paused session (transition from Paused to Starting).
|
|
48
|
-
/// The server creates a new Timelog.
|
|
49
|
-
/// Returns 409 if the session is not in the Paused state.
|
|
50
|
-
async fn sessions_resume(&self, claims: Self::Claims, account_id: uuid::Uuid, subject_id: i64, log_id: i64) -> Result<SessionsResumeResponse>;
|
|
51
|
-
/// End the session (transition from Starting or Paused to Stopped).
|
|
52
|
-
/// The server closes the current Timelog if it is running, and updates Log.stoppedAt.
|
|
53
|
-
/// Returns 409 if the session is already Stopped.
|
|
54
|
-
async fn sessions_stop(&self, claims: Self::Claims, account_id: uuid::Uuid, subject_id: i64, log_id: i64, body: SessionNoteBody) -> Result<SessionsStopResponse>;
|
|
55
|
-
/// Server-Sent Events stream for learning data changes.
|
|
56
|
-
async fn accounts_events(&self, account_id: uuid::Uuid) -> Result<AccountsEventsResponse>;
|
|
17
|
+
async fn events_accounts_events(&self, account_id: String) -> Result<EventsAccountsEventsResponse>;
|
|
18
|
+
async fn pets_list(&self, first_query: String, second_query: String) -> Result<PetsListResponse>;
|
|
57
19
|
}
|
|
58
20
|
#[allow(clippy::type_complexity)]
|
|
59
|
-
pub enum
|
|
60
|
-
Ok(
|
|
61
|
-
Unauthorized(Json<ApiError>),
|
|
21
|
+
pub enum EventsAccountsEventsResponse {
|
|
22
|
+
Ok(axum::response::Response),
|
|
62
23
|
}
|
|
63
24
|
|
|
64
|
-
impl IntoResponse for
|
|
25
|
+
impl IntoResponse for EventsAccountsEventsResponse {
|
|
65
26
|
fn into_response(self) -> axum::response::Response {
|
|
66
27
|
match self {
|
|
67
28
|
|
|
68
|
-
|
|
69
|
-
GroupsListResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
|
|
29
|
+
EventsAccountsEventsResponse::Ok(body) => body.into_response(),
|
|
70
30
|
}
|
|
71
31
|
}
|
|
72
32
|
}
|
|
73
33
|
|
|
74
34
|
#[allow(clippy::type_complexity)]
|
|
75
|
-
pub enum
|
|
76
|
-
Ok(Json<Vec<
|
|
77
|
-
Unauthorized(Json<ApiError>),
|
|
35
|
+
pub enum PetsListResponse {
|
|
36
|
+
Ok(Json<Vec<String>>),
|
|
78
37
|
}
|
|
79
38
|
|
|
80
|
-
impl IntoResponse for
|
|
39
|
+
impl IntoResponse for PetsListResponse {
|
|
81
40
|
fn into_response(self) -> axum::response::Response {
|
|
82
41
|
match self {
|
|
83
42
|
|
|
84
|
-
|
|
85
|
-
GroupsCalendarResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
#[allow(clippy::type_complexity)]
|
|
91
|
-
pub enum GroupsCreateResponse {
|
|
92
|
-
Created(Json<Group>),
|
|
93
|
-
BadRequest(Json<ValidationError>),
|
|
94
|
-
Unauthorized(Json<ApiError>),
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
impl IntoResponse for GroupsCreateResponse {
|
|
98
|
-
fn into_response(self) -> axum::response::Response {
|
|
99
|
-
match self {
|
|
100
|
-
|
|
101
|
-
GroupsCreateResponse::Created(body) => (StatusCode::CREATED, body).into_response(),
|
|
102
|
-
GroupsCreateResponse::BadRequest(body) => (StatusCode::BAD_REQUEST, body).into_response(),
|
|
103
|
-
GroupsCreateResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
#[allow(clippy::type_complexity)]
|
|
109
|
-
pub enum GroupsGetByIdResponse {
|
|
110
|
-
Ok(Json<GroupStatistics>),
|
|
111
|
-
Unauthorized(Json<ApiError>),
|
|
112
|
-
NotFound(Json<NotFoundError>),
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
impl IntoResponse for GroupsGetByIdResponse {
|
|
116
|
-
fn into_response(self) -> axum::response::Response {
|
|
117
|
-
match self {
|
|
118
|
-
|
|
119
|
-
GroupsGetByIdResponse::Ok(body) => (StatusCode::OK, body).into_response(),
|
|
120
|
-
GroupsGetByIdResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
|
|
121
|
-
GroupsGetByIdResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
#[allow(clippy::type_complexity)]
|
|
127
|
-
pub enum GroupsUpdateResponse {
|
|
128
|
-
Ok(Json<Group>),
|
|
129
|
-
BadRequest(Json<ValidationError>),
|
|
130
|
-
Unauthorized(Json<ApiError>),
|
|
131
|
-
NotFound(Json<NotFoundError>),
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
impl IntoResponse for GroupsUpdateResponse {
|
|
135
|
-
fn into_response(self) -> axum::response::Response {
|
|
136
|
-
match self {
|
|
137
|
-
|
|
138
|
-
GroupsUpdateResponse::Ok(body) => (StatusCode::OK, body).into_response(),
|
|
139
|
-
GroupsUpdateResponse::BadRequest(body) => (StatusCode::BAD_REQUEST, body).into_response(),
|
|
140
|
-
GroupsUpdateResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
|
|
141
|
-
GroupsUpdateResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
#[allow(clippy::type_complexity)]
|
|
147
|
-
pub enum GroupsDeleteResponse {
|
|
148
|
-
NoContent,
|
|
149
|
-
Unauthorized(Json<ApiError>),
|
|
150
|
-
NotFound(Json<NotFoundError>),
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
impl IntoResponse for GroupsDeleteResponse {
|
|
154
|
-
fn into_response(self) -> axum::response::Response {
|
|
155
|
-
match self {
|
|
156
|
-
|
|
157
|
-
GroupsDeleteResponse::NoContent => StatusCode::NO_CONTENT.into_response(),
|
|
158
|
-
GroupsDeleteResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
|
|
159
|
-
GroupsDeleteResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
#[allow(clippy::type_complexity)]
|
|
165
|
-
pub enum SubjectsListResponse {
|
|
166
|
-
Ok(Json<Vec<SubjectStatistics>>),
|
|
167
|
-
Unauthorized(Json<ApiError>),
|
|
168
|
-
NotFound(Json<NotFoundError>),
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
impl IntoResponse for SubjectsListResponse {
|
|
172
|
-
fn into_response(self) -> axum::response::Response {
|
|
173
|
-
match self {
|
|
174
|
-
|
|
175
|
-
SubjectsListResponse::Ok(body) => (StatusCode::OK, body).into_response(),
|
|
176
|
-
SubjectsListResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
|
|
177
|
-
SubjectsListResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
#[allow(clippy::type_complexity)]
|
|
183
|
-
pub enum SubjectsCreateResponse {
|
|
184
|
-
Created(Json<Subject>),
|
|
185
|
-
BadRequest(Json<ValidationError>),
|
|
186
|
-
Unauthorized(Json<ApiError>),
|
|
187
|
-
NotFound(Json<NotFoundError>),
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
impl IntoResponse for SubjectsCreateResponse {
|
|
191
|
-
fn into_response(self) -> axum::response::Response {
|
|
192
|
-
match self {
|
|
193
|
-
|
|
194
|
-
SubjectsCreateResponse::Created(body) => (StatusCode::CREATED, body).into_response(),
|
|
195
|
-
SubjectsCreateResponse::BadRequest(body) => (StatusCode::BAD_REQUEST, body).into_response(),
|
|
196
|
-
SubjectsCreateResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
|
|
197
|
-
SubjectsCreateResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
#[allow(clippy::type_complexity)]
|
|
203
|
-
pub enum SubjectsGetByIdResponse {
|
|
204
|
-
Ok(Json<SubjectStatistics>),
|
|
205
|
-
Unauthorized(Json<ApiError>),
|
|
206
|
-
NotFound(Json<NotFoundError>),
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
impl IntoResponse for SubjectsGetByIdResponse {
|
|
210
|
-
fn into_response(self) -> axum::response::Response {
|
|
211
|
-
match self {
|
|
212
|
-
|
|
213
|
-
SubjectsGetByIdResponse::Ok(body) => (StatusCode::OK, body).into_response(),
|
|
214
|
-
SubjectsGetByIdResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
|
|
215
|
-
SubjectsGetByIdResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
#[allow(clippy::type_complexity)]
|
|
221
|
-
pub enum SubjectsUpdateResponse {
|
|
222
|
-
Ok(Json<Subject>),
|
|
223
|
-
BadRequest(Json<ValidationError>),
|
|
224
|
-
Unauthorized(Json<ApiError>),
|
|
225
|
-
NotFound(Json<NotFoundError>),
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
impl IntoResponse for SubjectsUpdateResponse {
|
|
229
|
-
fn into_response(self) -> axum::response::Response {
|
|
230
|
-
match self {
|
|
231
|
-
|
|
232
|
-
SubjectsUpdateResponse::Ok(body) => (StatusCode::OK, body).into_response(),
|
|
233
|
-
SubjectsUpdateResponse::BadRequest(body) => (StatusCode::BAD_REQUEST, body).into_response(),
|
|
234
|
-
SubjectsUpdateResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
|
|
235
|
-
SubjectsUpdateResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
#[allow(clippy::type_complexity)]
|
|
241
|
-
pub enum SubjectsDeleteResponse {
|
|
242
|
-
NoContent,
|
|
243
|
-
Unauthorized(Json<ApiError>),
|
|
244
|
-
NotFound(Json<NotFoundError>),
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
impl IntoResponse for SubjectsDeleteResponse {
|
|
248
|
-
fn into_response(self) -> axum::response::Response {
|
|
249
|
-
match self {
|
|
250
|
-
|
|
251
|
-
SubjectsDeleteResponse::NoContent => StatusCode::NO_CONTENT.into_response(),
|
|
252
|
-
SubjectsDeleteResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
|
|
253
|
-
SubjectsDeleteResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
#[allow(clippy::type_complexity)]
|
|
259
|
-
pub enum SessionsStartResponse {
|
|
260
|
-
Created(Json<SessionOpenedResponse>),
|
|
261
|
-
Unauthorized(Json<ApiError>),
|
|
262
|
-
NotFound(Json<NotFoundError>),
|
|
263
|
-
Conflict(Json<ConflictError>),
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
impl IntoResponse for SessionsStartResponse {
|
|
267
|
-
fn into_response(self) -> axum::response::Response {
|
|
268
|
-
match self {
|
|
269
|
-
|
|
270
|
-
SessionsStartResponse::Created(body) => (StatusCode::CREATED, body).into_response(),
|
|
271
|
-
SessionsStartResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
|
|
272
|
-
SessionsStartResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
|
|
273
|
-
SessionsStartResponse::Conflict(body) => (StatusCode::CONFLICT, body).into_response(),
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
#[allow(clippy::type_complexity)]
|
|
279
|
-
pub enum SessionsPauseResponse {
|
|
280
|
-
Ok(Json<SessionClosedResponse>),
|
|
281
|
-
Unauthorized(Json<ApiError>),
|
|
282
|
-
NotFound(Json<NotFoundError>),
|
|
283
|
-
Conflict(Json<ConflictError>),
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
impl IntoResponse for SessionsPauseResponse {
|
|
287
|
-
fn into_response(self) -> axum::response::Response {
|
|
288
|
-
match self {
|
|
289
|
-
|
|
290
|
-
SessionsPauseResponse::Ok(body) => (StatusCode::OK, body).into_response(),
|
|
291
|
-
SessionsPauseResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
|
|
292
|
-
SessionsPauseResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
|
|
293
|
-
SessionsPauseResponse::Conflict(body) => (StatusCode::CONFLICT, body).into_response(),
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
#[allow(clippy::type_complexity)]
|
|
299
|
-
pub enum SessionsResumeResponse {
|
|
300
|
-
Ok(Json<SessionOpenedResponse>),
|
|
301
|
-
Unauthorized(Json<ApiError>),
|
|
302
|
-
NotFound(Json<NotFoundError>),
|
|
303
|
-
Conflict(Json<ConflictError>),
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
impl IntoResponse for SessionsResumeResponse {
|
|
307
|
-
fn into_response(self) -> axum::response::Response {
|
|
308
|
-
match self {
|
|
309
|
-
|
|
310
|
-
SessionsResumeResponse::Ok(body) => (StatusCode::OK, body).into_response(),
|
|
311
|
-
SessionsResumeResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
|
|
312
|
-
SessionsResumeResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
|
|
313
|
-
SessionsResumeResponse::Conflict(body) => (StatusCode::CONFLICT, body).into_response(),
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
#[allow(clippy::type_complexity)]
|
|
319
|
-
pub enum SessionsStopResponse {
|
|
320
|
-
Ok(Json<SessionClosedResponse>),
|
|
321
|
-
Unauthorized(Json<ApiError>),
|
|
322
|
-
NotFound(Json<NotFoundError>),
|
|
323
|
-
Conflict(Json<ConflictError>),
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
impl IntoResponse for SessionsStopResponse {
|
|
327
|
-
fn into_response(self) -> axum::response::Response {
|
|
328
|
-
match self {
|
|
329
|
-
|
|
330
|
-
SessionsStopResponse::Ok(body) => (StatusCode::OK, body).into_response(),
|
|
331
|
-
SessionsStopResponse::Unauthorized(body) => (StatusCode::UNAUTHORIZED, body).into_response(),
|
|
332
|
-
SessionsStopResponse::NotFound(body) => (StatusCode::NOT_FOUND, body).into_response(),
|
|
333
|
-
SessionsStopResponse::Conflict(body) => (StatusCode::CONFLICT, body).into_response(),
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
#[allow(clippy::type_complexity)]
|
|
339
|
-
pub enum AccountsEventsResponse {
|
|
340
|
-
Ok(axum::response::sse::Sse<std::pin::Pin<Box<dyn futures::stream::Stream<Item = Result<axum::response::sse::Event, std::convert::Infallible>> + Send>>>),
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
impl IntoResponse for AccountsEventsResponse {
|
|
344
|
-
fn into_response(self) -> axum::response::Response {
|
|
345
|
-
match self {
|
|
346
|
-
|
|
347
|
-
AccountsEventsResponse::Ok(body) => body.into_response(),
|
|
43
|
+
PetsListResponse::Ok(body) => (StatusCode::OK, body).into_response(),
|
|
348
44
|
}
|
|
349
45
|
}
|
|
350
46
|
}
|
|
351
47
|
|
|
352
48
|
use axum::extract::Query;
|
|
353
|
-
use axum::routing::{
|
|
49
|
+
use axum::routing::{get};
|
|
354
50
|
use axum::Router;
|
|
355
51
|
|
|
356
52
|
|
|
357
53
|
#[derive(Debug, Clone, serde::Deserialize)]
|
|
358
|
-
pub struct
|
|
359
|
-
|
|
360
|
-
pub
|
|
361
|
-
|
|
54
|
+
pub struct PetsListQuery {
|
|
55
|
+
#[serde(rename = "firstQuery")]
|
|
56
|
+
pub first_query: String,
|
|
57
|
+
#[serde(rename = "secondQuery")]
|
|
58
|
+
pub second_query: String
|
|
362
59
|
}
|
|
363
60
|
|
|
364
61
|
|
|
365
62
|
|
|
366
|
-
pub async fn
|
|
63
|
+
pub async fn events_accounts_events_handler<S>(
|
|
367
64
|
axum::extract::State(service): axum::extract::State<S>,
|
|
368
|
-
Path(account_id): Path<
|
|
65
|
+
Path(account_id): Path<String>,
|
|
369
66
|
) -> impl axum::response::IntoResponse
|
|
370
67
|
where
|
|
371
68
|
S: Server + Clone + Send + Sync + 'static,
|
|
372
69
|
S::Claims: Send + Sync + Clone + 'static,
|
|
373
70
|
{
|
|
374
|
-
let result = service.
|
|
71
|
+
let result = service.events_accounts_events(account_id).await;
|
|
375
72
|
match result {
|
|
376
73
|
Ok(response) => response.into_response(),
|
|
377
74
|
Err(e) => (
|
|
@@ -382,298 +79,15 @@ where
|
|
|
382
79
|
}
|
|
383
80
|
}
|
|
384
81
|
|
|
385
|
-
pub async fn
|
|
82
|
+
pub async fn pets_list_handler<S>(
|
|
386
83
|
axum::extract::State(service): axum::extract::State<S>,
|
|
387
|
-
|
|
388
|
-
Query(params): Query<GroupsCalendarQuery>,
|
|
84
|
+
Query(params): Query<PetsListQuery>,
|
|
389
85
|
) -> impl axum::response::IntoResponse
|
|
390
86
|
where
|
|
391
87
|
S: Server + Clone + Send + Sync + 'static,
|
|
392
88
|
S::Claims: Send + Sync + Clone + 'static,
|
|
393
89
|
{
|
|
394
|
-
let result = service.
|
|
395
|
-
match result {
|
|
396
|
-
Ok(response) => response.into_response(),
|
|
397
|
-
Err(e) => (
|
|
398
|
-
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
399
|
-
format!("Internal error: {e}"),
|
|
400
|
-
)
|
|
401
|
-
.into_response(),
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
pub async fn groups_create_handler<S>(
|
|
406
|
-
axum::extract::State(service): axum::extract::State<S>,
|
|
407
|
-
Extension(claims): Extension<S::Claims>,
|
|
408
|
-
Path(account_id): Path<uuid::Uuid>,
|
|
409
|
-
Json(payload): Json<CreateGroupBody>,
|
|
410
|
-
) -> impl axum::response::IntoResponse
|
|
411
|
-
where
|
|
412
|
-
S: Server + Clone + Send + Sync + 'static,
|
|
413
|
-
S::Claims: Send + Sync + Clone + 'static,
|
|
414
|
-
{
|
|
415
|
-
let result = service.groups_create(claims, account_id, payload).await;
|
|
416
|
-
match result {
|
|
417
|
-
Ok(response) => response.into_response(),
|
|
418
|
-
Err(e) => (
|
|
419
|
-
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
420
|
-
format!("Internal error: {e}"),
|
|
421
|
-
)
|
|
422
|
-
.into_response(),
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
pub async fn groups_get_by_id_handler<S>(
|
|
427
|
-
axum::extract::State(service): axum::extract::State<S>,
|
|
428
|
-
Path((account_id, id)): Path<(uuid::Uuid, i64)>,
|
|
429
|
-
) -> impl axum::response::IntoResponse
|
|
430
|
-
where
|
|
431
|
-
S: Server + Clone + Send + Sync + 'static,
|
|
432
|
-
S::Claims: Send + Sync + Clone + 'static,
|
|
433
|
-
{
|
|
434
|
-
let result = service.groups_get_by_id(account_id, id).await;
|
|
435
|
-
match result {
|
|
436
|
-
Ok(response) => response.into_response(),
|
|
437
|
-
Err(e) => (
|
|
438
|
-
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
439
|
-
format!("Internal error: {e}"),
|
|
440
|
-
)
|
|
441
|
-
.into_response(),
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
pub async fn groups_update_handler<S>(
|
|
446
|
-
axum::extract::State(service): axum::extract::State<S>,
|
|
447
|
-
Extension(claims): Extension<S::Claims>,
|
|
448
|
-
Path((account_id, id)): Path<(uuid::Uuid, i64)>,
|
|
449
|
-
Json(payload): Json<UpdateGroupBody>,
|
|
450
|
-
) -> impl axum::response::IntoResponse
|
|
451
|
-
where
|
|
452
|
-
S: Server + Clone + Send + Sync + 'static,
|
|
453
|
-
S::Claims: Send + Sync + Clone + 'static,
|
|
454
|
-
{
|
|
455
|
-
let result = service.groups_update(claims, account_id, id, payload).await;
|
|
456
|
-
match result {
|
|
457
|
-
Ok(response) => response.into_response(),
|
|
458
|
-
Err(e) => (
|
|
459
|
-
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
460
|
-
format!("Internal error: {e}"),
|
|
461
|
-
)
|
|
462
|
-
.into_response(),
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
pub async fn groups_delete_handler<S>(
|
|
467
|
-
axum::extract::State(service): axum::extract::State<S>,
|
|
468
|
-
Extension(claims): Extension<S::Claims>,
|
|
469
|
-
Path((account_id, id)): Path<(uuid::Uuid, i64)>,
|
|
470
|
-
) -> impl axum::response::IntoResponse
|
|
471
|
-
where
|
|
472
|
-
S: Server + Clone + Send + Sync + 'static,
|
|
473
|
-
S::Claims: Send + Sync + Clone + 'static,
|
|
474
|
-
{
|
|
475
|
-
let result = service.groups_delete(claims, account_id, id).await;
|
|
476
|
-
match result {
|
|
477
|
-
Ok(response) => response.into_response(),
|
|
478
|
-
Err(e) => (
|
|
479
|
-
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
480
|
-
format!("Internal error: {e}"),
|
|
481
|
-
)
|
|
482
|
-
.into_response(),
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
pub async fn subjects_list_handler<S>(
|
|
487
|
-
axum::extract::State(service): axum::extract::State<S>,
|
|
488
|
-
Path((account_id, group_id)): Path<(uuid::Uuid, i64)>,
|
|
489
|
-
) -> impl axum::response::IntoResponse
|
|
490
|
-
where
|
|
491
|
-
S: Server + Clone + Send + Sync + 'static,
|
|
492
|
-
S::Claims: Send + Sync + Clone + 'static,
|
|
493
|
-
{
|
|
494
|
-
let result = service.subjects_list(account_id, group_id).await;
|
|
495
|
-
match result {
|
|
496
|
-
Ok(response) => response.into_response(),
|
|
497
|
-
Err(e) => (
|
|
498
|
-
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
499
|
-
format!("Internal error: {e}"),
|
|
500
|
-
)
|
|
501
|
-
.into_response(),
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
pub async fn subjects_create_handler<S>(
|
|
506
|
-
axum::extract::State(service): axum::extract::State<S>,
|
|
507
|
-
Extension(claims): Extension<S::Claims>,
|
|
508
|
-
Path((account_id, group_id)): Path<(uuid::Uuid, i64)>,
|
|
509
|
-
Json(payload): Json<CreateSubjectBody>,
|
|
510
|
-
) -> impl axum::response::IntoResponse
|
|
511
|
-
where
|
|
512
|
-
S: Server + Clone + Send + Sync + 'static,
|
|
513
|
-
S::Claims: Send + Sync + Clone + 'static,
|
|
514
|
-
{
|
|
515
|
-
let result = service.subjects_create(claims, account_id, group_id, payload).await;
|
|
516
|
-
match result {
|
|
517
|
-
Ok(response) => response.into_response(),
|
|
518
|
-
Err(e) => (
|
|
519
|
-
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
520
|
-
format!("Internal error: {e}"),
|
|
521
|
-
)
|
|
522
|
-
.into_response(),
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
pub async fn subjects_get_by_id_handler<S>(
|
|
527
|
-
axum::extract::State(service): axum::extract::State<S>,
|
|
528
|
-
Path((account_id, group_id, id)): Path<(uuid::Uuid, i64, i64)>,
|
|
529
|
-
) -> impl axum::response::IntoResponse
|
|
530
|
-
where
|
|
531
|
-
S: Server + Clone + Send + Sync + 'static,
|
|
532
|
-
S::Claims: Send + Sync + Clone + 'static,
|
|
533
|
-
{
|
|
534
|
-
let result = service.subjects_get_by_id(account_id, group_id, id).await;
|
|
535
|
-
match result {
|
|
536
|
-
Ok(response) => response.into_response(),
|
|
537
|
-
Err(e) => (
|
|
538
|
-
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
539
|
-
format!("Internal error: {e}"),
|
|
540
|
-
)
|
|
541
|
-
.into_response(),
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
pub async fn subjects_update_handler<S>(
|
|
546
|
-
axum::extract::State(service): axum::extract::State<S>,
|
|
547
|
-
Extension(claims): Extension<S::Claims>,
|
|
548
|
-
Path((account_id, group_id, id)): Path<(uuid::Uuid, i64, i64)>,
|
|
549
|
-
Json(payload): Json<UpdateSubjectBody>,
|
|
550
|
-
) -> impl axum::response::IntoResponse
|
|
551
|
-
where
|
|
552
|
-
S: Server + Clone + Send + Sync + 'static,
|
|
553
|
-
S::Claims: Send + Sync + Clone + 'static,
|
|
554
|
-
{
|
|
555
|
-
let result = service.subjects_update(claims, account_id, group_id, id, payload).await;
|
|
556
|
-
match result {
|
|
557
|
-
Ok(response) => response.into_response(),
|
|
558
|
-
Err(e) => (
|
|
559
|
-
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
560
|
-
format!("Internal error: {e}"),
|
|
561
|
-
)
|
|
562
|
-
.into_response(),
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
pub async fn subjects_delete_handler<S>(
|
|
567
|
-
axum::extract::State(service): axum::extract::State<S>,
|
|
568
|
-
Extension(claims): Extension<S::Claims>,
|
|
569
|
-
Path((account_id, group_id, id)): Path<(uuid::Uuid, i64, i64)>,
|
|
570
|
-
) -> impl axum::response::IntoResponse
|
|
571
|
-
where
|
|
572
|
-
S: Server + Clone + Send + Sync + 'static,
|
|
573
|
-
S::Claims: Send + Sync + Clone + 'static,
|
|
574
|
-
{
|
|
575
|
-
let result = service.subjects_delete(claims, account_id, group_id, id).await;
|
|
576
|
-
match result {
|
|
577
|
-
Ok(response) => response.into_response(),
|
|
578
|
-
Err(e) => (
|
|
579
|
-
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
580
|
-
format!("Internal error: {e}"),
|
|
581
|
-
)
|
|
582
|
-
.into_response(),
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
pub async fn sessions_start_handler<S>(
|
|
587
|
-
axum::extract::State(service): axum::extract::State<S>,
|
|
588
|
-
Extension(claims): Extension<S::Claims>,
|
|
589
|
-
Path((account_id, subject_id)): Path<(uuid::Uuid, i64)>,
|
|
590
|
-
Json(payload): Json<SessionNoteBody>,
|
|
591
|
-
) -> impl axum::response::IntoResponse
|
|
592
|
-
where
|
|
593
|
-
S: Server + Clone + Send + Sync + 'static,
|
|
594
|
-
S::Claims: Send + Sync + Clone + 'static,
|
|
595
|
-
{
|
|
596
|
-
let result = service.sessions_start(claims, account_id, subject_id, payload).await;
|
|
597
|
-
match result {
|
|
598
|
-
Ok(response) => response.into_response(),
|
|
599
|
-
Err(e) => (
|
|
600
|
-
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
601
|
-
format!("Internal error: {e}"),
|
|
602
|
-
)
|
|
603
|
-
.into_response(),
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
pub async fn sessions_pause_handler<S>(
|
|
608
|
-
axum::extract::State(service): axum::extract::State<S>,
|
|
609
|
-
Extension(claims): Extension<S::Claims>,
|
|
610
|
-
Path((account_id, subject_id, log_id)): Path<(uuid::Uuid, i64, i64)>,
|
|
611
|
-
) -> impl axum::response::IntoResponse
|
|
612
|
-
where
|
|
613
|
-
S: Server + Clone + Send + Sync + 'static,
|
|
614
|
-
S::Claims: Send + Sync + Clone + 'static,
|
|
615
|
-
{
|
|
616
|
-
let result = service.sessions_pause(claims, account_id, subject_id, log_id).await;
|
|
617
|
-
match result {
|
|
618
|
-
Ok(response) => response.into_response(),
|
|
619
|
-
Err(e) => (
|
|
620
|
-
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
621
|
-
format!("Internal error: {e}"),
|
|
622
|
-
)
|
|
623
|
-
.into_response(),
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
pub async fn sessions_resume_handler<S>(
|
|
628
|
-
axum::extract::State(service): axum::extract::State<S>,
|
|
629
|
-
Extension(claims): Extension<S::Claims>,
|
|
630
|
-
Path((account_id, subject_id, log_id)): Path<(uuid::Uuid, i64, i64)>,
|
|
631
|
-
) -> impl axum::response::IntoResponse
|
|
632
|
-
where
|
|
633
|
-
S: Server + Clone + Send + Sync + 'static,
|
|
634
|
-
S::Claims: Send + Sync + Clone + 'static,
|
|
635
|
-
{
|
|
636
|
-
let result = service.sessions_resume(claims, account_id, subject_id, log_id).await;
|
|
637
|
-
match result {
|
|
638
|
-
Ok(response) => response.into_response(),
|
|
639
|
-
Err(e) => (
|
|
640
|
-
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
641
|
-
format!("Internal error: {e}"),
|
|
642
|
-
)
|
|
643
|
-
.into_response(),
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
pub async fn sessions_stop_handler<S>(
|
|
648
|
-
axum::extract::State(service): axum::extract::State<S>,
|
|
649
|
-
Extension(claims): Extension<S::Claims>,
|
|
650
|
-
Path((account_id, subject_id, log_id)): Path<(uuid::Uuid, i64, i64)>,
|
|
651
|
-
Json(payload): Json<SessionNoteBody>,
|
|
652
|
-
) -> impl axum::response::IntoResponse
|
|
653
|
-
where
|
|
654
|
-
S: Server + Clone + Send + Sync + 'static,
|
|
655
|
-
S::Claims: Send + Sync + Clone + 'static,
|
|
656
|
-
{
|
|
657
|
-
let result = service.sessions_stop(claims, account_id, subject_id, log_id, payload).await;
|
|
658
|
-
match result {
|
|
659
|
-
Ok(response) => response.into_response(),
|
|
660
|
-
Err(e) => (
|
|
661
|
-
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
662
|
-
format!("Internal error: {e}"),
|
|
663
|
-
)
|
|
664
|
-
.into_response(),
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
pub async fn accounts_events_handler<S>(
|
|
669
|
-
axum::extract::State(service): axum::extract::State<S>,
|
|
670
|
-
Path(account_id): Path<uuid::Uuid>,
|
|
671
|
-
) -> impl axum::response::IntoResponse
|
|
672
|
-
where
|
|
673
|
-
S: Server + Clone + Send + Sync + 'static,
|
|
674
|
-
S::Claims: Send + Sync + Clone + 'static,
|
|
675
|
-
{
|
|
676
|
-
let result = service.accounts_events(account_id).await;
|
|
90
|
+
let result = service.pets_list(params.first_query, params.second_query).await;
|
|
677
91
|
match result {
|
|
678
92
|
Ok(response) => response.into_response(),
|
|
679
93
|
Err(e) => (
|
|
@@ -692,26 +106,9 @@ where
|
|
|
692
106
|
{
|
|
693
107
|
let mut router = Router::new();
|
|
694
108
|
let public = Router::new()
|
|
695
|
-
.route("/
|
|
696
|
-
.route("/
|
|
697
|
-
.route("/accounts/{accountId}/learning/groups/{id}", get(groups_get_by_id_handler::<S>))
|
|
698
|
-
.route("/accounts/{accountId}/learning/groups/{groupId}/subjects", get(subjects_list_handler::<S>))
|
|
699
|
-
.route("/accounts/{accountId}/learning/groups/{groupId}/subjects/{id}", get(subjects_get_by_id_handler::<S>))
|
|
700
|
-
.route("/accounts/{accountId}/learning/accounts/{accountId}/events", get(accounts_events_handler::<S>))
|
|
109
|
+
.route("/events/{accountId}", get(events_accounts_events_handler::<S>))
|
|
110
|
+
.route("/pets", get(pets_list_handler::<S>))
|
|
701
111
|
;
|
|
702
112
|
router = router.merge(public);
|
|
703
|
-
let protected = Router::new()
|
|
704
|
-
.route("/accounts/{accountId}/learning/groups", post(groups_create_handler::<S>))
|
|
705
|
-
.route("/accounts/{accountId}/learning/groups/{id}", patch(groups_update_handler::<S>))
|
|
706
|
-
.route("/accounts/{accountId}/learning/groups/{id}", delete(groups_delete_handler::<S>))
|
|
707
|
-
.route("/accounts/{accountId}/learning/groups/{groupId}/subjects", post(subjects_create_handler::<S>))
|
|
708
|
-
.route("/accounts/{accountId}/learning/groups/{groupId}/subjects/{id}", patch(subjects_update_handler::<S>))
|
|
709
|
-
.route("/accounts/{accountId}/learning/groups/{groupId}/subjects/{id}", delete(subjects_delete_handler::<S>))
|
|
710
|
-
.route("/accounts/{accountId}/learning/subjects/{subjectId}/sessions", post(sessions_start_handler::<S>))
|
|
711
|
-
.route("/accounts/{accountId}/learning/subjects/{subjectId}/sessions/{logId}/pause", post(sessions_pause_handler::<S>))
|
|
712
|
-
.route("/accounts/{accountId}/learning/subjects/{subjectId}/sessions/{logId}/resume", post(sessions_resume_handler::<S>))
|
|
713
|
-
.route("/accounts/{accountId}/learning/subjects/{subjectId}/sessions/{logId}/stop", post(sessions_stop_handler::<S>))
|
|
714
|
-
;
|
|
715
|
-
router = router.merge(middleware(protected));
|
|
716
113
|
router.with_state(service)
|
|
717
114
|
}
|