alepha 0.11.5 → 0.11.6
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/api/files.d.ts +167 -167
- package/api/jobs.d.ts +226 -154
- package/api/notifications.d.ts +100 -100
- package/api/users.d.ts +477 -477
- package/batch.d.ts +59 -493
- package/bucket.d.ts +20 -11
- package/cache/redis.d.ts +1 -1
- package/cache.d.ts +1 -1
- package/command.d.ts +24 -7
- package/core.d.ts +219 -169
- package/datetime.d.ts +1 -1
- package/devtools.d.ts +292 -254
- package/email.d.ts +45 -2
- package/fake.d.ts +1 -1
- package/file.d.ts +1 -1
- package/lock/redis.d.ts +1 -1
- package/lock.d.ts +1 -1
- package/logger.d.ts +6 -3
- package/package.json +51 -51
- package/postgres.d.ts +473 -188
- package/queue/redis.d.ts +1 -1
- package/queue.d.ts +1 -1
- package/react/auth.d.ts +7 -2
- package/react/form.d.ts +35 -15
- package/react/head.d.ts +1 -1
- package/react/i18n.d.ts +2 -2
- package/react.d.ts +58 -35
- package/redis.d.ts +10 -10
- package/retry.d.ts +84 -21
- package/scheduler.d.ts +1 -1
- package/security.d.ts +29 -29
- package/server/cache.d.ts +1 -1
- package/server/compress.d.ts +9 -3
- package/server/cookies.d.ts +1 -1
- package/server/cors.d.ts +28 -10
- package/server/health.d.ts +1 -1
- package/server/helmet.d.ts +44 -15
- package/server/links.d.ts +8 -2
- package/server/metrics.d.ts +1 -1
- package/server/multipart.d.ts +1 -1
- package/server/proxy.d.ts +1 -1
- package/server/security.d.ts +8 -3
- package/server/static.d.ts +1 -1
- package/server/swagger.d.ts +19 -6
- package/server.d.ts +20 -20
- package/topic/redis.d.ts +1 -1
- package/topic.d.ts +1 -1
- package/ui.d.ts +127 -24
package/cache.d.ts
CHANGED
|
@@ -282,7 +282,7 @@ declare class MemoryCacheProvider implements CacheProvider {
|
|
|
282
282
|
* @see {@link CacheProvider}
|
|
283
283
|
* @module alepha.cache
|
|
284
284
|
*/
|
|
285
|
-
declare const AlephaCache: _alepha_core0.Service<_alepha_core0.Module
|
|
285
|
+
declare const AlephaCache: _alepha_core0.Service<_alepha_core0.Module>;
|
|
286
286
|
//#endregion
|
|
287
287
|
export { $cache, AlephaCache, CacheDescriptor, CacheDescriptorFn, CacheDescriptorOptions, CacheProvider, MemoryCacheProvider };
|
|
288
288
|
//# sourceMappingURL=index.d.ts.map
|
package/command.d.ts
CHANGED
|
@@ -177,6 +177,20 @@ declare const envSchema: TObject<{
|
|
|
177
177
|
declare module "alepha" {
|
|
178
178
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
179
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* CLI provider configuration atom
|
|
182
|
+
*/
|
|
183
|
+
declare const cliOptions: _alepha_core1.Atom<TObject<{
|
|
184
|
+
name: typebox0.TOptional<_alepha_core1.TString>;
|
|
185
|
+
description: typebox0.TOptional<_alepha_core1.TString>;
|
|
186
|
+
argv: typebox0.TOptional<typebox0.TArray<_alepha_core1.TString>>;
|
|
187
|
+
}>, "alepha.command.cli.options">;
|
|
188
|
+
type CliProviderOptions = Static<typeof cliOptions.schema>;
|
|
189
|
+
declare module "alepha" {
|
|
190
|
+
interface State {
|
|
191
|
+
[cliOptions.key]: CliProviderOptions;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
180
194
|
declare class CliProvider {
|
|
181
195
|
protected readonly env: {
|
|
182
196
|
CLI_NAME: string;
|
|
@@ -186,11 +200,14 @@ declare class CliProvider {
|
|
|
186
200
|
protected readonly log: _alepha_logger0.Logger;
|
|
187
201
|
protected readonly runner: Runner;
|
|
188
202
|
protected readonly asker: Asker;
|
|
189
|
-
options: {
|
|
190
|
-
name
|
|
191
|
-
description
|
|
192
|
-
argv
|
|
193
|
-
}
|
|
203
|
+
protected readonly options: Readonly<{
|
|
204
|
+
name?: string | undefined;
|
|
205
|
+
description?: string | undefined;
|
|
206
|
+
argv?: string[] | undefined;
|
|
207
|
+
}>;
|
|
208
|
+
protected get name(): string;
|
|
209
|
+
protected get description(): string;
|
|
210
|
+
protected get argv(): string[];
|
|
194
211
|
protected readonly globalFlags: {
|
|
195
212
|
help: {
|
|
196
213
|
aliases: string[];
|
|
@@ -234,7 +251,7 @@ declare class CliProvider {
|
|
|
234
251
|
* @see {@link $command}
|
|
235
252
|
* @module alepha.command
|
|
236
253
|
*/
|
|
237
|
-
declare const AlephaCommand: _alepha_core1.Service<_alepha_core1.Module
|
|
254
|
+
declare const AlephaCommand: _alepha_core1.Service<_alepha_core1.Module>;
|
|
238
255
|
declare module "typebox" {
|
|
239
256
|
interface StringOptions {
|
|
240
257
|
/**
|
|
@@ -248,5 +265,5 @@ declare module "typebox" {
|
|
|
248
265
|
//# sourceMappingURL=index.d.ts.map
|
|
249
266
|
|
|
250
267
|
//#endregion
|
|
251
|
-
export { $command, AlephaCommand, AskMethod, AskOptions, Asker, CliProvider, CommandDescriptor, CommandDescriptorOptions, CommandError, CommandHandlerArgs, RunOptions, Runner, RunnerMethod, Task };
|
|
268
|
+
export { $command, AlephaCommand, AskMethod, AskOptions, Asker, CliProvider, CliProviderOptions, CommandDescriptor, CommandDescriptorOptions, CommandError, CommandHandlerArgs, RunOptions, Runner, RunnerMethod, Task, cliOptions };
|
|
252
269
|
//# sourceMappingURL=index.d.ts.map
|
package/core.d.ts
CHANGED
|
@@ -147,16 +147,16 @@ interface InjectOptions<T extends object = any> {
|
|
|
147
147
|
/**
|
|
148
148
|
* Wrap Services and Descriptors into a Module.
|
|
149
149
|
*
|
|
150
|
-
* - A module is just a Service
|
|
150
|
+
* - A module is just a Service with some extra {@link Module}.
|
|
151
151
|
* - You must attach a `name` to it.
|
|
152
|
-
* - Name must follow the pattern: `project.module.submodule`.
|
|
152
|
+
* - Name must follow the pattern: `project.module.submodule`. (e.g. `myapp.users.auth`).
|
|
153
153
|
*
|
|
154
154
|
* @example
|
|
155
155
|
* ```ts
|
|
156
156
|
* import { $module } from "alepha";
|
|
157
157
|
* import { MyService } from "./MyService.ts";
|
|
158
158
|
*
|
|
159
|
-
* // export MyService, so it can be used everywhere
|
|
159
|
+
* // export MyService, so it can be used everywhere (optional)
|
|
160
160
|
* export * from "./MyService.ts";
|
|
161
161
|
*
|
|
162
162
|
* export default $module({
|
|
@@ -166,9 +166,9 @@ interface InjectOptions<T extends object = any> {
|
|
|
166
166
|
* });
|
|
167
167
|
* ```
|
|
168
168
|
*
|
|
169
|
-
*
|
|
169
|
+
* ### Why Modules?
|
|
170
170
|
*
|
|
171
|
-
*
|
|
171
|
+
* #### Logging
|
|
172
172
|
*
|
|
173
173
|
* By default, AlephaLogger will log the module name in the logs.
|
|
174
174
|
* This helps to identify where the logs are coming from.
|
|
@@ -176,23 +176,24 @@ interface InjectOptions<T extends object = any> {
|
|
|
176
176
|
* You can also set different log levels for different modules.
|
|
177
177
|
* It means you can set 'some.very.specific.module' to 'debug' and keep the rest of the application to 'info'.
|
|
178
178
|
*
|
|
179
|
-
*
|
|
179
|
+
* #### Modulith
|
|
180
180
|
*
|
|
181
181
|
* Force to structure your application in modules, even if it's a single deployable unit.
|
|
182
182
|
* It helps to keep a clean architecture and avoid monolithic applications.
|
|
183
183
|
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
184
|
+
* A strict mode flag will probably come to enforce module boundaries.
|
|
185
|
+
* -> Throwing errors when a service from another module is injected.
|
|
186
|
+
* But it's not implemented yet.
|
|
187
187
|
*
|
|
188
188
|
* ### When not to use Modules?
|
|
189
189
|
*
|
|
190
190
|
* Small applications does not need modules. It's better to keep it simple.
|
|
191
191
|
* Modules are more useful when the application grows and needs to be structured.
|
|
192
|
-
* If we speak with `$actions`, a module should be used when you have more than 30 actions in a single module.
|
|
192
|
+
* If we speak with number of `$actions`, a module should be used when you have more than 30 actions in a single module.
|
|
193
|
+
* Meaning that if you have 100 actions, you should have at least 3 modules.
|
|
193
194
|
*/
|
|
194
|
-
declare const $module: <T extends object = {}>(options: ModuleDescriptorOptions
|
|
195
|
-
interface ModuleDescriptorOptions
|
|
195
|
+
declare const $module: <T extends object = {}>(options: ModuleDescriptorOptions) => Service<Module>;
|
|
196
|
+
interface ModuleDescriptorOptions {
|
|
196
197
|
/**
|
|
197
198
|
* Name of the module.
|
|
198
199
|
*
|
|
@@ -200,7 +201,10 @@ interface ModuleDescriptorOptions<T extends object> {
|
|
|
200
201
|
*/
|
|
201
202
|
name: string;
|
|
202
203
|
/**
|
|
203
|
-
* List
|
|
204
|
+
* List all services related to this module.
|
|
205
|
+
*
|
|
206
|
+
* If you don't declare 'register' function, all services will be registered automatically.
|
|
207
|
+
* If you declare 'register' function, you must handle the registration of ALL services manually.
|
|
204
208
|
*/
|
|
205
209
|
services?: Array<Service>;
|
|
206
210
|
/**
|
|
@@ -208,29 +212,35 @@ interface ModuleDescriptorOptions<T extends object> {
|
|
|
208
212
|
*/
|
|
209
213
|
descriptors?: Array<DescriptorFactoryLike>;
|
|
210
214
|
/**
|
|
211
|
-
* By default, module will register
|
|
215
|
+
* By default, module will register ALL services.
|
|
212
216
|
* You can override this behavior by providing a register function.
|
|
213
217
|
* It's useful when you want to register services conditionally or in a specific order.
|
|
218
|
+
*
|
|
219
|
+
* Again, if you declare 'register', you must handle the registration of ALL services manually.
|
|
214
220
|
*/
|
|
215
|
-
register?: (alepha: Alepha
|
|
221
|
+
register?: (alepha: Alepha) => void;
|
|
216
222
|
}
|
|
217
223
|
/**
|
|
218
224
|
* Base class for all modules.
|
|
219
225
|
*/
|
|
220
|
-
declare abstract class Module
|
|
221
|
-
abstract readonly
|
|
226
|
+
declare abstract class Module {
|
|
227
|
+
abstract readonly options: ModuleDescriptorOptions;
|
|
222
228
|
abstract register(alepha: Alepha): void;
|
|
223
229
|
static NAME_REGEX: RegExp;
|
|
224
|
-
options: T;
|
|
225
230
|
/**
|
|
226
231
|
* Check if a Service is a Module.
|
|
227
232
|
*/
|
|
228
233
|
static is(ctor: Service): boolean;
|
|
229
234
|
/**
|
|
230
235
|
* Get the Module of a Service.
|
|
236
|
+
*
|
|
237
|
+
* Returns undefined if the Service is not part of a Module.
|
|
231
238
|
*/
|
|
232
239
|
static of(ctor: Service): Service<Module> | undefined;
|
|
233
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Helper type to add Module metadata to a Service.
|
|
243
|
+
*/
|
|
234
244
|
type WithModule<T extends object = any> = T & {
|
|
235
245
|
[MODULE]?: Service;
|
|
236
246
|
};
|
|
@@ -464,6 +474,7 @@ declare class TypeProvider {
|
|
|
464
474
|
null: typeof TypeBox.Null;
|
|
465
475
|
const: typeof TypeBox.Literal;
|
|
466
476
|
codec: typeof TypeBox.Codec;
|
|
477
|
+
literal: typeof TypeBox.Literal;
|
|
467
478
|
/**
|
|
468
479
|
* Type guards to check the type of schema.
|
|
469
480
|
* This is not a runtime type check, but a compile-time type guard.
|
|
@@ -762,6 +773,10 @@ declare class CodecManager {
|
|
|
762
773
|
* Decode data using the specified codec.
|
|
763
774
|
*/
|
|
764
775
|
decode<T extends TSchema$1>(schema: T, value: any, options?: DecodeOptions): StaticDecode$1<T>;
|
|
776
|
+
/**
|
|
777
|
+
* Validate decoded data.
|
|
778
|
+
*/
|
|
779
|
+
validate<T extends TSchema$1>(schema: T, value: any, options?: DecodeOptions): StaticDecode$1<T>;
|
|
765
780
|
}
|
|
766
781
|
//#endregion
|
|
767
782
|
//#region src/providers/EventManager.d.ts
|
|
@@ -803,20 +818,87 @@ declare class EventManager {
|
|
|
803
818
|
}): Promise<void>;
|
|
804
819
|
}
|
|
805
820
|
//#endregion
|
|
821
|
+
//#region src/descriptors/$atom.d.ts
|
|
822
|
+
/**
|
|
823
|
+
* Define an atom for state management.
|
|
824
|
+
*
|
|
825
|
+
* Atom lets you define a piece of state with a name, schema, and default value.
|
|
826
|
+
*
|
|
827
|
+
* By default, Alepha state is just a simple key-value store.
|
|
828
|
+
* Using atoms allows you to have type safety, validation, and default values for your state.
|
|
829
|
+
*
|
|
830
|
+
* You control how state is structured and validated.
|
|
831
|
+
*
|
|
832
|
+
* Features:
|
|
833
|
+
* - Set a schema for validation
|
|
834
|
+
* - Set a default value for initial state
|
|
835
|
+
* - Rules, like read-only, custom validation, etc.
|
|
836
|
+
* - Automatic getter access in services with {@link $use}
|
|
837
|
+
* - SSR support (server state automatically serialized and hydrated on client)
|
|
838
|
+
* - React integration (useAtom hook for automatic component re-renders)
|
|
839
|
+
* - Middleware
|
|
840
|
+
* - Persistence adapters (localStorage, Redis, database, file system, cookie, etc.)
|
|
841
|
+
* - State migrations (version upgrades when schema changes)
|
|
842
|
+
* - Documentation generation & devtools integration
|
|
843
|
+
*
|
|
844
|
+
* Common use cases:
|
|
845
|
+
* - user preferences
|
|
846
|
+
* - feature flags
|
|
847
|
+
* - configuration options
|
|
848
|
+
* - session data
|
|
849
|
+
*
|
|
850
|
+
* Atom must contain only serializable data.
|
|
851
|
+
* Avoid storing complex objects like class instances, functions, or DOM elements.
|
|
852
|
+
* If you need to store complex data, consider using identifiers or references instead.
|
|
853
|
+
*/
|
|
854
|
+
declare const $atom: {
|
|
855
|
+
<T extends TObject, N extends string>(options: AtomOptions<T, N>): Atom<T, N>;
|
|
856
|
+
[KIND]: string;
|
|
857
|
+
};
|
|
858
|
+
type AtomOptions<T extends TObject, N extends string> = {
|
|
859
|
+
name: N;
|
|
860
|
+
schema: T;
|
|
861
|
+
} & (T extends TOptionalAdd$1<T> ? {
|
|
862
|
+
default?: Static<T>;
|
|
863
|
+
} : {
|
|
864
|
+
default: Static<T>;
|
|
865
|
+
});
|
|
866
|
+
declare class Atom<T extends TObject = TObject, N extends string = string> {
|
|
867
|
+
readonly options: AtomOptions<T, N>;
|
|
868
|
+
get schema(): T;
|
|
869
|
+
get key(): N;
|
|
870
|
+
constructor(options: AtomOptions<T, N>);
|
|
871
|
+
}
|
|
872
|
+
//#endregion
|
|
806
873
|
//#region src/providers/StateManager.d.ts
|
|
874
|
+
interface AtomWithValue {
|
|
875
|
+
atom: Atom;
|
|
876
|
+
value: unknown;
|
|
877
|
+
}
|
|
807
878
|
declare class StateManager<State$1 extends object = State> {
|
|
808
879
|
protected readonly als: AlsProvider;
|
|
809
880
|
protected readonly events: EventManager;
|
|
881
|
+
protected readonly codec: JsonSchemaCodec;
|
|
882
|
+
protected readonly atoms: Map<keyof State$1, Atom<TObject$1<TypeBox.TProperties>, string>>;
|
|
810
883
|
protected store: Partial<State$1>;
|
|
811
884
|
constructor(store?: Partial<State$1>);
|
|
885
|
+
getAtoms(context?: boolean): Array<AtomWithValue>;
|
|
886
|
+
register(atom: Atom<any>): this;
|
|
812
887
|
/**
|
|
813
888
|
* Get a value from the state with proper typing
|
|
814
889
|
*/
|
|
815
|
-
get<
|
|
890
|
+
get<T extends TObject$1>(target: Atom<T>): Static<T>;
|
|
891
|
+
get<Key extends keyof State$1>(target: Key): State$1[Key] | undefined;
|
|
816
892
|
/**
|
|
817
893
|
* Set a value in the state
|
|
818
894
|
*/
|
|
819
|
-
set<
|
|
895
|
+
set<T extends TObject$1>(target: Atom<T>, value: Static<T>): this;
|
|
896
|
+
set<Key extends keyof State$1>(target: Key, value: State$1[Key] | undefined): this;
|
|
897
|
+
/**
|
|
898
|
+
* Mutate a value in the state.
|
|
899
|
+
*/
|
|
900
|
+
mut<T extends TObject$1>(target: Atom<T>, mutator: (current: Static<T>) => Static<T>): this;
|
|
901
|
+
mut<Key extends keyof State$1>(target: Key, mutator: (current: State$1[Key] | undefined) => State$1[Key] | undefined): this;
|
|
820
902
|
/**
|
|
821
903
|
* Check if a key exists in the state
|
|
822
904
|
*/
|
|
@@ -1000,7 +1082,7 @@ declare class Alepha {
|
|
|
1000
1082
|
*
|
|
1001
1083
|
* > Used to initialize the StateManager.
|
|
1002
1084
|
*/
|
|
1003
|
-
protected init: State
|
|
1085
|
+
protected init: Partial<State>;
|
|
1004
1086
|
/**
|
|
1005
1087
|
* During the instantiation process, we keep a list of pending instantiations.
|
|
1006
1088
|
* > It allows us to detect circular dependencies.
|
|
@@ -1025,12 +1107,6 @@ declare class Alepha {
|
|
|
1025
1107
|
protected substitutions: Map<Service, {
|
|
1026
1108
|
use: Service;
|
|
1027
1109
|
}>;
|
|
1028
|
-
/**
|
|
1029
|
-
* Configuration states for services.
|
|
1030
|
-
*
|
|
1031
|
-
* Used to configure services when they are instantiated.
|
|
1032
|
-
*/
|
|
1033
|
-
protected configurations: Map<Service, object>;
|
|
1034
1110
|
/**
|
|
1035
1111
|
* Registry of descriptors.
|
|
1036
1112
|
*/
|
|
@@ -1195,40 +1271,17 @@ declare class Alepha {
|
|
|
1195
1271
|
* > If you are interested in configuring a service, use Alepha#configure() instead.
|
|
1196
1272
|
*
|
|
1197
1273
|
* @param serviceEntry - The service to register in the container.
|
|
1198
|
-
* @param configure - Optional configuration object to merge with the service's options.
|
|
1199
1274
|
* @return Current instance of Alepha.
|
|
1200
1275
|
*/
|
|
1201
|
-
with<T extends {
|
|
1202
|
-
options?: object;
|
|
1203
|
-
} & object>(serviceEntry: ServiceEntry<T> | {
|
|
1276
|
+
with<T extends object>(serviceEntry: ServiceEntry<T> | {
|
|
1204
1277
|
default: ServiceEntry<T>;
|
|
1205
|
-
}
|
|
1278
|
+
}): this;
|
|
1206
1279
|
/**
|
|
1207
1280
|
* Get an instance of the specified service from the container.
|
|
1208
1281
|
*
|
|
1209
1282
|
* @see {@link InjectOptions} for the available options.
|
|
1210
1283
|
*/
|
|
1211
1284
|
inject<T extends object>(service: Service<T>, opts?: InjectOptions<T>): T;
|
|
1212
|
-
/**
|
|
1213
|
-
* Configures the specified service with the provided state.
|
|
1214
|
-
* If service is not registered, it will do nothing.
|
|
1215
|
-
*
|
|
1216
|
-
* It's recommended to use this method on the `configure` hook.
|
|
1217
|
-
* @example
|
|
1218
|
-
* ```ts
|
|
1219
|
-
* class AppConfig {
|
|
1220
|
-
* configure = $hook({
|
|
1221
|
-
* name: "configure",
|
|
1222
|
-
* handler: (a) => {
|
|
1223
|
-
* a.configure(MyProvider, { some: "data" });
|
|
1224
|
-
* }
|
|
1225
|
-
* })
|
|
1226
|
-
* }
|
|
1227
|
-
* ```
|
|
1228
|
-
*/
|
|
1229
|
-
configure<T extends {
|
|
1230
|
-
options?: object;
|
|
1231
|
-
}>(service: Service<T>, state: Partial<T["options"]>): this;
|
|
1232
1285
|
/**
|
|
1233
1286
|
* Applies environment variables to the provided schema and state object.
|
|
1234
1287
|
*
|
|
@@ -1248,6 +1301,10 @@ declare class Alepha {
|
|
|
1248
1301
|
as?: string[];
|
|
1249
1302
|
module?: string;
|
|
1250
1303
|
}>;
|
|
1304
|
+
services<T extends object>(base: Service<T>): Array<T>;
|
|
1305
|
+
/**
|
|
1306
|
+
* Get all descriptors of the specified type.
|
|
1307
|
+
*/
|
|
1251
1308
|
descriptors<TDescriptor extends Descriptor>(factory: {
|
|
1252
1309
|
[KIND]: InstantiableClass<TDescriptor>;
|
|
1253
1310
|
} | string): Array<TDescriptor>;
|
|
@@ -1289,20 +1346,52 @@ interface Env {
|
|
|
1289
1346
|
MODULE_NAME?: string;
|
|
1290
1347
|
}
|
|
1291
1348
|
interface State {
|
|
1292
|
-
|
|
1349
|
+
/**
|
|
1350
|
+
* Environment variables for the application.
|
|
1351
|
+
*/
|
|
1293
1352
|
env?: Readonly<Env>;
|
|
1353
|
+
/**
|
|
1354
|
+
* Logger instance to be used by the Alepha container.
|
|
1355
|
+
*
|
|
1356
|
+
* @internal
|
|
1357
|
+
*/
|
|
1358
|
+
"alepha.logger"?: LoggerInterface;
|
|
1294
1359
|
/**
|
|
1295
1360
|
* If defined, the Alepha container will only register this service and its dependencies.
|
|
1296
1361
|
*/
|
|
1297
|
-
target?: Service;
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1362
|
+
"alepha.target"?: Service;
|
|
1363
|
+
/**
|
|
1364
|
+
* Bind to Vitest 'beforeAll' hook.
|
|
1365
|
+
* Used for testing purposes.
|
|
1366
|
+
* This is automatically attached if Alepha#create() detects a test environment and global 'beforeAll' is available.
|
|
1367
|
+
*/
|
|
1368
|
+
"alepha.test.beforeAll"?: (run: any) => any;
|
|
1302
1369
|
/**
|
|
1303
|
-
*
|
|
1370
|
+
* Bind to Vitest 'afterAll' hook.
|
|
1371
|
+
* Used for testing purposes.
|
|
1372
|
+
* This is automatically attached if Alepha#create() detects a test environment and global 'afterAll' is available.
|
|
1304
1373
|
*/
|
|
1305
|
-
|
|
1374
|
+
"alepha.test.afterAll"?: (run: any) => any;
|
|
1375
|
+
/**
|
|
1376
|
+
* Bind to Vitest 'afterEach' hook.
|
|
1377
|
+
* Used for testing purposes.
|
|
1378
|
+
* This is automatically attached if Alepha#create() detects a test environment and global 'afterEach' is available.
|
|
1379
|
+
*/
|
|
1380
|
+
"alepha.test.afterEach"?: (run: any) => any;
|
|
1381
|
+
/**
|
|
1382
|
+
* Bind to Vitest 'onTestFinished' hook.
|
|
1383
|
+
* Used for testing purposes.
|
|
1384
|
+
* This is automatically attached if Alepha#create() detects a test environment and global 'onTestFinished' is available.
|
|
1385
|
+
*/
|
|
1386
|
+
"alepha.test.onTestFinished"?: (run: any) => any;
|
|
1387
|
+
/**
|
|
1388
|
+
* List of static assets to be copied to the output directory during the build process.
|
|
1389
|
+
*
|
|
1390
|
+
* Used for Alepha-based applications that require static assets.
|
|
1391
|
+
*
|
|
1392
|
+
* See @alepha/vite for more details.
|
|
1393
|
+
*/
|
|
1394
|
+
"alepha.build.assets"?: Array<string>;
|
|
1306
1395
|
}
|
|
1307
1396
|
interface Hooks {
|
|
1308
1397
|
/**
|
|
@@ -1346,9 +1435,6 @@ interface Hooks {
|
|
|
1346
1435
|
prevValue: any;
|
|
1347
1436
|
};
|
|
1348
1437
|
}
|
|
1349
|
-
interface Configurable<T extends object = any> {
|
|
1350
|
-
options: T;
|
|
1351
|
-
}
|
|
1352
1438
|
//#endregion
|
|
1353
1439
|
//#region src/interfaces/Run.d.ts
|
|
1354
1440
|
interface RunOptions {
|
|
@@ -1391,49 +1477,48 @@ declare const boot: {
|
|
|
1391
1477
|
*/
|
|
1392
1478
|
declare const OPTIONS: unique symbol;
|
|
1393
1479
|
//#endregion
|
|
1394
|
-
//#region src/descriptors/$
|
|
1480
|
+
//#region src/descriptors/$context.d.ts
|
|
1395
1481
|
/**
|
|
1396
|
-
* Get Alepha instance and
|
|
1397
|
-
* This should be used inside a descriptor only.
|
|
1482
|
+
* Get Alepha instance and current service from the current context.
|
|
1398
1483
|
*
|
|
1399
|
-
*
|
|
1400
|
-
* import { $cursor } from "alepha";
|
|
1484
|
+
* It can only be used inside $descriptor functions.
|
|
1401
1485
|
*
|
|
1402
|
-
*
|
|
1486
|
+
* ```ts
|
|
1487
|
+
* import { $context } from "alepha";
|
|
1403
1488
|
*
|
|
1404
|
-
*
|
|
1489
|
+
* const $hello = () => {
|
|
1490
|
+
* const { alepha, service, module } = $context();
|
|
1405
1491
|
*
|
|
1406
|
-
* //
|
|
1407
|
-
* //
|
|
1492
|
+
* // alepha - alepha instance
|
|
1493
|
+
* // service - class which is creating this descriptor, this is NOT the instance but the service definition
|
|
1494
|
+
* // module - module definition, if any
|
|
1408
1495
|
*
|
|
1409
1496
|
* return {};
|
|
1410
1497
|
* }
|
|
1411
1498
|
*
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1415
|
-
*/
|
|
1416
|
-
declare const $cursor: () => CursorDescriptor;
|
|
1417
|
-
/**
|
|
1418
|
-
* /!\ Global variable /!\
|
|
1499
|
+
* class MyService {
|
|
1500
|
+
* hello = $hello();
|
|
1501
|
+
* }
|
|
1419
1502
|
*
|
|
1420
|
-
*
|
|
1503
|
+
* const alepha = new Alepha().with(MyService);
|
|
1504
|
+
* ```
|
|
1421
1505
|
*
|
|
1422
1506
|
* @internal
|
|
1423
1507
|
*/
|
|
1424
|
-
declare const
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1508
|
+
declare const $context: () => ContextDescriptor;
|
|
1509
|
+
interface ContextDescriptor {
|
|
1510
|
+
/**
|
|
1511
|
+
* Alepha instance.
|
|
1512
|
+
*/
|
|
1513
|
+
alepha: Alepha;
|
|
1514
|
+
/**
|
|
1515
|
+
* Service definition which is creating this descriptor.
|
|
1516
|
+
* This is NOT the instance but the service definition.
|
|
1517
|
+
*/
|
|
1518
|
+
service?: Service;
|
|
1519
|
+
/**
|
|
1520
|
+
* Module definition, if any.
|
|
1521
|
+
*/
|
|
1437
1522
|
module?: Service;
|
|
1438
1523
|
}
|
|
1439
1524
|
//#endregion
|
|
@@ -1537,6 +1622,9 @@ declare class HookDescriptor<T extends keyof Hooks> extends Descriptor<HookOptio
|
|
|
1537
1622
|
protected onInit(): void;
|
|
1538
1623
|
}
|
|
1539
1624
|
//#endregion
|
|
1625
|
+
//#region src/descriptors/$use.d.ts
|
|
1626
|
+
declare const $use: <T extends TObject, N extends string>(atom: Atom<T, N>) => Readonly<Static<T>>;
|
|
1627
|
+
//#endregion
|
|
1540
1628
|
//#region src/errors/AppNotStartedError.d.ts
|
|
1541
1629
|
declare class AppNotStartedError extends AlephaError {
|
|
1542
1630
|
readonly name = "AppNotStartedError";
|
|
@@ -1562,6 +1650,24 @@ declare class TooLateSubstitutionError extends AlephaError {
|
|
|
1562
1650
|
}
|
|
1563
1651
|
//#endregion
|
|
1564
1652
|
//#region src/schemas/pageSchema.d.ts
|
|
1653
|
+
declare const pageMetadataSchema: TObject<{
|
|
1654
|
+
number: TypeBox.TInteger;
|
|
1655
|
+
size: TypeBox.TInteger;
|
|
1656
|
+
offset: TypeBox.TInteger;
|
|
1657
|
+
numberOfElements: TypeBox.TInteger;
|
|
1658
|
+
totalElements: TypeBox.TOptional<TypeBox.TInteger>;
|
|
1659
|
+
totalPages: TypeBox.TOptional<TypeBox.TInteger>;
|
|
1660
|
+
isEmpty: TypeBox.TBoolean;
|
|
1661
|
+
isFirst: TypeBox.TBoolean;
|
|
1662
|
+
isLast: TypeBox.TBoolean;
|
|
1663
|
+
sort: TypeBox.TOptional<TObject<{
|
|
1664
|
+
sorted: TypeBox.TBoolean;
|
|
1665
|
+
fields: TArray<TObject<{
|
|
1666
|
+
field: TypeBox.TString;
|
|
1667
|
+
direction: TypeBox.TUnsafe<"asc" | "desc">;
|
|
1668
|
+
}>>;
|
|
1669
|
+
}>>;
|
|
1670
|
+
}>;
|
|
1565
1671
|
/**
|
|
1566
1672
|
* Create a pagination schema for the given object schema.
|
|
1567
1673
|
*
|
|
@@ -1587,24 +1693,7 @@ declare class TooLateSubstitutionError extends AlephaError {
|
|
|
1587
1693
|
declare const pageSchema: <T extends TObject | TRecord>(objectSchema: T, options?: TObjectOptions) => TPage<T>;
|
|
1588
1694
|
type TPage<T extends TObject | TRecord> = TObject<{
|
|
1589
1695
|
content: TArray<T>;
|
|
1590
|
-
page:
|
|
1591
|
-
number: TInteger;
|
|
1592
|
-
size: TInteger;
|
|
1593
|
-
offset: TInteger;
|
|
1594
|
-
numberOfElements: TInteger;
|
|
1595
|
-
totalElements: TOptionalAdd<TInteger>;
|
|
1596
|
-
totalPages: TOptionalAdd<TInteger>;
|
|
1597
|
-
isEmpty: TBoolean;
|
|
1598
|
-
isFirst: TBoolean;
|
|
1599
|
-
isLast: TBoolean;
|
|
1600
|
-
sort: TOptionalAdd<TObject<{
|
|
1601
|
-
sorted: TBoolean;
|
|
1602
|
-
fields: TArray<TObject<{
|
|
1603
|
-
field: TString;
|
|
1604
|
-
direction: TSchema;
|
|
1605
|
-
}>>;
|
|
1606
|
-
}>>;
|
|
1607
|
-
}>;
|
|
1696
|
+
page: typeof pageMetadataSchema;
|
|
1608
1697
|
}>;
|
|
1609
1698
|
/**
|
|
1610
1699
|
* Opinionated type definition for a paginated response.
|
|
@@ -1641,65 +1730,18 @@ type Page<T> = {
|
|
|
1641
1730
|
* Array of items on the current page.
|
|
1642
1731
|
*/
|
|
1643
1732
|
content: T[];
|
|
1644
|
-
page:
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
/**
|
|
1650
|
-
* Number of items per page (requested page size).
|
|
1651
|
-
*/
|
|
1652
|
-
size: number;
|
|
1653
|
-
/**
|
|
1654
|
-
* Offset in the dataset (page × size).
|
|
1655
|
-
*/
|
|
1656
|
-
offset: number;
|
|
1657
|
-
/**
|
|
1658
|
-
* Number of elements in THIS page (content.length).
|
|
1659
|
-
* Different from totalElements which is the total across all pages.
|
|
1660
|
-
*/
|
|
1661
|
-
numberOfElements: number;
|
|
1662
|
-
/**
|
|
1663
|
-
* Total number of elements across all pages.
|
|
1664
|
-
* Only available when counting is enabled.
|
|
1665
|
-
*/
|
|
1666
|
-
totalElements?: number;
|
|
1667
|
-
/**
|
|
1668
|
-
* Total number of pages.
|
|
1669
|
-
* Only available when `totalElements` is present.
|
|
1670
|
-
*/
|
|
1671
|
-
totalPages?: number;
|
|
1672
|
-
/**
|
|
1673
|
-
* Indicates if the current page has no items (numberOfElements === 0).
|
|
1674
|
-
*/
|
|
1675
|
-
isEmpty: boolean;
|
|
1676
|
-
/**
|
|
1677
|
-
* Indicates if this is the first page (number === 0).
|
|
1678
|
-
*/
|
|
1679
|
-
isFirst: boolean;
|
|
1680
|
-
/**
|
|
1681
|
-
* Indicates if this is the last page (no more pages after this).
|
|
1682
|
-
*/
|
|
1683
|
-
isLast: boolean;
|
|
1733
|
+
page: Static<typeof pageMetadataSchema>;
|
|
1734
|
+
};
|
|
1735
|
+
type PageMetadata = Static<typeof pageMetadataSchema>;
|
|
1736
|
+
declare module "alepha" {
|
|
1737
|
+
interface TypeProvider {
|
|
1684
1738
|
/**
|
|
1685
|
-
*
|
|
1686
|
-
* Only present when sorting is applied.
|
|
1739
|
+
* Create a schema for a paginated response.
|
|
1687
1740
|
*/
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
sorted: boolean;
|
|
1693
|
-
/**
|
|
1694
|
-
* The fields and directions used for sorting.
|
|
1695
|
-
*/
|
|
1696
|
-
fields: Array<{
|
|
1697
|
-
field: string;
|
|
1698
|
-
direction: "asc" | "desc";
|
|
1699
|
-
}>;
|
|
1700
|
-
};
|
|
1701
|
-
};
|
|
1702
|
-
};
|
|
1741
|
+
page<T extends TObject | TRecord>(itemSchema: T): TPage<T>;
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
//# sourceMappingURL=pageSchema.d.ts.map
|
|
1703
1745
|
//#endregion
|
|
1704
1746
|
//#region src/helpers/createPagination.d.ts
|
|
1705
1747
|
/**
|
|
@@ -1806,6 +1848,14 @@ interface SortField {
|
|
|
1806
1848
|
direction: SortDirection;
|
|
1807
1849
|
}
|
|
1808
1850
|
//#endregion
|
|
1851
|
+
//#region src/schemas/pageQuerySchema.d.ts
|
|
1852
|
+
declare const pageQuerySchema: TypeBox.TObject<{
|
|
1853
|
+
page: TypeBox.TOptional<TypeBox.TInteger>;
|
|
1854
|
+
size: TypeBox.TOptional<TypeBox.TInteger>;
|
|
1855
|
+
sort: TypeBox.TOptional<TypeBox.TString>;
|
|
1856
|
+
}>;
|
|
1857
|
+
type PageQuery = Static<typeof pageQuerySchema>;
|
|
1858
|
+
//#endregion
|
|
1809
1859
|
//#region src/index.d.ts
|
|
1810
1860
|
/**
|
|
1811
1861
|
* Run Alepha application, trigger start lifecycle.
|
|
@@ -1823,5 +1873,5 @@ interface SortField {
|
|
|
1823
1873
|
*/
|
|
1824
1874
|
declare const run: (entry: Alepha | Service | Array<Service>, opts?: RunOptions) => Alepha;
|
|
1825
1875
|
//#endregion
|
|
1826
|
-
export { $
|
|
1876
|
+
export { $atom, $context, $env, $hook, $inject, $module, $use, AbstractClass, Alepha, AlephaError, AlsProvider, AppNotStartedError, Async, AsyncFn, AsyncLocalStorageData, Atom, AtomOptions, AtomWithValue, CircularDependencyError, CodecManager, ContainerLockedError, ContextDescriptor, DecodeOptions, Descriptor, DescriptorArgs, DescriptorConfig, DescriptorFactory, DescriptorFactoryLike, EncodeOptions, EncodeResult, Encoding, Env, FileLike, Hook, HookDescriptor, HookOptions, Hooks, InjectDescriptor, InjectOptions, InstantiableClass, JsonSchemaCodec, KIND, LogLevel, LoggerInterface, MaybePromise, Module, ModuleDescriptorOptions, OPTIONS, Page, PageMetadata, PageQuery, PageRequest, RunFunction, SchemaCodec, Service, ServiceEntry, ServiceSubstitution, SortDirection, SortField, 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, TPage, type TPick, type TProperties, type TRecord, type TSchema, TStream, type TString, type TStringOptions, TTextOptions, type TTuple, type TUnion, type TUnsafe, type TVoid, TextLength, TooLateSubstitutionError, TypeBox, TypeBoxError, TypeBoxErrorParams, TypeBoxFormat, TypeBoxValue, TypeGuard, TypeProvider, WithModule, boot, createDescriptor, createPagination, isClass, isEmail, isFileLike, isTypeFile, isURL, isUUID, pageMetadataSchema, pageQuerySchema, pageSchema, run, t };
|
|
1827
1877
|
//# sourceMappingURL=index.d.ts.map
|
package/datetime.d.ts
CHANGED
|
@@ -163,7 +163,7 @@ declare module "alepha" {
|
|
|
163
163
|
isDuration: typeof isDurationSchema;
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
declare const AlephaDateTime: _alepha_core1.Service<_alepha_core1.Module
|
|
166
|
+
declare const AlephaDateTime: _alepha_core1.Service<_alepha_core1.Module>;
|
|
167
167
|
//#endregion
|
|
168
168
|
export { $interval, AlephaDateTime, DateTime, DateTimeProvider, Duration, DurationLike, Interval, IntervalDescriptor, IntervalDescriptorOptions, Timeout, date, datetime, dayjs, duration, isDateSchema, isDateTimeSchema, isDurationSchema, isTimeSchema, time };
|
|
169
169
|
//# sourceMappingURL=index.d.ts.map
|