@strong-together/shared 1.0.6 → 2.0.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/dist/index.js CHANGED
@@ -1,666 +1,2229 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- addAerobicsRequest: () => addAerobicsRequest,
34
- addWorkoutRequest: () => addWorkoutRequest,
35
- addWorkoutResponseSchema: () => addWorkoutResponseSchema,
36
- adherenceExerciseStatsSchema: () => adherenceExerciseStatsSchema,
37
- aerobicsDailyRecordSchema: () => aerobicsDailyRecordSchema,
38
- aerobicsWeeklyRecordSchema: () => aerobicsWeeklyRecordSchema,
39
- allUserMessageSchema: () => allUserMessageSchema,
40
- appleOAuthRequest: () => appleOAuthRequest,
41
- bootstrapRequest: () => bootstrapRequest,
42
- bootstrapResponseSchema: () => bootstrapResponseSchema,
43
- changeEmailAndVerifyRequest: () => changeEmailAndVerifyRequest,
44
- checkUserVerifyRequest: () => checkUserVerifyRequest,
45
- createUserRequest: () => createUserRequest,
46
- createUserResponseSchema: () => createUserResponseSchema,
47
- createUserUserSchema: () => createUserUserSchema,
48
- deleteMessageRequest: () => deleteMessageRequest,
49
- deleteMessageResponseSchema: () => deleteMessageResponseSchema,
50
- deleteProfilePicRequest: () => deleteProfilePicRequest,
51
- deletedMessageSchema: () => deletedMessageSchema,
52
- exerciseInPlanSchema: () => exerciseInPlanSchema,
53
- exerciseMetadataSchema: () => exerciseMetadataSchema,
54
- exerciseTrackingAnalysisSchema: () => exerciseTrackingAnalysisSchema,
55
- exerciseTrackingAndStatsSchema: () => exerciseTrackingAndStatsSchema,
56
- exerciseTrackingPrMaxSchema: () => exerciseTrackingPrMaxSchema,
57
- finishUserWorkoutResponseSchema: () => finishUserWorkoutResponseSchema,
58
- finishWorkoutRequest: () => finishWorkoutRequest,
59
- generateTicketRequest: () => generateTicketRequest,
60
- generateTicketResponseSchema: () => generateTicketResponseSchema,
61
- getAerobicsRequest: () => getAerobicsRequest,
62
- getAllExercisesResponseSchema: () => getAllExercisesResponseSchema,
63
- getAllMessagesRequest: () => getAllMessagesRequest,
64
- getAllUserMessagesResponseSchema: () => getAllUserMessagesResponseSchema,
65
- getAnalyticsResponseSchema: () => getAnalyticsResponseSchema,
66
- getAuthenticatedUserByIdResponseSchema: () => getAuthenticatedUserByIdResponseSchema,
67
- getExerciseTrackingRequest: () => getExerciseTrackingRequest,
68
- getExerciseTrackingResponseSchema: () => getExerciseTrackingResponseSchema,
69
- getPresignedUrlFromS3ResponseSchema: () => getPresignedUrlFromS3ResponseSchema,
70
- getPresignedUrlS3Request: () => getPresignedUrlS3Request,
71
- getWholeUserWorkoutPlanResponseSchema: () => getWholeUserWorkoutPlanResponseSchema,
72
- getWholeWorkoutPlanRequest: () => getWholeWorkoutPlanRequest,
73
- googleOAuthRequest: () => googleOAuthRequest,
74
- loginRequest: () => loginRequest,
75
- loginResponseSchema: () => loginResponseSchema,
76
- logoutResponseSchema: () => logoutResponseSchema,
77
- markMessageAsReadRequest: () => markMessageAsReadRequest,
78
- markMessageAsReadResponseSchema: () => markMessageAsReadResponseSchema,
79
- messageAsReadSchema: () => messageAsReadSchema,
80
- oAuthLoginResponseSchema: () => oAuthLoginResponseSchema,
81
- proceedLoginResponseSchema: () => proceedLoginResponseSchema,
82
- refreshTokenResponseSchema: () => refreshTokenResponseSchema,
83
- resetPasswordRequest: () => resetPasswordRequest,
84
- resetPasswordResponseSchema: () => resetPasswordResponseSchema,
85
- saveUserPushTokenRequest: () => saveUserPushTokenRequest,
86
- sendChangePassEmailRequest: () => sendChangePassEmailRequest,
87
- sendVerificationMailRequest: () => sendVerificationMailRequest,
88
- setProfilePicAndUpdateDBResponseSchema: () => setProfilePicAndUpdateDBResponseSchema,
89
- trackingByDateItemSchema: () => trackingByDateItemSchema,
90
- trackingBySplitNameItemSchema: () => trackingBySplitNameItemSchema,
91
- trackingMapItemSchema: () => trackingMapItemSchema,
92
- updateAuthenticatedUserResponseSchema: () => updateAuthenticatedUserResponseSchema,
93
- updateUserRequest: () => updateUserRequest,
94
- userAerobicsResponseSchema: () => userAerobicsResponseSchema,
95
- userDataResponseSchema: () => userDataResponseSchema,
96
- userDataSchema: () => userDataSchema,
97
- verifyAccountRequest: () => verifyAccountRequest,
98
- weeklyDataSchema: () => weeklyDataSchema,
99
- wholeUserWorkoutPlanSchema: () => wholeUserWorkoutPlanSchema,
100
- workoutRmRecordSchema: () => workoutRmRecordSchema,
101
- workoutSplitSchema: () => workoutSplitSchema,
102
- workoutSplitsMapItemSchema: () => workoutSplitsMapItemSchema,
103
- workoutSplitsMapSchema: () => workoutSplitsMapSchema
104
- });
105
- module.exports = __toCommonJS(index_exports);
106
-
107
- // src/modules/aerobics/aerobics.schemas.ts
108
- var import_zod = __toESM(require("zod"));
109
- var addAerobicInput = import_zod.default.object({
110
- durationMins: import_zod.default.number(),
111
- durationSec: import_zod.default.number(),
112
- type: import_zod.default.string()
113
- });
114
- var addAerobicsRequest = import_zod.default.object({
115
- body: import_zod.default.object({
116
- tz: import_zod.default.string(),
117
- record: addAerobicInput
118
- })
119
- });
120
- var getAerobicsRequest = import_zod.default.object({
121
- query: import_zod.default.object({
122
- tz: import_zod.default.string().optional()
123
- })
124
- });
125
- var aerobicsDailyRecordSchema = import_zod.default.object({
126
- type: import_zod.default.string(),
127
- duration_sec: import_zod.default.number(),
128
- duration_mins: import_zod.default.number()
129
- });
130
- var aerobicsWeeklyRecordSchema = aerobicsDailyRecordSchema.extend({
131
- workout_time_utc: import_zod.default.string()
132
- });
133
- var weeklyDataSchema = import_zod.default.object({
134
- records: import_zod.default.array(aerobicsWeeklyRecordSchema),
135
- total_duration_sec: import_zod.default.number(),
136
- total_duration_mins: import_zod.default.number()
137
- });
138
- var userAerobicsResponseSchema = import_zod.default.object({
139
- daily: import_zod.default.record(import_zod.default.string(), import_zod.default.array(aerobicsDailyRecordSchema)),
140
- weekly: import_zod.default.record(import_zod.default.string(), weeklyDataSchema)
141
- });
142
-
143
- // src/modules/analytics/analytics.schemas.ts
144
- var import_zod2 = require("zod");
145
- var workoutRmRecordSchema = import_zod2.z.object({
146
- exercise: import_zod2.z.string(),
147
- pr_weight: import_zod2.z.number().nullable(),
148
- pr_reps: import_zod2.z.number().nullable(),
149
- max_1rm: import_zod2.z.number()
150
- });
151
- var adherenceExerciseStatsSchema = import_zod2.z.object({
152
- planned: import_zod2.z.number(),
153
- actual: import_zod2.z.number(),
154
- adherence_pct: import_zod2.z.number().nullable()
155
- });
156
- var getAnalyticsResponseSchema = import_zod2.z.object({
157
- _1RM: import_zod2.z.record(import_zod2.z.string(), workoutRmRecordSchema),
158
- goals: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.record(import_zod2.z.string(), adherenceExerciseStatsSchema))
159
- });
160
-
161
- // src/modules/auth/password/password.schemas.ts
162
- var import_zod3 = require("zod");
163
- var sendChangePassEmailRequest = import_zod3.z.object({
164
- body: import_zod3.z.object({ identifier: import_zod3.z.string() })
165
- });
166
- var resetPasswordRequest = import_zod3.z.object({
167
- body: import_zod3.z.object({
168
- newPassword: import_zod3.z.string().min(8, "Password must be at least 8 characters long")
169
- }),
170
- query: import_zod3.z.object({
171
- token: import_zod3.z.string().optional()
172
- })
173
- });
174
- var resetPasswordResponseSchema = import_zod3.z.object({
175
- ok: import_zod3.z.boolean()
176
- });
177
-
178
- // src/modules/auth/session/session.schemas.ts
179
- var import_zod4 = require("zod");
180
- var loginRequest = import_zod4.z.object({
181
- body: import_zod4.z.object({
182
- identifier: import_zod4.z.string().min(3).refine(
183
- (val) => {
184
- const isEmail = import_zod4.z.string().email().safeParse(val).success;
185
- const isUsername = /^[a-zA-Z0-9_]{3,20}$/.test(val);
186
- return isEmail || isUsername;
187
- },
188
- {
189
- message: "Must be a valid email or username"
190
- }
191
- ),
192
- password: import_zod4.z.string().min(1, "Username and password are required")
193
- })
194
- });
195
- var loginResponseSchema = import_zod4.z.object({
196
- message: import_zod4.z.string(),
197
- user: import_zod4.z.string(),
198
- accessToken: import_zod4.z.string(),
199
- refreshToken: import_zod4.z.string()
200
- });
201
- var logoutResponseSchema = import_zod4.z.object({
202
- message: import_zod4.z.string()
203
- });
204
- var refreshTokenResponseSchema = import_zod4.z.object({
205
- message: import_zod4.z.string(),
206
- accessToken: import_zod4.z.string(),
207
- refreshToken: import_zod4.z.string(),
208
- userId: import_zod4.z.string()
209
- });
210
-
211
- // src/modules/auth/verification/verification.schemas.ts
212
- var import_zod5 = __toESM(require("zod"));
213
- var verifyAccountRequest = import_zod5.default.object({
214
- query: import_zod5.default.object({
215
- token: import_zod5.default.string().optional()
216
- })
217
- });
218
- var sendVerificationMailRequest = import_zod5.default.object({
219
- body: import_zod5.default.object({ email: import_zod5.default.string().trim().email("Invalid email") })
220
- });
221
- var changeEmailAndVerifyRequest = import_zod5.default.object({
222
- body: import_zod5.default.object({ username: import_zod5.default.string(), password: import_zod5.default.string(), newEmail: import_zod5.default.string().trim().email("Invalid email") })
223
- });
224
- var checkUserVerifyRequest = import_zod5.default.object({
225
- query: import_zod5.default.object({ username: import_zod5.default.string() })
226
- });
227
-
228
- // src/modules/bootstrap/bootstrap.schemas.ts
229
- var import_zod10 = require("zod");
230
-
231
- // src/modules/messages/messages.schemas.ts
232
- var import_zod6 = require("zod");
233
- var getAllMessagesRequest = import_zod6.z.object({
234
- query: import_zod6.z.object({
235
- tz: import_zod6.z.string()
236
- })
237
- });
238
- var allUserMessageSchema = import_zod6.z.object({
239
- id: import_zod6.z.string(),
240
- subject: import_zod6.z.string(),
241
- msg: import_zod6.z.string(),
242
- sent_at: import_zod6.z.string(),
243
- is_read: import_zod6.z.boolean(),
244
- sender_full_name: import_zod6.z.string(),
245
- sender_profile_image_url: import_zod6.z.string().nullable()
246
- });
247
- var getAllUserMessagesResponseSchema = import_zod6.z.object({
248
- messages: import_zod6.z.array(allUserMessageSchema)
249
- });
250
- var markMessageAsReadRequest = import_zod6.z.object({
251
- params: import_zod6.z.object({
252
- id: import_zod6.z.string()
253
- // MSG ID
254
- })
255
- });
256
- var messageAsReadSchema = import_zod6.z.object({
257
- id: import_zod6.z.string(),
258
- is_read: import_zod6.z.boolean()
259
- });
260
- var markMessageAsReadResponseSchema = messageAsReadSchema;
261
- var deleteMessageRequest = import_zod6.z.object({
262
- params: import_zod6.z.object({
263
- id: import_zod6.z.string()
264
- // MSG ID
265
- })
266
- });
267
- var deletedMessageSchema = import_zod6.z.object({
268
- id: import_zod6.z.string()
269
- });
270
- var deleteMessageResponseSchema = deletedMessageSchema;
271
-
272
- // src/modules/user/update/update.schemas.ts
273
- var import_zod7 = require("zod");
274
- var updateUserRequest = import_zod7.z.object({
275
- body: import_zod7.z.object({
276
- username: import_zod7.z.string().trim().min(3, "Username must be at least 3 characters").max(15, "Username must be at most 15 characters").regex(/^[a-zA-Z0-9_]+$/, "Username may contain letters, numbers, and underscore only"),
277
- fullName: import_zod7.z.string().trim().min(1, "Full name is required").max(20, "Full name is too long").regex(/^[a-zA-Z\s]+$/, "Full name may contain letters and spaces only"),
278
- email: import_zod7.z.string().trim().toLowerCase().email("Invalid email format")
279
- }).partial()
280
- });
281
- var deleteProfilePicRequest = import_zod7.z.object({
282
- body: import_zod7.z.object({
283
- path: import_zod7.z.string()
284
- })
285
- });
286
- var userDataSchema = import_zod7.z.object({
287
- id: import_zod7.z.string(),
288
- username: import_zod7.z.string(),
289
- email: import_zod7.z.string().nullable(),
290
- name: import_zod7.z.string(),
291
- gender: import_zod7.z.string(),
292
- created_at: import_zod7.z.string(),
293
- profile_image_url: import_zod7.z.string().nullable(),
294
- push_token: import_zod7.z.string().nullable(),
295
- role: import_zod7.z.string(),
296
- is_first_login: import_zod7.z.boolean(),
297
- token_version: import_zod7.z.number(),
298
- is_verified: import_zod7.z.boolean(),
299
- auth_provider: import_zod7.z.string()
300
- });
301
- var userDataResponseSchema = import_zod7.z.object({
302
- user_data: userDataSchema
303
- });
304
- var getAuthenticatedUserByIdResponseSchema = userDataSchema;
305
- var updateAuthenticatedUserResponseSchema = import_zod7.z.object({
306
- message: import_zod7.z.string(),
307
- emailChanged: import_zod7.z.boolean(),
308
- user: userDataSchema
309
- });
310
- var setProfilePicAndUpdateDBResponseSchema = import_zod7.z.object({
311
- path: import_zod7.z.string(),
312
- url: import_zod7.z.string(),
313
- message: import_zod7.z.string()
314
- });
315
-
316
- // src/modules/workout/plan/plan.schemas.ts
317
- var import_zod8 = require("zod");
318
- var workoutExerciseSchema = import_zod8.z.object({
319
- id: import_zod8.z.number(),
320
- sets: import_zod8.z.array(import_zod8.z.number()),
321
- order_index: import_zod8.z.number()
322
- });
323
- var exerciseInPlanSchema = import_zod8.z.object({
324
- id: import_zod8.z.number(),
325
- sets: import_zod8.z.array(import_zod8.z.number()),
326
- is_active: import_zod8.z.boolean(),
327
- targetmuscle: import_zod8.z.string(),
328
- specifictargetmuscle: import_zod8.z.string(),
329
- exercise: import_zod8.z.string(),
330
- workoutsplit: import_zod8.z.string()
331
- });
332
- var workoutSplitSchema = import_zod8.z.object({
333
- id: import_zod8.z.number(),
334
- workout_id: import_zod8.z.number(),
335
- name: import_zod8.z.string(),
336
- created_at: import_zod8.z.string(),
337
- muscle_group: import_zod8.z.string().nullable(),
338
- is_active: import_zod8.z.boolean(),
339
- exercisetoworkoutsplit: import_zod8.z.array(exerciseInPlanSchema)
340
- });
341
- var wholeUserWorkoutPlanSchema = import_zod8.z.object({
342
- id: import_zod8.z.number(),
343
- name: import_zod8.z.string(),
344
- numberofsplits: import_zod8.z.number(),
345
- created_at: import_zod8.z.string(),
346
- is_deleted: import_zod8.z.boolean(),
347
- level: import_zod8.z.string(),
348
- user_id: import_zod8.z.string(),
349
- trainer_id: import_zod8.z.string(),
350
- is_active: import_zod8.z.boolean(),
351
- updated_at: import_zod8.z.string(),
352
- workoutsplits: import_zod8.z.array(workoutSplitSchema).nullable()
353
- });
354
- var workoutSplitsMapItemSchema = import_zod8.z.object({
355
- id: import_zod8.z.number(),
356
- name: import_zod8.z.string(),
357
- sets: import_zod8.z.array(import_zod8.z.number()),
358
- order_index: import_zod8.z.number(),
359
- targetmuscle: import_zod8.z.string(),
360
- specifictargetmuscle: import_zod8.z.string()
361
- });
362
- var workoutSplitsMapSchema = import_zod8.z.record(import_zod8.z.string(), import_zod8.z.array(workoutSplitsMapItemSchema));
363
- var addWorkoutSplitPayloadSchema = import_zod8.z.record(
364
- import_zod8.z.string(),
365
- import_zod8.z.array(workoutExerciseSchema).min(1, "Each split must include at least one exercise")
366
- );
367
- var addWorkoutRequest = import_zod8.z.object({
368
- body: import_zod8.z.object({
369
- workoutData: addWorkoutSplitPayloadSchema,
370
- workoutName: import_zod8.z.string().optional(),
371
- tz: import_zod8.z.string()
372
- })
373
- });
374
- var addWorkoutResponseSchema = import_zod8.z.object({
375
- message: import_zod8.z.string(),
376
- workoutPlan: wholeUserWorkoutPlanSchema,
377
- workoutPlanForEditWorkout: workoutSplitsMapSchema
378
- });
379
- var getWholeWorkoutPlanRequest = import_zod8.z.object({
380
- query: import_zod8.z.object({
381
- tz: import_zod8.z.string().optional()
382
- })
383
- });
384
- var getWholeUserWorkoutPlanResponseSchema = import_zod8.z.object({
385
- workoutPlan: wholeUserWorkoutPlanSchema.nullable(),
386
- workoutPlanForEditWorkout: workoutSplitsMapSchema.nullable()
387
- });
388
-
389
- // src/modules/workout/tracking/tracking.schemas.ts
390
- var import_zod9 = require("zod");
391
- var finishedExerciseEntry = import_zod9.z.object({
392
- exercisetosplit_id: import_zod9.z.number(),
393
- weight: import_zod9.z.array(import_zod9.z.number()),
394
- reps: import_zod9.z.array(import_zod9.z.number()),
395
- notes: import_zod9.z.string().optional().nullable()
396
- });
397
- var exerciseMetadataSchema = import_zod9.z.object({
398
- targetmuscle: import_zod9.z.string(),
399
- specifictargetmuscle: import_zod9.z.string()
400
- });
401
- var exerciseTrackingPrMaxSchema = import_zod9.z.object({
402
- exercise: import_zod9.z.string(),
403
- weight: import_zod9.z.number(),
404
- reps: import_zod9.z.number(),
405
- workout_time_utc: import_zod9.z.string()
406
- });
407
- var exerciseTrackingAnalysisSchema = import_zod9.z.object({
408
- unique_days: import_zod9.z.number(),
409
- most_frequent_split: import_zod9.z.string().nullable(),
410
- most_frequent_split_days: import_zod9.z.number().nullable(),
411
- lastWorkoutDate: import_zod9.z.string().nullable(),
412
- splitDaysByName: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.number()),
413
- prs: import_zod9.z.object({
414
- pr_max: exerciseTrackingPrMaxSchema.nullable()
415
- })
416
- });
417
- var trackingMapItemSchema = import_zod9.z.object({
418
- id: import_zod9.z.number(),
419
- exercisetosplit_id: import_zod9.z.number(),
420
- weight: import_zod9.z.array(import_zod9.z.number()),
421
- reps: import_zod9.z.array(import_zod9.z.number()),
422
- notes: import_zod9.z.string().nullable(),
423
- exercise_id: import_zod9.z.number(),
424
- workoutsplit_id: import_zod9.z.number(),
425
- splitname: import_zod9.z.string(),
426
- exercise: import_zod9.z.string(),
427
- workoutdate: import_zod9.z.string(),
428
- order_index: import_zod9.z.number(),
429
- exercisetoworkoutsplit: import_zod9.z.object({
430
- sets: import_zod9.z.array(import_zod9.z.number()),
431
- exercises: exerciseMetadataSchema
432
- })
433
- });
434
- var trackingByDateItemSchema = trackingMapItemSchema.omit({ workoutdate: true });
435
- var trackingBySplitNameItemSchema = trackingMapItemSchema.omit({ splitname: true });
436
- var exerciseTrackingAndStatsSchema = import_zod9.z.object({
437
- exerciseTrackingAnalysis: exerciseTrackingAnalysisSchema,
438
- exerciseTrackingMaps: import_zod9.z.object({
439
- byDate: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.array(trackingByDateItemSchema)),
440
- byETSId: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.array(trackingMapItemSchema)),
441
- bySplitName: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.array(trackingBySplitNameItemSchema))
442
- })
443
- });
444
- var finishWorkoutRequest = import_zod9.z.object({
445
- body: import_zod9.z.object({
446
- workout: import_zod9.z.array(finishedExerciseEntry),
447
- tz: import_zod9.z.string().optional(),
448
- workout_start_utc: import_zod9.z.string().datetime("workout_start_utc must be a valid ISO datetime"),
449
- workout_end_utc: import_zod9.z.string().datetime("workout_end_utc must be a valid ISO datetime").optional().nullable()
450
- })
451
- });
452
- var finishUserWorkoutResponseSchema = exerciseTrackingAndStatsSchema;
453
- var getExerciseTrackingRequest = import_zod9.z.object({
454
- query: import_zod9.z.object({
455
- tz: import_zod9.z.string().optional()
456
- })
457
- });
458
- var getExerciseTrackingResponseSchema = exerciseTrackingAndStatsSchema;
459
-
460
- // src/modules/bootstrap/bootstrap.schemas.ts
461
- var bootstrapRequest = import_zod10.z.object({
462
- query: import_zod10.z.object({
463
- tz: import_zod10.z.string().optional()
464
- })
465
- });
466
- var bootstrapResponseSchema = import_zod10.z.object({
467
- user: userDataSchema,
468
- workout: getWholeUserWorkoutPlanResponseSchema,
469
- tracking: exerciseTrackingAndStatsSchema,
470
- messages: getAllUserMessagesResponseSchema,
471
- aerobics: userAerobicsResponseSchema
472
- });
473
-
474
- // src/modules/exercises/exercises.schemas.ts
475
- var import_zod11 = require("zod");
476
- var getAllExercisesResponseSchema = import_zod11.z.record(
477
- import_zod11.z.string(),
478
- import_zod11.z.array(
479
- import_zod11.z.object({
480
- id: import_zod11.z.number(),
481
- name: import_zod11.z.string(),
482
- specificTargetMuscle: import_zod11.z.string()
483
- })
484
- )
485
- );
486
-
487
- // src/modules/oauth/apple/apple.schemas.ts
488
- var import_zod12 = require("zod");
489
- var appleNameInput = import_zod12.z.object({
490
- givenName: import_zod12.z.string().nullable(),
491
- familyName: import_zod12.z.string().nullable()
492
- });
493
- var appleOAuthRequest = import_zod12.z.object({
494
- body: import_zod12.z.object({
495
- idToken: import_zod12.z.string({
496
- required_error: "Missing or invalid Apple identityToken",
497
- invalid_type_error: "Missing or invalid Apple identityToken"
498
- }),
499
- rawNonce: import_zod12.z.string(),
500
- name: appleNameInput.optional(),
501
- email: import_zod12.z.string().email().nullable()
502
- })
503
- });
504
-
505
- // src/modules/oauth/google/google.schemas.ts
506
- var import_zod13 = require("zod");
507
- var googleOAuthRequest = import_zod13.z.object({
508
- body: import_zod13.z.object({
509
- idToken: import_zod13.z.string().optional()
510
- })
511
- });
512
-
513
- // src/modules/oauth/oauth.schemas.ts
514
- var import_zod14 = require("zod");
515
- var oAuthLoginResponseSchema = import_zod14.z.object({
516
- message: import_zod14.z.string(),
517
- user: import_zod14.z.string(),
518
- accessToken: import_zod14.z.string(),
519
- refreshToken: import_zod14.z.string(),
520
- missingFields: import_zod14.z.array(import_zod14.z.string()).nullable()
521
- });
522
- var proceedLoginResponseSchema = loginResponseSchema;
523
-
524
- // src/modules/user/create/create.schemas.ts
525
- var import_zod15 = require("zod");
526
- var createUserRequest = import_zod15.z.object({
527
- body: import_zod15.z.object({
528
- username: import_zod15.z.string().trim().min(3, "Username must be at least 3 characters").max(15, "Username must be at most 15 characters").regex(/^[a-zA-Z0-9_]+$/, "Username may contain letters, numbers, and underscore only"),
529
- fullName: import_zod15.z.preprocess(
530
- // Map "", null, undefined -> "User"
531
- (val) => {
532
- if (val == null) return "User";
533
- if (typeof val === "string" && val.trim() === "") return "User";
534
- return val;
535
- },
536
- import_zod15.z.string().trim().max(20, "Full name is too long").regex(/^[a-zA-Z\s]+$/, "Full name may contain letters and spaces only")
537
- ),
538
- email: import_zod15.z.string().trim().toLowerCase().email("Invalid email format"),
539
- password: import_zod15.z.string().min(8, "Password must be at least 8 characters long"),
540
- gender: import_zod15.z.preprocess(
541
- (val) => val === "" || val == null ? "Unknown" : val,
542
- import_zod15.z.enum(["Male", "Female", "Other", "Unknown"])
543
- )
544
- })
545
- });
546
- var createUserUserSchema = import_zod15.z.object({
547
- id: import_zod15.z.string(),
548
- username: import_zod15.z.string(),
549
- name: import_zod15.z.string(),
550
- email: import_zod15.z.string().nullable(),
551
- gender: import_zod15.z.string(),
552
- role: import_zod15.z.string(),
553
- created_at: import_zod15.z.string()
554
- });
555
- var createUserResponseSchema = import_zod15.z.object({
556
- message: import_zod15.z.string(),
557
- user: createUserUserSchema
558
- });
559
-
560
- // src/modules/user/push-tokens/push-tokens.schemas.ts
561
- var import_zod16 = require("zod");
562
- var saveUserPushTokenRequest = import_zod16.z.object({
563
- body: import_zod16.z.object({
564
- token: import_zod16.z.string()
565
- })
566
- });
567
-
568
- // src/modules/video-analysis/video-analysis.schemas.ts
569
- var import_zod17 = require("zod");
570
- var getPresignedUrlS3Request = import_zod17.z.object({
571
- body: import_zod17.z.object({
572
- exercise: import_zod17.z.string(),
573
- fileType: import_zod17.z.string(),
574
- jobId: import_zod17.z.string()
575
- })
576
- });
577
- var getPresignedUrlFromS3ResponseSchema = import_zod17.z.object({
578
- uploadUrl: import_zod17.z.string(),
579
- fileKey: import_zod17.z.string(),
580
- requestId: import_zod17.z.string()
581
- });
582
-
583
- // src/modules/web-sockets/web-sockets.schemas.ts
584
- var import_zod18 = require("zod");
585
- var generateTicketRequest = import_zod18.z.object({
586
- body: import_zod18.z.object({
587
- username: import_zod18.z.string()
588
- })
589
- });
590
- var generateTicketResponseSchema = import_zod18.z.object({
591
- ticket: import_zod18.z.string()
592
- });
593
- // Annotate the CommonJS export names for ESM import in node:
594
- 0 && (module.exports = {
595
- addAerobicsRequest,
596
- addWorkoutRequest,
597
- addWorkoutResponseSchema,
598
- adherenceExerciseStatsSchema,
599
- aerobicsDailyRecordSchema,
600
- aerobicsWeeklyRecordSchema,
601
- allUserMessageSchema,
602
- appleOAuthRequest,
603
- bootstrapRequest,
604
- bootstrapResponseSchema,
605
- changeEmailAndVerifyRequest,
606
- checkUserVerifyRequest,
607
- createUserRequest,
608
- createUserResponseSchema,
609
- createUserUserSchema,
610
- deleteMessageRequest,
611
- deleteMessageResponseSchema,
612
- deleteProfilePicRequest,
613
- deletedMessageSchema,
614
- exerciseInPlanSchema,
615
- exerciseMetadataSchema,
616
- exerciseTrackingAnalysisSchema,
617
- exerciseTrackingAndStatsSchema,
618
- exerciseTrackingPrMaxSchema,
619
- finishUserWorkoutResponseSchema,
620
- finishWorkoutRequest,
621
- generateTicketRequest,
622
- generateTicketResponseSchema,
623
- getAerobicsRequest,
624
- getAllExercisesResponseSchema,
625
- getAllMessagesRequest,
626
- getAllUserMessagesResponseSchema,
627
- getAnalyticsResponseSchema,
628
- getAuthenticatedUserByIdResponseSchema,
629
- getExerciseTrackingRequest,
630
- getExerciseTrackingResponseSchema,
631
- getPresignedUrlFromS3ResponseSchema,
632
- getPresignedUrlS3Request,
633
- getWholeUserWorkoutPlanResponseSchema,
634
- getWholeWorkoutPlanRequest,
635
- googleOAuthRequest,
636
- loginRequest,
637
- loginResponseSchema,
638
- logoutResponseSchema,
639
- markMessageAsReadRequest,
640
- markMessageAsReadResponseSchema,
641
- messageAsReadSchema,
642
- oAuthLoginResponseSchema,
643
- proceedLoginResponseSchema,
644
- refreshTokenResponseSchema,
645
- resetPasswordRequest,
646
- resetPasswordResponseSchema,
647
- saveUserPushTokenRequest,
648
- sendChangePassEmailRequest,
649
- sendVerificationMailRequest,
650
- setProfilePicAndUpdateDBResponseSchema,
651
- trackingByDateItemSchema,
652
- trackingBySplitNameItemSchema,
653
- trackingMapItemSchema,
654
- updateAuthenticatedUserResponseSchema,
655
- updateUserRequest,
656
- userAerobicsResponseSchema,
657
- userDataResponseSchema,
658
- userDataSchema,
659
- verifyAccountRequest,
660
- weeklyDataSchema,
661
- wholeUserWorkoutPlanSchema,
662
- workoutRmRecordSchema,
663
- workoutSplitSchema,
664
- workoutSplitsMapItemSchema,
665
- workoutSplitsMapSchema
666
- });
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/common/transport.schemas.ts
5
+ import { z } from "zod/v4";
6
+ var serializedDateSchema = z.string();
7
+ var timezoneSchema = z.string();
8
+
9
+ // src/database/database.schemas.ts
10
+ import { createInsertSchema, createSelectSchema, createUpdateSchema } from "drizzle-zod";
11
+
12
+ // ../../src/infrastructure/db/schema/drizzle/roles.ts
13
+ import { pgRole } from "drizzle-orm/pg-core";
14
+ var anonRole = pgRole("anon");
15
+ var authenticatedRole = pgRole("authenticated");
16
+ var guestRole = pgRole("guest");
17
+ var serviceRole = pgRole("service_role");
18
+ var appUserRole = pgRole("app_user");
19
+ var appRuntimeUserRole = pgRole("app_runtime_user", {
20
+ createDb: false,
21
+ createRole: false,
22
+ inherit: false
23
+ });
24
+
25
+ // ../../src/infrastructure/db/schema/drizzle/schemas.ts
26
+ import { pgSchema } from "drizzle-orm/pg-core";
27
+ var authSchema = pgSchema("auth");
28
+ var identitySchema = pgSchema("identity");
29
+ var workoutSchema = pgSchema("workout");
30
+ var trackingSchema = pgSchema("tracking");
31
+ var remindersSchema = pgSchema("reminders");
32
+ var analyticsSchema = pgSchema("analytics");
33
+ var messagesSchema = pgSchema("messages");
34
+ var authProviders = identitySchema.enum("Auth Providers", [
35
+ "apple",
36
+ "google",
37
+ "app"
38
+ ]);
39
+
40
+ // ../../src/infrastructure/db/schema/drizzle/identity/user/table.ts
41
+ import { relations as relations14, sql as drizzleSql24 } from "drizzle-orm";
42
+ import { bigint as bigint11, boolean as boolean6, primaryKey as primaryKey14, text as text8, timestamp as timestamp10, uniqueIndex as uniqueIndex3, uuid as uuid11 } from "drizzle-orm/pg-core";
43
+
44
+ // ../../src/infrastructure/db/schema/drizzle/messages/messages/table.ts
45
+ import { relations, sql as drizzleSql2 } from "drizzle-orm";
46
+ import { boolean, foreignKey, index, primaryKey, text, timestamp, uuid } from "drizzle-orm/pg-core";
47
+
48
+ // ../../src/infrastructure/db/schema/drizzle/messages/messages/policies.ts
49
+ import { sql as drizzleSql } from "drizzle-orm";
50
+ import { pgPolicy } from "drizzle-orm/pg-core";
51
+ var uid = drizzleSql`"identity"."current_user_id"()`;
52
+ function messagePolicies(t) {
53
+ const participant = drizzleSql`${uid} = ${t.senderId} or ${uid} = ${t.receiverId}`;
54
+ return [
55
+ // Lets authenticated message participants read their sent or received messages.
56
+ pgPolicy("Enable read access for auth users on message", {
57
+ for: "select",
58
+ to: authenticatedRole,
59
+ using: participant
60
+ }),
61
+ // Lets authenticated users send as themselves or as the existing system sender.
62
+ pgPolicy("Enable insert for auth users on message", {
63
+ for: "insert",
64
+ to: authenticatedRole,
65
+ withCheck: drizzleSql`${uid} = ${t.senderId} or ${t.senderId} = '8dedd0e0-8c25-4c84-a05b-4ae5f5c48f3a'::uuid`
66
+ }),
67
+ // Lets authenticated message participants update a message while remaining participants.
68
+ pgPolicy("Enable update for auth users on message", {
69
+ for: "update",
70
+ to: authenticatedRole,
71
+ using: participant,
72
+ withCheck: participant
73
+ }),
74
+ // Lets authenticated message participants delete their sent or received messages.
75
+ pgPolicy("Enable delete for auth users on message", {
76
+ for: "delete",
77
+ to: authenticatedRole,
78
+ using: participant
79
+ })
80
+ ];
81
+ }
82
+ __name(messagePolicies, "messagePolicies");
83
+
84
+ // ../../src/infrastructure/db/schema/drizzle/messages/messages/table.ts
85
+ var uid2 = drizzleSql2`"identity"."current_user_id"()`;
86
+ var message = messagesSchema.table("message", {
87
+ id: uuid("id").defaultRandom().notNull(),
88
+ senderId: uuid("sender_id").default(uid2).notNull(),
89
+ receiverId: uuid("receiver_id").default(uid2).notNull(),
90
+ subject: text("subject").default("Subject").notNull(),
91
+ msg: text("msg").default("Hello World").notNull(),
92
+ sentAt: timestamp("sent_at", {
93
+ withTimezone: true
94
+ }).default(drizzleSql2`(now() AT TIME ZONE 'utc')`).notNull(),
95
+ isRead: boolean("is_read").default(false).notNull()
96
+ }, (t) => [
97
+ primaryKey({
98
+ name: "message_pkey",
99
+ columns: [
100
+ t.id
101
+ ]
102
+ }),
103
+ foreignKey({
104
+ name: "message_sender_id_fkey",
105
+ columns: [
106
+ t.senderId
107
+ ],
108
+ foreignColumns: [
109
+ user.id
110
+ ]
111
+ }).onUpdate("cascade").onDelete("cascade"),
112
+ foreignKey({
113
+ name: "message_receiver_id_fkey",
114
+ columns: [
115
+ t.receiverId
116
+ ],
117
+ foreignColumns: [
118
+ user.id
119
+ ]
120
+ }).onUpdate("cascade").onDelete("cascade"),
121
+ index("message_receiver_id_idx").on(t.receiverId),
122
+ ...messagePolicies(t)
123
+ ]);
124
+ var messageRelations = relations(message, ({ one }) => ({
125
+ sender: one(user, {
126
+ fields: [
127
+ message.senderId
128
+ ],
129
+ references: [
130
+ user.id
131
+ ],
132
+ relationName: "messageSender"
133
+ }),
134
+ receiver: one(user, {
135
+ fields: [
136
+ message.receiverId
137
+ ],
138
+ references: [
139
+ user.id
140
+ ],
141
+ relationName: "messageReceiver"
142
+ })
143
+ }));
144
+
145
+ // ../../src/infrastructure/db/schema/drizzle/reminders/user_reminder_setting/table.ts
146
+ import { relations as relations2, sql as drizzleSql4 } from "drizzle-orm";
147
+ import { boolean as boolean2, foreignKey as foreignKey2, integer, primaryKey as primaryKey2, text as text2, timestamp as timestamp2, uuid as uuid2 } from "drizzle-orm/pg-core";
148
+
149
+ // ../../src/infrastructure/db/schema/drizzle/reminders/user_reminder_setting/policies.ts
150
+ import { sql as drizzleSql3 } from "drizzle-orm";
151
+ import { pgPolicy as pgPolicy2 } from "drizzle-orm/pg-core";
152
+ var uid3 = drizzleSql3`"identity"."current_user_id"()`;
153
+ function userReminderSettingPolicies(t) {
154
+ return [
155
+ // Lets authenticated users read only their own reminder settings.
156
+ pgPolicy2("auth can SELECT own reminder settings", {
157
+ for: "select",
158
+ to: authenticatedRole,
159
+ using: drizzleSql3`${uid3} = ${t.userId}`
160
+ }),
161
+ // Lets authenticated users insert reminder settings only for themselves.
162
+ pgPolicy2("auth can INSERT own reminder settings", {
163
+ for: "insert",
164
+ to: authenticatedRole,
165
+ withCheck: drizzleSql3`${uid3} = ${t.userId}`
166
+ }),
167
+ // Lets authenticated users update their own reminder settings and preserves ownership.
168
+ pgPolicy2("auth can UPDATE own reminder settings", {
169
+ for: "update",
170
+ to: authenticatedRole,
171
+ using: drizzleSql3`${uid3} = ${t.userId}`,
172
+ withCheck: drizzleSql3`${uid3} = ${t.userId}`
173
+ }),
174
+ // Provides the original additional update policy for settings owned by the user.
175
+ pgPolicy2("Allow authenticated users to update their own reminder settings", {
176
+ for: "update",
177
+ to: authenticatedRole,
178
+ using: drizzleSql3`${uid3} = ${t.userId}`
179
+ })
180
+ ];
181
+ }
182
+ __name(userReminderSettingPolicies, "userReminderSettingPolicies");
183
+
184
+ // ../../src/infrastructure/db/schema/drizzle/reminders/user_reminder_setting/table.ts
185
+ var userReminderSetting = remindersSchema.table("user_reminder_setting", {
186
+ userId: uuid2("user_id").notNull(),
187
+ workoutRemindersEnabled: boolean2("workout_reminders_enabled").default(true).notNull(),
188
+ reminderOffsetMinutes: integer("reminder_offset_minutes").default(60).notNull(),
189
+ updatedAt: timestamp2("updated_at", {
190
+ withTimezone: true
191
+ }).default(drizzleSql4`timezone('UTC', now())`).notNull(),
192
+ timezone: text2("timezone").default("'UTC'::text")
193
+ }, (t) => [
194
+ primaryKey2({
195
+ name: "user_reminder_setting_pkey",
196
+ columns: [
197
+ t.userId
198
+ ]
199
+ }),
200
+ foreignKey2({
201
+ name: "user_reminder_setting_user_id_fkey",
202
+ columns: [
203
+ t.userId
204
+ ],
205
+ foreignColumns: [
206
+ user.id
207
+ ]
208
+ }).onDelete("cascade"),
209
+ ...userReminderSettingPolicies(t)
210
+ ]);
211
+ var userReminderSettingRelations = relations2(userReminderSetting, ({ one }) => ({
212
+ user: one(user, {
213
+ fields: [
214
+ userReminderSetting.userId
215
+ ],
216
+ references: [
217
+ user.id
218
+ ]
219
+ })
220
+ }));
221
+
222
+ // ../../src/infrastructure/db/schema/drizzle/reminders/user_split_information/table.ts
223
+ import { relations as relations11, sql as drizzleSql18 } from "drizzle-orm";
224
+ import { bigint as bigint9, foreignKey as foreignKey10, index as index8, integer as integer4, numeric, primaryKey as primaryKey11, timestamp as timestamp7, unique as unique5, uuid as uuid8 } from "drizzle-orm/pg-core";
225
+
226
+ // ../../src/infrastructure/db/schema/drizzle/workout/workout_split/table.ts
227
+ import { relations as relations10, sql as drizzleSql17 } from "drizzle-orm";
228
+ import { bigint as bigint8, boolean as boolean5, foreignKey as foreignKey9, index as index7, primaryKey as primaryKey10, text as text5, timestamp as timestamp6, unique as unique4 } from "drizzle-orm/pg-core";
229
+
230
+ // ../../src/infrastructure/db/schema/drizzle/tracking/workout_summary/table.ts
231
+ import { relations as relations8, sql as drizzleSql13 } from "drizzle-orm";
232
+ import { bigint as bigint6, foreignKey as foreignKey7, index as index6, primaryKey as primaryKey8, timestamp as timestamp4, uuid as uuid6 } from "drizzle-orm/pg-core";
233
+
234
+ // ../../src/infrastructure/db/schema/drizzle/tracking/exercise_tracking/table.ts
235
+ import { relations as relations7, sql as drizzleSql11 } from "drizzle-orm";
236
+ import { bigint as bigint5, foreignKey as foreignKey6, index as index5, primaryKey as primaryKey7, text as text4, uuid as uuid5 } from "drizzle-orm/pg-core";
237
+
238
+ // ../../src/infrastructure/db/schema/drizzle/workout/exercises/table.ts
239
+ import { relations as relations5 } from "drizzle-orm";
240
+ import { bigint as bigint3, primaryKey as primaryKey5, text as text3, uniqueIndex } from "drizzle-orm/pg-core";
241
+
242
+ // ../../src/infrastructure/db/schema/drizzle/workout/exercisetoworkoutsplit/table.ts
243
+ import { relations as relations4, sql as drizzleSql7 } from "drizzle-orm";
244
+ import { bigint as bigint2, boolean as boolean3, foreignKey as foreignKey4, index as index3, primaryKey as primaryKey4, timestamp as timestamp3, unique as unique2 } from "drizzle-orm/pg-core";
245
+
246
+ // ../../src/infrastructure/db/schema/drizzle/workout/workout_set/table.ts
247
+ import { relations as relations3 } from "drizzle-orm";
248
+ import { bigint, foreignKey as foreignKey3, index as index2, integer as integer2, primaryKey as primaryKey3, unique, uuid as uuid3 } from "drizzle-orm/pg-core";
249
+
250
+ // ../../src/infrastructure/db/schema/drizzle/workout/workout_set/policies.ts
251
+ import { sql as drizzleSql5 } from "drizzle-orm";
252
+ import { pgPolicy as pgPolicy3 } from "drizzle-orm/pg-core";
253
+ var currentUserId = drizzleSql5`"identity"."current_user_id"()`;
254
+ function workoutSetPolicies(table) {
255
+ const ownsWorkoutSet = drizzleSql5`exists (
256
+ select 1
257
+ from "workout"."exercise_to_workout_split" ets
258
+ join "workout"."workout_split" ws on ws."id" = ets."workout_split_id"
259
+ join "workout"."workout_plan" wp on wp."id" = ws."workout_id"
260
+ where ets."id" = ${table.exerciseToSplitId}
261
+ and wp."user_id" = ${currentUserId}
262
+ )`;
263
+ return [
264
+ // Lets authenticated users read planned sets only from workout plans they own.
265
+ pgPolicy3("Enable read access for auth users on workout_set", {
266
+ for: "select",
267
+ to: authenticatedRole,
268
+ using: ownsWorkoutSet
269
+ }),
270
+ // Lets authenticated users add planned sets only to workout plans they own.
271
+ pgPolicy3("Enable insert for auth users on workout_set", {
272
+ for: "insert",
273
+ to: authenticatedRole,
274
+ withCheck: ownsWorkoutSet
275
+ }),
276
+ // Lets authenticated users update planned sets only within workout plans they own.
277
+ pgPolicy3("Enable update for auth users on workout_set", {
278
+ for: "update",
279
+ to: authenticatedRole,
280
+ using: ownsWorkoutSet,
281
+ withCheck: ownsWorkoutSet
282
+ }),
283
+ // Lets authenticated users delete planned sets only from workout plans they own.
284
+ pgPolicy3("Enable delete for auth users on workout_set", {
285
+ for: "delete",
286
+ to: authenticatedRole,
287
+ using: ownsWorkoutSet
288
+ })
289
+ ];
290
+ }
291
+ __name(workoutSetPolicies, "workoutSetPolicies");
292
+
293
+ // ../../src/infrastructure/db/schema/drizzle/workout/workout_set/table.ts
294
+ var workoutSet = workoutSchema.table("workout_set", {
295
+ id: uuid3("id").defaultRandom().notNull(),
296
+ exerciseToSplitId: bigint("exercise_to_split_id", {
297
+ mode: "number"
298
+ }).notNull(),
299
+ orderIndex: integer2("order_index").notNull(),
300
+ reps: integer2("reps").notNull()
301
+ }, (t) => [
302
+ primaryKey3({
303
+ name: "workout_set_pkey",
304
+ columns: [
305
+ t.id
306
+ ]
307
+ }),
308
+ unique("workout_set_exercise_order_unique").on(t.exerciseToSplitId, t.orderIndex),
309
+ foreignKey3({
310
+ name: "workout_set_exercise_to_split_id_fkey",
311
+ columns: [
312
+ t.exerciseToSplitId
313
+ ],
314
+ foreignColumns: [
315
+ exerciseToWorkoutSplit.id
316
+ ]
317
+ }).onUpdate("cascade").onDelete("cascade"),
318
+ index2("workout_set_exercise_to_split_id_idx").on(t.exerciseToSplitId),
319
+ ...workoutSetPolicies(t)
320
+ ]);
321
+ var workoutSetRelations = relations3(workoutSet, ({ one }) => ({
322
+ exerciseToWorkoutSplit: one(exerciseToWorkoutSplit, {
323
+ fields: [
324
+ workoutSet.exerciseToSplitId
325
+ ],
326
+ references: [
327
+ exerciseToWorkoutSplit.id
328
+ ]
329
+ })
330
+ }));
331
+
332
+ // ../../src/infrastructure/db/schema/drizzle/workout/exercisetoworkoutsplit/policies.ts
333
+ import { sql as drizzleSql6 } from "drizzle-orm";
334
+ import { pgPolicy as pgPolicy4 } from "drizzle-orm/pg-core";
335
+ var uid4 = drizzleSql6`"identity"."current_user_id"()`;
336
+ function exerciseToWorkoutSplitPolicies(t) {
337
+ const owns = drizzleSql6`${uid4} = (select wp."user_id" from "workout"."workout_plan" wp join "workout"."workout_split" ws on ws."workout_id" = wp."id" where ws."id" = ${t.workoutSplitId})`;
338
+ const ownsForDelete = drizzleSql6`exists (select 1 from "workout"."workout_split" ws join "workout"."workout_plan" wp on wp."id" = ws."workout_id" where ws."id" = ${t.workoutSplitId} and wp."user_id" = ${uid4})`;
339
+ return [
340
+ // Lets authenticated users read exercise assignments in splits they own.
341
+ pgPolicy4("Enable read access for auth users on exercise_to_workout_split", {
342
+ for: "select",
343
+ to: authenticatedRole,
344
+ using: owns
345
+ }),
346
+ // Lets authenticated users add exercise assignments only to splits they own.
347
+ pgPolicy4("Enable insert for auth users on exercise_to_workout_split", {
348
+ for: "insert",
349
+ to: authenticatedRole,
350
+ withCheck: owns
351
+ }),
352
+ // Lets authenticated users update exercise assignments only in splits they own.
353
+ pgPolicy4("Enable update for auth users on exercise_to_workout_split", {
354
+ for: "update",
355
+ to: authenticatedRole,
356
+ using: owns,
357
+ withCheck: owns
358
+ }),
359
+ // Lets authenticated users delete exercise assignments only from splits they own.
360
+ pgPolicy4("Enable delete for auth users on exercise_to_workout_split", {
361
+ for: "delete",
362
+ to: authenticatedRole,
363
+ using: ownsForDelete
364
+ })
365
+ ];
366
+ }
367
+ __name(exerciseToWorkoutSplitPolicies, "exerciseToWorkoutSplitPolicies");
368
+
369
+ // ../../src/infrastructure/db/schema/drizzle/workout/exercisetoworkoutsplit/table.ts
370
+ var exerciseToWorkoutSplit = workoutSchema.table("exercise_to_workout_split", {
371
+ id: bigint2("id", {
372
+ mode: "number"
373
+ }).generatedByDefaultAsIdentity({
374
+ name: "exercise_to_workout_split_id_seq"
375
+ }).notNull(),
376
+ workoutSplitId: bigint2("workout_split_id", {
377
+ mode: "number"
378
+ }).notNull(),
379
+ exerciseId: bigint2("exercise_id", {
380
+ mode: "number"
381
+ }).notNull(),
382
+ createdAt: timestamp3("created_at", {
383
+ withTimezone: true
384
+ }).default(drizzleSql7`(now() AT TIME ZONE 'utc')`).notNull(),
385
+ orderIndex: bigint2("order_index", {
386
+ mode: "number"
387
+ }).notNull(),
388
+ isActive: boolean3("is_active").default(true).notNull()
389
+ }, (t) => [
390
+ primaryKey4({
391
+ name: "exercise_to_workout_split_pkey",
392
+ columns: [
393
+ t.id
394
+ ]
395
+ }),
396
+ unique2("uq_exercise_to_workout_split_workout_split_exercise").on(t.workoutSplitId, t.exerciseId),
397
+ foreignKey4({
398
+ name: "exercise_to_workout_split_exercise_id_fkey",
399
+ columns: [
400
+ t.exerciseId
401
+ ],
402
+ foreignColumns: [
403
+ exercise.id
404
+ ]
405
+ }).onUpdate("cascade").onDelete("cascade"),
406
+ foreignKey4({
407
+ name: "exercise_to_workout_split_workout_split_id_fkey",
408
+ columns: [
409
+ t.workoutSplitId
410
+ ],
411
+ foreignColumns: [
412
+ workoutSplit.id
413
+ ]
414
+ }).onUpdate("cascade").onDelete("cascade"),
415
+ index3("exercise_to_workout_split_active_idx").on(t.workoutSplitId, t.orderIndex).where(drizzleSql7`${t.isActive} = true`),
416
+ index3("exercise_to_workout_split_workout_split_id_order_index_idx").on(t.workoutSplitId, t.orderIndex),
417
+ ...exerciseToWorkoutSplitPolicies(t)
418
+ ]);
419
+ var exerciseToWorkoutSplitRelations = relations4(exerciseToWorkoutSplit, ({ many, one }) => ({
420
+ exercise: one(exercise, {
421
+ fields: [
422
+ exerciseToWorkoutSplit.exerciseId
423
+ ],
424
+ references: [
425
+ exercise.id
426
+ ]
427
+ }),
428
+ workoutSplit: one(workoutSplit, {
429
+ fields: [
430
+ exerciseToWorkoutSplit.workoutSplitId
431
+ ],
432
+ references: [
433
+ workoutSplit.id
434
+ ]
435
+ }),
436
+ exerciseTrackings: many(exerciseTracking),
437
+ workoutSets: many(workoutSet)
438
+ }));
439
+
440
+ // ../../src/infrastructure/db/schema/drizzle/workout/exercises/policies.ts
441
+ import { sql as drizzleSql8 } from "drizzle-orm";
442
+ import { pgPolicy as pgPolicy5 } from "drizzle-orm/pg-core";
443
+ var exercisePolicies = /* @__PURE__ */ __name(() => [
444
+ // Makes the shared exercise catalog readable to every authenticated user.
445
+ pgPolicy5("Allow all authenticated users to read exercise", {
446
+ for: "select",
447
+ to: authenticatedRole,
448
+ using: drizzleSql8`true`
449
+ })
450
+ ], "exercisePolicies");
451
+
452
+ // ../../src/infrastructure/db/schema/drizzle/workout/exercises/table.ts
453
+ var exercise = workoutSchema.table("exercise", {
454
+ id: bigint3("id", {
455
+ mode: "number"
456
+ }).generatedByDefaultAsIdentity({
457
+ name: "exercise_id_seq"
458
+ }).notNull(),
459
+ name: text3("name").notNull(),
460
+ description: text3("description").notNull(),
461
+ targetMuscle: text3("target_muscle").notNull(),
462
+ specificTargetMuscle: text3("specific_target_muscle").notNull()
463
+ }, (t) => [
464
+ primaryKey5({
465
+ name: "exercise_pkey",
466
+ columns: [
467
+ t.id
468
+ ]
469
+ }),
470
+ uniqueIndex("exercise_name_unique").on(t.name),
471
+ ...exercisePolicies()
472
+ ]);
473
+ var exerciseRelations = relations5(exercise, ({ many }) => ({
474
+ workoutSplitAssignments: many(exerciseToWorkoutSplit)
475
+ }));
476
+
477
+ // ../../src/infrastructure/db/schema/drizzle/tracking/tracking_set/table.ts
478
+ import { relations as relations6 } from "drizzle-orm";
479
+ import { bigint as bigint4, foreignKey as foreignKey5, index as index4, integer as integer3, primaryKey as primaryKey6, real, unique as unique3, uuid as uuid4 } from "drizzle-orm/pg-core";
480
+
481
+ // ../../src/infrastructure/db/schema/drizzle/tracking/tracking_set/policies.ts
482
+ import { sql as drizzleSql9 } from "drizzle-orm";
483
+ import { pgPolicy as pgPolicy6 } from "drizzle-orm/pg-core";
484
+ var currentUserId2 = drizzleSql9`"identity"."current_user_id"()`;
485
+ function trackingSetPolicies(table) {
486
+ const ownsExerciseTracking = drizzleSql9`exists (
487
+ select 1
488
+ from "tracking"."exercise_tracking" et
489
+ join "tracking"."workout_summary" ws on ws."id" = et."workout_summary_id"
490
+ where et."id" = ${table.exerciseTrackingId}
491
+ and ws."user_id" = ${currentUserId2}
492
+ )`;
493
+ return [
494
+ // Lets authenticated users read tracked sets only from workout summaries they own.
495
+ pgPolicy6("Enable read access for auth users on tracking_set", {
496
+ for: "select",
497
+ to: authenticatedRole,
498
+ using: ownsExerciseTracking
499
+ }),
500
+ // Lets authenticated users add tracked sets only to their own exercise tracking rows.
501
+ pgPolicy6("Enable insert for auth users on tracking_set", {
502
+ for: "insert",
503
+ to: authenticatedRole,
504
+ withCheck: ownsExerciseTracking
505
+ }),
506
+ // Lets authenticated users update tracked sets without moving them outside their own workout.
507
+ pgPolicy6("Enable update for auth users on tracking_set", {
508
+ for: "update",
509
+ to: authenticatedRole,
510
+ using: ownsExerciseTracking,
511
+ withCheck: ownsExerciseTracking
512
+ }),
513
+ // Lets authenticated users delete tracked sets only from workout summaries they own.
514
+ pgPolicy6("Enable delete for auth users on tracking_set", {
515
+ for: "delete",
516
+ to: authenticatedRole,
517
+ using: ownsExerciseTracking
518
+ })
519
+ ];
520
+ }
521
+ __name(trackingSetPolicies, "trackingSetPolicies");
522
+
523
+ // ../../src/infrastructure/db/schema/drizzle/tracking/tracking_set/table.ts
524
+ var trackingSet = trackingSchema.table("tracking_set", {
525
+ id: uuid4("id").defaultRandom().notNull(),
526
+ exerciseTrackingId: bigint4("exercise_tracking_id", {
527
+ mode: "number"
528
+ }).notNull(),
529
+ setIndex: integer3("set_index").notNull(),
530
+ reps: integer3("reps").notNull(),
531
+ weight: real("weight").notNull()
532
+ }, (t) => [
533
+ primaryKey6({
534
+ name: "tracking_set_pkey",
535
+ columns: [
536
+ t.id
537
+ ]
538
+ }),
539
+ unique3("tracking_set_exercise_index_unique").on(t.exerciseTrackingId, t.setIndex),
540
+ foreignKey5({
541
+ name: "tracking_set_exercise_tracking_id_fkey",
542
+ columns: [
543
+ t.exerciseTrackingId
544
+ ],
545
+ foreignColumns: [
546
+ exerciseTracking.id
547
+ ]
548
+ }).onUpdate("cascade").onDelete("cascade"),
549
+ index4("tracking_set_exercise_tracking_id_idx").on(t.exerciseTrackingId),
550
+ ...trackingSetPolicies(t)
551
+ ]);
552
+ var trackingSetRelations = relations6(trackingSet, ({ one }) => ({
553
+ exerciseTracking: one(exerciseTracking, {
554
+ fields: [
555
+ trackingSet.exerciseTrackingId
556
+ ],
557
+ references: [
558
+ exerciseTracking.id
559
+ ]
560
+ })
561
+ }));
562
+
563
+ // ../../src/infrastructure/db/schema/drizzle/tracking/exercise_tracking/policies.ts
564
+ import { sql as drizzleSql10 } from "drizzle-orm";
565
+ import { pgPolicy as pgPolicy7 } from "drizzle-orm/pg-core";
566
+ var uid5 = drizzleSql10`"identity"."current_user_id"()`;
567
+ function exerciseTrackingPolicies(t) {
568
+ const owns = drizzleSql10`exists (select 1 from "tracking"."workout_summary" ws where ws."id" = ${t.workoutSummaryId} and ws."user_id" = ${uid5})`;
569
+ return [
570
+ // Lets authenticated users read exercise tracking rows through summaries they own.
571
+ pgPolicy7("exercise_tracking_select_by_summary_owner", {
572
+ for: "select",
573
+ to: authenticatedRole,
574
+ using: owns
575
+ }),
576
+ // Lets authenticated users insert exercise tracking rows through summaries they own.
577
+ pgPolicy7("exercise_tracking_insert_by_summary_owner", {
578
+ for: "insert",
579
+ to: authenticatedRole,
580
+ withCheck: owns
581
+ }),
582
+ // Lets authenticated users update exercise tracking rows through summaries they own.
583
+ pgPolicy7("exercise_tracking_update_by_summary_owner", {
584
+ for: "update",
585
+ to: authenticatedRole,
586
+ using: owns,
587
+ withCheck: owns
588
+ }),
589
+ // Lets authenticated users delete exercise tracking rows through summaries they own.
590
+ pgPolicy7("exercise_tracking_delete_by_summary_owner", {
591
+ for: "delete",
592
+ to: authenticatedRole,
593
+ using: owns
594
+ })
595
+ ];
596
+ }
597
+ __name(exerciseTrackingPolicies, "exerciseTrackingPolicies");
598
+
599
+ // ../../src/infrastructure/db/schema/drizzle/tracking/exercise_tracking/table.ts
600
+ import { check } from "drizzle-orm/pg-core";
601
+ var exerciseTracking = trackingSchema.table("exercise_tracking", {
602
+ id: bigint5("id", {
603
+ mode: "number"
604
+ }).generatedByDefaultAsIdentity({
605
+ name: "exercise_tracking_id_seq"
606
+ }).notNull(),
607
+ workoutSummaryId: uuid5("workout_summary_id").notNull(),
608
+ exerciseToSplitId: bigint5("exercise_to_split_id", {
609
+ mode: "number"
610
+ }),
611
+ exerciseId: bigint5("exercise_id", {
612
+ mode: "number"
613
+ }),
614
+ notes: text4("notes")
615
+ }, (t) => [
616
+ primaryKey7({
617
+ name: "exercise_tracking_pkey",
618
+ columns: [
619
+ t.id
620
+ ]
621
+ }),
622
+ foreignKey6({
623
+ name: "exercise_tracking_exercise_to_split_id_fkey",
624
+ columns: [
625
+ t.exerciseToSplitId
626
+ ],
627
+ foreignColumns: [
628
+ exerciseToWorkoutSplit.id
629
+ ]
630
+ }).onUpdate("cascade").onDelete("cascade"),
631
+ foreignKey6({
632
+ name: "exercise_tracking_exercise_id_fkey",
633
+ columns: [
634
+ t.exerciseId
635
+ ],
636
+ foreignColumns: [
637
+ exercise.id
638
+ ]
639
+ }).onUpdate("cascade").onDelete("cascade"),
640
+ foreignKey6({
641
+ name: "exercise_tracking_workout_summary_id_fkey",
642
+ columns: [
643
+ t.workoutSummaryId
644
+ ],
645
+ foreignColumns: [
646
+ workoutSummary.id
647
+ ]
648
+ }).onUpdate("cascade").onDelete("cascade"),
649
+ check("exercise_tracking_xor_check", drizzleSql11`num_nonnulls(${t.exerciseToSplitId}, ${t.exerciseId}) = 1`),
650
+ index5("exercise_tracking_workout_summary_id_idx").on(t.workoutSummaryId),
651
+ ...exerciseTrackingPolicies(t)
652
+ ]);
653
+ var exerciseTrackingRelations = relations7(exerciseTracking, ({ many, one }) => ({
654
+ exerciseToWorkoutSplit: one(exerciseToWorkoutSplit, {
655
+ fields: [
656
+ exerciseTracking.exerciseToSplitId
657
+ ],
658
+ references: [
659
+ exerciseToWorkoutSplit.id
660
+ ]
661
+ }),
662
+ workoutSummary: one(workoutSummary, {
663
+ fields: [
664
+ exerciseTracking.workoutSummaryId
665
+ ],
666
+ references: [
667
+ workoutSummary.id
668
+ ]
669
+ }),
670
+ trackingSets: many(trackingSet),
671
+ exercise: one(exercise, {
672
+ fields: [
673
+ exerciseTracking.exerciseId
674
+ ],
675
+ references: [
676
+ exercise.id
677
+ ]
678
+ })
679
+ }));
680
+
681
+ // ../../src/infrastructure/db/schema/drizzle/tracking/workout_summary/policies.ts
682
+ import { sql as drizzleSql12 } from "drizzle-orm";
683
+ import { pgPolicy as pgPolicy8 } from "drizzle-orm/pg-core";
684
+ var uid6 = drizzleSql12`"identity"."current_user_id"()`;
685
+ function workoutSummaryPolicies(t) {
686
+ return [
687
+ // Lets authenticated users read only their own completed workout summaries.
688
+ pgPolicy8("users can read their workout summaries", {
689
+ for: "select",
690
+ to: authenticatedRole,
691
+ using: drizzleSql12`${t.userId} = ${uid6}`
692
+ }),
693
+ // Lets authenticated users insert completed workout summaries only for themselves.
694
+ pgPolicy8("users can insert their workout summaries", {
695
+ for: "insert",
696
+ to: authenticatedRole,
697
+ withCheck: drizzleSql12`${t.userId} = ${uid6}`
698
+ }),
699
+ // Lets authenticated users update only their own completed workout summaries.
700
+ pgPolicy8("users can update their workout summaries", {
701
+ for: "update",
702
+ to: authenticatedRole,
703
+ using: drizzleSql12`${t.userId} = ${uid6}`,
704
+ withCheck: drizzleSql12`${t.userId} = ${uid6}`
705
+ }),
706
+ // Lets authenticated users delete only their own completed workout summaries.
707
+ pgPolicy8("users can delete their workout summaries", {
708
+ for: "delete",
709
+ to: authenticatedRole,
710
+ using: drizzleSql12`${t.userId} = ${uid6}`
711
+ })
712
+ ];
713
+ }
714
+ __name(workoutSummaryPolicies, "workoutSummaryPolicies");
715
+
716
+ // ../../src/infrastructure/db/schema/drizzle/tracking/workout_summary/table.ts
717
+ var workoutSummary = trackingSchema.table("workout_summary", {
718
+ id: uuid6("id").defaultRandom().notNull(),
719
+ userId: uuid6("user_id").notNull(),
720
+ workoutSplitId: bigint6("workout_split_id", {
721
+ mode: "number"
722
+ }).notNull(),
723
+ workoutStartUtc: timestamp4("workout_start_utc", {
724
+ withTimezone: true
725
+ }).notNull(),
726
+ workoutEndUtc: timestamp4("workout_end_utc", {
727
+ withTimezone: true
728
+ }).notNull(),
729
+ createdAt: timestamp4("created_at", {
730
+ withTimezone: true
731
+ }).defaultNow().notNull()
732
+ }, (t) => [
733
+ primaryKey8({
734
+ name: "workout_summary_pkey",
735
+ columns: [
736
+ t.id
737
+ ]
738
+ }),
739
+ foreignKey7({
740
+ name: "workout_summary_user_id_fkey",
741
+ columns: [
742
+ t.userId
743
+ ],
744
+ foreignColumns: [
745
+ user.id
746
+ ]
747
+ }).onDelete("cascade"),
748
+ foreignKey7({
749
+ name: "workout_summary_workout_split_id_fkey",
750
+ columns: [
751
+ t.workoutSplitId
752
+ ],
753
+ foreignColumns: [
754
+ workoutSplit.id
755
+ ]
756
+ }).onUpdate("cascade").onDelete("cascade"),
757
+ index6("workout_summary_start_date_idx").on(drizzleSql13`((${t.workoutStartUtc} at time zone 'UTC')::date)`),
758
+ index6("workout_summary_user_start_utc_idx").on(t.userId, t.workoutStartUtc.desc().nullsFirst()),
759
+ ...workoutSummaryPolicies(t)
760
+ ]);
761
+ var workoutSummaryRelations = relations8(workoutSummary, ({ many, one }) => ({
762
+ user: one(user, {
763
+ fields: [
764
+ workoutSummary.userId
765
+ ],
766
+ references: [
767
+ user.id
768
+ ]
769
+ }),
770
+ workoutSplit: one(workoutSplit, {
771
+ fields: [
772
+ workoutSummary.workoutSplitId
773
+ ],
774
+ references: [
775
+ workoutSplit.id
776
+ ]
777
+ }),
778
+ exerciseTrackings: many(exerciseTracking)
779
+ }));
780
+
781
+ // ../../src/infrastructure/db/schema/drizzle/workout/workout_plan/table.ts
782
+ import { relations as relations9, sql as drizzleSql15 } from "drizzle-orm";
783
+ import { bigint as bigint7, boolean as boolean4, foreignKey as foreignKey8, primaryKey as primaryKey9, timestamp as timestamp5, uniqueIndex as uniqueIndex2, uuid as uuid7 } from "drizzle-orm/pg-core";
784
+
785
+ // ../../src/infrastructure/db/schema/drizzle/workout/workout_plan/policies.ts
786
+ import { sql as drizzleSql14 } from "drizzle-orm";
787
+ import { pgPolicy as pgPolicy9 } from "drizzle-orm/pg-core";
788
+ var uid7 = drizzleSql14`"identity"."current_user_id"()`;
789
+ function workoutPlanPolicies(t) {
790
+ return [
791
+ // Lets authenticated users read only workout plans they own.
792
+ pgPolicy9("Enable read access for auth users on workout_plan", {
793
+ for: "select",
794
+ to: authenticatedRole,
795
+ using: drizzleSql14`${uid7} = ${t.userId}`
796
+ }),
797
+ // Lets authenticated users create workout plans only for themselves.
798
+ pgPolicy9("Enable insert for auth users on workout_plan", {
799
+ for: "insert",
800
+ to: authenticatedRole,
801
+ withCheck: drizzleSql14`${uid7} = ${t.userId}`
802
+ }),
803
+ // Lets authenticated users update only workout plans they own.
804
+ pgPolicy9("Enable update for auth users on workout_plan", {
805
+ for: "update",
806
+ to: authenticatedRole,
807
+ using: drizzleSql14`${uid7} = ${t.userId}`,
808
+ withCheck: drizzleSql14`${uid7} = ${t.userId}`
809
+ }),
810
+ // Lets authenticated users delete only workout plans they own.
811
+ pgPolicy9("Enable delete for auth users on workout_plan", {
812
+ for: "delete",
813
+ to: authenticatedRole,
814
+ using: drizzleSql14`${uid7} = ${t.userId}`
815
+ })
816
+ ];
817
+ }
818
+ __name(workoutPlanPolicies, "workoutPlanPolicies");
819
+
820
+ // ../../src/infrastructure/db/schema/drizzle/workout/workout_plan/table.ts
821
+ var workoutPlan = workoutSchema.table("workout_plan", {
822
+ id: bigint7("id", {
823
+ mode: "number"
824
+ }).generatedByDefaultAsIdentity({
825
+ name: "workout_plan_id_seq"
826
+ }).notNull(),
827
+ userId: uuid7("user_id").notNull(),
828
+ isActive: boolean4("is_active").default(true).notNull(),
829
+ updatedAt: timestamp5("updated_at", {
830
+ withTimezone: true
831
+ }).default(drizzleSql15`(now() AT TIME ZONE 'utc')`).notNull(),
832
+ createdAt: timestamp5("created_at", {
833
+ withTimezone: true
834
+ }).defaultNow().notNull()
835
+ }, (t) => [
836
+ primaryKey9({
837
+ name: "workout_plan_pkey",
838
+ columns: [
839
+ t.id
840
+ ]
841
+ }),
842
+ foreignKey8({
843
+ name: "workout_plan_user_id_fkey",
844
+ columns: [
845
+ t.userId
846
+ ],
847
+ foreignColumns: [
848
+ user.id
849
+ ]
850
+ }).onUpdate("cascade").onDelete("cascade"),
851
+ uniqueIndex2("uq_workout_plan_active_user").on(t.userId).where(drizzleSql15`${t.isActive}`),
852
+ ...workoutPlanPolicies(t)
853
+ ]);
854
+ var workoutPlanRelations = relations9(workoutPlan, ({ many, one }) => ({
855
+ owner: one(user, {
856
+ fields: [
857
+ workoutPlan.userId
858
+ ],
859
+ references: [
860
+ user.id
861
+ ],
862
+ relationName: "workoutPlanOwner"
863
+ }),
864
+ splits: many(workoutSplit)
865
+ }));
866
+
867
+ // ../../src/infrastructure/db/schema/drizzle/workout/workout_split/policies.ts
868
+ import { sql as drizzleSql16 } from "drizzle-orm";
869
+ import { pgPolicy as pgPolicy10 } from "drizzle-orm/pg-core";
870
+ var uid8 = drizzleSql16`"identity"."current_user_id"()`;
871
+ function workoutSplitPolicies(t) {
872
+ const owns = drizzleSql16`${uid8} = (select wp."user_id" from "workout"."workout_plan" wp where wp."id" = ${t.workoutId})`;
873
+ const ownsForDelete = drizzleSql16`exists (select 1 from "workout"."workout_plan" wp where wp."id" = ${t.workoutId} and wp."user_id" = ${uid8})`;
874
+ return [
875
+ // Lets authenticated users read splits belonging to their own plans.
876
+ pgPolicy10("Enable read access for auth users on workout_split", {
877
+ for: "select",
878
+ to: authenticatedRole,
879
+ using: owns
880
+ }),
881
+ // Lets authenticated users add splits only to their own plans.
882
+ pgPolicy10("Enable insert for auth users on workout_split", {
883
+ for: "insert",
884
+ to: authenticatedRole,
885
+ withCheck: owns
886
+ }),
887
+ // Lets authenticated users update splits only within their own plans.
888
+ pgPolicy10("Enable update for auth users on workout_split", {
889
+ for: "update",
890
+ to: authenticatedRole,
891
+ using: owns,
892
+ withCheck: owns
893
+ }),
894
+ // Lets authenticated users delete splits only from their own plans.
895
+ pgPolicy10("Enable delete for auth users on workout_split", {
896
+ for: "delete",
897
+ to: authenticatedRole,
898
+ using: ownsForDelete
899
+ })
900
+ ];
901
+ }
902
+ __name(workoutSplitPolicies, "workoutSplitPolicies");
903
+
904
+ // ../../src/infrastructure/db/schema/drizzle/workout/workout_split/table.ts
905
+ var workoutSplit = workoutSchema.table("workout_split", {
906
+ id: bigint8("id", {
907
+ mode: "number"
908
+ }).generatedByDefaultAsIdentity({
909
+ name: "workout_split_id_seq"
910
+ }).notNull(),
911
+ workoutId: bigint8("workout_id", {
912
+ mode: "number"
913
+ }).notNull(),
914
+ name: text5("name").notNull(),
915
+ createdAt: timestamp6("created_at", {
916
+ withTimezone: true
917
+ }).default(drizzleSql17`(now() AT TIME ZONE 'utc')`).notNull(),
918
+ isActive: boolean5("is_active").default(true).notNull()
919
+ }, (t) => [
920
+ primaryKey10({
921
+ name: "workout_split_pkey",
922
+ columns: [
923
+ t.id
924
+ ]
925
+ }),
926
+ unique4("uq_workout_split_plan_name").on(t.workoutId, t.name),
927
+ foreignKey9({
928
+ name: "workout_split_workout_id_fkey",
929
+ columns: [
930
+ t.workoutId
931
+ ],
932
+ foreignColumns: [
933
+ workoutPlan.id
934
+ ]
935
+ }).onUpdate("cascade").onDelete("cascade"),
936
+ index7("workout_split_workout_id_idx").on(t.workoutId),
937
+ ...workoutSplitPolicies(t)
938
+ ]);
939
+ var workoutSplitRelations = relations10(workoutSplit, ({ many, one }) => ({
940
+ workoutPlan: one(workoutPlan, {
941
+ fields: [
942
+ workoutSplit.workoutId
943
+ ],
944
+ references: [
945
+ workoutPlan.id
946
+ ]
947
+ }),
948
+ exerciseAssignments: many(exerciseToWorkoutSplit),
949
+ workoutSummaries: many(workoutSummary),
950
+ splitInformation: many(userSplitInformation)
951
+ }));
952
+
953
+ // ../../src/infrastructure/db/schema/drizzle/reminders/user_split_information/table.ts
954
+ var userSplitInformation = remindersSchema.table("user_split_information", {
955
+ id: bigint9("id", {
956
+ mode: "number"
957
+ }).generatedByDefaultAsIdentity({
958
+ name: "user_split_information_id_seq"
959
+ }).notNull(),
960
+ userId: uuid8("user_id").notNull(),
961
+ workoutSplitId: bigint9("workout_split_id", {
962
+ mode: "number"
963
+ }).notNull(),
964
+ estimatedTimeUtc: timestamp7("estimated_time_utc", {
965
+ withTimezone: true
966
+ }).notNull(),
967
+ confidence: numeric("confidence", {
968
+ precision: 3,
969
+ scale: 2
970
+ }).default("1.00").notNull(),
971
+ lastComputedAt: timestamp7("last_computed_at", {
972
+ withTimezone: true
973
+ }).default(drizzleSql18`timezone('UTC', now())`).notNull(),
974
+ preferredWeekday: integer4("preferred_weekday")
975
+ }, (t) => [
976
+ primaryKey11({
977
+ name: "user_split_information_pkey",
978
+ columns: [
979
+ t.id
980
+ ]
981
+ }),
982
+ unique5("user_split_information_user_id_workout_split_id_key").on(t.userId, t.workoutSplitId),
983
+ foreignKey10({
984
+ name: "user_split_information_user_id_fkey",
985
+ columns: [
986
+ t.userId
987
+ ],
988
+ foreignColumns: [
989
+ user.id
990
+ ]
991
+ }).onDelete("cascade"),
992
+ foreignKey10({
993
+ name: "user_split_information_workout_split_id_fkey",
994
+ columns: [
995
+ t.workoutSplitId
996
+ ],
997
+ foreignColumns: [
998
+ workoutSplit.id
999
+ ]
1000
+ }).onDelete("cascade"),
1001
+ index8("user_split_information_confidence_idx").on(t.preferredWeekday, t.confidence).where(drizzleSql18`${t.confidence} >= 0.60`),
1002
+ index8("user_split_information_user_weekday_idx").on(t.userId, t.preferredWeekday).where(drizzleSql18`${t.preferredWeekday} is not null`)
1003
+ ]).enableRLS();
1004
+ var userSplitInformationRelations = relations11(userSplitInformation, ({ one }) => ({
1005
+ user: one(user, {
1006
+ fields: [
1007
+ userSplitInformation.userId
1008
+ ],
1009
+ references: [
1010
+ user.id
1011
+ ]
1012
+ }),
1013
+ workoutSplit: one(workoutSplit, {
1014
+ fields: [
1015
+ userSplitInformation.workoutSplitId
1016
+ ],
1017
+ references: [
1018
+ workoutSplit.id
1019
+ ]
1020
+ })
1021
+ }));
1022
+
1023
+ // ../../src/infrastructure/db/schema/drizzle/tracking/aerobic_tracking/table.ts
1024
+ import { relations as relations12, sql as drizzleSql20 } from "drizzle-orm";
1025
+ import { bigint as bigint10, foreignKey as foreignKey11, index as index9, primaryKey as primaryKey12, text as text6, timestamp as timestamp8, uuid as uuid9 } from "drizzle-orm/pg-core";
1026
+
1027
+ // ../../src/infrastructure/db/schema/drizzle/tracking/aerobic_tracking/policies.ts
1028
+ import { sql as drizzleSql19 } from "drizzle-orm";
1029
+ import { pgPolicy as pgPolicy11 } from "drizzle-orm/pg-core";
1030
+ var uid9 = drizzleSql19`"identity"."current_user_id"()`;
1031
+ function aerobicTrackingPolicies(t) {
1032
+ return [
1033
+ // Lets authenticated users read only their own aerobic tracking rows.
1034
+ pgPolicy11("Enable read access for auth users on aerobic_tracking", {
1035
+ for: "select",
1036
+ to: authenticatedRole,
1037
+ using: drizzleSql19`${uid9} = ${t.userId}`
1038
+ }),
1039
+ // Lets authenticated users insert aerobic tracking rows only for themselves.
1040
+ pgPolicy11("Enable insert for auth users on aerobic_tracking", {
1041
+ for: "insert",
1042
+ to: authenticatedRole,
1043
+ withCheck: drizzleSql19`${uid9} = ${t.userId}`
1044
+ }),
1045
+ // Lets authenticated users update only their own aerobic tracking rows.
1046
+ pgPolicy11("Enable update for auth users on aerobic_tracking", {
1047
+ for: "update",
1048
+ to: authenticatedRole,
1049
+ using: drizzleSql19`${uid9} = ${t.userId}`,
1050
+ withCheck: drizzleSql19`${uid9} = ${t.userId}`
1051
+ }),
1052
+ // Lets authenticated users delete only their own aerobic tracking rows.
1053
+ pgPolicy11("Enable delete for auth users on aerobic_tracking", {
1054
+ for: "delete",
1055
+ to: authenticatedRole,
1056
+ using: drizzleSql19`${uid9} = ${t.userId}`
1057
+ })
1058
+ ];
1059
+ }
1060
+ __name(aerobicTrackingPolicies, "aerobicTrackingPolicies");
1061
+
1062
+ // ../../src/infrastructure/db/schema/drizzle/tracking/aerobic_tracking/table.ts
1063
+ var aerobicTracking = trackingSchema.table("aerobic_tracking", {
1064
+ id: bigint10("id", {
1065
+ mode: "number"
1066
+ }).generatedByDefaultAsIdentity({
1067
+ name: "aerobic_tracking_id_seq"
1068
+ }).notNull(),
1069
+ userId: uuid9("user_id").notNull(),
1070
+ type: text6("type").notNull(),
1071
+ durationSec: bigint10("duration_sec", {
1072
+ mode: "number"
1073
+ }).default(0).notNull(),
1074
+ workoutTimeUtc: timestamp8("workout_time_utc", {
1075
+ withTimezone: true
1076
+ }).default(drizzleSql20`(now() AT TIME ZONE 'utc')`).notNull()
1077
+ }, (t) => [
1078
+ primaryKey12({
1079
+ name: "aerobic_tracking_pkey",
1080
+ columns: [
1081
+ t.id
1082
+ ]
1083
+ }),
1084
+ foreignKey11({
1085
+ name: "aerobic_tracking_user_id_fkey",
1086
+ columns: [
1087
+ t.userId
1088
+ ],
1089
+ foreignColumns: [
1090
+ user.id
1091
+ ]
1092
+ }).onUpdate("cascade").onDelete("cascade"),
1093
+ index9("aerobic_tracking_user_id_workout_time_utc_idx").on(t.userId, t.workoutTimeUtc.desc().nullsFirst()),
1094
+ ...aerobicTrackingPolicies(t)
1095
+ ]);
1096
+ var aerobicTrackingRelations = relations12(aerobicTracking, ({ one }) => ({
1097
+ user: one(user, {
1098
+ fields: [
1099
+ aerobicTracking.userId
1100
+ ],
1101
+ references: [
1102
+ user.id
1103
+ ]
1104
+ })
1105
+ }));
1106
+
1107
+ // ../../src/infrastructure/db/schema/drizzle/identity/oauth_account/table.ts
1108
+ import { relations as relations13, sql as drizzleSql22 } from "drizzle-orm";
1109
+ import { foreignKey as foreignKey12, primaryKey as primaryKey13, text as text7, timestamp as timestamp9, unique as unique6, uuid as uuid10 } from "drizzle-orm/pg-core";
1110
+
1111
+ // ../../src/infrastructure/db/schema/drizzle/identity/oauth_account/policies.ts
1112
+ import { sql as drizzleSql21 } from "drizzle-orm";
1113
+ import { pgPolicy as pgPolicy12 } from "drizzle-orm/pg-core";
1114
+ var currentUserId3 = drizzleSql21`"identity"."current_user_id"()`;
1115
+ function oauthAccountPolicies(table) {
1116
+ return [
1117
+ // Lets authenticated users read only OAuth accounts linked to themselves.
1118
+ pgPolicy12("Enable read access for auth users on oauth_account", {
1119
+ for: "select",
1120
+ to: authenticatedRole,
1121
+ using: drizzleSql21`${currentUserId3} = ${table.userId}`
1122
+ }),
1123
+ // Lets authenticated users link OAuth accounts only to themselves.
1124
+ pgPolicy12("Enable insert for auth users on oauth_account", {
1125
+ for: "insert",
1126
+ to: authenticatedRole,
1127
+ withCheck: drizzleSql21`${currentUserId3} = ${table.userId}`
1128
+ }),
1129
+ // Lets authenticated users update only OAuth accounts linked to themselves.
1130
+ pgPolicy12("Enable update for auth users on oauth_account", {
1131
+ for: "update",
1132
+ to: authenticatedRole,
1133
+ using: drizzleSql21`${currentUserId3} = ${table.userId}`,
1134
+ withCheck: drizzleSql21`${currentUserId3} = ${table.userId}`
1135
+ }),
1136
+ // Lets authenticated users delete only OAuth accounts linked to themselves.
1137
+ pgPolicy12("Enable delete for auth users on oauth_account", {
1138
+ for: "delete",
1139
+ to: authenticatedRole,
1140
+ using: drizzleSql21`${currentUserId3} = ${table.userId}`
1141
+ })
1142
+ ];
1143
+ }
1144
+ __name(oauthAccountPolicies, "oauthAccountPolicies");
1145
+
1146
+ // ../../src/infrastructure/db/schema/drizzle/identity/oauth_account/table.ts
1147
+ var oauthAccount = identitySchema.table("oauth_account", {
1148
+ id: uuid10("id").defaultRandom().notNull(),
1149
+ userId: uuid10("user_id").notNull(),
1150
+ provider: text7("provider").notNull(),
1151
+ providerUserId: text7("provider_user_id").notNull(),
1152
+ providerEmail: text7("provider_email").notNull(),
1153
+ linkedAt: timestamp9("linked_at", {
1154
+ withTimezone: true
1155
+ }).default(drizzleSql22`(now() AT TIME ZONE 'utc')`).notNull(),
1156
+ missingFields: text7("missing_fields")
1157
+ }, (t) => [
1158
+ primaryKey13({
1159
+ name: "oauth_account_pkey",
1160
+ columns: [
1161
+ t.id
1162
+ ]
1163
+ }),
1164
+ unique6("oauth_account_provider_user_unique").on(t.provider, t.providerUserId),
1165
+ foreignKey12({
1166
+ name: "oauth_account_user_id_fkey",
1167
+ columns: [
1168
+ t.userId
1169
+ ],
1170
+ foreignColumns: [
1171
+ user.id
1172
+ ]
1173
+ }).onUpdate("cascade").onDelete("cascade"),
1174
+ ...oauthAccountPolicies(t)
1175
+ ]);
1176
+ var oauthAccountRelations = relations13(oauthAccount, ({ one }) => ({
1177
+ user: one(user, {
1178
+ fields: [
1179
+ oauthAccount.userId
1180
+ ],
1181
+ references: [
1182
+ user.id
1183
+ ]
1184
+ })
1185
+ }));
1186
+
1187
+ // ../../src/infrastructure/db/schema/drizzle/identity/user/policies.ts
1188
+ import { sql as drizzleSql23 } from "drizzle-orm";
1189
+ import { pgPolicy as pgPolicy13 } from "drizzle-orm/pg-core";
1190
+ var currentUserId4 = drizzleSql23`"identity"."current_user_id"()`;
1191
+ function userPolicies(table) {
1192
+ return [
1193
+ // Lets an authenticated user read their own profile.
1194
+ pgPolicy13("Enable read access for auth users on own profile", {
1195
+ for: "select",
1196
+ to: authenticatedRole,
1197
+ using: drizzleSql23`${currentUserId4} = ${table.id}`
1198
+ }),
1199
+ // Lets a message receiver read the profile of a sender in their inbox.
1200
+ pgPolicy13("Allow user to view senders in their messages", {
1201
+ for: "select",
1202
+ to: authenticatedRole,
1203
+ using: drizzleSql23`exists (select 1 from "messages"."message" m where m."sender_id" = ${table.id} and m."receiver_id" = ${currentUserId4})`
1204
+ }),
1205
+ // Lets an authenticated user create only their own profile row.
1206
+ pgPolicy13("Enable insert for auth users on own profile", {
1207
+ for: "insert",
1208
+ to: authenticatedRole,
1209
+ withCheck: drizzleSql23`${currentUserId4} = ${table.id}`
1210
+ }),
1211
+ // Preserves the legacy public self-registration policy for compatibility.
1212
+ pgPolicy13("Enable insert for public users on own profile", {
1213
+ for: "insert",
1214
+ to: "public",
1215
+ withCheck: drizzleSql23`${currentUserId4} = ${table.id}`
1216
+ }),
1217
+ // Lets an authenticated user update only their own profile.
1218
+ pgPolicy13("Enable update for auth users on own profile", {
1219
+ for: "update",
1220
+ to: authenticatedRole,
1221
+ using: drizzleSql23`${currentUserId4} = ${table.id}`,
1222
+ withCheck: drizzleSql23`${currentUserId4} = ${table.id}`
1223
+ }),
1224
+ // Lets an authenticated user delete only their own profile.
1225
+ pgPolicy13("Enable delete for auth users on own profile", {
1226
+ for: "delete",
1227
+ to: authenticatedRole,
1228
+ using: drizzleSql23`${currentUserId4} = ${table.id}`
1229
+ })
1230
+ ];
1231
+ }
1232
+ __name(userPolicies, "userPolicies");
1233
+
1234
+ // ../../src/infrastructure/db/schema/drizzle/identity/user/table.ts
1235
+ var user = identitySchema.table("user", {
1236
+ username: text8("username").notNull(),
1237
+ email: text8("email").notNull(),
1238
+ name: text8("name").notNull(),
1239
+ gender: text8("gender").default("Unknown").notNull(),
1240
+ createdAt: timestamp10("created_at", {
1241
+ withTimezone: true
1242
+ }).default(drizzleSql24`(now() AT TIME ZONE 'utc')`).notNull(),
1243
+ updatedAt: timestamp10("updated_at", {
1244
+ withTimezone: true
1245
+ }).default(drizzleSql24`(now() AT TIME ZONE 'utc')`).notNull(),
1246
+ profilePicPath: text8("profile_pic_path"),
1247
+ id: uuid11("id").defaultRandom().notNull(),
1248
+ pushToken: text8("push_token"),
1249
+ passwordHash: text8("password_hash"),
1250
+ role: text8("role").default("User").notNull(),
1251
+ tokenVersion: bigint11("token_version", {
1252
+ mode: "number"
1253
+ }).default(0).notNull(),
1254
+ isVerified: boolean6("is_verified").default(false).notNull(),
1255
+ authProvider: text8("auth_provider").default("app").notNull(),
1256
+ lastLogin: timestamp10("last_login", {
1257
+ withTimezone: true
1258
+ })
1259
+ }, (t) => [
1260
+ primaryKey14({
1261
+ name: "user_pkey",
1262
+ columns: [
1263
+ t.id
1264
+ ]
1265
+ }),
1266
+ uniqueIndex3("user_email_ci_unique").on(drizzleSql24`lower(trim(both from ${t.email}))`),
1267
+ uniqueIndex3("user_username_ci_unique").on(drizzleSql24`lower(trim(both from ${t.username}))`),
1268
+ ...userPolicies(t)
1269
+ ]);
1270
+ var userRelations = relations14(user, ({ many, one }) => ({
1271
+ oauthAccounts: many(oauthAccount),
1272
+ ownedWorkoutPlans: many(workoutPlan, {
1273
+ relationName: "workoutPlanOwner"
1274
+ }),
1275
+ trainedWorkoutPlans: many(workoutPlan, {
1276
+ relationName: "workoutPlanTrainer"
1277
+ }),
1278
+ workoutSummaries: many(workoutSummary),
1279
+ aerobicTrackings: many(aerobicTracking),
1280
+ reminderSettings: one(userReminderSetting),
1281
+ splitInformation: many(userSplitInformation),
1282
+ sentMessages: many(message, {
1283
+ relationName: "messageSender"
1284
+ }),
1285
+ receivedMessages: many(message, {
1286
+ relationName: "messageReceiver"
1287
+ })
1288
+ }));
1289
+
1290
+ // ../../src/infrastructure/db/schema/drizzle/workout/views/exercise-to-workoutsplit-expanded.view.ts
1291
+ import { bigint as bigint12, boolean as boolean7, text as text9, timestamp as timestamp11 } from "drizzle-orm/pg-core";
1292
+ import { sql as drizzleSql25 } from "drizzle-orm";
1293
+ import { integer as integer5 } from "drizzle-orm/pg-core";
1294
+ var exerciseToWorkoutSplitExpandedView = workoutSchema.view("v_exercise_to_workout_split_expanded", {
1295
+ id: bigint12("id", {
1296
+ mode: "number"
1297
+ }),
1298
+ workoutSplitId: bigint12("workout_split_id", {
1299
+ mode: "number"
1300
+ }),
1301
+ workoutId: bigint12("workout_id", {
1302
+ mode: "number"
1303
+ }),
1304
+ exerciseId: bigint12("exercise_id", {
1305
+ mode: "number"
1306
+ }),
1307
+ exercise: text9("exercise"),
1308
+ workoutSplit: text9("workout_split"),
1309
+ reps: integer5("reps"),
1310
+ orderIndex: bigint12("order_index", {
1311
+ mode: "number"
1312
+ }),
1313
+ setOrderIndex: integer5("set_order_index"),
1314
+ createdAt: timestamp11("created_at", {
1315
+ withTimezone: true
1316
+ }),
1317
+ isActive: boolean7("is_active")
1318
+ }).with({
1319
+ securityInvoker: true
1320
+ }).as(drizzleSql25`
1321
+ SELECT
1322
+ ews.id,
1323
+ ews.workout_split_id,
1324
+ ws.workout_id,
1325
+ ews.exercise_id,
1326
+ ex.name AS exercise,
1327
+ ws.name AS workout_split,
1328
+ workout_set.reps AS reps,
1329
+ workout_set.order_index AS set_order_index,
1330
+ ews.order_index,
1331
+ ews.created_at,
1332
+ ews.is_active
1333
+ FROM
1334
+ workout.exercise_to_workout_split ews
1335
+ JOIN workout.workout_split ws ON ws.id = ews.workout_split_id
1336
+ JOIN workout.exercise ex ON ex.id = ews.exercise_id
1337
+ LEFT JOIN workout.workout_set workout_set ON workout_set.exercise_to_split_id = ews.id
1338
+ GROUP BY
1339
+ ews.id,
1340
+ ews.workout_split_id,
1341
+ ws.workout_id,
1342
+ ews.exercise_id,
1343
+ ex.name,
1344
+ ws.name,
1345
+ workout_set.reps,
1346
+ workout_set.order_index,
1347
+ ews.order_index,
1348
+ ews.created_at,
1349
+ ews.is_active
1350
+ `);
1351
+
1352
+ // ../../src/infrastructure/db/schema/drizzle/analytics/views/exercise-tracking-expanded.view.ts
1353
+ import { sql as drizzleSql26 } from "drizzle-orm";
1354
+ import { bigint as bigint13, real as real2, text as text10, timestamp as timestamp12, uuid as uuid12 } from "drizzle-orm/pg-core";
1355
+ import { integer as integer6 } from "drizzle-orm/pg-core";
1356
+ var exerciseTrackingExpandedView = analyticsSchema.view("v_exercise_tracking_expanded", {
1357
+ id: bigint13("id", {
1358
+ mode: "number"
1359
+ }),
1360
+ exerciseToSplitId: bigint13("exercise_to_split_id", {
1361
+ mode: "number"
1362
+ }),
1363
+ weight: real2("weight"),
1364
+ reps: bigint13("reps", {
1365
+ mode: "number"
1366
+ }),
1367
+ setIndex: integer6("set_index"),
1368
+ exerciseId: bigint13("exercise_id", {
1369
+ mode: "number"
1370
+ }),
1371
+ workoutSplitId: bigint13("workout_split_id", {
1372
+ mode: "number"
1373
+ }),
1374
+ splitName: text10("split_name"),
1375
+ exercise: text10("exercise"),
1376
+ notes: text10("notes"),
1377
+ workoutSummaryId: uuid12("workout_summary_id"),
1378
+ workoutStartUtc: timestamp12("workout_start_utc", {
1379
+ withTimezone: true
1380
+ }),
1381
+ workoutEndUtc: timestamp12("workout_end_utc", {
1382
+ withTimezone: true
1383
+ })
1384
+ }).with({
1385
+ securityInvoker: true
1386
+ }).as(drizzleSql26`
1387
+ SELECT
1388
+ et.id,
1389
+ et.exercise_to_split_id,
1390
+ tracking_set.weight AS weight,
1391
+ tracking_set.reps AS reps,
1392
+ tracking_set.set_index AS set_index,
1393
+ COALESCE(ews.exercise_id, et.exercise_id) AS exercise_id,
1394
+ wsumm.workout_split_id,
1395
+ ws.name AS split_name,
1396
+ ex.name AS exercise,
1397
+ et.notes,
1398
+ et.workout_summary_id,
1399
+ wsumm.workout_start_utc,
1400
+ wsumm.workout_end_utc
1401
+ FROM
1402
+ tracking.exercise_tracking et
1403
+ LEFT JOIN tracking.workout_summary wsumm ON wsumm.id = et.workout_summary_id
1404
+ LEFT JOIN workout.exercise_to_workout_split ews ON ews.id = et.exercise_to_split_id
1405
+ LEFT JOIN workout.workout_split ws ON ws.id = wsumm.workout_split_id
1406
+ LEFT JOIN workout.exercise ex ON ex.id = COALESCE(ews.exercise_id, et.exercise_id)
1407
+ LEFT JOIN tracking.tracking_set tracking_set ON tracking_set.exercise_tracking_id = et.id
1408
+ `);
1409
+
1410
+ // ../../src/infrastructure/db/schema/drizzle/analytics/views/prs.view.ts
1411
+ import { sql as drizzleSql27 } from "drizzle-orm";
1412
+ import { bigint as bigint14, real as real3, text as text11, timestamp as timestamp13, uuid as uuid13 } from "drizzle-orm/pg-core";
1413
+ var prsView = analyticsSchema.view("v_prs", {
1414
+ id: bigint14("id", {
1415
+ mode: "number"
1416
+ }),
1417
+ exerciseToSplitId: bigint14("exercise_to_split_id", {
1418
+ mode: "number"
1419
+ }),
1420
+ exerciseId: bigint14("exercise_id", {
1421
+ mode: "number"
1422
+ }),
1423
+ exercise: text11("exercise"),
1424
+ weight: real3("weight"),
1425
+ reps: bigint14("reps", {
1426
+ mode: "number"
1427
+ }),
1428
+ workoutSummaryId: uuid13("workout_summary_id"),
1429
+ workoutStartUtc: timestamp13("workout_start_utc", {
1430
+ withTimezone: true
1431
+ }),
1432
+ workoutEndUtc: timestamp13("workout_end_utc", {
1433
+ withTimezone: true
1434
+ })
1435
+ }).with({
1436
+ securityInvoker: true
1437
+ }).as(drizzleSql27`
1438
+ SELECT DISTINCT
1439
+ ON (et.exercise_id) et.id,
1440
+ et.exercise_to_split_id,
1441
+ et.exercise_id,
1442
+ et.exercise,
1443
+ et.weight,
1444
+ et.reps,
1445
+ et.workout_summary_id,
1446
+ et.workout_start_utc,
1447
+ et.workout_end_utc
1448
+ FROM
1449
+ analytics.v_exercise_tracking_expanded et
1450
+ ORDER BY
1451
+ et.exercise_id,
1452
+ et.weight DESC,
1453
+ et.reps DESC,
1454
+ et.workout_start_utc DESC,
1455
+ et.id DESC
1456
+ `);
1457
+
1458
+ // src/database/database.schemas.ts
1459
+ var userDbSchema = createSelectSchema(user);
1460
+ var userInsertDbSchema = createInsertSchema(user);
1461
+ var userUpdateDbSchema = createUpdateSchema(user);
1462
+ var oauthAccountDbSchema = createSelectSchema(oauthAccount);
1463
+ var exerciseDbSchema = createSelectSchema(exercise);
1464
+ var workoutPlanDbSchema = createSelectSchema(workoutPlan);
1465
+ var workoutSplitDbSchema = createSelectSchema(workoutSplit);
1466
+ var exerciseToWorkoutSplitDbSchema = createSelectSchema(exerciseToWorkoutSplit);
1467
+ var exerciseToWorkoutSplitExpandedViewDbSchema = createSelectSchema(exerciseToWorkoutSplitExpandedView);
1468
+ var workoutSetDbSchema = createSelectSchema(workoutSet);
1469
+ var workoutSummaryDbSchema = createSelectSchema(workoutSummary);
1470
+ var exerciseTrackingDbSchema = createSelectSchema(exerciseTracking);
1471
+ var trackingSetDbSchema = createSelectSchema(trackingSet);
1472
+ var aerobicTrackingDbSchema = createSelectSchema(aerobicTracking);
1473
+ var messageDbSchema = createSelectSchema(message);
1474
+ var userReminderSettingDbSchema = createSelectSchema(userReminderSetting);
1475
+ var userSplitInformationDbSchema = createSelectSchema(userSplitInformation);
1476
+ var exerciseTrackingExpandedViewDbSchema = createSelectSchema(exerciseTrackingExpandedView);
1477
+ var prsViewDbSchema = createSelectSchema(prsView);
1478
+
1479
+ // src/modules/aerobics/aerobics.schemas.ts
1480
+ import z2 from "zod/v4";
1481
+ var addAerobicInput = z2.object({
1482
+ durationMins: z2.number(),
1483
+ durationSec: aerobicTrackingDbSchema.shape.durationSec,
1484
+ type: aerobicTrackingDbSchema.shape.type
1485
+ });
1486
+ var addAerobicsRequest = z2.object({
1487
+ body: z2.object({
1488
+ tz: z2.string(),
1489
+ record: addAerobicInput
1490
+ })
1491
+ });
1492
+ var getAerobicsRequest = z2.object({
1493
+ query: z2.object({
1494
+ tz: z2.string().optional()
1495
+ })
1496
+ });
1497
+ var aerobicsDailyRecordSchema = z2.object({
1498
+ type: aerobicTrackingDbSchema.shape.type,
1499
+ durationSec: aerobicTrackingDbSchema.shape.durationSec,
1500
+ durationMins: aerobicTrackingDbSchema.shape.durationSec
1501
+ });
1502
+ var aerobicsWeeklyRecordSchema = aerobicsDailyRecordSchema.extend({
1503
+ workoutTimeUtc: serializedDateSchema
1504
+ });
1505
+ var weeklyDataSchema = z2.object({
1506
+ records: z2.array(aerobicsWeeklyRecordSchema),
1507
+ totalDurationSec: z2.number(),
1508
+ totalDurationMins: z2.number()
1509
+ });
1510
+ var userAerobicsResponseSchema = z2.object({
1511
+ daily: z2.record(z2.string(), z2.array(aerobicsDailyRecordSchema)),
1512
+ weekly: z2.record(z2.string(), weeklyDataSchema)
1513
+ });
1514
+
1515
+ // src/modules/analytics/analytics.schemas.ts
1516
+ import { z as z3 } from "zod/v4";
1517
+ var workoutRmRecordSchema = z3.object({
1518
+ exercise: exerciseDbSchema.shape.name,
1519
+ prWeight: trackingSetDbSchema.shape.weight.nullable(),
1520
+ prReps: trackingSetDbSchema.shape.reps.nullable(),
1521
+ max1Rm: z3.number()
1522
+ });
1523
+ var adherenceExerciseStatsSchema = z3.object({
1524
+ planned: z3.number(),
1525
+ actual: z3.number(),
1526
+ adherencePct: z3.number().nullable()
1527
+ });
1528
+ var getAnalyticsResponseSchema = z3.object({
1529
+ oneRepMaxes: z3.record(z3.string(), workoutRmRecordSchema),
1530
+ goals: z3.record(z3.string(), z3.record(z3.string(), adherenceExerciseStatsSchema))
1531
+ });
1532
+
1533
+ // src/modules/auth/password/password.dtos.ts
1534
+ import { z as z4 } from "zod/v4";
1535
+ var forgotPasswordPayloadSchema = z4.object({
1536
+ sub: userDbSchema.shape.id,
1537
+ jti: z4.string(),
1538
+ exp: z4.number(),
1539
+ iss: z4.string(),
1540
+ typ: z4.string()
1541
+ });
1542
+
1543
+ // src/modules/auth/password/password.schemas.ts
1544
+ import { z as z5 } from "zod/v4";
1545
+ var sendChangePassEmailRequest = z5.object({
1546
+ body: z5.object({
1547
+ identifier: z5.string()
1548
+ })
1549
+ });
1550
+ var resetPasswordRequest = z5.object({
1551
+ body: z5.object({
1552
+ newPassword: z5.string().min(8, "Password must be at least 8 characters long")
1553
+ }),
1554
+ query: z5.object({
1555
+ token: z5.string().optional()
1556
+ })
1557
+ });
1558
+ var resetPasswordResponseSchema = z5.object({
1559
+ ok: z5.boolean()
1560
+ });
1561
+
1562
+ // src/modules/auth/session/session.dtos.ts
1563
+ import { z as z7 } from "zod/v4";
1564
+
1565
+ // src/modules/user/update/update.schemas.ts
1566
+ import { z as z6 } from "zod/v4";
1567
+ var updateUserRequest = z6.object({
1568
+ body: z6.object({
1569
+ username: userDbSchema.shape.username.trim().min(3, "Username must be at least 3 characters").max(15, "Username must be at most 15 characters").regex(/^[a-zA-Z0-9_]+$/, "Username may contain letters, numbers, and underscore only"),
1570
+ fullName: userDbSchema.shape.name.trim().min(1, "Full name is required").max(20, "Full name is too long").regex(/^[a-zA-Z\s]+$/, "Full name may contain letters and spaces only"),
1571
+ email: userDbSchema.shape.email.trim().toLowerCase().email("Invalid email format")
1572
+ }).partial()
1573
+ });
1574
+ var deleteProfilePicRequest = z6.object({
1575
+ body: z6.object({
1576
+ path: z6.string()
1577
+ })
1578
+ });
1579
+ var userDataSchema = z6.object({
1580
+ id: userDbSchema.shape.id,
1581
+ username: userDbSchema.shape.username,
1582
+ email: userDbSchema.shape.email,
1583
+ name: userDbSchema.shape.name,
1584
+ gender: userDbSchema.shape.gender,
1585
+ createdAt: serializedDateSchema,
1586
+ updatedAt: serializedDateSchema,
1587
+ profileImageUrl: userDbSchema.shape.profilePicPath,
1588
+ pushToken: userDbSchema.shape.pushToken,
1589
+ role: userDbSchema.shape.role,
1590
+ isFirstLogin: z6.boolean(),
1591
+ tokenVersion: userDbSchema.shape.tokenVersion,
1592
+ isVerified: userDbSchema.shape.isVerified,
1593
+ authProvider: userDbSchema.shape.authProvider,
1594
+ lastLogin: serializedDateSchema.nullable()
1595
+ });
1596
+ var userDataResponseSchema = z6.object({
1597
+ userData: userDataSchema
1598
+ });
1599
+ var getAuthenticatedUserByIdResponseSchema = userDataSchema;
1600
+ var updateAuthenticatedUserResponseSchema = z6.object({
1601
+ message: z6.string(),
1602
+ emailChanged: z6.boolean(),
1603
+ user: userDataSchema
1604
+ });
1605
+ var setProfilePicAndUpdateDBResponseSchema = z6.object({
1606
+ path: z6.string(),
1607
+ url: z6.string(),
1608
+ message: z6.string()
1609
+ });
1610
+
1611
+ // src/modules/auth/session/session.dtos.ts
1612
+ var accessTokenPayloadSchema = z7.object({
1613
+ id: userDbSchema.shape.id,
1614
+ role: userDbSchema.shape.role,
1615
+ tokenVer: userDbSchema.shape.tokenVersion,
1616
+ cnf: z7.object({
1617
+ jkt: z7.string()
1618
+ }).optional(),
1619
+ iat: z7.number().optional(),
1620
+ exp: z7.number().optional()
1621
+ });
1622
+ var userAfterBumpSchema = z7.object({
1623
+ tokenVersion: userDbSchema.shape.tokenVersion,
1624
+ userData: userDataSchema
1625
+ });
1626
+ var tokenVersionResultSchema = z7.object({
1627
+ tokenVersion: userDbSchema.shape.tokenVersion
1628
+ });
1629
+
1630
+ // src/modules/auth/session/session.schemas.ts
1631
+ import { z as z8 } from "zod/v4";
1632
+ var loginRequest = z8.object({
1633
+ body: z8.object({
1634
+ identifier: z8.string().min(3).refine((val) => {
1635
+ const isEmail = z8.string().email().safeParse(val).success;
1636
+ const isUsername = /^[a-zA-Z0-9_]{3,20}$/.test(val);
1637
+ return isEmail || isUsername;
1638
+ }, {
1639
+ message: "Must be a valid email or username"
1640
+ }),
1641
+ password: z8.string().min(1, "Username and password are required")
1642
+ })
1643
+ });
1644
+ var loginResponseSchema = z8.object({
1645
+ message: z8.string(),
1646
+ user: userDbSchema.shape.id,
1647
+ accessToken: z8.string(),
1648
+ refreshToken: z8.string()
1649
+ });
1650
+ var logoutResponseSchema = z8.object({
1651
+ message: z8.string()
1652
+ });
1653
+ var refreshTokenResponseSchema = z8.object({
1654
+ message: z8.string(),
1655
+ accessToken: z8.string(),
1656
+ refreshToken: z8.string(),
1657
+ userId: userDbSchema.shape.id
1658
+ });
1659
+
1660
+ // src/modules/auth/verification/verification.dtos.ts
1661
+ import { z as z9 } from "zod/v4";
1662
+ var emailVerifyPayloadSchema = z9.object({
1663
+ sub: userDbSchema.shape.id,
1664
+ jti: z9.string(),
1665
+ exp: z9.number(),
1666
+ iss: z9.string(),
1667
+ typ: z9.string()
1668
+ });
1669
+
1670
+ // src/modules/auth/verification/verification.schemas.ts
1671
+ import z10 from "zod/v4";
1672
+ var verifyAccountRequest = z10.object({
1673
+ query: z10.object({
1674
+ token: z10.string().optional()
1675
+ })
1676
+ });
1677
+ var sendVerificationMailRequest = z10.object({
1678
+ body: z10.object({
1679
+ email: userDbSchema.shape.email.trim().email("Invalid email")
1680
+ })
1681
+ });
1682
+ var changeEmailAndVerifyRequest = z10.object({
1683
+ body: z10.object({
1684
+ username: userDbSchema.shape.username,
1685
+ password: z10.string(),
1686
+ newEmail: userDbSchema.shape.email.trim().email("Invalid email")
1687
+ })
1688
+ });
1689
+ var checkUserVerifyRequest = z10.object({
1690
+ query: z10.object({
1691
+ username: userDbSchema.shape.username
1692
+ })
1693
+ });
1694
+
1695
+ // src/modules/auth/auth.dtos.ts
1696
+ import { z as z11 } from "zod/v4";
1697
+ var userByIndetifierSchema = z11.object({
1698
+ id: userDbSchema.shape.id,
1699
+ name: userDbSchema.shape.name,
1700
+ username: userDbSchema.shape.username,
1701
+ email: userDbSchema.shape.email.optional(),
1702
+ password: userDbSchema.shape.passwordHash,
1703
+ role: userDbSchema.shape.role,
1704
+ isVerified: userDbSchema.shape.isVerified,
1705
+ lastLogin: serializedDateSchema.nullable().optional()
1706
+ });
1707
+
1708
+ // src/modules/bootstrap/bootstrap.schemas.ts
1709
+ import { z as z15 } from "zod/v4";
1710
+
1711
+ // src/modules/messages/messages.schemas.ts
1712
+ import { z as z12 } from "zod/v4";
1713
+ var getAllMessagesRequest = z12.object({
1714
+ query: z12.object({
1715
+ tz: z12.string()
1716
+ })
1717
+ });
1718
+ var allUserMessageSchema = z12.object({
1719
+ id: messageDbSchema.shape.id,
1720
+ subject: messageDbSchema.shape.subject,
1721
+ msg: messageDbSchema.shape.msg,
1722
+ sentAt: serializedDateSchema,
1723
+ isRead: messageDbSchema.shape.isRead,
1724
+ senderFullName: userDbSchema.shape.name,
1725
+ senderProfileImageUrl: userDbSchema.shape.profilePicPath
1726
+ });
1727
+ var getAllUserMessagesResponseSchema = z12.object({
1728
+ messages: z12.array(allUserMessageSchema)
1729
+ });
1730
+ var markMessageAsReadRequest = z12.object({
1731
+ params: z12.object({
1732
+ id: messageDbSchema.shape.id
1733
+ })
1734
+ });
1735
+ var messageAsReadSchema = z12.object({
1736
+ id: messageDbSchema.shape.id,
1737
+ isRead: messageDbSchema.shape.isRead
1738
+ });
1739
+ var markMessageAsReadResponseSchema = messageAsReadSchema;
1740
+ var deleteMessageRequest = z12.object({
1741
+ params: z12.object({
1742
+ id: messageDbSchema.shape.id
1743
+ })
1744
+ });
1745
+ var deletedMessageSchema = z12.object({
1746
+ id: messageDbSchema.shape.id
1747
+ });
1748
+ var messageAfterSendResponseSchema = z12.object({
1749
+ id: messageDbSchema.shape.id,
1750
+ senderId: messageDbSchema.shape.senderId,
1751
+ receiverId: messageDbSchema.shape.receiverId,
1752
+ subject: messageDbSchema.shape.subject,
1753
+ msg: messageDbSchema.shape.msg,
1754
+ sentAt: serializedDateSchema,
1755
+ isRead: messageDbSchema.shape.isRead,
1756
+ senderUsername: userDbSchema.shape.username,
1757
+ senderFullName: userDbSchema.shape.name,
1758
+ senderProfileImageUrl: userDbSchema.shape.profilePicPath,
1759
+ senderGender: userDbSchema.shape.gender
1760
+ });
1761
+ var deleteMessageResponseSchema = deletedMessageSchema;
1762
+
1763
+ // src/modules/workout/plan/plan.schemas.ts
1764
+ import { z as z13 } from "zod/v4";
1765
+ var workoutExerciseSchema = z13.object({
1766
+ id: exerciseDbSchema.shape.id,
1767
+ sets: z13.array(workoutSetDbSchema.shape.reps),
1768
+ orderIndex: exerciseToWorkoutSplitDbSchema.shape.orderIndex
1769
+ });
1770
+ var exerciseInPlanSchema = z13.object({
1771
+ id: exerciseToWorkoutSplitDbSchema.shape.id,
1772
+ sets: z13.array(workoutSetDbSchema.shape.reps),
1773
+ isActive: exerciseToWorkoutSplitDbSchema.shape.isActive,
1774
+ targetMuscle: exerciseDbSchema.shape.targetMuscle,
1775
+ specificTargetMuscle: exerciseDbSchema.shape.specificTargetMuscle,
1776
+ exercise: exerciseDbSchema.shape.name,
1777
+ workoutSplit: workoutSplitDbSchema.shape.name
1778
+ });
1779
+ var workoutSplitSchema = z13.object({
1780
+ id: workoutSplitDbSchema.shape.id,
1781
+ workoutId: workoutSplitDbSchema.shape.workoutId,
1782
+ name: workoutSplitDbSchema.shape.name,
1783
+ createdAt: serializedDateSchema,
1784
+ muscleGroup: z13.string().nullable(),
1785
+ isActive: workoutSplitDbSchema.shape.isActive,
1786
+ exerciseToWorkoutSplit: z13.array(exerciseInPlanSchema)
1787
+ });
1788
+ var wholeUserWorkoutPlanSchema = z13.object({
1789
+ id: workoutPlanDbSchema.shape.id,
1790
+ numberOfSplits: z13.number(),
1791
+ createdAt: serializedDateSchema,
1792
+ userId: userDbSchema.shape.id,
1793
+ isActive: workoutPlanDbSchema.shape.isActive,
1794
+ updatedAt: serializedDateSchema,
1795
+ workoutSplits: z13.array(workoutSplitSchema).nullable()
1796
+ });
1797
+ var workoutSplitsMapItemSchema = z13.object({
1798
+ id: exerciseDbSchema.shape.id,
1799
+ name: exerciseDbSchema.shape.name,
1800
+ sets: z13.array(workoutSetDbSchema.shape.reps),
1801
+ orderIndex: exerciseToWorkoutSplitDbSchema.shape.orderIndex,
1802
+ targetMuscle: exerciseDbSchema.shape.targetMuscle,
1803
+ specificTargetMuscle: exerciseDbSchema.shape.specificTargetMuscle
1804
+ });
1805
+ var workoutSplitsMapSchema = z13.record(z13.string(), z13.array(workoutSplitsMapItemSchema));
1806
+ var addWorkoutSplitPayloadSchema = z13.record(z13.string(), z13.array(workoutExerciseSchema).min(1, "Each split must include at least one exercise"));
1807
+ var addWorkoutRequest = z13.object({
1808
+ body: z13.object({
1809
+ workoutData: addWorkoutSplitPayloadSchema,
1810
+ workoutName: z13.string().optional(),
1811
+ tz: z13.string()
1812
+ })
1813
+ });
1814
+ var addWorkoutResponseSchema = z13.object({
1815
+ message: z13.string(),
1816
+ workoutPlan: wholeUserWorkoutPlanSchema,
1817
+ workoutPlanForEditWorkout: workoutSplitsMapSchema
1818
+ });
1819
+ var getWholeWorkoutPlanRequest = z13.object({
1820
+ query: z13.object({
1821
+ tz: z13.string().optional()
1822
+ })
1823
+ });
1824
+ var getWholeUserWorkoutPlanResponseSchema = z13.object({
1825
+ workoutPlan: wholeUserWorkoutPlanSchema.nullable(),
1826
+ workoutPlanForEditWorkout: workoutSplitsMapSchema.nullable()
1827
+ });
1828
+
1829
+ // src/modules/workout/tracking/tracking.schemas.ts
1830
+ import { z as z14 } from "zod/v4";
1831
+ var finishedExerciseEntry = z14.object({
1832
+ exerciseToSplitId: exerciseToWorkoutSplitDbSchema.shape.id,
1833
+ weight: z14.array(trackingSetDbSchema.shape.weight),
1834
+ reps: z14.array(trackingSetDbSchema.shape.reps),
1835
+ notes: exerciseTrackingDbSchema.shape.notes.optional()
1836
+ });
1837
+ var exerciseMetadataSchema = z14.object({
1838
+ targetMuscle: exerciseDbSchema.shape.targetMuscle,
1839
+ specificTargetMuscle: exerciseDbSchema.shape.specificTargetMuscle
1840
+ });
1841
+ var exerciseTrackingPrMaxSchema = z14.object({
1842
+ exercise: exerciseDbSchema.shape.name,
1843
+ weight: trackingSetDbSchema.shape.weight,
1844
+ reps: trackingSetDbSchema.shape.reps,
1845
+ workoutTimeUtc: serializedDateSchema
1846
+ });
1847
+ var exerciseTrackingAnalysisSchema = z14.object({
1848
+ uniqueDays: z14.number(),
1849
+ mostFrequentSplit: z14.string().nullable(),
1850
+ mostFrequentSplitDays: z14.number().nullable(),
1851
+ lastWorkoutDate: z14.string().nullable(),
1852
+ splitDaysByName: z14.record(z14.string(), z14.number()),
1853
+ prs: z14.object({
1854
+ prMax: exerciseTrackingPrMaxSchema.nullable()
1855
+ })
1856
+ });
1857
+ var trackingMapItemSchema = z14.object({
1858
+ id: exerciseTrackingDbSchema.shape.id,
1859
+ exerciseToSplitId: exerciseToWorkoutSplitDbSchema.shape.id,
1860
+ weight: z14.array(trackingSetDbSchema.shape.weight),
1861
+ reps: z14.array(trackingSetDbSchema.shape.reps),
1862
+ notes: exerciseTrackingDbSchema.shape.notes,
1863
+ exerciseId: exerciseDbSchema.shape.id,
1864
+ workoutSplitId: workoutSplitDbSchema.shape.id,
1865
+ splitName: workoutSplitDbSchema.shape.name,
1866
+ exercise: exerciseDbSchema.shape.name,
1867
+ workoutDate: serializedDateSchema,
1868
+ orderIndex: exerciseToWorkoutSplitDbSchema.shape.orderIndex,
1869
+ exerciseToWorkoutSplit: z14.object({
1870
+ sets: z14.array(workoutSetDbSchema.shape.reps),
1871
+ exercises: exerciseMetadataSchema
1872
+ })
1873
+ });
1874
+ var trackingByDateItemSchema = trackingMapItemSchema.omit({
1875
+ workoutDate: true
1876
+ });
1877
+ var trackingBySplitNameItemSchema = trackingMapItemSchema.omit({
1878
+ splitName: true
1879
+ });
1880
+ var exerciseTrackingAndStatsSchema = z14.object({
1881
+ exerciseTrackingAnalysis: exerciseTrackingAnalysisSchema,
1882
+ exerciseTrackingMaps: z14.object({
1883
+ byDate: z14.record(z14.string(), z14.array(trackingByDateItemSchema)),
1884
+ byExerciseToSplitId: z14.record(z14.string(), z14.array(trackingMapItemSchema)),
1885
+ bySplitName: z14.record(z14.string(), z14.array(trackingBySplitNameItemSchema))
1886
+ })
1887
+ });
1888
+ var finishWorkoutRequest = z14.object({
1889
+ body: z14.object({
1890
+ workout: z14.array(finishedExerciseEntry),
1891
+ tz: z14.string().optional(),
1892
+ workoutStartUtc: z14.string().datetime("workoutStartUtc must be a valid ISO datetime"),
1893
+ workoutEndUtc: z14.string().datetime("workoutEndUtc must be a valid ISO datetime").optional().nullable()
1894
+ })
1895
+ });
1896
+ var finishUserWorkoutResponseSchema = exerciseTrackingAndStatsSchema;
1897
+ var getExerciseTrackingRequest = z14.object({
1898
+ query: z14.object({
1899
+ tz: z14.string().optional()
1900
+ })
1901
+ });
1902
+ var getExerciseTrackingResponseSchema = exerciseTrackingAndStatsSchema;
1903
+
1904
+ // src/modules/bootstrap/bootstrap.schemas.ts
1905
+ var bootstrapRequest = z15.object({
1906
+ query: z15.object({
1907
+ tz: z15.string().optional()
1908
+ })
1909
+ });
1910
+ var bootstrapResponseSchema = z15.object({
1911
+ user: userDataSchema,
1912
+ workout: getWholeUserWorkoutPlanResponseSchema,
1913
+ tracking: exerciseTrackingAndStatsSchema,
1914
+ messages: getAllUserMessagesResponseSchema,
1915
+ aerobics: userAerobicsResponseSchema
1916
+ });
1917
+
1918
+ // src/modules/exercises/exercises.schemas.ts
1919
+ import { z as z16 } from "zod/v4";
1920
+ var getAllExercisesExerciseSchema = z16.object({
1921
+ id: exerciseDbSchema.shape.id,
1922
+ name: exerciseDbSchema.shape.name,
1923
+ specificTargetMuscle: exerciseDbSchema.shape.specificTargetMuscle
1924
+ });
1925
+ var getAllExercisesResponseSchema = z16.record(z16.string(), z16.array(getAllExercisesExerciseSchema));
1926
+ var queryGetExerciseMapByMuscleRowSchema = z16.object({
1927
+ result: z16.object({
1928
+ map: getAllExercisesResponseSchema.nullable()
1929
+ }).nullable()
1930
+ });
1931
+
1932
+ // src/modules/oauth/apple/apple.dtos.ts
1933
+ import { z as z17 } from "zod/v4";
1934
+ var appleTokenVerificationResultSchema = z17.object({
1935
+ appleSub: z17.string(),
1936
+ email: userDbSchema.shape.email.nullable(),
1937
+ emailVerified: z17.boolean(),
1938
+ fullName: userDbSchema.shape.name
1939
+ });
1940
+
1941
+ // src/modules/oauth/apple/apple.schemas.ts
1942
+ import { z as z18 } from "zod/v4";
1943
+ var appleNameInput = z18.object({
1944
+ givenName: z18.string().nullable(),
1945
+ familyName: z18.string().nullable()
1946
+ });
1947
+ var appleOAuthRequest = z18.object({
1948
+ body: z18.object({
1949
+ idToken: z18.string({
1950
+ error: "Missing or invalid Apple identityToken"
1951
+ }),
1952
+ rawNonce: z18.string(),
1953
+ name: appleNameInput.optional(),
1954
+ email: userDbSchema.shape.email.email().nullable()
1955
+ })
1956
+ });
1957
+
1958
+ // src/modules/oauth/google/google.dtos.ts
1959
+ import { z as z19 } from "zod/v4";
1960
+ var googleTokenVerificationResultSchema = z19.object({
1961
+ googleSub: z19.string(),
1962
+ email: userDbSchema.shape.email.nullable(),
1963
+ emailVerified: z19.boolean(),
1964
+ fullName: userDbSchema.shape.name
1965
+ });
1966
+
1967
+ // src/modules/oauth/google/google.schemas.ts
1968
+ import { z as z20 } from "zod/v4";
1969
+ var googleOAuthRequest = z20.object({
1970
+ body: z20.object({
1971
+ idToken: z20.string().optional()
1972
+ })
1973
+ });
1974
+
1975
+ // src/modules/oauth/oauth.schemas.ts
1976
+ import { z as z21 } from "zod/v4";
1977
+ var oAuthLoginResponseSchema = z21.object({
1978
+ message: z21.string(),
1979
+ user: userDbSchema.shape.id,
1980
+ accessToken: z21.string(),
1981
+ refreshToken: z21.string(),
1982
+ missingFields: z21.array(z21.string()).nullable()
1983
+ });
1984
+ var proceedLoginResponseSchema = loginResponseSchema;
1985
+
1986
+ // src/modules/user/create/create.schemas.ts
1987
+ import { z as z22 } from "zod/v4";
1988
+ var usernameSchema = userDbSchema.shape.username.trim().min(3, "Username must be at least 3 characters").max(15, "Username must be at most 15 characters").regex(/^[a-zA-Z0-9_]+$/, "Username may contain letters, numbers, and underscore only");
1989
+ var fullNameSchema = userDbSchema.shape.name.trim().max(20, "Full name is too long").regex(/^[a-zA-Z\s]+$/, "Full name may contain letters and spaces only");
1990
+ var createUserRequest = z22.object({
1991
+ body: z22.object({
1992
+ username: usernameSchema,
1993
+ fullName: z22.preprocess(
1994
+ // Map "", null, undefined -> "User"
1995
+ (val) => {
1996
+ if (val == null) return "User";
1997
+ if (typeof val === "string" && val.trim() === "") return "User";
1998
+ return val;
1999
+ },
2000
+ fullNameSchema
2001
+ ),
2002
+ email: userDbSchema.shape.email.trim().toLowerCase().email("Invalid email format"),
2003
+ password: z22.string().min(8, "Password must be at least 8 characters long"),
2004
+ gender: z22.preprocess((val) => val === "" || val == null ? "Unknown" : val, z22.enum([
2005
+ "Male",
2006
+ "Female",
2007
+ "Other",
2008
+ "Unknown"
2009
+ ]))
2010
+ })
2011
+ });
2012
+ var createUserUserSchema = z22.object({
2013
+ id: userDbSchema.shape.id,
2014
+ username: userDbSchema.shape.username,
2015
+ name: userDbSchema.shape.name,
2016
+ email: userDbSchema.shape.email,
2017
+ gender: userDbSchema.shape.gender,
2018
+ role: userDbSchema.shape.role,
2019
+ createdAt: serializedDateSchema
2020
+ });
2021
+ var createUserResponseSchema = z22.object({
2022
+ message: z22.string(),
2023
+ user: createUserUserSchema
2024
+ });
2025
+
2026
+ // src/modules/user/push-tokens/push-tokens.schemas.ts
2027
+ import { z as z23 } from "zod/v4";
2028
+ var saveUserPushTokenRequest = z23.object({
2029
+ body: z23.object({
2030
+ token: userDbSchema.shape.pushToken.unwrap()
2031
+ })
2032
+ });
2033
+
2034
+ // src/modules/user/update/update.dtos.ts
2035
+ import { z as z24 } from "zod/v4";
2036
+ var changeEmailTokenPayloadSchema = z24.object({
2037
+ jti: z24.string(),
2038
+ sub: z24.string(),
2039
+ newEmail: z24.string(),
2040
+ exp: z24.number(),
2041
+ iss: z24.string(),
2042
+ typ: z24.string()
2043
+ });
2044
+
2045
+ // src/modules/video-analysis/video-analysis.dtos.ts
2046
+ import { z as z25 } from "zod/v4";
2047
+ var enqueueAanalyzeVideoParamsSchema = z25.object({
2048
+ fileKey: z25.string(),
2049
+ exercise: z25.string(),
2050
+ userId: userDbSchema.shape.id,
2051
+ requestId: z25.string(),
2052
+ sentryTrace: z25.string().optional(),
2053
+ baggage: z25.string().optional()
2054
+ });
2055
+ var analyzeVideoPayloadSchema = enqueueAanalyzeVideoParamsSchema.extend({
2056
+ expiresAt: z25.number()
2057
+ });
2058
+ var squatRepetitionSchema = z25.object({
2059
+ depth: z25.object({
2060
+ value: z25.number(),
2061
+ status: z25.string(),
2062
+ confidence: z25.number()
2063
+ }),
2064
+ backLean: z25.object({
2065
+ value: z25.number(),
2066
+ excessive: z25.boolean(),
2067
+ confidence: z25.number()
2068
+ }),
2069
+ audit: z25.object({
2070
+ framesAnalyzed: z25.number(),
2071
+ validFrames: z25.number(),
2072
+ cameraAngle: z25.string(),
2073
+ rawBottomAngle: z25.number(),
2074
+ samplingRate: z25.string()
2075
+ })
2076
+ });
2077
+ var analyzeVideoResultPayloadSchema = /* @__PURE__ */ __name((resultSchema) => z25.intersection(z25.object({
2078
+ jobId: z25.string(),
2079
+ userId: userDbSchema.shape.id,
2080
+ exercise: z25.string(),
2081
+ requestId: z25.string().optional()
2082
+ }), z25.discriminatedUnion("status", [
2083
+ z25.object({
2084
+ status: z25.literal("completed"),
2085
+ result: z25.array(resultSchema),
2086
+ error: z25.null()
2087
+ }),
2088
+ z25.object({
2089
+ status: z25.literal("failed"),
2090
+ result: z25.null(),
2091
+ error: z25.string()
2092
+ })
2093
+ ])), "analyzeVideoResultPayloadSchema");
2094
+
2095
+ // src/modules/video-analysis/video-analysis.schemas.ts
2096
+ import { z as z26 } from "zod/v4";
2097
+ var getPresignedUrlS3Request = z26.object({
2098
+ body: z26.object({
2099
+ exercise: exerciseDbSchema.shape.name,
2100
+ fileType: z26.string(),
2101
+ jobId: z26.string()
2102
+ })
2103
+ });
2104
+ var getPresignedUrlFromS3ResponseSchema = z26.object({
2105
+ uploadUrl: z26.string(),
2106
+ fileKey: z26.string(),
2107
+ requestId: z26.string()
2108
+ });
2109
+
2110
+ // src/modules/web-sockets/web-sockets.schemas.ts
2111
+ import { z as z27 } from "zod/v4";
2112
+ var generateTicketRequest = z27.object({
2113
+ body: z27.object({
2114
+ username: userDbSchema.shape.username
2115
+ })
2116
+ });
2117
+ var generateTicketResponseSchema = z27.object({
2118
+ ticket: z27.string()
2119
+ });
2120
+ export {
2121
+ accessTokenPayloadSchema,
2122
+ addAerobicsRequest,
2123
+ addWorkoutRequest,
2124
+ addWorkoutResponseSchema,
2125
+ adherenceExerciseStatsSchema,
2126
+ aerobicTrackingDbSchema,
2127
+ aerobicsDailyRecordSchema,
2128
+ aerobicsWeeklyRecordSchema,
2129
+ allUserMessageSchema,
2130
+ analyzeVideoPayloadSchema,
2131
+ analyzeVideoResultPayloadSchema,
2132
+ appleOAuthRequest,
2133
+ appleTokenVerificationResultSchema,
2134
+ bootstrapRequest,
2135
+ bootstrapResponseSchema,
2136
+ changeEmailAndVerifyRequest,
2137
+ changeEmailTokenPayloadSchema,
2138
+ checkUserVerifyRequest,
2139
+ createUserRequest,
2140
+ createUserResponseSchema,
2141
+ createUserUserSchema,
2142
+ deleteMessageRequest,
2143
+ deleteMessageResponseSchema,
2144
+ deleteProfilePicRequest,
2145
+ deletedMessageSchema,
2146
+ emailVerifyPayloadSchema,
2147
+ enqueueAanalyzeVideoParamsSchema,
2148
+ exerciseDbSchema,
2149
+ exerciseInPlanSchema,
2150
+ exerciseMetadataSchema,
2151
+ exerciseToWorkoutSplitDbSchema,
2152
+ exerciseToWorkoutSplitExpandedViewDbSchema,
2153
+ exerciseTrackingAnalysisSchema,
2154
+ exerciseTrackingAndStatsSchema,
2155
+ exerciseTrackingDbSchema,
2156
+ exerciseTrackingExpandedViewDbSchema,
2157
+ exerciseTrackingPrMaxSchema,
2158
+ finishUserWorkoutResponseSchema,
2159
+ finishWorkoutRequest,
2160
+ forgotPasswordPayloadSchema,
2161
+ generateTicketRequest,
2162
+ generateTicketResponseSchema,
2163
+ getAerobicsRequest,
2164
+ getAllExercisesExerciseSchema,
2165
+ getAllExercisesResponseSchema,
2166
+ getAllMessagesRequest,
2167
+ getAllUserMessagesResponseSchema,
2168
+ getAnalyticsResponseSchema,
2169
+ getAuthenticatedUserByIdResponseSchema,
2170
+ getExerciseTrackingRequest,
2171
+ getExerciseTrackingResponseSchema,
2172
+ getPresignedUrlFromS3ResponseSchema,
2173
+ getPresignedUrlS3Request,
2174
+ getWholeUserWorkoutPlanResponseSchema,
2175
+ getWholeWorkoutPlanRequest,
2176
+ googleOAuthRequest,
2177
+ googleTokenVerificationResultSchema,
2178
+ loginRequest,
2179
+ loginResponseSchema,
2180
+ logoutResponseSchema,
2181
+ markMessageAsReadRequest,
2182
+ markMessageAsReadResponseSchema,
2183
+ messageAfterSendResponseSchema,
2184
+ messageAsReadSchema,
2185
+ messageDbSchema,
2186
+ oAuthLoginResponseSchema,
2187
+ oauthAccountDbSchema,
2188
+ proceedLoginResponseSchema,
2189
+ prsViewDbSchema,
2190
+ queryGetExerciseMapByMuscleRowSchema,
2191
+ refreshTokenResponseSchema,
2192
+ resetPasswordRequest,
2193
+ resetPasswordResponseSchema,
2194
+ saveUserPushTokenRequest,
2195
+ sendChangePassEmailRequest,
2196
+ sendVerificationMailRequest,
2197
+ serializedDateSchema,
2198
+ setProfilePicAndUpdateDBResponseSchema,
2199
+ squatRepetitionSchema,
2200
+ timezoneSchema,
2201
+ tokenVersionResultSchema,
2202
+ trackingByDateItemSchema,
2203
+ trackingBySplitNameItemSchema,
2204
+ trackingMapItemSchema,
2205
+ trackingSetDbSchema,
2206
+ updateAuthenticatedUserResponseSchema,
2207
+ updateUserRequest,
2208
+ userAerobicsResponseSchema,
2209
+ userAfterBumpSchema,
2210
+ userByIndetifierSchema,
2211
+ userDataResponseSchema,
2212
+ userDataSchema,
2213
+ userDbSchema,
2214
+ userInsertDbSchema,
2215
+ userReminderSettingDbSchema,
2216
+ userSplitInformationDbSchema,
2217
+ userUpdateDbSchema,
2218
+ verifyAccountRequest,
2219
+ weeklyDataSchema,
2220
+ wholeUserWorkoutPlanSchema,
2221
+ workoutPlanDbSchema,
2222
+ workoutRmRecordSchema,
2223
+ workoutSetDbSchema,
2224
+ workoutSplitDbSchema,
2225
+ workoutSplitSchema,
2226
+ workoutSplitsMapItemSchema,
2227
+ workoutSplitsMapSchema,
2228
+ workoutSummaryDbSchema
2229
+ };