@tmlmobilidade/interfaces 20251211.1246.9 → 20251218.110.37

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.
@@ -1,8 +1,11 @@
1
1
  import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
- import { type CreateUserDto, type UpdateUserDto, type User } from '@tmlmobilidade/types';
3
- import { type Filter, type FindOptions, type IndexDescription } from 'mongodb';
2
+ import { type CreateUserDto, type UpdateUserDto, type User, type User_UNSAFE } from '@tmlmobilidade/types';
3
+ import { type Filter, type FindOptions, type IndexDescription, type WithId } from 'mongodb';
4
4
  import { z } from 'zod';
5
- declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, UpdateUserDto> {
5
+ interface SafeUserOptions {
6
+ includeUnsafeProperties: boolean;
7
+ }
8
+ declare class UsersClass extends MongoCollectionClass<User_UNSAFE, CreateUserDto, UpdateUserDto> {
6
9
  private static _instance;
7
10
  protected createSchema: z.ZodSchema;
8
11
  protected updateSchema: z.ZodSchema;
@@ -11,188 +14,40 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
11
14
  /**
12
15
  * Finds a user document by its email.
13
16
  * @param email The email of the user to find.
14
- * @param includePasswordHash - Whether to include the password hash in the result.
17
+ * @param options.includeUnsafeProperties Whether to include the password hash in the result.
15
18
  * @returns A promise that resolves to the matching user document or null if not found.
16
19
  */
17
- findByEmail(email: string, includePasswordHash?: boolean): Promise<{
18
- password_hash: any;
19
- permissions: ({
20
- scope: "agencies";
21
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
22
- } | {
23
- scope: "alerts_scheduled";
24
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
25
- } | {
26
- scope: "alerts_realtime";
27
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
28
- resources: {
29
- agency_ids: string[];
30
- };
31
- } | {
32
- scope: "rides";
33
- action: "acceptance_change_status" | "acceptance_justify" | "acceptance_lock" | "acceptance_read" | "analsys_lock" | "analysis_lock" | "analysis_read" | "analysis_reprocess" | "analysis_update" | "audit_lock" | "audit_read" | "audit_update";
34
- resources: {
35
- agency_ids: string[];
36
- };
37
- } | {
38
- scope: "sams";
39
- action: "read";
40
- } | {
41
- scope: "gtfs_validations";
42
- action: "create" | "read" | "request_approval";
43
- resources: {
44
- agency_ids: string[];
45
- };
46
- } | {
47
- scope: "home";
48
- action: "read_links" | "read_wiki";
49
- } | {
50
- scope: "organizations";
51
- action: "create" | "update" | "delete" | "read";
52
- } | {
53
- scope: "performance";
54
- action: "read";
55
- } | {
56
- scope: "plans";
57
- action: "create" | "update" | "delete" | "read" | "toggle_lock" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy";
58
- resources: {
59
- agency_ids: string[];
60
- };
61
- } | {
62
- scope: "roles";
63
- action: "create" | "update" | "delete" | "read";
64
- } | {
65
- scope: "stops";
66
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
67
- resources: {
68
- municipality_ids: string[];
69
- agency_ids: string[];
70
- };
71
- } | {
72
- scope: "users";
73
- action: "create" | "update" | "delete" | "read";
74
- })[];
75
- created_at: number & {
76
- __brand: "UnixTimestamp";
77
- };
78
- created_by?: string | undefined;
79
- updated_at: number & {
80
- __brand: "UnixTimestamp";
81
- };
82
- updated_by?: string | undefined;
83
- email: string;
84
- email_verified: import("@tmlmobilidade/types").UnixTimestamp | null;
85
- first_name: string;
86
- last_name: string;
87
- organization_id: string | null;
88
- phone: string | null;
89
- preferences: Record<string, Record<string, string | number | boolean | string[] | number[]>> | null;
90
- role_ids: string[];
91
- session_ids: string[];
92
- verification_token_ids: string[];
93
- _id: string;
94
- }>;
20
+ findByEmail(email: string, options: SafeUserOptions & {
21
+ includeUnsafeProperties: true;
22
+ }): Promise<null | WithId<User_UNSAFE>>;
23
+ findByEmail(email: string, options?: SafeUserOptions): Promise<null | WithId<User>>;
95
24
  /**
96
25
  * Finds a user document by its ID.
97
26
  * @param id The ID of the user document to find
98
- * @param includePasswordHash Whether to include the password hash in the result
27
+ * @param includeUnsafeProperties Whether to include the password hash in the result
99
28
  * @returns A promise that resolves to the matching user document or null if not found
100
29
  */
101
- findById(id: string, options?: FindOptions, includePasswordHash?: boolean): Promise<{
102
- password_hash: any;
103
- permissions: ({
104
- scope: "agencies";
105
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
106
- } | {
107
- scope: "alerts_scheduled";
108
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
109
- } | {
110
- scope: "alerts_realtime";
111
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
112
- resources: {
113
- agency_ids: string[];
114
- };
115
- } | {
116
- scope: "rides";
117
- action: "acceptance_change_status" | "acceptance_justify" | "acceptance_lock" | "acceptance_read" | "analsys_lock" | "analysis_lock" | "analysis_read" | "analysis_reprocess" | "analysis_update" | "audit_lock" | "audit_read" | "audit_update";
118
- resources: {
119
- agency_ids: string[];
120
- };
121
- } | {
122
- scope: "sams";
123
- action: "read";
124
- } | {
125
- scope: "gtfs_validations";
126
- action: "create" | "read" | "request_approval";
127
- resources: {
128
- agency_ids: string[];
129
- };
130
- } | {
131
- scope: "home";
132
- action: "read_links" | "read_wiki";
133
- } | {
134
- scope: "organizations";
135
- action: "create" | "update" | "delete" | "read";
136
- } | {
137
- scope: "performance";
138
- action: "read";
139
- } | {
140
- scope: "plans";
141
- action: "create" | "update" | "delete" | "read" | "toggle_lock" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy";
142
- resources: {
143
- agency_ids: string[];
144
- };
145
- } | {
146
- scope: "roles";
147
- action: "create" | "update" | "delete" | "read";
148
- } | {
149
- scope: "stops";
150
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
151
- resources: {
152
- municipality_ids: string[];
153
- agency_ids: string[];
154
- };
155
- } | {
156
- scope: "users";
157
- action: "create" | "update" | "delete" | "read";
158
- })[];
159
- created_at: number & {
160
- __brand: "UnixTimestamp";
161
- };
162
- created_by?: string | undefined;
163
- updated_at: number & {
164
- __brand: "UnixTimestamp";
165
- };
166
- updated_by?: string | undefined;
167
- email: string;
168
- email_verified: import("@tmlmobilidade/types").UnixTimestamp | null;
169
- first_name: string;
170
- last_name: string;
171
- organization_id: string | null;
172
- phone: string | null;
173
- preferences: Record<string, Record<string, string | number | boolean | string[] | number[]>> | null;
174
- role_ids: string[];
175
- session_ids: string[];
176
- verification_token_ids: string[];
177
- _id: string;
178
- }>;
30
+ findById(id: string, options: FindOptions & {
31
+ includeUnsafeProperties: true;
32
+ }): Promise<null | WithId<User_UNSAFE>>;
33
+ findById(id: string): Promise<null | WithId<User>>;
179
34
  /**
180
35
  * Finds users by their organization code.
181
36
  * @param code The code of the organization to find users for.
182
- * @param includePasswordHash Whether to include the password hash in the result.
37
+ * @param includeUnsafeProperties Whether to include the password hash in the result.
183
38
  * @returns A promise that resolves to the matching user documents or null if not found.
184
39
  */
185
- findByOrganization(id: string, includePasswordHash?: boolean): Promise<{
40
+ findByOrganization(id: string): Promise<{
186
41
  password_hash: any;
187
42
  permissions: ({
188
43
  scope: "agencies";
189
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
44
+ action: "create" | "update" | "delete" | "read" | "lock";
190
45
  } | {
191
46
  scope: "alerts_scheduled";
192
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
47
+ action: "create" | "update" | "delete" | "read" | "lock";
193
48
  } | {
194
49
  scope: "alerts_realtime";
195
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
50
+ action: "create" | "update" | "delete" | "read" | "lock";
196
51
  resources: {
197
52
  agency_ids: string[];
198
53
  };
@@ -207,7 +62,7 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
207
62
  action: "read";
208
63
  } | {
209
64
  scope: "gtfs_validations";
210
- action: "create" | "read" | "request_approval";
65
+ action: "create" | "read" | "lock" | "request_approval";
211
66
  resources: {
212
67
  agency_ids: string[];
213
68
  };
@@ -216,30 +71,38 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
216
71
  action: "read_links" | "read_wiki";
217
72
  } | {
218
73
  scope: "organizations";
219
- action: "create" | "update" | "delete" | "read";
74
+ action: "create" | "update" | "delete" | "read" | "lock";
220
75
  } | {
221
76
  scope: "performance";
222
77
  action: "read";
223
78
  } | {
224
79
  scope: "plans";
225
- action: "create" | "update" | "delete" | "read" | "toggle_lock" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy";
80
+ action: "create" | "update" | "delete" | "read" | "lock" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy";
226
81
  resources: {
227
82
  agency_ids: string[];
228
83
  };
229
84
  } | {
230
85
  scope: "roles";
231
- action: "create" | "update" | "delete" | "read";
86
+ action: "create" | "update" | "delete" | "read" | "lock";
232
87
  } | {
233
88
  scope: "stops";
234
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
89
+ action: "create" | "update" | "delete" | "read" | "lock";
235
90
  resources: {
236
91
  municipality_ids: string[];
237
92
  agency_ids: string[];
238
93
  };
239
94
  } | {
240
95
  scope: "users";
241
- action: "create" | "update" | "delete" | "read";
96
+ action: "create" | "update" | "delete" | "read" | "lock";
97
+ } | {
98
+ scope: "dates";
99
+ action: "create_annotations" | "delete_annotations" | "read_annotations" | "update_annotations" | "lock_annotations";
100
+ resources: {
101
+ agency_ids: string[];
102
+ };
242
103
  })[];
104
+ session_ids: any;
105
+ verification_token_ids: any;
243
106
  created_at: number & {
244
107
  __brand: "UnixTimestamp";
245
108
  };
@@ -248,16 +111,16 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
248
111
  __brand: "UnixTimestamp";
249
112
  };
250
113
  updated_by?: string | undefined;
114
+ is_locked: boolean;
251
115
  email: string;
252
116
  email_verified: import("@tmlmobilidade/types").UnixTimestamp | null;
253
117
  first_name: string;
254
118
  last_name: string;
255
- organization_id: string | null;
119
+ organization_id: string;
256
120
  phone: string | null;
257
121
  preferences: Record<string, Record<string, string | number | boolean | string[] | number[]>> | null;
258
122
  role_ids: string[];
259
- session_ids: string[];
260
- verification_token_ids: string[];
123
+ seen_last_at: import("@tmlmobilidade/types").UnixTimestamp | null;
261
124
  _id: string;
262
125
  }[]>;
263
126
  /**
@@ -265,17 +128,17 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
265
128
  * @param role The role of the user to find.
266
129
  * @returns A promise that resolves to the matching user document or null if not found.
267
130
  */
268
- findByRole(role: string, includePasswordHash?: boolean): Promise<{
131
+ findByRole(role: string): Promise<{
269
132
  password_hash: any;
270
133
  permissions: ({
271
134
  scope: "agencies";
272
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
135
+ action: "create" | "update" | "delete" | "read" | "lock";
273
136
  } | {
274
137
  scope: "alerts_scheduled";
275
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
138
+ action: "create" | "update" | "delete" | "read" | "lock";
276
139
  } | {
277
140
  scope: "alerts_realtime";
278
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
141
+ action: "create" | "update" | "delete" | "read" | "lock";
279
142
  resources: {
280
143
  agency_ids: string[];
281
144
  };
@@ -290,7 +153,7 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
290
153
  action: "read";
291
154
  } | {
292
155
  scope: "gtfs_validations";
293
- action: "create" | "read" | "request_approval";
156
+ action: "create" | "read" | "lock" | "request_approval";
294
157
  resources: {
295
158
  agency_ids: string[];
296
159
  };
@@ -299,30 +162,38 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
299
162
  action: "read_links" | "read_wiki";
300
163
  } | {
301
164
  scope: "organizations";
302
- action: "create" | "update" | "delete" | "read";
165
+ action: "create" | "update" | "delete" | "read" | "lock";
303
166
  } | {
304
167
  scope: "performance";
305
168
  action: "read";
306
169
  } | {
307
170
  scope: "plans";
308
- action: "create" | "update" | "delete" | "read" | "toggle_lock" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy";
171
+ action: "create" | "update" | "delete" | "read" | "lock" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy";
309
172
  resources: {
310
173
  agency_ids: string[];
311
174
  };
312
175
  } | {
313
176
  scope: "roles";
314
- action: "create" | "update" | "delete" | "read";
177
+ action: "create" | "update" | "delete" | "read" | "lock";
315
178
  } | {
316
179
  scope: "stops";
317
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
180
+ action: "create" | "update" | "delete" | "read" | "lock";
318
181
  resources: {
319
182
  municipality_ids: string[];
320
183
  agency_ids: string[];
321
184
  };
322
185
  } | {
323
186
  scope: "users";
324
- action: "create" | "update" | "delete" | "read";
187
+ action: "create" | "update" | "delete" | "read" | "lock";
188
+ } | {
189
+ scope: "dates";
190
+ action: "create_annotations" | "delete_annotations" | "read_annotations" | "update_annotations" | "lock_annotations";
191
+ resources: {
192
+ agency_ids: string[];
193
+ };
325
194
  })[];
195
+ session_ids: any;
196
+ verification_token_ids: any;
326
197
  created_at: number & {
327
198
  __brand: "UnixTimestamp";
328
199
  };
@@ -331,16 +202,16 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
331
202
  __brand: "UnixTimestamp";
332
203
  };
333
204
  updated_by?: string | undefined;
205
+ is_locked: boolean;
334
206
  email: string;
335
207
  email_verified: import("@tmlmobilidade/types").UnixTimestamp | null;
336
208
  first_name: string;
337
209
  last_name: string;
338
- organization_id: string | null;
210
+ organization_id: string;
339
211
  phone: string | null;
340
212
  preferences: Record<string, Record<string, string | number | boolean | string[] | number[]>> | null;
341
213
  role_ids: string[];
342
- session_ids: string[];
343
- verification_token_ids: string[];
214
+ seen_last_at: import("@tmlmobilidade/types").UnixTimestamp | null;
344
215
  _id: string;
345
216
  }[]>;
346
217
  /**
@@ -356,13 +227,13 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
356
227
  password_hash: any;
357
228
  permissions: ({
358
229
  scope: "agencies";
359
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
230
+ action: "create" | "update" | "delete" | "read" | "lock";
360
231
  } | {
361
232
  scope: "alerts_scheduled";
362
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
233
+ action: "create" | "update" | "delete" | "read" | "lock";
363
234
  } | {
364
235
  scope: "alerts_realtime";
365
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
236
+ action: "create" | "update" | "delete" | "read" | "lock";
366
237
  resources: {
367
238
  agency_ids: string[];
368
239
  };
@@ -377,7 +248,7 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
377
248
  action: "read";
378
249
  } | {
379
250
  scope: "gtfs_validations";
380
- action: "create" | "read" | "request_approval";
251
+ action: "create" | "read" | "lock" | "request_approval";
381
252
  resources: {
382
253
  agency_ids: string[];
383
254
  };
@@ -386,30 +257,38 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
386
257
  action: "read_links" | "read_wiki";
387
258
  } | {
388
259
  scope: "organizations";
389
- action: "create" | "update" | "delete" | "read";
260
+ action: "create" | "update" | "delete" | "read" | "lock";
390
261
  } | {
391
262
  scope: "performance";
392
263
  action: "read";
393
264
  } | {
394
265
  scope: "plans";
395
- action: "create" | "update" | "delete" | "read" | "toggle_lock" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy";
266
+ action: "create" | "update" | "delete" | "read" | "lock" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy";
396
267
  resources: {
397
268
  agency_ids: string[];
398
269
  };
399
270
  } | {
400
271
  scope: "roles";
401
- action: "create" | "update" | "delete" | "read";
272
+ action: "create" | "update" | "delete" | "read" | "lock";
402
273
  } | {
403
274
  scope: "stops";
404
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
275
+ action: "create" | "update" | "delete" | "read" | "lock";
405
276
  resources: {
406
277
  municipality_ids: string[];
407
278
  agency_ids: string[];
408
279
  };
409
280
  } | {
410
281
  scope: "users";
411
- action: "create" | "update" | "delete" | "read";
282
+ action: "create" | "update" | "delete" | "read" | "lock";
283
+ } | {
284
+ scope: "dates";
285
+ action: "create_annotations" | "delete_annotations" | "read_annotations" | "update_annotations" | "lock_annotations";
286
+ resources: {
287
+ agency_ids: string[];
288
+ };
412
289
  })[];
290
+ session_ids: any;
291
+ verification_token_ids: any;
413
292
  created_at: number & {
414
293
  __brand: "UnixTimestamp";
415
294
  };
@@ -418,16 +297,16 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
418
297
  __brand: "UnixTimestamp";
419
298
  };
420
299
  updated_by?: string | undefined;
300
+ is_locked: boolean;
421
301
  email: string;
422
302
  email_verified: import("@tmlmobilidade/types").UnixTimestamp | null;
423
303
  first_name: string;
424
304
  last_name: string;
425
- organization_id: string | null;
305
+ organization_id: string;
426
306
  phone: string | null;
427
307
  preferences: Record<string, Record<string, string | number | boolean | string[] | number[]>> | null;
428
308
  role_ids: string[];
429
- session_ids: string[];
430
- verification_token_ids: string[];
309
+ seen_last_at: import("@tmlmobilidade/types").UnixTimestamp | null;
431
310
  _id: string;
432
311
  }[]>;
433
312
  /**
@@ -439,13 +318,13 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
439
318
  password_hash: any;
440
319
  permissions: ({
441
320
  scope: "agencies";
442
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
321
+ action: "create" | "update" | "delete" | "read" | "lock";
443
322
  } | {
444
323
  scope: "alerts_scheduled";
445
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
324
+ action: "create" | "update" | "delete" | "read" | "lock";
446
325
  } | {
447
326
  scope: "alerts_realtime";
448
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
327
+ action: "create" | "update" | "delete" | "read" | "lock";
449
328
  resources: {
450
329
  agency_ids: string[];
451
330
  };
@@ -460,7 +339,7 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
460
339
  action: "read";
461
340
  } | {
462
341
  scope: "gtfs_validations";
463
- action: "create" | "read" | "request_approval";
342
+ action: "create" | "read" | "lock" | "request_approval";
464
343
  resources: {
465
344
  agency_ids: string[];
466
345
  };
@@ -469,30 +348,38 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
469
348
  action: "read_links" | "read_wiki";
470
349
  } | {
471
350
  scope: "organizations";
472
- action: "create" | "update" | "delete" | "read";
351
+ action: "create" | "update" | "delete" | "read" | "lock";
473
352
  } | {
474
353
  scope: "performance";
475
354
  action: "read";
476
355
  } | {
477
356
  scope: "plans";
478
- action: "create" | "update" | "delete" | "read" | "toggle_lock" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy";
357
+ action: "create" | "update" | "delete" | "read" | "lock" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy";
479
358
  resources: {
480
359
  agency_ids: string[];
481
360
  };
482
361
  } | {
483
362
  scope: "roles";
484
- action: "create" | "update" | "delete" | "read";
363
+ action: "create" | "update" | "delete" | "read" | "lock";
485
364
  } | {
486
365
  scope: "stops";
487
- action: "create" | "update" | "delete" | "read" | "toggle_lock";
366
+ action: "create" | "update" | "delete" | "read" | "lock";
488
367
  resources: {
489
368
  municipality_ids: string[];
490
369
  agency_ids: string[];
491
370
  };
492
371
  } | {
493
372
  scope: "users";
494
- action: "create" | "update" | "delete" | "read";
373
+ action: "create" | "update" | "delete" | "read" | "lock";
374
+ } | {
375
+ scope: "dates";
376
+ action: "create_annotations" | "delete_annotations" | "read_annotations" | "update_annotations" | "lock_annotations";
377
+ resources: {
378
+ agency_ids: string[];
379
+ };
495
380
  })[];
381
+ session_ids: any;
382
+ verification_token_ids: any;
496
383
  created_at: number & {
497
384
  __brand: "UnixTimestamp";
498
385
  };
@@ -501,16 +388,16 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
501
388
  __brand: "UnixTimestamp";
502
389
  };
503
390
  updated_by?: string | undefined;
391
+ is_locked: boolean;
504
392
  email: string;
505
393
  email_verified: import("@tmlmobilidade/types").UnixTimestamp | null;
506
394
  first_name: string;
507
395
  last_name: string;
508
- organization_id: string | null;
396
+ organization_id: string;
509
397
  phone: string | null;
510
398
  preferences: Record<string, Record<string, string | number | boolean | string[] | number[]>> | null;
511
399
  role_ids: string[];
512
- session_ids: string[];
513
- verification_token_ids: string[];
400
+ seen_last_at: import("@tmlmobilidade/types").UnixTimestamp | null;
514
401
  _id: string;
515
402
  }>;
516
403
  protected getCollectionIndexes(): IndexDescription[];
@@ -1,11 +1,11 @@
1
1
  /* * */
2
2
  import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
- import { PermissionCatalog, UpdateUserSchema, UserSchema } from '@tmlmobilidade/types';
3
+ import { CreateUserSchema, PermissionCatalog, UpdateUserSchema } from '@tmlmobilidade/types';
4
4
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
5
5
  /* * */
6
6
  class UsersClass extends MongoCollectionClass {
7
7
  static _instance;
8
- createSchema = UserSchema;
8
+ createSchema = CreateUserSchema;
9
9
  updateSchema = UpdateUserSchema;
10
10
  constructor() {
11
11
  super();
@@ -18,44 +18,30 @@ class UsersClass extends MongoCollectionClass {
18
18
  }
19
19
  return UsersClass._instance;
20
20
  }
21
- /**
22
- * Finds a user document by its email.
23
- * @param email The email of the user to find.
24
- * @param includePasswordHash - Whether to include the password hash in the result.
25
- * @returns A promise that resolves to the matching user document or null if not found.
26
- */
27
- async findByEmail(email, includePasswordHash = false) {
21
+ async findByEmail(email, options) {
28
22
  const foundUser = await this.mongoCollection.findOne({ email: { $eq: email } });
29
23
  if (!foundUser)
30
24
  return null;
31
- if (includePasswordHash)
25
+ if (options?.includeUnsafeProperties)
32
26
  return foundUser;
33
27
  return this.sanitizeUser(foundUser);
34
28
  }
35
- /**
36
- * Finds a user document by its ID.
37
- * @param id The ID of the user document to find
38
- * @param includePasswordHash Whether to include the password hash in the result
39
- * @returns A promise that resolves to the matching user document or null if not found
40
- */
41
- async findById(id, options, includePasswordHash = false) {
29
+ async findById(id, options) {
42
30
  const foundUser = await this.mongoCollection.findOne({ _id: id }, options);
43
31
  if (!foundUser)
44
32
  return null;
45
- if (includePasswordHash)
33
+ if (options?.includeUnsafeProperties)
46
34
  return foundUser;
47
35
  return this.sanitizeUser(foundUser);
48
36
  }
49
37
  /**
50
38
  * Finds users by their organization code.
51
39
  * @param code The code of the organization to find users for.
52
- * @param includePasswordHash Whether to include the password hash in the result.
40
+ * @param includeUnsafeProperties Whether to include the password hash in the result.
53
41
  * @returns A promise that resolves to the matching user documents or null if not found.
54
42
  */
55
- async findByOrganization(id, includePasswordHash = false) {
43
+ async findByOrganization(id) {
56
44
  const foundUsers = await this.mongoCollection.find({ organization_id: { $in: [id] } }).toArray();
57
- if (includePasswordHash)
58
- return foundUsers;
59
45
  return foundUsers.map(item => this.sanitizeUser(item));
60
46
  }
61
47
  /**
@@ -63,10 +49,8 @@ class UsersClass extends MongoCollectionClass {
63
49
  * @param role The role of the user to find.
64
50
  * @returns A promise that resolves to the matching user document or null if not found.
65
51
  */
66
- async findByRole(role, includePasswordHash = false) {
52
+ async findByRole(role) {
67
53
  const foundUsers = await this.mongoCollection.find({ role_ids: { $in: [role] } }).toArray();
68
- if (includePasswordHash)
69
- return foundUsers;
70
54
  return foundUsers.map(item => this.sanitizeUser(item));
71
55
  }
72
56
  /**
@@ -112,6 +96,8 @@ class UsersClass extends MongoCollectionClass {
112
96
  ...user,
113
97
  password_hash: null,
114
98
  permissions: PermissionCatalog.sanitize(user.permissions),
99
+ session_ids: null,
100
+ verification_token_ids: null,
115
101
  };
116
102
  }
117
103
  }