najm-auth 0.1.1 → 0.1.2

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.

Potentially problematic release.


This version of najm-auth might be problematic. Click here for more details.

Files changed (41) hide show
  1. package/dist/database/enums/index.d.ts +10 -0
  2. package/dist/database/schemas/index.d.ts +612 -0
  3. package/dist/guards/PermissionGuards.d.ts +9 -0
  4. package/dist/guards/RoleGuards.d.ts +45 -0
  5. package/{src/index.ts → dist/index.d.ts} +2 -46
  6. package/dist/index.js +4 -0
  7. package/dist/index.mjs +4 -0
  8. package/dist/repositories/PermissionRepository.d.ts +25 -0
  9. package/dist/repositories/RoleRepository.d.ts +19 -0
  10. package/dist/repositories/TokenRepository.d.ts +24 -0
  11. package/dist/services/AuthService.d.ts +27 -0
  12. package/dist/services/CookieService.d.ts +4 -0
  13. package/dist/services/EncryptionService.d.ts +5 -0
  14. package/dist/services/PermissionService.d.ts +23 -0
  15. package/dist/services/RoleService.d.ts +15 -0
  16. package/dist/services/TokenService.d.ts +24 -0
  17. package/dist/types/index.d.ts +94 -0
  18. package/dist/validators/PermissionValidator.d.ts +15 -0
  19. package/dist/validators/RoleValidator.d.ts +11 -0
  20. package/package.json +5 -1
  21. package/.claude/settings.local.json +0 -8
  22. package/.env.example +0 -6
  23. package/bun.lock +0 -648
  24. package/drizzle.config.ts +0 -24
  25. package/src/database/enums/index.ts +0 -47
  26. package/src/database/schemas/index.ts +0 -71
  27. package/src/guards/PermissionGuards.ts +0 -51
  28. package/src/guards/RoleGuards.ts +0 -104
  29. package/src/repositories/PermissionRepository.ts +0 -67
  30. package/src/repositories/RoleRepository.ts +0 -40
  31. package/src/repositories/TokenRepository.ts +0 -142
  32. package/src/services/AuthService.ts +0 -50
  33. package/src/services/CookieService.ts +0 -24
  34. package/src/services/EncryptionService.ts +0 -19
  35. package/src/services/PermissionService.ts +0 -113
  36. package/src/services/RoleService.ts +0 -62
  37. package/src/services/TokenService.ts +0 -158
  38. package/src/types/index.ts +0 -107
  39. package/src/validators/PermissionValidator.ts +0 -65
  40. package/src/validators/RoleValidator.ts +0 -48
  41. package/tsconfig.json +0 -16
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Auth-related PostgreSQL enums for najm-auth
3
+ * These enums define the core authentication and authorization types
4
+ */
5
+ export declare const userStatusEnum: import("drizzle-orm/pg-core").PgEnum<["active", "inactive", "pending"]>;
6
+ export declare const tokenStatusEnum: import("drizzle-orm/pg-core").PgEnum<["active", "revoked", "expired"]>;
7
+ export declare const tokenTypeEnum: import("drizzle-orm/pg-core").PgEnum<["access", "refresh"]>;
8
+ export declare const fileStatusEnum: import("drizzle-orm/pg-core").PgEnum<["active", "deleted", "archived"]>;
9
+ export declare const genderEnum: import("drizzle-orm/pg-core").PgEnum<["M", "F"]>;
10
+ export declare const languageEnum: import("drizzle-orm/pg-core").PgEnum<["en", "fr", "ar", "es"]>;
@@ -0,0 +1,612 @@
1
+ export declare const timestamps: {
2
+ createdAt: import("drizzle-orm").HasDefault<import("drizzle-orm/pg-core").PgTimestampStringBuilderInitial<"created_at">>;
3
+ updatedAt: import("drizzle-orm").HasDefault<import("drizzle-orm").HasDefault<import("drizzle-orm/pg-core").PgTimestampStringBuilderInitial<"updated_at">>>;
4
+ };
5
+ export declare const idField: (length?: number) => import("drizzle-orm").HasRuntimeDefault<import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"id", [string, ...string[]]>>>>>>;
6
+ export declare const roles: import("drizzle-orm/pg-core").PgTableWithColumns<{
7
+ name: "roles";
8
+ schema: undefined;
9
+ columns: {
10
+ id: import("drizzle-orm/pg-core").PgColumn<{
11
+ name: "id";
12
+ tableName: "roles";
13
+ dataType: "string";
14
+ columnType: "PgText";
15
+ data: string;
16
+ driverParam: string;
17
+ notNull: true;
18
+ hasDefault: true;
19
+ isPrimaryKey: true;
20
+ isAutoincrement: false;
21
+ hasRuntimeDefault: true;
22
+ enumValues: [string, ...string[]];
23
+ baseColumn: never;
24
+ identity: undefined;
25
+ generated: undefined;
26
+ }, {}, {}>;
27
+ name: import("drizzle-orm/pg-core").PgColumn<{
28
+ name: "name";
29
+ tableName: "roles";
30
+ dataType: "string";
31
+ columnType: "PgText";
32
+ data: string;
33
+ driverParam: string;
34
+ notNull: true;
35
+ hasDefault: false;
36
+ isPrimaryKey: false;
37
+ isAutoincrement: false;
38
+ hasRuntimeDefault: false;
39
+ enumValues: [string, ...string[]];
40
+ baseColumn: never;
41
+ identity: undefined;
42
+ generated: undefined;
43
+ }, {}, {}>;
44
+ description: import("drizzle-orm/pg-core").PgColumn<{
45
+ name: "description";
46
+ tableName: "roles";
47
+ dataType: "string";
48
+ columnType: "PgText";
49
+ data: string;
50
+ driverParam: string;
51
+ notNull: false;
52
+ hasDefault: false;
53
+ isPrimaryKey: false;
54
+ isAutoincrement: false;
55
+ hasRuntimeDefault: false;
56
+ enumValues: [string, ...string[]];
57
+ baseColumn: never;
58
+ identity: undefined;
59
+ generated: undefined;
60
+ }, {}, {}>;
61
+ };
62
+ dialect: "pg";
63
+ }>;
64
+ export declare const users: import("drizzle-orm/pg-core").PgTableWithColumns<{
65
+ name: "users";
66
+ schema: undefined;
67
+ columns: {
68
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
69
+ name: "created_at";
70
+ tableName: "users";
71
+ dataType: "string";
72
+ columnType: "PgTimestampString";
73
+ data: string;
74
+ driverParam: string;
75
+ notNull: false;
76
+ hasDefault: true;
77
+ isPrimaryKey: false;
78
+ isAutoincrement: false;
79
+ hasRuntimeDefault: false;
80
+ enumValues: undefined;
81
+ baseColumn: never;
82
+ identity: undefined;
83
+ generated: undefined;
84
+ }, {}, {}>;
85
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
86
+ name: "updated_at";
87
+ tableName: "users";
88
+ dataType: "string";
89
+ columnType: "PgTimestampString";
90
+ data: string;
91
+ driverParam: string;
92
+ notNull: false;
93
+ hasDefault: true;
94
+ isPrimaryKey: false;
95
+ isAutoincrement: false;
96
+ hasRuntimeDefault: false;
97
+ enumValues: undefined;
98
+ baseColumn: never;
99
+ identity: undefined;
100
+ generated: undefined;
101
+ }, {}, {}>;
102
+ id: import("drizzle-orm/pg-core").PgColumn<{
103
+ name: "id";
104
+ tableName: "users";
105
+ dataType: "string";
106
+ columnType: "PgText";
107
+ data: string;
108
+ driverParam: string;
109
+ notNull: true;
110
+ hasDefault: true;
111
+ isPrimaryKey: true;
112
+ isAutoincrement: false;
113
+ hasRuntimeDefault: true;
114
+ enumValues: [string, ...string[]];
115
+ baseColumn: never;
116
+ identity: undefined;
117
+ generated: undefined;
118
+ }, {}, {}>;
119
+ email: import("drizzle-orm/pg-core").PgColumn<{
120
+ name: "email";
121
+ tableName: "users";
122
+ dataType: "string";
123
+ columnType: "PgText";
124
+ data: string;
125
+ driverParam: string;
126
+ notNull: true;
127
+ hasDefault: false;
128
+ isPrimaryKey: false;
129
+ isAutoincrement: false;
130
+ hasRuntimeDefault: false;
131
+ enumValues: [string, ...string[]];
132
+ baseColumn: never;
133
+ identity: undefined;
134
+ generated: undefined;
135
+ }, {}, {}>;
136
+ emailVerified: import("drizzle-orm/pg-core").PgColumn<{
137
+ name: "email_verified";
138
+ tableName: "users";
139
+ dataType: "boolean";
140
+ columnType: "PgBoolean";
141
+ data: boolean;
142
+ driverParam: boolean;
143
+ notNull: false;
144
+ hasDefault: true;
145
+ isPrimaryKey: false;
146
+ isAutoincrement: false;
147
+ hasRuntimeDefault: false;
148
+ enumValues: undefined;
149
+ baseColumn: never;
150
+ identity: undefined;
151
+ generated: undefined;
152
+ }, {}, {}>;
153
+ password: import("drizzle-orm/pg-core").PgColumn<{
154
+ name: "password";
155
+ tableName: "users";
156
+ dataType: "string";
157
+ columnType: "PgText";
158
+ data: string;
159
+ driverParam: string;
160
+ notNull: true;
161
+ hasDefault: false;
162
+ isPrimaryKey: false;
163
+ isAutoincrement: false;
164
+ hasRuntimeDefault: false;
165
+ enumValues: [string, ...string[]];
166
+ baseColumn: never;
167
+ identity: undefined;
168
+ generated: undefined;
169
+ }, {}, {}>;
170
+ image: import("drizzle-orm/pg-core").PgColumn<{
171
+ name: "image";
172
+ tableName: "users";
173
+ dataType: "string";
174
+ columnType: "PgText";
175
+ data: string;
176
+ driverParam: string;
177
+ notNull: false;
178
+ hasDefault: true;
179
+ isPrimaryKey: false;
180
+ isAutoincrement: false;
181
+ hasRuntimeDefault: false;
182
+ enumValues: [string, ...string[]];
183
+ baseColumn: never;
184
+ identity: undefined;
185
+ generated: undefined;
186
+ }, {}, {}>;
187
+ status: import("drizzle-orm/pg-core").PgColumn<{
188
+ name: "status";
189
+ tableName: "users";
190
+ dataType: "string";
191
+ columnType: "PgEnumColumn";
192
+ data: "active" | "inactive" | "pending";
193
+ driverParam: string;
194
+ notNull: false;
195
+ hasDefault: true;
196
+ isPrimaryKey: false;
197
+ isAutoincrement: false;
198
+ hasRuntimeDefault: false;
199
+ enumValues: ["active", "inactive", "pending"];
200
+ baseColumn: never;
201
+ identity: undefined;
202
+ generated: undefined;
203
+ }, {}, {}>;
204
+ roleId: import("drizzle-orm/pg-core").PgColumn<{
205
+ name: "role_id";
206
+ tableName: "users";
207
+ dataType: "string";
208
+ columnType: "PgText";
209
+ data: string;
210
+ driverParam: string;
211
+ notNull: false;
212
+ hasDefault: false;
213
+ isPrimaryKey: false;
214
+ isAutoincrement: false;
215
+ hasRuntimeDefault: false;
216
+ enumValues: [string, ...string[]];
217
+ baseColumn: never;
218
+ identity: undefined;
219
+ generated: undefined;
220
+ }, {}, {}>;
221
+ lastLogin: import("drizzle-orm/pg-core").PgColumn<{
222
+ name: "last_login";
223
+ tableName: "users";
224
+ dataType: "string";
225
+ columnType: "PgTimestampString";
226
+ data: string;
227
+ driverParam: string;
228
+ notNull: false;
229
+ hasDefault: false;
230
+ isPrimaryKey: false;
231
+ isAutoincrement: false;
232
+ hasRuntimeDefault: false;
233
+ enumValues: undefined;
234
+ baseColumn: never;
235
+ identity: undefined;
236
+ generated: undefined;
237
+ }, {}, {}>;
238
+ };
239
+ dialect: "pg";
240
+ }>;
241
+ export declare const tokens: import("drizzle-orm/pg-core").PgTableWithColumns<{
242
+ name: "tokens";
243
+ schema: undefined;
244
+ columns: {
245
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
246
+ name: "created_at";
247
+ tableName: "tokens";
248
+ dataType: "string";
249
+ columnType: "PgTimestampString";
250
+ data: string;
251
+ driverParam: string;
252
+ notNull: false;
253
+ hasDefault: true;
254
+ isPrimaryKey: false;
255
+ isAutoincrement: false;
256
+ hasRuntimeDefault: false;
257
+ enumValues: undefined;
258
+ baseColumn: never;
259
+ identity: undefined;
260
+ generated: undefined;
261
+ }, {}, {}>;
262
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
263
+ name: "updated_at";
264
+ tableName: "tokens";
265
+ dataType: "string";
266
+ columnType: "PgTimestampString";
267
+ data: string;
268
+ driverParam: string;
269
+ notNull: false;
270
+ hasDefault: true;
271
+ isPrimaryKey: false;
272
+ isAutoincrement: false;
273
+ hasRuntimeDefault: false;
274
+ enumValues: undefined;
275
+ baseColumn: never;
276
+ identity: undefined;
277
+ generated: undefined;
278
+ }, {}, {}>;
279
+ id: import("drizzle-orm/pg-core").PgColumn<{
280
+ name: "id";
281
+ tableName: "tokens";
282
+ dataType: "string";
283
+ columnType: "PgText";
284
+ data: string;
285
+ driverParam: string;
286
+ notNull: true;
287
+ hasDefault: true;
288
+ isPrimaryKey: true;
289
+ isAutoincrement: false;
290
+ hasRuntimeDefault: true;
291
+ enumValues: [string, ...string[]];
292
+ baseColumn: never;
293
+ identity: undefined;
294
+ generated: undefined;
295
+ }, {}, {}>;
296
+ userId: import("drizzle-orm/pg-core").PgColumn<{
297
+ name: "user_id";
298
+ tableName: "tokens";
299
+ dataType: "string";
300
+ columnType: "PgText";
301
+ data: string;
302
+ driverParam: string;
303
+ notNull: true;
304
+ hasDefault: false;
305
+ isPrimaryKey: false;
306
+ isAutoincrement: false;
307
+ hasRuntimeDefault: false;
308
+ enumValues: [string, ...string[]];
309
+ baseColumn: never;
310
+ identity: undefined;
311
+ generated: undefined;
312
+ }, {}, {}>;
313
+ token: import("drizzle-orm/pg-core").PgColumn<{
314
+ name: "token";
315
+ tableName: "tokens";
316
+ dataType: "string";
317
+ columnType: "PgText";
318
+ data: string;
319
+ driverParam: string;
320
+ notNull: true;
321
+ hasDefault: false;
322
+ isPrimaryKey: false;
323
+ isAutoincrement: false;
324
+ hasRuntimeDefault: false;
325
+ enumValues: [string, ...string[]];
326
+ baseColumn: never;
327
+ identity: undefined;
328
+ generated: undefined;
329
+ }, {}, {}>;
330
+ type: import("drizzle-orm/pg-core").PgColumn<{
331
+ name: "type";
332
+ tableName: "tokens";
333
+ dataType: "string";
334
+ columnType: "PgEnumColumn";
335
+ data: "access" | "refresh";
336
+ driverParam: string;
337
+ notNull: false;
338
+ hasDefault: true;
339
+ isPrimaryKey: false;
340
+ isAutoincrement: false;
341
+ hasRuntimeDefault: false;
342
+ enumValues: ["access", "refresh"];
343
+ baseColumn: never;
344
+ identity: undefined;
345
+ generated: undefined;
346
+ }, {}, {}>;
347
+ status: import("drizzle-orm/pg-core").PgColumn<{
348
+ name: "status";
349
+ tableName: "tokens";
350
+ dataType: "string";
351
+ columnType: "PgEnumColumn";
352
+ data: "active" | "revoked" | "expired";
353
+ driverParam: string;
354
+ notNull: false;
355
+ hasDefault: true;
356
+ isPrimaryKey: false;
357
+ isAutoincrement: false;
358
+ hasRuntimeDefault: false;
359
+ enumValues: ["active", "revoked", "expired"];
360
+ baseColumn: never;
361
+ identity: undefined;
362
+ generated: undefined;
363
+ }, {}, {}>;
364
+ expiresAt: import("drizzle-orm/pg-core").PgColumn<{
365
+ name: "expires_at";
366
+ tableName: "tokens";
367
+ dataType: "string";
368
+ columnType: "PgTimestampString";
369
+ data: string;
370
+ driverParam: string;
371
+ notNull: true;
372
+ hasDefault: false;
373
+ isPrimaryKey: false;
374
+ isAutoincrement: false;
375
+ hasRuntimeDefault: false;
376
+ enumValues: undefined;
377
+ baseColumn: never;
378
+ identity: undefined;
379
+ generated: undefined;
380
+ }, {}, {}>;
381
+ };
382
+ dialect: "pg";
383
+ }>;
384
+ export declare const permissions: import("drizzle-orm/pg-core").PgTableWithColumns<{
385
+ name: "permissions";
386
+ schema: undefined;
387
+ columns: {
388
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
389
+ name: "created_at";
390
+ tableName: "permissions";
391
+ dataType: "string";
392
+ columnType: "PgTimestampString";
393
+ data: string;
394
+ driverParam: string;
395
+ notNull: false;
396
+ hasDefault: true;
397
+ isPrimaryKey: false;
398
+ isAutoincrement: false;
399
+ hasRuntimeDefault: false;
400
+ enumValues: undefined;
401
+ baseColumn: never;
402
+ identity: undefined;
403
+ generated: undefined;
404
+ }, {}, {}>;
405
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
406
+ name: "updated_at";
407
+ tableName: "permissions";
408
+ dataType: "string";
409
+ columnType: "PgTimestampString";
410
+ data: string;
411
+ driverParam: string;
412
+ notNull: false;
413
+ hasDefault: true;
414
+ isPrimaryKey: false;
415
+ isAutoincrement: false;
416
+ hasRuntimeDefault: false;
417
+ enumValues: undefined;
418
+ baseColumn: never;
419
+ identity: undefined;
420
+ generated: undefined;
421
+ }, {}, {}>;
422
+ id: import("drizzle-orm/pg-core").PgColumn<{
423
+ name: "id";
424
+ tableName: "permissions";
425
+ dataType: "string";
426
+ columnType: "PgText";
427
+ data: string;
428
+ driverParam: string;
429
+ notNull: true;
430
+ hasDefault: true;
431
+ isPrimaryKey: true;
432
+ isAutoincrement: false;
433
+ hasRuntimeDefault: true;
434
+ enumValues: [string, ...string[]];
435
+ baseColumn: never;
436
+ identity: undefined;
437
+ generated: undefined;
438
+ }, {}, {}>;
439
+ name: import("drizzle-orm/pg-core").PgColumn<{
440
+ name: "name";
441
+ tableName: "permissions";
442
+ dataType: "string";
443
+ columnType: "PgText";
444
+ data: string;
445
+ driverParam: string;
446
+ notNull: true;
447
+ hasDefault: false;
448
+ isPrimaryKey: false;
449
+ isAutoincrement: false;
450
+ hasRuntimeDefault: false;
451
+ enumValues: [string, ...string[]];
452
+ baseColumn: never;
453
+ identity: undefined;
454
+ generated: undefined;
455
+ }, {}, {}>;
456
+ description: import("drizzle-orm/pg-core").PgColumn<{
457
+ name: "description";
458
+ tableName: "permissions";
459
+ dataType: "string";
460
+ columnType: "PgText";
461
+ data: string;
462
+ driverParam: string;
463
+ notNull: false;
464
+ hasDefault: false;
465
+ isPrimaryKey: false;
466
+ isAutoincrement: false;
467
+ hasRuntimeDefault: false;
468
+ enumValues: [string, ...string[]];
469
+ baseColumn: never;
470
+ identity: undefined;
471
+ generated: undefined;
472
+ }, {}, {}>;
473
+ resource: import("drizzle-orm/pg-core").PgColumn<{
474
+ name: "resource";
475
+ tableName: "permissions";
476
+ dataType: "string";
477
+ columnType: "PgText";
478
+ data: string;
479
+ driverParam: string;
480
+ notNull: true;
481
+ hasDefault: false;
482
+ isPrimaryKey: false;
483
+ isAutoincrement: false;
484
+ hasRuntimeDefault: false;
485
+ enumValues: [string, ...string[]];
486
+ baseColumn: never;
487
+ identity: undefined;
488
+ generated: undefined;
489
+ }, {}, {}>;
490
+ action: import("drizzle-orm/pg-core").PgColumn<{
491
+ name: "action";
492
+ tableName: "permissions";
493
+ dataType: "string";
494
+ columnType: "PgText";
495
+ data: string;
496
+ driverParam: string;
497
+ notNull: true;
498
+ hasDefault: false;
499
+ isPrimaryKey: false;
500
+ isAutoincrement: false;
501
+ hasRuntimeDefault: false;
502
+ enumValues: [string, ...string[]];
503
+ baseColumn: never;
504
+ identity: undefined;
505
+ generated: undefined;
506
+ }, {}, {}>;
507
+ };
508
+ dialect: "pg";
509
+ }>;
510
+ export declare const rolePermissions: import("drizzle-orm/pg-core").PgTableWithColumns<{
511
+ name: "role_permissions";
512
+ schema: undefined;
513
+ columns: {
514
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
515
+ name: "created_at";
516
+ tableName: "role_permissions";
517
+ dataType: "string";
518
+ columnType: "PgTimestampString";
519
+ data: string;
520
+ driverParam: string;
521
+ notNull: false;
522
+ hasDefault: true;
523
+ isPrimaryKey: false;
524
+ isAutoincrement: false;
525
+ hasRuntimeDefault: false;
526
+ enumValues: undefined;
527
+ baseColumn: never;
528
+ identity: undefined;
529
+ generated: undefined;
530
+ }, {}, {}>;
531
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
532
+ name: "updated_at";
533
+ tableName: "role_permissions";
534
+ dataType: "string";
535
+ columnType: "PgTimestampString";
536
+ data: string;
537
+ driverParam: string;
538
+ notNull: false;
539
+ hasDefault: true;
540
+ isPrimaryKey: false;
541
+ isAutoincrement: false;
542
+ hasRuntimeDefault: false;
543
+ enumValues: undefined;
544
+ baseColumn: never;
545
+ identity: undefined;
546
+ generated: undefined;
547
+ }, {}, {}>;
548
+ id: import("drizzle-orm/pg-core").PgColumn<{
549
+ name: "id";
550
+ tableName: "role_permissions";
551
+ dataType: "string";
552
+ columnType: "PgText";
553
+ data: string;
554
+ driverParam: string;
555
+ notNull: true;
556
+ hasDefault: true;
557
+ isPrimaryKey: true;
558
+ isAutoincrement: false;
559
+ hasRuntimeDefault: true;
560
+ enumValues: [string, ...string[]];
561
+ baseColumn: never;
562
+ identity: undefined;
563
+ generated: undefined;
564
+ }, {}, {}>;
565
+ roleId: import("drizzle-orm/pg-core").PgColumn<{
566
+ name: "role_id";
567
+ tableName: "role_permissions";
568
+ dataType: "string";
569
+ columnType: "PgText";
570
+ data: string;
571
+ driverParam: string;
572
+ notNull: true;
573
+ hasDefault: false;
574
+ isPrimaryKey: false;
575
+ isAutoincrement: false;
576
+ hasRuntimeDefault: false;
577
+ enumValues: [string, ...string[]];
578
+ baseColumn: never;
579
+ identity: undefined;
580
+ generated: undefined;
581
+ }, {}, {}>;
582
+ permissionId: import("drizzle-orm/pg-core").PgColumn<{
583
+ name: "permission_id";
584
+ tableName: "role_permissions";
585
+ dataType: "string";
586
+ columnType: "PgText";
587
+ data: string;
588
+ driverParam: string;
589
+ notNull: true;
590
+ hasDefault: false;
591
+ isPrimaryKey: false;
592
+ isAutoincrement: false;
593
+ hasRuntimeDefault: false;
594
+ enumValues: [string, ...string[]];
595
+ baseColumn: never;
596
+ identity: undefined;
597
+ generated: undefined;
598
+ }, {}, {}>;
599
+ };
600
+ dialect: "pg";
601
+ }>;
602
+ export type User = typeof users.$inferSelect;
603
+ export type NewUser = typeof users.$inferInsert;
604
+ export type Token = typeof tokens.$inferSelect;
605
+ export type NewToken = typeof tokens.$inferInsert;
606
+ export type Role = typeof roles.$inferSelect;
607
+ export type NewRole = typeof roles.$inferInsert;
608
+ export type Permission = typeof permissions.$inferSelect;
609
+ export type NewPermission = typeof permissions.$inferInsert;
610
+ export type RolePermission = typeof rolePermissions.$inferSelect;
611
+ export type NewRolePermission = typeof rolePermissions.$inferInsert;
612
+ export * from '../enums';
@@ -0,0 +1,9 @@
1
+ import { TokenService } from '../services/TokenService';
2
+ export declare class PermissionGuards {
3
+ private tokenService;
4
+ constructor(tokenService: TokenService);
5
+ private getUserPermissions;
6
+ private checkPermissionMatch;
7
+ hasPermission(auth: string, ctx: any, requiredPermission: string): Promise<boolean>;
8
+ }
9
+ export declare const Permission: (...permissions: string[]) => (target: any, propertyKey?: string) => void;
@@ -0,0 +1,45 @@
1
+ import { TokenService } from '../services/TokenService';
2
+ export declare const ROLES: {
3
+ readonly ADMIN: "admin";
4
+ readonly PRINCIPAL: "principal";
5
+ readonly ACCOUNTING: "accounting";
6
+ readonly SECRETARY: "secretary";
7
+ readonly TEACHER: "teacher";
8
+ readonly STUDENT: "student";
9
+ readonly PARENT: "parent";
10
+ };
11
+ export declare const ROLE_GROUPS: {
12
+ readonly ADMINISTRATORS: readonly ["admin", "principal"];
13
+ readonly FINANCIAL: readonly ["admin", "accounting"];
14
+ readonly STAFF: readonly ["admin", "principal", "accounting", "secretary", "teacher"];
15
+ readonly END_USERS: readonly ["student", "parent"];
16
+ readonly ALL: readonly ["admin", "principal", "accounting", "secretary", "teacher", "student", "parent"];
17
+ };
18
+ export type Role = (typeof ROLES)[keyof typeof ROLES];
19
+ export type RoleGroup = (typeof ROLE_GROUPS)[keyof typeof ROLE_GROUPS];
20
+ export declare class RoleChecker {
21
+ isInGroup(userRole: string, group: readonly string[]): boolean;
22
+ isAdministrator(userRole: string): boolean;
23
+ isStaff(userRole: string): boolean;
24
+ hasAnyRole(userRole: string, roles: readonly string[]): boolean;
25
+ hasExactRole(userRole: string, requiredRole: string): boolean;
26
+ }
27
+ export declare class RoleGuards {
28
+ private roleChecker;
29
+ private tokenService;
30
+ constructor(roleChecker: RoleChecker, tokenService: TokenService);
31
+ isAuth(auth: string, ctx: any): Promise<boolean>;
32
+ hasRoles(auth: string, ctx: any, roles: string | string[]): Promise<boolean>;
33
+ }
34
+ export declare const isAdmin: () => (target: any, propertyKey?: string) => void;
35
+ export declare const isPrincipal: () => (target: any, propertyKey?: string) => void;
36
+ export declare const isAccounting: () => (target: any, propertyKey?: string) => void;
37
+ export declare const isSecretary: () => (target: any, propertyKey?: string) => void;
38
+ export declare const isTeacher: () => (target: any, propertyKey?: string) => void;
39
+ export declare const isParent: () => (target: any, propertyKey?: string) => void;
40
+ export declare const isStudent: () => (target: any, propertyKey?: string) => void;
41
+ export declare const isAdministrator: () => (target: any, propertyKey?: string) => void;
42
+ export declare const isFinancial: () => (target: any, propertyKey?: string) => void;
43
+ export declare const isStaff: () => (target: any, propertyKey?: string) => void;
44
+ export declare const isAuth: (...params: any[]) => (target: any, propertyKey?: string) => void;
45
+ export declare const Role: (...roles: string[]) => (target: any, propertyKey?: string) => void;