alepha 0.11.5 → 0.11.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/LICENSE +1 -1
- package/README.md +15 -100
- package/api/files.d.ts +168 -169
- package/api/jobs.d.ts +263 -154
- package/api/notifications.d.ts +28 -29
- package/api/users.d.ts +476 -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 +299 -222
- package/datetime.d.ts +4 -29
- package/devtools.d.ts +166 -284
- 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 +11 -9
- package/package.json +51 -51
- package/postgres.d.ts +480 -198
- 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 +39 -16
- package/react/head.d.ts +1 -1
- package/react/i18n.d.ts +2 -2
- package/react.d.ts +66 -41
- package/redis.d.ts +1 -1
- 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 +18 -19
- package/server/helmet.d.ts +44 -15
- package/server/links.d.ts +37 -31
- 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 +1 -1
- package/topic/redis.d.ts +1 -1
- package/topic.d.ts +1 -1
- package/ui.d.ts +142 -12
- package/vite.d.ts +2 -2
package/core.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { Validator } from "typebox/compile";
|
|
3
|
-
import * as TypeBoxValue from "typebox/value";
|
|
4
3
|
import * as TypeBox from "typebox";
|
|
5
|
-
import { Static as Static$1, StaticDecode, StaticDecode as Static,
|
|
4
|
+
import { Static as Static$1, StaticDecode, StaticDecode as Static, StaticEncode, StaticEncode as StaticEncode$1, TAny, TAny as TAny$1, TArray, TArray as TArray$1, TArrayOptions, TBigInt, TBoolean, TBoolean as TBoolean$1, TInteger, TInteger as TInteger$1, TInterface, TKeysToIndexer, TKeysToIndexer as TKeysToIndexer$1, TNull, TNull as TNull$1, TNumber, TNumber as TNumber$1, TNumberOptions, TNumberOptions as TNumberOptions$1, TObject, TObject as TObject$1, TObjectOptions, TObjectOptions as TObjectOptions$1, TOmit, TOptional, TOptionalAdd, TOptionalAdd as TOptionalAdd$1, TPartial, TPick, TPick as TPick$1, TProperties, TProperties as TProperties$1, TRecord, TRecord as TRecord$1, TSchema, TSchema as TSchema$1, TSchemaOptions, TString, TString as TString$1, TStringOptions, TStringOptions as TStringOptions$1, TTuple, TUnion, TUnion as TUnion$1, TUnsafe, TUnsafe as TUnsafe$1, TVoid } from "typebox";
|
|
6
5
|
import TypeBoxFormat from "typebox/format";
|
|
6
|
+
import * as TypeBoxValue from "typebox/value";
|
|
7
7
|
import { TLocalizedValidationError } from "typebox/error";
|
|
8
8
|
import { Readable } from "node:stream";
|
|
9
9
|
import { ReadableStream as ReadableStream$1 } from "node:stream/web";
|
|
@@ -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
|
};
|
|
@@ -372,8 +382,11 @@ type TStream = TUnsafe$1<StreamLike>;
|
|
|
372
382
|
declare const isUUID: typeof TypeBoxFormat.IsUuid;
|
|
373
383
|
declare const isEmail: typeof TypeBoxFormat.IsEmail;
|
|
374
384
|
declare const isURL: typeof TypeBoxFormat.IsUrl;
|
|
385
|
+
declare const isDateTime: typeof TypeBoxFormat.IsDateTime;
|
|
386
|
+
declare const isDate: typeof TypeBoxFormat.IsDate;
|
|
387
|
+
declare const isTime: typeof TypeBoxFormat.IsTime;
|
|
388
|
+
declare const isDuration: typeof TypeBoxFormat.IsDuration;
|
|
375
389
|
declare class TypeGuard {
|
|
376
|
-
isFile: (value: TSchema$1) => value is TFile;
|
|
377
390
|
isBigInt: (value: TSchema$1) => value is TString$1;
|
|
378
391
|
isUUID: (value: TSchema$1) => value is TString$1;
|
|
379
392
|
isObject: typeof TypeBox.IsObject;
|
|
@@ -393,6 +406,11 @@ declare class TypeGuard {
|
|
|
393
406
|
isVoid: typeof TypeBox.IsVoid;
|
|
394
407
|
isLiteral: typeof TypeBox.IsLiteral;
|
|
395
408
|
isSchema: typeof TypeBox.IsSchema;
|
|
409
|
+
isFile: (value: TSchema$1) => value is TFile;
|
|
410
|
+
isDateTime: (schema: unknown) => boolean;
|
|
411
|
+
isDate: (schema: unknown) => boolean;
|
|
412
|
+
isTime: (schema: unknown) => boolean;
|
|
413
|
+
isDuration: (schema: unknown) => boolean;
|
|
396
414
|
}
|
|
397
415
|
declare module "typebox" {
|
|
398
416
|
interface TString {
|
|
@@ -457,13 +475,11 @@ declare class TypeProvider {
|
|
|
457
475
|
void: typeof TypeBox.Void;
|
|
458
476
|
undefined: typeof TypeBox.Undefined;
|
|
459
477
|
record: typeof TypeBox.Record;
|
|
460
|
-
partial: typeof TypeBox.Partial;
|
|
461
478
|
union: typeof TypeBox.Union;
|
|
462
479
|
tuple: typeof TypeBox.Tuple;
|
|
463
|
-
interface: typeof TypeBox.Interface;
|
|
464
480
|
null: typeof TypeBox.Null;
|
|
465
481
|
const: typeof TypeBox.Literal;
|
|
466
|
-
|
|
482
|
+
options: typeof TypeBox.Options;
|
|
467
483
|
/**
|
|
468
484
|
* Type guards to check the type of schema.
|
|
469
485
|
* This is not a runtime type check, but a compile-time type guard.
|
|
@@ -476,8 +492,11 @@ declare class TypeProvider {
|
|
|
476
492
|
* ```
|
|
477
493
|
*/
|
|
478
494
|
readonly schema: TypeGuard;
|
|
495
|
+
extend<T extends TSchema$1[], U$1 extends TProperties$1>(schema: [...T], properties: U$1, options?: TSchemaOptions): TInterface<T, U$1>;
|
|
496
|
+
extend<T extends TObject$1, U$1 extends TProperties$1>(schema: T, properties: U$1, options?: TSchemaOptions): TInterface<[T], U$1>;
|
|
479
497
|
pick<T extends TObject$1, Indexer extends PropertyKey[]>(schema: T, keys: [...Indexer], options?: TObjectOptions$1): TPick$1<T, TKeysToIndexer$1<Indexer>>;
|
|
480
498
|
omit<T extends TObject$1, Indexer extends PropertyKey[]>(schema: T, keys: [...Indexer], options?: TObjectOptions$1): TOmit<T, TKeysToIndexer$1<Indexer>>;
|
|
499
|
+
partial<T extends TSchema$1>(schema: T, options?: TSchemaOptions): TPartial<T>;
|
|
481
500
|
/**
|
|
482
501
|
* Create a schema for an object.
|
|
483
502
|
* By default, additional properties are not allowed.
|
|
@@ -564,18 +583,18 @@ declare class TypeProvider {
|
|
|
564
583
|
*/
|
|
565
584
|
enum<T extends string[]>(values: [...T], options?: TStringOptions$1): TUnsafe$1<T[number]>;
|
|
566
585
|
/**
|
|
567
|
-
* Create a schema for a bigint.
|
|
568
|
-
* This is
|
|
586
|
+
* Create a schema for a bigint represented as a string.
|
|
587
|
+
* This is a string that validates bigint format (e.g. "123456789").
|
|
569
588
|
*/
|
|
570
|
-
bigint(options?: TStringOptions$1):
|
|
589
|
+
bigint(options?: TStringOptions$1): TString$1;
|
|
571
590
|
/**
|
|
572
|
-
* Create a schema for a
|
|
591
|
+
* Create a schema for a URL represented as a string.
|
|
573
592
|
*/
|
|
574
|
-
url(options?: TStringOptions$1):
|
|
593
|
+
url(options?: TStringOptions$1): TString$1;
|
|
575
594
|
/**
|
|
576
|
-
* Create a schema for binary data represented as a string.
|
|
595
|
+
* Create a schema for binary data represented as a base64 string.
|
|
577
596
|
*/
|
|
578
|
-
binary(options: TStringOptions$1):
|
|
597
|
+
binary(options: TStringOptions$1): TString$1;
|
|
579
598
|
/**
|
|
580
599
|
* Create a schema for uuid.
|
|
581
600
|
*/
|
|
@@ -624,6 +643,10 @@ declare class TypeProvider {
|
|
|
624
643
|
label: TString$1;
|
|
625
644
|
description: TypeBox.TOptional<TString$1>;
|
|
626
645
|
}>;
|
|
646
|
+
datetime: (options?: TStringOptions$1) => TString$1;
|
|
647
|
+
date: (options?: TStringOptions$1) => TString$1;
|
|
648
|
+
time: (options?: TStringOptions$1) => TString$1;
|
|
649
|
+
duration: (options?: TStringOptions$1) => TString$1;
|
|
627
650
|
}
|
|
628
651
|
type TextLength = "short" | "regular" | "long" | "rich";
|
|
629
652
|
interface TTextOptions extends TStringOptions$1 {
|
|
@@ -651,61 +674,56 @@ declare const t: TypeProvider;
|
|
|
651
674
|
//#endregion
|
|
652
675
|
//#region src/providers/SchemaCodec.d.ts
|
|
653
676
|
declare abstract class SchemaCodec {
|
|
654
|
-
protected cache: Map<TSchema$1, Validator>;
|
|
655
|
-
protected guard: TypeGuard;
|
|
656
677
|
/**
|
|
657
678
|
* Encode the value to a string format.
|
|
658
679
|
*/
|
|
659
|
-
abstract encodeToString(schema:
|
|
680
|
+
abstract encodeToString<T extends TSchema>(schema: T, value: Static<T>): string;
|
|
660
681
|
/**
|
|
661
682
|
* Encode the value to a binary format.
|
|
662
683
|
*/
|
|
663
|
-
abstract encodeToBinary(schema:
|
|
664
|
-
/**
|
|
665
|
-
* Transform a specific type for this codec.
|
|
666
|
-
* Return undefined to use the default schema, or return a new schema to replace it.
|
|
667
|
-
*
|
|
668
|
-
* Override this method to customize how specific types are handled in this codec.
|
|
669
|
-
* For example, a ProtobufCodec might keep BigInt as-is instead of converting to string.
|
|
670
|
-
*/
|
|
671
|
-
protected abstract transformType(schema: TSchema$1): TSchema$1 | false | void;
|
|
672
|
-
encode<T extends TSchema$1>(schema: T, value: any): StaticEncode$1<T>;
|
|
673
|
-
decode<T extends TSchema$1>(schema: T, value: any): StaticDecode$1<T>;
|
|
674
|
-
protected validator<T extends TSchema$1>(schema: T): Validator<{}, T>;
|
|
684
|
+
abstract encodeToBinary<T extends TSchema>(schema: T, value: Static<T>): Uint8Array;
|
|
675
685
|
/**
|
|
676
|
-
*
|
|
677
|
-
* Override this method to provide custom schema transformations.
|
|
678
|
-
* This method should recursively transform all nested schemas.
|
|
686
|
+
* Decode string, binary, or other formats to the schema type.
|
|
679
687
|
*/
|
|
680
|
-
|
|
688
|
+
abstract decode<T>(schema: TSchema, value: unknown): T;
|
|
689
|
+
}
|
|
690
|
+
//#endregion
|
|
691
|
+
//#region src/providers/JsonSchemaCodec.d.ts
|
|
692
|
+
declare class JsonSchemaCodec extends SchemaCodec {
|
|
693
|
+
protected readonly json: Json;
|
|
694
|
+
protected readonly encoder: TextEncoder;
|
|
695
|
+
protected readonly decoder: TextDecoder;
|
|
696
|
+
encodeToString<T extends TSchema$1>(schema: T, value: Static<T>): string;
|
|
697
|
+
encodeToBinary<T extends TSchema$1>(schema: T, value: Static<T>): Uint8Array;
|
|
698
|
+
decode<T>(schema: TSchema$1, value: unknown): T;
|
|
699
|
+
}
|
|
700
|
+
//#endregion
|
|
701
|
+
//#region src/providers/SchemaValidator.d.ts
|
|
702
|
+
declare class SchemaValidator {
|
|
703
|
+
protected cache: Map<TSchema$1, Validator<TypeBox.TProperties, TSchema$1>>;
|
|
681
704
|
/**
|
|
682
|
-
*
|
|
705
|
+
* Validate the value against the provided schema.
|
|
683
706
|
*
|
|
684
|
-
*
|
|
707
|
+
* Validation create a new value by applying some preprocessing. (e.g., trimming text)
|
|
685
708
|
*/
|
|
686
|
-
|
|
709
|
+
validate<T extends TSchema$1>(schema: T, value: unknown, options?: ValidateOptions): Static<T>;
|
|
710
|
+
protected getValidator<T extends TSchema$1>(schema: T): Validator<{}, T>;
|
|
687
711
|
/**
|
|
688
712
|
* Preprocess the value based on the schema before validation.
|
|
689
713
|
*
|
|
690
714
|
* - If the value is `null` and the schema does not allow `null`, it converts it to `undefined`.
|
|
691
715
|
* - If the value is a string and the schema has a `~options.trim` flag, it trims whitespace from the string.
|
|
692
716
|
*/
|
|
693
|
-
|
|
717
|
+
beforeParse(schema: any, value: any, options: ValidateOptions): any;
|
|
694
718
|
/**
|
|
695
|
-
* Used by `
|
|
719
|
+
* Used by `beforeParse` to determine if a schema allows null values.
|
|
696
720
|
*/
|
|
697
721
|
protected isSchemaNullable: (schema: any) => boolean;
|
|
698
722
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
protected readonly encoder: TextEncoder;
|
|
704
|
-
protected readonly decoder: TextDecoder;
|
|
705
|
-
protected transformType(schema: TSchema$1): TSchema$1 | false | void;
|
|
706
|
-
encodeToString(schema: TSchema$1, value: any): string;
|
|
707
|
-
encodeToBinary(schema: TSchema$1, value: any): Uint8Array;
|
|
708
|
-
decode<T extends TSchema$1>(schema: T, value: any): StaticDecode$1<T>;
|
|
723
|
+
interface ValidateOptions {
|
|
724
|
+
trim?: boolean;
|
|
725
|
+
nullToUndefined?: boolean;
|
|
726
|
+
deleteUndefined?: boolean;
|
|
709
727
|
}
|
|
710
728
|
//#endregion
|
|
711
729
|
//#region src/providers/CodecManager.d.ts
|
|
@@ -713,24 +731,35 @@ type Encoding = "object" | "string" | "binary";
|
|
|
713
731
|
interface EncodeOptions<T extends Encoding = Encoding> {
|
|
714
732
|
/**
|
|
715
733
|
* The output encoding format:
|
|
716
|
-
* - 'object': Returns native types (objects, BigInt, Date, etc.)
|
|
717
734
|
* - 'string': Returns JSON string
|
|
718
735
|
* - 'binary': Returns Uint8Array (for protobuf, msgpack, etc.)
|
|
736
|
+
*
|
|
737
|
+
* @default "string"
|
|
719
738
|
*/
|
|
720
739
|
as?: T;
|
|
721
740
|
/**
|
|
722
741
|
* The encoder to use (e.g., 'json', 'protobuf', 'msgpack')
|
|
723
|
-
*
|
|
742
|
+
*
|
|
743
|
+
* @default "json"
|
|
724
744
|
*/
|
|
725
745
|
encoder?: string;
|
|
746
|
+
/**
|
|
747
|
+
* Validation options to apply before encoding.
|
|
748
|
+
*/
|
|
749
|
+
validation?: ValidateOptions | false;
|
|
726
750
|
}
|
|
727
751
|
type EncodeResult<T extends TSchema$1, E extends Encoding> = E extends "string" ? string : E extends "binary" ? Uint8Array : StaticEncode$1<T>;
|
|
728
752
|
interface DecodeOptions {
|
|
729
753
|
/**
|
|
730
754
|
* The encoder to use (e.g., 'json', 'protobuf', 'msgpack')
|
|
731
|
-
*
|
|
755
|
+
*
|
|
756
|
+
* @default "json"
|
|
732
757
|
*/
|
|
733
758
|
encoder?: string;
|
|
759
|
+
/**
|
|
760
|
+
* Validation options to apply before encoding.
|
|
761
|
+
*/
|
|
762
|
+
validation?: ValidateOptions | false;
|
|
734
763
|
}
|
|
735
764
|
/**
|
|
736
765
|
* CodecManager manages multiple codec formats and provides a unified interface
|
|
@@ -739,29 +768,38 @@ interface DecodeOptions {
|
|
|
739
768
|
declare class CodecManager {
|
|
740
769
|
protected readonly codecs: Map<string, SchemaCodec>;
|
|
741
770
|
protected readonly jsonCodec: JsonSchemaCodec;
|
|
771
|
+
protected readonly schemaValidator: SchemaValidator;
|
|
742
772
|
default: string;
|
|
743
773
|
constructor();
|
|
744
774
|
/**
|
|
745
775
|
* Register a new codec format.
|
|
776
|
+
*
|
|
746
777
|
* @param name - The name of the codec (e.g., 'json', 'protobuf')
|
|
747
778
|
* @param codec - The codec implementation
|
|
748
779
|
*/
|
|
749
780
|
register(name: string, codec: SchemaCodec): void;
|
|
750
781
|
/**
|
|
751
782
|
* Get a specific codec by name.
|
|
783
|
+
*
|
|
752
784
|
* @param name - The name of the codec
|
|
753
785
|
* @returns The codec instance
|
|
754
786
|
* @throws {AlephaError} If the codec is not found
|
|
755
787
|
*/
|
|
756
|
-
|
|
788
|
+
getCodec(name: string): SchemaCodec;
|
|
757
789
|
/**
|
|
758
790
|
* Encode data using the specified codec and output format.
|
|
759
791
|
*/
|
|
760
|
-
encode<T extends TSchema$1, E extends Encoding = "object">(schema: T, value:
|
|
792
|
+
encode<T extends TSchema$1, E extends Encoding = "object">(schema: T, value: unknown, options?: EncodeOptions<E>): EncodeResult<T, E>;
|
|
761
793
|
/**
|
|
762
794
|
* Decode data using the specified codec.
|
|
763
795
|
*/
|
|
764
|
-
decode<T extends TSchema$1>(schema: T,
|
|
796
|
+
decode<T extends TSchema$1>(schema: T, data: any, options?: DecodeOptions): Static<T>;
|
|
797
|
+
/**
|
|
798
|
+
* Validate decoded data against the schema.
|
|
799
|
+
*
|
|
800
|
+
* This is automatically called before encoding or after decoding.
|
|
801
|
+
*/
|
|
802
|
+
validate<T extends TSchema$1>(schema: T, value: unknown, options?: ValidateOptions): Static<T>;
|
|
765
803
|
}
|
|
766
804
|
//#endregion
|
|
767
805
|
//#region src/providers/EventManager.d.ts
|
|
@@ -803,20 +841,91 @@ declare class EventManager {
|
|
|
803
841
|
}): Promise<void>;
|
|
804
842
|
}
|
|
805
843
|
//#endregion
|
|
844
|
+
//#region src/descriptors/$atom.d.ts
|
|
845
|
+
/**
|
|
846
|
+
* Define an atom for state management.
|
|
847
|
+
*
|
|
848
|
+
* Atom lets you define a piece of state with a name, schema, and default value.
|
|
849
|
+
*
|
|
850
|
+
* By default, Alepha state is just a simple key-value store.
|
|
851
|
+
* Using atoms allows you to have type safety, validation, and default values for your state.
|
|
852
|
+
*
|
|
853
|
+
* You control how state is structured and validated.
|
|
854
|
+
*
|
|
855
|
+
* Features:
|
|
856
|
+
* - Set a schema for validation
|
|
857
|
+
* - Set a default value for initial state
|
|
858
|
+
* - Rules, like read-only, custom validation, etc.
|
|
859
|
+
* - Automatic getter access in services with {@link $use}
|
|
860
|
+
* - SSR support (server state automatically serialized and hydrated on client)
|
|
861
|
+
* - React integration (useAtom hook for automatic component re-renders)
|
|
862
|
+
* - Middleware
|
|
863
|
+
* - Persistence adapters (localStorage, Redis, database, file system, cookie, etc.)
|
|
864
|
+
* - State migrations (version upgrades when schema changes)
|
|
865
|
+
* - Documentation generation & devtools integration
|
|
866
|
+
*
|
|
867
|
+
* Common use cases:
|
|
868
|
+
* - user preferences
|
|
869
|
+
* - feature flags
|
|
870
|
+
* - configuration options
|
|
871
|
+
* - session data
|
|
872
|
+
*
|
|
873
|
+
* Atom must contain only serializable data.
|
|
874
|
+
* Avoid storing complex objects like class instances, functions, or DOM elements.
|
|
875
|
+
* If you need to store complex data, consider using identifiers or references instead.
|
|
876
|
+
*/
|
|
877
|
+
declare const $atom: {
|
|
878
|
+
<T extends TObject<TProperties$2> | TArray$1, N extends string>(options: AtomOptions<T, N>): Atom<T, N>;
|
|
879
|
+
[KIND]: string;
|
|
880
|
+
};
|
|
881
|
+
type AtomOptions<T extends TAtomObject, N extends string> = {
|
|
882
|
+
name: N;
|
|
883
|
+
schema: T;
|
|
884
|
+
description?: string;
|
|
885
|
+
} & (T extends TOptionalAdd<T> ? {
|
|
886
|
+
default?: Static<T>;
|
|
887
|
+
} : {
|
|
888
|
+
default: Static<T>;
|
|
889
|
+
});
|
|
890
|
+
declare class Atom<T extends TAtomObject = TObject, N extends string = string> {
|
|
891
|
+
readonly options: AtomOptions<T, N>;
|
|
892
|
+
get schema(): T;
|
|
893
|
+
get key(): N;
|
|
894
|
+
constructor(options: AtomOptions<T, N>);
|
|
895
|
+
}
|
|
896
|
+
type TProperties$2 = any;
|
|
897
|
+
type TAtomObject = TObject<any> | TArray$1;
|
|
898
|
+
type AtomStatic<T extends TAtomObject> = T extends TOptionalAdd<T> ? Static<T> | undefined : Static<T>;
|
|
899
|
+
//#endregion
|
|
806
900
|
//#region src/providers/StateManager.d.ts
|
|
901
|
+
interface AtomWithValue {
|
|
902
|
+
atom: Atom;
|
|
903
|
+
value: unknown;
|
|
904
|
+
}
|
|
807
905
|
declare class StateManager<State$1 extends object = State> {
|
|
808
906
|
protected readonly als: AlsProvider;
|
|
809
907
|
protected readonly events: EventManager;
|
|
908
|
+
protected readonly codec: JsonSchemaCodec;
|
|
909
|
+
protected readonly atoms: Map<keyof State$1, Atom<TObject$1<TypeBox.TProperties>, string>>;
|
|
810
910
|
protected store: Partial<State$1>;
|
|
811
911
|
constructor(store?: Partial<State$1>);
|
|
912
|
+
getAtoms(context?: boolean): Array<AtomWithValue>;
|
|
913
|
+
register(atom: Atom<any>): this;
|
|
812
914
|
/**
|
|
813
915
|
* Get a value from the state with proper typing
|
|
814
916
|
*/
|
|
815
|
-
get<
|
|
917
|
+
get<T extends TAtomObject>(target: Atom<T>): Static<T>;
|
|
918
|
+
get<Key extends keyof State$1>(target: Key): State$1[Key] | undefined;
|
|
816
919
|
/**
|
|
817
920
|
* Set a value in the state
|
|
818
921
|
*/
|
|
819
|
-
set<
|
|
922
|
+
set<T extends TAtomObject>(target: Atom<T>, value: AtomStatic<T>): this;
|
|
923
|
+
set<Key extends keyof State$1>(target: Key, value: State$1[Key] | undefined): this;
|
|
924
|
+
/**
|
|
925
|
+
* Mutate a value in the state.
|
|
926
|
+
*/
|
|
927
|
+
mut<T extends TObject$1>(target: Atom<T>, mutator: (current: Static<T>) => Static<T>): this;
|
|
928
|
+
mut<Key extends keyof State$1>(target: Key, mutator: (current: State$1[Key] | undefined) => State$1[Key] | undefined): this;
|
|
820
929
|
/**
|
|
821
930
|
* Check if a key exists in the state
|
|
822
931
|
*/
|
|
@@ -1000,7 +1109,7 @@ declare class Alepha {
|
|
|
1000
1109
|
*
|
|
1001
1110
|
* > Used to initialize the StateManager.
|
|
1002
1111
|
*/
|
|
1003
|
-
protected init: State
|
|
1112
|
+
protected init: Partial<State>;
|
|
1004
1113
|
/**
|
|
1005
1114
|
* During the instantiation process, we keep a list of pending instantiations.
|
|
1006
1115
|
* > It allows us to detect circular dependencies.
|
|
@@ -1025,12 +1134,6 @@ declare class Alepha {
|
|
|
1025
1134
|
protected substitutions: Map<Service, {
|
|
1026
1135
|
use: Service;
|
|
1027
1136
|
}>;
|
|
1028
|
-
/**
|
|
1029
|
-
* Configuration states for services.
|
|
1030
|
-
*
|
|
1031
|
-
* Used to configure services when they are instantiated.
|
|
1032
|
-
*/
|
|
1033
|
-
protected configurations: Map<Service, object>;
|
|
1034
1137
|
/**
|
|
1035
1138
|
* Registry of descriptors.
|
|
1036
1139
|
*/
|
|
@@ -1195,40 +1298,17 @@ declare class Alepha {
|
|
|
1195
1298
|
* > If you are interested in configuring a service, use Alepha#configure() instead.
|
|
1196
1299
|
*
|
|
1197
1300
|
* @param serviceEntry - The service to register in the container.
|
|
1198
|
-
* @param configure - Optional configuration object to merge with the service's options.
|
|
1199
1301
|
* @return Current instance of Alepha.
|
|
1200
1302
|
*/
|
|
1201
|
-
with<T extends {
|
|
1202
|
-
options?: object;
|
|
1203
|
-
} & object>(serviceEntry: ServiceEntry<T> | {
|
|
1303
|
+
with<T extends object>(serviceEntry: ServiceEntry<T> | {
|
|
1204
1304
|
default: ServiceEntry<T>;
|
|
1205
|
-
}
|
|
1305
|
+
}): this;
|
|
1206
1306
|
/**
|
|
1207
1307
|
* Get an instance of the specified service from the container.
|
|
1208
1308
|
*
|
|
1209
1309
|
* @see {@link InjectOptions} for the available options.
|
|
1210
1310
|
*/
|
|
1211
1311
|
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
1312
|
/**
|
|
1233
1313
|
* Applies environment variables to the provided schema and state object.
|
|
1234
1314
|
*
|
|
@@ -1248,6 +1328,10 @@ declare class Alepha {
|
|
|
1248
1328
|
as?: string[];
|
|
1249
1329
|
module?: string;
|
|
1250
1330
|
}>;
|
|
1331
|
+
services<T extends object>(base: Service<T>): Array<T>;
|
|
1332
|
+
/**
|
|
1333
|
+
* Get all descriptors of the specified type.
|
|
1334
|
+
*/
|
|
1251
1335
|
descriptors<TDescriptor extends Descriptor>(factory: {
|
|
1252
1336
|
[KIND]: InstantiableClass<TDescriptor>;
|
|
1253
1337
|
} | string): Array<TDescriptor>;
|
|
@@ -1289,20 +1373,52 @@ interface Env {
|
|
|
1289
1373
|
MODULE_NAME?: string;
|
|
1290
1374
|
}
|
|
1291
1375
|
interface State {
|
|
1292
|
-
|
|
1376
|
+
/**
|
|
1377
|
+
* Environment variables for the application.
|
|
1378
|
+
*/
|
|
1293
1379
|
env?: Readonly<Env>;
|
|
1380
|
+
/**
|
|
1381
|
+
* Logger instance to be used by the Alepha container.
|
|
1382
|
+
*
|
|
1383
|
+
* @internal
|
|
1384
|
+
*/
|
|
1385
|
+
"alepha.logger"?: LoggerInterface;
|
|
1294
1386
|
/**
|
|
1295
1387
|
* If defined, the Alepha container will only register this service and its dependencies.
|
|
1296
1388
|
*/
|
|
1297
|
-
target?: Service;
|
|
1298
|
-
beforeAll?: (run: any) => any;
|
|
1299
|
-
afterAll?: (run: any) => any;
|
|
1300
|
-
afterEach?: (run: any) => any;
|
|
1301
|
-
onTestFinished?: (run: any) => any;
|
|
1389
|
+
"alepha.target"?: Service;
|
|
1302
1390
|
/**
|
|
1303
|
-
*
|
|
1391
|
+
* Bind to Vitest 'beforeAll' hook.
|
|
1392
|
+
* Used for testing purposes.
|
|
1393
|
+
* This is automatically attached if Alepha#create() detects a test environment and global 'beforeAll' is available.
|
|
1304
1394
|
*/
|
|
1305
|
-
|
|
1395
|
+
"alepha.test.beforeAll"?: (run: any) => any;
|
|
1396
|
+
/**
|
|
1397
|
+
* Bind to Vitest 'afterAll' hook.
|
|
1398
|
+
* Used for testing purposes.
|
|
1399
|
+
* This is automatically attached if Alepha#create() detects a test environment and global 'afterAll' is available.
|
|
1400
|
+
*/
|
|
1401
|
+
"alepha.test.afterAll"?: (run: any) => any;
|
|
1402
|
+
/**
|
|
1403
|
+
* Bind to Vitest 'afterEach' hook.
|
|
1404
|
+
* Used for testing purposes.
|
|
1405
|
+
* This is automatically attached if Alepha#create() detects a test environment and global 'afterEach' is available.
|
|
1406
|
+
*/
|
|
1407
|
+
"alepha.test.afterEach"?: (run: any) => any;
|
|
1408
|
+
/**
|
|
1409
|
+
* Bind to Vitest 'onTestFinished' hook.
|
|
1410
|
+
* Used for testing purposes.
|
|
1411
|
+
* This is automatically attached if Alepha#create() detects a test environment and global 'onTestFinished' is available.
|
|
1412
|
+
*/
|
|
1413
|
+
"alepha.test.onTestFinished"?: (run: any) => any;
|
|
1414
|
+
/**
|
|
1415
|
+
* List of static assets to be copied to the output directory during the build process.
|
|
1416
|
+
*
|
|
1417
|
+
* Used for Alepha-based applications that require static assets.
|
|
1418
|
+
*
|
|
1419
|
+
* See @alepha/vite for more details.
|
|
1420
|
+
*/
|
|
1421
|
+
"alepha.build.assets"?: Array<string>;
|
|
1306
1422
|
}
|
|
1307
1423
|
interface Hooks {
|
|
1308
1424
|
/**
|
|
@@ -1346,9 +1462,6 @@ interface Hooks {
|
|
|
1346
1462
|
prevValue: any;
|
|
1347
1463
|
};
|
|
1348
1464
|
}
|
|
1349
|
-
interface Configurable<T extends object = any> {
|
|
1350
|
-
options: T;
|
|
1351
|
-
}
|
|
1352
1465
|
//#endregion
|
|
1353
1466
|
//#region src/interfaces/Run.d.ts
|
|
1354
1467
|
interface RunOptions {
|
|
@@ -1391,49 +1504,48 @@ declare const boot: {
|
|
|
1391
1504
|
*/
|
|
1392
1505
|
declare const OPTIONS: unique symbol;
|
|
1393
1506
|
//#endregion
|
|
1394
|
-
//#region src/descriptors/$
|
|
1507
|
+
//#region src/descriptors/$context.d.ts
|
|
1395
1508
|
/**
|
|
1396
|
-
* Get Alepha instance and
|
|
1397
|
-
* This should be used inside a descriptor only.
|
|
1509
|
+
* Get Alepha instance and current service from the current context.
|
|
1398
1510
|
*
|
|
1399
|
-
*
|
|
1400
|
-
* import { $cursor } from "alepha";
|
|
1511
|
+
* It can only be used inside $descriptor functions.
|
|
1401
1512
|
*
|
|
1402
|
-
*
|
|
1513
|
+
* ```ts
|
|
1514
|
+
* import { $context } from "alepha";
|
|
1403
1515
|
*
|
|
1404
|
-
*
|
|
1516
|
+
* const $hello = () => {
|
|
1517
|
+
* const { alepha, service, module } = $context();
|
|
1405
1518
|
*
|
|
1406
|
-
* //
|
|
1407
|
-
* //
|
|
1519
|
+
* // alepha - alepha instance
|
|
1520
|
+
* // service - class which is creating this descriptor, this is NOT the instance but the service definition
|
|
1521
|
+
* // module - module definition, if any
|
|
1408
1522
|
*
|
|
1409
1523
|
* return {};
|
|
1410
1524
|
* }
|
|
1411
1525
|
*
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1415
|
-
*/
|
|
1416
|
-
declare const $cursor: () => CursorDescriptor;
|
|
1417
|
-
/**
|
|
1418
|
-
* /!\ Global variable /!\
|
|
1526
|
+
* class MyService {
|
|
1527
|
+
* hello = $hello();
|
|
1528
|
+
* }
|
|
1419
1529
|
*
|
|
1420
|
-
*
|
|
1530
|
+
* const alepha = new Alepha().with(MyService);
|
|
1531
|
+
* ```
|
|
1421
1532
|
*
|
|
1422
1533
|
* @internal
|
|
1423
1534
|
*/
|
|
1424
|
-
declare const
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1535
|
+
declare const $context: () => ContextDescriptor;
|
|
1536
|
+
interface ContextDescriptor {
|
|
1537
|
+
/**
|
|
1538
|
+
* Alepha instance.
|
|
1539
|
+
*/
|
|
1540
|
+
alepha: Alepha;
|
|
1541
|
+
/**
|
|
1542
|
+
* Service definition which is creating this descriptor.
|
|
1543
|
+
* This is NOT the instance but the service definition.
|
|
1544
|
+
*/
|
|
1545
|
+
service?: Service;
|
|
1546
|
+
/**
|
|
1547
|
+
* Module definition, if any.
|
|
1548
|
+
*/
|
|
1437
1549
|
module?: Service;
|
|
1438
1550
|
}
|
|
1439
1551
|
//#endregion
|
|
@@ -1537,6 +1649,9 @@ declare class HookDescriptor<T extends keyof Hooks> extends Descriptor<HookOptio
|
|
|
1537
1649
|
protected onInit(): void;
|
|
1538
1650
|
}
|
|
1539
1651
|
//#endregion
|
|
1652
|
+
//#region src/descriptors/$use.d.ts
|
|
1653
|
+
declare const $use: <T extends TObject, N extends string>(atom: Atom<T, N>) => Readonly<Static<T>>;
|
|
1654
|
+
//#endregion
|
|
1540
1655
|
//#region src/errors/AppNotStartedError.d.ts
|
|
1541
1656
|
declare class AppNotStartedError extends AlephaError {
|
|
1542
1657
|
readonly name = "AppNotStartedError";
|
|
@@ -1562,6 +1677,24 @@ declare class TooLateSubstitutionError extends AlephaError {
|
|
|
1562
1677
|
}
|
|
1563
1678
|
//#endregion
|
|
1564
1679
|
//#region src/schemas/pageSchema.d.ts
|
|
1680
|
+
declare const pageMetadataSchema: TObject<{
|
|
1681
|
+
number: TypeBox.TInteger;
|
|
1682
|
+
size: TypeBox.TInteger;
|
|
1683
|
+
offset: TypeBox.TInteger;
|
|
1684
|
+
numberOfElements: TypeBox.TInteger;
|
|
1685
|
+
totalElements: TypeBox.TOptional<TypeBox.TInteger>;
|
|
1686
|
+
totalPages: TypeBox.TOptional<TypeBox.TInteger>;
|
|
1687
|
+
isEmpty: TypeBox.TBoolean;
|
|
1688
|
+
isFirst: TypeBox.TBoolean;
|
|
1689
|
+
isLast: TypeBox.TBoolean;
|
|
1690
|
+
sort: TypeBox.TOptional<TObject<{
|
|
1691
|
+
sorted: TypeBox.TBoolean;
|
|
1692
|
+
fields: TArray<TObject<{
|
|
1693
|
+
field: TypeBox.TString;
|
|
1694
|
+
direction: TypeBox.TUnsafe<"asc" | "desc">;
|
|
1695
|
+
}>>;
|
|
1696
|
+
}>>;
|
|
1697
|
+
}>;
|
|
1565
1698
|
/**
|
|
1566
1699
|
* Create a pagination schema for the given object schema.
|
|
1567
1700
|
*
|
|
@@ -1587,24 +1720,7 @@ declare class TooLateSubstitutionError extends AlephaError {
|
|
|
1587
1720
|
declare const pageSchema: <T extends TObject | TRecord>(objectSchema: T, options?: TObjectOptions) => TPage<T>;
|
|
1588
1721
|
type TPage<T extends TObject | TRecord> = TObject<{
|
|
1589
1722
|
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
|
-
}>;
|
|
1723
|
+
page: typeof pageMetadataSchema;
|
|
1608
1724
|
}>;
|
|
1609
1725
|
/**
|
|
1610
1726
|
* Opinionated type definition for a paginated response.
|
|
@@ -1641,65 +1757,18 @@ type Page<T> = {
|
|
|
1641
1757
|
* Array of items on the current page.
|
|
1642
1758
|
*/
|
|
1643
1759
|
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;
|
|
1760
|
+
page: Static<typeof pageMetadataSchema>;
|
|
1761
|
+
};
|
|
1762
|
+
type PageMetadata = Static<typeof pageMetadataSchema>;
|
|
1763
|
+
declare module "alepha" {
|
|
1764
|
+
interface TypeProvider {
|
|
1684
1765
|
/**
|
|
1685
|
-
*
|
|
1686
|
-
* Only present when sorting is applied.
|
|
1766
|
+
* Create a schema for a paginated response.
|
|
1687
1767
|
*/
|
|
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
|
-
};
|
|
1768
|
+
page<T extends TObject | TRecord>(itemSchema: T): TPage<T>;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
//# sourceMappingURL=pageSchema.d.ts.map
|
|
1703
1772
|
//#endregion
|
|
1704
1773
|
//#region src/helpers/createPagination.d.ts
|
|
1705
1774
|
/**
|
|
@@ -1806,6 +1875,14 @@ interface SortField {
|
|
|
1806
1875
|
direction: SortDirection;
|
|
1807
1876
|
}
|
|
1808
1877
|
//#endregion
|
|
1878
|
+
//#region src/schemas/pageQuerySchema.d.ts
|
|
1879
|
+
declare const pageQuerySchema: TypeBox.TObject<{
|
|
1880
|
+
page: TypeBox.TOptional<TypeBox.TInteger>;
|
|
1881
|
+
size: TypeBox.TOptional<TypeBox.TInteger>;
|
|
1882
|
+
sort: TypeBox.TOptional<TypeBox.TString>;
|
|
1883
|
+
}>;
|
|
1884
|
+
type PageQuery = Static<typeof pageQuerySchema>;
|
|
1885
|
+
//#endregion
|
|
1809
1886
|
//#region src/index.d.ts
|
|
1810
1887
|
/**
|
|
1811
1888
|
* Run Alepha application, trigger start lifecycle.
|
|
@@ -1823,5 +1900,5 @@ interface SortField {
|
|
|
1823
1900
|
*/
|
|
1824
1901
|
declare const run: (entry: Alepha | Service | Array<Service>, opts?: RunOptions) => Alepha;
|
|
1825
1902
|
//#endregion
|
|
1826
|
-
export { $
|
|
1903
|
+
export { $atom, $context, $env, $hook, $inject, $module, $use, AbstractClass, Alepha, AlephaError, AlsProvider, AppNotStartedError, Async, AsyncFn, AsyncLocalStorageData, Atom, AtomOptions, AtomStatic, 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, TAtomObject, 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, isDate, isDateTime, isDuration, isEmail, isFileLike, isTime, isTypeFile, isURL, isUUID, pageMetadataSchema, pageQuerySchema, pageSchema, run, t };
|
|
1827
1904
|
//# sourceMappingURL=index.d.ts.map
|