alepha 0.7.6 → 0.8.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 (59) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +44 -44
  3. package/batch.cjs +8 -0
  4. package/batch.d.ts +114 -0
  5. package/batch.js +1 -0
  6. package/cache/redis.d.ts +15 -18
  7. package/cache.d.ts +115 -119
  8. package/command.cjs +8 -0
  9. package/command.d.ts +154 -0
  10. package/command.js +1 -0
  11. package/core.d.ts +800 -795
  12. package/datetime.d.ts +76 -76
  13. package/lock/redis.d.ts +12 -12
  14. package/lock.d.ts +70 -75
  15. package/package.json +102 -29
  16. package/postgres.d.ts +385 -278
  17. package/queue/redis.d.ts +15 -13
  18. package/queue.d.ts +16 -13
  19. package/react/auth.d.ts +16 -16
  20. package/react/head.cjs +8 -0
  21. package/react/head.d.ts +92 -0
  22. package/react/head.js +1 -0
  23. package/react.d.ts +90 -116
  24. package/redis.d.ts +20 -27
  25. package/retry.d.ts +74 -54
  26. package/scheduler.d.ts +14 -13
  27. package/security.d.ts +38 -41
  28. package/server/cache.d.ts +9 -7
  29. package/server/compress.cjs +8 -0
  30. package/server/compress.d.ts +26 -0
  31. package/server/compress.js +1 -0
  32. package/server/cookies.d.ts +71 -14
  33. package/server/cors.cjs +8 -0
  34. package/server/cors.d.ts +29 -0
  35. package/server/cors.js +1 -0
  36. package/server/health.cjs +8 -0
  37. package/server/health.d.ts +42 -0
  38. package/server/health.js +1 -0
  39. package/server/helmet.cjs +8 -0
  40. package/server/helmet.d.ts +72 -0
  41. package/server/helmet.js +1 -0
  42. package/server/links.cjs +8 -0
  43. package/server/links.d.ts +179 -0
  44. package/server/links.js +1 -0
  45. package/server/metrics.cjs +8 -0
  46. package/server/metrics.d.ts +37 -0
  47. package/server/metrics.js +1 -0
  48. package/server/multipart.cjs +8 -0
  49. package/server/multipart.d.ts +48 -0
  50. package/server/multipart.js +1 -0
  51. package/server/proxy.cjs +8 -0
  52. package/server/proxy.d.ts +41 -0
  53. package/server/proxy.js +1 -0
  54. package/server/static.d.ts +63 -51
  55. package/server/swagger.d.ts +50 -50
  56. package/server.d.ts +220 -437
  57. package/topic/redis.d.ts +24 -23
  58. package/topic.d.ts +9 -19
  59. package/vite.d.ts +8 -1
package/core.d.ts CHANGED
@@ -2,102 +2,109 @@ import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import { TypeCheck } from "@sinclair/typebox/compiler";
3
3
  import * as TypeBoxValue from "@sinclair/typebox/value";
4
4
  import * as TypeBox from "@sinclair/typebox";
5
- import { ArrayOptions, IntegerOptions, NumberOptions, ObjectOptions, SchemaOptions, Static, Static as Static$1, StaticDecode, StaticEncode, StringOptions, TArray, TBoolean, TInteger, TIntersect, TNull, TNumber, TObject, TObject as TObject$1, TOptionalWithFlag, TProperties, TSchema, TSchema as TSchema$1, TString, TUnsafe, TypeGuard, Union, UnsafeOptions } from "@sinclair/typebox";
5
+ import { ArrayOptions, FormatRegistry, IntegerOptions, NumberOptions, ObjectOptions, SchemaOptions, Static, Static as Static$1, StaticDecode, StaticEncode, StringOptions, TAny, TAny as TAny$1, TArray, TArray as TArray$1, TBoolean, TBoolean as TBoolean$1, TComposite, TInteger, TIntersect, TMappedResult, TNull, TNumber, TNumber as TNumber$1, TObject, TObject as TObject$1, TOmit, TOptional, TOptionalWithFlag, TPartial, TPartialFromMappedResult, TPick, TProperties, TProperties as TProperties$1, TRecord, TRecord as TRecord$1, TRecordOrObject, TSchema, TSchema as TSchema$1, TString, TString as TString$1, TUndefined, TUnion, TUnsafe, TVoid, Type, TypeGuard, Union, UnsafeOptions } from "@sinclair/typebox";
6
6
  import { ValueError } from "@sinclair/typebox/errors";
7
- import { ReadableStream as ReadableStream$1 } from "node:stream/web";
8
7
  import { Readable } from "node:stream";
8
+ import { ReadableStream as ReadableStream$1 } from "node:stream/web";
9
9
 
10
10
  //#region src/constants/KIND.d.ts
11
11
  /**
12
- * Used for identifying descriptors.
13
- *
14
- * @internal
15
- */
12
+ * Used for identifying descriptors.
13
+ *
14
+ * @internal
15
+ */
16
16
  declare const KIND: unique symbol;
17
17
  //#endregion
18
18
  //#region src/constants/OPTIONS.d.ts
19
19
  /**
20
- * Used for descriptors options.
21
- *
22
- * @internal
23
- */
20
+ * Used for descriptors options.
21
+ *
22
+ * @internal
23
+ */
24
24
  declare const OPTIONS: unique symbol;
25
25
  //#endregion
26
26
  //#region src/interfaces/Async.d.ts
27
+ // ---------------------------------------------------------------------------------------------------------------------
27
28
  /**
28
- * Represents a value that can be either a value or a promise.
29
- */
29
+ * Represents a value that can be either a value or a promise.
30
+ */
30
31
  type Async<T> = T | Promise<T>;
32
+ // ---------------------------------------------------------------------------------------------------------------------
31
33
  /**
32
- * Represents a function that returns a promise.
33
- */
34
+ * Represents a function that returns a promise.
35
+ */
34
36
  type PromiseFn = (...args: any[]) => Promise<any>;
37
+ // ---------------------------------------------------------------------------------------------------------------------
35
38
  /**
36
- * Represents a function that returns an async value.
37
- */
39
+ * Represents a function that returns an async value.
40
+ */
38
41
  type AsyncFn = (...args: any[]) => Async<any>;
42
+ // ---------------------------------------------------------------------------------------------------------------------
39
43
  type MaybePromise<T> = T extends Promise<any> ? T : Promise<T>;
40
44
  //#endregion
41
45
  //#region src/interfaces/Service.d.ts
46
+ // ---------------------------------------------------------------------------------------------------------------------
42
47
  /**
43
- * In Alepha, a service is a class that can be instantiated. Nothing more, nothing less.
44
- */
48
+ * In Alepha, a service is a class that can be instantiated. Nothing more, nothing less.
49
+ */
45
50
  type Service<T extends object = any> = InstantiableService<T> | AbstractService<T>;
46
51
  type InstantiableService<T extends object = any> = new (...args: any[]) => T;
47
52
  type AbstractService<T extends object = any> = abstract new (...args: any[]) => T;
53
+ // ---------------------------------------------------------------------------------------------------------------------
48
54
  /**
49
- * Service substitution allows you to register a class as a different class.
50
- */
55
+ * Service substitution allows you to register a class as a different class.
56
+ */
51
57
  interface ServiceSubstitution<T extends object = any> {
52
58
  /**
53
- * Every time someone asks for this service, it will be provided with the 'use' service.
54
- */
59
+ * Every time someone asks for this service, it will be provided with the 'use' service.
60
+ */
55
61
  provide: Service<T>;
56
62
  /**
57
- * Service to use instead of the 'provide' service.
58
- *
59
- * Note: Syntax is based on Angular's DI system.
60
- */
63
+ * Service to use instead of the 'provide' service.
64
+ *
65
+ * Note: Syntax is based on Angular's DI system.
66
+ */
61
67
  use: Service<T>;
62
68
  /**
63
- * If true and the service already exists, just ignore the substitution and do not throw an error.
64
- * Mostly used for plugins to enforce a substitution without throwing an error.
65
- */
69
+ * If true and the service already exists, just ignore the substitution and do not throw an error.
70
+ * Mostly used for plugins to enforce a substitution without throwing an error.
71
+ */
66
72
  optional?: boolean;
67
73
  }
74
+ // ---------------------------------------------------------------------------------------------------------------------
68
75
  /**
69
- * Every time you register a service, you can use this type to define it.
70
- *
71
- * alepha.with( ServiceEntry )
72
- * or
73
- * alepha.with( provide: ServiceEntry, use: MyOwnServiceEntry )
74
- *
75
- * And yes, you declare the *type* of the service, not the *instance*.
76
- */
76
+ * Every time you register a service, you can use this type to define it.
77
+ *
78
+ * alepha.with( ServiceEntry )
79
+ * or
80
+ * alepha.with( provide: ServiceEntry, use: MyOwnServiceEntry )
81
+ *
82
+ * And yes, you declare the *type* of the service, not the *instance*.
83
+ */
77
84
  type ServiceEntry<T extends object = any> = Service<T> | ServiceSubstitution<T>;
78
85
  //#endregion
79
86
  //#region src/descriptors/$hook.d.ts
80
87
  declare const KEY = "HOOK";
81
88
  interface HookOptions<T extends keyof Hooks> {
82
89
  /**
83
- * The name of the hook. "configure", "start", "ready", "stop", ...
84
- */
85
- name: T;
90
+ * The name of the hook. "configure", "start", "ready", "stop", ...
91
+ */
92
+ on: T;
86
93
  /**
87
- * The handler to run when the hook is triggered.
88
- */
94
+ * The handler to run when the hook is triggered.
95
+ */
89
96
  handler: (app: Hooks[T]) => Async<any>;
90
97
  /**
91
- * Force the hook to run first or last on the list of hooks.
92
- */
98
+ * Force the hook to run first or last on the list of hooks.
99
+ */
93
100
  priority?: "first" | "last";
94
101
  /**
95
- * Empty placeholder, not working yet. :-)
96
- */
102
+ * Empty placeholder, not working yet. :-)
103
+ */
97
104
  before?: object | Array<object>;
98
105
  /**
99
- * Empty placeholder, not working yet. :-)
100
- */
106
+ * Empty placeholder, not working yet. :-)
107
+ */
101
108
  after?: object | Array<object>;
102
109
  }
103
110
  interface Hook<T extends keyof Hooks = any> {
@@ -111,44 +118,44 @@ interface HookDescriptor<T extends keyof Hooks> {
111
118
  (app: Hooks[T]): Async<any>;
112
119
  }
113
120
  /**
114
- * Registers a new hook.
115
- *
116
- * ```ts
117
- * import { $hook } from "alepha";
118
- *
119
- * class MyProvider {
120
- * onStart = $hook({
121
- * name: "start", // or "configure", "ready", "stop", ...
122
- * handler: async (app) => {
123
- * // await db.connect(); ...
124
- * }
125
- * });
126
- * }
127
- * ```
128
- *
129
- * Hooks are used to run async functions from all registered providers/services.
130
- *
131
- * You can't register a hook after the App has started.
132
- *
133
- * It's used under the hood by the `configure`, `start`, and `stop` methods.
134
- * Some modules also use hooks to run their own logic. (e.g. `@alepha/server`).
135
- *
136
- * You can create your own hooks by using module augmentation:
137
- *
138
- * ```ts
139
- * declare module "alepha" {
140
- *
141
- * interface Hooks {
142
- * "my:custom:hook": {
143
- * arg1: string;
144
- * }
145
- * }
146
- * }
147
- *
148
- * await alepha.emit("my:custom:hook", { arg1: "value" });
149
- * ```
150
- *
151
- */
121
+ * Registers a new hook.
122
+ *
123
+ * ```ts
124
+ * import { $hook } from "alepha";
125
+ *
126
+ * class MyProvider {
127
+ * onStart = $hook({
128
+ * name: "start", // or "configure", "ready", "stop", ...
129
+ * handler: async (app) => {
130
+ * // await db.connect(); ...
131
+ * }
132
+ * });
133
+ * }
134
+ * ```
135
+ *
136
+ * Hooks are used to run async functions from all registered providers/services.
137
+ *
138
+ * You can't register a hook after the App has started.
139
+ *
140
+ * It's used under the hood by the `configure`, `start`, and `stop` methods.
141
+ * Some modules also use hooks to run their own logic. (e.g. `@alepha/server`).
142
+ *
143
+ * You can create your own hooks by using module augmentation:
144
+ *
145
+ * ```ts
146
+ * declare module "alepha" {
147
+ *
148
+ * interface Hooks {
149
+ * "my:custom:hook": {
150
+ * arg1: string;
151
+ * }
152
+ * }
153
+ * }
154
+ *
155
+ * await alepha.emit("my:custom:hook", { arg1: "value" });
156
+ * ```
157
+ *
158
+ */
152
159
  declare const $hook: {
153
160
  <T extends keyof Hooks>(options: HookOptions<T>): HookDescriptor<T>;
154
161
  [KIND]: string;
@@ -162,17 +169,19 @@ interface Module {
162
169
  interface ModuleDefinition extends Module {
163
170
  services: Array<Service>;
164
171
  }
172
+ // ---------------------------------------------------------------------------------------------------------------------
165
173
  declare const isModule: (value: unknown) => value is Module;
166
174
  declare const toModuleName: (name: string) => string;
167
175
  //#endregion
168
176
  //#region src/descriptors/$cursor.d.ts
177
+ // ---------------------------------------------------------------------------------------------------------------------
169
178
  /**
170
- * /!\ Global variable /!\
171
- *
172
- * Store the current context and definition during injection phase.
173
- *
174
- * @internal
175
- */
179
+ * /!\ Global variable /!\
180
+ *
181
+ * Store the current context and definition during injection phase.
182
+ *
183
+ * @internal
184
+ */
176
185
  declare const __alephaRef: {
177
186
  context?: Alepha;
178
187
  definition?: Service;
@@ -182,42 +191,44 @@ declare const __alephaRef: {
182
191
  parent: Service;
183
192
  };
184
193
  };
194
+ // ---------------------------------------------------------------------------------------------------------------------
185
195
  /**
186
- * Cursor descriptor.
187
- */
196
+ * Cursor descriptor.
197
+ */
188
198
  interface CursorDescriptor {
189
199
  context: Alepha;
190
200
  definition?: Service;
191
201
  module?: ModuleDefinition;
192
202
  }
193
203
  /**
194
- * Get Alepha instance and Class definition from the current context.
195
- * This should be used inside a descriptor only.
196
- *
197
- * ```ts
198
- * import { $cursor } from "@alepha/core";
199
- *
200
- * const $ = () => {
201
- *
202
- * const { context, definition } = $cursor();
203
- *
204
- * // context - alepha instance
205
- * // definition - class which is creating this descriptor
206
- *
207
- * return {};
208
- * }
209
- *
210
- * ```
211
- *
212
- * @internal
213
- */
204
+ * Get Alepha instance and Class definition from the current context.
205
+ * This should be used inside a descriptor only.
206
+ *
207
+ * ```ts
208
+ * import { $cursor } from "alepha";
209
+ *
210
+ * const $ = () => {
211
+ *
212
+ * const { context, definition } = $cursor();
213
+ *
214
+ * // context - alepha instance
215
+ * // definition - class which is creating this descriptor
216
+ *
217
+ * return {};
218
+ * }
219
+ *
220
+ * ```
221
+ *
222
+ * @internal
223
+ */
214
224
  declare const $cursor: () => CursorDescriptor;
215
225
  //#endregion
216
226
  //#region src/helpers/EventEmitterLike.d.ts
227
+ // ---------------------------------------------------------------------------------------------------------------------
217
228
  /**
218
- * Low-cost event emitter like for internal use.
219
- * Used only for descriptor implicit registration.
220
- */
229
+ * Low-cost event emitter like for internal use.
230
+ * Used only for descriptor implicit registration.
231
+ */
221
232
  declare class EventEmitterLike<TEvents extends {
222
233
  [key: string]: any;
223
234
  }> {
@@ -227,133 +238,148 @@ declare class EventEmitterLike<TEvents extends {
227
238
  }
228
239
  //#endregion
229
240
  //#region src/helpers/descriptor.d.ts
241
+ // ---------------------------------------------------------------------------------------------------------------------
230
242
  /**
231
- * Descriptor events.
232
- *
233
- * - `create` - Emitted when a descriptor is created.
234
- */
243
+ * Descriptor events.
244
+ *
245
+ * - `create` - Emitted when a descriptor is created.
246
+ */
235
247
  declare const descriptorEvents: EventEmitterLike<{
236
248
  create: CursorDescriptor & {
237
249
  [KIND]: string;
238
250
  };
239
251
  }>;
252
+ // ---------------------------------------------------------------------------------------------------------------------
240
253
  /**
241
- * Register a descriptor.
242
- *
243
- * This is used to run the event "create" and allow auto-registration of descriptors.
244
- *
245
- * @internal
246
- * @param kind
247
- */
254
+ * Register a descriptor.
255
+ *
256
+ * This is used to run the event "create" and allow auto-registration of descriptors.
257
+ *
258
+ * @internal
259
+ * @param kind
260
+ */
248
261
  declare const __descriptor: (kind: string) => void;
262
+ // ---------------------------------------------------------------------------------------------------------------------
249
263
  /**
250
- * Auto-inject a class/module when a descriptor is created.
251
- *
252
- * Like, you auto-inject the ServerModule when a `$route` descriptor is used.
253
- *
254
- * @param descriptor
255
- * @param to
256
- */
264
+ * Auto-inject a class/module when a descriptor is created.
265
+ *
266
+ * Like, you auto-inject the ServerModule when a `$route` descriptor is used.
267
+ *
268
+ * @param descriptor
269
+ * @param to
270
+ */
257
271
  declare const __bind: (descriptor: {
258
272
  [KIND]: string;
259
273
  }, ...to: Service[]) => void;
274
+ // ---------------------------------------------------------------------------------------------------------------------
260
275
  /**
261
- * Check if the value is a descriptor value.
262
- *
263
- * @param value - Value to check.
264
- * @returns Is the value a descriptor value.
265
- */
276
+ * Check if the value is a descriptor value.
277
+ *
278
+ * @param value - Value to check.
279
+ * @returns Is the value a descriptor value.
280
+ */
266
281
  declare const isDescriptorValue: (value: any) => value is DescriptorIdentifier;
282
+ // ---------------------------------------------------------------------------------------------------------------------
267
283
  /**
268
- * The "$descriptor" function.
269
- */
284
+ * The "$descriptor" function.
285
+ */
270
286
  interface Descriptor<T extends object = any> {
271
287
  [KIND]: string;
272
288
  (options: T): DescriptorIdentifier<T>;
273
289
  }
290
+ // ---------------------------------------------------------------------------------------------------------------------
274
291
  /**
275
- * Class member descriptor.
276
- */
292
+ * Class member descriptor.
293
+ */
277
294
  interface DescriptorIdentifier<T = object> {
278
295
  [KIND]: string;
279
296
  [OPTIONS]: T;
280
297
  }
298
+ // ---------------------------------------------------------------------------------------------------------------------
281
299
  /**
282
- * Descriptor identifier + his instance + his key.
283
- */
300
+ * Descriptor identifier + his instance + his key.
301
+ */
284
302
  interface DescriptorItem<T extends Descriptor> {
285
303
  value: ReturnType<T>;
286
304
  key: string;
287
305
  instance: Record<string, any>;
288
306
  }
289
307
  //#endregion
290
- //#region src/providers/AsyncLocalStorageProvider.d.ts
308
+ //#region src/providers/AlsProvider.d.ts
291
309
  type AsyncLocalStorageData = any;
292
- declare class AsyncLocalStorageProvider {
310
+ declare class AlsProvider {
293
311
  static create: () => AsyncLocalStorage<AsyncLocalStorageData> | undefined;
294
312
  protected als?: AsyncLocalStorage<AsyncLocalStorageData>;
295
313
  constructor();
296
- run<R>(data: AsyncLocalStorageData, callback: () => R): R;
314
+ createContextId(): string;
315
+ run<R>(callback: () => R, data?: Record<string, any>): R;
297
316
  get<T>(key: string): T | undefined;
298
317
  set<T>(key: string, value: T): void;
299
318
  }
300
319
  //#endregion
301
320
  //#region src/services/Logger.d.ts
321
+ // ---------------------------------------------------------------------------------------------------------------------
302
322
  type LogLevel = "error" | "warn" | "info" | "debug" | "trace" | "silent";
323
+ // ---------------------------------------------------------------------------------------------------------------------
303
324
  interface LoggerEnv {
304
325
  /**
305
- * Default log level for the application.
306
- * Default by environment:
307
- * - dev = "debug"
308
- * - test = "error"
309
- * - prod = "info"
310
- */
311
- LOG_LEVEL?: "trace" | "debug" | "info" | "warn" | "error" | "silent";
312
- /**
313
- * Disable colors in the console output.
314
- */
326
+ * Default log level for the application.
327
+ * Default by environment:
328
+ * - dev = "debug"
329
+ * - test = "error"
330
+ * - prod = "info"
331
+ *
332
+ * "trace" | "debug" | "info" | "warn" | "error" | "silent"
333
+ */
334
+ LOG_LEVEL?: string;
335
+ /**
336
+ * Disable colors in the console output.
337
+ */
315
338
  NO_COLOR?: string;
316
339
  /**
317
- * Force color output for the application.
318
- */
340
+ * Force color output for the application.
341
+ */
319
342
  FORCE_COLOR?: string;
320
343
  /**
321
- * Log format.
322
- *
323
- * @default "text"
324
- */
325
- LOG_FORMAT?: "json" | "text";
344
+ * Log format.
345
+ *
346
+ * @default "text"
347
+ */
348
+ LOG_FORMAT?: "json" | "text" | "cli" | "raw";
326
349
  }
350
+ // ---------------------------------------------------------------------------------------------------------------------
327
351
  interface LoggerOptions {
328
352
  /**
329
- * The logging level. Can be one of "error", "warn", "info", "debug", or "trace".
330
- */
331
- level?: LogLevel;
353
+ * The logging level. Can be one of "error", "warn", "info", "debug", or "trace".
354
+ */
355
+ level?: string;
356
+ app?: string;
332
357
  /**
333
- * The name of the logger. Like a module name or a service name.
334
- */
358
+ * The name of the logger. Like a module name or a service name.
359
+ */
335
360
  name?: string;
336
361
  /**
337
- * An optional context to include in the log output. Like a request ID or a correlation ID.
338
- */
362
+ * An optional context to include in the log output. Like a request ID or a correlation ID.
363
+ */
339
364
  context?: string;
340
365
  /**
341
- * An optional tag to include in the log output. Like a class name or a module name.
342
- */
366
+ * An optional tag to include in the log output. Like a class name or a module name.
367
+ */
343
368
  caller?: string;
344
369
  /**
345
- * Whether to use colors in the log output. Defaults to true.
346
- */
370
+ * Whether to use colors in the log output. Defaults to true.
371
+ */
347
372
  color?: boolean;
348
373
  /**
349
- * Whether to log in JSON format. Defaults to false.
350
- */
351
- json?: boolean;
374
+ * Log output format. Can be "json", "text", or "cli".
375
+ */
376
+ format?: string;
352
377
  /**
353
- * An optional async local storage provider to use for storing context information.
354
- */
355
- als?: AsyncLocalStorageProvider;
378
+ * An optional async local storage provider to use for storing context information.
379
+ */
380
+ als?: AlsProvider;
356
381
  }
382
+ // ---------------------------------------------------------------------------------------------------------------------
357
383
  declare const COLORS: {
358
384
  reset: string;
359
385
  grey: string;
@@ -365,17 +391,22 @@ declare const COLORS: {
365
391
  cyan: string;
366
392
  darkGrey: string;
367
393
  };
368
- declare const LEVEL_COLORS: Record<LogLevel, string>;
394
+ declare const LEVEL_COLORS: Record<string, string>;
395
+ // ---------------------------------------------------------------------------------------------------------------------
369
396
  declare class Logger {
370
- protected levelOrder: Record<LogLevel, number>;
371
- readonly level: LogLevel;
397
+ protected levelOrder: Record<string, number>;
398
+ readonly level: string;
399
+ readonly rawLevel: string;
372
400
  readonly name: string;
373
401
  protected caller: string;
374
402
  protected context: string;
403
+ protected app: string;
375
404
  protected color: boolean;
376
- protected json: boolean;
377
- protected als?: AsyncLocalStorageProvider;
405
+ protected format: string;
406
+ protected als?: AlsProvider;
378
407
  constructor(options?: LoggerOptions);
408
+ parseLevel(level: string, app: string): LogLevel;
409
+ asLogLevel(something: string): LogLevel;
379
410
  child(options: LoggerOptions): Logger;
380
411
  error(message: unknown, data?: object | Error | string | unknown): void;
381
412
  warn(message: unknown, data?: object | Error | string): void;
@@ -383,49 +414,32 @@ declare class Logger {
383
414
  debug(message: unknown, data?: object | Error | string): void;
384
415
  trace(message: unknown, data?: object | Error | string): void;
385
416
  /**
386
- * Log a message to the console.
387
- *
388
- * @param level
389
- * @param message
390
- * @param data
391
- * @protected
392
- */
417
+ * Log a message to the console.
418
+ */
393
419
  protected log(level: LogLevel, message: unknown, data?: object | Error | string): void;
394
420
  /**
395
- * Print a log message to the console.
396
- *
397
- * @param formatted
398
- * @protected
399
- */
421
+ * Print a log message to the console.
422
+ */
400
423
  protected print(formatted: string): void;
401
424
  /**
402
- * Format a log message to JSON.
403
- *
404
- * @param level
405
- * @param message
406
- * @param data
407
- * @protected
408
- */
425
+ * Format a log message to JSON.
426
+ */
409
427
  protected formatJson(level: LogLevel, message: unknown, data?: object | Error | string): string;
410
428
  protected formatJsonError(error: Error): object;
411
429
  /**
412
- * Format a log message to a string.
413
- *
414
- * @param level
415
- * @param message
416
- * @param data
417
- * @protected
418
- */
430
+ * Format a log message to a string.
431
+ */
419
432
  protected formatLog(level: LogLevel, message: string, data?: object | Error): string;
420
433
  protected colorize(color: string, text: string, reset?: string): string;
421
434
  /**
422
- * Format an error to a string.
423
- *
424
- * @param error
425
- * @protected
426
- */
435
+ * Format an error to a string.
436
+ *
437
+ * @param error
438
+ * @protected
439
+ */
427
440
  protected formatError(error: Error): string;
428
441
  }
442
+ // ---------------------------------------------------------------------------------------------------------------------
429
443
  declare class MockLogger extends Logger {
430
444
  store: MockLoggerStore;
431
445
  constructor(options?: LoggerOptions & {
@@ -433,586 +447,605 @@ declare class MockLogger extends Logger {
433
447
  });
434
448
  print(msg: string): void;
435
449
  child(options: LoggerOptions): MockLogger;
450
+ reset(): void;
436
451
  }
452
+ // ---------------------------------------------------------------------------------------------------------------------
437
453
  interface MockLoggerStore {
438
454
  stack: Array<{
439
455
  date: string;
440
456
  level: string;
441
457
  message: string;
458
+ context?: string;
459
+ app?: string;
442
460
  } & Record<string, any>>;
443
461
  }
444
462
  //#endregion
445
463
  //#region src/Alepha.d.ts
464
+ // ---------------------------------------------------------------------------------------------------------------------
446
465
  interface Env extends LoggerEnv {
447
466
  [key: string]: string | boolean | number | undefined;
448
467
  /**
449
- * Optional environment variable that indicates the current environment.
450
- */
468
+ * Optional environment variable that indicates the current environment.
469
+ */
451
470
  NODE_ENV?: "dev" | "test" | "production";
452
471
  /**
453
- * Optional name of the application.
454
- */
472
+ * Optional name of the application.
473
+ */
455
474
  APP_NAME?: string;
456
475
  /**
457
- * If true, the container will not automatically register the default providers based on the descriptors.
458
- *
459
- * It means that you have to alepha.with(ServiceModule) manually. No magic.
460
- *
461
- * @default false
462
- */
476
+ * Optional root module name.
477
+ */
478
+ MODULE_NAME?: string;
479
+ /**
480
+ * If true, the container will not automatically register the default providers based on the descriptors.
481
+ *
482
+ * It means that you have to alepha.with(ServiceModule) manually. No magic.
483
+ *
484
+ * @default false
485
+ */
463
486
  EXPLICIT_PROVIDERS?: boolean;
464
487
  }
488
+ // ---------------------------------------------------------------------------------------------------------------------
465
489
  interface State {
466
490
  log: Logger;
467
491
  env?: Readonly<Env>;
492
+ // test hooks
468
493
  beforeAll?: (run: any) => any;
469
494
  afterAll?: (run: any) => any;
470
495
  afterEach?: (run: any) => any;
471
496
  onTestFinished?: (run: any) => any;
472
497
  }
498
+ // ---------------------------------------------------------------------------------------------------------------------
473
499
  interface Hooks {
474
500
  echo: any;
475
501
  /**
476
- * Triggered during the configuration phase. Before the start phase.
477
- */
502
+ * Triggered during the configuration phase. Before the start phase.
503
+ */
478
504
  configure: Alepha;
479
505
  /**
480
- * Triggered during the start phase. When `Alepha#start()` is called.
481
- */
506
+ * Triggered during the start phase. When `Alepha#start()` is called.
507
+ */
482
508
  start: Alepha;
483
509
  /**
484
- * Triggered during the ready phase. After the start phase.
485
- */
510
+ * Triggered during the ready phase. After the start phase.
511
+ */
486
512
  ready: Alepha;
487
513
  /**
488
- * Triggered during the stop phase.
489
- *
490
- * - Stop should be called after a SIGINT or SIGTERM signal in order to gracefully shutdown the application. (@see `run()` method)
491
- *
492
- */
514
+ * Triggered during the stop phase.
515
+ *
516
+ * - Stop should be called after a SIGINT or SIGTERM signal in order to gracefully shutdown the application. (@see `run()` method)
517
+ *
518
+ */
493
519
  stop: Alepha;
494
520
  /**
495
- * Triggered when a state value is mutated.
496
- */
521
+ * Triggered when a state value is mutated.
522
+ */
497
523
  "state:mutate": {
498
524
  /**
499
- * The key of the state that was mutated.
500
- */
525
+ * The key of the state that was mutated.
526
+ */
501
527
  key: keyof State;
502
528
  /**
503
- * The new value of the state.
504
- */
529
+ * The new value of the state.
530
+ */
505
531
  value: any;
506
532
  /**
507
- * The previous value of the state.
508
- */
533
+ * The previous value of the state.
534
+ */
509
535
  prevValue: any;
510
536
  };
511
537
  }
538
+ // ---------------------------------------------------------------------------------------------------------------------
512
539
  /**
513
- * Core container of the Alepha framework.
514
- *
515
- * It is responsible for managing the lifecycle of services,
516
- * handling dependency injection,
517
- * and providing a unified interface for the application.
518
- *
519
- * @example
520
- * ```ts
521
- * import { Alepha, run } from "@alepha/core";
522
- *
523
- * class MyService {
524
- * // business logic here
525
- * }
526
- *
527
- * const alepha = Alepha.create({
528
- * // state, env, and other properties
529
- * })
530
- *
531
- * alepha.with(MyService);
532
- *
533
- * run(alepha); // trigger .start (and .stop) automatically
534
- * ```
535
- *
536
- * > Some alepha methods are not intended to be used directly, use descriptors instead.
537
- *
538
- * - $hook -> alepha.on()
539
- * - $inject -> alepha.get(), alepha.parseEnv()
540
- */
540
+ * Core container of the Alepha framework.
541
+ *
542
+ * It is responsible for managing the lifecycle of services,
543
+ * handling dependency injection,
544
+ * and providing a unified interface for the application.
545
+ *
546
+ * @example
547
+ * ```ts
548
+ * import { Alepha, run } from "alepha";
549
+ *
550
+ * class MyService {
551
+ * // business logic here
552
+ * }
553
+ *
554
+ * const alepha = Alepha.create({
555
+ * // state, env, and other properties
556
+ * })
557
+ *
558
+ * alepha.with(MyService);
559
+ *
560
+ * run(alepha); // trigger .start (and .stop) automatically
561
+ * ```
562
+ *
563
+ * > Some alepha methods are not intended to be used directly, use descriptors instead.
564
+ *
565
+ * - $hook -> alepha.on()
566
+ * - $inject -> alepha.get(), alepha.parseEnv()
567
+ */
541
568
  declare class Alepha {
542
569
  /**
543
- * Creates a new instance of the Alepha container with some helpers:
544
- *
545
- * - merges `process.env` with the provided state.env when available.
546
- * - populates the test hooks for Vitest or Jest environments when available.
547
- *
548
- * If you are not interested about these helpers, you can use the constructor directly.
549
- */
570
+ * Creates a new instance of the Alepha container with some helpers:
571
+ *
572
+ * - merges `process.env` with the provided state.env when available.
573
+ * - populates the test hooks for Vitest or Jest environments when available.
574
+ *
575
+ * If you are not interested about these helpers, you can use the constructor directly.
576
+ */
550
577
  static create(state?: Partial<State>): Alepha;
551
578
  /**
552
- * List of all services + how they are provided.
553
- */
579
+ * List of all services + how they are provided.
580
+ */
554
581
  protected registry: Map<Service, ServiceDefinition>;
555
582
  /**
556
- * Flag indicating whether the App won't accept any further changes.
557
- * Pass to true when #start() is called.
558
- */
583
+ * Flag indicating whether the App won't accept any further changes.
584
+ * Pass to true when #start() is called.
585
+ */
559
586
  protected locked: boolean;
560
587
  /**
561
- * True if the App has been configured.
562
- */
588
+ * True if the App has been configured.
589
+ */
563
590
  protected configured: boolean;
564
591
  /**
565
- * True if the App has started.
566
- */
592
+ * True if the App has started.
593
+ */
567
594
  protected started: boolean;
568
595
  /**
569
- * True if the App is ready.
570
- */
596
+ * True if the App is ready.
597
+ */
571
598
  protected ready: boolean;
572
599
  /**
573
- * A promise that resolves when the App has started.
574
- */
600
+ * A promise that resolves when the App has started.
601
+ */
575
602
  protected starting?: PromiseWithResolvers<this>;
576
603
  /**
577
- * The current state of the App.
578
- *
579
- * It contains the environment variables, logger, and other state-related properties.
580
- *
581
- * You can declare your own state properties by extending the `State` interface.
582
- *
583
- * ```ts
584
- * declare module "alepha/core" {
585
- * interface State {
586
- * myCustomValue: string;
587
- * }
588
- * }
589
- * ```
590
- *
591
- * Same story for the `Env` interface.
592
- * ```ts
593
- * declare module "@alepha/core" {
594
- * interface Env {
595
- * readonly myCustomValue: string;
596
- * }
597
- * }
598
- * ```
599
- *
600
- * State values can be function or primitive values.
601
- * However, all .env variables must serializable to JSON.
602
- */
604
+ * The current state of the App.
605
+ *
606
+ * It contains the environment variables, logger, and other state-related properties.
607
+ *
608
+ * You can declare your own state properties by extending the `State` interface.
609
+ *
610
+ * ```ts
611
+ * declare module "alepha" {
612
+ * interface State {
613
+ * myCustomValue: string;
614
+ * }
615
+ * }
616
+ * ```
617
+ *
618
+ * Same story for the `Env` interface.
619
+ * ```ts
620
+ * declare module "alepha" {
621
+ * interface Env {
622
+ * readonly myCustomValue: string;
623
+ * }
624
+ * }
625
+ * ```
626
+ *
627
+ * State values can be function or primitive values.
628
+ * However, all .env variables must serializable to JSON.
629
+ */
603
630
  protected store: State;
604
631
  /**
605
- * During the instantiation process, we keep a list of pending instantiations.
606
- * > It allows us to detect circular dependencies.
607
- */
632
+ * During the instantiation process, we keep a list of pending instantiations.
633
+ * > It allows us to detect circular dependencies.
634
+ */
608
635
  protected pendingInstantiations: Service[];
609
636
  /**
610
- * Cache for environment variables.
611
- * > It allows us to avoid parsing the same schema multiple times.
612
- */
637
+ * Cache for environment variables.
638
+ * > It allows us to avoid parsing the same schema multiple times.
639
+ */
613
640
  protected cacheEnv: Map<TSchema$1, any>;
614
641
  /**
615
- * Cache for TypeBox type checks.
616
- * > It allows us to avoid compiling the same schema multiple times.
617
- */
642
+ * Cache for TypeBox type checks.
643
+ * > It allows us to avoid compiling the same schema multiple times.
644
+ */
618
645
  protected cacheTypeCheck: Map<TSchema$1, TypeCheck<TSchema$1>>;
619
646
  /**
620
- * List of events that can be triggered. Powered by $hook().
621
- */
647
+ * List of events that can be triggered. Powered by $hook().
648
+ */
622
649
  protected events: Record<string, Array<Hook>>;
623
650
  /**
624
- * List of modules that are registered in the container.
625
- *
626
- * Modules are used to group services and provide a way to register them in the container.
627
- */
651
+ * List of modules that are registered in the container.
652
+ *
653
+ * Modules are used to group services and provide a way to register them in the container.
654
+ */
628
655
  protected modules: Array<ModuleDefinition>;
629
656
  /**
630
- * Node.js feature that allows to store context across asynchronous calls.
631
- *
632
- * This is used for logging, tracing, and other context-related features.
633
- *
634
- * Mocked for browser environments.
635
- */
636
- readonly context: AsyncLocalStorageProvider;
657
+ * Node.js feature that allows to store context across asynchronous calls.
658
+ *
659
+ * This is used for logging, tracing, and other context-related features.
660
+ *
661
+ * Mocked for browser environments.
662
+ */
663
+ readonly context: AlsProvider;
637
664
  /**
638
- * Get logger instance.
639
- */
665
+ * Get logger instance.
666
+ */
640
667
  get log(): Logger;
641
668
  /**
642
- * The environment variables for the App.
643
- */
669
+ * The environment variables for the App.
670
+ */
644
671
  get env(): Readonly<Env>;
645
672
  constructor(state?: Partial<State>);
646
673
  /**
647
- * Generic handle function used as generic interface for serverless functions.
648
- * You should not use this property directly.
649
- */
650
- handle?: (req: any, res: any) => Promise<any>;
651
- /**
652
- * State accessor and mutator.
653
- */
674
+ * State accessor and mutator.
675
+ */
654
676
  state<Key extends keyof State>(key: Key, value?: State[Key]): State[Key];
677
+ // -------------------------------------------------------------------------------------------------------------------
655
678
  /**
656
- * True when start() is called.
657
- *
658
- * -> No more services can be added, it's over, bye!
659
- */
679
+ * True when start() is called.
680
+ *
681
+ * -> No more services can be added, it's over, bye!
682
+ */
660
683
  isLocked(): boolean;
661
684
  /**
662
- * Returns whether the App is configured.
663
- *
664
- * It means that Alepha#configure() has been called.
665
- *
666
- * > By default, configure() is called automatically when start() is called, but you can also call it manually.
667
- */
685
+ * Returns whether the App is configured.
686
+ *
687
+ * It means that Alepha#configure() has been called.
688
+ *
689
+ * > By default, configure() is called automatically when start() is called, but you can also call it manually.
690
+ */
668
691
  isConfigured(): boolean;
669
692
  /**
670
- * Returns whether the App has started.
671
- *
672
- * It means that #start() has been called but maybe not all services are ready.
673
- */
693
+ * Returns whether the App has started.
694
+ *
695
+ * It means that #start() has been called but maybe not all services are ready.
696
+ */
674
697
  isStarted(): boolean;
675
698
  /**
676
- * True if the App is ready. It means that Alepha is started AND ready() hook has beed called.
677
- */
699
+ * True if the App is ready. It means that Alepha is started AND ready() hook has beed called.
700
+ */
678
701
  isReady(): boolean;
679
702
  /**
680
- * True if the App is running in a browser environment.
681
- */
703
+ * True if the App is running in a browser environment.
704
+ */
682
705
  isBrowser(): boolean;
683
706
  /**
684
- * Returns whether the App is running in a serverless environment.
685
- *
686
- * > Vite developer mode is also considered serverless.
687
- */
707
+ * Returns whether the App is running in a serverless environment.
708
+ *
709
+ * > Vite developer mode is also considered serverless.
710
+ */
688
711
  isServerless(): boolean | "vite" | "vercel";
689
712
  /**
690
- * Returns whether the App is in test mode. (Running in a test environment)
691
- *
692
- * > This is automatically set when running tests with Jest or Vitest.
693
- */
713
+ * Returns whether the App is in test mode. (Running in a test environment)
714
+ *
715
+ * > This is automatically set when running tests with Jest or Vitest.
716
+ */
694
717
  isTest(): boolean;
695
718
  /**
696
- * Returns whether the App is in production mode. (Running in a production environment)
697
- *
698
- * > This is automatically set by Vite or Vercel. However, you have to set it manually when running Docker apps.
699
- */
719
+ * Returns whether the App is in production mode. (Running in a production environment)
720
+ *
721
+ * > This is automatically set by Vite or Vercel. However, you have to set it manually when running Docker apps.
722
+ */
700
723
  isProduction(): boolean;
701
- /**
702
- * Starts the App.
703
- *
704
- * - Lock any further changes to the container.
705
- * - Run "configure" hook for all services. Descriptors will be processed.
706
- * - Run "start" hook for all services. Providers will connect/listen/...
707
- * - Run "ready" hook for all services. This is the point where the App is ready to serve requests.
708
- *
709
- * @return A promise that resolves when the App has started.
710
- */
724
+ // -------------------------------------------------------------------------------------------------------------------
725
+ /**
726
+ * Starts the App.
727
+ *
728
+ * - Lock any further changes to the container.
729
+ * - Run "configure" hook for all services. Descriptors will be processed.
730
+ * - Run "start" hook for all services. Providers will connect/listen/...
731
+ * - Run "ready" hook for all services. This is the point where the App is ready to serve requests.
732
+ *
733
+ * @return A promise that resolves when the App has started.
734
+ */
711
735
  start(): Promise<this>;
712
736
  /**
713
- * Stops the App.
714
- *
715
- * - Run "stop" hook for all services.
716
- *
717
- * Stop will NOT reset the container.
718
- * Stop will NOT unlock the container.
719
- *
720
- * > Stop is used to gracefully shut down the application, nothing more. There is no "restart".
721
- *
722
- * @return A promise that resolves when the App has stopped.
723
- */
737
+ * Stops the App.
738
+ *
739
+ * - Run "stop" hook for all services.
740
+ *
741
+ * Stop will NOT reset the container.
742
+ * Stop will NOT unlock the container.
743
+ *
744
+ * > Stop is used to gracefully shut down the application, nothing more. There is no "restart".
745
+ *
746
+ * @return A promise that resolves when the App has stopped.
747
+ */
724
748
  stop(): Promise<void>;
749
+ // -------------------------------------------------------------------------------------------------------------------
725
750
  /**
726
- * Check if entry is registered in the container.
727
- */
751
+ * Check if entry is registered in the container.
752
+ */
728
753
  has(entry: ServiceEntry, opts?: {
729
754
  /**
730
- * Check if the entry is registered in the pending instantiation stack.
731
- *
732
- * Default: true
733
- */
755
+ * Check if the entry is registered in the pending instantiation stack.
756
+ *
757
+ * Default: true
758
+ */
734
759
  inStack?: boolean;
735
760
  /**
736
- * Check if the entry is registered in the container registry.
737
- *
738
- * Default: true
739
- */
761
+ * Check if the entry is registered in the container registry.
762
+ *
763
+ * Default: true
764
+ */
740
765
  inRegistry?: boolean;
741
766
  }): boolean;
742
767
  /**
743
- * Registers the specified service in the container.
744
- *
745
- * - If the service is ALREADY registered, the method does nothing.
746
- * - If the service is NOT registered, a new instance is created and registered.
747
- *
748
- * Method is chainable, so you can register multiple services in a single call.
749
- *
750
- * > ServiceEntry allows to provide a service **substitution** feature.
751
- *
752
- * @example
753
- * ```ts
754
- * class A { value = "a"; }
755
- * class B { value = "b"; }
756
- * class M { a = $inject(A); }
757
- *
758
- * Alepha.create().with({ provide: A, use: B }).get(M).a.value; // "b"
759
- * ```
760
- *
761
- * > **Substitution** is an advanced feature that allows you to replace a service with another service.
762
- * > It's useful for testing or for providing different implementations of a service.
763
- * > If you are interested in configuring a service, use Alepha#configure() instead.
764
- *
765
- * @param entry - The service to register in the container.
766
- * @return Current instance of Alepha.
767
- */
768
+ * Registers the specified service in the container.
769
+ *
770
+ * - If the service is ALREADY registered, the method does nothing.
771
+ * - If the service is NOT registered, a new instance is created and registered.
772
+ *
773
+ * Method is chainable, so you can register multiple services in a single call.
774
+ *
775
+ * > ServiceEntry allows to provide a service **substitution** feature.
776
+ *
777
+ * @example
778
+ * ```ts
779
+ * class A { value = "a"; }
780
+ * class B { value = "b"; }
781
+ * class M { a = $inject(A); }
782
+ *
783
+ * Alepha.create().with({ provide: A, use: B }).get(M).a.value; // "b"
784
+ * ```
785
+ *
786
+ * > **Substitution** is an advanced feature that allows you to replace a service with another service.
787
+ * > It's useful for testing or for providing different implementations of a service.
788
+ * > If you are interested in configuring a service, use Alepha#configure() instead.
789
+ *
790
+ * @param entry - The service to register in the container.
791
+ * @return Current instance of Alepha.
792
+ */
768
793
  with<T extends object>(entry: ServiceEntry<T>): this;
769
794
  /**
770
- * Get the instance of the specified service and apply some changes, depending on the options.
771
- * - If the service is already registered, it will return the existing instance. (except if `skipCache` is true)
772
- * - If the service is not registered, it will create a new instance and register it. (except if `skipRegistration` is true)
773
- * - New instance can be created with custom constructor arguments. (`args` option)
774
- *
775
- * > This method is used by $inject() under the hood.
776
- *
777
- * @return The instance of the specified class or type.
778
- */
795
+ * Get the instance of the specified service and apply some changes, depending on the options.
796
+ * - If the service is already registered, it will return the existing instance. (except if `skipCache` is true)
797
+ * - If the service is not registered, it will create a new instance and register it. (except if `skipRegistration` is true)
798
+ * - New instance can be created with custom constructor arguments. (`args` option)
799
+ *
800
+ * > This method is used by $inject() under the hood.
801
+ *
802
+ * @return The instance of the specified class or type.
803
+ */
779
804
  get<T extends object>(serviceEntry: ServiceEntry<T>, opts?: {
780
805
  /**
781
- * Ignore current existing instance.
782
- */
806
+ * Ignore current existing instance.
807
+ */
783
808
  skipCache?: boolean;
784
809
  /**
785
- * Don't store the instance in the registry.
786
- */
810
+ * Don't store the instance in the registry.
811
+ */
787
812
  skipRegistration?: boolean;
788
813
  /**
789
- * Constructor arguments to pass when creating a new instance.
790
- */
814
+ * Constructor arguments to pass when creating a new instance.
815
+ */
791
816
  args?: ConstructorParameters<InstantiableService<T>>;
792
817
  /**
793
- * Parent service that requested the instance.
794
- * @internal
795
- */
818
+ * Parent service that requested the instance.
819
+ * @internal
820
+ */
796
821
  parent?: Service | null;
797
822
  /**
798
- * If the service is provided by a module, the module definition.
799
- * @internal
800
- */
823
+ * If the service is provided by a module, the module definition.
824
+ * @internal
825
+ */
801
826
  module?: ModuleDefinition;
802
827
  }): T;
803
828
  /**
804
- * Configures the specified service with the provided state.
805
- * If service is not registered, it will do nothing.
806
- *
807
- * It's recommended to use this method on the `configure` hook.
808
- * @example
809
- * ```ts
810
- * class AppConfig {
811
- * configure = $hook({
812
- * name: "configure",
813
- * handler: (a) => {
814
- * a.configure(MyProvider, { some: "data" });
815
- * }
816
- * })
817
- * }
818
- * ```
819
- */
820
- configure<T extends object>(service: Service<T>, state: Partial<T>): void;
821
- /**
822
- * Registers a hook for the specified event.
823
- */
829
+ * Configures the specified service with the provided state.
830
+ * If service is not registered, it will do nothing.
831
+ *
832
+ * It's recommended to use this method on the `configure` hook.
833
+ * @example
834
+ * ```ts
835
+ * class AppConfig {
836
+ * configure = $hook({
837
+ * name: "configure",
838
+ * handler: (a) => {
839
+ * a.configure(MyProvider, { some: "data" });
840
+ * }
841
+ * })
842
+ * }
843
+ * ```
844
+ */
845
+ configure<T extends {
846
+ options: object;
847
+ }>(service: Service<T>, state: Partial<T["options"]>): this;
848
+ // -------------------------------------------------------------------------------------------------------------------
849
+ /**
850
+ * Registers a hook for the specified event.
851
+ */
824
852
  on<T extends keyof Hooks>(event: T, hookOrFunc: Hook<T> | ((payload: Hooks[T]) => Async<void>)): () => void;
825
853
  /**
826
- * Emits the specified event with the given payload.
827
- */
854
+ * Emits the specified event with the given payload.
855
+ */
828
856
  emit<T extends keyof Hooks>(func: keyof Hooks, payload: Hooks[T], options?: {
829
857
  /**
830
- * If true, the hooks will be executed in reverse order.
831
- * This is useful for "stop" hooks that should be executed in reverse order.
832
- *
833
- * @default false
834
- */
858
+ * If true, the hooks will be executed in reverse order.
859
+ * This is useful for "stop" hooks that should be executed in reverse order.
860
+ *
861
+ * @default false
862
+ */
835
863
  reverse?: boolean;
836
864
  /**
837
- * If true, the hooks will be logged with their execution time.
838
- *
839
- * @default false
840
- */
865
+ * If true, the hooks will be logged with their execution time.
866
+ *
867
+ * @default false
868
+ */
841
869
  log?: boolean;
842
870
  /**
843
- * If true, errors will be caught and logged instead of throwing.
844
- *
845
- * @default false
846
- */
871
+ * If true, errors will be caught and logged instead of throwing.
872
+ *
873
+ * @default false
874
+ */
847
875
  catch?: boolean;
848
876
  }): Promise<void>;
877
+ // -------------------------------------------------------------------------------------------------------------------
849
878
  /**
850
- * Casts the given value to the specified schema.
851
- *
852
- * It uses the TypeBox library to validate the value against the schema.
853
- */
879
+ * Casts the given value to the specified schema.
880
+ *
881
+ * It uses the TypeBox library to validate the value against the schema.
882
+ */
854
883
  parse<T extends TSchema$1>(schema: T, value?: any, opts?: {
855
884
  /**
856
- * Clone the value before parsing.
857
- * @default true
858
- */
885
+ * Clone the value before parsing.
886
+ * @default true
887
+ */
859
888
  clone?: boolean;
860
889
  /**
861
- * Apply default values defined in the schema.
862
- * @default true
863
- */
890
+ * Apply default values defined in the schema.
891
+ * @default true
892
+ */
864
893
  default?: boolean;
865
894
  /**
866
- * Remove all values not defined in the schema.
867
- * @default true
868
- */
895
+ * Remove all values not defined in the schema.
896
+ * @default true
897
+ */
869
898
  clean?: boolean;
870
899
  /**
871
- * Try to cast/convert some data based on the schema.
872
- * @default true
873
- */
900
+ * Try to cast/convert some data based on the schema.
901
+ * @default true
902
+ */
874
903
  convert?: boolean;
875
904
  /**
876
- * Prepare value after being deserialized.
877
- * @default true
878
- */
905
+ * Prepare value after being deserialized.
906
+ * @default true
907
+ */
879
908
  check?: boolean;
880
909
  }): Static$1<T>;
881
910
  /**
882
- * Applies environment variables to the provided schema and state object.
883
- *
884
- * It replaces also all templated $ENV inside string values.
885
- *
886
- * @param schema - The schema object to apply environment variables to.
887
- * @return The schema object with environment variables applied.
888
- */
911
+ * Applies environment variables to the provided schema and state object.
912
+ *
913
+ * It replaces also all templated $ENV inside string values.
914
+ *
915
+ * @param schema - The schema object to apply environment variables to.
916
+ * @return The schema object with environment variables applied.
917
+ */
889
918
  parseEnv<T extends TObject$1>(schema: T): Static$1<T>;
919
+ // -------------------------------------------------------------------------------------------------------------------
890
920
  /**
891
- * Dump the current dependency graph of the App.
892
- *
893
- * This method returns a record where the keys are the names of the services.
894
- */
921
+ * Dump the current dependency graph of the App.
922
+ *
923
+ * This method returns a record where the keys are the names of the services.
924
+ */
895
925
  graph(): Record<string, {
896
926
  from: string[];
897
927
  as?: string;
898
928
  module?: string;
899
929
  }>;
930
+ // -------------------------------------------------------------------------------------------------------------------
900
931
  /**
901
- * @internal
902
- */
932
+ * @internal
933
+ */
903
934
  getDescriptorValues<T extends Descriptor>(descriptor: T): Array<DescriptorItem<T>>;
904
935
  /**
905
- * @internal
906
- */
936
+ * @internal
937
+ */
907
938
  protected new<T extends object>(definition: Service<T>, args?: any[], module?: ModuleDefinition): T;
908
939
  /**
909
- * @internal
910
- */
940
+ * @internal
941
+ */
911
942
  protected createLogger(env: Env): Logger;
912
- /**
913
- * @internal
914
- */
915
943
  getModuleOf(service: Service): Module | undefined;
916
944
  }
945
+ // ---------------------------------------------------------------------------------------------------------------------
917
946
  /**
918
- * This is how we store services in the Alepha container.
919
- */
947
+ * This is how we store services in the Alepha container.
948
+ */
920
949
  interface ServiceDefinition<T extends object = any> {
921
950
  /**
922
- * The class or type definition to provide.
923
- */
951
+ * The class or type definition to provide.
952
+ */
924
953
  provide: Service<T>;
925
954
  /**
926
- * The class or type definition to use. This will override the 'provide' property.
927
- */
955
+ * The class or type definition to use. This will override the 'provide' property.
956
+ */
928
957
  use?: Service<T>;
929
958
  /**
930
- * The instance of the class or type definition.
931
- * Mostly used for caching / singleton but can be used for other purposes like forcing the instance.
932
- */
959
+ * The instance of the class or type definition.
960
+ * Mostly used for caching / singleton but can be used for other purposes like forcing the instance.
961
+ */
933
962
  instance: T;
934
963
  /**
935
- * List of classes which use this class.
936
- */
964
+ * List of classes which use this class.
965
+ */
937
966
  parents: Array<Service | null>;
938
967
  /**
939
- * If the service is provided by a module, the module definition.
940
- */
968
+ * If the service is provided by a module, the module definition.
969
+ */
941
970
  module?: ModuleDefinition;
942
971
  }
943
972
  //#endregion
944
973
  //#region src/interfaces/Run.d.ts
945
974
  interface RunOptions {
946
975
  /**
947
- * Environment variables to be used by the application.
948
- * If not provided, it will use the current process environment.
949
- */
976
+ * Environment variables to be used by the application.
977
+ * If not provided, it will use the current process environment.
978
+ */
950
979
  env?: Env;
951
980
  /**
952
- * A callback that will be executed before the application starts.
953
- */
981
+ * A callback that will be executed before the application starts.
982
+ */
954
983
  configure?: (alepha: Alepha) => Async<void>;
955
984
  /**
956
- * A callback that will be executed once the application is ready.
957
- * This is useful for initializing resources or starting background tasks.
958
- */
985
+ * A callback that will be executed once the application is ready.
986
+ * This is useful for initializing resources or starting background tasks.
987
+ */
959
988
  ready?: (alepha: Alepha) => Async<void>;
960
989
  /**
961
- * If true, the application will stop after the ready callback is executed.
962
- */
990
+ * If true, the application will stop after the ready callback is executed.
991
+ */
963
992
  once?: boolean;
964
993
  }
965
994
  //#endregion
966
995
  //#region src/descriptors/$inject.d.ts
967
996
  /**
968
- * Get the instance of the specified type from the context.
969
- *
970
- * - If the type is a class, it will be resolved from the context.
971
- * - If the type is a schema, it will be parsed from the environment.
972
- *
973
- * ```ts
974
- * class A { }
975
- * class B {
976
- * a = $inject(A);
977
- * }
978
- * ```
979
- *
980
- * @param type - Type (or TypeBox schema) to resolve
981
- * @returns Instance of the specified type
982
- */
997
+ * Get the instance of the specified type from the context.
998
+ *
999
+ * - If the type is a class, it will be resolved from the context.
1000
+ * - If the type is a schema, it will be parsed from the environment.
1001
+ *
1002
+ * ```ts
1003
+ * class A { }
1004
+ * class B {
1005
+ * a = $inject(A);
1006
+ * }
1007
+ * ```
1008
+ *
1009
+ * @param type - Type (or TypeBox schema) to resolve
1010
+ * @returns Instance of the specified type
1011
+ */
983
1012
  declare function $inject<T extends TObject$1>(type: T): Static$1<T>;
984
1013
  declare function $inject<T extends object>(type: Service<T>): T;
985
- /**
986
- * @alias $inject
987
- */
988
- declare const $env: typeof $inject;
1014
+ declare class InjectResolverRegistry {
1015
+ resolvers: Array<(it: any) => any>;
1016
+ register(fn: (it: any) => any): void;
1017
+ resolve(it: any): any;
1018
+ }
1019
+ declare const $injectResolverRegistry: InjectResolverRegistry;
989
1020
  //#endregion
990
1021
  //#region src/descriptors/$logger.d.ts
1022
+ // ---------------------------------------------------------------------------------------------------------------------
991
1023
  /**
992
- * Create a logger.
993
- *
994
- * `name` is optional, by default it will use the name of the service.
995
- *
996
- * @example
997
- * ```ts
998
- * import { $logger } from "@alepha/core";
999
- *
1000
- * class MyService {
1001
- * log = $logger();
1002
- *
1003
- * constructor() {
1004
- * // print something like 'date - [MyService] Service initialized'
1005
- * this.log.info("Service initialized");
1006
- * }
1007
- * }
1008
- * ```
1009
- */
1024
+ * Create a logger.
1025
+ *
1026
+ * `name` is optional, by default it will use the name of the service.
1027
+ *
1028
+ * @example
1029
+ * ```ts
1030
+ * import { $logger } from "alepha";
1031
+ *
1032
+ * class MyService {
1033
+ * log = $logger();
1034
+ *
1035
+ * constructor() {
1036
+ * // print something like 'date - [MyService] Service initialized'
1037
+ * this.log.info("Service initialized");
1038
+ * }
1039
+ * }
1040
+ * ```
1041
+ */
1010
1042
  declare const $logger: (name?: string) => Logger;
1011
1043
  //#endregion
1012
1044
  //#region src/errors/AlephaError.d.ts
1045
+ // ---------------------------------------------------------------------------------------------------------------------
1013
1046
  /**
1014
- * Default error class for Alepha.
1015
- */
1047
+ * Default error class for Alepha.
1048
+ */
1016
1049
  declare class AlephaError extends Error {}
1017
1050
  //#endregion
1018
1051
  //#region src/errors/AppNotStartedError.d.ts
@@ -1042,245 +1075,217 @@ declare class TypeBoxError extends Error {
1042
1075
  }
1043
1076
  //#endregion
1044
1077
  //#region src/providers/TypeProvider.d.ts
1078
+ // ---------------------------------------------------------------------------------------------------------------------
1045
1079
  declare class TypeProvider {
1046
1080
  static DEFAULT_STRING_MAX_LENGTH: number;
1047
1081
  static DEFAULT_LONG_STRING_MAX_LENGTH: number;
1048
1082
  static DEFAULT_RICH_STRING_MAX_LENGTH: number;
1049
1083
  static DEFAULT_ARRAY_MAX_ITEMS: number;
1050
- static FormatRegistry: typeof TypeBox.FormatRegistry;
1051
- Type: TypeBox.JavaScriptTypeBuilder;
1052
- any: (options?: SchemaOptions) => TypeBox.TAny;
1053
- void: (options?: SchemaOptions) => TypeBox.TVoid;
1054
- undefined: (options?: SchemaOptions) => TypeBox.TUndefined;
1055
- record: <Key extends TSchema$1, Value extends TSchema$1>(key: Key, value: Value, options?: ObjectOptions) => TypeBox.TRecordOrObject<Key, Value>;
1056
- omit: {
1057
- <Type extends TSchema$1, Key extends PropertyKey[]>(type: Type, key: readonly [...Key], options?: SchemaOptions): TypeBox.TOmit<Type, Key>;
1058
- <Type extends TSchema$1, Key extends TSchema$1>(type: Type, key: Key, options?: SchemaOptions): TypeBox.TOmit<Type, Key>;
1059
- };
1060
- union: <Types extends TSchema$1[]>(types: [...Types], options?: SchemaOptions) => Union<Types>;
1061
- partial: {
1062
- <MappedResult extends TypeBox.TMappedResult>(type: MappedResult, options?: SchemaOptions): TypeBox.TPartialFromMappedResult<MappedResult>;
1063
- <Type extends TSchema$1>(type: Type, options?: SchemaOptions): TypeBox.TPartial<Type>;
1064
- };
1065
- composite: <T extends TSchema$1[]>(schemas: [...T], options?: ObjectOptions) => TypeBox.TComposite<T>;
1066
- pick: {
1067
- <Type extends TSchema$1, Key extends PropertyKey[]>(type: Type, key: readonly [...Key], options?: SchemaOptions): TypeBox.TPick<Type, Key>;
1068
- <Type extends TSchema$1, Key extends TSchema$1>(type: Type, key: Key, options?: SchemaOptions): TypeBox.TPick<Type, Key>;
1069
- };
1070
- clean: typeof TypeBoxValue.Clean;
1071
- /**
1072
- * Create a schema for an object.
1073
- *
1074
- * @param properties The properties of the object.
1075
- * @param options The options for the object.
1076
- */
1077
- object: <T extends TProperties>(properties: T, options?: ObjectOptions) => TObject$1<T>;
1078
- /**
1079
- * Create a schema for an array.
1080
- *
1081
- * @param schema
1082
- * @param options
1083
- */
1084
- array: <T extends TSchema$1>(schema: T, options?: ArrayOptions) => TArray<T>;
1085
- /**
1086
- * Create a schema for a string.
1087
- *
1088
- * @param options
1089
- */
1090
- string: (options?: AlephaStringOptions) => TString;
1091
- /**
1092
- * Create a schema for a JSON object.
1093
- *
1094
- * @param options
1095
- */
1096
- json: (options?: SchemaOptions) => TypeBox.TRecord<TString, TypeBox.TAny>;
1097
- /**
1098
- * Create a schema for a boolean.
1099
- *
1100
- * @param options
1101
- */
1102
- boolean: (options?: SchemaOptions) => TBoolean;
1103
- /**
1104
- * Create a schema for a number.
1105
- *
1106
- * @param options
1107
- */
1108
- number: (options?: NumberOptions) => TNumber;
1109
- /**
1110
- * Create a schema for an unsigned 8-bit integer.
1111
- *
1112
- * @param options
1113
- */
1114
- uchar: (options?: IntegerOptions) => TInteger;
1115
- /**
1116
- * Create a schema for an unsigned 32-bit integer.
1117
- */
1118
- uint: (options?: IntegerOptions) => TNumber;
1119
- /**
1120
- * Create a schema for a signed 32-bit integer.
1121
- */
1122
- int: (options?: IntegerOptions) => TInteger;
1123
- /**
1124
- * Create a schema for a bigint. Bigint is a 64-bit integer.
1125
- * This is a workaround for TypeBox, which does not support bigint natively.
1126
- */
1127
- bigint: (options?: IntegerOptions) => TNumber;
1128
- /**
1129
- * Make a schema optional.
1130
- *
1131
- * @param schema The schema to make optional.
1132
- */
1133
- optional: <T extends TSchema$1>(schema: T) => TOptionalWithFlag<T, true>;
1134
- /**
1135
- * Nullify all properties of a schema.
1136
- *
1137
- * @param schema The schema to nullify.
1138
- * @param options The options for the schema.
1139
- */
1140
- nullify: <T extends TSchema$1>(schema: T, options?: ObjectOptions) => TObject$1<TypeBox.Evaluate<TypeBox.TMappedFunctionReturnType<TypeBox.TIndexPropertyKeys<TypeBox.TKeyOf<T>>, TypeBox.TUnion<[TNull, TypeBox.TMappedResult<TypeBox.Evaluate<TypeBox.TIndexPropertyKeys<TypeBox.TKeyOf<T>> extends infer T_1 ? T_1 extends TypeBox.TIndexPropertyKeys<TypeBox.TKeyOf<T>> ? T_1 extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? Right extends [infer Left extends PropertyKey, ...infer Right extends PropertyKey[]] ? /*elided*/any : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema$1> } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema$1> } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema$1> } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema$1> } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema$1> } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema$1> } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema$1> } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema$1> } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema$1> } : { [_ in Left]: TypeBox.Assert<TypeBox.TIndexFromPropertyKey<T, Left>, TSchema$1> } : {} : never : never>>]>, {}>>>;
1141
- /**
1142
- * Make a schema nullable.
1143
- *
1144
- * @param schema The schema to make nullable.
1145
- * @param options The options for the schema.
1146
- */
1147
- nullable: <T extends TSchema$1>(schema: T, options?: ObjectOptions) => Union<[TNull, T]>;
1148
- /**
1149
- * Map a schema to another schema.
1150
- *
1151
- * @param schema The schema to map.
1152
- * @param operations The operations to perform on the schema.
1153
- * @param options The options for the schema.
1154
- * @returns The mapped schema.
1155
- */
1156
- map: <T extends TObject$1 | TIntersect, Omit extends (keyof T["properties"])[], Optional extends (keyof T["properties"])[]>(schema: T, operations: {
1084
+ static FormatRegistry: typeof FormatRegistry;
1085
+ raw: typeof Type;
1086
+ any(options?: SchemaOptions): TAny$1;
1087
+ void(options?: SchemaOptions): TVoid;
1088
+ undefined(options?: SchemaOptions): TUndefined;
1089
+ record<Key extends TSchema$1, Value extends TSchema$1>(key: Key, value: Value, options?: ObjectOptions): TRecordOrObject<Key, Value>;
1090
+ omit<Type extends TSchema$1, Key extends TSchema$1>(type: Type, key: Key, options?: SchemaOptions): TOmit<Type, Key>;
1091
+ partial<MappedResult extends TMappedResult>(type: MappedResult, options?: SchemaOptions): TPartialFromMappedResult<MappedResult>;
1092
+ union<Types extends TSchema$1[]>(types: [...Types], options?: SchemaOptions): Union<Types>;
1093
+ composite<T extends TSchema$1[]>(schemas: [...T], options?: ObjectOptions): TComposite<T>;
1094
+ pick<Type extends TSchema$1, Key extends PropertyKey[]>(type: Type, key: readonly [...Key], options?: SchemaOptions): TPick<Type, Key>;
1095
+ /**
1096
+ * Create a schema for an object.
1097
+ *
1098
+ * @param properties The properties of the object.
1099
+ * @param options The options for the object.
1100
+ */
1101
+ object<T extends TProperties$1>(properties: T, options?: ObjectOptions): TObject$1<T>;
1102
+ /**
1103
+ * Create a schema for an array.
1104
+ *
1105
+ * @param schema
1106
+ * @param options
1107
+ */
1108
+ array<T extends TSchema$1>(schema: T, options?: ArrayOptions): TArray$1<T>;
1109
+ /**
1110
+ * Create a schema for a string.
1111
+ *
1112
+ * @param options
1113
+ */
1114
+ string(options?: AlephaStringOptions): TString$1;
1115
+ /**
1116
+ * Create a schema for a JSON object.
1117
+ *
1118
+ * @param options
1119
+ */
1120
+ json(options?: SchemaOptions): TRecord$1<TString$1, TAny$1>;
1121
+ /**
1122
+ * Create a schema for a boolean.
1123
+ *
1124
+ * @param options
1125
+ */
1126
+ boolean(options?: SchemaOptions): TBoolean$1;
1127
+ /**
1128
+ * Create a schema for a number.
1129
+ *
1130
+ * @param options
1131
+ */
1132
+ number(options?: NumberOptions): TNumber$1;
1133
+ /**
1134
+ * Create a schema for an unsigned 8-bit integer.
1135
+ *
1136
+ * @param options
1137
+ */
1138
+ uchar(options?: IntegerOptions): TInteger;
1139
+ /**
1140
+ * Create a schema for an unsigned 32-bit integer.
1141
+ */
1142
+ uint(options?: IntegerOptions): TNumber$1;
1143
+ /**
1144
+ * Create a schema for a signed 32-bit integer.
1145
+ */
1146
+ int(options?: IntegerOptions): TInteger;
1147
+ /**
1148
+ * Create a schema for a signed 32-bit integer.
1149
+ */
1150
+ integer(options?: IntegerOptions): TInteger;
1151
+ /**
1152
+ * Create a schema for a bigint. Bigint is a 64-bit integer.
1153
+ * This is a workaround for TypeBox, which does not support bigint natively.
1154
+ */
1155
+ bigint(options?: IntegerOptions): TNumber$1;
1156
+ /**
1157
+ * Make a schema optional.
1158
+ *
1159
+ * @param schema The schema to make optional.
1160
+ */
1161
+ optional<T extends TSchema$1>(schema: T): TOptionalWithFlag<T, true>;
1162
+ /**
1163
+ * Make a schema nullable.
1164
+ *
1165
+ * @param schema The schema to make nullable.
1166
+ * @param options The options for the schema.
1167
+ */
1168
+ nullable<T extends TSchema$1>(schema: T, options?: ObjectOptions): TUnion<[TNull, T]>;
1169
+ /**
1170
+ * Map a schema to another schema.
1171
+ *
1172
+ * @param schema The schema to map.
1173
+ * @param operations The operations to perform on the schema.
1174
+ * @param options The options for the schema.
1175
+ * @returns The mapped schema.
1176
+ */
1177
+ map<T extends TObject$1 | TIntersect, Omit extends (keyof T["properties"])[], Optional extends (keyof T["properties"])[]>(schema: T, operations: {
1157
1178
  omit: readonly [...Omit];
1158
1179
  optional: [...Optional];
1159
- }, options?: ObjectOptions) => TObject$1<TypeBox.Evaluate<TypeBox.TSetDistinct<[...TypeBox.TKeyOfPropertyKeys<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_1 ? T_1 extends [...Omit, ...Optional] ? T_1 extends TypeBox.TRef<string> ? true : false : never : never>>, ...TypeBox.TKeyOfPropertyKeys<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>>], []> extends infer T_2 ? T_2 extends TypeBox.TSetDistinct<[...TypeBox.TKeyOfPropertyKeys<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_53 ? T_53 extends [...Omit, ...Optional] ? T_53 extends TypeBox.TRef<string> ? true : false : never : never>>, ...TypeBox.TKeyOfPropertyKeys<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>>], []> ? T_2 extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? R extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? /*elided*/any : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_3 ? T_3 extends [...Omit, ...Optional] ? T_3 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> extends infer T_4 ? T_4 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_7 ? T_7 extends [...Omit, ...Optional] ? T_7 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> ? T_4 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_5 ? T_5 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_5 extends TypeBox.TNever ? [] : [T_5] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_6 ? T_6 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_6 extends TypeBox.TNever ? [T_4] : [T_4, T_6] : never : never : never : never> } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_8 ? T_8 extends [...Omit, ...Optional] ? T_8 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> extends infer T_9 ? T_9 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_12 ? T_12 extends [...Omit, ...Optional] ? T_12 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> ? T_9 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_10 ? T_10 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_10 extends TypeBox.TNever ? [] : [T_10] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_11 ? T_11 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_11 extends TypeBox.TNever ? [T_9] : [T_9, T_11] : never : never : never : never> } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_13 ? T_13 extends [...Omit, ...Optional] ? T_13 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> extends infer T_14 ? T_14 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_17 ? T_17 extends [...Omit, ...Optional] ? T_17 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> ? T_14 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_15 ? T_15 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_15 extends TypeBox.TNever ? [] : [T_15] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_16 ? T_16 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_16 extends TypeBox.TNever ? [T_14] : [T_14, T_16] : never : never : never : never> } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_18 ? T_18 extends [...Omit, ...Optional] ? T_18 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> extends infer T_19 ? T_19 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_22 ? T_22 extends [...Omit, ...Optional] ? T_22 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> ? T_19 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_20 ? T_20 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_20 extends TypeBox.TNever ? [] : [T_20] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_21 ? T_21 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_21 extends TypeBox.TNever ? [T_19] : [T_19, T_21] : never : never : never : never> } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_23 ? T_23 extends [...Omit, ...Optional] ? T_23 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> extends infer T_24 ? T_24 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_27 ? T_27 extends [...Omit, ...Optional] ? T_27 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> ? T_24 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_25 ? T_25 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_25 extends TypeBox.TNever ? [] : [T_25] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_26 ? T_26 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_26 extends TypeBox.TNever ? [T_24] : [T_24, T_26] : never : never : never : never> } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_28 ? T_28 extends [...Omit, ...Optional] ? T_28 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> extends infer T_29 ? T_29 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_32 ? T_32 extends [...Omit, ...Optional] ? T_32 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> ? T_29 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_30 ? T_30 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_30 extends TypeBox.TNever ? [] : [T_30] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_31 ? T_31 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_31 extends TypeBox.TNever ? [T_29] : [T_29, T_31] : never : never : never : never> } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_33 ? T_33 extends [...Omit, ...Optional] ? T_33 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> extends infer T_34 ? T_34 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_37 ? T_37 extends [...Omit, ...Optional] ? T_37 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> ? T_34 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_35 ? T_35 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_35 extends TypeBox.TNever ? [] : [T_35] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_36 ? T_36 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_36 extends TypeBox.TNever ? [T_34] : [T_34, T_36] : never : never : never : never> } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_38 ? T_38 extends [...Omit, ...Optional] ? T_38 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> extends infer T_39 ? T_39 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_42 ? T_42 extends [...Omit, ...Optional] ? T_42 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> ? T_39 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_40 ? T_40 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_40 extends TypeBox.TNever ? [] : [T_40] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_41 ? T_41 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_41 extends TypeBox.TNever ? [T_39] : [T_39, T_41] : never : never : never : never> } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_43 ? T_43 extends [...Omit, ...Optional] ? T_43 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> extends infer T_44 ? T_44 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_47 ? T_47 extends [...Omit, ...Optional] ? T_47 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> ? T_44 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_45 ? T_45 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_45 extends TypeBox.TNever ? [] : [T_45] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_46 ? T_46 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_46 extends TypeBox.TNever ? [T_44] : [T_44, T_46] : never : never : never : never> } : { [_ in L]: TypeBox.TIntersectEvaluated<TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_48 ? T_48 extends [...Omit, ...Optional] ? T_48 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> extends infer T_49 ? T_49 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TOmit<T, [...Omit, ...Optional], T extends TypeBox.TRef<string> ? true : false, [...Omit, ...Optional] extends infer T_52 ? T_52 extends [...Omit, ...Optional] ? T_52 extends TypeBox.TRef<string> ? true : false : never : never>, L>, TSchema$1> ? T_49 extends TypeBox.TNever ? TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_50 ? T_50 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_50 extends TypeBox.TNever ? [] : [T_50] : never : never : TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> extends infer T_51 ? T_51 extends TypeBox.Assert<TypeBox.TIndexFromPropertyKey<TypeBox.TPartial<TypeBox.TPick<T, Optional, T extends TypeBox.TRef<string> ? true : false, Optional extends TypeBox.TRef<string> ? true : false>>, L>, TSchema$1> ? T_51 extends TypeBox.TNever ? [T_49] : [T_49, T_51] : never : never : never : never> } : {} : never : never>>;
1160
- /**
1161
- * Create a schema for a string enum.
1162
- *
1163
- * @param values
1164
- * @param options
1165
- */
1166
- enum: <T extends string[]>(values: [...T], options?: StringOptions) => TUnsafe<T[number]>;
1167
- /**
1168
- * Create a schema for a string enum e.g. LIKE_THIS.
1169
- *
1170
- * @param options
1171
- */
1172
- snakeCase: (options?: StringOptions) => TString;
1173
- /**
1174
- * Create a schema for an object with a value and label.
1175
- *
1176
- * @param options
1177
- */
1178
- valueLabel: (options?: ObjectOptions) => TObject$1<{
1179
- value: TString;
1180
- label: TString;
1181
- description: TypeBox.TOptional<TString>;
1182
- }>;
1183
- /**
1184
- * Create a schema for a datetime.
1185
- *
1186
- * @param options The options for the date.
1187
- */
1188
- datetime: (options?: StringOptions) => TString;
1189
- /**
1190
- * Create a schema for a date.
1191
- *
1192
- * @param options
1193
- */
1194
- date: (options?: StringOptions) => TString;
1195
- /**
1196
- * Create a schema for uuid.
1197
- *
1198
- * @param options The options for the duration.
1199
- */
1200
- uuid: (options?: StringOptions) => TString;
1201
- /**
1202
- *
1203
- *
1204
- * @param kind
1205
- * @param options
1206
- */
1207
- unsafe: <T>(kind: string, options?: UnsafeOptions) => TUnsafe<T>;
1208
- file: (options?: {
1180
+ }, options?: ObjectOptions): TComposite<[TOmit<T, [...Omit, ...Optional]>, TPartial<TPick<T, Optional>>]>;
1181
+ /**
1182
+ * Create a schema for a string enum.
1183
+ *
1184
+ * @param values
1185
+ * @param options
1186
+ */
1187
+ enum<T extends string[]>(values: [...T], options?: StringOptions): TUnsafe<T[number]>;
1188
+ /**
1189
+ * Create a schema for a datetime.
1190
+ *
1191
+ * @param options The options for the date.
1192
+ */
1193
+ datetime(options?: StringOptions): TString$1;
1194
+ /**
1195
+ * Create a schema for a date.
1196
+ *
1197
+ * @param options
1198
+ */
1199
+ date(options?: StringOptions): TString$1;
1200
+ /**
1201
+ * Create a schema for uuid.
1202
+ *
1203
+ * @param options The options for the duration.
1204
+ */
1205
+ uuid(options?: StringOptions): TString$1;
1206
+ unsafe<T>(kind: string, options?: UnsafeOptions): TUnsafe<T>;
1207
+ file(options?: {
1209
1208
  max?: number;
1210
- }) => TFile;
1211
- stream: () => TStream;
1209
+ }): TFile;
1210
+ stream(): TStream;
1212
1211
  }
1212
+ // ---------------------------------------------------------------------------------------------------------------------
1213
1213
  interface FileLike {
1214
1214
  /**
1215
- * Filename.
1216
- * @default "file"
1217
- */
1215
+ * Filename.
1216
+ * @default "file"
1217
+ */
1218
1218
  name: string;
1219
1219
  /**
1220
- * Mandatory MIME type of the file.
1221
- * @default "application/octet-stream"
1222
- */
1220
+ * Mandatory MIME type of the file.
1221
+ * @default "application/octet-stream"
1222
+ */
1223
1223
  type: string;
1224
1224
  /**
1225
- * Size of the file in bytes.
1226
- *
1227
- * Always 0 for streams, as the size is not known until the stream is fully read.
1228
- *
1229
- * @default 0
1230
- */
1225
+ * Size of the file in bytes.
1226
+ *
1227
+ * Always 0 for streams, as the size is not known until the stream is fully read.
1228
+ *
1229
+ * @default 0
1230
+ */
1231
1231
  size: number;
1232
1232
  /**
1233
- * Last modified timestamp in milliseconds since epoch.
1234
- *
1235
- * Always the current timestamp for streams, as the last modified time is not known.
1236
- * We use this field to ensure compatibility with File API.
1237
- *
1238
- * @default Date.now()
1239
- */
1233
+ * Last modified timestamp in milliseconds since epoch.
1234
+ *
1235
+ * Always the current timestamp for streams, as the last modified time is not known.
1236
+ * We use this field to ensure compatibility with File API.
1237
+ *
1238
+ * @default Date.now()
1239
+ */
1240
1240
  lastModified: number;
1241
1241
  /**
1242
- * Returns a ReadableStream or Node.js Readable stream of the file content.
1243
- *
1244
- * For streams, this is the original stream.
1245
- */
1242
+ * Returns a ReadableStream or Node.js Readable stream of the file content.
1243
+ *
1244
+ * For streams, this is the original stream.
1245
+ */
1246
1246
  stream(): StreamLike;
1247
1247
  /**
1248
- * Returns the file content as an ArrayBuffer.
1249
- *
1250
- * For streams, this reads the entire stream into memory.
1251
- */
1248
+ * Returns the file content as an ArrayBuffer.
1249
+ *
1250
+ * For streams, this reads the entire stream into memory.
1251
+ */
1252
1252
  arrayBuffer(): Promise<ArrayBuffer>;
1253
1253
  /**
1254
- * Returns the file content as a string.
1255
- *
1256
- * For streams, this reads the entire stream into memory and converts it to a string.
1257
- */
1254
+ * Returns the file content as a string.
1255
+ *
1256
+ * For streams, this reads the entire stream into memory and converts it to a string.
1257
+ */
1258
1258
  text(): Promise<string>;
1259
+ // -- node specific fields --
1259
1260
  /**
1260
- * Optional file path, if the file is stored on disk.
1261
- *
1262
- * This is not from the File API, but rather a custom field to indicate where the file is stored.
1263
- */
1261
+ * Optional file path, if the file is stored on disk.
1262
+ *
1263
+ * This is not from the File API, but rather a custom field to indicate where the file is stored.
1264
+ */
1264
1265
  filepath?: string;
1265
1266
  }
1266
1267
  /**
1267
- * TypeBox view of FileLike.
1268
- */
1268
+ * TypeBox view of FileLike.
1269
+ */
1269
1270
  type TFile = TUnsafe<FileLike>;
1270
1271
  declare const isTypeFile: (value: TSchema$1) => value is TFile;
1271
1272
  declare const isFileLike: (value: any) => value is FileLike;
1273
+ // ---------------------------------------------------------------------------------------------------------------------
1272
1274
  type StreamLike = ReadableStream | ReadableStream$1 | Readable | NodeJS.ReadableStream;
1273
1275
  type TStream = TUnsafe<StreamLike>;
1274
1276
  declare const isTypeStream: (value: TSchema$1) => value is TStream;
1277
+ // ---------------------------------------------------------------------------------------------------------------------
1275
1278
  type TextLength = "short" | "long" | "rich";
1276
1279
  interface AlephaStringOptions extends StringOptions {
1277
1280
  size?: TextLength;
1278
1281
  }
1282
+ // ---------------------------------------------------------------------------------------------------------------------
1279
1283
  declare const t: TypeProvider;
1284
+ // ---------------------------------------------------------------------------------------------------------------------
1280
1285
  declare const isUUID: (value: string) => boolean;
1281
1286
  //#endregion
1282
1287
  //#region src/index.d.ts
1283
1288
  declare const run: (entry: Alepha | Service | Array<Service>, opts?: RunOptions) => Alepha;
1284
1289
  //#endregion
1285
- export { $cursor, $env, $hook, $inject, $logger, AbstractService, Alepha, AlephaError, AlephaStringOptions, AppNotStartedError, Async, AsyncFn, AsyncLocalStorageData, AsyncLocalStorageProvider, COLORS, CircularDependencyError, ContainerLockedError, CursorDescriptor, Descriptor, DescriptorIdentifier, DescriptorItem, Env, FileLike, Hook, HookDescriptor, HookOptions, Hooks, InstantiableService, KIND, LEVEL_COLORS, LogLevel, Logger, LoggerEnv, LoggerOptions, MaybePromise, MockLogger, MockLoggerStore, Module, ModuleDefinition, NotImplementedError, OPTIONS, PromiseFn, Service, ServiceEntry, ServiceSubstitution, State, Static, StaticDecode, StaticEncode, StreamLike, TFile, TObject, TSchema, TStream, TextLength, TypeBox, TypeBoxError, TypeBoxValue, TypeGuard, TypeProvider, __alephaRef, __bind, __descriptor, descriptorEvents, isDescriptorValue, isFileLike, isModule, isTypeFile, isTypeStream, isUUID, run, t, toModuleName };
1290
+ export { $cursor, $hook, $inject, $injectResolverRegistry, $logger, AbstractService, Alepha, AlephaError, AlephaStringOptions, AlsProvider, AppNotStartedError, Async, AsyncFn, AsyncLocalStorageData, COLORS, CircularDependencyError, ContainerLockedError, CursorDescriptor, Descriptor, DescriptorIdentifier, DescriptorItem, Env, FileLike, Hook, HookDescriptor, HookOptions, Hooks, InstantiableService, KIND, LEVEL_COLORS, LogLevel, Logger, LoggerEnv, LoggerOptions, MaybePromise, MockLogger, MockLoggerStore, Module, ModuleDefinition, NotImplementedError, OPTIONS, PromiseFn, Service, ServiceEntry, ServiceSubstitution, State, Static, StaticDecode, StaticEncode, StreamLike, TAny, TArray, TBoolean, TFile, TNumber, TObject, TOptional, TProperties, TRecord, TSchema, TStream, TString, TextLength, TypeBox, TypeBoxError, TypeBoxValue, TypeGuard, TypeProvider, __alephaRef, __bind, __descriptor, descriptorEvents, isDescriptorValue, isFileLike, isModule, isTypeFile, isTypeStream, isUUID, run, t, toModuleName };
1286
1291
  //# sourceMappingURL=index.d.ts.map