@tmlmobilidade/types 20250325.1729.12
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 +13 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +21 -0
- package/dist/src/agency.d.ts +155 -0
- package/dist/src/agency.js +20 -0
- package/dist/src/alert.d.ts +289 -0
- package/dist/src/alert.js +81 -0
- package/dist/src/apex-t11.d.ts +152 -0
- package/dist/src/apex-t11.js +98 -0
- package/dist/src/apex-t19.d.ts +67 -0
- package/dist/src/apex-t19.js +17 -0
- package/dist/src/auth.d.ts +525 -0
- package/dist/src/auth.js +97 -0
- package/dist/src/common.d.ts +77 -0
- package/dist/src/common.js +50 -0
- package/dist/src/file.d.ts +121 -0
- package/dist/src/file.js +16 -0
- package/dist/src/hashed-shape.d.ts +186 -0
- package/dist/src/hashed-shape.js +19 -0
- package/dist/src/hashed-trip.d.ts +445 -0
- package/dist/src/hashed-trip.js +37 -0
- package/dist/src/locality.d.ts +145 -0
- package/dist/src/locality.js +20 -0
- package/dist/src/municipality.d.ts +145 -0
- package/dist/src/municipality.js +20 -0
- package/dist/src/organization.d.ts +52 -0
- package/dist/src/organization.js +8 -0
- package/dist/src/plan.d.ts +127 -0
- package/dist/src/plan.js +16 -0
- package/dist/src/ride.d.ts +498 -0
- package/dist/src/ride.js +44 -0
- package/dist/src/stop.d.ts +474 -0
- package/dist/src/stop.js +139 -0
- package/dist/src/vehicle-event.d.ts +76 -0
- package/dist/src/vehicle-event.js +20 -0
- package/dist/src/zone.d.ts +120 -0
- package/dist/src/zone.js +16 -0
- package/package.json +51 -0
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
import { type UnixTimestamp } from './common.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const PermissionSchema: z.ZodObject<{
|
|
4
|
+
action: z.ZodString;
|
|
5
|
+
resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
6
|
+
scope: z.ZodString;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
action: string;
|
|
9
|
+
scope: string;
|
|
10
|
+
resource?: Record<string, any> | null | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
action: string;
|
|
13
|
+
scope: string;
|
|
14
|
+
resource?: Record<string, any> | null | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
export interface Permission<T> {
|
|
17
|
+
action: string;
|
|
18
|
+
resource?: Partial<Record<keyof T, T[keyof T][]>>;
|
|
19
|
+
scope: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const UserSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
22
|
+
_id: z.ZodString;
|
|
23
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
24
|
+
updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
25
|
+
}, {
|
|
26
|
+
avatar: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
|
+
bio: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
28
|
+
email: z.ZodString;
|
|
29
|
+
email_verified: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
30
|
+
first_name: z.ZodString;
|
|
31
|
+
last_name: z.ZodString;
|
|
32
|
+
organization_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
33
|
+
password_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
34
|
+
permissions: z.ZodArray<z.ZodObject<{
|
|
35
|
+
action: z.ZodString;
|
|
36
|
+
resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
37
|
+
scope: z.ZodString;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
action: string;
|
|
40
|
+
scope: string;
|
|
41
|
+
resource?: Record<string, any> | null | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
action: string;
|
|
44
|
+
scope: string;
|
|
45
|
+
resource?: Record<string, any> | null | undefined;
|
|
46
|
+
}>, "many">;
|
|
47
|
+
phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
role_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
49
|
+
session_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
50
|
+
verification_token_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
51
|
+
}>, "strict", z.ZodTypeAny, {
|
|
52
|
+
_id: string;
|
|
53
|
+
email: string;
|
|
54
|
+
first_name: string;
|
|
55
|
+
last_name: string;
|
|
56
|
+
organization_ids: string[];
|
|
57
|
+
permissions: {
|
|
58
|
+
action: string;
|
|
59
|
+
scope: string;
|
|
60
|
+
resource?: Record<string, any> | null | undefined;
|
|
61
|
+
}[];
|
|
62
|
+
role_ids: string[];
|
|
63
|
+
session_ids: string[];
|
|
64
|
+
verification_token_ids: string[];
|
|
65
|
+
created_at?: (number & {
|
|
66
|
+
__brand: "UnixTimestamp";
|
|
67
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
68
|
+
updated_at?: (number & {
|
|
69
|
+
__brand: "UnixTimestamp";
|
|
70
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
71
|
+
phone?: string | null | undefined;
|
|
72
|
+
avatar?: string | null | undefined;
|
|
73
|
+
bio?: string | null | undefined;
|
|
74
|
+
email_verified?: (number & {
|
|
75
|
+
__brand: "UnixTimestamp";
|
|
76
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
77
|
+
password_hash?: string | null | undefined;
|
|
78
|
+
}, {
|
|
79
|
+
_id: string;
|
|
80
|
+
email: string;
|
|
81
|
+
first_name: string;
|
|
82
|
+
last_name: string;
|
|
83
|
+
permissions: {
|
|
84
|
+
action: string;
|
|
85
|
+
scope: string;
|
|
86
|
+
resource?: Record<string, any> | null | undefined;
|
|
87
|
+
}[];
|
|
88
|
+
created_at?: number | null | undefined;
|
|
89
|
+
updated_at?: number | null | undefined;
|
|
90
|
+
phone?: string | null | undefined;
|
|
91
|
+
avatar?: string | null | undefined;
|
|
92
|
+
bio?: string | null | undefined;
|
|
93
|
+
email_verified?: number | null | undefined;
|
|
94
|
+
organization_ids?: string[] | undefined;
|
|
95
|
+
password_hash?: string | null | undefined;
|
|
96
|
+
role_ids?: string[] | undefined;
|
|
97
|
+
session_ids?: string[] | undefined;
|
|
98
|
+
verification_token_ids?: string[] | undefined;
|
|
99
|
+
}>;
|
|
100
|
+
export declare const CreateUserSchema: z.ZodObject<Omit<z.objectUtil.extendShape<{
|
|
101
|
+
_id: z.ZodString;
|
|
102
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
103
|
+
updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
104
|
+
}, {
|
|
105
|
+
avatar: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
106
|
+
bio: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
107
|
+
email: z.ZodString;
|
|
108
|
+
email_verified: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
109
|
+
first_name: z.ZodString;
|
|
110
|
+
last_name: z.ZodString;
|
|
111
|
+
organization_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
112
|
+
password_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
113
|
+
permissions: z.ZodArray<z.ZodObject<{
|
|
114
|
+
action: z.ZodString;
|
|
115
|
+
resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
116
|
+
scope: z.ZodString;
|
|
117
|
+
}, "strip", z.ZodTypeAny, {
|
|
118
|
+
action: string;
|
|
119
|
+
scope: string;
|
|
120
|
+
resource?: Record<string, any> | null | undefined;
|
|
121
|
+
}, {
|
|
122
|
+
action: string;
|
|
123
|
+
scope: string;
|
|
124
|
+
resource?: Record<string, any> | null | undefined;
|
|
125
|
+
}>, "many">;
|
|
126
|
+
phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
127
|
+
role_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
128
|
+
session_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
129
|
+
verification_token_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
130
|
+
}>, "_id" | "created_at" | "updated_at" | "password_hash">, "strict", z.ZodTypeAny, {
|
|
131
|
+
email: string;
|
|
132
|
+
first_name: string;
|
|
133
|
+
last_name: string;
|
|
134
|
+
organization_ids: string[];
|
|
135
|
+
permissions: {
|
|
136
|
+
action: string;
|
|
137
|
+
scope: string;
|
|
138
|
+
resource?: Record<string, any> | null | undefined;
|
|
139
|
+
}[];
|
|
140
|
+
role_ids: string[];
|
|
141
|
+
session_ids: string[];
|
|
142
|
+
verification_token_ids: string[];
|
|
143
|
+
phone?: string | null | undefined;
|
|
144
|
+
avatar?: string | null | undefined;
|
|
145
|
+
bio?: string | null | undefined;
|
|
146
|
+
email_verified?: (number & {
|
|
147
|
+
__brand: "UnixTimestamp";
|
|
148
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
149
|
+
}, {
|
|
150
|
+
email: string;
|
|
151
|
+
first_name: string;
|
|
152
|
+
last_name: string;
|
|
153
|
+
permissions: {
|
|
154
|
+
action: string;
|
|
155
|
+
scope: string;
|
|
156
|
+
resource?: Record<string, any> | null | undefined;
|
|
157
|
+
}[];
|
|
158
|
+
phone?: string | null | undefined;
|
|
159
|
+
avatar?: string | null | undefined;
|
|
160
|
+
bio?: string | null | undefined;
|
|
161
|
+
email_verified?: number | null | undefined;
|
|
162
|
+
organization_ids?: string[] | undefined;
|
|
163
|
+
role_ids?: string[] | undefined;
|
|
164
|
+
session_ids?: string[] | undefined;
|
|
165
|
+
verification_token_ids?: string[] | undefined;
|
|
166
|
+
}>;
|
|
167
|
+
export declare const UpdateUserSchema: z.ZodObject<{
|
|
168
|
+
email: z.ZodOptional<z.ZodString>;
|
|
169
|
+
phone: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
170
|
+
avatar: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
171
|
+
bio: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
172
|
+
email_verified: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>>;
|
|
173
|
+
first_name: z.ZodOptional<z.ZodString>;
|
|
174
|
+
last_name: z.ZodOptional<z.ZodString>;
|
|
175
|
+
organization_ids: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
|
|
176
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
177
|
+
action: z.ZodString;
|
|
178
|
+
resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
179
|
+
scope: z.ZodString;
|
|
180
|
+
}, "strip", z.ZodTypeAny, {
|
|
181
|
+
action: string;
|
|
182
|
+
scope: string;
|
|
183
|
+
resource?: Record<string, any> | null | undefined;
|
|
184
|
+
}, {
|
|
185
|
+
action: string;
|
|
186
|
+
scope: string;
|
|
187
|
+
resource?: Record<string, any> | null | undefined;
|
|
188
|
+
}>, "many">>;
|
|
189
|
+
role_ids: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
|
|
190
|
+
session_ids: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
|
|
191
|
+
verification_token_ids: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
|
|
192
|
+
password_hash: z.ZodOptional<z.ZodString>;
|
|
193
|
+
}, "strict", z.ZodTypeAny, {
|
|
194
|
+
email?: string | undefined;
|
|
195
|
+
phone?: string | null | undefined;
|
|
196
|
+
avatar?: string | null | undefined;
|
|
197
|
+
bio?: string | null | undefined;
|
|
198
|
+
email_verified?: (number & {
|
|
199
|
+
__brand: "UnixTimestamp";
|
|
200
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
201
|
+
first_name?: string | undefined;
|
|
202
|
+
last_name?: string | undefined;
|
|
203
|
+
organization_ids?: string[] | undefined;
|
|
204
|
+
password_hash?: string | undefined;
|
|
205
|
+
permissions?: {
|
|
206
|
+
action: string;
|
|
207
|
+
scope: string;
|
|
208
|
+
resource?: Record<string, any> | null | undefined;
|
|
209
|
+
}[] | undefined;
|
|
210
|
+
role_ids?: string[] | undefined;
|
|
211
|
+
session_ids?: string[] | undefined;
|
|
212
|
+
verification_token_ids?: string[] | undefined;
|
|
213
|
+
}, {
|
|
214
|
+
email?: string | undefined;
|
|
215
|
+
phone?: string | null | undefined;
|
|
216
|
+
avatar?: string | null | undefined;
|
|
217
|
+
bio?: string | null | undefined;
|
|
218
|
+
email_verified?: number | null | undefined;
|
|
219
|
+
first_name?: string | undefined;
|
|
220
|
+
last_name?: string | undefined;
|
|
221
|
+
organization_ids?: string[] | undefined;
|
|
222
|
+
password_hash?: string | undefined;
|
|
223
|
+
permissions?: {
|
|
224
|
+
action: string;
|
|
225
|
+
scope: string;
|
|
226
|
+
resource?: Record<string, any> | null | undefined;
|
|
227
|
+
}[] | undefined;
|
|
228
|
+
role_ids?: string[] | undefined;
|
|
229
|
+
session_ids?: string[] | undefined;
|
|
230
|
+
verification_token_ids?: string[] | undefined;
|
|
231
|
+
}>;
|
|
232
|
+
export interface User extends Omit<z.infer<typeof UserSchema>, 'created_at' | 'email_verified' | 'updated_at'> {
|
|
233
|
+
created_at: UnixTimestamp;
|
|
234
|
+
email_verified?: null | UnixTimestamp;
|
|
235
|
+
updated_at: UnixTimestamp;
|
|
236
|
+
}
|
|
237
|
+
export interface CreateUserDto extends Omit<z.infer<typeof CreateUserSchema>, 'created_at' | 'email_verified' | 'updated_at'> {
|
|
238
|
+
created_at?: UnixTimestamp;
|
|
239
|
+
email_verified?: null | UnixTimestamp;
|
|
240
|
+
updated_at?: UnixTimestamp;
|
|
241
|
+
}
|
|
242
|
+
export type UpdateUserDto = Partial<CreateUserDto> & {
|
|
243
|
+
password_hash?: string;
|
|
244
|
+
};
|
|
245
|
+
export declare const LoginDtoSchema: z.ZodObject<{
|
|
246
|
+
email: z.ZodString;
|
|
247
|
+
password: z.ZodString;
|
|
248
|
+
}, "strict", z.ZodTypeAny, {
|
|
249
|
+
email: string;
|
|
250
|
+
password: string;
|
|
251
|
+
}, {
|
|
252
|
+
email: string;
|
|
253
|
+
password: string;
|
|
254
|
+
}>;
|
|
255
|
+
export type LoginDto = z.infer<typeof LoginDtoSchema>;
|
|
256
|
+
export declare const PasswordRequirementsSchema: z.ZodEffects<z.ZodObject<{
|
|
257
|
+
password: z.ZodString;
|
|
258
|
+
}, "strip", z.ZodTypeAny, {
|
|
259
|
+
password: string;
|
|
260
|
+
}, {
|
|
261
|
+
password: string;
|
|
262
|
+
}>, {
|
|
263
|
+
password: string;
|
|
264
|
+
}, {
|
|
265
|
+
password: string;
|
|
266
|
+
}>;
|
|
267
|
+
export type PasswordRequirements = z.infer<typeof PasswordRequirementsSchema>;
|
|
268
|
+
export declare const RoleSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
269
|
+
_id: z.ZodString;
|
|
270
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
271
|
+
updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
272
|
+
}, {
|
|
273
|
+
name: z.ZodString;
|
|
274
|
+
permissions: z.ZodArray<z.ZodObject<{
|
|
275
|
+
action: z.ZodString;
|
|
276
|
+
resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
277
|
+
scope: z.ZodString;
|
|
278
|
+
}, "strip", z.ZodTypeAny, {
|
|
279
|
+
action: string;
|
|
280
|
+
scope: string;
|
|
281
|
+
resource?: Record<string, any> | null | undefined;
|
|
282
|
+
}, {
|
|
283
|
+
action: string;
|
|
284
|
+
scope: string;
|
|
285
|
+
resource?: Record<string, any> | null | undefined;
|
|
286
|
+
}>, "many">;
|
|
287
|
+
}>, "strict", z.ZodTypeAny, {
|
|
288
|
+
_id: string;
|
|
289
|
+
name: string;
|
|
290
|
+
permissions: {
|
|
291
|
+
action: string;
|
|
292
|
+
scope: string;
|
|
293
|
+
resource?: Record<string, any> | null | undefined;
|
|
294
|
+
}[];
|
|
295
|
+
created_at?: (number & {
|
|
296
|
+
__brand: "UnixTimestamp";
|
|
297
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
298
|
+
updated_at?: (number & {
|
|
299
|
+
__brand: "UnixTimestamp";
|
|
300
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
301
|
+
}, {
|
|
302
|
+
_id: string;
|
|
303
|
+
name: string;
|
|
304
|
+
permissions: {
|
|
305
|
+
action: string;
|
|
306
|
+
scope: string;
|
|
307
|
+
resource?: Record<string, any> | null | undefined;
|
|
308
|
+
}[];
|
|
309
|
+
created_at?: number | null | undefined;
|
|
310
|
+
updated_at?: number | null | undefined;
|
|
311
|
+
}>;
|
|
312
|
+
export declare const CreateRoleSchema: z.ZodObject<Omit<z.objectUtil.extendShape<{
|
|
313
|
+
_id: z.ZodString;
|
|
314
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
315
|
+
updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
316
|
+
}, {
|
|
317
|
+
name: z.ZodString;
|
|
318
|
+
permissions: z.ZodArray<z.ZodObject<{
|
|
319
|
+
action: z.ZodString;
|
|
320
|
+
resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
321
|
+
scope: z.ZodString;
|
|
322
|
+
}, "strip", z.ZodTypeAny, {
|
|
323
|
+
action: string;
|
|
324
|
+
scope: string;
|
|
325
|
+
resource?: Record<string, any> | null | undefined;
|
|
326
|
+
}, {
|
|
327
|
+
action: string;
|
|
328
|
+
scope: string;
|
|
329
|
+
resource?: Record<string, any> | null | undefined;
|
|
330
|
+
}>, "many">;
|
|
331
|
+
}>, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, {
|
|
332
|
+
name: string;
|
|
333
|
+
permissions: {
|
|
334
|
+
action: string;
|
|
335
|
+
scope: string;
|
|
336
|
+
resource?: Record<string, any> | null | undefined;
|
|
337
|
+
}[];
|
|
338
|
+
}, {
|
|
339
|
+
name: string;
|
|
340
|
+
permissions: {
|
|
341
|
+
action: string;
|
|
342
|
+
scope: string;
|
|
343
|
+
resource?: Record<string, any> | null | undefined;
|
|
344
|
+
}[];
|
|
345
|
+
}>;
|
|
346
|
+
export declare const UpdateRoleSchema: z.ZodObject<{
|
|
347
|
+
name: z.ZodOptional<z.ZodString>;
|
|
348
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
349
|
+
action: z.ZodString;
|
|
350
|
+
resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
351
|
+
scope: z.ZodString;
|
|
352
|
+
}, "strip", z.ZodTypeAny, {
|
|
353
|
+
action: string;
|
|
354
|
+
scope: string;
|
|
355
|
+
resource?: Record<string, any> | null | undefined;
|
|
356
|
+
}, {
|
|
357
|
+
action: string;
|
|
358
|
+
scope: string;
|
|
359
|
+
resource?: Record<string, any> | null | undefined;
|
|
360
|
+
}>, "many">>;
|
|
361
|
+
}, "strict", z.ZodTypeAny, {
|
|
362
|
+
name?: string | undefined;
|
|
363
|
+
permissions?: {
|
|
364
|
+
action: string;
|
|
365
|
+
scope: string;
|
|
366
|
+
resource?: Record<string, any> | null | undefined;
|
|
367
|
+
}[] | undefined;
|
|
368
|
+
}, {
|
|
369
|
+
name?: string | undefined;
|
|
370
|
+
permissions?: {
|
|
371
|
+
action: string;
|
|
372
|
+
scope: string;
|
|
373
|
+
resource?: Record<string, any> | null | undefined;
|
|
374
|
+
}[] | undefined;
|
|
375
|
+
}>;
|
|
376
|
+
export interface Role extends Omit<z.infer<typeof RoleSchema>, 'created_at' | 'updated_at'> {
|
|
377
|
+
created_at: UnixTimestamp;
|
|
378
|
+
updated_at: UnixTimestamp;
|
|
379
|
+
}
|
|
380
|
+
export type CreateRoleDto = z.infer<typeof CreateRoleSchema>;
|
|
381
|
+
export type UpdateRoleDto = Partial<CreateRoleDto>;
|
|
382
|
+
export declare const VerificationTokenSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
383
|
+
_id: z.ZodString;
|
|
384
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
385
|
+
updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
386
|
+
}, {
|
|
387
|
+
expires_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
|
|
388
|
+
token: z.ZodString;
|
|
389
|
+
user_id: z.ZodString;
|
|
390
|
+
}>, "strict", z.ZodTypeAny, {
|
|
391
|
+
_id: string;
|
|
392
|
+
user_id: string;
|
|
393
|
+
expires_at: number & {
|
|
394
|
+
__brand: "UnixTimestamp";
|
|
395
|
+
} & z.BRAND<"UnixTimestamp">;
|
|
396
|
+
token: string;
|
|
397
|
+
created_at?: (number & {
|
|
398
|
+
__brand: "UnixTimestamp";
|
|
399
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
400
|
+
updated_at?: (number & {
|
|
401
|
+
__brand: "UnixTimestamp";
|
|
402
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
403
|
+
}, {
|
|
404
|
+
_id: string;
|
|
405
|
+
user_id: string;
|
|
406
|
+
expires_at: number;
|
|
407
|
+
token: string;
|
|
408
|
+
created_at?: number | null | undefined;
|
|
409
|
+
updated_at?: number | null | undefined;
|
|
410
|
+
}>;
|
|
411
|
+
export declare const CreateVerificationTokenSchema: z.ZodObject<Omit<z.objectUtil.extendShape<{
|
|
412
|
+
_id: z.ZodString;
|
|
413
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
414
|
+
updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
415
|
+
}, {
|
|
416
|
+
expires_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
|
|
417
|
+
token: z.ZodString;
|
|
418
|
+
user_id: z.ZodString;
|
|
419
|
+
}>, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, {
|
|
420
|
+
user_id: string;
|
|
421
|
+
expires_at: number & {
|
|
422
|
+
__brand: "UnixTimestamp";
|
|
423
|
+
} & z.BRAND<"UnixTimestamp">;
|
|
424
|
+
token: string;
|
|
425
|
+
}, {
|
|
426
|
+
user_id: string;
|
|
427
|
+
expires_at: number;
|
|
428
|
+
token: string;
|
|
429
|
+
}>;
|
|
430
|
+
export declare const UpdateVerificationTokenSchema: z.ZodObject<{
|
|
431
|
+
user_id: z.ZodOptional<z.ZodString>;
|
|
432
|
+
expires_at: z.ZodOptional<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>;
|
|
433
|
+
token: z.ZodOptional<z.ZodString>;
|
|
434
|
+
}, "strict", z.ZodTypeAny, {
|
|
435
|
+
user_id?: string | undefined;
|
|
436
|
+
expires_at?: (number & {
|
|
437
|
+
__brand: "UnixTimestamp";
|
|
438
|
+
} & z.BRAND<"UnixTimestamp">) | undefined;
|
|
439
|
+
token?: string | undefined;
|
|
440
|
+
}, {
|
|
441
|
+
user_id?: string | undefined;
|
|
442
|
+
expires_at?: number | undefined;
|
|
443
|
+
token?: string | undefined;
|
|
444
|
+
}>;
|
|
445
|
+
export interface VerificationToken extends Omit<z.infer<typeof VerificationTokenSchema>, 'created_at' | 'expires_at' | 'updated_at'> {
|
|
446
|
+
created_at: UnixTimestamp;
|
|
447
|
+
expires_at: UnixTimestamp;
|
|
448
|
+
updated_at: UnixTimestamp;
|
|
449
|
+
}
|
|
450
|
+
export type CreateVerificationTokenDto = Omit<z.infer<typeof CreateVerificationTokenSchema>, 'expires_at'> & {
|
|
451
|
+
expires_at: UnixTimestamp;
|
|
452
|
+
};
|
|
453
|
+
export type UpdateVerificationTokenDto = Partial<CreateVerificationTokenDto>;
|
|
454
|
+
export declare const SessionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
455
|
+
_id: z.ZodString;
|
|
456
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
457
|
+
updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
458
|
+
}, {
|
|
459
|
+
expires_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
460
|
+
token: z.ZodString;
|
|
461
|
+
user_id: z.ZodString;
|
|
462
|
+
}>, "strict", z.ZodTypeAny, {
|
|
463
|
+
_id: string;
|
|
464
|
+
user_id: string;
|
|
465
|
+
token: string;
|
|
466
|
+
created_at?: (number & {
|
|
467
|
+
__brand: "UnixTimestamp";
|
|
468
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
469
|
+
updated_at?: (number & {
|
|
470
|
+
__brand: "UnixTimestamp";
|
|
471
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
472
|
+
expires_at?: (number & {
|
|
473
|
+
__brand: "UnixTimestamp";
|
|
474
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
475
|
+
}, {
|
|
476
|
+
_id: string;
|
|
477
|
+
user_id: string;
|
|
478
|
+
token: string;
|
|
479
|
+
created_at?: number | null | undefined;
|
|
480
|
+
updated_at?: number | null | undefined;
|
|
481
|
+
expires_at?: number | null | undefined;
|
|
482
|
+
}>;
|
|
483
|
+
export declare const CreateSessionSchema: z.ZodObject<Omit<z.objectUtil.extendShape<{
|
|
484
|
+
_id: z.ZodString;
|
|
485
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
486
|
+
updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
487
|
+
}, {
|
|
488
|
+
expires_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
|
|
489
|
+
token: z.ZodString;
|
|
490
|
+
user_id: z.ZodString;
|
|
491
|
+
}>, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, {
|
|
492
|
+
user_id: string;
|
|
493
|
+
token: string;
|
|
494
|
+
expires_at?: (number & {
|
|
495
|
+
__brand: "UnixTimestamp";
|
|
496
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
497
|
+
}, {
|
|
498
|
+
user_id: string;
|
|
499
|
+
token: string;
|
|
500
|
+
expires_at?: number | null | undefined;
|
|
501
|
+
}>;
|
|
502
|
+
export declare const UpdateSessionSchema: z.ZodObject<{
|
|
503
|
+
user_id: z.ZodOptional<z.ZodString>;
|
|
504
|
+
expires_at: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>>;
|
|
505
|
+
token: z.ZodOptional<z.ZodString>;
|
|
506
|
+
}, "strict", z.ZodTypeAny, {
|
|
507
|
+
user_id?: string | undefined;
|
|
508
|
+
expires_at?: (number & {
|
|
509
|
+
__brand: "UnixTimestamp";
|
|
510
|
+
} & z.BRAND<"UnixTimestamp">) | null | undefined;
|
|
511
|
+
token?: string | undefined;
|
|
512
|
+
}, {
|
|
513
|
+
user_id?: string | undefined;
|
|
514
|
+
expires_at?: number | null | undefined;
|
|
515
|
+
token?: string | undefined;
|
|
516
|
+
}>;
|
|
517
|
+
export interface Session extends Omit<z.infer<typeof SessionSchema>, 'created_at' | 'expires_at' | 'updated_at'> {
|
|
518
|
+
created_at: UnixTimestamp;
|
|
519
|
+
expires_at?: UnixTimestamp;
|
|
520
|
+
updated_at: UnixTimestamp;
|
|
521
|
+
}
|
|
522
|
+
export interface CreateSessionDto extends Omit<z.infer<typeof CreateSessionSchema>, 'expires_at'> {
|
|
523
|
+
expires_at?: UnixTimestamp;
|
|
524
|
+
}
|
|
525
|
+
export type UpdateSessionDto = Partial<CreateSessionDto>;
|
package/dist/src/auth.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/* * */
|
|
2
|
+
import { DocumentSchema, validateUnixTimestamp } from './common.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const PermissionSchema = z.object({
|
|
5
|
+
action: z.string(),
|
|
6
|
+
resource: z.record(z.any()).nullish(),
|
|
7
|
+
scope: z.string(),
|
|
8
|
+
});
|
|
9
|
+
/* * */
|
|
10
|
+
export const UserSchema = DocumentSchema.extend({
|
|
11
|
+
avatar: z.string().nullish(),
|
|
12
|
+
bio: z.string().nullish(),
|
|
13
|
+
email: z.string().email(),
|
|
14
|
+
email_verified: z.number().transform(validateUnixTimestamp).brand('UnixTimestamp').nullish(),
|
|
15
|
+
first_name: z.string().nonempty(),
|
|
16
|
+
last_name: z.string().nonempty(),
|
|
17
|
+
organization_ids: z.array(z.string()).default([]),
|
|
18
|
+
password_hash: z.string().nullish(),
|
|
19
|
+
permissions: z.array(PermissionSchema),
|
|
20
|
+
phone: z.string().nullish(),
|
|
21
|
+
role_ids: z.array(z.string()).default([]),
|
|
22
|
+
session_ids: z.array(z.string()).default([]),
|
|
23
|
+
verification_token_ids: z.array(z.string()).default([]),
|
|
24
|
+
}).strict();
|
|
25
|
+
export const CreateUserSchema = UserSchema.omit({ _id: true, created_at: true, password_hash: true, updated_at: true });
|
|
26
|
+
export const UpdateUserSchema = CreateUserSchema.extend({ password_hash: z.string() }).partial();
|
|
27
|
+
/* * */
|
|
28
|
+
export const LoginDtoSchema = z.object({
|
|
29
|
+
email: z.string({
|
|
30
|
+
required_error: 'Email is required',
|
|
31
|
+
}).email({
|
|
32
|
+
message: 'Email must be a valid email address',
|
|
33
|
+
}),
|
|
34
|
+
password: z.string({
|
|
35
|
+
required_error: 'Password is required',
|
|
36
|
+
}),
|
|
37
|
+
}).strict();
|
|
38
|
+
/* * */
|
|
39
|
+
export const PasswordRequirementsSchema = z.object({
|
|
40
|
+
password: z.string(),
|
|
41
|
+
})
|
|
42
|
+
.superRefine(({ password }, checkPassComplexity) => {
|
|
43
|
+
const CONDITIONS = {
|
|
44
|
+
minLength: 8,
|
|
45
|
+
minLowerCase: 1,
|
|
46
|
+
minNumber: 1,
|
|
47
|
+
minSpecialChar: 1,
|
|
48
|
+
minUpperCase: 1,
|
|
49
|
+
};
|
|
50
|
+
const errObj = {
|
|
51
|
+
minLength: CONDITIONS.minLength > 0 ? {
|
|
52
|
+
message: `Password must be at least ${CONDITIONS.minLength} characters long`,
|
|
53
|
+
valid: password.length >= CONDITIONS.minLength,
|
|
54
|
+
} : undefined,
|
|
55
|
+
minLowerCase: CONDITIONS.minLowerCase > 0 ? {
|
|
56
|
+
message: 'Password must contain at least one lowercase character',
|
|
57
|
+
valid: (password.match(/[a-z]/) || []).length >= CONDITIONS.minLowerCase,
|
|
58
|
+
} : undefined,
|
|
59
|
+
minNumber: CONDITIONS.minNumber > 0 ? {
|
|
60
|
+
message: 'Password must contain at least one number',
|
|
61
|
+
valid: (password.match(/\d/) || []).length >= CONDITIONS.minNumber,
|
|
62
|
+
} : undefined,
|
|
63
|
+
minSpecialChar: CONDITIONS.minSpecialChar > 0 ? {
|
|
64
|
+
message: 'Password must contain at least one special character',
|
|
65
|
+
valid: (password.match(/[`!@#$%^&*()_\-+=[\]{};':"\\|,.<>/?~ ]/) || []).length >= CONDITIONS.minSpecialChar,
|
|
66
|
+
} : undefined,
|
|
67
|
+
minUpperCase: CONDITIONS.minUpperCase > 0 ? {
|
|
68
|
+
message: 'Password must contain at least one uppercase character',
|
|
69
|
+
valid: (password.match(/[A-Z]/) || []).length >= CONDITIONS.minUpperCase,
|
|
70
|
+
} : undefined,
|
|
71
|
+
};
|
|
72
|
+
checkPassComplexity.addIssue({ code: z.ZodIssueCode.custom, message: JSON.stringify(errObj), path: ['password'] });
|
|
73
|
+
});
|
|
74
|
+
/* * */
|
|
75
|
+
export const RoleSchema = DocumentSchema.extend({
|
|
76
|
+
name: z.string(),
|
|
77
|
+
permissions: z.array(PermissionSchema),
|
|
78
|
+
}).strict();
|
|
79
|
+
export const CreateRoleSchema = RoleSchema.omit({ _id: true, created_at: true, updated_at: true });
|
|
80
|
+
export const UpdateRoleSchema = CreateRoleSchema.partial();
|
|
81
|
+
/* * */
|
|
82
|
+
export const VerificationTokenSchema = DocumentSchema.extend({
|
|
83
|
+
expires_at: z.number().transform(validateUnixTimestamp).brand('UnixTimestamp'),
|
|
84
|
+
token: z.string(),
|
|
85
|
+
user_id: z.string(),
|
|
86
|
+
}).strict();
|
|
87
|
+
export const CreateVerificationTokenSchema = VerificationTokenSchema.omit({ _id: true, created_at: true, updated_at: true });
|
|
88
|
+
export const UpdateVerificationTokenSchema = CreateVerificationTokenSchema.partial();
|
|
89
|
+
/* * */
|
|
90
|
+
export const SessionSchema = DocumentSchema.extend({
|
|
91
|
+
expires_at: z.number().transform(validateUnixTimestamp).brand('UnixTimestamp').nullish(),
|
|
92
|
+
token: z.string(),
|
|
93
|
+
user_id: z.string(),
|
|
94
|
+
}).strict();
|
|
95
|
+
export const CreateSessionSchema = SessionSchema.omit({ _id: true, created_at: true, updated_at: true });
|
|
96
|
+
export const UpdateSessionSchema = CreateSessionSchema.partial();
|
|
97
|
+
/* * */
|