alepha 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +47 -44
  3. package/batch.d.ts +87 -88
  4. package/bucket.cjs +8 -0
  5. package/bucket.d.ts +194 -0
  6. package/bucket.js +1 -0
  7. package/cache/redis.d.ts +14 -16
  8. package/cache.d.ts +101 -170
  9. package/command.d.ts +70 -77
  10. package/core.d.ts +1043 -887
  11. package/datetime.d.ts +91 -117
  12. package/file.cjs +8 -0
  13. package/file.d.ts +56 -0
  14. package/file.js +1 -0
  15. package/lock/redis.d.ts +11 -13
  16. package/lock.d.ts +125 -117
  17. package/package.json +66 -38
  18. package/postgres.d.ts +232 -275
  19. package/queue/redis.d.ts +13 -15
  20. package/queue.d.ts +88 -116
  21. package/react/auth.d.ts +50 -55
  22. package/react/head.d.ts +5 -8
  23. package/react.d.ts +71 -73
  24. package/redis.d.ts +32 -14
  25. package/retry.d.ts +70 -58
  26. package/router.cjs +8 -0
  27. package/router.d.ts +45 -0
  28. package/router.js +1 -0
  29. package/scheduler.d.ts +54 -96
  30. package/security.d.ts +117 -119
  31. package/server/cache.d.ts +22 -31
  32. package/server/compress.d.ts +16 -7
  33. package/server/cookies.d.ts +70 -61
  34. package/server/cors.d.ts +15 -13
  35. package/server/health.d.ts +23 -26
  36. package/server/helmet.d.ts +17 -20
  37. package/server/links.d.ts +113 -90
  38. package/server/metrics.d.ts +25 -23
  39. package/server/multipart.d.ts +12 -16
  40. package/server/proxy.d.ts +25 -20
  41. package/server/security.cjs +8 -0
  42. package/server/security.d.ts +90 -0
  43. package/server/security.js +1 -0
  44. package/server/static.d.ts +67 -68
  45. package/server/swagger.d.ts +77 -65
  46. package/server.d.ts +265 -308
  47. package/topic/redis.d.ts +25 -26
  48. package/topic.d.ts +76 -122
  49. package/vite.d.ts +52 -36
package/scheduler.d.ts CHANGED
@@ -1,21 +1,55 @@
1
- import * as _alepha_core9 from "alepha";
1
+ import * as _alepha_core4 from "alepha";
2
+ import * as _alepha_core0$1 from "alepha";
2
3
  import * as _alepha_core0 from "alepha";
3
- import { Alepha, Async, KIND, OPTIONS, Static } from "alepha";
4
- import * as _alepha_lock8 from "alepha/lock";
5
- import { DateTime, DateTimeProvider, DurationLike, Interval } from "alepha/datetime";
4
+ import { Alepha, Async, Descriptor, KIND, Static } from "alepha";
5
+ import * as _alepha_lock0 from "alepha/lock";
6
+ import { DateTime, DateTimeProvider, DurationLike } from "alepha/datetime";
6
7
  import { Cron } from "cron-schedule";
7
- import * as dayjs10 from "dayjs";
8
+ import * as dayjs0 from "dayjs";
8
9
 
10
+ //#region src/providers/CronProvider.d.ts
11
+ declare class CronProvider {
12
+ protected readonly dt: DateTimeProvider;
13
+ protected readonly alepha: Alepha;
14
+ protected readonly log: _alepha_core4.Logger;
15
+ protected readonly cronJobs: Array<CronJob>;
16
+ getCronJobs(): Array<CronJob>;
17
+ protected readonly start: _alepha_core4.HookDescriptor<"start">;
18
+ protected readonly stop: _alepha_core4.HookDescriptor<"stop">;
19
+ protected boot(name: string | CronJob): void;
20
+ abort(name: string | CronJob): void;
21
+ /**
22
+ * Registers a cron job.
23
+ *
24
+ * It's automatically done when using the `$scheduler` descriptor but can also be used manually.
25
+ */
26
+ createCronJob(name: string, expression: string, handler: (context: {
27
+ now: DateTime;
28
+ }) => Promise<void>, start?: boolean): void;
29
+ protected run(task: CronJob, now?: dayjs0.Dayjs): void;
30
+ }
31
+ interface CronJob {
32
+ name: string;
33
+ expression: string;
34
+ handler: (context: {
35
+ now: DateTime;
36
+ }) => Promise<void>;
37
+ cron: Cron;
38
+ loop: boolean;
39
+ running?: boolean;
40
+ onError?: (error: Error) => void;
41
+ abort: AbortController;
42
+ }
43
+ //# sourceMappingURL=CronProvider.d.ts.map
44
+ //#endregion
9
45
  //#region src/descriptors/$scheduler.d.ts
10
- declare const KEY = "SCHEDULER";
11
46
  /**
12
47
  * Scheduler descriptor.
13
48
  */
14
49
  declare const $scheduler: {
15
50
  (options: SchedulerDescriptorOptions): SchedulerDescriptor;
16
- [KIND]: string;
51
+ [KIND]: typeof SchedulerDescriptor;
17
52
  };
18
- declare const isScheduler: (value: any) => value is SchedulerDescriptor;
19
53
  type SchedulerDescriptorOptions = {
20
54
  /**
21
55
  * Function to run on schedule.
@@ -45,117 +79,41 @@ type SchedulerDescriptorOptions = {
45
79
  */
46
80
  lock?: boolean;
47
81
  };
48
- interface SchedulerDescriptor {
49
- [KIND]: typeof KEY;
50
- [OPTIONS]: SchedulerDescriptorOptions;
51
- (): Promise<void>;
52
- }
53
- interface SchedulerHandlerArguments {
54
- now: DateTime;
55
- }
56
- //#endregion
57
- //#region src/providers/CronScheduler.d.ts
58
- interface CronJob {
59
- handler: (context: {
60
- now: DateTime;
61
- }) => Promise<void>;
62
- cron: Cron;
63
- loop: boolean;
64
- running?: boolean;
65
- onError?: (error: Error) => void;
66
- abort: AbortController;
67
- }
68
- declare class CronProvider {
69
- protected readonly dt: DateTimeProvider;
70
- protected readonly alepha: Alepha;
71
- protected readonly log: _alepha_core9.Logger;
72
- start(cron: CronJob): void;
73
- stop(cron: CronJob): void;
74
- create(expression: string, handler: (context: {
75
- now: DateTime;
76
- }) => Promise<void>): CronJob;
77
- run(task: CronJob, now?: dayjs10.Dayjs): void;
78
- }
79
- //# sourceMappingURL=CronScheduler.d.ts.map
80
- //#endregion
81
- //#region src/providers/SchedulerDescriptorProvider.d.ts
82
- declare const envSchema: _alepha_core0.TObject<{
83
- SCHEDULER_PREFIX: _alepha_core0.TOptional<_alepha_core0.TString>;
82
+ declare const envSchema: _alepha_core0$1.TObject<{
83
+ SCHEDULER_PREFIX: _alepha_core0$1.TOptional<_alepha_core0$1.TString>;
84
84
  }>;
85
85
  declare module "alepha" {
86
86
  interface Env extends Partial<Static<typeof envSchema>> {}
87
87
  }
88
- declare class SchedulerDescriptorProvider {
89
- protected readonly log: _alepha_core0.Logger;
88
+ declare class SchedulerDescriptor extends Descriptor<SchedulerDescriptorOptions> {
89
+ protected readonly log: _alepha_core0$1.Logger;
90
90
  protected readonly env: {
91
91
  SCHEDULER_PREFIX?: string | undefined;
92
92
  };
93
93
  protected readonly alepha: Alepha;
94
94
  protected readonly dateTimeProvider: DateTimeProvider;
95
95
  protected readonly cronProvider: CronProvider;
96
- protected readonly schedulers: Scheduler[];
97
- protected readonly configure: _alepha_core0.HookDescriptor<"configure">;
98
- protected readonly start: _alepha_core0.HookDescriptor<"start">;
99
- protected readonly stop: _alepha_core0.HookDescriptor<"stop">;
100
- /**
101
- * Get the schedulers.
102
- */
103
- getSchedulers(): Scheduler[];
104
- /**
105
- * Process scheduler descriptors.
106
- *
107
- * @protected
108
- */
109
- protected processSchedulerDescriptors(): void;
110
- /**
111
- * Create a scheduler.
112
- *
113
- * @param options - The scheduler options.
114
- * @param instance - The instance of the scheduler.
115
- * @param key - Property key name.
116
- * @protected
117
- */
118
- protected createScheduler(options: SchedulerDescriptorOptions, instance: any, key: string): Scheduler;
119
- protected createHandler(name: string, options: SchedulerDescriptorOptions): (args: SchedulerHandlerArguments) => Promise<void>;
120
- trigger(name: string): Promise<void>;
121
- protected runLock: _alepha_lock8.LockDescriptor<(options: SchedulerDescriptorOptions & {
122
- name: string;
123
- args: SchedulerHandlerArguments;
124
- }) => Promise<void>>;
125
- /**
126
- * Prefix the scheduler key.
127
- */
96
+ get name(): string;
97
+ protected onInit(): void;
98
+ trigger(): Promise<void>;
99
+ protected schedulerLock: _alepha_lock0.LockDescriptor<(args: SchedulerHandlerArguments) => Promise<void>>;
128
100
  protected prefix(key: string): string;
129
- /**
130
- *
131
- * @param options
132
- * @protected
133
- */
134
101
  protected getLockGracePeriod(options: SchedulerDescriptorOptions): number;
135
102
  }
136
- interface Scheduler {
137
- name: string;
138
- options: SchedulerDescriptorOptions;
139
- trigger: (args: SchedulerHandlerArguments) => Promise<void>;
140
- cron?: CronJob;
141
- interval?: Interval;
103
+ interface SchedulerHandlerArguments {
104
+ now: DateTime;
142
105
  }
143
106
  //#endregion
144
107
  //#region src/index.d.ts
145
108
  /**
146
- * Alepha Scheduler Module
147
- *
148
109
  * Generic interface for scheduling tasks.
149
110
  *
150
111
  * @see {@link $scheduler}
151
112
  * @module alepha.scheduler
152
113
  */
153
- declare class AlephaScheduler {
154
- readonly name = "alepha.scheduler";
155
- readonly $services: (alepha: Alepha) => Alepha;
156
- }
114
+ declare const AlephaScheduler: _alepha_core0.ModuleDescriptor;
157
115
  //# sourceMappingURL=index.d.ts.map
158
116
 
159
117
  //#endregion
160
- export { $scheduler, AlephaScheduler, Scheduler, SchedulerDescriptor, SchedulerDescriptorOptions, SchedulerDescriptorProvider, SchedulerHandlerArguments, isScheduler };
118
+ export { $scheduler, AlephaScheduler, SchedulerDescriptor, SchedulerDescriptorOptions, SchedulerHandlerArguments };
161
119
  //# sourceMappingURL=index.d.ts.map
package/security.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import * as _alepha_core15 from "alepha";
2
- import * as _alepha_core16 from "alepha";
3
- import { Alepha, KIND, OPTIONS, Static } from "alepha";
1
+ import * as _alepha_core0$1 from "alepha";
2
+ import * as _alepha_core1 from "alepha";
3
+ import * as _alepha_core0 from "alepha";
4
+ import { Alepha, Descriptor, KIND, Static } from "alepha";
4
5
  import { DateTimeProvider } from "alepha/datetime";
5
6
  import { CryptoKey, FlattenedJWSInput, JSONWebKeySet, JWSHeaderParameters, JWTHeaderParameters, JWTPayload, JWTVerifyResult, KeyObject } from "jose";
6
- import * as _sinclair_typebox22 from "@sinclair/typebox";
7
- import * as _sinclair_typebox1 from "@sinclair/typebox";
7
+ import * as _sinclair_typebox13 from "@sinclair/typebox";
8
+ import * as _sinclair_typebox0 from "@sinclair/typebox";
8
9
 
9
10
  //#region src/interfaces/UserAccountInfo.d.ts
10
11
  /**
@@ -38,58 +39,6 @@ interface UserAccountInfo {
38
39
  }
39
40
  //# sourceMappingURL=UserAccountInfo.d.ts.map
40
41
  //#endregion
41
- //#region src/schemas/permissionSchema.d.ts
42
- declare const permissionSchema: _sinclair_typebox22.TObject<{
43
- name: _sinclair_typebox22.TString;
44
- group: _sinclair_typebox22.TOptional<_sinclair_typebox22.TString>;
45
- description: _sinclair_typebox22.TOptional<_sinclair_typebox22.TString>;
46
- method: _sinclair_typebox22.TOptional<_sinclair_typebox22.TString>;
47
- path: _sinclair_typebox22.TOptional<_sinclair_typebox22.TString>;
48
- }>;
49
- type Permission = Static<typeof permissionSchema>;
50
- //# sourceMappingURL=permissionSchema.d.ts.map
51
- //#endregion
52
- //#region src/descriptors/$permission.d.ts
53
- declare const KEY$2 = "PERMISSION";
54
- interface PermissionDescriptorOptions {
55
- /**
56
- * Name of the permission. Use Property name is not provided.
57
- */
58
- name?: string;
59
- /**
60
- * Group of the permission. Use Class name is not provided.
61
- */
62
- group?: string;
63
- /**
64
- * Describe the permission.
65
- */
66
- description?: string;
67
- /**
68
- * HTTP method of the permission. When available.
69
- */
70
- method?: string;
71
- /**
72
- * URL of the permission. When available.
73
- */
74
- url?: string;
75
- }
76
- interface PermissionDescriptor {
77
- [KIND]: typeof KEY$2;
78
- [OPTIONS]: PermissionDescriptorOptions;
79
- /**
80
- * Get the permission object.
81
- */
82
- (): Permission;
83
- /**
84
- * Check if the user has the permission.
85
- */
86
- can(user: UserAccountInfo): boolean;
87
- }
88
- declare const $permission: {
89
- (options?: PermissionDescriptorOptions): PermissionDescriptor;
90
- [KIND]: string;
91
- };
92
- //#endregion
93
42
  //#region src/interfaces/UserAccountToken.d.ts
94
43
  interface UserAccountToken extends UserAccountInfo {
95
44
  /**
@@ -105,15 +54,26 @@ interface UserAccountToken extends UserAccountInfo {
105
54
  }
106
55
  //# sourceMappingURL=UserAccountToken.d.ts.map
107
56
  //#endregion
57
+ //#region src/schemas/permissionSchema.d.ts
58
+ declare const permissionSchema: _sinclair_typebox13.TObject<{
59
+ name: _sinclair_typebox13.TString;
60
+ group: _sinclair_typebox13.TOptional<_sinclair_typebox13.TString>;
61
+ description: _sinclair_typebox13.TOptional<_sinclair_typebox13.TString>;
62
+ method: _sinclair_typebox13.TOptional<_sinclair_typebox13.TString>;
63
+ path: _sinclair_typebox13.TOptional<_sinclair_typebox13.TString>;
64
+ }>;
65
+ type Permission = Static<typeof permissionSchema>;
66
+ //# sourceMappingURL=permissionSchema.d.ts.map
67
+ //#endregion
108
68
  //#region src/schemas/roleSchema.d.ts
109
- declare const roleSchema: _sinclair_typebox1.TObject<{
110
- name: _sinclair_typebox1.TString;
111
- description: _sinclair_typebox1.TOptional<_sinclair_typebox1.TString>;
112
- default: _sinclair_typebox1.TOptional<_sinclair_typebox1.TBoolean>;
113
- permissions: _sinclair_typebox1.TArray<_sinclair_typebox1.TObject<{
114
- name: _sinclair_typebox1.TString;
115
- ownership: _sinclair_typebox1.TOptional<_sinclair_typebox1.TBoolean>;
116
- exclude: _sinclair_typebox1.TOptional<_sinclair_typebox1.TArray<_sinclair_typebox1.TString>>;
69
+ declare const roleSchema: _sinclair_typebox0.TObject<{
70
+ name: _sinclair_typebox0.TString;
71
+ description: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
72
+ default: _sinclair_typebox0.TOptional<_sinclair_typebox0.TBoolean>;
73
+ permissions: _sinclair_typebox0.TArray<_sinclair_typebox0.TObject<{
74
+ name: _sinclair_typebox0.TString;
75
+ ownership: _sinclair_typebox0.TOptional<_sinclair_typebox0.TBoolean>;
76
+ exclude: _sinclair_typebox0.TOptional<_sinclair_typebox0.TArray<_sinclair_typebox0.TString>>;
117
77
  }>>;
118
78
  }>;
119
79
  type Role = Static<typeof roleSchema>;
@@ -124,7 +84,7 @@ type Role = Static<typeof roleSchema>;
124
84
  * Provides utilities for working with JSON Web Tokens (JWT).
125
85
  */
126
86
  declare class JwtProvider {
127
- protected readonly log: _alepha_core15.Logger;
87
+ protected readonly log: _alepha_core0$1.Logger;
128
88
  protected readonly keystore: KeyLoaderHolder[];
129
89
  protected readonly dateTimeProvider: DateTimeProvider;
130
90
  /**
@@ -208,8 +168,8 @@ interface JwtParseResult {
208
168
  //# sourceMappingURL=JwtProvider.d.ts.map
209
169
  //#endregion
210
170
  //#region src/providers/SecurityProvider.d.ts
211
- declare const envSchema: _alepha_core16.TObject<{
212
- SECURITY_SECRET_KEY: _alepha_core16.TString;
171
+ declare const envSchema: _alepha_core1.TObject<{
172
+ SECURITY_SECRET_KEY: _alepha_core1.TString;
213
173
  }>;
214
174
  declare module "alepha" {
215
175
  interface Env extends Partial<Static<typeof envSchema>> {}
@@ -218,7 +178,7 @@ declare class SecurityProvider {
218
178
  protected readonly UNKNOWN_USER_NAME = "Unknown User";
219
179
  protected readonly PERMISSION_REGEXP: RegExp;
220
180
  protected readonly PERMISSION_REGEXP_WILDCARD: RegExp;
221
- protected readonly log: _alepha_core16.Logger;
181
+ protected readonly log: _alepha_core1.Logger;
222
182
  protected readonly jwt: JwtProvider;
223
183
  protected readonly env: {
224
184
  SECURITY_SECRET_KEY: string;
@@ -232,33 +192,8 @@ declare class SecurityProvider {
232
192
  * The realms configured for the security provider.
233
193
  */
234
194
  protected readonly realms: Realm[];
235
- /**
236
- * Create realms.
237
- */
238
- protected createRealms(): Realm[];
239
- protected configure: _alepha_core16.HookDescriptor<"configure">;
240
- /**
241
- * Processes all $permission descriptors.
242
- */
243
- protected processPermissionDescriptors(): void;
244
- /**
245
- * Processes all $realm descriptors.
246
- */
247
- protected processRealmDescriptors(): void;
248
- /**
249
- * Processes all $role descriptors.
250
- */
251
- protected processRoleDescriptors(): void;
252
- protected ready: _alepha_core16.HookDescriptor<"ready">;
253
- /**
254
- * Updates the roles for a realm then synchronizes the user account provider if available.
255
- *
256
- * Only available when the app is started.
257
- *
258
- * @param realm - The realm to update the roles for.
259
- * @param roles - The roles to update.
260
- */
261
- updateRealm(realm: string, roles: Role[]): Promise<void>;
195
+ protected configure: _alepha_core1.HookDescriptor<"configure">;
196
+ protected ready: _alepha_core1.HookDescriptor<"ready">;
262
197
  /**
263
198
  * Adds a role to one or more realms.
264
199
  *
@@ -272,6 +207,16 @@ declare class SecurityProvider {
272
207
  * @param raw - The permission to add.
273
208
  */
274
209
  createPermission(raw: Permission | string): Permission;
210
+ createRealm(realm: Realm): void;
211
+ /**
212
+ * Updates the roles for a realm then synchronizes the user account provider if available.
213
+ *
214
+ * Only available when the app is started.
215
+ *
216
+ * @param realm - The realm to update the roles for.
217
+ * @param roles - The roles to update.
218
+ */
219
+ updateRealm(realm: string, roles: Role[]): Promise<void>;
275
220
  /**
276
221
  * Creates a user account from the provided payload.
277
222
  *
@@ -296,7 +241,7 @@ declare class SecurityProvider {
296
241
  * @param headerOrToken
297
242
  * @param permissionLike
298
243
  */
299
- createUserFromToken(headerOrToken?: string, permissionLike?: Permission | string): Promise<UserAccountToken>;
244
+ createUserFromToken(headerOrToken?: string, permission?: Permission | string): Promise<UserAccountToken>;
300
245
  /**
301
246
  * Checks if a user has a specific role.
302
247
  *
@@ -392,8 +337,48 @@ interface RealmConfig {
392
337
  };
393
338
  }
394
339
  //#endregion
340
+ //#region src/descriptors/$permission.d.ts
341
+ /**
342
+ * Create a new permission.
343
+ */
344
+ declare const $permission: {
345
+ (options?: PermissionDescriptorOptions): PermissionDescriptor;
346
+ [KIND]: typeof PermissionDescriptor;
347
+ };
348
+ interface PermissionDescriptorOptions {
349
+ /**
350
+ * Name of the permission. Use Property name is not provided.
351
+ */
352
+ name?: string;
353
+ /**
354
+ * Group of the permission. Use Class name is not provided.
355
+ */
356
+ group?: string;
357
+ /**
358
+ * Describe the permission.
359
+ */
360
+ description?: string;
361
+ }
362
+ declare class PermissionDescriptor extends Descriptor<PermissionDescriptorOptions> {
363
+ protected readonly securityProvider: SecurityProvider;
364
+ get name(): string;
365
+ get group(): string;
366
+ protected onInit(): void;
367
+ /**
368
+ * Check if the user has the permission.
369
+ */
370
+ can(user: UserAccountInfo): boolean;
371
+ }
372
+ //# sourceMappingURL=$permission.d.ts.map
373
+ //#endregion
395
374
  //#region src/descriptors/$realm.d.ts
396
- declare const KEY$1 = "REALM";
375
+ /**
376
+ * Create a new realm.
377
+ */
378
+ declare const $realm: {
379
+ (options?: RealmDescriptorOptions): RealmDescriptor;
380
+ [KIND]: typeof RealmDescriptor;
381
+ };
397
382
  interface RealmDescriptorOptions {
398
383
  /**
399
384
  * Define the realm name.
@@ -422,9 +407,11 @@ interface RealmDescriptorOptions {
422
407
  */
423
408
  userAccountProvider?: SecurityUserAccountProvider | (() => SecurityUserAccountProvider);
424
409
  }
425
- interface RealmDescriptor {
426
- [KIND]: typeof KEY$1;
427
- [OPTIONS]: RealmDescriptorOptions;
410
+ declare class RealmDescriptor extends Descriptor<RealmDescriptorOptions> {
411
+ protected readonly securityProvider: SecurityProvider;
412
+ protected readonly jwt: JwtProvider;
413
+ get name(): string;
414
+ protected onInit(): void;
428
415
  /**
429
416
  * Get all roles in the realm.
430
417
  */
@@ -442,13 +429,16 @@ interface RealmDescriptor {
442
429
  */
443
430
  createToken(subject: string, roles?: string[]): Promise<string>;
444
431
  }
445
- declare const $realm: {
446
- (options?: RealmDescriptorOptions): RealmDescriptor;
447
- [KIND]: string;
448
- };
432
+ //# sourceMappingURL=$realm.d.ts.map
449
433
  //#endregion
450
434
  //#region src/descriptors/$role.d.ts
451
- declare const KEY = "ROLE";
435
+ /**
436
+ * Create a new role.
437
+ */
438
+ declare const $role: {
439
+ (options?: RoleDescriptorOptions): RoleDescriptor;
440
+ [KIND]: typeof RoleDescriptor;
441
+ };
452
442
  interface RoleDescriptorOptions {
453
443
  /**
454
444
  * Name of the role.
@@ -458,23 +448,22 @@ interface RoleDescriptorOptions {
458
448
  * Describe the role.
459
449
  */
460
450
  description?: string;
451
+ realm?: string | RealmDescriptor;
461
452
  permissions?: Array<string | {
462
453
  name: string;
463
454
  ownership?: boolean;
464
455
  }>;
465
456
  }
466
- interface RoleDescriptor {
467
- [KIND]: typeof KEY;
468
- [OPTIONS]: RoleDescriptorOptions;
457
+ declare class RoleDescriptor extends Descriptor<RoleDescriptorOptions> {
458
+ protected readonly securityProvider: SecurityProvider;
459
+ get name(): string;
460
+ protected onInit(): void;
469
461
  /**
470
- * Get the role object.
462
+ * Get the realm of the role.
471
463
  */
472
- (): Role;
464
+ get realm(): string | RealmDescriptor | undefined;
473
465
  }
474
- declare const $role: {
475
- (options?: RoleDescriptorOptions): RoleDescriptor;
476
- [KIND]: string;
477
- };
466
+ //# sourceMappingURL=$role.d.ts.map
478
467
  //#endregion
479
468
  //#region src/descriptors/$serviceAccount.d.ts
480
469
  /**
@@ -568,10 +557,19 @@ declare module "alepha" {
568
557
  };
569
558
  }
570
559
  }
571
- declare class AlephaSecurity {
572
- readonly name = "alepha.security";
573
- readonly $services: (alepha: Alepha) => Alepha;
574
- }
560
+ /**
561
+ * Provides comprehensive authentication and authorization capabilities with JWT tokens, role-based access control, and user management.
562
+ *
563
+ * The security module enables building secure applications using descriptors like `$realm`, `$role`, and `$permission`
564
+ * on class properties. It offers JWT-based authentication, fine-grained permissions, service accounts, and seamless
565
+ * integration with various authentication providers and user management systems.
566
+ *
567
+ * @see {@link $realm}
568
+ * @see {@link $role}
569
+ * @see {@link $permission}
570
+ * @module alepha.security
571
+ */
572
+ declare const AlephaSecurity: _alepha_core0.ModuleDescriptor;
575
573
  //# sourceMappingURL=index.d.ts.map
576
574
 
577
575
  //#endregion
package/server/cache.d.ts CHANGED
@@ -1,54 +1,48 @@
1
- import { Cache, CacheDescriptorOptions, CacheDescriptorProvider } from "alepha/cache";
2
- import { ServerHandler, ServerRequestConfig } from "alepha/server";
3
- import * as _alepha_core1 from "alepha";
4
- import { Alepha, Module, OPTIONS } from "alepha";
1
+ import * as _alepha_cache0 from "alepha/cache";
2
+ import { CacheDescriptorOptions } from "alepha/cache";
3
+ import * as _alepha_core0$1 from "alepha";
4
+ import * as _alepha_core0 from "alepha";
5
+ import { Alepha } from "alepha";
5
6
  import { DateTimeProvider, DurationLike } from "alepha/datetime";
7
+ import { RequestConfigSchema, ServerRequest, ServerRoute } from "alepha/server";
6
8
 
7
9
  //#region src/providers/ServerCacheProvider.d.ts
8
10
  declare module "alepha/server" {
9
11
  interface ServerRoute {
10
12
  cache?: ServerRouteCache;
11
13
  }
12
- interface ActionDescriptor {
14
+ interface ActionDescriptor<TConfig extends RequestConfigSchema> {
13
15
  invalidate: () => Promise<void>;
14
16
  }
15
17
  }
16
18
  declare class ServerCacheProvider {
17
- protected readonly log: _alepha_core1.Logger;
19
+ protected readonly log: _alepha_core0$1.Logger;
18
20
  protected readonly alepha: Alepha;
19
- protected readonly cacheProvider: CacheDescriptorProvider;
20
21
  protected readonly time: DateTimeProvider;
21
- protected readonly caches: Map<ServerHandler, RouteCache>;
22
- readonly onConfigure: _alepha_core1.HookDescriptor<"configure">;
23
- readonly onRoute: _alepha_core1.HookDescriptor<"server:onRoute">;
24
- readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
25
- readonly onSend: _alepha_core1.HookDescriptor<"server:onResponse">;
22
+ protected readonly cache: _alepha_cache0.CacheDescriptorFn<RouteCacheEntry, any[]>;
26
23
  generateETag(content: string): string;
27
- invalidate(route: RouteLike): Promise<void>;
28
- protected getCacheByRoute(route: RouteLike): RouteCache | undefined;
29
- protected createCacheKey(args: ServerRequestConfig): string;
24
+ invalidate(route: ServerRoute): Promise<void>;
25
+ protected readonly onRequest: _alepha_core0$1.HookDescriptor<"server:onRequest">;
26
+ protected readonly onSend: _alepha_core0$1.HookDescriptor<"server:onResponse">;
27
+ protected getCacheOptions(cache: ServerRouteCache): {
28
+ provider?: (_alepha_core0$1.InstantiableClass<_alepha_cache0.CacheProvider> | "memory") | undefined;
29
+ name?: string | undefined;
30
+ ttl?: DurationLike | undefined;
31
+ disabled?: boolean | undefined;
32
+ };
33
+ protected createCacheKey(route: ServerRoute, args?: ServerRequest): string;
30
34
  }
31
35
  type ServerRouteCache = boolean | DurationLike | Omit<CacheDescriptorOptions<any>, "handler" | "key">;
32
- type RouteCache = Cache<{
36
+ interface RouteCacheEntry {
33
37
  contentType?: string;
34
38
  body: string;
35
39
  status?: number;
36
40
  lastModified: string;
37
41
  hash: string;
38
- }>;
39
- type RouteLike = {
40
- [OPTIONS]: {
41
- handler?: ServerHandler;
42
- };
43
- } | {
44
- handler?: ServerHandler;
45
- };
42
+ }
46
43
  //#endregion
47
44
  //#region src/index.d.ts
48
45
  /**
49
- * # Alepha Server Cache Module
50
- *
51
- * @description
52
46
  * Plugin for Alepha Server that provides server-side caching capabilities.
53
47
  * It uses the Alepha Cache module to cache responses from server actions ($action).
54
48
  * It also provides a ETag-based cache invalidation mechanism.
@@ -76,10 +70,7 @@ type RouteLike = {
76
70
  * @see {@link ServerCacheProvider}
77
71
  * @module alepha.server.cache
78
72
  */
79
- declare class AlephaServerCache implements Module {
80
- readonly name = "alepha.server.cache";
81
- readonly $services: (alepha: Alepha) => Alepha;
82
- }
73
+ declare const AlephaServerCache: _alepha_core0.ModuleDescriptor;
83
74
  //# sourceMappingURL=index.d.ts.map
84
75
 
85
76
  //#endregion
@@ -1,6 +1,7 @@
1
+ import * as _alepha_core0 from "alepha";
2
+ import { HookDescriptor } from "alepha";
1
3
  import { ServerResponse } from "alepha/server";
2
4
  import { Transform } from "node:stream";
3
- import { Alepha, HookDescriptor, Module } from "alepha";
4
5
 
5
6
  //#region src/providers/ServerCompressProvider.d.ts
6
7
  declare class ServerCompressProvider {
@@ -8,19 +9,27 @@ declare class ServerCompressProvider {
8
9
  compress: (...args: any[]) => Promise<Buffer>;
9
10
  stream: (options?: any) => Transform;
10
11
  } | undefined>;
12
+ options: ServerCompressProviderOptions;
11
13
  readonly onResponse: HookDescriptor<"server:onResponse">;
12
14
  protected isAllowedContentType(contentType: string | undefined): boolean;
13
15
  protected compress(encoding: keyof typeof (void 0).compressors, response: ServerResponse): Promise<void>;
14
16
  protected getParams(encoding: keyof typeof (void 0).compressors): Record<number, any>;
15
17
  protected setHeaders(response: ServerResponse, encoding: keyof typeof (void 0).compressors): void;
16
18
  }
19
+ interface ServerCompressProviderOptions {
20
+ allowedContentTypes: string[];
21
+ }
22
+ //# sourceMappingURL=ServerCompressProvider.d.ts.map
17
23
  //#endregion
18
24
  //#region src/index.d.ts
19
- // ---------------------------------------------------------------------------------------------------------------------
20
- declare class AlephaServerCompress implements Module {
21
- readonly name = "alepha.server.compress";
22
- readonly $services: (alepha: Alepha) => void;
23
- }
25
+ /**
26
+ * Plugin for Alepha Server that provides server-side compression capabilities.
27
+ *
28
+ * Compresses responses using gzip, brotli, or zstd based on the `Accept-Encoding` header.
29
+ */
30
+ declare const AlephaServerCompress: _alepha_core0.ModuleDescriptor;
31
+ //# sourceMappingURL=index.d.ts.map
32
+
24
33
  //#endregion
25
- export { AlephaServerCompress, ServerCompressProvider };
34
+ export { AlephaServerCompress, ServerCompressProvider, ServerCompressProviderOptions };
26
35
  //# sourceMappingURL=index.d.ts.map