alepha 0.10.5 → 0.10.7

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
@@ -28,13 +28,13 @@ declare const MODULE: unique symbol;
28
28
  /**
29
29
  * In Alepha, a service is a class that can be instantiated or an abstract class. Nothing more, nothing less...
30
30
  */
31
- type Service<T extends object = any> = InstantiableClass<T> | AbstractClass<T>;
32
- type InstantiableClass<T extends object = any> = new (...args: any[]) => T;
31
+ type Service<T$1 extends object = any> = InstantiableClass<T$1> | AbstractClass<T$1>;
32
+ type InstantiableClass<T$1 extends object = any> = new (...args: any[]) => T$1;
33
33
  /**
34
34
  * Abstract class is a class that cannot be instantiated directly!
35
35
  * It widely used for defining interfaces.
36
36
  */
37
- type AbstractClass<T extends object = any> = abstract new (...args: any[]) => T;
37
+ type AbstractClass<T$1 extends object = any> = abstract new (...args: any[]) => T$1;
38
38
  /**
39
39
  * Service substitution allows you to register a class as a different class.
40
40
  * Providing class A, but using class B instead.
@@ -42,17 +42,17 @@ type AbstractClass<T extends object = any> = abstract new (...args: any[]) => T;
42
42
  *
43
43
  * class A is mostly an AbstractClass, while class B is an InstantiableClass.
44
44
  */
45
- interface ServiceSubstitution<T extends object = any> {
45
+ interface ServiceSubstitution<T$1 extends object = any> {
46
46
  /**
47
47
  * Every time someone asks for this class, it will be provided with the 'use' class.
48
48
  */
49
- provide: Service<T>;
49
+ provide: Service<T$1>;
50
50
  /**
51
51
  * Service to use instead of the 'provide' service.
52
52
  *
53
53
  * Syntax is inspired by Angular's DI system.
54
54
  */
55
- use: Service<T>;
55
+ use: Service<T$1>;
56
56
  /**
57
57
  * If true, if the service already exists -> just ignore the substitution and do not throw an error.
58
58
  * Mostly used for plugins to enforce a substitution without throwing an error.
@@ -68,11 +68,11 @@ interface ServiceSubstitution<T extends object = any> {
68
68
  *
69
69
  * And yes, you declare the *type* of the service, not the *instance*.
70
70
  */
71
- type ServiceEntry<T extends object = any> = Service<T> | ServiceSubstitution<T>;
71
+ type ServiceEntry<T$1 extends object = any> = Service<T$1> | ServiceSubstitution<T$1>;
72
72
  //#endregion
73
73
  //#region src/helpers/descriptor.d.ts
74
- interface DescriptorArgs<T extends object = {}> {
75
- options: T;
74
+ interface DescriptorArgs<T$1 extends object = {}> {
75
+ options: T$1;
76
76
  alepha: Alepha;
77
77
  service: InstantiableClass<Service>;
78
78
  module?: Service;
@@ -82,22 +82,22 @@ interface DescriptorConfig {
82
82
  service: InstantiableClass<Service>;
83
83
  module?: Service;
84
84
  }
85
- declare abstract class Descriptor<T extends object = {}> {
85
+ declare abstract class Descriptor<T$1 extends object = {}> {
86
86
  protected readonly alepha: Alepha;
87
- readonly options: T;
87
+ readonly options: T$1;
88
88
  readonly config: DescriptorConfig;
89
- constructor(args: DescriptorArgs<T>);
89
+ constructor(args: DescriptorArgs<T$1>);
90
90
  /**
91
91
  * Called automatically by Alepha after the descriptor is created.
92
92
  */
93
93
  protected onInit(): void;
94
94
  }
95
- type DescriptorFactory<TDescriptor extends Descriptor = Descriptor> = {
96
- (options: TDescriptor["options"]): TDescriptor;
97
- [KIND]: InstantiableClass<TDescriptor>;
95
+ type DescriptorFactory<TDescriptor$1 extends Descriptor = Descriptor> = {
96
+ (options: TDescriptor$1["options"]): TDescriptor$1;
97
+ [KIND]: InstantiableClass<TDescriptor$1>;
98
98
  };
99
- type DescriptorFactoryLike<T extends object = any> = {
100
- (options: T): any;
99
+ type DescriptorFactoryLike<T$1 extends object = any> = {
100
+ (options: T$1): any;
101
101
  [KIND]: any;
102
102
  };
103
103
  declare const createDescriptor: <TDescriptor extends Descriptor>(descriptor: InstantiableClass<TDescriptor> & {
@@ -117,7 +117,7 @@ declare const createDescriptor: <TDescriptor extends Descriptor>(descriptor: Ins
117
117
  */
118
118
  declare const $inject: <T extends object>(type: Service<T>, opts?: InjectOptions<T>) => T;
119
119
  declare class InjectDescriptor extends Descriptor {}
120
- interface InjectOptions<T extends object = any> {
120
+ interface InjectOptions<T$1 extends object = any> {
121
121
  /**
122
122
  * - 'transient' → Always a new instance on every inject. Zero caching.
123
123
  * - 'singleton' → One instance per Alepha runtime (per-thread). Never disposed until Alepha shuts down. (default)
@@ -132,7 +132,7 @@ interface InjectOptions<T extends object = any> {
132
132
  /**
133
133
  * Constructor arguments to pass when creating a new instance.
134
134
  */
135
- args?: ConstructorParameters<InstantiableClass<T>>;
135
+ args?: ConstructorParameters<InstantiableClass<T$1>>;
136
136
  /**
137
137
  * Parent that requested the instance.
138
138
  *
@@ -190,7 +190,7 @@ interface InjectOptions<T extends object = any> {
190
190
  * If we speak with `$actions`, a module should be used when you have more than 30 actions in a single module.
191
191
  */
192
192
  declare const $module: <T extends object = {}>(options: ModuleDescriptorOptions<T>) => Service<Module<T>>;
193
- interface ModuleDescriptorOptions<T extends object> {
193
+ interface ModuleDescriptorOptions<T$1 extends object> {
194
194
  /**
195
195
  * Name of the module.
196
196
  *
@@ -210,16 +210,16 @@ interface ModuleDescriptorOptions<T extends object> {
210
210
  * You can override this behavior by providing a register function.
211
211
  * It's useful when you want to register services conditionally or in a specific order.
212
212
  */
213
- register?: (alepha: Alepha, options: T) => void;
213
+ register?: (alepha: Alepha, options: T$1) => void;
214
214
  }
215
215
  /**
216
216
  * Base class for all modules.
217
217
  */
218
- declare abstract class Module<T extends object = {}> {
219
- abstract readonly config: ModuleDescriptorOptions<T>;
218
+ declare abstract class Module<T$1 extends object = {}> {
219
+ abstract readonly config: ModuleDescriptorOptions<T$1>;
220
220
  abstract register(alepha: Alepha): void;
221
221
  static NAME_REGEX: RegExp;
222
- options: T;
222
+ options: T$1;
223
223
  /**
224
224
  * Check if a Service is a Module.
225
225
  */
@@ -229,7 +229,7 @@ declare abstract class Module<T extends object = {}> {
229
229
  */
230
230
  static of(ctor: Service): Service<Module> | undefined;
231
231
  }
232
- type WithModule<T extends object = any> = T & {
232
+ type WithModule<T$1 extends object = any> = T$1 & {
233
233
  [MODULE]?: Service;
234
234
  };
235
235
  //#endregion
@@ -237,7 +237,7 @@ type WithModule<T extends object = any> = T & {
237
237
  /**
238
238
  * Represents a value that can be either a value or a promise of value.
239
239
  */
240
- type Async<T> = T | Promise<T>;
240
+ type Async<T$1> = T$1 | Promise<T$1>;
241
241
  /**
242
242
  * Represents a function that returns an async value.
243
243
  */
@@ -245,7 +245,7 @@ type AsyncFn = (...args: any[]) => Async<any>;
245
245
  /**
246
246
  * Transforms a type T into a promise if it is not already a promise.
247
247
  */
248
- type MaybePromise<T> = T extends Promise<any> ? T : Promise<T>;
248
+ type MaybePromise<T$1> = T$1 extends Promise<any> ? T$1 : Promise<T$1>;
249
249
  //#endregion
250
250
  //#region src/interfaces/LoggerInterface.d.ts
251
251
  type LogLevel = "ERROR" | "WARN" | "INFO" | "DEBUG" | "TRACE" | "SILENT";
@@ -273,7 +273,7 @@ declare class EventManager {
273
273
  /**
274
274
  * Emits the specified event with the given payload.
275
275
  */
276
- emit<T extends keyof Hooks>(func: keyof Hooks, payload: Hooks[T], options?: {
276
+ emit<T extends keyof Hooks>(func: T, payload: Hooks[T], options?: {
277
277
  /**
278
278
  * If true, the hooks will be executed in reverse order.
279
279
  * This is useful for "stop" hooks that should be executed in reverse order.
@@ -630,10 +630,26 @@ declare class TypeProvider {
630
630
  * @experimental
631
631
  */
632
632
  stream(): TStream;
633
+ email(options?: TStringOptions$1): TString$1;
634
+ e164(options?: TStringOptions$1): TString$1;
635
+ bcp47(options?: TStringOptions$1): TString$1;
636
+ /**
637
+ * Create a schema for short text, such as names or titles.
638
+ * Default max length is 64 characters.
639
+ */
640
+ shortText(options?: TStringOptions$1): TString$1;
641
+ /**
642
+ * Create a schema for long text, such as descriptions or comments.
643
+ * Default max length is 1024 characters.
644
+ */
645
+ longText(options?: TStringOptions$1): TString$1;
646
+ /**
647
+ * Create a schema for rich text, such as HTML or Markdown.
648
+ * Default max length is 65535 characters.
649
+ */
650
+ richText(options?: TStringOptions$1): TString$1;
633
651
  /**
634
652
  * Create a schema for a string enum e.g. LIKE_THIS.
635
- *
636
- * @param options
637
653
  */
638
654
  snakeCase: (options?: TStringOptions$1) => TString$1;
639
655
  /**
@@ -935,12 +951,14 @@ declare class Alepha {
935
951
  * True if the App is running in a browser environment.
936
952
  */
937
953
  isBrowser(): boolean;
954
+ /**
955
+ * Returns whether the App is running in Vite dev mode.
956
+ */
957
+ isViteDev(): boolean;
938
958
  /**
939
959
  * Returns whether the App is running in a serverless environment.
940
- *
941
- * > Vite developer mode is also considered serverless.
942
960
  */
943
- isServerless(): boolean | "vite" | "vercel";
961
+ isServerless(): boolean | "vercel";
944
962
  /**
945
963
  * Returns whether the App is in test mode. (Running in a test environment)
946
964
  *
@@ -1126,20 +1144,20 @@ declare class Alepha {
1126
1144
  protected new<T extends object>(service: Service<T>, args?: any[]): T;
1127
1145
  protected processDescriptor(value: Descriptor, propertyKey?: string): void;
1128
1146
  }
1129
- interface Hook<T extends keyof Hooks = any> {
1147
+ interface Hook<T$1 extends keyof Hooks = any> {
1130
1148
  caller?: Service;
1131
1149
  priority?: "first" | "last";
1132
- callback: (payload: Hooks[T]) => Async<void>;
1150
+ callback: (payload: Hooks[T$1]) => Async<void>;
1133
1151
  }
1134
1152
  /**
1135
1153
  * This is how we store services in the Alepha container.
1136
1154
  */
1137
- interface ServiceDefinition<T extends object = any> {
1155
+ interface ServiceDefinition<T$1 extends object = any> {
1138
1156
  /**
1139
1157
  * The instance of the class or type definition.
1140
1158
  * Mostly used for caching / singleton but can be used for other purposes like forcing the instance.
1141
1159
  */
1142
- instance: T;
1160
+ instance: T$1;
1143
1161
  /**
1144
1162
  * List of classes which use this class.
1145
1163
  */
@@ -1211,6 +1229,9 @@ interface Hooks {
1211
1229
  prevValue: any;
1212
1230
  };
1213
1231
  }
1232
+ interface Configurable<T$1 extends object = any> {
1233
+ options: T$1;
1234
+ }
1214
1235
  //#endregion
1215
1236
  //#region src/interfaces/Run.d.ts
1216
1237
  interface RunOptions {
@@ -1366,15 +1387,15 @@ declare const $hook: {
1366
1387
  <T extends keyof Hooks>(options: HookOptions<T>): HookDescriptor<T>;
1367
1388
  [KIND]: typeof HookDescriptor;
1368
1389
  };
1369
- interface HookOptions<T extends keyof Hooks> {
1390
+ interface HookOptions<T$1 extends keyof Hooks> {
1370
1391
  /**
1371
1392
  * The name of the hook. "configure", "start", "ready", "stop", ...
1372
1393
  */
1373
- on: T;
1394
+ on: T$1;
1374
1395
  /**
1375
1396
  * The handler to run when the hook is triggered.
1376
1397
  */
1377
- handler: (args: Hooks[T]) => Async<any>;
1398
+ handler: (args: Hooks[T$1]) => Async<any>;
1378
1399
  /**
1379
1400
  * Force the hook to run first or last on the list of hooks.
1380
1401
  */
@@ -1388,7 +1409,7 @@ interface HookOptions<T extends keyof Hooks> {
1388
1409
  */
1389
1410
  after?: object | Array<object>;
1390
1411
  }
1391
- declare class HookDescriptor<T extends keyof Hooks> extends Descriptor<HookOptions<T>> {
1412
+ declare class HookDescriptor<T$1 extends keyof Hooks> extends Descriptor<HookOptions<T$1>> {
1392
1413
  called: number;
1393
1414
  protected onInit(): void;
1394
1415
  }
@@ -1447,5 +1468,5 @@ declare global {
1447
1468
  */
1448
1469
  declare const run: (entry: Alepha | Service | Array<Service>, opts?: RunOptions) => void;
1449
1470
  //#endregion
1450
- export { $cursor, $env, $hook, $inject, $module, AbstractClass, Alepha, AlephaError, 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, Service, ServiceEntry, ServiceSubstitution, State, StateManager, type Static, type StaticDecode, type StaticEncode, StreamLike, type TAny, type TArray, type TBigInt, type TBoolean, TFile, type TInteger, type TKeysToIndexer, type TNull, type TNumber, type TNumberOptions, type TObject, type TObjectOptions, type TOptional, type TOptionalAdd, type TPick, type TProperties, type TRecord, type TSchema, TStream, type TString, type TStringOptions, TTextOptions, type TTuple, type TUnion, type TVoid, TextLength, TooLateSubstitutionError, TypeBox, TypeBoxError, TypeBoxFormat, TypeBoxValue, TypeGuard, TypeProvider, WithModule, __alephaRef, createDescriptor, isDate, isDateTime, isEmail, isFileLike, isTypeFile, isURL, isUUID, run, t };
1471
+ export { $cursor, $env, $hook, $inject, $module, AbstractClass, Alepha, AlephaError, AlsProvider, AppNotStartedError, Async, AsyncFn, AsyncLocalStorageData, CircularDependencyError, Configurable, ContainerLockedError, CursorDescriptor, Descriptor, DescriptorArgs, DescriptorConfig, DescriptorFactory, DescriptorFactoryLike, Env, FileLike, Hook, HookDescriptor, HookOptions, Hooks, InjectDescriptor, InjectOptions, InstantiableClass, KIND, LogLevel, LoggerInterface, MaybePromise, Module, ModuleDescriptorOptions, OPTIONS, Service, ServiceEntry, ServiceSubstitution, State, StateManager, type Static, type StaticDecode, type StaticEncode, StreamLike, type TAny, type TArray, type TBigInt, type TBoolean, TFile, type TInteger, type TKeysToIndexer, type TNull, type TNumber, type TNumberOptions, type TObject, type TObjectOptions, type TOptional, type TOptionalAdd, type TPick, type TProperties, type TRecord, type TSchema, TStream, type TString, type TStringOptions, TTextOptions, type TTuple, type TUnion, type TVoid, TextLength, TooLateSubstitutionError, TypeBox, TypeBoxError, TypeBoxFormat, TypeBoxValue, TypeGuard, TypeProvider, WithModule, __alephaRef, createDescriptor, isDate, isDateTime, isEmail, isFileLike, isTypeFile, isURL, isUUID, run, t };
1451
1472
  //# sourceMappingURL=index.d.ts.map