alepha 0.7.7 → 0.8.1

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