@tbs-fitness/contract 0.3.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 (56) hide show
  1. package/README.md +21 -0
  2. package/dist/cjs/app-settings/app-settings.dto.d.ts +124 -0
  3. package/dist/cjs/app-settings/app-settings.dto.js +94 -0
  4. package/dist/cjs/app-settings/index.d.ts +1 -0
  5. package/dist/cjs/app-settings/index.js +17 -0
  6. package/dist/cjs/auth/auth.dto.d.ts +4 -4
  7. package/dist/cjs/auth/index.d.ts +1 -0
  8. package/dist/cjs/auth/index.js +1 -0
  9. package/dist/cjs/auth/otp.dto.d.ts +45 -0
  10. package/dist/cjs/auth/otp.dto.js +39 -0
  11. package/dist/cjs/client/client-auth.dto.d.ts +81 -0
  12. package/dist/cjs/client/client-auth.dto.js +49 -0
  13. package/dist/cjs/client/index.d.ts +2 -0
  14. package/dist/cjs/client/index.js +18 -0
  15. package/dist/cjs/coach/coach-auth.dto.d.ts +0 -40
  16. package/dist/cjs/coach/coach-auth.dto.js +1 -30
  17. package/dist/cjs/coach/index.d.ts +1 -0
  18. package/dist/cjs/coach/index.js +1 -0
  19. package/dist/cjs/communication/index.d.ts +2 -0
  20. package/dist/cjs/communication/index.js +18 -0
  21. package/dist/cjs/communication/message-catalogue.d.ts +26 -0
  22. package/dist/cjs/communication/message-catalogue.js +53 -0
  23. package/dist/cjs/communication/template.dto.d.ts +240 -0
  24. package/dist/cjs/communication/template.dto.js +206 -0
  25. package/dist/cjs/enums/index.d.ts +21 -2
  26. package/dist/cjs/enums/index.js +28 -3
  27. package/dist/cjs/feature-flags/feature-flag.dto.d.ts +4 -4
  28. package/dist/cjs/feature-flags/feature-flag.dto.js +1 -1
  29. package/dist/esm/app-settings/app-settings.dto.d.ts +124 -0
  30. package/dist/esm/app-settings/app-settings.dto.js +90 -0
  31. package/dist/esm/app-settings/index.d.ts +1 -0
  32. package/dist/esm/app-settings/index.js +1 -0
  33. package/dist/esm/auth/auth.dto.d.ts +4 -4
  34. package/dist/esm/auth/index.d.ts +1 -0
  35. package/dist/esm/auth/index.js +1 -0
  36. package/dist/esm/auth/otp.dto.d.ts +45 -0
  37. package/dist/esm/auth/otp.dto.js +36 -0
  38. package/dist/esm/client/client-auth.dto.d.ts +81 -0
  39. package/dist/esm/client/client-auth.dto.js +46 -0
  40. package/dist/esm/client/index.d.ts +2 -0
  41. package/dist/esm/client/index.js +2 -0
  42. package/dist/esm/coach/coach-auth.dto.d.ts +0 -40
  43. package/dist/esm/coach/coach-auth.dto.js +1 -30
  44. package/dist/esm/coach/index.d.ts +1 -0
  45. package/dist/esm/coach/index.js +1 -0
  46. package/dist/esm/communication/index.d.ts +2 -0
  47. package/dist/esm/communication/index.js +2 -0
  48. package/dist/esm/communication/message-catalogue.d.ts +26 -0
  49. package/dist/esm/communication/message-catalogue.js +50 -0
  50. package/dist/esm/communication/template.dto.d.ts +240 -0
  51. package/dist/esm/communication/template.dto.js +200 -0
  52. package/dist/esm/enums/index.d.ts +21 -2
  53. package/dist/esm/enums/index.js +27 -2
  54. package/dist/esm/feature-flags/feature-flag.dto.d.ts +4 -4
  55. package/dist/esm/feature-flags/feature-flag.dto.js +1 -1
  56. package/package.json +31 -1
@@ -2,14 +2,14 @@
2
2
  // These values are stored in the database and sent over the API. Renaming or
3
3
  // removing one is a breaking change, so it needs a major version.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.FEATURE_FLAG_RULE_TYPES = exports.AUDIT_OUTCOMES = exports.TOKEN_TRANSPORTS = exports.TIMEZONE_SOURCES = exports.ADMIN_SETTABLE_ACCOUNT_STATUSES = exports.ACCOUNT_STATUSES = exports.ROLES = exports.APP_ENVIRONMENTS = void 0;
5
+ exports.TEMPLATE_STATUSES = exports.DELIVERY_STATUSES = exports.MESSAGE_TYPES = exports.COMMUNICATION_CHANNELS = exports.FEATURE_FLAG_RULE_TYPES = exports.AUDIT_OUTCOMES = exports.TOKEN_TRANSPORTS = exports.TIMEZONE_SOURCES = exports.ADMIN_SETTABLE_ACCOUNT_STATUSES = exports.ACCOUNT_STATUSES = exports.ROLES = exports.APP_ENVIRONMENTS = void 0;
6
6
  exports.APP_ENVIRONMENTS = [
7
7
  'development',
8
8
  'staging',
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,32 @@ 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
  ];
38
+ /**
39
+ * The ways a message can reach someone. WhatsApp and push are added here when
40
+ * their channel modules are built.
41
+ */
42
+ exports.COMMUNICATION_CHANNELS = ['EMAIL', 'SMS'];
43
+ /**
44
+ * Every message the platform sends. Each has a catalogue entry in
45
+ * `@tbs-fitness/contract/communication` saying which channels may carry it and
46
+ * which variables its sender supplies.
47
+ */
48
+ exports.MESSAGE_TYPES = [
49
+ 'auth.otp.signup_verification',
50
+ 'auth.otp.password_reset',
51
+ 'auth.password_reset_link',
52
+ ];
53
+ /** What happened to one message on one channel. */
54
+ exports.DELIVERY_STATUSES = [
55
+ 'sent',
56
+ 'skipped_disabled',
57
+ 'skipped_unreachable',
58
+ 'failed',
59
+ 'failed_missing_variables',
60
+ ];
61
+ /** Only one version of a template per message type and channel is active. */
62
+ exports.TEMPLATE_STATUSES = ['draft', 'active', 'archived'];
@@ -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
  }),
@@ -0,0 +1,124 @@
1
+ import { z } from 'zod';
2
+ import { type MessageType } from '../enums/index.js';
3
+ /**
4
+ * Runtime settings an administrator changes without a deploy. Each key has a
5
+ * value schema here, which both the server and the admin screen use. A key
6
+ * with no saved value uses its default.
7
+ */
8
+ export declare const APP_SETTING_KEYS: readonly ["communication.channels", "communication.messages"];
9
+ export type AppSettingKey = (typeof APP_SETTING_KEYS)[number];
10
+ /** A switch per channel. */
11
+ export declare const channelSwitchesSchema: z.ZodObject<{
12
+ EMAIL: z.ZodBoolean;
13
+ SMS: z.ZodBoolean;
14
+ }, z.core.$strict>;
15
+ export type ChannelSwitches = z.output<typeof channelSwitchesSchema>;
16
+ /**
17
+ * Master switches: a channel switched off here sends nothing, whatever the
18
+ * per-message settings say.
19
+ */
20
+ export declare const communicationChannelsSettingSchema: z.ZodObject<{
21
+ EMAIL: z.ZodBoolean;
22
+ SMS: z.ZodBoolean;
23
+ }, z.core.$strict>;
24
+ /**
25
+ * Per message type and channel. A type missing from a saved value uses its
26
+ * catalogue defaults, so a newly added message type needs no data change.
27
+ */
28
+ export declare const communicationMessagesSettingSchema: z.ZodRecord<z.ZodEnum<{
29
+ "auth.otp.signup_verification": "auth.otp.signup_verification";
30
+ "auth.otp.password_reset": "auth.otp.password_reset";
31
+ "auth.password_reset_link": "auth.password_reset_link";
32
+ }> & z.core.$partial, z.ZodObject<{
33
+ EMAIL: z.ZodBoolean;
34
+ SMS: z.ZodBoolean;
35
+ }, z.core.$strict>>;
36
+ export type CommunicationMessagesSetting = z.output<typeof communicationMessagesSettingSchema>;
37
+ export declare const APP_SETTING_VALUE_SCHEMAS: {
38
+ readonly 'communication.channels': z.ZodObject<{
39
+ EMAIL: z.ZodBoolean;
40
+ SMS: z.ZodBoolean;
41
+ }, z.core.$strict>;
42
+ readonly 'communication.messages': z.ZodRecord<z.ZodEnum<{
43
+ "auth.otp.signup_verification": "auth.otp.signup_verification";
44
+ "auth.otp.password_reset": "auth.otp.password_reset";
45
+ "auth.password_reset_link": "auth.password_reset_link";
46
+ }> & z.core.$partial, z.ZodObject<{
47
+ EMAIL: z.ZodBoolean;
48
+ SMS: z.ZodBoolean;
49
+ }, z.core.$strict>>;
50
+ };
51
+ export interface AppSettingValues {
52
+ 'communication.channels': ChannelSwitches;
53
+ 'communication.messages': CommunicationMessagesSetting;
54
+ }
55
+ /** Every message type, with its catalogue defaults: the effective value with nothing saved. */
56
+ export declare function defaultMessageSettings(): Record<MessageType, ChannelSwitches>;
57
+ export declare const APP_SETTING_DEFAULTS: AppSettingValues;
58
+ export declare const appSettingKeyParamSchema: z.ZodEnum<{
59
+ "communication.channels": "communication.channels";
60
+ "communication.messages": "communication.messages";
61
+ }>;
62
+ export declare const appSettingResponseSchema: z.ZodObject<{
63
+ key: z.ZodEnum<{
64
+ "communication.channels": "communication.channels";
65
+ "communication.messages": "communication.messages";
66
+ }>;
67
+ label: z.ZodString;
68
+ description: z.ZodString;
69
+ value: z.ZodUnknown;
70
+ defaultValue: z.ZodUnknown;
71
+ version: z.ZodNumber;
72
+ updatedBy: z.ZodNullable<z.ZodUUID>;
73
+ updatedAt: z.ZodNullable<z.ZodISODateTime>;
74
+ }, z.core.$strip>;
75
+ export type AppSettingResponse = z.output<typeof appSettingResponseSchema>;
76
+ export declare const appSettingListResponseSchema: z.ZodArray<z.ZodObject<{
77
+ key: z.ZodEnum<{
78
+ "communication.channels": "communication.channels";
79
+ "communication.messages": "communication.messages";
80
+ }>;
81
+ label: z.ZodString;
82
+ description: z.ZodString;
83
+ value: z.ZodUnknown;
84
+ defaultValue: z.ZodUnknown;
85
+ version: z.ZodNumber;
86
+ updatedBy: z.ZodNullable<z.ZodUUID>;
87
+ updatedAt: z.ZodNullable<z.ZodISODateTime>;
88
+ }, z.core.$strip>>;
89
+ /**
90
+ * Replaces a setting's value. `version` must be the one last read, so a
91
+ * change made in between is not silently overwritten. The value is checked
92
+ * against the key's schema on the server.
93
+ */
94
+ export declare const updateAppSettingSchema: z.ZodObject<{
95
+ value: z.ZodUnknown;
96
+ version: z.ZodNumber;
97
+ }, z.core.$strict>;
98
+ export type UpdateAppSettingInput = z.input<typeof updateAppSettingSchema>;
99
+ export type UpdateAppSettingBody = z.output<typeof updateAppSettingSchema>;
100
+ export declare const appSettingHistoryEntrySchema: z.ZodObject<{
101
+ id: z.ZodUUID;
102
+ key: z.ZodEnum<{
103
+ "communication.channels": "communication.channels";
104
+ "communication.messages": "communication.messages";
105
+ }>;
106
+ previousValue: z.ZodUnknown;
107
+ newValue: z.ZodUnknown;
108
+ version: z.ZodNumber;
109
+ actorUserId: z.ZodUUID;
110
+ createdAt: z.ZodISODateTime;
111
+ }, z.core.$strip>;
112
+ export type AppSettingHistoryEntry = z.output<typeof appSettingHistoryEntrySchema>;
113
+ export declare const appSettingHistoryResponseSchema: z.ZodArray<z.ZodObject<{
114
+ id: z.ZodUUID;
115
+ key: z.ZodEnum<{
116
+ "communication.channels": "communication.channels";
117
+ "communication.messages": "communication.messages";
118
+ }>;
119
+ previousValue: z.ZodUnknown;
120
+ newValue: z.ZodUnknown;
121
+ version: z.ZodNumber;
122
+ actorUserId: z.ZodUUID;
123
+ createdAt: z.ZodISODateTime;
124
+ }, z.core.$strip>>;
@@ -0,0 +1,90 @@
1
+ import { z } from 'zod';
2
+ import { utcTimestampSchema } from '../common/date-time.schema.js';
3
+ import { MESSAGE_CATALOGUE } from '../communication/message-catalogue.js';
4
+ import { MESSAGE_TYPES } from '../enums/index.js';
5
+ /**
6
+ * Runtime settings an administrator changes without a deploy. Each key has a
7
+ * value schema here, which both the server and the admin screen use. A key
8
+ * with no saved value uses its default.
9
+ */
10
+ export const APP_SETTING_KEYS = [
11
+ 'communication.channels',
12
+ 'communication.messages',
13
+ ];
14
+ /** A switch per channel. */
15
+ export const channelSwitchesSchema = z.strictObject({
16
+ EMAIL: z.boolean(),
17
+ SMS: z.boolean(),
18
+ });
19
+ /**
20
+ * Master switches: a channel switched off here sends nothing, whatever the
21
+ * per-message settings say.
22
+ */
23
+ export const communicationChannelsSettingSchema = channelSwitchesSchema;
24
+ /**
25
+ * Per message type and channel. A type missing from a saved value uses its
26
+ * catalogue defaults, so a newly added message type needs no data change.
27
+ */
28
+ export const communicationMessagesSettingSchema = z
29
+ .partialRecord(z.enum(MESSAGE_TYPES), channelSwitchesSchema)
30
+ .superRefine((value, ctx) => {
31
+ for (const [type, switches] of Object.entries(value)) {
32
+ const allowed = MESSAGE_CATALOGUE[type].channels;
33
+ for (const [channel, on] of Object.entries(switches ?? {})) {
34
+ if (on && !allowed.includes(channel)) {
35
+ ctx.addIssue({
36
+ code: 'custom',
37
+ path: [type, channel],
38
+ message: `${MESSAGE_CATALOGUE[type].label} cannot be sent by ${channel}`,
39
+ });
40
+ }
41
+ }
42
+ }
43
+ });
44
+ export const APP_SETTING_VALUE_SCHEMAS = {
45
+ 'communication.channels': communicationChannelsSettingSchema,
46
+ 'communication.messages': communicationMessagesSettingSchema,
47
+ };
48
+ /** Every message type, with its catalogue defaults: the effective value with nothing saved. */
49
+ export function defaultMessageSettings() {
50
+ return Object.fromEntries(MESSAGE_TYPES.map((type) => [
51
+ type,
52
+ { ...MESSAGE_CATALOGUE[type].defaultChannels },
53
+ ]));
54
+ }
55
+ export const APP_SETTING_DEFAULTS = {
56
+ 'communication.channels': { EMAIL: true, SMS: true },
57
+ 'communication.messages': defaultMessageSettings(),
58
+ };
59
+ export const appSettingKeyParamSchema = z.enum(APP_SETTING_KEYS);
60
+ export const appSettingResponseSchema = z.object({
61
+ key: z.enum(APP_SETTING_KEYS),
62
+ label: z.string(),
63
+ description: z.string(),
64
+ value: z.unknown(),
65
+ defaultValue: z.unknown(),
66
+ /** 0 until the setting is first saved. Send it back to update. */
67
+ version: z.number().int(),
68
+ updatedBy: z.uuid().nullable(),
69
+ updatedAt: utcTimestampSchema.nullable(),
70
+ });
71
+ export const appSettingListResponseSchema = z.array(appSettingResponseSchema);
72
+ /**
73
+ * Replaces a setting's value. `version` must be the one last read, so a
74
+ * change made in between is not silently overwritten. The value is checked
75
+ * against the key's schema on the server.
76
+ */
77
+ export const updateAppSettingSchema = z.strictObject({
78
+ value: z.unknown(),
79
+ version: z.number().int().min(0),
80
+ });
81
+ export const appSettingHistoryEntrySchema = z.object({
82
+ id: z.uuid(),
83
+ key: z.enum(APP_SETTING_KEYS),
84
+ previousValue: z.unknown(),
85
+ newValue: z.unknown(),
86
+ version: z.number().int(),
87
+ actorUserId: z.uuid(),
88
+ createdAt: utcTimestampSchema,
89
+ });
90
+ export const appSettingHistoryResponseSchema = z.array(appSettingHistoryEntrySchema);
@@ -0,0 +1 @@
1
+ export * from './app-settings.dto.js';
@@ -0,0 +1 @@
1
+ export * from './app-settings.dto.js';
@@ -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;