@tbs-fitness/contract 0.4.0 → 0.5.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.
Files changed (36) hide show
  1. package/README.md +10 -0
  2. package/dist/cjs/auth/auth.dto.d.ts +4 -4
  3. package/dist/cjs/auth/index.d.ts +1 -0
  4. package/dist/cjs/auth/index.js +1 -0
  5. package/dist/cjs/auth/otp.dto.d.ts +45 -0
  6. package/dist/cjs/auth/otp.dto.js +39 -0
  7. package/dist/cjs/client/client-auth.dto.d.ts +81 -0
  8. package/dist/cjs/client/client-auth.dto.js +49 -0
  9. package/dist/cjs/client/index.d.ts +2 -0
  10. package/dist/cjs/client/index.js +18 -0
  11. package/dist/cjs/coach/coach-auth.dto.d.ts +0 -40
  12. package/dist/cjs/coach/coach-auth.dto.js +1 -30
  13. package/dist/cjs/coach/index.d.ts +1 -0
  14. package/dist/cjs/coach/index.js +1 -0
  15. package/dist/cjs/enums/index.d.ts +2 -2
  16. package/dist/cjs/enums/index.js +2 -2
  17. package/dist/cjs/feature-flags/feature-flag.dto.d.ts +4 -4
  18. package/dist/cjs/feature-flags/feature-flag.dto.js +1 -1
  19. package/dist/esm/auth/auth.dto.d.ts +4 -4
  20. package/dist/esm/auth/index.d.ts +1 -0
  21. package/dist/esm/auth/index.js +1 -0
  22. package/dist/esm/auth/otp.dto.d.ts +45 -0
  23. package/dist/esm/auth/otp.dto.js +36 -0
  24. package/dist/esm/client/client-auth.dto.d.ts +81 -0
  25. package/dist/esm/client/client-auth.dto.js +46 -0
  26. package/dist/esm/client/index.d.ts +2 -0
  27. package/dist/esm/client/index.js +2 -0
  28. package/dist/esm/coach/coach-auth.dto.d.ts +0 -40
  29. package/dist/esm/coach/coach-auth.dto.js +1 -30
  30. package/dist/esm/coach/index.d.ts +1 -0
  31. package/dist/esm/coach/index.js +1 -0
  32. package/dist/esm/enums/index.d.ts +2 -2
  33. package/dist/esm/enums/index.js +2 -2
  34. package/dist/esm/feature-flags/feature-flag.dto.d.ts +4 -4
  35. package/dist/esm/feature-flags/feature-flag.dto.js +1 -1
  36. package/package.json +11 -1
package/README.md CHANGED
@@ -11,6 +11,7 @@ It is published as `@tbs-fitness/contract`. The package holds definitions only:
11
11
  | `@tbs-fitness/contract/enums` | `ROLES`, `ACCOUNT_STATUSES`, `TOKEN_TRANSPORTS`, `AUDIT_OUTCOMES`, `APP_ENVIRONMENTS`, `FEATURE_FLAG_RULE_TYPES` and their types |
12
12
  | `@tbs-fitness/contract/common` | Pagination, response envelopes (`{ data }`, `{ data, meta }`, `{ error }`), `emailSchema`, `phoneSchema`, `safeTextSchema` |
13
13
  | `@tbs-fitness/contract/auth` | Login, sessions, password changes and resets, account administration |
14
+ | `@tbs-fitness/contract/client` | Client sign-up, one-time code verification and resend, client sign-in and profile, password recovery |
14
15
  | `@tbs-fitness/contract/coach` | Coach sign-up, one-time code verification and resend, coach sign-in and profile, password recovery |
15
16
  | `@tbs-fitness/contract/audit` | The audit log query and response |
16
17
  | `@tbs-fitness/contract/feature-flags` | Feature flag requests and responses |
@@ -41,6 +42,15 @@ const result = createFlagSchema.safeParse(input); // The same rules as the API.
41
42
 
42
43
  Requests have two types. Clients use `*Input`, where fields with a default are optional. The backend uses `*Body`, which is the result after validation. List queries come from the URL as strings, so they have no `*Input`: use `Partial<PaginationQuery>` or `Partial<AuditLogQuery>`.
43
44
 
45
+ ## Version 0.5.0 (breaking)
46
+
47
+ - `ROLES` is now `ADMIN`, `COACH` and `CLIENT`: `CUSTOMER` is renamed to `CLIENT`. The backend migrates stored roles in step.
48
+ - `FEATURE_FLAG_RULE_TYPES` renames `customer` to `client`, and `createRuleSchema` accepts `ruleType: 'client'`.
49
+ - New `/client`: `clientSignupSchema` (`fullName`, `email`, `password`, optional detected `timezone`), `clientLoginSchema` (body transport by default, for the mobile app), `clientProfileSchema` and `clientLoginResponseSchema`.
50
+ - The one-time code and recovery schemas (`otpEmailSchema`, `verifyOtpSchema`, `resetPasswordSchema`, `otpDispatchResponseSchema`, `signupVerifiedResponseSchema`, `resetTokenResponseSchema`) now live in `/auth`. `/coach` and `/client` re-export them, so existing imports keep working.
51
+
52
+ Consumers install `^0.5.0` explicitly, and deploy the backend first.
53
+
44
54
  ## Version 0.4.0
45
55
 
46
56
  Communication and runtime settings. Additive; consumers install `^0.4.0` explicitly.
@@ -45,7 +45,7 @@ export declare const setRoleSchema: z.ZodObject<{
45
45
  role: z.ZodEnum<{
46
46
  ADMIN: "ADMIN";
47
47
  COACH: "COACH";
48
- CUSTOMER: "CUSTOMER";
48
+ CLIENT: "CLIENT";
49
49
  }>;
50
50
  }, z.core.$strict>;
51
51
  export type SetRoleInput = z.input<typeof setRoleSchema>;
@@ -100,7 +100,7 @@ export declare const accountResponseSchema: z.ZodObject<{
100
100
  role: z.ZodEnum<{
101
101
  ADMIN: "ADMIN";
102
102
  COACH: "COACH";
103
- CUSTOMER: "CUSTOMER";
103
+ CLIENT: "CLIENT";
104
104
  }>;
105
105
  roles: z.ZodArray<z.ZodString>;
106
106
  permissions: z.ZodArray<z.ZodString>;
@@ -125,7 +125,7 @@ export declare const loginResponseSchema: z.ZodObject<{
125
125
  role: z.ZodEnum<{
126
126
  ADMIN: "ADMIN";
127
127
  COACH: "COACH";
128
- CUSTOMER: "CUSTOMER";
128
+ CLIENT: "CLIENT";
129
129
  }>;
130
130
  roles: z.ZodArray<z.ZodString>;
131
131
  permissions: z.ZodArray<z.ZodString>;
@@ -162,7 +162,7 @@ export declare const adminAccountResponseSchema: z.ZodObject<{
162
162
  role: z.ZodEnum<{
163
163
  ADMIN: "ADMIN";
164
164
  COACH: "COACH";
165
- CUSTOMER: "CUSTOMER";
165
+ CLIENT: "CLIENT";
166
166
  }>;
167
167
  status: z.ZodEnum<{
168
168
  pending_verification: "pending_verification";
@@ -1 +1,2 @@
1
1
  export * from './auth.dto.js';
2
+ export * from './otp.dto.js';
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./auth.dto.js"), exports);
18
+ __exportStar(require("./otp.dto.js"), exports);
@@ -0,0 +1,45 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * One-time code and password recovery shapes shared by every role's sign-up
4
+ * and recovery routes. `/coach` and `/client` re-export them.
5
+ */
6
+ /** Used by both resend endpoints and by forgot-password. */
7
+ export declare const otpEmailSchema: z.ZodObject<{
8
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
9
+ }, z.core.$strict>;
10
+ export type OtpEmailInput = z.input<typeof otpEmailSchema>;
11
+ export type OtpEmailBody = z.output<typeof otpEmailSchema>;
12
+ export declare const verifyOtpSchema: z.ZodObject<{
13
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
14
+ code: z.ZodString;
15
+ }, z.core.$strict>;
16
+ export type VerifyOtpInput = z.input<typeof verifyOtpSchema>;
17
+ export type VerifyOtpBody = z.output<typeof verifyOtpSchema>;
18
+ export declare const resetPasswordSchema: z.ZodObject<{
19
+ resetToken: z.ZodString;
20
+ newPassword: z.ZodString;
21
+ }, z.core.$strict>;
22
+ export type ResetPasswordInput = z.input<typeof resetPasswordSchema>;
23
+ export type ResetPasswordBody = z.output<typeof resetPasswordSchema>;
24
+ /**
25
+ * Says what the client needs to drive the code screen, and nothing about
26
+ * whether the email belongs to an account: the same values are returned either
27
+ * way.
28
+ */
29
+ export declare const otpDispatchResponseSchema: z.ZodObject<{
30
+ message: z.ZodString;
31
+ otpLength: z.ZodNumber;
32
+ expiresInSeconds: z.ZodNumber;
33
+ resendAvailableInSeconds: z.ZodNumber;
34
+ }, z.core.$strip>;
35
+ export type OtpDispatchResponse = z.output<typeof otpDispatchResponseSchema>;
36
+ export declare const signupVerifiedResponseSchema: z.ZodObject<{
37
+ message: z.ZodString;
38
+ }, z.core.$strip>;
39
+ export type SignupVerifiedResponse = z.output<typeof signupVerifiedResponseSchema>;
40
+ /** Issued only after a recovery code is verified. It can reset a password once. */
41
+ export declare const resetTokenResponseSchema: z.ZodObject<{
42
+ resetToken: z.ZodString;
43
+ expiresInSeconds: z.ZodNumber;
44
+ }, z.core.$strip>;
45
+ export type ResetTokenResponse = z.output<typeof resetTokenResponseSchema>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resetTokenResponseSchema = exports.signupVerifiedResponseSchema = exports.otpDispatchResponseSchema = exports.resetPasswordSchema = exports.verifyOtpSchema = exports.otpEmailSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const contact_schema_js_1 = require("../common/contact.schema.js");
6
+ const auth_dto_js_1 = require("./auth.dto.js");
7
+ /**
8
+ * One-time code and password recovery shapes shared by every role's sign-up
9
+ * and recovery routes. `/coach` and `/client` re-export them.
10
+ */
11
+ /** Used by both resend endpoints and by forgot-password. */
12
+ exports.otpEmailSchema = zod_1.z.strictObject({ email: contact_schema_js_1.emailSchema });
13
+ exports.verifyOtpSchema = zod_1.z.strictObject({
14
+ email: contact_schema_js_1.emailSchema,
15
+ code: auth_dto_js_1.otpCodeSchema,
16
+ });
17
+ exports.resetPasswordSchema = zod_1.z.strictObject({
18
+ resetToken: auth_dto_js_1.opaqueTokenSchema,
19
+ newPassword: auth_dto_js_1.newPasswordSchema,
20
+ });
21
+ /**
22
+ * Says what the client needs to drive the code screen, and nothing about
23
+ * whether the email belongs to an account: the same values are returned either
24
+ * way.
25
+ */
26
+ exports.otpDispatchResponseSchema = zod_1.z.object({
27
+ message: zod_1.z.string(),
28
+ otpLength: zod_1.z.number().int(),
29
+ expiresInSeconds: zod_1.z.number().int(),
30
+ resendAvailableInSeconds: zod_1.z.number().int(),
31
+ });
32
+ exports.signupVerifiedResponseSchema = zod_1.z.object({
33
+ message: zod_1.z.string(),
34
+ });
35
+ /** Issued only after a recovery code is verified. It can reset a password once. */
36
+ exports.resetTokenResponseSchema = zod_1.z.object({
37
+ resetToken: zod_1.z.string(),
38
+ expiresInSeconds: zod_1.z.number().int(),
39
+ });
@@ -0,0 +1,81 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Client self sign-up: a name, an email address and a password. The account
4
+ * cannot sign in until the emailed code is verified.
5
+ */
6
+ export declare const clientSignupSchema: z.ZodObject<{
7
+ fullName: z.ZodPipe<z.ZodString, z.ZodString>;
8
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
9
+ password: z.ZodString;
10
+ timezone: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<string | undefined, unknown>>>;
11
+ }, z.core.$strict>;
12
+ export type ClientSignupInput = z.input<typeof clientSignupSchema>;
13
+ export type ClientSignupBody = z.output<typeof clientSignupSchema>;
14
+ /**
15
+ * Clients sign in from the mobile app, so the refresh token comes back in the
16
+ * body by default. A browser sends `tokenTransport: "cookie"` instead, and
17
+ * `rememberMe: false` then makes the cookie end with the browser session.
18
+ */
19
+ export declare const clientLoginSchema: z.ZodObject<{
20
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
21
+ password: z.ZodString;
22
+ deviceName: z.ZodOptional<z.ZodString>;
23
+ tokenTransport: z.ZodDefault<z.ZodEnum<{
24
+ body: "body";
25
+ cookie: "cookie";
26
+ }>>;
27
+ rememberMe: z.ZodDefault<z.ZodBoolean>;
28
+ timezone: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<string | undefined, unknown>>>;
29
+ }, z.core.$strict>;
30
+ export type ClientLoginInput = z.input<typeof clientLoginSchema>;
31
+ export type ClientLoginBody = z.output<typeof clientLoginSchema>;
32
+ export declare const clientProfileSchema: z.ZodObject<{
33
+ id: z.ZodUUID;
34
+ email: z.ZodString;
35
+ fullName: z.ZodNullable<z.ZodString>;
36
+ phone: z.ZodNullable<z.ZodString>;
37
+ role: z.ZodLiteral<"CLIENT">;
38
+ status: z.ZodEnum<{
39
+ pending_verification: "pending_verification";
40
+ active: "active";
41
+ disabled: "disabled";
42
+ }>;
43
+ emailVerifiedAt: z.ZodNullable<z.ZodISODateTime>;
44
+ lastLoginAt: z.ZodNullable<z.ZodISODateTime>;
45
+ createdAt: z.ZodISODateTime;
46
+ timezone: z.ZodString;
47
+ timezoneSource: z.ZodEnum<{
48
+ AUTO: "AUTO";
49
+ MANUAL: "MANUAL";
50
+ }>;
51
+ }, z.core.$strip>;
52
+ export type ClientProfile = z.output<typeof clientProfileSchema>;
53
+ export declare const clientLoginResponseSchema: z.ZodObject<{
54
+ accessToken: z.ZodString;
55
+ tokenType: z.ZodLiteral<"Bearer">;
56
+ expiresInSeconds: z.ZodNumber;
57
+ refreshToken: z.ZodOptional<z.ZodString>;
58
+ csrfToken: z.ZodOptional<z.ZodString>;
59
+ sessionId: z.ZodUUID;
60
+ client: z.ZodObject<{
61
+ id: z.ZodUUID;
62
+ email: z.ZodString;
63
+ fullName: z.ZodNullable<z.ZodString>;
64
+ phone: z.ZodNullable<z.ZodString>;
65
+ role: z.ZodLiteral<"CLIENT">;
66
+ status: z.ZodEnum<{
67
+ pending_verification: "pending_verification";
68
+ active: "active";
69
+ disabled: "disabled";
70
+ }>;
71
+ emailVerifiedAt: z.ZodNullable<z.ZodISODateTime>;
72
+ lastLoginAt: z.ZodNullable<z.ZodISODateTime>;
73
+ createdAt: z.ZodISODateTime;
74
+ timezone: z.ZodString;
75
+ timezoneSource: z.ZodEnum<{
76
+ AUTO: "AUTO";
77
+ MANUAL: "MANUAL";
78
+ }>;
79
+ }, z.core.$strip>;
80
+ }, z.core.$strip>;
81
+ export type ClientLoginResponse = z.output<typeof clientLoginResponseSchema>;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clientLoginResponseSchema = exports.clientProfileSchema = exports.clientLoginSchema = exports.clientSignupSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const auth_dto_js_1 = require("../auth/auth.dto.js");
6
+ const contact_schema_js_1 = require("../common/contact.schema.js");
7
+ const date_time_schema_js_1 = require("../common/date-time.schema.js");
8
+ const safe_text_schema_js_1 = require("../common/safe-text.schema.js");
9
+ const index_js_1 = require("../enums/index.js");
10
+ /**
11
+ * Client self sign-up: a name, an email address and a password. The account
12
+ * cannot sign in until the emailed code is verified.
13
+ */
14
+ exports.clientSignupSchema = zod_1.z.strictObject({
15
+ fullName: (0, safe_text_schema_js_1.safeTextSchema)(100).pipe(zod_1.z.string().min(2, { error: 'Enter your full name' })),
16
+ email: contact_schema_js_1.emailSchema,
17
+ password: auth_dto_js_1.newPasswordSchema,
18
+ /** The device's time zone. Missing or unusable becomes UTC on the server. */
19
+ timezone: date_time_schema_js_1.detectedTimezoneSchema,
20
+ });
21
+ /**
22
+ * Clients sign in from the mobile app, so the refresh token comes back in the
23
+ * body by default. A browser sends `tokenTransport: "cookie"` instead, and
24
+ * `rememberMe: false` then makes the cookie end with the browser session.
25
+ */
26
+ exports.clientLoginSchema = auth_dto_js_1.loginSchema.extend({
27
+ rememberMe: zod_1.z.boolean().default(true),
28
+ /**
29
+ * The device's time zone. It replaces the saved one only while the client's
30
+ * preference is `AUTO`; a manual choice is never overwritten.
31
+ */
32
+ timezone: date_time_schema_js_1.detectedTimezoneSchema,
33
+ });
34
+ exports.clientProfileSchema = zod_1.z
35
+ .object({
36
+ id: zod_1.z.uuid(),
37
+ email: zod_1.z.string(),
38
+ fullName: zod_1.z.string().nullable(),
39
+ phone: zod_1.z.string().nullable(),
40
+ role: zod_1.z.literal('CLIENT'),
41
+ status: zod_1.z.enum(index_js_1.ACCOUNT_STATUSES),
42
+ emailVerifiedAt: date_time_schema_js_1.utcTimestampSchema.nullable(),
43
+ lastLoginAt: date_time_schema_js_1.utcTimestampSchema.nullable(),
44
+ createdAt: date_time_schema_js_1.utcTimestampSchema,
45
+ })
46
+ .extend(auth_dto_js_1.timezonePreferenceSchema.shape);
47
+ exports.clientLoginResponseSchema = auth_dto_js_1.tokenResponseSchema.extend({
48
+ client: exports.clientProfileSchema,
49
+ });
@@ -0,0 +1,2 @@
1
+ export * from '../auth/otp.dto.js';
2
+ export * from './client-auth.dto.js';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("../auth/otp.dto.js"), exports);
18
+ __exportStar(require("./client-auth.dto.js"), exports);
@@ -8,18 +8,6 @@ export declare const coachSignupSchema: z.ZodObject<{
8
8
  }, z.core.$strict>;
9
9
  export type CoachSignupInput = z.input<typeof coachSignupSchema>;
10
10
  export type CoachSignupBody = z.output<typeof coachSignupSchema>;
11
- /** Used by both resend endpoints and by forgot-password. */
12
- export declare const otpEmailSchema: z.ZodObject<{
13
- email: z.ZodPipe<z.ZodString, z.ZodEmail>;
14
- }, z.core.$strict>;
15
- export type OtpEmailInput = z.input<typeof otpEmailSchema>;
16
- export type OtpEmailBody = z.output<typeof otpEmailSchema>;
17
- export declare const verifyOtpSchema: z.ZodObject<{
18
- email: z.ZodPipe<z.ZodString, z.ZodEmail>;
19
- code: z.ZodString;
20
- }, z.core.$strict>;
21
- export type VerifyOtpInput = z.input<typeof verifyOtpSchema>;
22
- export type VerifyOtpBody = z.output<typeof verifyOtpSchema>;
23
11
  /**
24
12
  * Coaches sign in from the browser, so the refresh token always travels in an
25
13
  * HttpOnly cookie. `rememberMe: false` makes that cookie end with the browser
@@ -34,34 +22,6 @@ export declare const coachLoginSchema: z.ZodObject<{
34
22
  }, z.core.$strict>;
35
23
  export type CoachLoginInput = z.input<typeof coachLoginSchema>;
36
24
  export type CoachLoginBody = z.output<typeof coachLoginSchema>;
37
- export declare const resetPasswordSchema: z.ZodObject<{
38
- resetToken: z.ZodString;
39
- newPassword: z.ZodString;
40
- }, z.core.$strict>;
41
- export type ResetPasswordInput = z.input<typeof resetPasswordSchema>;
42
- export type ResetPasswordBody = z.output<typeof resetPasswordSchema>;
43
- /**
44
- * Says what the client needs to drive the code screen, and nothing about
45
- * whether the email belongs to an account: the same values are returned either
46
- * way.
47
- */
48
- export declare const otpDispatchResponseSchema: z.ZodObject<{
49
- message: z.ZodString;
50
- otpLength: z.ZodNumber;
51
- expiresInSeconds: z.ZodNumber;
52
- resendAvailableInSeconds: z.ZodNumber;
53
- }, z.core.$strip>;
54
- export type OtpDispatchResponse = z.output<typeof otpDispatchResponseSchema>;
55
- export declare const signupVerifiedResponseSchema: z.ZodObject<{
56
- message: z.ZodString;
57
- }, z.core.$strip>;
58
- export type SignupVerifiedResponse = z.output<typeof signupVerifiedResponseSchema>;
59
- /** Issued only after a recovery code is verified. It can reset a password once. */
60
- export declare const resetTokenResponseSchema: z.ZodObject<{
61
- resetToken: z.ZodString;
62
- expiresInSeconds: z.ZodNumber;
63
- }, z.core.$strip>;
64
- export type ResetTokenResponse = z.output<typeof resetTokenResponseSchema>;
65
25
  export declare const coachProfileSchema: z.ZodObject<{
66
26
  id: z.ZodUUID;
67
27
  email: z.ZodString;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.coachLoginResponseSchema = exports.coachProfileSchema = exports.resetTokenResponseSchema = exports.signupVerifiedResponseSchema = exports.otpDispatchResponseSchema = exports.resetPasswordSchema = exports.coachLoginSchema = exports.verifyOtpSchema = exports.otpEmailSchema = exports.coachSignupSchema = void 0;
3
+ exports.coachLoginResponseSchema = exports.coachProfileSchema = exports.coachLoginSchema = exports.coachSignupSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const auth_dto_js_1 = require("../auth/auth.dto.js");
6
6
  const contact_schema_js_1 = require("../common/contact.schema.js");
@@ -15,12 +15,6 @@ exports.coachSignupSchema = zod_1.z.strictObject({
15
15
  /** The browser's time zone. Missing or unusable becomes UTC on the server. */
16
16
  timezone: date_time_schema_js_1.detectedTimezoneSchema,
17
17
  });
18
- /** Used by both resend endpoints and by forgot-password. */
19
- exports.otpEmailSchema = zod_1.z.strictObject({ email: contact_schema_js_1.emailSchema });
20
- exports.verifyOtpSchema = zod_1.z.strictObject({
21
- email: contact_schema_js_1.emailSchema,
22
- code: auth_dto_js_1.otpCodeSchema,
23
- });
24
18
  /**
25
19
  * Coaches sign in from the browser, so the refresh token always travels in an
26
20
  * HttpOnly cookie. `rememberMe: false` makes that cookie end with the browser
@@ -36,29 +30,6 @@ exports.coachLoginSchema = auth_dto_js_1.loginSchema
36
30
  */
37
31
  timezone: date_time_schema_js_1.detectedTimezoneSchema,
38
32
  });
39
- exports.resetPasswordSchema = zod_1.z.strictObject({
40
- resetToken: auth_dto_js_1.opaqueTokenSchema,
41
- newPassword: auth_dto_js_1.newPasswordSchema,
42
- });
43
- /**
44
- * Says what the client needs to drive the code screen, and nothing about
45
- * whether the email belongs to an account: the same values are returned either
46
- * way.
47
- */
48
- exports.otpDispatchResponseSchema = zod_1.z.object({
49
- message: zod_1.z.string(),
50
- otpLength: zod_1.z.number().int(),
51
- expiresInSeconds: zod_1.z.number().int(),
52
- resendAvailableInSeconds: zod_1.z.number().int(),
53
- });
54
- exports.signupVerifiedResponseSchema = zod_1.z.object({
55
- message: zod_1.z.string(),
56
- });
57
- /** Issued only after a recovery code is verified. It can reset a password once. */
58
- exports.resetTokenResponseSchema = zod_1.z.object({
59
- resetToken: zod_1.z.string(),
60
- expiresInSeconds: zod_1.z.number().int(),
61
- });
62
33
  exports.coachProfileSchema = zod_1.z
63
34
  .object({
64
35
  id: zod_1.z.uuid(),
@@ -1 +1,2 @@
1
+ export * from '../auth/otp.dto.js';
1
2
  export * from './coach-auth.dto.js';
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("../auth/otp.dto.js"), exports);
17
18
  __exportStar(require("./coach-auth.dto.js"), exports);
@@ -1,7 +1,7 @@
1
1
  export declare const APP_ENVIRONMENTS: readonly ["development", "staging", "production"];
2
2
  export type AppEnvironment = (typeof APP_ENVIRONMENTS)[number];
3
3
  /** Each user has exactly one role. A new role is added here and nowhere else. */
4
- export declare const ROLES: readonly ["ADMIN", "COACH", "CUSTOMER"];
4
+ export declare const ROLES: readonly ["ADMIN", "COACH", "CLIENT"];
5
5
  export type Role = (typeof ROLES)[number];
6
6
  /**
7
7
  * `pending_verification` is a self-registered user who has not yet proved they
@@ -23,7 +23,7 @@ export declare const TOKEN_TRANSPORTS: readonly ["body", "cookie"];
23
23
  export type TokenTransport = (typeof TOKEN_TRANSPORTS)[number];
24
24
  export declare const AUDIT_OUTCOMES: readonly ["success", "failure"];
25
25
  export type AuditOutcome = (typeof AUDIT_OUTCOMES)[number];
26
- export declare const FEATURE_FLAG_RULE_TYPES: readonly ["user", "customer", "trainer", "role"];
26
+ export declare const FEATURE_FLAG_RULE_TYPES: readonly ["user", "client", "trainer", "role"];
27
27
  export type FeatureFlagRuleType = (typeof FEATURE_FLAG_RULE_TYPES)[number];
28
28
  /**
29
29
  * The ways a message can reach someone. WhatsApp and push are added here when
@@ -9,7 +9,7 @@ exports.APP_ENVIRONMENTS = [
9
9
  'production',
10
10
  ];
11
11
  /** Each user has exactly one role. A new role is added here and nowhere else. */
12
- exports.ROLES = ['ADMIN', 'COACH', 'CUSTOMER'];
12
+ exports.ROLES = ['ADMIN', 'COACH', 'CLIENT'];
13
13
  /**
14
14
  * `pending_verification` is a self-registered user who has not yet proved they
15
15
  * own their email address. Such a user cannot sign in.
@@ -31,7 +31,7 @@ exports.TOKEN_TRANSPORTS = ['body', 'cookie'];
31
31
  exports.AUDIT_OUTCOMES = ['success', 'failure'];
32
32
  exports.FEATURE_FLAG_RULE_TYPES = [
33
33
  'user',
34
- 'customer',
34
+ 'client',
35
35
  'trainer',
36
36
  'role',
37
37
  ];
@@ -31,7 +31,7 @@ export declare const createRuleSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
31
31
  ruleValue: z.ZodPipe<z.ZodString, z.ZodUUID>;
32
32
  enabled: z.ZodDefault<z.ZodBoolean>;
33
33
  }, z.core.$strict>, z.ZodObject<{
34
- ruleType: z.ZodLiteral<"customer">;
34
+ ruleType: z.ZodLiteral<"client">;
35
35
  ruleValue: z.ZodPipe<z.ZodString, z.ZodUUID>;
36
36
  enabled: z.ZodDefault<z.ZodBoolean>;
37
37
  }, z.core.$strict>, z.ZodObject<{
@@ -43,7 +43,7 @@ export declare const createRuleSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
43
43
  ruleValue: z.ZodEnum<{
44
44
  ADMIN: "ADMIN";
45
45
  COACH: "COACH";
46
- CUSTOMER: "CUSTOMER";
46
+ CLIENT: "CLIENT";
47
47
  }>;
48
48
  enabled: z.ZodDefault<z.ZodBoolean>;
49
49
  }, z.core.$strict>], "ruleType">;
@@ -68,7 +68,7 @@ export declare const ruleResponseSchema: z.ZodObject<{
68
68
  id: z.ZodUUID;
69
69
  ruleType: z.ZodEnum<{
70
70
  user: "user";
71
- customer: "customer";
71
+ client: "client";
72
72
  trainer: "trainer";
73
73
  role: "role";
74
74
  }>;
@@ -101,7 +101,7 @@ export declare const flagResponseSchema: z.ZodObject<{
101
101
  id: z.ZodUUID;
102
102
  ruleType: z.ZodEnum<{
103
103
  user: "user";
104
- customer: "customer";
104
+ client: "client";
105
105
  trainer: "trainer";
106
106
  role: "role";
107
107
  }>;
@@ -65,7 +65,7 @@ exports.createRuleSchema = zod_1.z.discriminatedUnion('ruleType', [
65
65
  enabled: zod_1.z.boolean().default(true),
66
66
  }),
67
67
  zod_1.z.strictObject({
68
- ruleType: zod_1.z.literal('customer'),
68
+ ruleType: zod_1.z.literal('client'),
69
69
  ruleValue: accountIdSchema,
70
70
  enabled: zod_1.z.boolean().default(true),
71
71
  }),
@@ -45,7 +45,7 @@ export declare const setRoleSchema: z.ZodObject<{
45
45
  role: z.ZodEnum<{
46
46
  ADMIN: "ADMIN";
47
47
  COACH: "COACH";
48
- CUSTOMER: "CUSTOMER";
48
+ CLIENT: "CLIENT";
49
49
  }>;
50
50
  }, z.core.$strict>;
51
51
  export type SetRoleInput = z.input<typeof setRoleSchema>;
@@ -100,7 +100,7 @@ export declare const accountResponseSchema: z.ZodObject<{
100
100
  role: z.ZodEnum<{
101
101
  ADMIN: "ADMIN";
102
102
  COACH: "COACH";
103
- CUSTOMER: "CUSTOMER";
103
+ CLIENT: "CLIENT";
104
104
  }>;
105
105
  roles: z.ZodArray<z.ZodString>;
106
106
  permissions: z.ZodArray<z.ZodString>;
@@ -125,7 +125,7 @@ export declare const loginResponseSchema: z.ZodObject<{
125
125
  role: z.ZodEnum<{
126
126
  ADMIN: "ADMIN";
127
127
  COACH: "COACH";
128
- CUSTOMER: "CUSTOMER";
128
+ CLIENT: "CLIENT";
129
129
  }>;
130
130
  roles: z.ZodArray<z.ZodString>;
131
131
  permissions: z.ZodArray<z.ZodString>;
@@ -162,7 +162,7 @@ export declare const adminAccountResponseSchema: z.ZodObject<{
162
162
  role: z.ZodEnum<{
163
163
  ADMIN: "ADMIN";
164
164
  COACH: "COACH";
165
- CUSTOMER: "CUSTOMER";
165
+ CLIENT: "CLIENT";
166
166
  }>;
167
167
  status: z.ZodEnum<{
168
168
  pending_verification: "pending_verification";
@@ -1 +1,2 @@
1
1
  export * from './auth.dto.js';
2
+ export * from './otp.dto.js';
@@ -1 +1,2 @@
1
1
  export * from './auth.dto.js';
2
+ export * from './otp.dto.js';
@@ -0,0 +1,45 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * One-time code and password recovery shapes shared by every role's sign-up
4
+ * and recovery routes. `/coach` and `/client` re-export them.
5
+ */
6
+ /** Used by both resend endpoints and by forgot-password. */
7
+ export declare const otpEmailSchema: z.ZodObject<{
8
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
9
+ }, z.core.$strict>;
10
+ export type OtpEmailInput = z.input<typeof otpEmailSchema>;
11
+ export type OtpEmailBody = z.output<typeof otpEmailSchema>;
12
+ export declare const verifyOtpSchema: z.ZodObject<{
13
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
14
+ code: z.ZodString;
15
+ }, z.core.$strict>;
16
+ export type VerifyOtpInput = z.input<typeof verifyOtpSchema>;
17
+ export type VerifyOtpBody = z.output<typeof verifyOtpSchema>;
18
+ export declare const resetPasswordSchema: z.ZodObject<{
19
+ resetToken: z.ZodString;
20
+ newPassword: z.ZodString;
21
+ }, z.core.$strict>;
22
+ export type ResetPasswordInput = z.input<typeof resetPasswordSchema>;
23
+ export type ResetPasswordBody = z.output<typeof resetPasswordSchema>;
24
+ /**
25
+ * Says what the client needs to drive the code screen, and nothing about
26
+ * whether the email belongs to an account: the same values are returned either
27
+ * way.
28
+ */
29
+ export declare const otpDispatchResponseSchema: z.ZodObject<{
30
+ message: z.ZodString;
31
+ otpLength: z.ZodNumber;
32
+ expiresInSeconds: z.ZodNumber;
33
+ resendAvailableInSeconds: z.ZodNumber;
34
+ }, z.core.$strip>;
35
+ export type OtpDispatchResponse = z.output<typeof otpDispatchResponseSchema>;
36
+ export declare const signupVerifiedResponseSchema: z.ZodObject<{
37
+ message: z.ZodString;
38
+ }, z.core.$strip>;
39
+ export type SignupVerifiedResponse = z.output<typeof signupVerifiedResponseSchema>;
40
+ /** Issued only after a recovery code is verified. It can reset a password once. */
41
+ export declare const resetTokenResponseSchema: z.ZodObject<{
42
+ resetToken: z.ZodString;
43
+ expiresInSeconds: z.ZodNumber;
44
+ }, z.core.$strip>;
45
+ export type ResetTokenResponse = z.output<typeof resetTokenResponseSchema>;
@@ -0,0 +1,36 @@
1
+ import { z } from 'zod';
2
+ import { emailSchema } from '../common/contact.schema.js';
3
+ import { newPasswordSchema, opaqueTokenSchema, otpCodeSchema, } from './auth.dto.js';
4
+ /**
5
+ * One-time code and password recovery shapes shared by every role's sign-up
6
+ * and recovery routes. `/coach` and `/client` re-export them.
7
+ */
8
+ /** Used by both resend endpoints and by forgot-password. */
9
+ export const otpEmailSchema = z.strictObject({ email: emailSchema });
10
+ export const verifyOtpSchema = z.strictObject({
11
+ email: emailSchema,
12
+ code: otpCodeSchema,
13
+ });
14
+ export const resetPasswordSchema = z.strictObject({
15
+ resetToken: opaqueTokenSchema,
16
+ newPassword: newPasswordSchema,
17
+ });
18
+ /**
19
+ * Says what the client needs to drive the code screen, and nothing about
20
+ * whether the email belongs to an account: the same values are returned either
21
+ * way.
22
+ */
23
+ export const otpDispatchResponseSchema = z.object({
24
+ message: z.string(),
25
+ otpLength: z.number().int(),
26
+ expiresInSeconds: z.number().int(),
27
+ resendAvailableInSeconds: z.number().int(),
28
+ });
29
+ export const signupVerifiedResponseSchema = z.object({
30
+ message: z.string(),
31
+ });
32
+ /** Issued only after a recovery code is verified. It can reset a password once. */
33
+ export const resetTokenResponseSchema = z.object({
34
+ resetToken: z.string(),
35
+ expiresInSeconds: z.number().int(),
36
+ });
@@ -0,0 +1,81 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Client self sign-up: a name, an email address and a password. The account
4
+ * cannot sign in until the emailed code is verified.
5
+ */
6
+ export declare const clientSignupSchema: z.ZodObject<{
7
+ fullName: z.ZodPipe<z.ZodString, z.ZodString>;
8
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
9
+ password: z.ZodString;
10
+ timezone: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<string | undefined, unknown>>>;
11
+ }, z.core.$strict>;
12
+ export type ClientSignupInput = z.input<typeof clientSignupSchema>;
13
+ export type ClientSignupBody = z.output<typeof clientSignupSchema>;
14
+ /**
15
+ * Clients sign in from the mobile app, so the refresh token comes back in the
16
+ * body by default. A browser sends `tokenTransport: "cookie"` instead, and
17
+ * `rememberMe: false` then makes the cookie end with the browser session.
18
+ */
19
+ export declare const clientLoginSchema: z.ZodObject<{
20
+ email: z.ZodPipe<z.ZodString, z.ZodEmail>;
21
+ password: z.ZodString;
22
+ deviceName: z.ZodOptional<z.ZodString>;
23
+ tokenTransport: z.ZodDefault<z.ZodEnum<{
24
+ body: "body";
25
+ cookie: "cookie";
26
+ }>>;
27
+ rememberMe: z.ZodDefault<z.ZodBoolean>;
28
+ timezone: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<string | undefined, unknown>>>;
29
+ }, z.core.$strict>;
30
+ export type ClientLoginInput = z.input<typeof clientLoginSchema>;
31
+ export type ClientLoginBody = z.output<typeof clientLoginSchema>;
32
+ export declare const clientProfileSchema: z.ZodObject<{
33
+ id: z.ZodUUID;
34
+ email: z.ZodString;
35
+ fullName: z.ZodNullable<z.ZodString>;
36
+ phone: z.ZodNullable<z.ZodString>;
37
+ role: z.ZodLiteral<"CLIENT">;
38
+ status: z.ZodEnum<{
39
+ pending_verification: "pending_verification";
40
+ active: "active";
41
+ disabled: "disabled";
42
+ }>;
43
+ emailVerifiedAt: z.ZodNullable<z.ZodISODateTime>;
44
+ lastLoginAt: z.ZodNullable<z.ZodISODateTime>;
45
+ createdAt: z.ZodISODateTime;
46
+ timezone: z.ZodString;
47
+ timezoneSource: z.ZodEnum<{
48
+ AUTO: "AUTO";
49
+ MANUAL: "MANUAL";
50
+ }>;
51
+ }, z.core.$strip>;
52
+ export type ClientProfile = z.output<typeof clientProfileSchema>;
53
+ export declare const clientLoginResponseSchema: z.ZodObject<{
54
+ accessToken: z.ZodString;
55
+ tokenType: z.ZodLiteral<"Bearer">;
56
+ expiresInSeconds: z.ZodNumber;
57
+ refreshToken: z.ZodOptional<z.ZodString>;
58
+ csrfToken: z.ZodOptional<z.ZodString>;
59
+ sessionId: z.ZodUUID;
60
+ client: z.ZodObject<{
61
+ id: z.ZodUUID;
62
+ email: z.ZodString;
63
+ fullName: z.ZodNullable<z.ZodString>;
64
+ phone: z.ZodNullable<z.ZodString>;
65
+ role: z.ZodLiteral<"CLIENT">;
66
+ status: z.ZodEnum<{
67
+ pending_verification: "pending_verification";
68
+ active: "active";
69
+ disabled: "disabled";
70
+ }>;
71
+ emailVerifiedAt: z.ZodNullable<z.ZodISODateTime>;
72
+ lastLoginAt: z.ZodNullable<z.ZodISODateTime>;
73
+ createdAt: z.ZodISODateTime;
74
+ timezone: z.ZodString;
75
+ timezoneSource: z.ZodEnum<{
76
+ AUTO: "AUTO";
77
+ MANUAL: "MANUAL";
78
+ }>;
79
+ }, z.core.$strip>;
80
+ }, z.core.$strip>;
81
+ export type ClientLoginResponse = z.output<typeof clientLoginResponseSchema>;
@@ -0,0 +1,46 @@
1
+ import { z } from 'zod';
2
+ import { loginSchema, newPasswordSchema, timezonePreferenceSchema, tokenResponseSchema, } from '../auth/auth.dto.js';
3
+ import { emailSchema } from '../common/contact.schema.js';
4
+ import { detectedTimezoneSchema, utcTimestampSchema, } from '../common/date-time.schema.js';
5
+ import { safeTextSchema } from '../common/safe-text.schema.js';
6
+ import { ACCOUNT_STATUSES } from '../enums/index.js';
7
+ /**
8
+ * Client self sign-up: a name, an email address and a password. The account
9
+ * cannot sign in until the emailed code is verified.
10
+ */
11
+ export const clientSignupSchema = z.strictObject({
12
+ fullName: safeTextSchema(100).pipe(z.string().min(2, { error: 'Enter your full name' })),
13
+ email: emailSchema,
14
+ password: newPasswordSchema,
15
+ /** The device's time zone. Missing or unusable becomes UTC on the server. */
16
+ timezone: detectedTimezoneSchema,
17
+ });
18
+ /**
19
+ * Clients sign in from the mobile app, so the refresh token comes back in the
20
+ * body by default. A browser sends `tokenTransport: "cookie"` instead, and
21
+ * `rememberMe: false` then makes the cookie end with the browser session.
22
+ */
23
+ export const clientLoginSchema = loginSchema.extend({
24
+ rememberMe: z.boolean().default(true),
25
+ /**
26
+ * The device's time zone. It replaces the saved one only while the client's
27
+ * preference is `AUTO`; a manual choice is never overwritten.
28
+ */
29
+ timezone: detectedTimezoneSchema,
30
+ });
31
+ export const clientProfileSchema = z
32
+ .object({
33
+ id: z.uuid(),
34
+ email: z.string(),
35
+ fullName: z.string().nullable(),
36
+ phone: z.string().nullable(),
37
+ role: z.literal('CLIENT'),
38
+ status: z.enum(ACCOUNT_STATUSES),
39
+ emailVerifiedAt: utcTimestampSchema.nullable(),
40
+ lastLoginAt: utcTimestampSchema.nullable(),
41
+ createdAt: utcTimestampSchema,
42
+ })
43
+ .extend(timezonePreferenceSchema.shape);
44
+ export const clientLoginResponseSchema = tokenResponseSchema.extend({
45
+ client: clientProfileSchema,
46
+ });
@@ -0,0 +1,2 @@
1
+ export * from '../auth/otp.dto.js';
2
+ export * from './client-auth.dto.js';
@@ -0,0 +1,2 @@
1
+ export * from '../auth/otp.dto.js';
2
+ export * from './client-auth.dto.js';
@@ -8,18 +8,6 @@ export declare const coachSignupSchema: z.ZodObject<{
8
8
  }, z.core.$strict>;
9
9
  export type CoachSignupInput = z.input<typeof coachSignupSchema>;
10
10
  export type CoachSignupBody = z.output<typeof coachSignupSchema>;
11
- /** Used by both resend endpoints and by forgot-password. */
12
- export declare const otpEmailSchema: z.ZodObject<{
13
- email: z.ZodPipe<z.ZodString, z.ZodEmail>;
14
- }, z.core.$strict>;
15
- export type OtpEmailInput = z.input<typeof otpEmailSchema>;
16
- export type OtpEmailBody = z.output<typeof otpEmailSchema>;
17
- export declare const verifyOtpSchema: z.ZodObject<{
18
- email: z.ZodPipe<z.ZodString, z.ZodEmail>;
19
- code: z.ZodString;
20
- }, z.core.$strict>;
21
- export type VerifyOtpInput = z.input<typeof verifyOtpSchema>;
22
- export type VerifyOtpBody = z.output<typeof verifyOtpSchema>;
23
11
  /**
24
12
  * Coaches sign in from the browser, so the refresh token always travels in an
25
13
  * HttpOnly cookie. `rememberMe: false` makes that cookie end with the browser
@@ -34,34 +22,6 @@ export declare const coachLoginSchema: z.ZodObject<{
34
22
  }, z.core.$strict>;
35
23
  export type CoachLoginInput = z.input<typeof coachLoginSchema>;
36
24
  export type CoachLoginBody = z.output<typeof coachLoginSchema>;
37
- export declare const resetPasswordSchema: z.ZodObject<{
38
- resetToken: z.ZodString;
39
- newPassword: z.ZodString;
40
- }, z.core.$strict>;
41
- export type ResetPasswordInput = z.input<typeof resetPasswordSchema>;
42
- export type ResetPasswordBody = z.output<typeof resetPasswordSchema>;
43
- /**
44
- * Says what the client needs to drive the code screen, and nothing about
45
- * whether the email belongs to an account: the same values are returned either
46
- * way.
47
- */
48
- export declare const otpDispatchResponseSchema: z.ZodObject<{
49
- message: z.ZodString;
50
- otpLength: z.ZodNumber;
51
- expiresInSeconds: z.ZodNumber;
52
- resendAvailableInSeconds: z.ZodNumber;
53
- }, z.core.$strip>;
54
- export type OtpDispatchResponse = z.output<typeof otpDispatchResponseSchema>;
55
- export declare const signupVerifiedResponseSchema: z.ZodObject<{
56
- message: z.ZodString;
57
- }, z.core.$strip>;
58
- export type SignupVerifiedResponse = z.output<typeof signupVerifiedResponseSchema>;
59
- /** Issued only after a recovery code is verified. It can reset a password once. */
60
- export declare const resetTokenResponseSchema: z.ZodObject<{
61
- resetToken: z.ZodString;
62
- expiresInSeconds: z.ZodNumber;
63
- }, z.core.$strip>;
64
- export type ResetTokenResponse = z.output<typeof resetTokenResponseSchema>;
65
25
  export declare const coachProfileSchema: z.ZodObject<{
66
26
  id: z.ZodUUID;
67
27
  email: z.ZodString;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { loginSchema, newPasswordSchema, opaqueTokenSchema, otpCodeSchema, timezonePreferenceSchema, tokenResponseSchema, } from '../auth/auth.dto.js';
2
+ import { loginSchema, newPasswordSchema, timezonePreferenceSchema, tokenResponseSchema, } from '../auth/auth.dto.js';
3
3
  import { emailSchema, phoneSchema } from '../common/contact.schema.js';
4
4
  import { detectedTimezoneSchema, utcTimestampSchema, } from '../common/date-time.schema.js';
5
5
  import { safeTextSchema } from '../common/safe-text.schema.js';
@@ -12,12 +12,6 @@ export const coachSignupSchema = z.strictObject({
12
12
  /** The browser's time zone. Missing or unusable becomes UTC on the server. */
13
13
  timezone: detectedTimezoneSchema,
14
14
  });
15
- /** Used by both resend endpoints and by forgot-password. */
16
- export const otpEmailSchema = z.strictObject({ email: emailSchema });
17
- export const verifyOtpSchema = z.strictObject({
18
- email: emailSchema,
19
- code: otpCodeSchema,
20
- });
21
15
  /**
22
16
  * Coaches sign in from the browser, so the refresh token always travels in an
23
17
  * HttpOnly cookie. `rememberMe: false` makes that cookie end with the browser
@@ -33,29 +27,6 @@ export const coachLoginSchema = loginSchema
33
27
  */
34
28
  timezone: detectedTimezoneSchema,
35
29
  });
36
- export const resetPasswordSchema = z.strictObject({
37
- resetToken: opaqueTokenSchema,
38
- newPassword: newPasswordSchema,
39
- });
40
- /**
41
- * Says what the client needs to drive the code screen, and nothing about
42
- * whether the email belongs to an account: the same values are returned either
43
- * way.
44
- */
45
- export const otpDispatchResponseSchema = z.object({
46
- message: z.string(),
47
- otpLength: z.number().int(),
48
- expiresInSeconds: z.number().int(),
49
- resendAvailableInSeconds: z.number().int(),
50
- });
51
- export const signupVerifiedResponseSchema = z.object({
52
- message: z.string(),
53
- });
54
- /** Issued only after a recovery code is verified. It can reset a password once. */
55
- export const resetTokenResponseSchema = z.object({
56
- resetToken: z.string(),
57
- expiresInSeconds: z.number().int(),
58
- });
59
30
  export const coachProfileSchema = z
60
31
  .object({
61
32
  id: z.uuid(),
@@ -1 +1,2 @@
1
+ export * from '../auth/otp.dto.js';
1
2
  export * from './coach-auth.dto.js';
@@ -1 +1,2 @@
1
+ export * from '../auth/otp.dto.js';
1
2
  export * from './coach-auth.dto.js';
@@ -1,7 +1,7 @@
1
1
  export declare const APP_ENVIRONMENTS: readonly ["development", "staging", "production"];
2
2
  export type AppEnvironment = (typeof APP_ENVIRONMENTS)[number];
3
3
  /** Each user has exactly one role. A new role is added here and nowhere else. */
4
- export declare const ROLES: readonly ["ADMIN", "COACH", "CUSTOMER"];
4
+ export declare const ROLES: readonly ["ADMIN", "COACH", "CLIENT"];
5
5
  export type Role = (typeof ROLES)[number];
6
6
  /**
7
7
  * `pending_verification` is a self-registered user who has not yet proved they
@@ -23,7 +23,7 @@ export declare const TOKEN_TRANSPORTS: readonly ["body", "cookie"];
23
23
  export type TokenTransport = (typeof TOKEN_TRANSPORTS)[number];
24
24
  export declare const AUDIT_OUTCOMES: readonly ["success", "failure"];
25
25
  export type AuditOutcome = (typeof AUDIT_OUTCOMES)[number];
26
- export declare const FEATURE_FLAG_RULE_TYPES: readonly ["user", "customer", "trainer", "role"];
26
+ export declare const FEATURE_FLAG_RULE_TYPES: readonly ["user", "client", "trainer", "role"];
27
27
  export type FeatureFlagRuleType = (typeof FEATURE_FLAG_RULE_TYPES)[number];
28
28
  /**
29
29
  * The ways a message can reach someone. WhatsApp and push are added here when
@@ -6,7 +6,7 @@ export const APP_ENVIRONMENTS = [
6
6
  'production',
7
7
  ];
8
8
  /** Each user has exactly one role. A new role is added here and nowhere else. */
9
- export const ROLES = ['ADMIN', 'COACH', 'CUSTOMER'];
9
+ export const ROLES = ['ADMIN', 'COACH', 'CLIENT'];
10
10
  /**
11
11
  * `pending_verification` is a self-registered user who has not yet proved they
12
12
  * own their email address. Such a user cannot sign in.
@@ -28,7 +28,7 @@ export const TOKEN_TRANSPORTS = ['body', 'cookie'];
28
28
  export const AUDIT_OUTCOMES = ['success', 'failure'];
29
29
  export const FEATURE_FLAG_RULE_TYPES = [
30
30
  'user',
31
- 'customer',
31
+ 'client',
32
32
  'trainer',
33
33
  'role',
34
34
  ];
@@ -31,7 +31,7 @@ export declare const createRuleSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
31
31
  ruleValue: z.ZodPipe<z.ZodString, z.ZodUUID>;
32
32
  enabled: z.ZodDefault<z.ZodBoolean>;
33
33
  }, z.core.$strict>, z.ZodObject<{
34
- ruleType: z.ZodLiteral<"customer">;
34
+ ruleType: z.ZodLiteral<"client">;
35
35
  ruleValue: z.ZodPipe<z.ZodString, z.ZodUUID>;
36
36
  enabled: z.ZodDefault<z.ZodBoolean>;
37
37
  }, z.core.$strict>, z.ZodObject<{
@@ -43,7 +43,7 @@ export declare const createRuleSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
43
43
  ruleValue: z.ZodEnum<{
44
44
  ADMIN: "ADMIN";
45
45
  COACH: "COACH";
46
- CUSTOMER: "CUSTOMER";
46
+ CLIENT: "CLIENT";
47
47
  }>;
48
48
  enabled: z.ZodDefault<z.ZodBoolean>;
49
49
  }, z.core.$strict>], "ruleType">;
@@ -68,7 +68,7 @@ export declare const ruleResponseSchema: z.ZodObject<{
68
68
  id: z.ZodUUID;
69
69
  ruleType: z.ZodEnum<{
70
70
  user: "user";
71
- customer: "customer";
71
+ client: "client";
72
72
  trainer: "trainer";
73
73
  role: "role";
74
74
  }>;
@@ -101,7 +101,7 @@ export declare const flagResponseSchema: z.ZodObject<{
101
101
  id: z.ZodUUID;
102
102
  ruleType: z.ZodEnum<{
103
103
  user: "user";
104
- customer: "customer";
104
+ client: "client";
105
105
  trainer: "trainer";
106
106
  role: "role";
107
107
  }>;
@@ -62,7 +62,7 @@ export const createRuleSchema = z.discriminatedUnion('ruleType', [
62
62
  enabled: z.boolean().default(true),
63
63
  }),
64
64
  z.strictObject({
65
- ruleType: z.literal('customer'),
65
+ ruleType: z.literal('client'),
66
66
  ruleValue: accountIdSchema,
67
67
  enabled: z.boolean().default(true),
68
68
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tbs-fitness/contract",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "TBS API contract: Zod schemas, DTO types and enums shared by the backend, web and mobile apps",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -43,6 +43,16 @@
43
43
  "default": "./dist/cjs/auth/index.js"
44
44
  }
45
45
  },
46
+ "./client": {
47
+ "import": {
48
+ "types": "./dist/esm/client/index.d.ts",
49
+ "default": "./dist/esm/client/index.js"
50
+ },
51
+ "require": {
52
+ "types": "./dist/cjs/client/index.d.ts",
53
+ "default": "./dist/cjs/client/index.js"
54
+ }
55
+ },
46
56
  "./coach": {
47
57
  "import": {
48
58
  "types": "./dist/esm/coach/index.d.ts",