alepha 0.8.0 → 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.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Feunard
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Feunard
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,44 +1,17 @@
1
- <div align="center">
1
+ # Alepha Alepha
2
2
 
3
- <h1 >
4
- <img
5
- src="https://raw.githubusercontent.com/feunard/alepha/main/assets/logo.png"
6
- width="128"
7
- height="128"
8
- alt="Logo"
9
- valign="middle"
10
- />
11
- Alepha
12
- </h1>
13
- <p style="max-width: 512px">
14
- 🚧
15
- </p>
16
- <a href="https://www.npmjs.com/package/alepha"><img src="https://img.shields.io/npm/v/alepha.svg" alt="npm"/></a>
17
- <a href="https://www.npmjs.com/package/alepha"><img src="https://img.shields.io/npm/l/alepha.svg" alt="npm"/></a>
18
- <a href="https://codecov.io/gh/feunard/alepha"><img src="https://codecov.io/gh/feunard/alepha/graph/badge.svg?token=ZDLWI514CP" alt="npm"/></a>
19
- <a href="https://www.npmjs.com/package/alepha"><img src="https://img.shields.io/npm/dt/alepha.svg" alt="npm"/></a>
20
- <a href="https://github.com/feunard/alepha"><img src="https://img.shields.io/github/stars/feunard/alepha.svg?style=social" alt="GitHub stars"/></a>
21
- </div>
3
+ TypeScript framework for building full-stack apps with strict conventions, and React-based SPA or SSR without filesystem-based routing.
22
4
 
23
5
  ## Installation
24
6
 
7
+ This package is part of the Alepha framework and can be installed via the all-in-one package:
8
+
25
9
  ```bash
26
10
  npm install alepha
27
11
  ```
28
12
 
29
- ## Usage
30
-
31
- Minimalist http server with a single endpoint.
32
-
33
- ```ts
34
- import { run } from "alepha";
35
- import { $action } from "alepha/server";
13
+ Alternatively, you can install it individually:
36
14
 
37
- class App {
38
- hello = $action({
39
- handler: () => "Hello world!",
40
- })
41
- }
42
-
43
- run(App);
15
+ ```bash
16
+ npm install @alepha/core alepha
44
17
  ```
package/batch.d.ts CHANGED
@@ -4,6 +4,15 @@ import { RetryDescriptorOptions } from "alepha/retry";
4
4
 
5
5
  //#region src/descriptors/$batch.d.ts
6
6
  declare const KEY = "BATCH";
7
+ /**
8
+ * Creates a batch processor. This is useful for grouping multiple operations
9
+ * (like API calls or database writes) into a single one to improve performance.
10
+ */
11
+ declare const $batch: {
12
+ <TItem extends TSchema, TResponse>(options: BatchDescriptorOptions<TItem, TResponse>): BatchDescriptor<TItem, TResponse>;
13
+ [KIND]: string;
14
+ };
15
+ // ---------------------------------------------------------------------------------------------------------------------
7
16
  interface BatchDescriptorOptions<TItem extends TSchema, TResponse = any> {
8
17
  /**
9
18
  * A TypeBox schema to validate each item pushed to the batch.
@@ -55,14 +64,6 @@ interface BatchDescriptor<TItem extends TSchema, TResponse = any> {
55
64
  */
56
65
  flush: (partitionKey?: string) => Promise<TResponse>;
57
66
  }
58
- /**
59
- * Creates a batch processor. This is useful for grouping multiple operations
60
- * (like API calls or database writes) into a single one to improve performance.
61
- */
62
- declare const $batch: {
63
- <TItem extends TSchema, TResponse>(options: BatchDescriptorOptions<TItem, TResponse>): BatchDescriptor<TItem, TResponse>;
64
- [KIND]: string;
65
- };
66
67
  //#endregion
67
68
  //#region src/providers/BatchDescriptorProvider.d.ts
68
69
  interface PartitionState<TItem extends TSchema> {
@@ -81,6 +82,9 @@ interface BatchInstance<TItem extends TSchema> {
81
82
  activeHandlers: PromiseWithResolvers<void>[];
82
83
  handler: (items: Static<TItem>[]) => Promise<void>;
83
84
  }
85
+ /**
86
+ * Process every $batch.
87
+ */
84
88
  declare class BatchDescriptorProvider {
85
89
  protected readonly alepha: Alepha;
86
90
  protected readonly log: Logger;
@@ -97,10 +101,39 @@ declare class BatchDescriptorProvider {
97
101
  //#region src/index.d.ts
98
102
  // ---------------------------------------------------------------------------------------------------------------------
99
103
  /**
100
- * Alepha Batch Module
104
+ * This module allows you to group multiple asynchronous operations into a single "batch," which is then processed together.
105
+ * This is an essential pattern for improving performance, reducing I/O, and interacting efficiently with rate-limited APIs or databases.
106
+ *
107
+ * ### Basic Example: A Simple Event Logger
108
+ *
109
+ * Let's create a batch processor that collects log messages and prints them to the console every 5 seconds or whenever 10 messages have been collected.
110
+ *
111
+ * ```ts
112
+ * import { Alepha, $hook, run, t } from "alepha";
113
+ * import { $batch } from "alepha/batch";
114
+ *
115
+ * class LoggingService {
116
+ * // define the batch processor
117
+ * logBatch = $batch({
118
+ * schema: t.string(),
119
+ * maxSize: 10,
120
+ * maxDuration: [5, "seconds"],
121
+ * handler: async (items) => {
122
+ * console.log(`[BATCH LOG] Processing ${items.length} events:`, items);
123
+ * },
124
+ * });
101
125
  *
102
- * This module provides a powerful batch processing utility that can group
103
- * multiple operations into a single one based on size, time, or partitions.
126
+ * // example of how to use it
127
+ * onReady = $hook({
128
+ * on: "ready",
129
+ * handler: async () => {
130
+ * this.logBatch.push("Application started.");
131
+ * this.logBatch.push("User authenticated.");
132
+ * // ... more events pushed from elsewhere in the app
133
+ * },
134
+ * });
135
+ * }
136
+ * ```
104
137
  *
105
138
  * @see {@link $batch}
106
139
  * @module alepha.batch
package/cache/redis.d.ts CHANGED
@@ -25,8 +25,6 @@ declare class RedisCacheProvider implements CacheProvider {
25
25
  //#region src/index.d.ts
26
26
  // ---------------------------------------------------------------------------------------------------------------------
27
27
  /**
28
- * Alepha Cache Redis Module
29
- *
30
28
  * Plugin for Alepha Cache that provides Redis caching capabilities.
31
29
  *
32
30
  * @see {@link RedisCacheProvider}
package/cache.d.ts CHANGED
@@ -208,9 +208,77 @@ interface Cache<TReturn = any, TParameter extends any[] = any[]> {
208
208
  //#region src/index.d.ts
209
209
  // ---------------------------------------------------------------------------------------------------------------------
210
210
  /**
211
- * Alepha Cache Module
211
+ * Provides high-performance caching capabilities for Alepha applications with configurable TTL and multiple storage backends.
212
212
  *
213
- * This module provides a caching mechanism for Alepha applications.
213
+ * The cache module enables declarative caching through the `$cache` descriptor, allowing you to cache method results,
214
+ * API responses, or computed values with automatic invalidation and type safety. It supports both in-memory and
215
+ * persistent storage backends for different performance and durability requirements.
216
+ *
217
+ * **Key Features:**
218
+ * - Declarative caching with `$cache` descriptor on class properties
219
+ * - Configurable TTL (time-to-live) with duration literals
220
+ * - Custom key generation and automatic serialization
221
+ * - Multiple storage backends (memory, Redis, etc.)
222
+ * - Cache invalidation and manual cache operations
223
+ * - Type-safe operations with full TypeScript support
224
+ *
225
+ * **Basic Usage:**
226
+ * ```ts
227
+ * import { Alepha, run } from "alepha";
228
+ * import { AlephaCache, $cache } from "alepha/cache";
229
+ *
230
+ * class UserService {
231
+ * getUserData = $cache({
232
+ * key: (userId: string) => `user:${userId}`,
233
+ * ttl: [1, "hour"],
234
+ * handler: async (userId: string) => {
235
+ * // This will be cached for 1 hour
236
+ * return await fetchUserFromDatabase(userId);
237
+ * },
238
+ * });
239
+ *
240
+ * getUserProfile = $cache({
241
+ * provider: "memory",
242
+ * ttl: [5, "minutes"],
243
+ * handler: async (userId: string) => {
244
+ * return await buildUserProfile(userId);
245
+ * },
246
+ * });
247
+ * }
248
+ *
249
+ * const alepha = Alepha.create()
250
+ * .with(AlephaCache)
251
+ * .with(UserService);
252
+ *
253
+ * run(alepha);
254
+ * ```
255
+ *
256
+ * **Cache Operations:**
257
+ * ```ts
258
+ * class ProductService {
259
+ * productCache = $cache({
260
+ * handler: async (productId: string) => {
261
+ * return await getProduct(productId);
262
+ * },
263
+ * });
264
+ *
265
+ * async getProduct(id: string) {
266
+ * // Get from cache or compute
267
+ * return await this.productCache(id);
268
+ * }
269
+ *
270
+ * async updateProduct(id: string, data: any) {
271
+ * await updateProductInDb(id, data);
272
+ * // Invalidate cache
273
+ * await this.productCache.invalidate(this.productCache.key(id));
274
+ * }
275
+ *
276
+ * async warmUpCache(id: string, data: any) {
277
+ * // Manually set cache
278
+ * await this.productCache.set(this.productCache.key(id), data, [30, "minutes"]);
279
+ * }
280
+ * }
281
+ * ```
214
282
  *
215
283
  * @see {@link $cache}
216
284
  * @see {@link CacheProvider}
package/command.d.ts CHANGED
@@ -38,6 +38,16 @@ declare class Runner {
38
38
  //#endregion
39
39
  //#region src/descriptors/$command.d.ts
40
40
  declare const KEY = "COMMAND";
41
+ /**
42
+ * Declares a CLI command.
43
+ *
44
+ * This descriptor allows you to define a command, its flags, and its handler
45
+ * within your Alepha application structure.
46
+ */
47
+ declare const $command: {
48
+ <T extends TObject>(options: CommandDescriptorOptions<T>): CommandDescriptor<T>;
49
+ [KIND]: string;
50
+ };
41
51
  interface CommandDescriptorOptions<T extends TObject> {
42
52
  /**
43
53
  * The handler function to execute when the command is matched.
@@ -75,16 +85,6 @@ interface CommandDescriptor<T extends TObject> {
75
85
  */
76
86
  (flags: Static<T>): Promise<void>;
77
87
  }
78
- /**
79
- * Declares a CLI command.
80
- *
81
- * This descriptor allows you to define a command, its flags, and its handler
82
- * within your Alepha application structure.
83
- */
84
- declare const $command: {
85
- <T extends TObject>(options: CommandDescriptorOptions<T>): CommandDescriptor<T>;
86
- [KIND]: string;
87
- };
88
88
  //#endregion
89
89
  //#region src/errors/CommandError.d.ts
90
90
  declare class CommandError extends AlephaError {}
@@ -137,9 +137,7 @@ declare class CommandDescriptorProvider {
137
137
  //#region src/index.d.ts
138
138
  // ---------------------------------------------------------------------------------------------------------------------
139
139
  /**
140
- * Alepha Command Module
141
- *
142
- * This module provides a powerful way to build command-line interfaces
140
+ *This module provides a powerful way to build command-line interfaces
143
141
  * directly within your Alepha application, using declarative descriptors.
144
142
  *
145
143
  * @see {@link $command}
package/core.d.ts CHANGED
@@ -85,38 +85,6 @@ type ServiceEntry<T extends object = any> = Service<T> | ServiceSubstitution<T>;
85
85
  //#endregion
86
86
  //#region src/descriptors/$hook.d.ts
87
87
  declare const KEY = "HOOK";
88
- interface HookOptions<T extends keyof Hooks> {
89
- /**
90
- * The name of the hook. "configure", "start", "ready", "stop", ...
91
- */
92
- on: T;
93
- /**
94
- * The handler to run when the hook is triggered.
95
- */
96
- handler: (app: Hooks[T]) => Async<any>;
97
- /**
98
- * Force the hook to run first or last on the list of hooks.
99
- */
100
- priority?: "first" | "last";
101
- /**
102
- * Empty placeholder, not working yet. :-)
103
- */
104
- before?: object | Array<object>;
105
- /**
106
- * Empty placeholder, not working yet. :-)
107
- */
108
- after?: object | Array<object>;
109
- }
110
- interface Hook<T extends keyof Hooks = any> {
111
- caller?: Service;
112
- priority?: "first" | "last";
113
- callback: (payload: Hooks[T]) => Async<void>;
114
- }
115
- interface HookDescriptor<T extends keyof Hooks> {
116
- [KIND]: typeof KEY;
117
- [OPTIONS]: HookOptions<T>;
118
- (app: Hooks[T]): Async<any>;
119
- }
120
88
  /**
121
89
  * Registers a new hook.
122
90
  *
@@ -160,6 +128,38 @@ declare const $hook: {
160
128
  <T extends keyof Hooks>(options: HookOptions<T>): HookDescriptor<T>;
161
129
  [KIND]: string;
162
130
  };
131
+ interface HookOptions<T extends keyof Hooks> {
132
+ /**
133
+ * The name of the hook. "configure", "start", "ready", "stop", ...
134
+ */
135
+ on: T;
136
+ /**
137
+ * The handler to run when the hook is triggered.
138
+ */
139
+ handler: (app: Hooks[T]) => Async<any>;
140
+ /**
141
+ * Force the hook to run first or last on the list of hooks.
142
+ */
143
+ priority?: "first" | "last";
144
+ /**
145
+ * Empty placeholder, not working yet. :-)
146
+ */
147
+ before?: object | Array<object>;
148
+ /**
149
+ * Empty placeholder, not working yet. :-)
150
+ */
151
+ after?: object | Array<object>;
152
+ }
153
+ interface Hook<T extends keyof Hooks = any> {
154
+ caller?: Service;
155
+ priority?: "first" | "last";
156
+ callback: (payload: Hooks[T]) => Async<void>;
157
+ }
158
+ interface HookDescriptor<T extends keyof Hooks> {
159
+ [KIND]: typeof KEY;
160
+ [OPTIONS]: HookOptions<T>;
161
+ (app: Hooks[T]): Async<any>;
162
+ }
163
163
  //#endregion
164
164
  //#region src/helpers/Module.d.ts
165
165
  interface Module {
@@ -174,6 +174,28 @@ declare const isModule: (value: unknown) => value is Module;
174
174
  declare const toModuleName: (name: string) => string;
175
175
  //#endregion
176
176
  //#region src/descriptors/$cursor.d.ts
177
+ /**
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;
177
199
  // ---------------------------------------------------------------------------------------------------------------------
178
200
  /**
179
201
  * /!\ Global variable /!\
@@ -200,28 +222,6 @@ interface CursorDescriptor {
200
222
  definition?: Service;
201
223
  module?: ModuleDefinition;
202
224
  }
203
- /**
204
- * Get Alepha instance and Class definition from the current context.
205
- * This should be used inside a descriptor only.
206
- *
207
- * ```ts
208
- * import { $cursor } from "alepha";
209
- *
210
- * const $ = () => {
211
- *
212
- * const { context, definition } = $cursor();
213
- *
214
- * // context - alepha instance
215
- * // definition - class which is creating this descriptor
216
- *
217
- * return {};
218
- * }
219
- *
220
- * ```
221
- *
222
- * @internal
223
- */
224
- declare const $cursor: () => CursorDescriptor;
225
225
  //#endregion
226
226
  //#region src/helpers/EventEmitterLike.d.ts
227
227
  // ---------------------------------------------------------------------------------------------------------------------
@@ -461,81 +461,6 @@ interface MockLoggerStore {
461
461
  }
462
462
  //#endregion
463
463
  //#region src/Alepha.d.ts
464
- // ---------------------------------------------------------------------------------------------------------------------
465
- interface Env extends LoggerEnv {
466
- [key: string]: string | boolean | number | undefined;
467
- /**
468
- * Optional environment variable that indicates the current environment.
469
- */
470
- NODE_ENV?: "dev" | "test" | "production";
471
- /**
472
- * Optional name of the application.
473
- */
474
- APP_NAME?: string;
475
- /**
476
- * Optional root module name.
477
- */
478
- MODULE_NAME?: string;
479
- /**
480
- * If true, the container will not automatically register the default providers based on the descriptors.
481
- *
482
- * It means that you have to alepha.with(ServiceModule) manually. No magic.
483
- *
484
- * @default false
485
- */
486
- EXPLICIT_PROVIDERS?: boolean;
487
- }
488
- // ---------------------------------------------------------------------------------------------------------------------
489
- interface State {
490
- log: Logger;
491
- env?: Readonly<Env>;
492
- // test hooks
493
- beforeAll?: (run: any) => any;
494
- afterAll?: (run: any) => any;
495
- afterEach?: (run: any) => any;
496
- onTestFinished?: (run: any) => any;
497
- }
498
- // ---------------------------------------------------------------------------------------------------------------------
499
- interface Hooks {
500
- echo: any;
501
- /**
502
- * Triggered during the configuration phase. Before the start phase.
503
- */
504
- configure: Alepha;
505
- /**
506
- * Triggered during the start phase. When `Alepha#start()` is called.
507
- */
508
- start: Alepha;
509
- /**
510
- * Triggered during the ready phase. After the start phase.
511
- */
512
- ready: Alepha;
513
- /**
514
- * Triggered during the stop phase.
515
- *
516
- * - Stop should be called after a SIGINT or SIGTERM signal in order to gracefully shutdown the application. (@see `run()` method)
517
- *
518
- */
519
- stop: Alepha;
520
- /**
521
- * Triggered when a state value is mutated.
522
- */
523
- "state:mutate": {
524
- /**
525
- * The key of the state that was mutated.
526
- */
527
- key: keyof State;
528
- /**
529
- * The new value of the state.
530
- */
531
- value: any;
532
- /**
533
- * The previous value of the state.
534
- */
535
- prevValue: any;
536
- };
537
- }
538
- // ---------------------------------------------------------------------------------------------------------------------
539
464
  /**
540
465
  * Core container of the Alepha framework.
541
466
  *
@@ -561,9 +486,9 @@ interface Hooks {
561
486
  * ```
562
487
  *
563
488
  * > Some alepha methods are not intended to be used directly, use descriptors instead.
564
- *
565
- * - $hook -> alepha.on()
566
- * - $inject -> alepha.get(), alepha.parseEnv()
489
+ * >
490
+ * > - $hook -> alepha.on()
491
+ * > - $inject -> alepha.get(), alepha.parseEnv()
567
492
  */
568
493
  declare class Alepha {
569
494
  /**
@@ -846,6 +771,9 @@ declare class Alepha {
846
771
  options: object;
847
772
  }>(service: Service<T>, state: Partial<T["options"]>): this;
848
773
  // -------------------------------------------------------------------------------------------------------------------
774
+ protected useCounter: number;
775
+ use<T extends Descriptor>(descriptor: T, options: Parameters<T>[0]): ReturnType<T>;
776
+ // -------------------------------------------------------------------------------------------------------------------
849
777
  /**
850
778
  * Registers a hook for the specified event.
851
779
  */
@@ -969,6 +897,80 @@ interface ServiceDefinition<T extends object = any> {
969
897
  */
970
898
  module?: ModuleDefinition;
971
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
+ }
972
974
  //#endregion
973
975
  //#region src/interfaces/Run.d.ts
974
976
  interface RunOptions {
@@ -1019,7 +1021,6 @@ declare class InjectResolverRegistry {
1019
1021
  declare const $injectResolverRegistry: InjectResolverRegistry;
1020
1022
  //#endregion
1021
1023
  //#region src/descriptors/$logger.d.ts
1022
- // ---------------------------------------------------------------------------------------------------------------------
1023
1024
  /**
1024
1025
  * Create a logger.
1025
1026
  *
@@ -1285,6 +1286,9 @@ declare const t: TypeProvider;
1285
1286
  declare const isUUID: (value: string) => boolean;
1286
1287
  //#endregion
1287
1288
  //#region src/index.d.ts
1289
+ /**
1290
+ *
1291
+ */
1288
1292
  declare const run: (entry: Alepha | Service | Array<Service>, opts?: RunOptions) => Alepha;
1289
1293
  //#endregion
1290
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 };
package/datetime.d.ts CHANGED
@@ -134,6 +134,10 @@ declare class DateTimeProvider {
134
134
  }
135
135
  //#endregion
136
136
  //#region src/descriptors/$interval.d.ts
137
+ /**
138
+ * Registers a new interval.
139
+ */
140
+ declare const $interval: (options: IntervalDescriptorOptions) => Interval;
137
141
  interface IntervalDescriptorOptions {
138
142
  /**
139
143
  * Whether to start the interval immediately.
@@ -158,10 +162,6 @@ interface IntervalDescriptorOptions {
158
162
  */
159
163
  duration: DurationLike;
160
164
  }
161
- /**
162
- * Registers a new interval.
163
- */
164
- declare const $interval: (options: IntervalDescriptorOptions) => Interval;
165
165
  //#endregion
166
166
  export { $interval, DateTime, DateTimeProvider, Duration, DurationLike, Interval, IntervalDescriptorOptions, Timeout };
167
167
  //# sourceMappingURL=index.d.ts.map
package/file.cjs ADDED
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+ var m = require('@alepha/file');
3
+ Object.keys(m).forEach(function (k) {
4
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
5
+ enumerable: true,
6
+ get: function () { return m[k]; }
7
+ });
8
+ });