alepha 0.13.3 → 0.13.4
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/README.md +7 -7
- package/dist/api-files/index.d.ts +175 -175
- package/dist/api-jobs/index.d.ts +156 -156
- package/dist/api-notifications/index.d.ts +147 -147
- package/dist/api-verifications/index.d.ts +12 -12
- package/dist/core/index.browser.js +5 -1
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +221 -219
- package/dist/core/index.js +5 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +5 -1
- package/dist/core/index.native.js.map +1 -1
- package/dist/email/index.d.ts +4 -4
- package/dist/orm/index.d.ts +19 -19
- package/dist/server-auth/index.d.ts +152 -152
- package/dist/server-security/index.d.ts +9 -9
- package/package.json +1 -1
- package/src/core/Alepha.ts +14 -0
- package/src/core/primitives/$module.ts +1 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -130,169 +130,6 @@ interface LoggerInterface {
|
|
|
130
130
|
error(message: string, data?: unknown): void;
|
|
131
131
|
}
|
|
132
132
|
//#endregion
|
|
133
|
-
//#region src/core/primitives/$inject.d.ts
|
|
134
|
-
/**
|
|
135
|
-
* Get the instance of the specified type from the context.
|
|
136
|
-
*
|
|
137
|
-
* ```ts
|
|
138
|
-
* class A { }
|
|
139
|
-
* class B {
|
|
140
|
-
* a = $inject(A);
|
|
141
|
-
* }
|
|
142
|
-
* ```
|
|
143
|
-
*/
|
|
144
|
-
declare const $inject: <T extends object>(type: Service<T>, opts?: InjectOptions<T>) => T;
|
|
145
|
-
declare class InjectPrimitive extends Primitive {}
|
|
146
|
-
interface InjectOptions<T extends object = any> {
|
|
147
|
-
/**
|
|
148
|
-
* - 'transient' → Always a new instance on every inject. Zero caching.
|
|
149
|
-
* - 'singleton' → One instance per Alepha runtime (per-thread). Never disposed until Alepha shuts down. (default)
|
|
150
|
-
* - 'scoped' → One instance per AsyncLocalStorage context.
|
|
151
|
-
* - A new scope is created when Alepha handles a request, a scheduled job, a queue worker task...
|
|
152
|
-
* - You can also start a manual scope via alepha.context.run(() => { ... }).
|
|
153
|
-
* - When the scope ends, the scoped registry is discarded.
|
|
154
|
-
*
|
|
155
|
-
* @default "singleton"
|
|
156
|
-
*/
|
|
157
|
-
lifetime?: "transient" | "singleton" | "scoped";
|
|
158
|
-
/**
|
|
159
|
-
* Constructor arguments to pass when creating a new instance.
|
|
160
|
-
*/
|
|
161
|
-
args?: ConstructorParameters<InstantiableClass<T>>;
|
|
162
|
-
/**
|
|
163
|
-
* Parent that requested the instance.
|
|
164
|
-
*
|
|
165
|
-
* @internal
|
|
166
|
-
*/
|
|
167
|
-
parent?: Service | null;
|
|
168
|
-
}
|
|
169
|
-
//#endregion
|
|
170
|
-
//#region src/core/primitives/$module.d.ts
|
|
171
|
-
/**
|
|
172
|
-
* Wrap Services and Primitives into a Module.
|
|
173
|
-
*
|
|
174
|
-
* - A module is just a Service with some extra {@link Module}.
|
|
175
|
-
* - You must attach a `name` to it.
|
|
176
|
-
* - Name must follow the pattern: `project.module.submodule`. (e.g. `myapp.users.auth`).
|
|
177
|
-
*
|
|
178
|
-
* @example
|
|
179
|
-
* ```ts
|
|
180
|
-
* import { $module } from "alepha";
|
|
181
|
-
* import { MyService } from "./MyService.ts";
|
|
182
|
-
*
|
|
183
|
-
* // export MyService, so it can be used everywhere (optional)
|
|
184
|
-
* export * from "./MyService.ts";
|
|
185
|
-
*
|
|
186
|
-
* export default $module({
|
|
187
|
-
* name: "my.project.module",
|
|
188
|
-
* // MyService will have a module context "my.project.module"
|
|
189
|
-
* services: [MyService],
|
|
190
|
-
* });
|
|
191
|
-
* ```
|
|
192
|
-
*
|
|
193
|
-
* ### Why Modules?
|
|
194
|
-
*
|
|
195
|
-
* #### Logging
|
|
196
|
-
*
|
|
197
|
-
* By default, AlephaLogger will log the module name in the logs.
|
|
198
|
-
* This helps to identify where the logs are coming from.
|
|
199
|
-
*
|
|
200
|
-
* You can also set different log levels for different modules.
|
|
201
|
-
* It means you can set 'some.very.specific.module' to 'debug' and keep the rest of the application to 'info'.
|
|
202
|
-
*
|
|
203
|
-
* #### Modulith
|
|
204
|
-
*
|
|
205
|
-
* Force to structure your application in modules, even if it's a single deployable unit.
|
|
206
|
-
* It helps to keep a clean architecture and avoid monolithic applications.
|
|
207
|
-
*
|
|
208
|
-
* A strict mode flag will probably come to enforce module boundaries.
|
|
209
|
-
* -> Throwing errors when a service from another module is injected.
|
|
210
|
-
* But it's not implemented yet.
|
|
211
|
-
*
|
|
212
|
-
* ### When not to use Modules?
|
|
213
|
-
*
|
|
214
|
-
* Small applications does not need modules. It's better to keep it simple.
|
|
215
|
-
* Modules are more useful when the application grows and needs to be structured.
|
|
216
|
-
* If we speak with number of `$actions`, a module should be used when you have more than 30 actions in a single module.
|
|
217
|
-
* Meaning that if you have 100 actions, you should have at least 3 modules.
|
|
218
|
-
*/
|
|
219
|
-
declare const $module: <T extends object = {}>(options: ModulePrimitiveOptions) => Service<Module>;
|
|
220
|
-
interface ModulePrimitiveOptions {
|
|
221
|
-
/**
|
|
222
|
-
* Name of the module.
|
|
223
|
-
*
|
|
224
|
-
* It should be in the format of `project.module.submodule`.
|
|
225
|
-
*/
|
|
226
|
-
name: string;
|
|
227
|
-
/**
|
|
228
|
-
* List all services related to this module.
|
|
229
|
-
*
|
|
230
|
-
* If you don't declare 'register' function, all services will be registered automatically.
|
|
231
|
-
* If you declare 'register' function, you must handle the registration of ALL services manually.
|
|
232
|
-
*/
|
|
233
|
-
services?: Array<Service>;
|
|
234
|
-
/**
|
|
235
|
-
* List of $primitives to register in the module.
|
|
236
|
-
*/
|
|
237
|
-
primitives?: Array<PrimitiveFactoryLike>;
|
|
238
|
-
/**
|
|
239
|
-
* By default, module will register ALL services.
|
|
240
|
-
* You can override this behavior by providing a register function.
|
|
241
|
-
* It's useful when you want to register services conditionally or in a specific order.
|
|
242
|
-
*
|
|
243
|
-
* Again, if you declare 'register', you must handle the registration of ALL services manually.
|
|
244
|
-
*/
|
|
245
|
-
register?: (alepha: Alepha) => void;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Base class for all modules.
|
|
249
|
-
*/
|
|
250
|
-
declare abstract class Module {
|
|
251
|
-
abstract readonly options: ModulePrimitiveOptions;
|
|
252
|
-
abstract register(alepha: Alepha): void;
|
|
253
|
-
static NAME_REGEX: RegExp;
|
|
254
|
-
/**
|
|
255
|
-
* Check if a Service is a Module.
|
|
256
|
-
*/
|
|
257
|
-
static is(ctor: Service): boolean;
|
|
258
|
-
/**
|
|
259
|
-
* Get the Module of a Service.
|
|
260
|
-
*
|
|
261
|
-
* Returns undefined if the Service is not part of a Module.
|
|
262
|
-
*/
|
|
263
|
-
static of(ctor: Service): Service<Module> | undefined;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Helper type to add Module metadata to a Service.
|
|
267
|
-
*/
|
|
268
|
-
type WithModule<T extends object = any> = T & {
|
|
269
|
-
[MODULE]?: Service;
|
|
270
|
-
};
|
|
271
|
-
//#endregion
|
|
272
|
-
//#region src/core/providers/AlsProvider.d.ts
|
|
273
|
-
type AsyncLocalStorageData = any;
|
|
274
|
-
declare class AlsProvider {
|
|
275
|
-
static create: () => AsyncLocalStorage<AsyncLocalStorageData> | undefined;
|
|
276
|
-
als?: AsyncLocalStorage<AsyncLocalStorageData>;
|
|
277
|
-
constructor();
|
|
278
|
-
createContextId(): string;
|
|
279
|
-
run<R>(callback: () => R, data?: Record<string, any>): R;
|
|
280
|
-
exists(): boolean;
|
|
281
|
-
get<T>(key: string): T | undefined;
|
|
282
|
-
set<T>(key: string, value: T): void;
|
|
283
|
-
}
|
|
284
|
-
//#endregion
|
|
285
|
-
//#region src/core/providers/Json.d.ts
|
|
286
|
-
/**
|
|
287
|
-
* Mimics the JSON global object with stringify and parse methods.
|
|
288
|
-
*
|
|
289
|
-
* Used across the codebase via dependency injection.
|
|
290
|
-
*/
|
|
291
|
-
declare class Json {
|
|
292
|
-
stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
|
|
293
|
-
parse(text: string, reviver?: (this: any, key: string, value: any) => any): any;
|
|
294
|
-
}
|
|
295
|
-
//#endregion
|
|
296
133
|
//#region src/core/errors/AlephaError.d.ts
|
|
297
134
|
/**
|
|
298
135
|
* Default error class for Alepha.
|
|
@@ -675,6 +512,225 @@ interface TTextOptions extends TStringOptions$1 {
|
|
|
675
512
|
}
|
|
676
513
|
declare const t: TypeProvider;
|
|
677
514
|
//#endregion
|
|
515
|
+
//#region src/core/primitives/$atom.d.ts
|
|
516
|
+
/**
|
|
517
|
+
* Define an atom for state management.
|
|
518
|
+
*
|
|
519
|
+
* Atom lets you define a piece of state with a name, schema, and default value.
|
|
520
|
+
*
|
|
521
|
+
* By default, Alepha state is just a simple key-value store.
|
|
522
|
+
* Using atoms allows you to have type safety, validation, and default values for your state.
|
|
523
|
+
*
|
|
524
|
+
* You control how state is structured and validated.
|
|
525
|
+
*
|
|
526
|
+
* Features:
|
|
527
|
+
* - Set a schema for validation
|
|
528
|
+
* - Set a default value for initial state
|
|
529
|
+
* - Rules, like read-only, custom validation, etc.
|
|
530
|
+
* - Automatic getter access in services with {@link $use}
|
|
531
|
+
* - SSR support (server state automatically serialized and hydrated on client)
|
|
532
|
+
* - React integration (useAtom hook for automatic component re-renders)
|
|
533
|
+
* - Middleware
|
|
534
|
+
* - Persistence adapters (localStorage, Redis, database, file system, cookie, etc.)
|
|
535
|
+
* - State migrations (version upgrades when schema changes)
|
|
536
|
+
* - Documentation generation & devtools integration
|
|
537
|
+
*
|
|
538
|
+
* Common use cases:
|
|
539
|
+
* - user preferences
|
|
540
|
+
* - feature flags
|
|
541
|
+
* - configuration options
|
|
542
|
+
* - session data
|
|
543
|
+
*
|
|
544
|
+
* Atom must contain only serializable data.
|
|
545
|
+
* Avoid storing complex objects like class instances, functions, or DOM elements.
|
|
546
|
+
* If you need to store complex data, consider using identifiers or references instead.
|
|
547
|
+
*/
|
|
548
|
+
declare const $atom: {
|
|
549
|
+
<T extends TObject<TProperties$2> | TArray$1, N extends string>(options: AtomOptions<T, N>): Atom<T, N>;
|
|
550
|
+
[KIND]: string;
|
|
551
|
+
};
|
|
552
|
+
type AtomOptions<T extends TAtomObject, N extends string> = {
|
|
553
|
+
name: N;
|
|
554
|
+
schema: T;
|
|
555
|
+
description?: string;
|
|
556
|
+
} & (T extends TOptionalAdd<T> ? {
|
|
557
|
+
default?: Static<T>;
|
|
558
|
+
} : {
|
|
559
|
+
default: Static<T>;
|
|
560
|
+
});
|
|
561
|
+
declare class Atom<T extends TAtomObject = TObject, N extends string = string> {
|
|
562
|
+
readonly options: AtomOptions<T, N>;
|
|
563
|
+
get schema(): T;
|
|
564
|
+
get key(): N;
|
|
565
|
+
constructor(options: AtomOptions<T, N>);
|
|
566
|
+
}
|
|
567
|
+
type TProperties$2 = any;
|
|
568
|
+
type TAtomObject = TObject<any> | TArray$1;
|
|
569
|
+
type AtomStatic<T extends TAtomObject> = T extends TOptionalAdd<T> ? Static<T> | undefined : Static<T>;
|
|
570
|
+
//#endregion
|
|
571
|
+
//#region src/core/primitives/$inject.d.ts
|
|
572
|
+
/**
|
|
573
|
+
* Get the instance of the specified type from the context.
|
|
574
|
+
*
|
|
575
|
+
* ```ts
|
|
576
|
+
* class A { }
|
|
577
|
+
* class B {
|
|
578
|
+
* a = $inject(A);
|
|
579
|
+
* }
|
|
580
|
+
* ```
|
|
581
|
+
*/
|
|
582
|
+
declare const $inject: <T extends object>(type: Service<T>, opts?: InjectOptions<T>) => T;
|
|
583
|
+
declare class InjectPrimitive extends Primitive {}
|
|
584
|
+
interface InjectOptions<T extends object = any> {
|
|
585
|
+
/**
|
|
586
|
+
* - 'transient' → Always a new instance on every inject. Zero caching.
|
|
587
|
+
* - 'singleton' → One instance per Alepha runtime (per-thread). Never disposed until Alepha shuts down. (default)
|
|
588
|
+
* - 'scoped' → One instance per AsyncLocalStorage context.
|
|
589
|
+
* - A new scope is created when Alepha handles a request, a scheduled job, a queue worker task...
|
|
590
|
+
* - You can also start a manual scope via alepha.context.run(() => { ... }).
|
|
591
|
+
* - When the scope ends, the scoped registry is discarded.
|
|
592
|
+
*
|
|
593
|
+
* @default "singleton"
|
|
594
|
+
*/
|
|
595
|
+
lifetime?: "transient" | "singleton" | "scoped";
|
|
596
|
+
/**
|
|
597
|
+
* Constructor arguments to pass when creating a new instance.
|
|
598
|
+
*/
|
|
599
|
+
args?: ConstructorParameters<InstantiableClass<T>>;
|
|
600
|
+
/**
|
|
601
|
+
* Parent that requested the instance.
|
|
602
|
+
*
|
|
603
|
+
* @internal
|
|
604
|
+
*/
|
|
605
|
+
parent?: Service | null;
|
|
606
|
+
}
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region src/core/primitives/$module.d.ts
|
|
609
|
+
/**
|
|
610
|
+
* Wrap Services and Primitives into a Module.
|
|
611
|
+
*
|
|
612
|
+
* - A module is just a Service with some extra {@link Module}.
|
|
613
|
+
* - You must attach a `name` to it.
|
|
614
|
+
* - Name must follow the pattern: `project.module.submodule`. (e.g. `myapp.users.auth`).
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* ```ts
|
|
618
|
+
* import { $module } from "alepha";
|
|
619
|
+
* import { MyService } from "./MyService.ts";
|
|
620
|
+
*
|
|
621
|
+
* // export MyService, so it can be used everywhere (optional)
|
|
622
|
+
* export * from "./MyService.ts";
|
|
623
|
+
*
|
|
624
|
+
* export default $module({
|
|
625
|
+
* name: "my.project.module",
|
|
626
|
+
* // MyService will have a module context "my.project.module"
|
|
627
|
+
* services: [MyService],
|
|
628
|
+
* });
|
|
629
|
+
* ```
|
|
630
|
+
*
|
|
631
|
+
* ### Why Modules?
|
|
632
|
+
*
|
|
633
|
+
* #### Logging
|
|
634
|
+
*
|
|
635
|
+
* By default, AlephaLogger will log the module name in the logs.
|
|
636
|
+
* This helps to identify where the logs are coming from.
|
|
637
|
+
*
|
|
638
|
+
* You can also set different log levels for different modules.
|
|
639
|
+
* It means you can set 'some.very.specific.module' to 'debug' and keep the rest of the application to 'info'.
|
|
640
|
+
*
|
|
641
|
+
* #### Modulith
|
|
642
|
+
*
|
|
643
|
+
* Force to structure your application in modules, even if it's a single deployable unit.
|
|
644
|
+
* It helps to keep a clean architecture and avoid monolithic applications.
|
|
645
|
+
*
|
|
646
|
+
* A strict mode flag will probably come to enforce module boundaries.
|
|
647
|
+
* -> Throwing errors when a service from another module is injected.
|
|
648
|
+
* But it's not implemented yet.
|
|
649
|
+
*
|
|
650
|
+
* ### When not to use Modules?
|
|
651
|
+
*
|
|
652
|
+
* Small applications does not need modules. It's better to keep it simple.
|
|
653
|
+
* Modules are more useful when the application grows and needs to be structured.
|
|
654
|
+
* If we speak with number of `$actions`, a module should be used when you have more than 30 actions in a single module.
|
|
655
|
+
* Meaning that if you have 100 actions, you should have at least 3 modules.
|
|
656
|
+
*/
|
|
657
|
+
declare const $module: <T extends object = {}>(options: ModulePrimitiveOptions) => Service<Module>;
|
|
658
|
+
interface ModulePrimitiveOptions {
|
|
659
|
+
/**
|
|
660
|
+
* Name of the module.
|
|
661
|
+
*
|
|
662
|
+
* It should be in the format of `project.module.submodule`.
|
|
663
|
+
*/
|
|
664
|
+
name: string;
|
|
665
|
+
/**
|
|
666
|
+
* List all services related to this module.
|
|
667
|
+
*
|
|
668
|
+
* If you don't declare 'register' function, all services will be registered automatically.
|
|
669
|
+
* If you declare 'register' function, you must handle the registration of ALL services manually.
|
|
670
|
+
*/
|
|
671
|
+
services?: Array<Service>;
|
|
672
|
+
/**
|
|
673
|
+
* List of $primitives to register in the module.
|
|
674
|
+
*/
|
|
675
|
+
primitives?: Array<PrimitiveFactoryLike>;
|
|
676
|
+
/**
|
|
677
|
+
* By default, module will register ALL services.
|
|
678
|
+
* You can override this behavior by providing a register function.
|
|
679
|
+
* It's useful when you want to register services conditionally or in a specific order.
|
|
680
|
+
*
|
|
681
|
+
* Again, if you declare 'register', you must handle the registration of ALL services manually.
|
|
682
|
+
*/
|
|
683
|
+
register?: (alepha: Alepha) => void;
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Base class for all modules.
|
|
687
|
+
*/
|
|
688
|
+
declare abstract class Module {
|
|
689
|
+
abstract readonly options: ModulePrimitiveOptions;
|
|
690
|
+
abstract register(alepha: Alepha): void;
|
|
691
|
+
static NAME_REGEX: RegExp;
|
|
692
|
+
/**
|
|
693
|
+
* Check if a Service is a Module.
|
|
694
|
+
*/
|
|
695
|
+
static is(ctor: Service): boolean;
|
|
696
|
+
/**
|
|
697
|
+
* Get the Module of a Service.
|
|
698
|
+
*
|
|
699
|
+
* Returns undefined if the Service is not part of a Module.
|
|
700
|
+
*/
|
|
701
|
+
static of(ctor: Service): Service<Module> | undefined;
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Helper type to add Module metadata to a Service.
|
|
705
|
+
*/
|
|
706
|
+
type WithModule<T extends object = any> = T & {
|
|
707
|
+
[MODULE]?: Service;
|
|
708
|
+
};
|
|
709
|
+
//#endregion
|
|
710
|
+
//#region src/core/providers/AlsProvider.d.ts
|
|
711
|
+
type AsyncLocalStorageData = any;
|
|
712
|
+
declare class AlsProvider {
|
|
713
|
+
static create: () => AsyncLocalStorage<AsyncLocalStorageData> | undefined;
|
|
714
|
+
als?: AsyncLocalStorage<AsyncLocalStorageData>;
|
|
715
|
+
constructor();
|
|
716
|
+
createContextId(): string;
|
|
717
|
+
run<R>(callback: () => R, data?: Record<string, any>): R;
|
|
718
|
+
exists(): boolean;
|
|
719
|
+
get<T>(key: string): T | undefined;
|
|
720
|
+
set<T>(key: string, value: T): void;
|
|
721
|
+
}
|
|
722
|
+
//#endregion
|
|
723
|
+
//#region src/core/providers/Json.d.ts
|
|
724
|
+
/**
|
|
725
|
+
* Mimics the JSON global object with stringify and parse methods.
|
|
726
|
+
*
|
|
727
|
+
* Used across the codebase via dependency injection.
|
|
728
|
+
*/
|
|
729
|
+
declare class Json {
|
|
730
|
+
stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
|
|
731
|
+
parse(text: string, reviver?: (this: any, key: string, value: any) => any): any;
|
|
732
|
+
}
|
|
733
|
+
//#endregion
|
|
678
734
|
//#region src/core/providers/SchemaCodec.d.ts
|
|
679
735
|
declare abstract class SchemaCodec {
|
|
680
736
|
/**
|
|
@@ -844,62 +900,6 @@ declare class EventManager {
|
|
|
844
900
|
}): Promise<void>;
|
|
845
901
|
}
|
|
846
902
|
//#endregion
|
|
847
|
-
//#region src/core/primitives/$atom.d.ts
|
|
848
|
-
/**
|
|
849
|
-
* Define an atom for state management.
|
|
850
|
-
*
|
|
851
|
-
* Atom lets you define a piece of state with a name, schema, and default value.
|
|
852
|
-
*
|
|
853
|
-
* By default, Alepha state is just a simple key-value store.
|
|
854
|
-
* Using atoms allows you to have type safety, validation, and default values for your state.
|
|
855
|
-
*
|
|
856
|
-
* You control how state is structured and validated.
|
|
857
|
-
*
|
|
858
|
-
* Features:
|
|
859
|
-
* - Set a schema for validation
|
|
860
|
-
* - Set a default value for initial state
|
|
861
|
-
* - Rules, like read-only, custom validation, etc.
|
|
862
|
-
* - Automatic getter access in services with {@link $use}
|
|
863
|
-
* - SSR support (server state automatically serialized and hydrated on client)
|
|
864
|
-
* - React integration (useAtom hook for automatic component re-renders)
|
|
865
|
-
* - Middleware
|
|
866
|
-
* - Persistence adapters (localStorage, Redis, database, file system, cookie, etc.)
|
|
867
|
-
* - State migrations (version upgrades when schema changes)
|
|
868
|
-
* - Documentation generation & devtools integration
|
|
869
|
-
*
|
|
870
|
-
* Common use cases:
|
|
871
|
-
* - user preferences
|
|
872
|
-
* - feature flags
|
|
873
|
-
* - configuration options
|
|
874
|
-
* - session data
|
|
875
|
-
*
|
|
876
|
-
* Atom must contain only serializable data.
|
|
877
|
-
* Avoid storing complex objects like class instances, functions, or DOM elements.
|
|
878
|
-
* If you need to store complex data, consider using identifiers or references instead.
|
|
879
|
-
*/
|
|
880
|
-
declare const $atom: {
|
|
881
|
-
<T extends TObject<TProperties$2> | TArray$1, N extends string>(options: AtomOptions<T, N>): Atom<T, N>;
|
|
882
|
-
[KIND]: string;
|
|
883
|
-
};
|
|
884
|
-
type AtomOptions<T extends TAtomObject, N extends string> = {
|
|
885
|
-
name: N;
|
|
886
|
-
schema: T;
|
|
887
|
-
description?: string;
|
|
888
|
-
} & (T extends TOptionalAdd<T> ? {
|
|
889
|
-
default?: Static<T>;
|
|
890
|
-
} : {
|
|
891
|
-
default: Static<T>;
|
|
892
|
-
});
|
|
893
|
-
declare class Atom<T extends TAtomObject = TObject, N extends string = string> {
|
|
894
|
-
readonly options: AtomOptions<T, N>;
|
|
895
|
-
get schema(): T;
|
|
896
|
-
get key(): N;
|
|
897
|
-
constructor(options: AtomOptions<T, N>);
|
|
898
|
-
}
|
|
899
|
-
type TProperties$2 = any;
|
|
900
|
-
type TAtomObject = TObject<any> | TArray$1;
|
|
901
|
-
type AtomStatic<T extends TAtomObject> = T extends TOptionalAdd<T> ? Static<T> | undefined : Static<T>;
|
|
902
|
-
//#endregion
|
|
903
903
|
//#region src/core/providers/StateManager.d.ts
|
|
904
904
|
interface AtomWithValue {
|
|
905
905
|
atom: Atom;
|
|
@@ -1176,6 +1176,8 @@ declare class Alepha {
|
|
|
1176
1176
|
*/
|
|
1177
1177
|
get env(): Readonly<Env>;
|
|
1178
1178
|
constructor(init?: Partial<State>);
|
|
1179
|
+
set<T extends TAtomObject>(target: Atom<T>, value: AtomStatic<T>): this;
|
|
1180
|
+
set<Key extends keyof State>(target: Key, value: State[Key] | undefined): this;
|
|
1179
1181
|
/**
|
|
1180
1182
|
* True when start() is called.
|
|
1181
1183
|
*
|
package/dist/core/index.js
CHANGED
|
@@ -283,7 +283,7 @@ const $module = (options) => {
|
|
|
283
283
|
* Base class for all modules.
|
|
284
284
|
*/
|
|
285
285
|
var Module = class Module {
|
|
286
|
-
static NAME_REGEX = /^[a-z]+(\.[a-z][a-z0-9-]*)*$/;
|
|
286
|
+
static NAME_REGEX = /^[a-z-]+(\.[a-z-][a-z0-9-]*)*$/;
|
|
287
287
|
/**
|
|
288
288
|
* Check if a Service is a Module.
|
|
289
289
|
*/
|
|
@@ -1022,6 +1022,10 @@ var Alepha = class Alepha {
|
|
|
1022
1022
|
constructor(init = {}) {
|
|
1023
1023
|
this.init = init;
|
|
1024
1024
|
}
|
|
1025
|
+
set(target, value) {
|
|
1026
|
+
this.store.set(target, value);
|
|
1027
|
+
return this;
|
|
1028
|
+
}
|
|
1025
1029
|
/**
|
|
1026
1030
|
* True when start() is called.
|
|
1027
1031
|
*
|