alepha 0.9.3 → 0.9.5

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.
package/core.d.ts CHANGED
@@ -2,7 +2,7 @@ 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, 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, TNull, TNumber, TNumber as TNumber$1, TObject, TObject as TObject$1, TOmit, TOptional, TOptionalWithFlag, TPartial, TPick, TProperties, TProperties as TProperties$1, TRecord, TRecord as TRecord$1, TSchema, TSchema as TSchema$1, TString, TString as TString$1, TUnion, TUnsafe, TypeGuard, 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, TNull, TNull as TNull$1, TNumber, TNumber as TNumber$1, TObject, TObject as TObject$1, TOmit, TOptional, TOptionalWithFlag, TPartial, TPick, TProperties, TProperties as TProperties$1, TRecord, TRecord as TRecord$1, TSchema, TSchema as TSchema$1, TString, TString as TString$1, TUnion, TUnion as TUnion$1, TUnsafe, TypeGuard, UnsafeOptions } from "@sinclair/typebox";
6
6
  import { ValueError } from "@sinclair/typebox/errors";
7
7
  import { Readable } from "node:stream";
8
8
  import { ReadableStream as ReadableStream$1 } from "node:stream/web";
@@ -14,7 +14,6 @@ import { ReadableStream as ReadableStream$1 } from "node:stream/web";
14
14
  * @internal
15
15
  */
16
16
  declare const KIND: unique symbol;
17
- //# sourceMappingURL=KIND.d.ts.map
18
17
  //#endregion
19
18
  //#region src/constants/MODULE.d.ts
20
19
  /**
@@ -23,16 +22,6 @@ declare const KIND: unique symbol;
23
22
  * @internal
24
23
  */
25
24
  declare const MODULE: unique symbol;
26
- //# sourceMappingURL=MODULE.d.ts.map
27
- //#endregion
28
- //#region src/constants/OPTIONS.d.ts
29
- /**
30
- * Used for descriptors options.
31
- *
32
- * @internal
33
- */
34
- declare const OPTIONS: unique symbol;
35
- //# sourceMappingURL=OPTIONS.d.ts.map
36
25
  //#endregion
37
26
  //#region src/interfaces/Service.d.ts
38
27
  /**
@@ -79,7 +68,6 @@ interface ServiceSubstitution<T extends object = any> {
79
68
  * And yes, you declare the *type* of the service, not the *instance*.
80
69
  */
81
70
  type ServiceEntry<T extends object = any> = Service<T> | ServiceSubstitution<T>;
82
- //# sourceMappingURL=Service.d.ts.map
83
71
  //#endregion
84
72
  //#region src/helpers/descriptor.d.ts
85
73
  interface DescriptorArgs<T extends object = {}> {
@@ -114,23 +102,58 @@ type DescriptorFactoryLike<T extends object = any> = {
114
102
  declare const createDescriptor: <TDescriptor extends Descriptor>(descriptor: InstantiableClass<TDescriptor> & {
115
103
  [MODULE]?: Service;
116
104
  }, options: TDescriptor["options"]) => TDescriptor;
117
- //# sourceMappingURL=descriptor.d.ts.map
118
105
  //#endregion
119
- //#region src/descriptors/$module.d.ts
106
+ //#region src/descriptors/$inject.d.ts
120
107
  /**
121
- * Wrap services and descriptors into a module.
108
+ * Get the instance of the specified type from the context.
122
109
  *
123
- * Module is just a class.
124
- * You must attach a `name` to it.
110
+ * ```ts
111
+ * class A { }
112
+ * class B {
113
+ * a = $inject(A);
114
+ * }
115
+ * ```
116
+ */
117
+ declare const $inject: <T extends object>(type: Service<T>, opts?: InjectOptions<T>) => T;
118
+ declare class InjectDescriptor extends Descriptor {}
119
+ interface InjectOptions<T extends object = any> {
120
+ /**
121
+ * - 'transient' → Always a new instance on every inject. Zero caching.
122
+ * - 'singleton' → One instance per Alepha runtime (per-thread). Never disposed until Alepha shuts down. (default)
123
+ * - 'scoped' → One instance per AsyncLocalStorage context.
124
+ * - A new scope is created when Alepha handles a request, a scheduled job, a queue worker task...
125
+ * - You can also start a manual scope via alepha.context.run(() => { ... }).
126
+ * - When the scope ends, the scoped registry is discarded.
127
+ *
128
+ * @default "singleton"
129
+ */
130
+ lifetime?: "transient" | "singleton" | "scoped";
131
+ /**
132
+ * Constructor arguments to pass when creating a new instance.
133
+ */
134
+ args?: ConstructorParameters<InstantiableClass<T>>;
135
+ /**
136
+ * Parent that requested the instance.
137
+ *
138
+ * @internal
139
+ */
140
+ parent?: Service | null;
141
+ }
142
+ //#endregion
143
+ //#region src/descriptors/$module.d.ts
144
+ /**
145
+ * Wrap Services and Descriptors into a Module.
125
146
  *
126
- * It's recommended to use `project.module.submodule` format.
147
+ * - A module is just a Service extended {@link Module}.
148
+ * - You must attach a `name` to it.
149
+ * - Name must follow the pattern: `project.module.submodule`.
127
150
  *
128
151
  * @example
129
152
  * ```ts
130
153
  * import { $module } from "alepha";
131
154
  * import { MyService } from "./MyService.ts";
132
155
  *
133
- * // export MyService so it can be used everywhere
156
+ * // export MyService, so it can be used everywhere
134
157
  * export * from "./MyService.ts";
135
158
  *
136
159
  * export default $module({
@@ -140,9 +163,30 @@ declare const createDescriptor: <TDescriptor extends Descriptor>(descriptor: Ins
140
163
  * });
141
164
  * ```
142
165
  *
143
- * - Module is used for logging and other purposes.
144
- * - It's useful for large applications or libraries to group services and descriptors together.
145
- * - It's probably overkill for small applications.
166
+ * ## Why Modules?
167
+ *
168
+ * ### Logging
169
+ *
170
+ * By default, AlephaLogger will log the module name in the logs.
171
+ * This helps to identify where the logs are coming from.
172
+ *
173
+ * You can also set different log levels for different modules.
174
+ * It means you can set 'some.very.specific.module' to 'debug' and keep the rest of the application to 'info'.
175
+ *
176
+ * ### Modulith
177
+ *
178
+ * Force to structure your application in modules, even if it's a single deployable unit.
179
+ * It helps to keep a clean architecture and avoid monolithic applications.
180
+ *
181
+ * You can also use `MODULE_INCLUDE` and `MODULE_EXCLUDE` environment variables to load only specific modules.
182
+ *
183
+ * A strict mode is planned to enforce module boundaries. Throwing errors when a service from another module is injected.
184
+ *
185
+ * ### When not to use Modules?
186
+ *
187
+ * Small applications does not need modules. It's better to keep it simple.
188
+ * Modules are more useful when the application grows and needs to be structured.
189
+ * If we speak with `$actions`, a module should be used when you have more than 30 actions in a single module.
146
190
  */
147
191
  declare const $module: (options: ModuleDescriptorOptions) => Service<Module>;
148
192
  interface ModuleDescriptorOptions {
@@ -167,17 +211,25 @@ interface ModuleDescriptorOptions {
167
211
  */
168
212
  register?: (alepha: Alepha) => void;
169
213
  }
170
- interface Module {
171
- [KIND]: "MODULE";
172
- [OPTIONS]: ModuleDescriptorOptions;
173
- register: (alepha: Alepha) => void;
214
+ /**
215
+ * Base class for all modules.
216
+ */
217
+ declare abstract class Module {
218
+ abstract readonly options: ModuleDescriptorOptions;
219
+ abstract register(alepha: Alepha): void;
220
+ static NAME_REGEX: RegExp;
221
+ /**
222
+ * Check if a Service is a Module.
223
+ */
224
+ static is(ctor: Service): boolean;
225
+ /**
226
+ * Get the Module of a Service.
227
+ */
228
+ static of(ctor: Service): Service<Module> | undefined;
174
229
  }
175
- type ServiceWithModule<T extends object = any> = T & {
230
+ type WithModule<T extends object = any> = T & {
176
231
  [MODULE]?: Service;
177
232
  };
178
- declare const isModule: (value: unknown) => value is Module;
179
- declare const toModuleName: (name: string) => string;
180
- //# sourceMappingURL=$module.d.ts.map
181
233
  //#endregion
182
234
  //#region src/interfaces/Async.d.ts
183
235
  /**
@@ -192,7 +244,16 @@ type AsyncFn = (...args: any[]) => Async<any>;
192
244
  * Transforms a type T into a promise if it is not already a promise.
193
245
  */
194
246
  type MaybePromise<T> = T extends Promise<any> ? T : Promise<T>;
195
- //# sourceMappingURL=Async.d.ts.map
247
+ //#endregion
248
+ //#region src/interfaces/LoggerInterface.d.ts
249
+ type LogLevel = "error" | "warn" | "info" | "debug" | "trace" | "silent";
250
+ interface LoggerInterface {
251
+ trace(message: string, data?: unknown): void;
252
+ debug(message: string, data?: unknown): void;
253
+ info(message: string, data?: unknown): void;
254
+ warn(message: string, data?: unknown): void;
255
+ error(message: string, data?: unknown): void;
256
+ }
196
257
  //#endregion
197
258
  //#region src/providers/AlsProvider.d.ts
198
259
  type AsyncLocalStorageData = any;
@@ -206,150 +267,6 @@ declare class AlsProvider {
206
267
  get<T>(key: string): T | undefined;
207
268
  set<T>(key: string, value: T): void;
208
269
  }
209
- //# sourceMappingURL=AlsProvider.d.ts.map
210
- //#endregion
211
- //#region src/services/Logger.d.ts
212
- type LogLevel = "error" | "warn" | "info" | "debug" | "trace" | "silent";
213
- interface LoggerEnv {
214
- /**
215
- * Default log level for the application.
216
- * Default by environment:
217
- * - dev = "debug"
218
- * - test = "error"
219
- * - prod = "info"
220
- *
221
- * "trace" | "debug" | "info" | "warn" | "error" | "silent"
222
- */
223
- LOG_LEVEL?: string;
224
- /**
225
- * Disable colors in the console output.
226
- */
227
- NO_COLOR?: string;
228
- /**
229
- * Force color output for the application.
230
- */
231
- FORCE_COLOR?: string;
232
- /**
233
- * Log format.
234
- *
235
- * @default "text"
236
- */
237
- LOG_FORMAT?: "json" | "text" | "cli" | "raw";
238
- }
239
- interface LoggerOptions {
240
- /**
241
- * The logging level. Can be one of "error", "warn", "info", "debug", or "trace".
242
- */
243
- level?: string;
244
- /**
245
- * The name of the application. Used to identify the source of the log messages.
246
- */
247
- app?: string;
248
- /**
249
- * The name of the logger. Like a module name or a service name.
250
- */
251
- name?: string;
252
- /**
253
- * An optional context to include in the log output. Like a request ID or a correlation ID.
254
- */
255
- context?: string;
256
- /**
257
- * An optional tag to include in the log output. Like a class name or a module name.
258
- */
259
- caller?: string;
260
- /**
261
- * Whether to use colors in the log output. Defaults to true.
262
- */
263
- color?: boolean;
264
- /**
265
- * Log output format. Can be "json", "text", or "cli".
266
- */
267
- format?: string;
268
- /**
269
- * An optional async local storage provider to use for storing context information.
270
- */
271
- als?: AlsProvider;
272
- }
273
- declare const COLORS: {
274
- reset: string;
275
- grey: string;
276
- red: string;
277
- orange: string;
278
- green: string;
279
- blue: string;
280
- white: string;
281
- cyan: string;
282
- darkGrey: string;
283
- };
284
- declare const LEVEL_COLORS: Record<string, string>;
285
- declare class Logger {
286
- protected levelOrder: Record<string, number>;
287
- readonly level: string;
288
- readonly rawLevel: string;
289
- readonly name: string;
290
- protected caller: string;
291
- protected context: string;
292
- protected app: string;
293
- protected color: boolean;
294
- protected format: string;
295
- protected als?: AlsProvider;
296
- constructor(options?: LoggerOptions);
297
- parseLevel(level: string, app: string): LogLevel;
298
- asLogLevel(something: string): LogLevel;
299
- child(options: LoggerOptions): Logger;
300
- error(message: unknown, data?: object | Error | string | unknown): void;
301
- warn(message: unknown, data?: object | Error | string | unknown): void;
302
- info(message: unknown, data?: object | Error | string): void;
303
- debug(message: unknown, data?: object | Error | string): void;
304
- trace(message: unknown, data?: object | Error | string): void;
305
- /**
306
- * Log a message to the console.
307
- */
308
- protected log(level: LogLevel, message: unknown, data?: object | Error | string): void;
309
- /**
310
- * Print a log message to the console.
311
- */
312
- protected print(formatted: string): void;
313
- /**
314
- * Format a log message to JSON.
315
- */
316
- protected formatJson(level: LogLevel, message: unknown, data?: object | Error | string): string;
317
- protected formatJsonError(error: Error): object;
318
- /**
319
- * Format a log message to a string.
320
- */
321
- protected formatLog(level: LogLevel, message: string, data?: object | Error): string;
322
- protected nowTimeFormatted(): string;
323
- protected pad2: (n: number) => string;
324
- protected pad3: (n: number) => string;
325
- protected colorize(color: string, text: string, reset?: string): string;
326
- /**
327
- * Format an error to a string.
328
- *
329
- * @param error
330
- * @protected
331
- */
332
- protected formatError(error: Error): string;
333
- }
334
- declare class MockLogger extends Logger {
335
- store: MockLoggerStore;
336
- constructor(options?: LoggerOptions & {
337
- store: MockLoggerStore;
338
- });
339
- print(msg: string): void;
340
- child(options: LoggerOptions): MockLogger;
341
- reset(): void;
342
- }
343
- interface MockLoggerStore {
344
- stack: Array<{
345
- date: string;
346
- level: string;
347
- message: string;
348
- context?: string;
349
- app?: string;
350
- } & Record<string, any>>;
351
- }
352
- //# sourceMappingURL=Logger.d.ts.map
353
270
  //#endregion
354
271
  //#region src/Alepha.d.ts
355
272
  /**
@@ -450,7 +367,7 @@ interface MockLoggerStore {
450
367
  * onCustomerHook = $hook({
451
368
  * on: "my:custom:hook",
452
369
  * handler: () => {
453
- * this.log.info("App is being configured");
370
+ * this.log?.info("App is being configured");
454
371
  * },
455
372
  * });
456
373
  * }
@@ -472,6 +389,8 @@ interface MockLoggerStore {
472
389
  * }
473
390
  * }
474
391
  * ```
392
+ *
393
+ * @module alepha
475
394
  */
476
395
  declare class Alepha {
477
396
  /**
@@ -577,7 +496,7 @@ declare class Alepha {
577
496
  /**
578
497
  * Get logger instance.
579
498
  */
580
- get log(): Logger;
499
+ get log(): LoggerInterface | undefined;
581
500
  /**
582
501
  * The environment variables for the App.
583
502
  */
@@ -664,15 +583,27 @@ declare class Alepha {
664
583
  /**
665
584
  * Check if the entry is registered in the pending instantiation stack.
666
585
  *
667
- * Default: true
586
+ * @default true
668
587
  */
669
588
  inStack?: boolean;
670
589
  /**
671
590
  * Check if the entry is registered in the container registry.
672
591
  *
673
- * Default: true
592
+ * @default true
674
593
  */
675
594
  inRegistry?: boolean;
595
+ /**
596
+ * Check if the entry is registered in the substitutions.
597
+ *
598
+ * @default true
599
+ */
600
+ inSubstitutions?: boolean;
601
+ /**
602
+ * Where to look for registered services.
603
+ *
604
+ * @default this.registry
605
+ */
606
+ registry?: Map<Service, ServiceDefinition>;
676
607
  }): boolean;
677
608
  /**
678
609
  * Registers the specified service in the container.
@@ -704,34 +635,11 @@ declare class Alepha {
704
635
  default: ServiceEntry<T>;
705
636
  }): this;
706
637
  /**
707
- * Get the instance of the specified service and apply some changes, depending on the options.
708
- * - If the service is already registered, it will return the existing instance. (except if `skipCache` is true)
709
- * - If the service is not registered, it will create a new instance and register it. (except if `skipRegistration` is true)
710
- * - New instance can be created with custom constructor arguments. (`args` option)
711
- *
712
- * > This method is used by $inject() under the hood.
638
+ * Get an instance of the specified service from the container.
713
639
  *
714
- * @return The instance of the specified class or type.
640
+ * @see {@link InjectOptions} for the available options.
715
641
  */
716
- inject<T extends object>(service: Service<T>, opts?: {
717
- /**
718
- * Ignore current existing instance.
719
- */
720
- skipCache?: boolean;
721
- /**
722
- * Don't store the instance in the registry.
723
- */
724
- skipRegistration?: boolean;
725
- /**
726
- * Constructor arguments to pass when creating a new instance.
727
- */
728
- args?: ConstructorParameters<InstantiableClass<T>>;
729
- /**
730
- * Parent service that requested the instance.
731
- * @internal
732
- */
733
- parent?: Service | null;
734
- }): T;
642
+ inject<T extends object>(service: Service<T>, opts?: InjectOptions<T>): T;
735
643
  /**
736
644
  * Configures the specified service with the provided state.
737
645
  * If service is not registered, it will do nothing.
@@ -786,6 +694,11 @@ declare class Alepha {
786
694
  * It uses the TypeBox library to validate the value against the schema.
787
695
  */
788
696
  parse<T extends TSchema$1>(schema: T, value?: any, opts?: {
697
+ /**
698
+ * Convert `null` to `undefined`
699
+ * @default true
700
+ */
701
+ convertNullToUndefined?: boolean;
789
702
  /**
790
703
  * Clone the value before parsing.
791
704
  * @default true
@@ -832,14 +745,10 @@ declare class Alepha {
832
745
  module?: string;
833
746
  }>;
834
747
  descriptors<TDescriptor extends Descriptor>(factory: {
835
- [KIND]: InstantiableClass<TDescriptor> | string;
836
- }): Array<TDescriptor>;
748
+ [KIND]: InstantiableClass<TDescriptor>;
749
+ } | string): Array<TDescriptor>;
837
750
  protected new<T extends object>(service: Service<T>, args?: any[]): T;
838
751
  protected processDescriptor(value: Descriptor, propertyKey?: string): void;
839
- /**
840
- * @internal
841
- */
842
- protected createLogger(env: Env): Logger;
843
752
  }
844
753
  interface Hook<T extends keyof Hooks = any> {
845
754
  caller?: Service;
@@ -859,12 +768,8 @@ interface ServiceDefinition<T extends object = any> {
859
768
  * List of classes which use this class.
860
769
  */
861
770
  parents: Array<Service | null>;
862
- /**
863
- * If the service is provided by a module, the module definition.
864
- */
865
- module?: Service;
866
771
  }
867
- interface Env extends LoggerEnv {
772
+ interface Env {
868
773
  [key: string]: string | boolean | number | undefined;
869
774
  /**
870
775
  * Optional environment variable that indicates the current environment.
@@ -880,7 +785,7 @@ interface Env extends LoggerEnv {
880
785
  MODULE_NAME?: string;
881
786
  }
882
787
  interface State {
883
- log: Logger;
788
+ log?: LoggerInterface;
884
789
  env?: Readonly<Env>;
885
790
  /**
886
791
  * If defined, the Alepha container will only register this service and its dependencies.
@@ -957,7 +862,14 @@ interface RunOptions {
957
862
  */
958
863
  cluster?: boolean;
959
864
  }
960
- //# sourceMappingURL=Run.d.ts.map
865
+ //#endregion
866
+ //#region src/constants/OPTIONS.d.ts
867
+ /**
868
+ * Used for descriptors options.
869
+ *
870
+ * @internal
871
+ */
872
+ declare const OPTIONS: unique symbol;
961
873
  //#endregion
962
874
  //#region src/constants/PRIMITIVE.d.ts
963
875
  /**
@@ -968,8 +880,6 @@ interface RunOptions {
968
880
  * @internal
969
881
  */
970
882
  declare const PRIMITIVE: unique symbol;
971
- //# sourceMappingURL=PRIMITIVE.d.ts.map
972
-
973
883
  //#endregion
974
884
  //#region src/descriptors/$cursor.d.ts
975
885
  /**
@@ -1016,7 +926,6 @@ interface CursorDescriptor {
1016
926
  definition?: Service;
1017
927
  module?: Service;
1018
928
  }
1019
- //# sourceMappingURL=$cursor.d.ts.map
1020
929
  //#endregion
1021
930
  //#region src/descriptors/$env.d.ts
1022
931
  /**
@@ -1046,8 +955,6 @@ interface CursorDescriptor {
1046
955
  * ```
1047
956
  */
1048
957
  declare const $env: <T extends TObject$1>(type: T) => Static$1<T>;
1049
- //# sourceMappingURL=$env.d.ts.map
1050
-
1051
958
  //#endregion
1052
959
  //#region src/descriptors/$hook.d.ts
1053
960
  /**
@@ -1101,7 +1008,7 @@ interface HookOptions<T extends keyof Hooks> {
1101
1008
  /**
1102
1009
  * The handler to run when the hook is triggered.
1103
1010
  */
1104
- handler: (app: Hooks[T]) => Async<any>;
1011
+ handler: (args: Hooks[T]) => Async<any>;
1105
1012
  /**
1106
1013
  * Force the hook to run first or last on the list of hooks.
1107
1014
  */
@@ -1119,52 +1026,6 @@ declare class HookDescriptor<T extends keyof Hooks> extends Descriptor<HookOptio
1119
1026
  called: number;
1120
1027
  protected onInit(): void;
1121
1028
  }
1122
- //# sourceMappingURL=$hook.d.ts.map
1123
- //#endregion
1124
- //#region src/descriptors/$inject.d.ts
1125
- /**
1126
- * Get the instance of the specified type from the context.
1127
- *
1128
- * ```ts
1129
- * class A { }
1130
- * class B {
1131
- * a = $inject(A);
1132
- * }
1133
- * ```
1134
- */
1135
- declare const $inject: <T extends object>(type: Service<T>) => T;
1136
- declare class InjectDescriptor extends Descriptor {}
1137
- //# sourceMappingURL=$inject.d.ts.map
1138
-
1139
- //#endregion
1140
- //#region src/descriptors/$logger.d.ts
1141
- /**
1142
- * Create a logger.
1143
- *
1144
- * `name` is optional, by default it will use the name of the service.
1145
- *
1146
- * @example
1147
- * ```ts
1148
- * import { $logger } from "alepha";
1149
- *
1150
- * class MyService {
1151
- * log = $logger();
1152
- *
1153
- * constructor() {
1154
- * // print something like 'date - [MyService] Service initialized'
1155
- * this.log.info("Service initialized");
1156
- * }
1157
- * }
1158
- * ```
1159
- */
1160
- declare const $logger: {
1161
- (options?: LoggerDescriptorOptions): Logger;
1162
- [KIND]: typeof Logger;
1163
- };
1164
- interface LoggerDescriptorOptions {
1165
- name?: string;
1166
- }
1167
- //# sourceMappingURL=$logger.d.ts.map
1168
1029
  //#endregion
1169
1030
  //#region src/errors/AlephaError.d.ts
1170
1031
  /**
@@ -1173,43 +1034,79 @@ interface LoggerDescriptorOptions {
1173
1034
  declare class AlephaError extends Error {
1174
1035
  name: string;
1175
1036
  }
1176
- //# sourceMappingURL=AlephaError.d.ts.map
1177
1037
  //#endregion
1178
1038
  //#region src/errors/AppNotStartedError.d.ts
1179
- declare class AppNotStartedError extends Error {
1039
+ declare class AppNotStartedError extends AlephaError {
1180
1040
  readonly name = "AppNotStartedError";
1181
1041
  constructor();
1182
1042
  }
1183
- //# sourceMappingURL=AppNotStartedError.d.ts.map
1184
1043
  //#endregion
1185
1044
  //#region src/errors/CircularDependencyError.d.ts
1186
- declare class CircularDependencyError extends Error {
1045
+ declare class CircularDependencyError extends AlephaError {
1187
1046
  readonly name = "CircularDependencyError";
1188
1047
  constructor(provider: string, parents?: string[]);
1189
1048
  }
1190
- //# sourceMappingURL=CircularDependencyError.d.ts.map
1191
1049
  //#endregion
1192
1050
  //#region src/errors/ContainerLockedError.d.ts
1193
- declare class ContainerLockedError extends Error {
1051
+ declare class ContainerLockedError extends AlephaError {
1194
1052
  readonly name = "ContainerLockedError";
1195
1053
  constructor(message?: string);
1196
1054
  }
1197
- //# sourceMappingURL=ContainerLockedError.d.ts.map
1055
+ //#endregion
1056
+ //#region src/errors/TooLateSubstitutionError.d.ts
1057
+ declare class TooLateSubstitutionError extends AlephaError {
1058
+ readonly name = "TooLateSubstitutionError";
1059
+ constructor(original: string, substitution: string);
1060
+ }
1198
1061
  //#endregion
1199
1062
  //#region src/errors/TypeBoxError.d.ts
1200
- declare class TypeBoxError extends Error {
1063
+ declare class TypeBoxError extends AlephaError {
1201
1064
  readonly name = "TypeBoxError";
1202
1065
  readonly value: ValueError;
1203
1066
  constructor(value: ValueError);
1204
1067
  }
1205
- //# sourceMappingURL=TypeBoxError.d.ts.map
1206
-
1207
1068
  //#endregion
1208
1069
  //#region src/providers/TypeProvider.d.ts
1209
1070
  declare class TypeProvider {
1210
- static DEFAULT_STRING_MAX_LENGTH: number;
1211
- static DEFAULT_LONG_STRING_MAX_LENGTH: number;
1212
- static DEFAULT_RICH_STRING_MAX_LENGTH: number;
1071
+ /**
1072
+ * Default maximum length for strings.
1073
+ *
1074
+ * It can be set to a larger value:
1075
+ * ```ts
1076
+ * TypeProvider.DEFAULT_STRING_MAX_LENGTH = 1000000;
1077
+ * TypeProvider.DEFAULT_STRING_MAX_LENGTH = undefined; // no limit (not recommended)
1078
+ * ```
1079
+ */
1080
+ static DEFAULT_STRING_MAX_LENGTH: number | undefined;
1081
+ static DEFAULT_SHORT_STRING_MAX_LENGTH: number | undefined;
1082
+ /**
1083
+ * Maximum length for long strings, such as descriptions or comments.
1084
+ * It can be overridden in the string options.
1085
+ *
1086
+ * It can be set to a larger value:
1087
+ * ```ts
1088
+ * TypeProvider.DEFAULT_LONG_STRING_MAX_LENGTH = 2048;
1089
+ * ```
1090
+ */
1091
+ static DEFAULT_LONG_STRING_MAX_LENGTH: number | undefined;
1092
+ /**
1093
+ * Maximum length for rich strings, such as HTML or Markdown.
1094
+ * This is a large value to accommodate rich text content.
1095
+ * > It's also the maximum length of PG's TEXT type.
1096
+ *
1097
+ * It can be overridden in the string options.
1098
+ *
1099
+ * It can be set to a larger value:
1100
+ * ```ts
1101
+ * TypeProvider.DEFAULT_RICH_STRING_MAX_LENGTH = 1000000;
1102
+ * ```
1103
+ */
1104
+ static DEFAULT_RICH_STRING_MAX_LENGTH: number | undefined;
1105
+ /**
1106
+ * Maximum number of items in an array.
1107
+ * This is a default value to prevent excessive memory usage.
1108
+ * It can be overridden in the array options.
1109
+ */
1213
1110
  static DEFAULT_ARRAY_MAX_ITEMS: number;
1214
1111
  static FormatRegistry: typeof FormatRegistry;
1215
1112
  raw: TypeBox.JavaScriptTypeBuilder;
@@ -1304,8 +1201,8 @@ declare class TypeProvider {
1304
1201
  * @param schema The schema to make nullable.
1305
1202
  * @param options The options for the schema.
1306
1203
  */
1307
- nullable<T extends TSchema$1>(schema: T, options?: ObjectOptions): TUnion<[TNull, T]>;
1308
- nullify: <T extends TSchema$1>(schema: T, options?: ObjectOptions) => TObject$1<TypeBox.Evaluate<TypeBox.TMappedFunctionReturnType<TypeBox.TIndexPropertyKeys<TypeBox.TKeyOf<T>>, 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>>]>, {}>>>;
1204
+ nullable<T extends TSchema$1>(schema: T, options?: ObjectOptions): TUnion$1<[TNull$1, T]>;
1205
+ nullify: <T extends TSchema$1>(schema: T, options?: ObjectOptions) => TObject$1<TypeBox.Evaluate<TypeBox.TMappedFunctionReturnType<TypeBox.TIndexPropertyKeys<TypeBox.TKeyOf<T>>, TUnion$1<[TNull$1, 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>>]>, {}>>>;
1309
1206
  /**
1310
1207
  * Map a schema to another schema.
1311
1208
  *
@@ -1424,7 +1321,6 @@ declare const isTypeFile: (value: TSchema$1) => value is TFile;
1424
1321
  declare const isFileLike: (value: any) => value is FileLike;
1425
1322
  type StreamLike = ReadableStream | ReadableStream$1 | Readable | NodeJS.ReadableStream;
1426
1323
  type TStream = TUnsafe<StreamLike>;
1427
- declare const isTypeStream: (value: TSchema$1) => value is TStream;
1428
1324
  type TextLength = "short" | "long" | "rich";
1429
1325
  interface AlephaStringOptions extends StringOptions {
1430
1326
  size?: TextLength;
@@ -1434,7 +1330,6 @@ declare function isISODate(str: string): boolean;
1434
1330
  declare function isISODateTime(value: string): boolean;
1435
1331
  declare function isUUID(value: string): boolean;
1436
1332
  declare function isEmail(value: string): boolean;
1437
- //# sourceMappingURL=TypeProvider.d.ts.map
1438
1333
  //#endregion
1439
1334
  //#region src/index.d.ts
1440
1335
  declare global {
@@ -1449,8 +1344,6 @@ declare global {
1449
1344
  *
1450
1345
  */
1451
1346
  declare const run: (entry: Alepha | Service | Array<Service>, opts?: RunOptions) => void;
1452
- //# sourceMappingURL=index.d.ts.map
1453
-
1454
1347
  //#endregion
1455
- export { $cursor, $env, $hook, $inject, $logger, $module, AbstractClass, Alepha, AlephaError, AlephaStringOptions, AlsProvider, AppNotStartedError, Async, AsyncFn, AsyncLocalStorageData, COLORS, CircularDependencyError, ContainerLockedError, CursorDescriptor, Descriptor, DescriptorArgs, DescriptorConfig, DescriptorFactory, DescriptorFactoryLike, Env, FileLike, Hook, HookDescriptor, HookOptions, Hooks, InjectDescriptor, InstantiableClass, KIND, LEVEL_COLORS, LogLevel, Logger, LoggerDescriptorOptions, LoggerEnv, LoggerOptions, MaybePromise, MockLogger, MockLoggerStore, Module, ModuleDescriptorOptions, OPTIONS, PRIMITIVE, Service, ServiceEntry, ServiceSubstitution, ServiceWithModule, State, type Static, type StaticDecode, type StaticEncode, StreamLike, type TAny, type TArray, type TBoolean, TFile, type TNumber, type TObject, type TOptional, type TProperties, type TRecord, type TSchema, TStream, type TString, TextLength, TypeBox, TypeBoxError, TypeBoxValue, TypeGuard, TypeProvider, __alephaRef, createDescriptor, isEmail, isFileLike, isISODate, isISODateTime, isModule, isTypeFile, isTypeStream, isUUID, run, t, toModuleName };
1348
+ export { $cursor, $env, $hook, $inject, $module, AbstractClass, Alepha, AlephaError, AlephaStringOptions, AlsProvider, AppNotStartedError, Async, AsyncFn, AsyncLocalStorageData, CircularDependencyError, ContainerLockedError, CursorDescriptor, Descriptor, DescriptorArgs, DescriptorConfig, DescriptorFactory, DescriptorFactoryLike, Env, FileLike, Hook, HookDescriptor, HookOptions, Hooks, InjectDescriptor, InjectOptions, InstantiableClass, KIND, LogLevel, LoggerInterface, MaybePromise, Module, ModuleDescriptorOptions, OPTIONS, PRIMITIVE, Service, ServiceEntry, ServiceSubstitution, State, type Static, type StaticDecode, type StaticEncode, StreamLike, type TAny, type TArray, type TBoolean, TFile, type TNull, type TNumber, type TObject, type TOptional, type TProperties, type TRecord, type TSchema, TStream, type TString, type TUnion, TextLength, TooLateSubstitutionError, TypeBox, TypeBoxError, TypeBoxValue, TypeGuard, TypeProvider, WithModule, __alephaRef, createDescriptor, isEmail, isFileLike, isISODate, isISODateTime, isTypeFile, isUUID, run, t };
1456
1349
  //# sourceMappingURL=index.d.ts.map