@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.
- package/README.md +21 -0
- package/dist/cjs/app-settings/app-settings.dto.d.ts +124 -0
- package/dist/cjs/app-settings/app-settings.dto.js +94 -0
- package/dist/cjs/app-settings/index.d.ts +1 -0
- package/dist/cjs/app-settings/index.js +17 -0
- package/dist/cjs/auth/auth.dto.d.ts +4 -4
- package/dist/cjs/auth/index.d.ts +1 -0
- package/dist/cjs/auth/index.js +1 -0
- package/dist/cjs/auth/otp.dto.d.ts +45 -0
- package/dist/cjs/auth/otp.dto.js +39 -0
- package/dist/cjs/client/client-auth.dto.d.ts +81 -0
- package/dist/cjs/client/client-auth.dto.js +49 -0
- package/dist/cjs/client/index.d.ts +2 -0
- package/dist/cjs/client/index.js +18 -0
- package/dist/cjs/coach/coach-auth.dto.d.ts +0 -40
- package/dist/cjs/coach/coach-auth.dto.js +1 -30
- package/dist/cjs/coach/index.d.ts +1 -0
- package/dist/cjs/coach/index.js +1 -0
- package/dist/cjs/communication/index.d.ts +2 -0
- package/dist/cjs/communication/index.js +18 -0
- package/dist/cjs/communication/message-catalogue.d.ts +26 -0
- package/dist/cjs/communication/message-catalogue.js +53 -0
- package/dist/cjs/communication/template.dto.d.ts +240 -0
- package/dist/cjs/communication/template.dto.js +206 -0
- package/dist/cjs/enums/index.d.ts +21 -2
- package/dist/cjs/enums/index.js +28 -3
- package/dist/cjs/feature-flags/feature-flag.dto.d.ts +4 -4
- package/dist/cjs/feature-flags/feature-flag.dto.js +1 -1
- package/dist/esm/app-settings/app-settings.dto.d.ts +124 -0
- package/dist/esm/app-settings/app-settings.dto.js +90 -0
- package/dist/esm/app-settings/index.d.ts +1 -0
- package/dist/esm/app-settings/index.js +1 -0
- package/dist/esm/auth/auth.dto.d.ts +4 -4
- package/dist/esm/auth/index.d.ts +1 -0
- package/dist/esm/auth/index.js +1 -0
- package/dist/esm/auth/otp.dto.d.ts +45 -0
- package/dist/esm/auth/otp.dto.js +36 -0
- package/dist/esm/client/client-auth.dto.d.ts +81 -0
- package/dist/esm/client/client-auth.dto.js +46 -0
- package/dist/esm/client/index.d.ts +2 -0
- package/dist/esm/client/index.js +2 -0
- package/dist/esm/coach/coach-auth.dto.d.ts +0 -40
- package/dist/esm/coach/coach-auth.dto.js +1 -30
- package/dist/esm/coach/index.d.ts +1 -0
- package/dist/esm/coach/index.js +1 -0
- package/dist/esm/communication/index.d.ts +2 -0
- package/dist/esm/communication/index.js +2 -0
- package/dist/esm/communication/message-catalogue.d.ts +26 -0
- package/dist/esm/communication/message-catalogue.js +50 -0
- package/dist/esm/communication/template.dto.d.ts +240 -0
- package/dist/esm/communication/template.dto.js +200 -0
- package/dist/esm/enums/index.d.ts +21 -2
- package/dist/esm/enums/index.js +27 -2
- package/dist/esm/feature-flags/feature-flag.dto.d.ts +4 -4
- package/dist/esm/feature-flags/feature-flag.dto.js +1 -1
- package/package.json +31 -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,26 @@ 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
|
+
|
|
54
|
+
## Version 0.4.0
|
|
55
|
+
|
|
56
|
+
Communication and runtime settings. Additive; consumers install `^0.4.0` explicitly.
|
|
57
|
+
|
|
58
|
+
- `/enums`: `COMMUNICATION_CHANNELS` (`EMAIL`, `SMS`), `MESSAGE_TYPES`, `DELIVERY_STATUSES` and `TEMPLATE_STATUSES`.
|
|
59
|
+
- New `/communication`:
|
|
60
|
+
- `MESSAGE_CATALOGUE`: per message type, the channels that may carry it, the default switches, and the variables its sender supplies, with the required ones.
|
|
61
|
+
- `templatePlaceholders`, `hasMalformedPlaceholder` and `templateProblems`, the template rules shared by the server and the admin editor.
|
|
62
|
+
- `createTemplateSchema`, `templateResponseSchema`, `previewTemplateSchema`, `renderedMessageSchema`, `testSendResponseSchema` and `messageTypeResponseSchema`.
|
|
63
|
+
- New `/app-settings`: `APP_SETTING_KEYS`, a value schema and default per key (`communication.channels` master switches, `communication.messages` per type and channel), plus `appSettingResponseSchema`, `updateAppSettingSchema` (`{ value, version }`) and `appSettingHistoryResponseSchema`.
|
|
64
|
+
|
|
44
65
|
## Version 0.3.0
|
|
45
66
|
|
|
46
67
|
Time zones and the platform's date and time rules. Additive, but a caret range on 0.x does not cross minor versions, so consumers install `^0.3.0` explicitly.
|
|
@@ -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,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.appSettingHistoryResponseSchema = exports.appSettingHistoryEntrySchema = exports.updateAppSettingSchema = exports.appSettingListResponseSchema = exports.appSettingResponseSchema = exports.appSettingKeyParamSchema = exports.APP_SETTING_DEFAULTS = exports.APP_SETTING_VALUE_SCHEMAS = exports.communicationMessagesSettingSchema = exports.communicationChannelsSettingSchema = exports.channelSwitchesSchema = exports.APP_SETTING_KEYS = void 0;
|
|
4
|
+
exports.defaultMessageSettings = defaultMessageSettings;
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const date_time_schema_js_1 = require("../common/date-time.schema.js");
|
|
7
|
+
const message_catalogue_js_1 = require("../communication/message-catalogue.js");
|
|
8
|
+
const index_js_1 = require("../enums/index.js");
|
|
9
|
+
/**
|
|
10
|
+
* Runtime settings an administrator changes without a deploy. Each key has a
|
|
11
|
+
* value schema here, which both the server and the admin screen use. A key
|
|
12
|
+
* with no saved value uses its default.
|
|
13
|
+
*/
|
|
14
|
+
exports.APP_SETTING_KEYS = [
|
|
15
|
+
'communication.channels',
|
|
16
|
+
'communication.messages',
|
|
17
|
+
];
|
|
18
|
+
/** A switch per channel. */
|
|
19
|
+
exports.channelSwitchesSchema = zod_1.z.strictObject({
|
|
20
|
+
EMAIL: zod_1.z.boolean(),
|
|
21
|
+
SMS: zod_1.z.boolean(),
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Master switches: a channel switched off here sends nothing, whatever the
|
|
25
|
+
* per-message settings say.
|
|
26
|
+
*/
|
|
27
|
+
exports.communicationChannelsSettingSchema = exports.channelSwitchesSchema;
|
|
28
|
+
/**
|
|
29
|
+
* Per message type and channel. A type missing from a saved value uses its
|
|
30
|
+
* catalogue defaults, so a newly added message type needs no data change.
|
|
31
|
+
*/
|
|
32
|
+
exports.communicationMessagesSettingSchema = zod_1.z
|
|
33
|
+
.partialRecord(zod_1.z.enum(index_js_1.MESSAGE_TYPES), exports.channelSwitchesSchema)
|
|
34
|
+
.superRefine((value, ctx) => {
|
|
35
|
+
for (const [type, switches] of Object.entries(value)) {
|
|
36
|
+
const allowed = message_catalogue_js_1.MESSAGE_CATALOGUE[type].channels;
|
|
37
|
+
for (const [channel, on] of Object.entries(switches ?? {})) {
|
|
38
|
+
if (on && !allowed.includes(channel)) {
|
|
39
|
+
ctx.addIssue({
|
|
40
|
+
code: 'custom',
|
|
41
|
+
path: [type, channel],
|
|
42
|
+
message: `${message_catalogue_js_1.MESSAGE_CATALOGUE[type].label} cannot be sent by ${channel}`,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
exports.APP_SETTING_VALUE_SCHEMAS = {
|
|
49
|
+
'communication.channels': exports.communicationChannelsSettingSchema,
|
|
50
|
+
'communication.messages': exports.communicationMessagesSettingSchema,
|
|
51
|
+
};
|
|
52
|
+
/** Every message type, with its catalogue defaults: the effective value with nothing saved. */
|
|
53
|
+
function defaultMessageSettings() {
|
|
54
|
+
return Object.fromEntries(index_js_1.MESSAGE_TYPES.map((type) => [
|
|
55
|
+
type,
|
|
56
|
+
{ ...message_catalogue_js_1.MESSAGE_CATALOGUE[type].defaultChannels },
|
|
57
|
+
]));
|
|
58
|
+
}
|
|
59
|
+
exports.APP_SETTING_DEFAULTS = {
|
|
60
|
+
'communication.channels': { EMAIL: true, SMS: true },
|
|
61
|
+
'communication.messages': defaultMessageSettings(),
|
|
62
|
+
};
|
|
63
|
+
exports.appSettingKeyParamSchema = zod_1.z.enum(exports.APP_SETTING_KEYS);
|
|
64
|
+
exports.appSettingResponseSchema = zod_1.z.object({
|
|
65
|
+
key: zod_1.z.enum(exports.APP_SETTING_KEYS),
|
|
66
|
+
label: zod_1.z.string(),
|
|
67
|
+
description: zod_1.z.string(),
|
|
68
|
+
value: zod_1.z.unknown(),
|
|
69
|
+
defaultValue: zod_1.z.unknown(),
|
|
70
|
+
/** 0 until the setting is first saved. Send it back to update. */
|
|
71
|
+
version: zod_1.z.number().int(),
|
|
72
|
+
updatedBy: zod_1.z.uuid().nullable(),
|
|
73
|
+
updatedAt: date_time_schema_js_1.utcTimestampSchema.nullable(),
|
|
74
|
+
});
|
|
75
|
+
exports.appSettingListResponseSchema = zod_1.z.array(exports.appSettingResponseSchema);
|
|
76
|
+
/**
|
|
77
|
+
* Replaces a setting's value. `version` must be the one last read, so a
|
|
78
|
+
* change made in between is not silently overwritten. The value is checked
|
|
79
|
+
* against the key's schema on the server.
|
|
80
|
+
*/
|
|
81
|
+
exports.updateAppSettingSchema = zod_1.z.strictObject({
|
|
82
|
+
value: zod_1.z.unknown(),
|
|
83
|
+
version: zod_1.z.number().int().min(0),
|
|
84
|
+
});
|
|
85
|
+
exports.appSettingHistoryEntrySchema = zod_1.z.object({
|
|
86
|
+
id: zod_1.z.uuid(),
|
|
87
|
+
key: zod_1.z.enum(exports.APP_SETTING_KEYS),
|
|
88
|
+
previousValue: zod_1.z.unknown(),
|
|
89
|
+
newValue: zod_1.z.unknown(),
|
|
90
|
+
version: zod_1.z.number().int(),
|
|
91
|
+
actorUserId: zod_1.z.uuid(),
|
|
92
|
+
createdAt: date_time_schema_js_1.utcTimestampSchema,
|
|
93
|
+
});
|
|
94
|
+
exports.appSettingHistoryResponseSchema = zod_1.z.array(exports.appSettingHistoryEntrySchema);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './app-settings.dto.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./app-settings.dto.js"), exports);
|
|
@@ -45,7 +45,7 @@ export declare const setRoleSchema: z.ZodObject<{
|
|
|
45
45
|
role: z.ZodEnum<{
|
|
46
46
|
ADMIN: "ADMIN";
|
|
47
47
|
COACH: "COACH";
|
|
48
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
165
|
+
CLIENT: "CLIENT";
|
|
166
166
|
}>;
|
|
167
167
|
status: z.ZodEnum<{
|
|
168
168
|
pending_verification: "pending_verification";
|
package/dist/cjs/auth/index.d.ts
CHANGED
package/dist/cjs/auth/index.js
CHANGED
|
@@ -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,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;
|