@beorchid-llc/thrivo-contracts 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,416 @@
1
+ import { z } from "zod";
2
+ export declare const adminRoleSchema: z.ZodEnum<["admin", "support", "read-only"]>;
3
+ export type AdminRole = z.infer<typeof adminRoleSchema>;
4
+ export declare const adminSchema: z.ZodObject<{
5
+ id: z.ZodString;
6
+ email: z.ZodString;
7
+ name: z.ZodNullable<z.ZodString>;
8
+ role: z.ZodEnum<["admin", "support", "read-only"]>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ id: string;
11
+ email: string;
12
+ name: string | null;
13
+ role: "admin" | "support" | "read-only";
14
+ }, {
15
+ id: string;
16
+ email: string;
17
+ name: string | null;
18
+ role: "admin" | "support" | "read-only";
19
+ }>;
20
+ export type Admin = z.infer<typeof adminSchema>;
21
+ export declare const adminSessionResponseSchema: z.ZodObject<{
22
+ admin: z.ZodObject<{
23
+ id: z.ZodString;
24
+ email: z.ZodString;
25
+ name: z.ZodNullable<z.ZodString>;
26
+ role: z.ZodEnum<["admin", "support", "read-only"]>;
27
+ }, "strip", z.ZodTypeAny, {
28
+ id: string;
29
+ email: string;
30
+ name: string | null;
31
+ role: "admin" | "support" | "read-only";
32
+ }, {
33
+ id: string;
34
+ email: string;
35
+ name: string | null;
36
+ role: "admin" | "support" | "read-only";
37
+ }>;
38
+ }, "strip", z.ZodTypeAny, {
39
+ admin: {
40
+ id: string;
41
+ email: string;
42
+ name: string | null;
43
+ role: "admin" | "support" | "read-only";
44
+ };
45
+ }, {
46
+ admin: {
47
+ id: string;
48
+ email: string;
49
+ name: string | null;
50
+ role: "admin" | "support" | "read-only";
51
+ };
52
+ }>;
53
+ export type AdminSessionResponse = z.infer<typeof adminSessionResponseSchema>;
54
+ export declare const adminAckSchema: z.ZodObject<{
55
+ success: z.ZodBoolean;
56
+ }, "strip", z.ZodTypeAny, {
57
+ success: boolean;
58
+ }, {
59
+ success: boolean;
60
+ }>;
61
+ export type AdminAck = z.infer<typeof adminAckSchema>;
62
+ export declare const adminOtpRequestPayloadSchema: z.ZodObject<{
63
+ email: z.ZodString;
64
+ }, "strip", z.ZodTypeAny, {
65
+ email: string;
66
+ }, {
67
+ email: string;
68
+ }>;
69
+ export type AdminOtpRequestPayload = z.infer<typeof adminOtpRequestPayloadSchema>;
70
+ export declare const adminOtpVerifyPayloadSchema: z.ZodObject<{
71
+ email: z.ZodString;
72
+ code: z.ZodString;
73
+ }, "strip", z.ZodTypeAny, {
74
+ code: string;
75
+ email: string;
76
+ }, {
77
+ code: string;
78
+ email: string;
79
+ }>;
80
+ export type AdminOtpVerifyPayload = z.infer<typeof adminOtpVerifyPayloadSchema>;
81
+ export declare const adminPaginationSchema: z.ZodObject<{
82
+ page: z.ZodNumber;
83
+ pageSize: z.ZodNumber;
84
+ total: z.ZodNumber;
85
+ totalPages: z.ZodNumber;
86
+ }, "strip", z.ZodTypeAny, {
87
+ page: number;
88
+ pageSize: number;
89
+ total: number;
90
+ totalPages: number;
91
+ }, {
92
+ page: number;
93
+ pageSize: number;
94
+ total: number;
95
+ totalPages: number;
96
+ }>;
97
+ export type AdminPagination = z.infer<typeof adminPaginationSchema>;
98
+ export declare const adminPaginated: <T extends z.ZodTypeAny>(item: T) => z.ZodObject<{
99
+ items: z.ZodArray<T, "many">;
100
+ pagination: z.ZodObject<{
101
+ page: z.ZodNumber;
102
+ pageSize: z.ZodNumber;
103
+ total: z.ZodNumber;
104
+ totalPages: z.ZodNumber;
105
+ }, "strip", z.ZodTypeAny, {
106
+ page: number;
107
+ pageSize: number;
108
+ total: number;
109
+ totalPages: number;
110
+ }, {
111
+ page: number;
112
+ pageSize: number;
113
+ total: number;
114
+ totalPages: number;
115
+ }>;
116
+ }, "strip", z.ZodTypeAny, {
117
+ items: T["_output"][];
118
+ pagination: {
119
+ page: number;
120
+ pageSize: number;
121
+ total: number;
122
+ totalPages: number;
123
+ };
124
+ }, {
125
+ items: T["_input"][];
126
+ pagination: {
127
+ page: number;
128
+ pageSize: number;
129
+ total: number;
130
+ totalPages: number;
131
+ };
132
+ }>;
133
+ export declare const adminEntitlementSchema: z.ZodEnum<["free", "premium"]>;
134
+ export type AdminEntitlement = z.infer<typeof adminEntitlementSchema>;
135
+ export declare const adminUserStatusSchema: z.ZodEnum<["active", "suspended", "deleted"]>;
136
+ export type AdminUserStatus = z.infer<typeof adminUserStatusSchema>;
137
+ export declare const adminSubscriptionStatusSchema: z.ZodEnum<["active", "trialing", "canceled", "expired", "none"]>;
138
+ export type AdminSubscriptionStatus = z.infer<typeof adminSubscriptionStatusSchema>;
139
+ export declare const adminUserSchema: z.ZodObject<{
140
+ id: z.ZodString;
141
+ email: z.ZodString;
142
+ name: z.ZodNullable<z.ZodString>;
143
+ entitlement: z.ZodEnum<["free", "premium"]>;
144
+ status: z.ZodEnum<["active", "suspended", "deleted"]>;
145
+ createdAt: z.ZodString;
146
+ lastActiveAt: z.ZodNullable<z.ZodString>;
147
+ }, "strip", z.ZodTypeAny, {
148
+ status: "active" | "suspended" | "deleted";
149
+ id: string;
150
+ email: string;
151
+ name: string | null;
152
+ entitlement: "free" | "premium";
153
+ createdAt: string;
154
+ lastActiveAt: string | null;
155
+ }, {
156
+ status: "active" | "suspended" | "deleted";
157
+ id: string;
158
+ email: string;
159
+ name: string | null;
160
+ entitlement: "free" | "premium";
161
+ createdAt: string;
162
+ lastActiveAt: string | null;
163
+ }>;
164
+ export type AdminUser = z.infer<typeof adminUserSchema>;
165
+ export declare const adminUserDetailSchema: z.ZodObject<{
166
+ id: z.ZodString;
167
+ email: z.ZodString;
168
+ name: z.ZodNullable<z.ZodString>;
169
+ entitlement: z.ZodEnum<["free", "premium"]>;
170
+ status: z.ZodEnum<["active", "suspended", "deleted"]>;
171
+ createdAt: z.ZodString;
172
+ lastActiveAt: z.ZodNullable<z.ZodString>;
173
+ } & {
174
+ goal: z.ZodNullable<z.ZodString>;
175
+ targetCalories: z.ZodNullable<z.ZodNumber>;
176
+ totalFoodLogs: z.ZodNumber;
177
+ currentStreakDays: z.ZodNumber;
178
+ subscription: z.ZodNullable<z.ZodObject<{
179
+ status: z.ZodEnum<["active", "trialing", "canceled", "expired", "none"]>;
180
+ priceLabel: z.ZodNullable<z.ZodString>;
181
+ renewsAt: z.ZodNullable<z.ZodString>;
182
+ cancelAtPeriodEnd: z.ZodBoolean;
183
+ }, "strip", z.ZodTypeAny, {
184
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
185
+ priceLabel: string | null;
186
+ renewsAt: string | null;
187
+ cancelAtPeriodEnd: boolean;
188
+ }, {
189
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
190
+ priceLabel: string | null;
191
+ renewsAt: string | null;
192
+ cancelAtPeriodEnd: boolean;
193
+ }>>;
194
+ }, "strip", z.ZodTypeAny, {
195
+ status: "active" | "suspended" | "deleted";
196
+ id: string;
197
+ email: string;
198
+ name: string | null;
199
+ entitlement: "free" | "premium";
200
+ createdAt: string;
201
+ lastActiveAt: string | null;
202
+ goal: string | null;
203
+ targetCalories: number | null;
204
+ totalFoodLogs: number;
205
+ currentStreakDays: number;
206
+ subscription: {
207
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
208
+ priceLabel: string | null;
209
+ renewsAt: string | null;
210
+ cancelAtPeriodEnd: boolean;
211
+ } | null;
212
+ }, {
213
+ status: "active" | "suspended" | "deleted";
214
+ id: string;
215
+ email: string;
216
+ name: string | null;
217
+ entitlement: "free" | "premium";
218
+ createdAt: string;
219
+ lastActiveAt: string | null;
220
+ goal: string | null;
221
+ targetCalories: number | null;
222
+ totalFoodLogs: number;
223
+ currentStreakDays: number;
224
+ subscription: {
225
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
226
+ priceLabel: string | null;
227
+ renewsAt: string | null;
228
+ cancelAtPeriodEnd: boolean;
229
+ } | null;
230
+ }>;
231
+ export type AdminUserDetail = z.infer<typeof adminUserDetailSchema>;
232
+ export declare const adminUserDetailResponseSchema: z.ZodObject<{
233
+ user: z.ZodObject<{
234
+ id: z.ZodString;
235
+ email: z.ZodString;
236
+ name: z.ZodNullable<z.ZodString>;
237
+ entitlement: z.ZodEnum<["free", "premium"]>;
238
+ status: z.ZodEnum<["active", "suspended", "deleted"]>;
239
+ createdAt: z.ZodString;
240
+ lastActiveAt: z.ZodNullable<z.ZodString>;
241
+ } & {
242
+ goal: z.ZodNullable<z.ZodString>;
243
+ targetCalories: z.ZodNullable<z.ZodNumber>;
244
+ totalFoodLogs: z.ZodNumber;
245
+ currentStreakDays: z.ZodNumber;
246
+ subscription: z.ZodNullable<z.ZodObject<{
247
+ status: z.ZodEnum<["active", "trialing", "canceled", "expired", "none"]>;
248
+ priceLabel: z.ZodNullable<z.ZodString>;
249
+ renewsAt: z.ZodNullable<z.ZodString>;
250
+ cancelAtPeriodEnd: z.ZodBoolean;
251
+ }, "strip", z.ZodTypeAny, {
252
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
253
+ priceLabel: string | null;
254
+ renewsAt: string | null;
255
+ cancelAtPeriodEnd: boolean;
256
+ }, {
257
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
258
+ priceLabel: string | null;
259
+ renewsAt: string | null;
260
+ cancelAtPeriodEnd: boolean;
261
+ }>>;
262
+ }, "strip", z.ZodTypeAny, {
263
+ status: "active" | "suspended" | "deleted";
264
+ id: string;
265
+ email: string;
266
+ name: string | null;
267
+ entitlement: "free" | "premium";
268
+ createdAt: string;
269
+ lastActiveAt: string | null;
270
+ goal: string | null;
271
+ targetCalories: number | null;
272
+ totalFoodLogs: number;
273
+ currentStreakDays: number;
274
+ subscription: {
275
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
276
+ priceLabel: string | null;
277
+ renewsAt: string | null;
278
+ cancelAtPeriodEnd: boolean;
279
+ } | null;
280
+ }, {
281
+ status: "active" | "suspended" | "deleted";
282
+ id: string;
283
+ email: string;
284
+ name: string | null;
285
+ entitlement: "free" | "premium";
286
+ createdAt: string;
287
+ lastActiveAt: string | null;
288
+ goal: string | null;
289
+ targetCalories: number | null;
290
+ totalFoodLogs: number;
291
+ currentStreakDays: number;
292
+ subscription: {
293
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
294
+ priceLabel: string | null;
295
+ renewsAt: string | null;
296
+ cancelAtPeriodEnd: boolean;
297
+ } | null;
298
+ }>;
299
+ }, "strip", z.ZodTypeAny, {
300
+ user: {
301
+ status: "active" | "suspended" | "deleted";
302
+ id: string;
303
+ email: string;
304
+ name: string | null;
305
+ entitlement: "free" | "premium";
306
+ createdAt: string;
307
+ lastActiveAt: string | null;
308
+ goal: string | null;
309
+ targetCalories: number | null;
310
+ totalFoodLogs: number;
311
+ currentStreakDays: number;
312
+ subscription: {
313
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
314
+ priceLabel: string | null;
315
+ renewsAt: string | null;
316
+ cancelAtPeriodEnd: boolean;
317
+ } | null;
318
+ };
319
+ }, {
320
+ user: {
321
+ status: "active" | "suspended" | "deleted";
322
+ id: string;
323
+ email: string;
324
+ name: string | null;
325
+ entitlement: "free" | "premium";
326
+ createdAt: string;
327
+ lastActiveAt: string | null;
328
+ goal: string | null;
329
+ targetCalories: number | null;
330
+ totalFoodLogs: number;
331
+ currentStreakDays: number;
332
+ subscription: {
333
+ status: "active" | "trialing" | "canceled" | "expired" | "none";
334
+ priceLabel: string | null;
335
+ renewsAt: string | null;
336
+ cancelAtPeriodEnd: boolean;
337
+ } | null;
338
+ };
339
+ }>;
340
+ export type AdminUserDetailResponse = z.infer<typeof adminUserDetailResponseSchema>;
341
+ export declare const adminCancelPayloadSchema: z.ZodObject<{
342
+ reason: z.ZodString;
343
+ }, "strip", z.ZodTypeAny, {
344
+ reason: string;
345
+ }, {
346
+ reason: string;
347
+ }>;
348
+ export type AdminCancelPayload = z.infer<typeof adminCancelPayloadSchema>;
349
+ export declare const adminRefundPayloadSchema: z.ZodObject<{
350
+ amountCents: z.ZodOptional<z.ZodNumber>;
351
+ reason: z.ZodString;
352
+ }, "strip", z.ZodTypeAny, {
353
+ reason: string;
354
+ amountCents?: number | undefined;
355
+ }, {
356
+ reason: string;
357
+ amountCents?: number | undefined;
358
+ }>;
359
+ export type AdminRefundPayload = z.infer<typeof adminRefundPayloadSchema>;
360
+ /** Response for CSV/export endpoints — a signed download URL. */
361
+ export declare const adminExportResponseSchema: z.ZodObject<{
362
+ url: z.ZodString;
363
+ }, "strip", z.ZodTypeAny, {
364
+ url: string;
365
+ }, {
366
+ url: string;
367
+ }>;
368
+ export type AdminExportResponse = z.infer<typeof adminExportResponseSchema>;
369
+ export declare const adminRoutes: {
370
+ getSession: {
371
+ method: "GET";
372
+ path: "/api/v1/admin/auth/session";
373
+ auth: "admin";
374
+ };
375
+ requestOtp: {
376
+ method: "POST";
377
+ path: "/api/v1/admin/auth/request-otp";
378
+ auth: "public";
379
+ };
380
+ verifyOtp: {
381
+ method: "POST";
382
+ path: "/api/v1/admin/auth/verify-otp";
383
+ auth: "public";
384
+ };
385
+ adminLogout: {
386
+ method: "POST";
387
+ path: "/api/v1/admin/auth/logout";
388
+ auth: "admin";
389
+ };
390
+ listUsers: {
391
+ method: "GET";
392
+ path: "/api/v1/admin/users";
393
+ auth: "admin";
394
+ };
395
+ getUser: {
396
+ method: "GET";
397
+ path: "/api/v1/admin/users/:id";
398
+ auth: "admin";
399
+ };
400
+ hardDeleteUser: {
401
+ method: "DELETE";
402
+ path: "/api/v1/admin/users/:id";
403
+ auth: "admin";
404
+ };
405
+ cancelSubscription: {
406
+ method: "POST";
407
+ path: "/api/v1/admin/users/:id/subscription/cancel";
408
+ auth: "admin";
409
+ };
410
+ refundSubscription: {
411
+ method: "POST";
412
+ path: "/api/v1/admin/users/:id/subscription/refund";
413
+ auth: "admin";
414
+ };
415
+ };
416
+ //# sourceMappingURL=admin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA,OA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,CAAC;AAM5E,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDiB,CAAC"}
package/dist/admin.js ADDED
@@ -0,0 +1,129 @@
1
+ import { z } from "zod";
2
+ // ---------------------------------------------------------------------------
3
+ // Admin identity
4
+ // ---------------------------------------------------------------------------
5
+ export const adminRoleSchema = z.enum(["admin", "support", "read-only"]);
6
+ export const adminSchema = z.object({
7
+ id: z.string(),
8
+ email: z.string().email(),
9
+ name: z.string().nullable(),
10
+ role: adminRoleSchema,
11
+ });
12
+ // ---------------------------------------------------------------------------
13
+ // Admin auth payloads + responses
14
+ // ---------------------------------------------------------------------------
15
+ export const adminSessionResponseSchema = z.object({ admin: adminSchema });
16
+ export const adminAckSchema = z.object({ success: z.boolean() });
17
+ export const adminOtpRequestPayloadSchema = z.object({
18
+ email: z.string().email(),
19
+ });
20
+ export const adminOtpVerifyPayloadSchema = z.object({
21
+ email: z.string().email(),
22
+ code: z.string().min(4),
23
+ });
24
+ // ---------------------------------------------------------------------------
25
+ // Admin pagination helper
26
+ // ---------------------------------------------------------------------------
27
+ export const adminPaginationSchema = z.object({
28
+ page: z.number(),
29
+ pageSize: z.number(),
30
+ total: z.number(),
31
+ totalPages: z.number(),
32
+ });
33
+ export const adminPaginated = (item) => z.object({ items: z.array(item), pagination: adminPaginationSchema });
34
+ // ---------------------------------------------------------------------------
35
+ // Admin user schemas
36
+ // ---------------------------------------------------------------------------
37
+ export const adminEntitlementSchema = z.enum(["free", "premium"]);
38
+ export const adminUserStatusSchema = z.enum(["active", "suspended", "deleted"]);
39
+ export const adminSubscriptionStatusSchema = z.enum([
40
+ "active",
41
+ "trialing",
42
+ "canceled",
43
+ "expired",
44
+ "none",
45
+ ]);
46
+ export const adminUserSchema = z.object({
47
+ id: z.string(),
48
+ email: z.string().email(),
49
+ name: z.string().nullable(),
50
+ entitlement: adminEntitlementSchema,
51
+ status: adminUserStatusSchema,
52
+ createdAt: z.string(), // ISO-8601
53
+ lastActiveAt: z.string().nullable(),
54
+ });
55
+ export const adminUserDetailSchema = adminUserSchema.extend({
56
+ goal: z.string().nullable(),
57
+ targetCalories: z.number().nullable(),
58
+ totalFoodLogs: z.number(),
59
+ currentStreakDays: z.number(),
60
+ subscription: z
61
+ .object({
62
+ status: adminSubscriptionStatusSchema,
63
+ priceLabel: z.string().nullable(),
64
+ renewsAt: z.string().nullable(),
65
+ cancelAtPeriodEnd: z.boolean(),
66
+ })
67
+ .nullable(),
68
+ });
69
+ export const adminUserDetailResponseSchema = z.object({ user: adminUserDetailSchema });
70
+ export const adminCancelPayloadSchema = z.object({ reason: z.string().min(1) });
71
+ export const adminRefundPayloadSchema = z.object({
72
+ amountCents: z.number().int().positive().optional(),
73
+ reason: z.string().min(1),
74
+ });
75
+ /** Response for CSV/export endpoints — a signed download URL. */
76
+ export const adminExportResponseSchema = z.object({ url: z.string().url() });
77
+ // ---------------------------------------------------------------------------
78
+ // Admin route contracts
79
+ // ---------------------------------------------------------------------------
80
+ export const adminRoutes = {
81
+ // Auth (staff OTP login — session stored in httpOnly cookie)
82
+ getSession: {
83
+ method: "GET",
84
+ path: "/api/v1/admin/auth/session",
85
+ auth: "admin",
86
+ },
87
+ requestOtp: {
88
+ method: "POST",
89
+ path: "/api/v1/admin/auth/request-otp",
90
+ auth: "public",
91
+ },
92
+ verifyOtp: {
93
+ method: "POST",
94
+ path: "/api/v1/admin/auth/verify-otp",
95
+ auth: "public",
96
+ },
97
+ adminLogout: {
98
+ method: "POST",
99
+ path: "/api/v1/admin/auth/logout",
100
+ auth: "admin",
101
+ },
102
+ // User management
103
+ listUsers: {
104
+ method: "GET",
105
+ path: "/api/v1/admin/users",
106
+ auth: "admin",
107
+ },
108
+ getUser: {
109
+ method: "GET",
110
+ path: "/api/v1/admin/users/:id",
111
+ auth: "admin",
112
+ },
113
+ hardDeleteUser: {
114
+ method: "DELETE",
115
+ path: "/api/v1/admin/users/:id",
116
+ auth: "admin",
117
+ },
118
+ cancelSubscription: {
119
+ method: "POST",
120
+ path: "/api/v1/admin/users/:id/subscription/cancel",
121
+ auth: "admin",
122
+ },
123
+ refundSubscription: {
124
+ method: "POST",
125
+ path: "/api/v1/admin/users/:id/subscription/refund",
126
+ auth: "admin",
127
+ },
128
+ };
129
+ //# sourceMappingURL=admin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.js","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;AAGzE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;IACzB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,IAAI,EAAE,eAAe;CACtB,CAAC,CAAC;AAGH,8EAA8E;AAC9E,kCAAkC;AAClC,8EAA8E;AAE9E,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;AAG3E,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAGjE,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;CAC1B,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM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.ts ADDED
@@ -0,0 +1,71 @@
1
+ import { z } from "zod";
2
+ /** Token pair returned to a client after a successful auth flow (magic-link or Google OAuth). */
3
+ export declare const authSessionSchema: z.ZodObject<{
4
+ accessToken: z.ZodString;
5
+ refreshToken: z.ZodString;
6
+ refreshExpiresAt: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ accessToken: string;
9
+ refreshToken: string;
10
+ refreshExpiresAt: string;
11
+ }, {
12
+ accessToken: string;
13
+ refreshToken: string;
14
+ refreshExpiresAt: string;
15
+ }>;
16
+ export type AuthSession = z.infer<typeof authSessionSchema>;
17
+ /** POST /auth/magic-link/request payload */
18
+ export declare const magicLinkRequestPayloadSchema: z.ZodObject<{
19
+ email: z.ZodString;
20
+ }, "strip", z.ZodTypeAny, {
21
+ email: string;
22
+ }, {
23
+ email: string;
24
+ }>;
25
+ export type MagicLinkRequestPayload = z.infer<typeof magicLinkRequestPayloadSchema>;
26
+ /** POST /auth/magic-link/verify payload */
27
+ export declare const magicLinkVerifyPayloadSchema: z.ZodObject<{
28
+ token: z.ZodString;
29
+ }, "strip", z.ZodTypeAny, {
30
+ token: string;
31
+ }, {
32
+ token: string;
33
+ }>;
34
+ export type MagicLinkVerifyPayload = z.infer<typeof magicLinkVerifyPayloadSchema>;
35
+ /** POST /auth/refresh + POST /auth/logout payload */
36
+ export declare const refreshPayloadSchema: z.ZodObject<{
37
+ refreshToken: z.ZodString;
38
+ }, "strip", z.ZodTypeAny, {
39
+ refreshToken: string;
40
+ }, {
41
+ refreshToken: string;
42
+ }>;
43
+ export type RefreshPayload = z.infer<typeof refreshPayloadSchema>;
44
+ export declare const authRoutes: {
45
+ requestMagicLink: {
46
+ method: "POST";
47
+ path: "/api/v1/auth/magic-link/request";
48
+ auth: "public";
49
+ };
50
+ verifyMagicLink: {
51
+ method: "POST";
52
+ path: "/api/v1/auth/magic-link/verify";
53
+ auth: "public";
54
+ };
55
+ refresh: {
56
+ method: "POST";
57
+ path: "/api/v1/auth/refresh";
58
+ auth: "public";
59
+ };
60
+ logout: {
61
+ method: "POST";
62
+ path: "/api/v1/auth/logout";
63
+ auth: "public";
64
+ };
65
+ googleStart: {
66
+ method: "GET";
67
+ path: "/api/v1/auth/google/start";
68
+ auth: "public";
69
+ };
70
+ };
71
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,iGAAiG;AACjG,eAAO,MAAM,iBAAiB;;;;;;;;;;;;EAI5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,4CAA4C;AAC5C,eAAO,MAAM,6BAA6B;;;;;;EAExC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF,2CAA2C;AAC3C,eAAO,MAAM,4BAA4B;;;;;;EAEvC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF,qDAAqD;AACrD,eAAO,MAAM,oBAAoB;;;;;;EAE/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BkB,CAAC"}
package/dist/auth.js ADDED
@@ -0,0 +1,47 @@
1
+ import { z } from "zod";
2
+ /** Token pair returned to a client after a successful auth flow (magic-link or Google OAuth). */
3
+ export const authSessionSchema = z.object({
4
+ accessToken: z.string(),
5
+ refreshToken: z.string(),
6
+ refreshExpiresAt: z.string(), // ISO-8601
7
+ });
8
+ /** POST /auth/magic-link/request payload */
9
+ export const magicLinkRequestPayloadSchema = z.object({
10
+ email: z.string().email(),
11
+ });
12
+ /** POST /auth/magic-link/verify payload */
13
+ export const magicLinkVerifyPayloadSchema = z.object({
14
+ token: z.string().min(1),
15
+ });
16
+ /** POST /auth/refresh + POST /auth/logout payload */
17
+ export const refreshPayloadSchema = z.object({
18
+ refreshToken: z.string().min(1),
19
+ });
20
+ export const authRoutes = {
21
+ requestMagicLink: {
22
+ method: "POST",
23
+ path: "/api/v1/auth/magic-link/request",
24
+ auth: "public",
25
+ },
26
+ verifyMagicLink: {
27
+ method: "POST",
28
+ path: "/api/v1/auth/magic-link/verify",
29
+ auth: "public",
30
+ },
31
+ refresh: {
32
+ method: "POST",
33
+ path: "/api/v1/auth/refresh",
34
+ auth: "public",
35
+ },
36
+ logout: {
37
+ method: "POST",
38
+ path: "/api/v1/auth/logout",
39
+ auth: "public",
40
+ },
41
+ googleStart: {
42
+ method: "GET",
43
+ path: "/api/v1/auth/google/start",
44
+ auth: "public",
45
+ },
46
+ };
47
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,iGAAiG;AACjG,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;IACxB,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,WAAW;CAC1C,CAAC,CAAC;AAGH,4CAA4C;AAC5C,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC;IACpD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;CAC1B,CAAC,CAAC;AAGH,2CAA2C;AAC3C,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACzB,CAAC,CAAC;AAGH,qDAAqD;AACrD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAChC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,gBAAgB,EAAE;QAChB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,iCAAiC;QACvC,IAAI,EAAE,QAAQ;KACf;IACD,eAAe,EAAE;QACf,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,gCAAgC;QACtC,IAAI,EAAE,QAAQ;KACf;IACD,OAAO,EAAE;QACP,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,sBAAsB;QAC5B,IAAI,EAAE,QAAQ;KACf;IACD,MAAM,EAAE;QACN,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,QAAQ;KACf;IACD,WAAW,EAAE;QACX,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,2BAA2B;QACjC,IAAI,EAAE,QAAQ;KACf;CACsC,CAAC"}
package/dist/common.d.ts CHANGED
@@ -75,4 +75,21 @@ export type RouteContract = {
75
75
  path: `/api/v1/${string}`;
76
76
  auth: "public" | "user" | "admin" | "signature";
77
77
  };
78
+ /** Generic success envelope `{ data: T, meta? }` — admin-panel alias of apiSuccessSchema. */
79
+ export declare const successEnvelope: typeof apiSuccessSchema;
80
+ /** Untyped primitive schemas for ID fields and ISO date strings. */
81
+ export declare const idSchema: z.ZodString;
82
+ export declare const isoDateSchema: z.ZodString;
83
+ /** Named time-series point used in admin analytics charts. */
84
+ export declare const timePointSchema: z.ZodObject<{
85
+ date: z.ZodString;
86
+ value: z.ZodNumber;
87
+ }, "strip", z.ZodTypeAny, {
88
+ value: number;
89
+ date: string;
90
+ }, {
91
+ value: number;
92
+ date: string;
93
+ }>;
94
+ export type TimePoint = z.infer<typeof timePointSchema>;
78
95
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,eAAe,+JAU1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,UAAU;;;;;;0BAIC,CAAC;AAEzB,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAE9C,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;EAMzB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;kEAK/D;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAC1B,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE7D,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,WAAW,MAAM,EAAE,CAAC;IAC1B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,WAAW,CAAC;CACjD,CAAC"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,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function apiSuccessSchema(data) {
28
28
  meta: metaSchema.optional(),
29
29
  });
30
30
  }
31
+ // ---------------------------------------------------------------------------
32
+ // Utility aliases used by admin-panel consumers
33
+ // ---------------------------------------------------------------------------
34
+ /** Generic success envelope `{ data: T, meta? }` — admin-panel alias of apiSuccessSchema. */
35
+ export const successEnvelope = apiSuccessSchema;
36
+ /** Untyped primitive schemas for ID fields and ISO date strings. */
37
+ export const idSchema = z.string().min(1);
38
+ export const isoDateSchema = z.string();
39
+ /** Named time-series point used in admin analytics charts. */
40
+ export const timePointSchema = z.object({ date: z.string(), value: z.number() });
31
41
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC;IACpC,kBAAkB;IAClB,cAAc;IACd,WAAW;IACX,kBAAkB;IAClB,WAAW;IACX,UAAU;IACV,cAAc;IACd,gBAAgB;IAChB,gBAAgB;CACjB,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC;KACxB,MAAM,CAAC;IACN,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CAC7C,CAAC;KACD,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAIzB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;KAChC,CAAC;CACH,CAAC,CAAC;AAIH,MAAM,UAAU,gBAAgB,CAAyB,IAAO;IAC9D,OAAO,CAAC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,CAAC,CAAC,CAAC,CAAC;AAC1C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;AAExC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from "./common";
2
2
  export * from "./users";
3
+ export * from "./auth";
4
+ export * from "./admin";
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from "./common";
2
2
  export * from "./users";
3
+ export * from "./auth";
4
+ export * from "./admin";
3
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
package/dist/users.d.ts CHANGED
@@ -34,6 +34,7 @@ export declare const userProfileSchema: z.ZodObject<{
34
34
  id: string;
35
35
  email: string;
36
36
  name: string;
37
+ createdAt: Date;
37
38
  goal: "lose" | "maintain" | "gain" | null;
38
39
  sex: "male" | "female" | "prefer_not_to_say" | null;
39
40
  age: number | null;
@@ -45,7 +46,7 @@ export declare const userProfileSchema: z.ZodObject<{
45
46
  targetProteinG: number | null;
46
47
  targetCarbsG: number | null;
47
48
  targetFatG: number | null;
48
- activityLevel: "sedentary" | "light" | "moderate" | "active" | "very_active" | null;
49
+ activityLevel: "active" | "sedentary" | "light" | "moderate" | "very_active" | null;
49
50
  manualDailyTargetKcal: number | null;
50
51
  notifyTimes: string[] | null;
51
52
  timezone: string | null;
@@ -54,11 +55,11 @@ export declare const userProfileSchema: z.ZodObject<{
54
55
  trialEndsAt: Date | null;
55
56
  onboardingStep: number;
56
57
  isOnboarded: boolean;
57
- createdAt: Date;
58
58
  }, {
59
59
  id: string;
60
60
  email: string;
61
61
  name: string;
62
+ createdAt: Date;
62
63
  goal: "lose" | "maintain" | "gain" | null;
63
64
  sex: "male" | "female" | "prefer_not_to_say" | null;
64
65
  age: number | null;
@@ -70,7 +71,7 @@ export declare const userProfileSchema: z.ZodObject<{
70
71
  targetProteinG: number | null;
71
72
  targetCarbsG: number | null;
72
73
  targetFatG: number | null;
73
- activityLevel: "sedentary" | "light" | "moderate" | "active" | "very_active" | null;
74
+ activityLevel: "active" | "sedentary" | "light" | "moderate" | "very_active" | null;
74
75
  manualDailyTargetKcal: number | null;
75
76
  notifyTimes: string[] | null;
76
77
  timezone: string | null;
@@ -79,7 +80,6 @@ export declare const userProfileSchema: z.ZodObject<{
79
80
  trialEndsAt: Date | null;
80
81
  onboardingStep: number;
81
82
  isOnboarded: boolean;
82
- createdAt: Date;
83
83
  }>;
84
84
  export type UserProfile = z.infer<typeof userProfileSchema>;
85
85
  export declare const getMeResponseSchema: z.ZodObject<{
@@ -112,6 +112,7 @@ export declare const getMeResponseSchema: z.ZodObject<{
112
112
  id: string;
113
113
  email: string;
114
114
  name: string;
115
+ createdAt: Date;
115
116
  goal: "lose" | "maintain" | "gain" | null;
116
117
  sex: "male" | "female" | "prefer_not_to_say" | null;
117
118
  age: number | null;
@@ -123,7 +124,7 @@ export declare const getMeResponseSchema: z.ZodObject<{
123
124
  targetProteinG: number | null;
124
125
  targetCarbsG: number | null;
125
126
  targetFatG: number | null;
126
- activityLevel: "sedentary" | "light" | "moderate" | "active" | "very_active" | null;
127
+ activityLevel: "active" | "sedentary" | "light" | "moderate" | "very_active" | null;
127
128
  manualDailyTargetKcal: number | null;
128
129
  notifyTimes: string[] | null;
129
130
  timezone: string | null;
@@ -132,11 +133,11 @@ export declare const getMeResponseSchema: z.ZodObject<{
132
133
  trialEndsAt: Date | null;
133
134
  onboardingStep: number;
134
135
  isOnboarded: boolean;
135
- createdAt: Date;
136
136
  }, {
137
137
  id: string;
138
138
  email: string;
139
139
  name: string;
140
+ createdAt: Date;
140
141
  goal: "lose" | "maintain" | "gain" | null;
141
142
  sex: "male" | "female" | "prefer_not_to_say" | null;
142
143
  age: number | null;
@@ -148,7 +149,7 @@ export declare const getMeResponseSchema: z.ZodObject<{
148
149
  targetProteinG: number | null;
149
150
  targetCarbsG: number | null;
150
151
  targetFatG: number | null;
151
- activityLevel: "sedentary" | "light" | "moderate" | "active" | "very_active" | null;
152
+ activityLevel: "active" | "sedentary" | "light" | "moderate" | "very_active" | null;
152
153
  manualDailyTargetKcal: number | null;
153
154
  notifyTimes: string[] | null;
154
155
  timezone: string | null;
@@ -157,7 +158,6 @@ export declare const getMeResponseSchema: z.ZodObject<{
157
158
  trialEndsAt: Date | null;
158
159
  onboardingStep: number;
159
160
  isOnboarded: boolean;
160
- createdAt: Date;
161
161
  }>;
162
162
  meta: z.ZodOptional<z.ZodObject<{
163
163
  nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -171,6 +171,7 @@ export declare const getMeResponseSchema: z.ZodObject<{
171
171
  id: string;
172
172
  email: string;
173
173
  name: string;
174
+ createdAt: Date;
174
175
  goal: "lose" | "maintain" | "gain" | null;
175
176
  sex: "male" | "female" | "prefer_not_to_say" | null;
176
177
  age: number | null;
@@ -182,7 +183,7 @@ export declare const getMeResponseSchema: z.ZodObject<{
182
183
  targetProteinG: number | null;
183
184
  targetCarbsG: number | null;
184
185
  targetFatG: number | null;
185
- activityLevel: "sedentary" | "light" | "moderate" | "active" | "very_active" | null;
186
+ activityLevel: "active" | "sedentary" | "light" | "moderate" | "very_active" | null;
186
187
  manualDailyTargetKcal: number | null;
187
188
  notifyTimes: string[] | null;
188
189
  timezone: string | null;
@@ -191,7 +192,6 @@ export declare const getMeResponseSchema: z.ZodObject<{
191
192
  trialEndsAt: Date | null;
192
193
  onboardingStep: number;
193
194
  isOnboarded: boolean;
194
- createdAt: Date;
195
195
  };
196
196
  meta?: z.objectOutputType<{
197
197
  nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -201,6 +201,7 @@ export declare const getMeResponseSchema: z.ZodObject<{
201
201
  id: string;
202
202
  email: string;
203
203
  name: string;
204
+ createdAt: Date;
204
205
  goal: "lose" | "maintain" | "gain" | null;
205
206
  sex: "male" | "female" | "prefer_not_to_say" | null;
206
207
  age: number | null;
@@ -212,7 +213,7 @@ export declare const getMeResponseSchema: z.ZodObject<{
212
213
  targetProteinG: number | null;
213
214
  targetCarbsG: number | null;
214
215
  targetFatG: number | null;
215
- activityLevel: "sedentary" | "light" | "moderate" | "active" | "very_active" | null;
216
+ activityLevel: "active" | "sedentary" | "light" | "moderate" | "very_active" | null;
216
217
  manualDailyTargetKcal: number | null;
217
218
  notifyTimes: string[] | null;
218
219
  timezone: string | null;
@@ -221,7 +222,6 @@ export declare const getMeResponseSchema: z.ZodObject<{
221
222
  trialEndsAt: Date | null;
222
223
  onboardingStep: number;
223
224
  isOnboarded: boolean;
224
- createdAt: Date;
225
225
  };
226
226
  meta?: z.objectInputType<{
227
227
  nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -248,7 +248,7 @@ export declare const updateProfilePayloadSchema: z.ZodObject<{
248
248
  sex?: "male" | "female" | "prefer_not_to_say" | undefined;
249
249
  heightCm?: number | undefined;
250
250
  targetWeightKg?: number | undefined;
251
- activityLevel?: "sedentary" | "light" | "moderate" | "active" | "very_active" | undefined;
251
+ activityLevel?: "active" | "sedentary" | "light" | "moderate" | "very_active" | undefined;
252
252
  manualDailyTargetKcal?: number | undefined;
253
253
  notifyTimes?: string[] | undefined;
254
254
  timezone?: string | undefined;
@@ -263,7 +263,7 @@ export declare const updateProfilePayloadSchema: z.ZodObject<{
263
263
  sex?: "male" | "female" | "prefer_not_to_say" | undefined;
264
264
  heightCm?: number | undefined;
265
265
  targetWeightKg?: number | undefined;
266
- activityLevel?: "sedentary" | "light" | "moderate" | "active" | "very_active" | undefined;
266
+ activityLevel?: "active" | "sedentary" | "light" | "moderate" | "very_active" | undefined;
267
267
  manualDailyTargetKcal?: number | undefined;
268
268
  notifyTimes?: string[] | undefined;
269
269
  timezone?: string | undefined;
@@ -305,6 +305,7 @@ export declare const updateProfileResponseSchema: z.ZodObject<{
305
305
  id: string;
306
306
  email: string;
307
307
  name: string;
308
+ createdAt: Date;
308
309
  goal: "lose" | "maintain" | "gain" | null;
309
310
  sex: "male" | "female" | "prefer_not_to_say" | null;
310
311
  age: number | null;
@@ -316,7 +317,7 @@ export declare const updateProfileResponseSchema: z.ZodObject<{
316
317
  targetProteinG: number | null;
317
318
  targetCarbsG: number | null;
318
319
  targetFatG: number | null;
319
- activityLevel: "sedentary" | "light" | "moderate" | "active" | "very_active" | null;
320
+ activityLevel: "active" | "sedentary" | "light" | "moderate" | "very_active" | null;
320
321
  manualDailyTargetKcal: number | null;
321
322
  notifyTimes: string[] | null;
322
323
  timezone: string | null;
@@ -325,11 +326,11 @@ export declare const updateProfileResponseSchema: z.ZodObject<{
325
326
  trialEndsAt: Date | null;
326
327
  onboardingStep: number;
327
328
  isOnboarded: boolean;
328
- createdAt: Date;
329
329
  }, {
330
330
  id: string;
331
331
  email: string;
332
332
  name: string;
333
+ createdAt: Date;
333
334
  goal: "lose" | "maintain" | "gain" | null;
334
335
  sex: "male" | "female" | "prefer_not_to_say" | null;
335
336
  age: number | null;
@@ -341,7 +342,7 @@ export declare const updateProfileResponseSchema: z.ZodObject<{
341
342
  targetProteinG: number | null;
342
343
  targetCarbsG: number | null;
343
344
  targetFatG: number | null;
344
- activityLevel: "sedentary" | "light" | "moderate" | "active" | "very_active" | null;
345
+ activityLevel: "active" | "sedentary" | "light" | "moderate" | "very_active" | null;
345
346
  manualDailyTargetKcal: number | null;
346
347
  notifyTimes: string[] | null;
347
348
  timezone: string | null;
@@ -350,7 +351,6 @@ export declare const updateProfileResponseSchema: z.ZodObject<{
350
351
  trialEndsAt: Date | null;
351
352
  onboardingStep: number;
352
353
  isOnboarded: boolean;
353
- createdAt: Date;
354
354
  }>;
355
355
  meta: z.ZodOptional<z.ZodObject<{
356
356
  nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -364,6 +364,7 @@ export declare const updateProfileResponseSchema: z.ZodObject<{
364
364
  id: string;
365
365
  email: string;
366
366
  name: string;
367
+ createdAt: Date;
367
368
  goal: "lose" | "maintain" | "gain" | null;
368
369
  sex: "male" | "female" | "prefer_not_to_say" | null;
369
370
  age: number | null;
@@ -375,7 +376,7 @@ export declare const updateProfileResponseSchema: z.ZodObject<{
375
376
  targetProteinG: number | null;
376
377
  targetCarbsG: number | null;
377
378
  targetFatG: number | null;
378
- activityLevel: "sedentary" | "light" | "moderate" | "active" | "very_active" | null;
379
+ activityLevel: "active" | "sedentary" | "light" | "moderate" | "very_active" | null;
379
380
  manualDailyTargetKcal: number | null;
380
381
  notifyTimes: string[] | null;
381
382
  timezone: string | null;
@@ -384,7 +385,6 @@ export declare const updateProfileResponseSchema: z.ZodObject<{
384
385
  trialEndsAt: Date | null;
385
386
  onboardingStep: number;
386
387
  isOnboarded: boolean;
387
- createdAt: Date;
388
388
  };
389
389
  meta?: z.objectOutputType<{
390
390
  nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -394,6 +394,7 @@ export declare const updateProfileResponseSchema: z.ZodObject<{
394
394
  id: string;
395
395
  email: string;
396
396
  name: string;
397
+ createdAt: Date;
397
398
  goal: "lose" | "maintain" | "gain" | null;
398
399
  sex: "male" | "female" | "prefer_not_to_say" | null;
399
400
  age: number | null;
@@ -405,7 +406,7 @@ export declare const updateProfileResponseSchema: z.ZodObject<{
405
406
  targetProteinG: number | null;
406
407
  targetCarbsG: number | null;
407
408
  targetFatG: number | null;
408
- activityLevel: "sedentary" | "light" | "moderate" | "active" | "very_active" | null;
409
+ activityLevel: "active" | "sedentary" | "light" | "moderate" | "very_active" | null;
409
410
  manualDailyTargetKcal: number | null;
410
411
  notifyTimes: string[] | null;
411
412
  timezone: string | null;
@@ -414,7 +415,6 @@ export declare const updateProfileResponseSchema: z.ZodObject<{
414
415
  trialEndsAt: Date | null;
415
416
  onboardingStep: number;
416
417
  isOnboarded: boolean;
417
- createdAt: Date;
418
418
  };
419
419
  meta?: z.objectInputType<{
420
420
  nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beorchid-llc/thrivo-contracts",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Shared Thrivo API request and response contracts.",
5
5
  "type": "module",
6
6
  "private": false,
@@ -19,6 +19,14 @@
19
19
  "./users": {
20
20
  "types": "./dist/users.d.ts",
21
21
  "import": "./dist/users.js"
22
+ },
23
+ "./auth": {
24
+ "types": "./dist/auth.d.ts",
25
+ "import": "./dist/auth.js"
26
+ },
27
+ "./admin": {
28
+ "types": "./dist/admin.d.ts",
29
+ "import": "./dist/admin.js"
22
30
  }
23
31
  },
24
32
  "files": [