alepha 0.14.3 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -5
- package/dist/api/audits/index.d.ts +620 -811
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/files/index.d.ts +185 -377
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js +0 -1
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.d.ts +245 -435
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/notifications/index.d.ts +238 -429
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/parameters/index.d.ts +236 -427
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/users/index.browser.js +1 -2
- package/dist/api/users/index.browser.js.map +1 -1
- package/dist/api/users/index.d.ts +1010 -1196
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +178 -151
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts +17 -17
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/batch/index.d.ts +122 -122
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js +1 -2
- package/dist/batch/index.js.map +1 -1
- package/dist/bucket/index.d.ts +163 -163
- package/dist/bucket/index.d.ts.map +1 -1
- package/dist/cache/core/index.d.ts +46 -46
- package/dist/cache/core/index.d.ts.map +1 -1
- package/dist/cache/redis/index.d.ts.map +1 -1
- package/dist/cli/index.d.ts +384 -285
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +1113 -623
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +299 -300
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +13 -9
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +445 -103
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +733 -625
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +446 -103
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +445 -103
- package/dist/core/index.native.js.map +1 -1
- package/dist/datetime/index.d.ts +44 -44
- package/dist/datetime/index.d.ts.map +1 -1
- package/dist/datetime/index.js +4 -4
- package/dist/datetime/index.js.map +1 -1
- package/dist/email/index.d.ts +97 -50
- package/dist/email/index.d.ts.map +1 -1
- package/dist/email/index.js +129 -33
- package/dist/email/index.js.map +1 -1
- package/dist/fake/index.d.ts +7981 -14
- package/dist/fake/index.d.ts.map +1 -1
- package/dist/file/index.d.ts +523 -390
- package/dist/file/index.d.ts.map +1 -1
- package/dist/file/index.js +253 -1
- package/dist/file/index.js.map +1 -1
- package/dist/lock/core/index.d.ts +208 -208
- package/dist/lock/core/index.d.ts.map +1 -1
- package/dist/lock/redis/index.d.ts.map +1 -1
- package/dist/logger/index.d.ts +25 -26
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +12 -2
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.d.ts +197 -197
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/chunk-DtkW-qnP.js +38 -0
- package/dist/orm/index.browser.js.map +1 -1
- package/dist/orm/index.bun.js +2814 -0
- package/dist/orm/index.bun.js.map +1 -0
- package/dist/orm/index.d.ts +1228 -1216
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +2041 -1967
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/core/index.d.ts +248 -248
- package/dist/queue/core/index.d.ts.map +1 -1
- package/dist/queue/redis/index.d.ts.map +1 -1
- package/dist/redis/index.bun.js +285 -0
- package/dist/redis/index.bun.js.map +1 -0
- package/dist/redis/index.d.ts +118 -136
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js +18 -38
- package/dist/redis/index.js.map +1 -1
- package/dist/retry/index.d.ts +69 -69
- package/dist/retry/index.d.ts.map +1 -1
- package/dist/router/index.d.ts +6 -6
- package/dist/router/index.d.ts.map +1 -1
- package/dist/scheduler/index.d.ts +25 -25
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/security/index.browser.js +5 -1
- package/dist/security/index.browser.js.map +1 -1
- package/dist/security/index.d.ts +417 -254
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +386 -86
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +110 -110
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +20 -20
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cache/index.d.ts +62 -47
- package/dist/server/cache/index.d.ts.map +1 -1
- package/dist/server/cache/index.js +56 -3
- package/dist/server/cache/index.js.map +1 -1
- package/dist/server/compress/index.d.ts +6 -0
- package/dist/server/compress/index.d.ts.map +1 -1
- package/dist/server/compress/index.js +36 -1
- package/dist/server/compress/index.js.map +1 -1
- package/dist/server/cookies/index.d.ts +6 -6
- package/dist/server/cookies/index.d.ts.map +1 -1
- package/dist/server/cookies/index.js +3 -3
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/server/core/index.browser.js +2 -2
- package/dist/server/core/index.browser.js.map +1 -1
- package/dist/server/core/index.d.ts +242 -150
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +294 -125
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/cors/index.d.ts +11 -12
- package/dist/server/cors/index.d.ts.map +1 -1
- package/dist/server/health/index.d.ts +0 -1
- package/dist/server/health/index.d.ts.map +1 -1
- package/dist/server/helmet/index.d.ts +2 -2
- package/dist/server/helmet/index.d.ts.map +1 -1
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.d.ts +123 -124
- package/dist/server/links/index.d.ts.map +1 -1
- package/dist/server/links/index.js +1 -2
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/metrics/index.d.ts.map +1 -1
- package/dist/server/multipart/index.d.ts +6 -6
- package/dist/server/multipart/index.d.ts.map +1 -1
- package/dist/server/proxy/index.d.ts +102 -103
- package/dist/server/proxy/index.d.ts.map +1 -1
- package/dist/server/rate-limit/index.d.ts +16 -16
- package/dist/server/rate-limit/index.d.ts.map +1 -1
- package/dist/server/static/index.d.ts +44 -44
- package/dist/server/static/index.d.ts.map +1 -1
- package/dist/server/static/index.js +4 -0
- package/dist/server/static/index.js.map +1 -1
- package/dist/server/swagger/index.d.ts +48 -49
- package/dist/server/swagger/index.d.ts.map +1 -1
- package/dist/server/swagger/index.js +3 -5
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/sms/index.d.ts +13 -11
- package/dist/sms/index.d.ts.map +1 -1
- package/dist/sms/index.js +7 -7
- package/dist/sms/index.js.map +1 -1
- package/dist/thread/index.d.ts +71 -72
- package/dist/thread/index.d.ts.map +1 -1
- package/dist/topic/core/index.d.ts +318 -318
- package/dist/topic/core/index.d.ts.map +1 -1
- package/dist/topic/redis/index.d.ts +6 -6
- package/dist/topic/redis/index.d.ts.map +1 -1
- package/dist/vite/index.d.ts +5805 -249
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +599 -513
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js +6 -6
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.d.ts +247 -247
- package/dist/websocket/index.d.ts.map +1 -1
- package/dist/websocket/index.js +6 -6
- package/dist/websocket/index.js.map +1 -1
- package/package.json +9 -14
- package/src/api/files/controllers/AdminFileStatsController.ts +0 -1
- package/src/api/users/atoms/realmAuthSettingsAtom.ts +5 -0
- package/src/api/users/controllers/{UserRealmController.ts → RealmController.ts} +11 -11
- package/src/api/users/entities/users.ts +1 -1
- package/src/api/users/index.ts +8 -8
- package/src/api/users/primitives/{$userRealm.ts → $realm.ts} +17 -19
- package/src/api/users/providers/{UserRealmProvider.ts → RealmProvider.ts} +26 -30
- package/src/api/users/schemas/{userRealmConfigSchema.ts → realmConfigSchema.ts} +2 -2
- package/src/api/users/services/CredentialService.ts +7 -7
- package/src/api/users/services/IdentityService.ts +4 -4
- package/src/api/users/services/RegistrationService.spec.ts +25 -27
- package/src/api/users/services/RegistrationService.ts +38 -27
- package/src/api/users/services/SessionCrudService.ts +3 -3
- package/src/api/users/services/SessionService.spec.ts +3 -3
- package/src/api/users/services/SessionService.ts +28 -9
- package/src/api/users/services/UserService.ts +7 -7
- package/src/batch/providers/BatchProvider.ts +1 -2
- package/src/cli/apps/AlephaCli.ts +0 -2
- package/src/cli/apps/AlephaPackageBuilderCli.ts +38 -19
- package/src/cli/assets/apiHelloControllerTs.ts +18 -0
- package/src/cli/assets/apiIndexTs.ts +16 -0
- package/src/cli/assets/claudeMd.ts +303 -0
- package/src/cli/assets/mainBrowserTs.ts +2 -2
- package/src/cli/assets/mainServerTs.ts +24 -0
- package/src/cli/assets/webAppRouterTs.ts +15 -0
- package/src/cli/assets/webHelloComponentTsx.ts +16 -0
- package/src/cli/assets/webIndexTs.ts +16 -0
- package/src/cli/atoms/buildOptions.ts +88 -0
- package/src/cli/commands/build.ts +70 -87
- package/src/cli/commands/db.ts +21 -22
- package/src/cli/commands/deploy.ts +17 -5
- package/src/cli/commands/dev.ts +22 -14
- package/src/cli/commands/format.ts +8 -2
- package/src/cli/commands/gen/env.ts +53 -0
- package/src/cli/commands/gen/openapi.ts +1 -1
- package/src/cli/commands/gen/resource.ts +15 -0
- package/src/cli/commands/gen.ts +7 -1
- package/src/cli/commands/init.ts +74 -30
- package/src/cli/commands/lint.ts +8 -2
- package/src/cli/commands/test.ts +8 -3
- package/src/cli/commands/typecheck.ts +5 -1
- package/src/cli/commands/verify.ts +5 -3
- package/src/cli/defineConfig.ts +49 -7
- package/src/cli/index.ts +0 -1
- package/src/cli/services/AlephaCliUtils.ts +39 -589
- package/src/cli/services/PackageManagerUtils.ts +301 -0
- package/src/cli/services/ProjectScaffolder.ts +306 -0
- package/src/command/helpers/Runner.spec.ts +2 -2
- package/src/command/helpers/Runner.ts +16 -4
- package/src/command/primitives/$command.ts +0 -6
- package/src/command/providers/CliProvider.ts +1 -3
- package/src/core/Alepha.ts +42 -0
- package/src/core/__tests__/Alepha-graph.spec.ts +4 -0
- package/src/core/index.shared.ts +1 -0
- package/src/core/index.ts +2 -0
- package/src/core/primitives/$hook.ts +6 -2
- package/src/core/primitives/$module.spec.ts +4 -0
- package/src/core/providers/AlsProvider.ts +1 -1
- package/src/core/providers/CodecManager.spec.ts +12 -6
- package/src/core/providers/CodecManager.ts +26 -6
- package/src/core/providers/EventManager.ts +169 -13
- package/src/core/providers/KeylessJsonSchemaCodec.spec.ts +621 -0
- package/src/core/providers/KeylessJsonSchemaCodec.ts +407 -0
- package/src/core/providers/StateManager.spec.ts +27 -16
- package/src/email/providers/LocalEmailProvider.spec.ts +111 -87
- package/src/email/providers/LocalEmailProvider.ts +52 -15
- package/src/email/providers/NodemailerEmailProvider.ts +167 -56
- package/src/file/errors/FileError.ts +7 -0
- package/src/file/index.ts +9 -1
- package/src/file/providers/MemoryFileSystemProvider.ts +393 -0
- package/src/logger/index.ts +15 -3
- package/src/mcp/transports/StdioMcpTransport.ts +1 -1
- package/src/orm/index.browser.ts +1 -19
- package/src/orm/index.bun.ts +77 -0
- package/src/orm/index.shared-server.ts +22 -0
- package/src/orm/index.shared.ts +15 -0
- package/src/orm/index.ts +13 -39
- package/src/orm/providers/drivers/BunPostgresProvider.ts +3 -5
- package/src/orm/providers/drivers/BunSqliteProvider.ts +1 -1
- package/src/orm/providers/drivers/CloudflareD1Provider.ts +4 -0
- package/src/orm/providers/drivers/DatabaseProvider.ts +4 -0
- package/src/orm/providers/drivers/PglitePostgresProvider.ts +4 -0
- package/src/orm/services/Repository.ts +8 -0
- package/src/queue/core/providers/WorkerProvider.spec.ts +48 -32
- package/src/redis/index.bun.ts +35 -0
- package/src/redis/providers/BunRedisProvider.ts +12 -43
- package/src/redis/providers/BunRedisSubscriberProvider.ts +2 -3
- package/src/redis/providers/NodeRedisProvider.ts +16 -34
- package/src/{server/security → security}/__tests__/BasicAuth.spec.ts +11 -11
- package/src/{server/security → security}/__tests__/ServerSecurityProvider-realm.spec.ts +21 -16
- package/src/{server/security/providers → security/__tests__}/ServerSecurityProvider.spec.ts +5 -5
- package/src/security/index.browser.ts +5 -0
- package/src/security/index.ts +90 -7
- package/src/security/primitives/{$realm.spec.ts → $issuer.spec.ts} +11 -11
- package/src/security/primitives/{$realm.ts → $issuer.ts} +20 -17
- package/src/security/primitives/$role.ts +5 -5
- package/src/security/primitives/$serviceAccount.spec.ts +5 -5
- package/src/security/primitives/$serviceAccount.ts +3 -3
- package/src/{server/security → security}/providers/ServerSecurityProvider.ts +5 -7
- package/src/server/auth/primitives/$auth.ts +10 -10
- package/src/server/auth/primitives/$authCredentials.ts +3 -3
- package/src/server/auth/primitives/$authGithub.ts +3 -3
- package/src/server/auth/primitives/$authGoogle.ts +3 -3
- package/src/server/auth/providers/ServerAuthProvider.ts +13 -13
- package/src/server/cache/providers/ServerCacheProvider.spec.ts +183 -0
- package/src/server/cache/providers/ServerCacheProvider.ts +95 -10
- package/src/server/compress/providers/ServerCompressProvider.ts +61 -2
- package/src/server/cookies/providers/ServerCookiesProvider.ts +3 -3
- package/src/server/core/helpers/ServerReply.ts +2 -2
- package/src/server/core/providers/NodeHttpServerProvider.ts +25 -6
- package/src/server/core/providers/ServerBodyParserProvider.ts +19 -23
- package/src/server/core/providers/ServerLoggerProvider.ts +23 -19
- package/src/server/core/providers/ServerProvider.ts +155 -22
- package/src/server/core/providers/ServerRouterProvider.ts +259 -115
- package/src/server/core/providers/ServerTimingProvider.ts +2 -2
- package/src/server/links/index.ts +1 -1
- package/src/server/links/providers/LinkProvider.ts +1 -1
- package/src/server/static/providers/ServerStaticProvider.ts +10 -0
- package/src/server/swagger/index.ts +1 -1
- package/src/server/swagger/providers/ServerSwaggerProvider.ts +5 -8
- package/src/sms/providers/LocalSmsProvider.spec.ts +153 -111
- package/src/sms/providers/LocalSmsProvider.ts +8 -7
- package/src/vite/helpers/boot.ts +28 -17
- package/src/vite/helpers/importViteReact.ts +13 -0
- package/src/vite/index.ts +1 -21
- package/src/vite/plugins/viteAlephaDev.ts +16 -1
- package/src/vite/plugins/viteAlephaSsrPreload.ts +222 -0
- package/src/vite/tasks/buildClient.ts +11 -0
- package/src/vite/tasks/buildServer.ts +59 -4
- package/src/vite/tasks/devServer.ts +71 -0
- package/src/vite/tasks/generateCloudflare.ts +7 -0
- package/src/vite/tasks/index.ts +2 -1
- package/dist/server/security/index.browser.js +0 -13
- package/dist/server/security/index.browser.js.map +0 -1
- package/dist/server/security/index.d.ts +0 -173
- package/dist/server/security/index.d.ts.map +0 -1
- package/dist/server/security/index.js +0 -311
- package/dist/server/security/index.js.map +0 -1
- package/src/cli/assets/appRouterTs.ts +0 -9
- package/src/cli/assets/mainTs.ts +0 -13
- package/src/cli/assets/viteConfigTs.ts +0 -14
- package/src/cli/commands/run.ts +0 -24
- package/src/server/security/index.browser.ts +0 -10
- package/src/server/security/index.ts +0 -94
- package/src/vite/plugins/viteAlepha.ts +0 -37
- package/src/vite/plugins/viteAlephaBuild.ts +0 -281
- /package/src/{server/security → security}/primitives/$basicAuth.ts +0 -0
- /package/src/{server/security → security}/providers/ServerBasicAuthProvider.ts +0 -0
package/dist/core/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import { Validator } from "typebox/compile";
|
|
3
2
|
import * as typebox0 from "typebox";
|
|
4
3
|
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, Type } from "typebox";
|
|
5
4
|
import Format from "typebox/format";
|
|
6
5
|
import * as Value from "typebox/value";
|
|
6
|
+
import { Validator } from "typebox/compile";
|
|
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";
|
|
@@ -45,19 +45,19 @@ type AbstractClass<T extends object = any> = abstract new (...args: any[]) => T;
|
|
|
45
45
|
*/
|
|
46
46
|
interface ServiceSubstitution<T extends object = any> {
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
* Every time someone asks for this class, it will be provided with the 'use' class.
|
|
49
|
+
*/
|
|
50
50
|
provide: Service<T>;
|
|
51
51
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
* Service to use instead of the 'provide' service.
|
|
53
|
+
*
|
|
54
|
+
* Syntax is inspired by Angular's DI system.
|
|
55
|
+
*/
|
|
56
56
|
use: Service<T>;
|
|
57
57
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
* If true, if the service already exists -> just ignore the substitution and do not throw an error.
|
|
59
|
+
* Mostly used for plugins to enforce a substitution without throwing an error.
|
|
60
|
+
*/
|
|
61
61
|
optional?: boolean;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
@@ -90,8 +90,8 @@ declare abstract class Primitive<T extends object = {}> {
|
|
|
90
90
|
readonly config: PrimitiveConfig;
|
|
91
91
|
constructor(args: PrimitiveArgs<T>);
|
|
92
92
|
/**
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
* Called automatically by Alepha after the primitive is created.
|
|
94
|
+
*/
|
|
95
95
|
protected onInit(): void;
|
|
96
96
|
}
|
|
97
97
|
type PrimitiveFactory<TPrimitive extends Primitive = Primitive> = {
|
|
@@ -155,55 +155,55 @@ interface TypeBoxErrorParams {
|
|
|
155
155
|
//#region ../../src/core/helpers/FileLike.d.ts
|
|
156
156
|
interface FileLike {
|
|
157
157
|
/**
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
* Filename.
|
|
159
|
+
* @default "file"
|
|
160
|
+
*/
|
|
161
161
|
name: string;
|
|
162
162
|
/**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
* Mandatory MIME type of the file.
|
|
164
|
+
* @default "application/octet-stream"
|
|
165
|
+
*/
|
|
166
166
|
type: string;
|
|
167
167
|
/**
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
168
|
+
* Size of the file in bytes.
|
|
169
|
+
*
|
|
170
|
+
* Always 0 for streams, as the size is not known until the stream is fully read.
|
|
171
|
+
*
|
|
172
|
+
* @default 0
|
|
173
|
+
*/
|
|
174
174
|
size: number;
|
|
175
175
|
/**
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
176
|
+
* Last modified timestamp in milliseconds since epoch.
|
|
177
|
+
*
|
|
178
|
+
* Always the current timestamp for streams, as the last modified time is not known.
|
|
179
|
+
* We use this field to ensure compatibility with File API.
|
|
180
|
+
*
|
|
181
|
+
* @default Date.now()
|
|
182
|
+
*/
|
|
183
183
|
lastModified: number;
|
|
184
184
|
/**
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
* Returns a ReadableStream or Node.js Readable stream of the file content.
|
|
186
|
+
*
|
|
187
|
+
* For streams, this is the original stream.
|
|
188
|
+
*/
|
|
189
189
|
stream(): StreamLike;
|
|
190
190
|
/**
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
* Returns the file content as an ArrayBuffer.
|
|
192
|
+
*
|
|
193
|
+
* For streams, this reads the entire stream into memory.
|
|
194
|
+
*/
|
|
195
195
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
196
196
|
/**
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
197
|
+
* Returns the file content as a string.
|
|
198
|
+
*
|
|
199
|
+
* For streams, this reads the entire stream into memory and converts it to a string.
|
|
200
|
+
*/
|
|
201
201
|
text(): Promise<string>;
|
|
202
202
|
/**
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
* Optional file path, if the file is stored on disk.
|
|
204
|
+
*
|
|
205
|
+
* This is not from the File API, but rather a custom field to indicate where the file is stored.
|
|
206
|
+
*/
|
|
207
207
|
filepath?: string;
|
|
208
208
|
}
|
|
209
209
|
/**
|
|
@@ -259,47 +259,47 @@ declare class TypeProvider {
|
|
|
259
259
|
static setLocale(locale: string): void;
|
|
260
260
|
static isValidBigInt(value: string | number): boolean;
|
|
261
261
|
/**
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
262
|
+
* Default maximum length for strings.
|
|
263
|
+
*
|
|
264
|
+
* It can be set to a larger value:
|
|
265
|
+
* ```ts
|
|
266
|
+
* TypeProvider.DEFAULT_STRING_MAX_LENGTH = 1000000;
|
|
267
|
+
* TypeProvider.DEFAULT_STRING_MAX_LENGTH = undefined; // no limit (not recommended)
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
270
|
static DEFAULT_STRING_MAX_LENGTH: number | undefined;
|
|
271
271
|
/**
|
|
272
|
-
|
|
273
|
-
|
|
272
|
+
* Maximum length for short strings, such as names or titles.
|
|
273
|
+
*/
|
|
274
274
|
static DEFAULT_SHORT_STRING_MAX_LENGTH: number | undefined;
|
|
275
275
|
/**
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
276
|
+
* Maximum length for long strings, such as descriptions or comments.
|
|
277
|
+
* It can be overridden in the string options.
|
|
278
|
+
*
|
|
279
|
+
* It can be set to a larger value:
|
|
280
|
+
* ```ts
|
|
281
|
+
* TypeProvider.DEFAULT_LONG_STRING_MAX_LENGTH = 2048;
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
284
|
static DEFAULT_LONG_STRING_MAX_LENGTH: number | undefined;
|
|
285
285
|
/**
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
286
|
+
* Maximum length for rich strings, such as HTML or Markdown.
|
|
287
|
+
* This is a large value to accommodate rich text content.
|
|
288
|
+
* > It's also the maximum length of PG's TEXT type.
|
|
289
|
+
*
|
|
290
|
+
* It can be overridden in the string options.
|
|
291
|
+
*
|
|
292
|
+
* It can be set to a larger value:
|
|
293
|
+
* ```ts
|
|
294
|
+
* TypeProvider.DEFAULT_RICH_STRING_MAX_LENGTH = 1000000;
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
297
|
static DEFAULT_RICH_STRING_MAX_LENGTH: number | undefined;
|
|
298
298
|
/**
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
299
|
+
* Maximum number of items in an array.
|
|
300
|
+
* This is a default value to prevent excessive memory usage.
|
|
301
|
+
* It can be overridden in the array options.
|
|
302
|
+
*/
|
|
303
303
|
static DEFAULT_ARRAY_MAX_ITEMS: number;
|
|
304
304
|
raw: typeof Type;
|
|
305
305
|
any: typeof Type.Any;
|
|
@@ -312,16 +312,16 @@ declare class TypeProvider {
|
|
|
312
312
|
const: typeof Type.Literal;
|
|
313
313
|
options: typeof Type.Options;
|
|
314
314
|
/**
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
315
|
+
* Type guards to check the type of schema.
|
|
316
|
+
* This is not a runtime type check, but a compile-time type guard.
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```ts
|
|
320
|
+
* if (t.schema.isString(schema)) {
|
|
321
|
+
* // schema is TString
|
|
322
|
+
* }
|
|
323
|
+
* ```
|
|
324
|
+
*/
|
|
325
325
|
readonly schema: TypeGuard;
|
|
326
326
|
extend<T extends TSchema$1[], U extends TProperties$1>(schema: [...T], properties: U, options?: TSchemaOptions): TInterface<T, U>;
|
|
327
327
|
extend<T extends TObject$1, U extends TProperties$1>(schema: T, properties: U, options?: TSchemaOptions): TInterface<[T], U>;
|
|
@@ -329,76 +329,76 @@ declare class TypeProvider {
|
|
|
329
329
|
omit<T extends TObject$1, Indexer extends PropertyKey[]>(schema: T, keys: [...Indexer], options?: TObjectOptions$1): TOmit<T, TKeysToIndexer$1<Indexer>>;
|
|
330
330
|
partial<T extends TSchema$1>(schema: T, options?: TSchemaOptions): TPartial<T>;
|
|
331
331
|
/**
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
332
|
+
* Create a schema for an object.
|
|
333
|
+
* By default, additional properties are not allowed.
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```ts
|
|
337
|
+
* const userSchema = t.object({
|
|
338
|
+
* id: t.integer(),
|
|
339
|
+
* name: t.string(),
|
|
340
|
+
* });
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
343
|
object<T extends TProperties$1>(properties: T, options?: TObjectOptions$1): TObject$1<T>;
|
|
344
344
|
/**
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
345
|
+
* Create a schema for an array.
|
|
346
|
+
* By default, the maximum number of items is limited to prevent excessive memory usage.
|
|
347
|
+
*
|
|
348
|
+
* @see TypeProvider.DEFAULT_ARRAY_MAX_ITEMS
|
|
349
|
+
*/
|
|
350
350
|
array<T extends TSchema$1>(schema: T, options?: TArrayOptions): TArray$1<T>;
|
|
351
351
|
/**
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
352
|
+
* Create a schema for a string.
|
|
353
|
+
* For db or input fields, consider using `t.text()` instead, which has length limits.
|
|
354
|
+
*
|
|
355
|
+
* If you need a string with specific format (e.g. email, uuid), consider using the corresponding method (e.g. `t.email()`, `t.uuid()`).
|
|
356
|
+
*/
|
|
357
357
|
string(options?: TStringOptions$1): TString$1;
|
|
358
358
|
/**
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
359
|
+
* Create a schema for a string with length limits.
|
|
360
|
+
* For internal strings without length limits, consider using `t.string()` instead.
|
|
361
|
+
*
|
|
362
|
+
* Default size is "regular", which has a max length of 255 characters.
|
|
363
|
+
*/
|
|
364
364
|
text(options?: TTextOptions): TString$1;
|
|
365
365
|
/**
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
366
|
+
* Create a schema for a JSON object.
|
|
367
|
+
* This is a record with string keys and any values.
|
|
368
|
+
*/
|
|
369
369
|
json<T = any>(options?: TSchemaOptions): TRecord$1<string, TAny$1>;
|
|
370
370
|
/**
|
|
371
|
-
|
|
372
|
-
|
|
371
|
+
* Create a schema for a boolean.
|
|
372
|
+
*/
|
|
373
373
|
boolean(options?: TSchemaOptions): TBoolean$1;
|
|
374
374
|
/**
|
|
375
|
-
|
|
376
|
-
|
|
375
|
+
* Create a schema for a number.
|
|
376
|
+
*/
|
|
377
377
|
number(options?: TNumberOptions$1): TNumber$1;
|
|
378
378
|
/**
|
|
379
|
-
|
|
380
|
-
|
|
379
|
+
* Create a schema for an integer.
|
|
380
|
+
*/
|
|
381
381
|
integer(options?: TNumberOptions$1): TInteger$1;
|
|
382
382
|
int32(options?: TNumberOptions$1): TInteger$1;
|
|
383
383
|
/**
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
384
|
+
* Mimic a signed 64-bit integer.
|
|
385
|
+
*
|
|
386
|
+
* This is NOT a true int64, as JavaScript cannot represent all int64 values.
|
|
387
|
+
* It is a number that is an integer and between -9007199254740991 and 9007199254740991.
|
|
388
|
+
* Use `t.bigint()` for true int64 values represented as strings.
|
|
389
|
+
*/
|
|
390
390
|
int64(options?: TNumberOptions$1): TNumber$1;
|
|
391
391
|
/**
|
|
392
|
-
|
|
393
|
-
|
|
392
|
+
* Make a schema optional.
|
|
393
|
+
*/
|
|
394
394
|
optional<T extends TSchema$1>(schema: T): TOptionalAdd$1<T>;
|
|
395
395
|
/**
|
|
396
|
-
|
|
397
|
-
|
|
396
|
+
* Make a schema nullable.
|
|
397
|
+
*/
|
|
398
398
|
nullable<T extends TSchema$1>(schema: T, options?: TObjectOptions$1): TUnion$1<[TNull$1, T]>;
|
|
399
399
|
/**
|
|
400
|
-
|
|
401
|
-
|
|
400
|
+
* Create a schema that maps all properties of an object schema to nullable.
|
|
401
|
+
*/
|
|
402
402
|
nullify: <T extends TSchema$1>(schema: T, options?: TObjectOptions$1) => typebox0.TMappedInstantiate<{}, {
|
|
403
403
|
callstack: [];
|
|
404
404
|
}, Type.TIdentifier<"K">, typebox0.TKeyOfInstantiate<{}, {
|
|
@@ -407,65 +407,65 @@ declare class TypeProvider {
|
|
|
407
407
|
callstack: [];
|
|
408
408
|
}, T, Type.TRef<"K">>, TNull$1]>>;
|
|
409
409
|
/**
|
|
410
|
-
|
|
411
|
-
|
|
410
|
+
* Create a schema for a string enum.
|
|
411
|
+
*/
|
|
412
412
|
enum<T extends string[]>(values: [...T], options?: TTextOptions): TUnsafe$1<T[number]>;
|
|
413
413
|
/**
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
414
|
+
* Create a schema for a bigint represented as a string.
|
|
415
|
+
* This is a string that validates bigint format (e.g. "123456789").
|
|
416
|
+
*/
|
|
417
417
|
bigint(options?: TStringOptions$1): TString$1;
|
|
418
418
|
/**
|
|
419
|
-
|
|
420
|
-
|
|
419
|
+
* Create a schema for a URL represented as a string.
|
|
420
|
+
*/
|
|
421
421
|
url(options?: TStringOptions$1): TString$1;
|
|
422
422
|
/**
|
|
423
|
-
|
|
424
|
-
|
|
423
|
+
* Create a schema for binary data represented as a base64 string.
|
|
424
|
+
*/
|
|
425
425
|
binary(options: TStringOptions$1): TString$1;
|
|
426
426
|
/**
|
|
427
|
-
|
|
428
|
-
|
|
427
|
+
* Create a schema for uuid.
|
|
428
|
+
*/
|
|
429
429
|
uuid(options?: TStringOptions$1): TString$1;
|
|
430
430
|
/**
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
431
|
+
* Create a schema for a file-like object.
|
|
432
|
+
*
|
|
433
|
+
* File like mimics the File API in browsers, but is adapted to work in Node.js as well.
|
|
434
|
+
*
|
|
435
|
+
* Implementation of file-like objects is handled by "alepha/file" package.
|
|
436
|
+
*/
|
|
437
437
|
file(options?: {
|
|
438
438
|
maxSize?: number;
|
|
439
439
|
}): TFile;
|
|
440
440
|
/**
|
|
441
|
-
|
|
442
|
-
|
|
441
|
+
* @experimental
|
|
442
|
+
*/
|
|
443
443
|
stream(): TStream;
|
|
444
444
|
email(options?: TStringOptions$1): TString$1;
|
|
445
445
|
e164(options?: TStringOptions$1): TString$1;
|
|
446
446
|
bcp47(options?: TStringOptions$1): TString$1;
|
|
447
447
|
/**
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
448
|
+
* Create a schema for short text, such as names or titles.
|
|
449
|
+
* Default max length is 64 characters.
|
|
450
|
+
*/
|
|
451
451
|
shortText(options?: TStringOptions$1): TString$1;
|
|
452
452
|
/**
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
453
|
+
* Create a schema for long text, such as descriptions or comments.
|
|
454
|
+
* Default max length is 1024 characters.
|
|
455
|
+
*/
|
|
456
456
|
longText(options?: TStringOptions$1): TString$1;
|
|
457
457
|
/**
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
458
|
+
* Create a schema for rich text, such as HTML or Markdown.
|
|
459
|
+
* Default max length is 65535 characters.
|
|
460
|
+
*/
|
|
461
461
|
richText(options?: TStringOptions$1): TString$1;
|
|
462
462
|
/**
|
|
463
|
-
|
|
464
|
-
|
|
463
|
+
* Create a schema for a string enum e.g. LIKE_THIS.
|
|
464
|
+
*/
|
|
465
465
|
snakeCase: (options?: TStringOptions$1) => TString$1;
|
|
466
466
|
/**
|
|
467
|
-
|
|
468
|
-
|
|
467
|
+
* Create a schema for an object with a value and label.
|
|
468
|
+
*/
|
|
469
469
|
valueLabel: (options?: TObjectOptions$1) => TObject$1<{
|
|
470
470
|
value: TString$1;
|
|
471
471
|
label: TString$1;
|
|
@@ -479,29 +479,29 @@ declare class TypeProvider {
|
|
|
479
479
|
type TextLength = "short" | "regular" | "long" | "rich";
|
|
480
480
|
interface TTextOptions extends TStringOptions$1 {
|
|
481
481
|
/**
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
482
|
+
* Predefined size of the text.
|
|
483
|
+
*
|
|
484
|
+
* - `short` - short text, such as names or titles. Default max length is 64 characters.
|
|
485
|
+
* - `regular` - regular text, such as single-line input. Default max length is 255 characters.
|
|
486
|
+
* - `long` - long text, such as descriptions or comments. Default max length is 1024 characters.
|
|
487
|
+
* - `rich` - rich text, such as HTML or Markdown. Default max length is 65535 characters.
|
|
488
|
+
*
|
|
489
|
+
* You can override the default max length by specifying `maxLength` in the options.
|
|
490
|
+
*
|
|
491
|
+
* @default "regular"
|
|
492
|
+
*/
|
|
493
493
|
size?: TextLength;
|
|
494
494
|
/**
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
495
|
+
* Trim whitespace from both ends of the string.
|
|
496
|
+
*
|
|
497
|
+
* @default true
|
|
498
|
+
*/
|
|
499
499
|
trim?: boolean;
|
|
500
500
|
/**
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
501
|
+
* Convert the string to lowercase.
|
|
502
|
+
*
|
|
503
|
+
* @default false
|
|
504
|
+
*/
|
|
505
505
|
lowercase?: boolean;
|
|
506
506
|
}
|
|
507
507
|
declare const t: TypeProvider;
|
|
@@ -577,25 +577,25 @@ declare const $inject: <T extends object>(type: Service<T>, opts?: InjectOptions
|
|
|
577
577
|
declare class InjectPrimitive extends Primitive {}
|
|
578
578
|
interface InjectOptions<T extends object = any> {
|
|
579
579
|
/**
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
580
|
+
* - 'transient' → Always a new instance on every inject. Zero caching.
|
|
581
|
+
* - 'singleton' → One instance per Alepha runtime (per-thread). Never disposed until Alepha shuts down. (default)
|
|
582
|
+
* - 'scoped' → One instance per AsyncLocalStorage context.
|
|
583
|
+
* - A new scope is created when Alepha handles a request, a scheduled job, a queue worker task...
|
|
584
|
+
* - You can also start a manual scope via alepha.context.run(() => { ... }).
|
|
585
|
+
* - When the scope ends, the scoped registry is discarded.
|
|
586
|
+
*
|
|
587
|
+
* @default "singleton"
|
|
588
|
+
*/
|
|
589
589
|
lifetime?: "transient" | "singleton" | "scoped";
|
|
590
590
|
/**
|
|
591
|
-
|
|
592
|
-
|
|
591
|
+
* Constructor arguments to pass when creating a new instance.
|
|
592
|
+
*/
|
|
593
593
|
args?: ConstructorParameters<InstantiableClass<T>>;
|
|
594
594
|
/**
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
595
|
+
* Parent that requested the instance.
|
|
596
|
+
*
|
|
597
|
+
* @internal
|
|
598
|
+
*/
|
|
599
599
|
parent?: Service | null;
|
|
600
600
|
}
|
|
601
601
|
//#endregion
|
|
@@ -651,29 +651,29 @@ interface InjectOptions<T extends object = any> {
|
|
|
651
651
|
declare const $module: <T extends object = {}>(options: ModulePrimitiveOptions) => Service<Module>;
|
|
652
652
|
interface ModulePrimitiveOptions {
|
|
653
653
|
/**
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
654
|
+
* Name of the module.
|
|
655
|
+
*
|
|
656
|
+
* It should be in the format of `project.module.submodule`.
|
|
657
|
+
*/
|
|
658
658
|
name: string;
|
|
659
659
|
/**
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
660
|
+
* List all services related to this module.
|
|
661
|
+
*
|
|
662
|
+
* If you don't declare 'register' function, all services will be registered automatically.
|
|
663
|
+
* If you declare 'register' function, you must handle the registration of ALL services manually.
|
|
664
|
+
*/
|
|
665
665
|
services?: Array<Service>;
|
|
666
666
|
/**
|
|
667
|
-
|
|
668
|
-
|
|
667
|
+
* List of $primitives to register in the module.
|
|
668
|
+
*/
|
|
669
669
|
primitives?: Array<PrimitiveFactoryLike>;
|
|
670
670
|
/**
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
671
|
+
* By default, module will register ALL services.
|
|
672
|
+
* You can override this behavior by providing a register function.
|
|
673
|
+
* It's useful when you want to register services conditionally or in a specific order.
|
|
674
|
+
*
|
|
675
|
+
* Again, if you declare 'register', you must handle the registration of ALL services manually.
|
|
676
|
+
*/
|
|
677
677
|
register?: (alepha: Alepha) => void;
|
|
678
678
|
}
|
|
679
679
|
/**
|
|
@@ -684,14 +684,14 @@ declare abstract class Module {
|
|
|
684
684
|
abstract register(alepha: Alepha): void;
|
|
685
685
|
static NAME_REGEX: RegExp;
|
|
686
686
|
/**
|
|
687
|
-
|
|
688
|
-
|
|
687
|
+
* Check if a Service is a Module.
|
|
688
|
+
*/
|
|
689
689
|
static is(ctor: Service): boolean;
|
|
690
690
|
/**
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
691
|
+
* Get the Module of a Service.
|
|
692
|
+
*
|
|
693
|
+
* Returns undefined if the Service is not part of a Module.
|
|
694
|
+
*/
|
|
695
695
|
static of(ctor: Service): Service<Module> | undefined;
|
|
696
696
|
}
|
|
697
697
|
/**
|
|
@@ -728,16 +728,16 @@ declare class Json {
|
|
|
728
728
|
//#region ../../src/core/providers/SchemaCodec.d.ts
|
|
729
729
|
declare abstract class SchemaCodec {
|
|
730
730
|
/**
|
|
731
|
-
|
|
732
|
-
|
|
731
|
+
* Encode the value to a string format.
|
|
732
|
+
*/
|
|
733
733
|
abstract encodeToString<T extends TSchema>(schema: T, value: Static<T>): string;
|
|
734
734
|
/**
|
|
735
|
-
|
|
736
|
-
|
|
735
|
+
* Encode the value to a binary format.
|
|
736
|
+
*/
|
|
737
737
|
abstract encodeToBinary<T extends TSchema>(schema: T, value: Static<T>): Uint8Array;
|
|
738
738
|
/**
|
|
739
|
-
|
|
740
|
-
|
|
739
|
+
* Decode string, binary, or other formats to the schema type.
|
|
740
|
+
*/
|
|
741
741
|
abstract decode<T>(schema: TSchema, value: unknown): T;
|
|
742
742
|
}
|
|
743
743
|
//#endregion
|
|
@@ -751,6 +751,61 @@ declare class JsonSchemaCodec extends SchemaCodec {
|
|
|
751
751
|
decode<T>(schema: TSchema$1, value: unknown): T;
|
|
752
752
|
}
|
|
753
753
|
//#endregion
|
|
754
|
+
//#region ../../src/core/providers/KeylessJsonSchemaCodec.d.ts
|
|
755
|
+
interface KeylessCodec<T = any> {
|
|
756
|
+
encode: (value: T) => string;
|
|
757
|
+
decode: (str: string) => T;
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* KeylessJsonSchemaCodec provides schema-driven JSON encoding without keys.
|
|
761
|
+
*
|
|
762
|
+
* It uses the schema to determine field order, allowing the encoded output
|
|
763
|
+
* to be a simple JSON array instead of an object with keys.
|
|
764
|
+
*
|
|
765
|
+
* Performance characteristics:
|
|
766
|
+
* - Encode: 0.94-1.53x vs JSON.stringify (faster for complex objects)
|
|
767
|
+
* - Decode: 1.76-2.00x vs JSON.parse
|
|
768
|
+
* - Size: 50-56% smaller than JSON
|
|
769
|
+
*/
|
|
770
|
+
declare class KeylessJsonSchemaCodec extends SchemaCodec {
|
|
771
|
+
protected readonly cache: Map<TSchema$1, KeylessCodec<any>>;
|
|
772
|
+
protected readonly encoder: TextEncoder;
|
|
773
|
+
protected readonly decoder: TextDecoder;
|
|
774
|
+
protected varCounter: number;
|
|
775
|
+
/**
|
|
776
|
+
* Encode value to a keyless JSON string.
|
|
777
|
+
*/
|
|
778
|
+
encodeToString<T extends TSchema$1>(schema: T, value: Static<T>): string;
|
|
779
|
+
/**
|
|
780
|
+
* Encode value to binary (UTF-8 encoded keyless JSON).
|
|
781
|
+
*/
|
|
782
|
+
encodeToBinary<T extends TSchema$1>(schema: T, value: Static<T>): Uint8Array;
|
|
783
|
+
/**
|
|
784
|
+
* Decode keyless JSON string or binary to value.
|
|
785
|
+
*/
|
|
786
|
+
decode<T>(schema: TSchema$1, value: unknown): T;
|
|
787
|
+
/**
|
|
788
|
+
* Get a compiled codec for the given schema.
|
|
789
|
+
* Codecs are cached for reuse.
|
|
790
|
+
*/
|
|
791
|
+
protected getCodec<T>(schema: TSchema$1): KeylessCodec<T>;
|
|
792
|
+
protected nextVar(): string;
|
|
793
|
+
protected compile(schema: TSchema$1): KeylessCodec;
|
|
794
|
+
protected genEnc(schema: TSchema$1, ve: string): string;
|
|
795
|
+
protected genDec(schema: TSchema$1): {
|
|
796
|
+
code: string;
|
|
797
|
+
result: string;
|
|
798
|
+
};
|
|
799
|
+
protected genDecFromValue(schema: TSchema$1, expr: string): string;
|
|
800
|
+
protected isEnum(schema: TSchema$1): boolean;
|
|
801
|
+
protected isNullable(schema: TSchema$1): boolean;
|
|
802
|
+
protected unwrap(schema: TSchema$1): TSchema$1;
|
|
803
|
+
/**
|
|
804
|
+
* Reconstruct an object from a parsed array (for when input is already parsed).
|
|
805
|
+
*/
|
|
806
|
+
protected reconstructObject(schema: TSchema$1, arr: any[]): any;
|
|
807
|
+
}
|
|
808
|
+
//#endregion
|
|
754
809
|
//#region ../../src/core/primitives/$hook.d.ts
|
|
755
810
|
/**
|
|
756
811
|
* Registers a new hook.
|
|
@@ -797,24 +852,24 @@ declare const $hook: {
|
|
|
797
852
|
};
|
|
798
853
|
interface HookOptions<T extends keyof Hooks> {
|
|
799
854
|
/**
|
|
800
|
-
|
|
801
|
-
|
|
855
|
+
* The name of the hook. "configure", "start", "ready", "stop", ...
|
|
856
|
+
*/
|
|
802
857
|
on: T;
|
|
803
858
|
/**
|
|
804
|
-
|
|
805
|
-
|
|
859
|
+
* The handler to run when the hook is triggered.
|
|
860
|
+
*/
|
|
806
861
|
handler: (args: Hooks[T]) => Async<any>;
|
|
807
862
|
/**
|
|
808
|
-
|
|
809
|
-
|
|
863
|
+
* Force the hook to run first or last on the list of hooks.
|
|
864
|
+
*/
|
|
810
865
|
priority?: "first" | "last";
|
|
811
866
|
/**
|
|
812
|
-
|
|
813
|
-
|
|
867
|
+
* Empty placeholder, not implemented yet. :-)
|
|
868
|
+
*/
|
|
814
869
|
before?: object | Array<object>;
|
|
815
870
|
/**
|
|
816
|
-
|
|
817
|
-
|
|
871
|
+
* Empty placeholder, not implemented yet. :-)
|
|
872
|
+
*/
|
|
818
873
|
after?: object | Array<object>;
|
|
819
874
|
}
|
|
820
875
|
declare class HookPrimitive<T extends keyof Hooks> extends Primitive<HookOptions<T>> {
|
|
@@ -827,22 +882,22 @@ declare class SchemaValidator {
|
|
|
827
882
|
protected cache: Map<TSchema$1, Validator<typebox0.TProperties, TSchema$1, unknown, unknown>>;
|
|
828
883
|
protected useEval: boolean;
|
|
829
884
|
/**
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
885
|
+
* Validate the value against the provided schema.
|
|
886
|
+
*
|
|
887
|
+
* Validation create a new value by applying some preprocessing. (e.g., trimming text)
|
|
888
|
+
*/
|
|
834
889
|
validate<T extends TSchema$1>(schema: T, value: unknown, options?: ValidateOptions): Static<T>;
|
|
835
890
|
protected getValidator<T extends TSchema$1>(schema: T): Validator<{}, T>;
|
|
836
891
|
/**
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
892
|
+
* Preprocess the value based on the schema before validation.
|
|
893
|
+
*
|
|
894
|
+
* - If the value is `null` and the schema does not allow `null`, it converts it to `undefined`.
|
|
895
|
+
* - If the value is a string and the schema has a `~options.trim` flag, it trims whitespace from the string.
|
|
896
|
+
*/
|
|
842
897
|
beforeParse(schema: any, value: any, options: ValidateOptions): any;
|
|
843
898
|
/**
|
|
844
|
-
|
|
845
|
-
|
|
899
|
+
* Used by `beforeParse` to determine if a schema allows null values.
|
|
900
|
+
*/
|
|
846
901
|
protected isSchemaNullable: (schema: any) => boolean;
|
|
847
902
|
protected onConfigure: HookPrimitive<"configure">;
|
|
848
903
|
protected canEval(): boolean;
|
|
@@ -857,35 +912,35 @@ interface ValidateOptions {
|
|
|
857
912
|
type Encoding = "object" | "string" | "binary";
|
|
858
913
|
interface EncodeOptions<T extends Encoding = Encoding> {
|
|
859
914
|
/**
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
915
|
+
* The output encoding format:
|
|
916
|
+
* - 'string': Returns JSON string
|
|
917
|
+
* - 'binary': Returns Uint8Array (for protobuf, msgpack, etc.)
|
|
918
|
+
*
|
|
919
|
+
* @default "string"
|
|
920
|
+
*/
|
|
866
921
|
as?: T;
|
|
867
922
|
/**
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
923
|
+
* The encoder to use (e.g., 'json', 'protobuf', 'msgpack')
|
|
924
|
+
*
|
|
925
|
+
* @default "json"
|
|
926
|
+
*/
|
|
872
927
|
encoder?: string;
|
|
873
928
|
/**
|
|
874
|
-
|
|
875
|
-
|
|
929
|
+
* Validation options to apply before encoding.
|
|
930
|
+
*/
|
|
876
931
|
validation?: ValidateOptions | false;
|
|
877
932
|
}
|
|
878
933
|
type EncodeResult<T extends TSchema$1, E extends Encoding> = E extends "string" ? string : E extends "binary" ? Uint8Array : StaticEncode$1<T>;
|
|
879
934
|
interface DecodeOptions {
|
|
880
935
|
/**
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
936
|
+
* The encoder to use (e.g., 'json', 'protobuf', 'msgpack')
|
|
937
|
+
*
|
|
938
|
+
* @default "json"
|
|
939
|
+
*/
|
|
885
940
|
encoder?: string;
|
|
886
941
|
/**
|
|
887
|
-
|
|
888
|
-
|
|
942
|
+
* Validation options to apply before encoding.
|
|
943
|
+
*/
|
|
889
944
|
validation?: ValidateOptions | false;
|
|
890
945
|
}
|
|
891
946
|
/**
|
|
@@ -895,76 +950,115 @@ interface DecodeOptions {
|
|
|
895
950
|
declare class CodecManager {
|
|
896
951
|
protected readonly codecs: Map<string, SchemaCodec>;
|
|
897
952
|
protected readonly jsonCodec: JsonSchemaCodec;
|
|
953
|
+
protected readonly keylessCodec: KeylessJsonSchemaCodec;
|
|
898
954
|
protected readonly schemaValidator: SchemaValidator;
|
|
899
955
|
default: string;
|
|
900
956
|
constructor();
|
|
901
957
|
/**
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
* @returns The codec instance
|
|
913
|
-
* @throws {AlephaError} If the codec is not found
|
|
914
|
-
*/
|
|
958
|
+
* Register a new codec format.
|
|
959
|
+
*/
|
|
960
|
+
register(opts: CodecRegisterOptions): void;
|
|
961
|
+
/**
|
|
962
|
+
* Get a specific codec by name.
|
|
963
|
+
*
|
|
964
|
+
* @param name - The name of the codec
|
|
965
|
+
* @returns The codec instance
|
|
966
|
+
* @throws {AlephaError} If the codec is not found
|
|
967
|
+
*/
|
|
915
968
|
getCodec(name: string): SchemaCodec;
|
|
916
969
|
/**
|
|
917
|
-
|
|
918
|
-
|
|
970
|
+
* Encode data using the specified codec and output format.
|
|
971
|
+
*/
|
|
919
972
|
encode<T extends TSchema$1, E extends Encoding = "object">(schema: T, value: unknown, options?: EncodeOptions<E>): EncodeResult<T, E>;
|
|
920
973
|
/**
|
|
921
|
-
|
|
922
|
-
|
|
974
|
+
* Decode data using the specified codec.
|
|
975
|
+
*/
|
|
923
976
|
decode<T extends TSchema$1>(schema: T, data: any, options?: DecodeOptions): Static<T>;
|
|
924
977
|
/**
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
978
|
+
* Validate decoded data against the schema.
|
|
979
|
+
*
|
|
980
|
+
* This is automatically called before encoding or after decoding.
|
|
981
|
+
*/
|
|
929
982
|
validate<T extends TSchema$1>(schema: T, value: unknown, options?: ValidateOptions): Static<T>;
|
|
930
983
|
}
|
|
984
|
+
interface CodecRegisterOptions {
|
|
985
|
+
name: string;
|
|
986
|
+
codec: SchemaCodec;
|
|
987
|
+
default?: boolean;
|
|
988
|
+
}
|
|
931
989
|
//#endregion
|
|
932
990
|
//#region ../../src/core/providers/EventManager.d.ts
|
|
991
|
+
/**
|
|
992
|
+
* Compiled event executor - optimized for hot paths.
|
|
993
|
+
* Returns void for sync-only chains, Promise<void> for chains with async hooks.
|
|
994
|
+
*/
|
|
995
|
+
type CompiledEventExecutor<T> = (payload: T) => void | Promise<void>;
|
|
996
|
+
/**
|
|
997
|
+
* Options for compiled event executors.
|
|
998
|
+
*/
|
|
999
|
+
interface CompileOptions {
|
|
1000
|
+
/**
|
|
1001
|
+
* If true, errors will be caught and logged instead of throwing.
|
|
1002
|
+
* @default false
|
|
1003
|
+
*/
|
|
1004
|
+
catch?: boolean;
|
|
1005
|
+
}
|
|
933
1006
|
declare class EventManager {
|
|
934
1007
|
logFn?: () => LoggerInterface | undefined;
|
|
935
1008
|
/**
|
|
936
|
-
|
|
937
|
-
|
|
1009
|
+
* List of events that can be triggered. Powered by $hook().
|
|
1010
|
+
*/
|
|
938
1011
|
protected events: Record<string, Array<Hook>>;
|
|
939
1012
|
constructor(logFn?: () => LoggerInterface | undefined);
|
|
940
1013
|
protected get log(): LoggerInterface | undefined;
|
|
941
1014
|
clear(): void;
|
|
942
1015
|
/**
|
|
943
|
-
|
|
944
|
-
|
|
1016
|
+
* Registers a hook for the specified event.
|
|
1017
|
+
*/
|
|
945
1018
|
on<T extends keyof Hooks>(event: T, hookOrFunc: Hook<T> | ((payload: Hooks[T]) => Async<void>)): () => void;
|
|
946
1019
|
/**
|
|
947
|
-
|
|
948
|
-
|
|
1020
|
+
* Compiles an event into an optimized executor function.
|
|
1021
|
+
*
|
|
1022
|
+
* Call this after all hooks are registered (e.g., after Alepha.start()).
|
|
1023
|
+
* The returned function checks each hook's return value and awaits promises.
|
|
1024
|
+
* Returns undefined if all hooks are sync, or a Promise if any hook returns one.
|
|
1025
|
+
*
|
|
1026
|
+
* @example
|
|
1027
|
+
* ```ts
|
|
1028
|
+
* // At startup (after hooks are registered)
|
|
1029
|
+
* const onRequest = alepha.events.compile("server:onRequest", { catch: true });
|
|
1030
|
+
*
|
|
1031
|
+
* // In hot path - only await if promise returned
|
|
1032
|
+
* const result = onRequest({ request, route });
|
|
1033
|
+
* if (result) await result;
|
|
1034
|
+
* ```
|
|
1035
|
+
*/
|
|
1036
|
+
compile<T extends keyof Hooks>(event: T, options?: CompileOptions): CompiledEventExecutor<Hooks[T]>;
|
|
1037
|
+
/**
|
|
1038
|
+
* Emits the specified event with the given payload.
|
|
1039
|
+
*
|
|
1040
|
+
* For hot paths (like HTTP request handling), use compile() instead
|
|
1041
|
+
* to get an optimized executor.
|
|
1042
|
+
*/
|
|
949
1043
|
emit<T extends keyof Hooks>(func: T, payload: Hooks[T], options?: {
|
|
950
1044
|
/**
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
1045
|
+
* If true, the hooks will be executed in reverse order.
|
|
1046
|
+
* This is useful for "stop" hooks that should be executed in reverse order.
|
|
1047
|
+
*
|
|
1048
|
+
* @default false
|
|
1049
|
+
*/
|
|
956
1050
|
reverse?: boolean;
|
|
957
1051
|
/**
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
1052
|
+
* If true, the hooks will be logged with their execution time.
|
|
1053
|
+
*
|
|
1054
|
+
* @default false
|
|
1055
|
+
*/
|
|
962
1056
|
log?: boolean;
|
|
963
1057
|
/**
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
1058
|
+
* If true, errors will be caught and logged instead of throwing.
|
|
1059
|
+
*
|
|
1060
|
+
* @default false
|
|
1061
|
+
*/
|
|
968
1062
|
catch?: boolean;
|
|
969
1063
|
}): Promise<void>;
|
|
970
1064
|
}
|
|
@@ -984,39 +1078,39 @@ declare class StateManager<State$1 extends object = State> {
|
|
|
984
1078
|
getAtoms(context?: boolean): Array<AtomWithValue>;
|
|
985
1079
|
register(atom: Atom<any>): this;
|
|
986
1080
|
/**
|
|
987
|
-
|
|
988
|
-
|
|
1081
|
+
* Get a value from the state with proper typing
|
|
1082
|
+
*/
|
|
989
1083
|
get<T extends TAtomObject>(target: Atom<T>): Static<T>;
|
|
990
1084
|
get<Key extends keyof State$1>(target: Key): State$1[Key] | undefined;
|
|
991
1085
|
/**
|
|
992
|
-
|
|
993
|
-
|
|
1086
|
+
* Set a value in the state
|
|
1087
|
+
*/
|
|
994
1088
|
set<T extends TAtomObject>(target: Atom<T>, value: AtomStatic<T>, options?: SetStateOptions): this;
|
|
995
1089
|
set<Key extends keyof State$1>(target: Key, value: State$1[Key] | undefined, options?: SetStateOptions): this;
|
|
996
1090
|
/**
|
|
997
|
-
|
|
998
|
-
|
|
1091
|
+
* Mutate a value in the state.
|
|
1092
|
+
*/
|
|
999
1093
|
mut<T extends TObject$1>(target: Atom<T>, mutator: (current: Static<T>) => Static<T>): this;
|
|
1000
1094
|
mut<Key extends keyof State$1>(target: Key, mutator: (current: State$1[Key] | undefined) => State$1[Key] | undefined): this;
|
|
1001
1095
|
/**
|
|
1002
|
-
|
|
1003
|
-
|
|
1096
|
+
* Check if a key exists in the state
|
|
1097
|
+
*/
|
|
1004
1098
|
has<Key extends keyof State$1>(key: Key): boolean;
|
|
1005
1099
|
/**
|
|
1006
|
-
|
|
1007
|
-
|
|
1100
|
+
* Delete a key from the state (set to undefined)
|
|
1101
|
+
*/
|
|
1008
1102
|
del<Key extends keyof State$1>(key: Key): this;
|
|
1009
1103
|
/**
|
|
1010
|
-
|
|
1011
|
-
|
|
1104
|
+
* Push a value to an array in the state
|
|
1105
|
+
*/
|
|
1012
1106
|
push<Key extends keyof OnlyArray<State$1>>(key: Key, ...value: Array<NonNullable<State$1[Key]> extends Array<infer U> ? U : never>): this;
|
|
1013
1107
|
/**
|
|
1014
|
-
|
|
1015
|
-
|
|
1108
|
+
* Clear all state
|
|
1109
|
+
*/
|
|
1016
1110
|
clear(): this;
|
|
1017
1111
|
/**
|
|
1018
|
-
|
|
1019
|
-
|
|
1112
|
+
* Get all keys that exist in the state
|
|
1113
|
+
*/
|
|
1020
1114
|
keys(): (keyof State$1)[];
|
|
1021
1115
|
}
|
|
1022
1116
|
type OnlyArray<T extends object> = { [K in keyof T]: NonNullable<T[K]> extends Array<any> ? K : never };
|
|
@@ -1151,273 +1245,274 @@ interface SetStateOptions {
|
|
|
1151
1245
|
*/
|
|
1152
1246
|
declare class Alepha {
|
|
1153
1247
|
/**
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1248
|
+
* Creates a new instance of the Alepha container with some helpers:
|
|
1249
|
+
*
|
|
1250
|
+
* - merges `process.env` with the provided state.env when available.
|
|
1251
|
+
* - populates the test hooks for Vitest or Jest environments when available.
|
|
1252
|
+
*
|
|
1253
|
+
* If you are not interested about these helpers, you can use the constructor directly.
|
|
1254
|
+
*/
|
|
1161
1255
|
static create(state?: Partial<State>): Alepha;
|
|
1162
1256
|
/**
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1257
|
+
* Flag indicating whether the App won't accept any further changes.
|
|
1258
|
+
* Pass to true when #start() is called.
|
|
1259
|
+
*/
|
|
1166
1260
|
protected locked: boolean;
|
|
1167
1261
|
/**
|
|
1168
|
-
|
|
1169
|
-
|
|
1262
|
+
* True if the App has been configured.
|
|
1263
|
+
*/
|
|
1170
1264
|
protected configured: boolean;
|
|
1171
1265
|
/**
|
|
1172
|
-
|
|
1173
|
-
|
|
1266
|
+
* True if the App has started.
|
|
1267
|
+
*/
|
|
1174
1268
|
protected started: boolean;
|
|
1175
1269
|
/**
|
|
1176
|
-
|
|
1177
|
-
|
|
1270
|
+
* True if the App is ready.
|
|
1271
|
+
*/
|
|
1178
1272
|
protected ready: boolean;
|
|
1179
1273
|
/**
|
|
1180
|
-
|
|
1181
|
-
|
|
1274
|
+
* A promise that resolves when the App has started.
|
|
1275
|
+
*/
|
|
1182
1276
|
protected starting?: PromiseWithResolvers<this>;
|
|
1183
1277
|
/**
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1278
|
+
* During the instantiation process, we keep a list of pending instantiations.
|
|
1279
|
+
* > It allows us to detect circular dependencies.
|
|
1280
|
+
*/
|
|
1187
1281
|
protected pendingInstantiations: Service[];
|
|
1188
1282
|
/**
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1283
|
+
* Cache for environment variables.
|
|
1284
|
+
* > It allows us to avoid parsing the same schema multiple times.
|
|
1285
|
+
*/
|
|
1192
1286
|
protected cacheEnv: Map<TSchema, any>;
|
|
1193
1287
|
/**
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1288
|
+
* List of modules that are registered in the container.
|
|
1289
|
+
*
|
|
1290
|
+
* Modules are used to group services and provide a way to register them in the container.
|
|
1291
|
+
*/
|
|
1198
1292
|
protected modules: Array<Module>;
|
|
1199
1293
|
/**
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1294
|
+
* List of service substitutions.
|
|
1295
|
+
*
|
|
1296
|
+
* Services registered here will be replaced by the specified service when injected.
|
|
1297
|
+
*/
|
|
1204
1298
|
protected substitutions: Map<Service, {
|
|
1205
1299
|
use: Service;
|
|
1206
1300
|
}>;
|
|
1207
1301
|
/**
|
|
1208
|
-
|
|
1209
|
-
|
|
1302
|
+
* Registry of primitives.
|
|
1303
|
+
*/
|
|
1210
1304
|
protected primitiveRegistry: Map<Service<Primitive<{}>>, Primitive<{}>[]>;
|
|
1211
1305
|
/**
|
|
1212
|
-
|
|
1213
|
-
|
|
1306
|
+
* List of all services + how they are provided.
|
|
1307
|
+
*/
|
|
1214
1308
|
protected registry: Map<Service, ServiceDefinition>;
|
|
1215
1309
|
/**
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1310
|
+
* Node.js feature that allows to store context across asynchronous calls.
|
|
1311
|
+
*
|
|
1312
|
+
* This is used for logging, tracing, and other context-related features.
|
|
1313
|
+
*
|
|
1314
|
+
* Mocked for browser environments.
|
|
1315
|
+
*/
|
|
1222
1316
|
context: AlsProvider;
|
|
1223
1317
|
/**
|
|
1224
|
-
|
|
1225
|
-
|
|
1318
|
+
* Event manager to handle lifecycle events and custom events.
|
|
1319
|
+
*/
|
|
1226
1320
|
events: EventManager;
|
|
1227
1321
|
/**
|
|
1228
|
-
|
|
1229
|
-
|
|
1322
|
+
* State manager to store arbitrary values.
|
|
1323
|
+
*/
|
|
1230
1324
|
store: StateManager<State>;
|
|
1231
1325
|
/**
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1326
|
+
* Codec manager for encoding and decoding data with different formats.
|
|
1327
|
+
*
|
|
1328
|
+
* Supports multiple codec formats (JSON, Protobuf, etc.) with a unified interface.
|
|
1329
|
+
*/
|
|
1236
1330
|
codec: CodecManager;
|
|
1237
1331
|
/**
|
|
1238
|
-
|
|
1239
|
-
|
|
1332
|
+
* Get logger instance.
|
|
1333
|
+
*/
|
|
1240
1334
|
get log(): LoggerInterface | undefined;
|
|
1241
1335
|
/**
|
|
1242
|
-
|
|
1243
|
-
|
|
1336
|
+
* The environment variables for the App.
|
|
1337
|
+
*/
|
|
1244
1338
|
get env(): Readonly<Env>;
|
|
1245
1339
|
constructor(state?: Partial<State>);
|
|
1246
1340
|
set<T extends TAtomObject>(target: Atom<T>, value: AtomStatic<T>): this;
|
|
1247
1341
|
set<Key extends keyof State>(target: Key, value: State[Key] | undefined): this;
|
|
1248
1342
|
/**
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1343
|
+
* True when start() is called.
|
|
1344
|
+
*
|
|
1345
|
+
* -> No more services can be added, it's over, bye!
|
|
1346
|
+
*/
|
|
1253
1347
|
isLocked(): boolean;
|
|
1254
1348
|
/**
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1349
|
+
* Returns whether the App is configured.
|
|
1350
|
+
*
|
|
1351
|
+
* It means that Alepha#configure() has been called.
|
|
1352
|
+
*
|
|
1353
|
+
* > By default, configure() is called automatically when start() is called, but you can also call it manually.
|
|
1354
|
+
*/
|
|
1261
1355
|
isConfigured(): boolean;
|
|
1262
1356
|
/**
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1357
|
+
* Returns whether the App has started.
|
|
1358
|
+
*
|
|
1359
|
+
* It means that #start() has been called but maybe not all services are ready.
|
|
1360
|
+
*/
|
|
1267
1361
|
isStarted(): boolean;
|
|
1268
1362
|
/**
|
|
1269
|
-
|
|
1270
|
-
|
|
1363
|
+
* True if the App is ready. It means that Alepha is started AND ready() hook has beed called.
|
|
1364
|
+
*/
|
|
1271
1365
|
isReady(): boolean;
|
|
1272
1366
|
/**
|
|
1273
|
-
|
|
1274
|
-
|
|
1367
|
+
* True if the App is running in a Continuous Integration environment.
|
|
1368
|
+
*/
|
|
1275
1369
|
isCI(): boolean;
|
|
1276
1370
|
/**
|
|
1277
|
-
|
|
1278
|
-
|
|
1371
|
+
* True if the App is running in a browser environment.
|
|
1372
|
+
*/
|
|
1279
1373
|
isBrowser(): boolean;
|
|
1280
1374
|
/**
|
|
1281
|
-
|
|
1282
|
-
|
|
1375
|
+
* Returns whether the App is running in Vite dev mode.
|
|
1376
|
+
*/
|
|
1283
1377
|
isViteDev(): boolean;
|
|
1284
1378
|
isBun(): boolean;
|
|
1285
1379
|
/**
|
|
1286
|
-
|
|
1287
|
-
|
|
1380
|
+
* Returns whether the App is running in a serverless environment.
|
|
1381
|
+
*/
|
|
1288
1382
|
isServerless(): boolean;
|
|
1289
1383
|
/**
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1384
|
+
* Returns whether the App is in test mode. (Running in a test environment)
|
|
1385
|
+
*
|
|
1386
|
+
* > This is automatically set when running tests with Jest or Vitest.
|
|
1387
|
+
*/
|
|
1294
1388
|
isTest(): boolean;
|
|
1295
1389
|
/**
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1390
|
+
* Returns whether the App is in production mode. (Running in a production environment)
|
|
1391
|
+
*
|
|
1392
|
+
* > This is automatically set by Vite or Vercel. However, you have to set it manually when running Docker apps.
|
|
1393
|
+
*/
|
|
1300
1394
|
isProduction(): boolean;
|
|
1301
1395
|
/**
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1396
|
+
* Starts the App.
|
|
1397
|
+
*
|
|
1398
|
+
* - Lock any further changes to the container.
|
|
1399
|
+
* - Run "configure" hook for all services. Primitives will be processed.
|
|
1400
|
+
* - Run "start" hook for all services. Providers will connect/listen/...
|
|
1401
|
+
* - Run "ready" hook for all services. This is the point where the App is ready to serve requests.
|
|
1402
|
+
*
|
|
1403
|
+
* @return A promise that resolves when the App has started.
|
|
1404
|
+
*/
|
|
1311
1405
|
start(): Promise<this>;
|
|
1312
1406
|
/**
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1407
|
+
* Stops the App.
|
|
1408
|
+
*
|
|
1409
|
+
* - Run "stop" hook for all services.
|
|
1410
|
+
*
|
|
1411
|
+
* Stop will NOT reset the container.
|
|
1412
|
+
* Stop will NOT unlock the container.
|
|
1413
|
+
*
|
|
1414
|
+
* > Stop is used to gracefully shut down the application, nothing more. There is no "restart".
|
|
1415
|
+
*
|
|
1416
|
+
* @return A promise that resolves when the App has stopped.
|
|
1417
|
+
*/
|
|
1324
1418
|
stop(): Promise<void>;
|
|
1325
1419
|
/**
|
|
1326
|
-
|
|
1327
|
-
|
|
1420
|
+
* Check if entry is registered in the container.
|
|
1421
|
+
*/
|
|
1328
1422
|
has(entry: ServiceEntry, opts?: {
|
|
1329
1423
|
/**
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1424
|
+
* Check if the entry is registered in the pending instantiation stack.
|
|
1425
|
+
*
|
|
1426
|
+
* @default true
|
|
1427
|
+
*/
|
|
1334
1428
|
inStack?: boolean;
|
|
1335
1429
|
/**
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1430
|
+
* Check if the entry is registered in the container registry.
|
|
1431
|
+
*
|
|
1432
|
+
* @default true
|
|
1433
|
+
*/
|
|
1340
1434
|
inRegistry?: boolean;
|
|
1341
1435
|
/**
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1436
|
+
* Check if the entry is registered in the substitutions.
|
|
1437
|
+
*
|
|
1438
|
+
* @default true
|
|
1439
|
+
*/
|
|
1346
1440
|
inSubstitutions?: boolean;
|
|
1347
1441
|
/**
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1442
|
+
* Where to look for registered services.
|
|
1443
|
+
*
|
|
1444
|
+
* @default this.registry
|
|
1445
|
+
*/
|
|
1352
1446
|
registry?: Map<Service, ServiceDefinition>;
|
|
1353
1447
|
}): boolean;
|
|
1354
1448
|
/**
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1449
|
+
* Registers the specified service in the container.
|
|
1450
|
+
*
|
|
1451
|
+
* - If the service is ALREADY registered, the method does nothing.
|
|
1452
|
+
* - If the service is NOT registered, a new instance is created and registered.
|
|
1453
|
+
*
|
|
1454
|
+
* Method is chainable, so you can register multiple services in a single call.
|
|
1455
|
+
*
|
|
1456
|
+
* > ServiceEntry allows to provide a service **substitution** feature.
|
|
1457
|
+
*
|
|
1458
|
+
* @example
|
|
1459
|
+
* ```ts
|
|
1460
|
+
* class A { value = "a"; }
|
|
1461
|
+
* class B { value = "b"; }
|
|
1462
|
+
* class M { a = $inject(A); }
|
|
1463
|
+
*
|
|
1464
|
+
* Alepha.create().with({ provide: A, use: B }).get(M).a.value; // "b"
|
|
1465
|
+
* ```
|
|
1466
|
+
*
|
|
1467
|
+
* > **Substitution** is an advanced feature that allows you to replace a service with another service.
|
|
1468
|
+
* > It's useful for testing or for providing different implementations of a service.
|
|
1469
|
+
* > If you are interested in configuring a service, use Alepha#configure() instead.
|
|
1470
|
+
*
|
|
1471
|
+
* @param serviceEntry - The service to register in the container.
|
|
1472
|
+
* @return Current instance of Alepha.
|
|
1473
|
+
*/
|
|
1380
1474
|
with<T extends object>(serviceEntry: ServiceEntry<T> | {
|
|
1381
1475
|
default: ServiceEntry<T>;
|
|
1382
1476
|
}): this;
|
|
1383
1477
|
/**
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1478
|
+
* Get an instance of the specified service from the container.
|
|
1479
|
+
*
|
|
1480
|
+
* @see {@link InjectOptions} for the available options.
|
|
1481
|
+
*/
|
|
1388
1482
|
inject<T extends object>(service: Service<T> | string, opts?: InjectOptions<T>): T;
|
|
1389
1483
|
/**
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1484
|
+
* Applies environment variables to the provided schema and state object.
|
|
1485
|
+
*
|
|
1486
|
+
* It replaces also all templated $ENV inside string values.
|
|
1487
|
+
*
|
|
1488
|
+
* @param schema - The schema object to apply environment variables to.
|
|
1489
|
+
* @return The schema object with environment variables applied.
|
|
1490
|
+
*/
|
|
1397
1491
|
parseEnv<T extends TObject$1>(schema: T): Static$1<T>;
|
|
1398
1492
|
/**
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1493
|
+
* Get all environment variable schemas and their parsed values.
|
|
1494
|
+
*
|
|
1495
|
+
* This is useful for DevTools to display all expected environment variables.
|
|
1496
|
+
*/
|
|
1403
1497
|
getEnvSchemas(): Array<{
|
|
1404
1498
|
schema: TSchema;
|
|
1405
1499
|
values: Record<string, any>;
|
|
1406
1500
|
}>;
|
|
1407
1501
|
/**
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1502
|
+
* Dump the current dependency graph of the App.
|
|
1503
|
+
*
|
|
1504
|
+
* This method returns a record where the keys are the names of the services.
|
|
1505
|
+
*/
|
|
1412
1506
|
graph(): Record<string, {
|
|
1413
1507
|
from: string[];
|
|
1414
1508
|
as?: string[];
|
|
1415
1509
|
module?: string;
|
|
1416
1510
|
}>;
|
|
1511
|
+
dump(): AlephaDump;
|
|
1417
1512
|
services<T extends object>(base: Service<T>): Array<T>;
|
|
1418
1513
|
/**
|
|
1419
|
-
|
|
1420
|
-
|
|
1514
|
+
* Get all primitives of the specified type.
|
|
1515
|
+
*/
|
|
1421
1516
|
primitives<TPrimitive extends Primitive>(factory: {
|
|
1422
1517
|
[KIND]: InstantiableClass<TPrimitive>;
|
|
1423
1518
|
} | string): Array<TPrimitive>;
|
|
@@ -1429,150 +1524,164 @@ interface Hook<T extends keyof Hooks = any> {
|
|
|
1429
1524
|
priority?: "first" | "last";
|
|
1430
1525
|
callback: (payload: Hooks[T]) => Async<void>;
|
|
1431
1526
|
}
|
|
1527
|
+
interface AlephaDump {
|
|
1528
|
+
env: Record<string, AlephaDumpEnvVariable>;
|
|
1529
|
+
providers: Record<string, {
|
|
1530
|
+
from: string[];
|
|
1531
|
+
as?: string[];
|
|
1532
|
+
module?: string;
|
|
1533
|
+
}>;
|
|
1534
|
+
}
|
|
1535
|
+
interface AlephaDumpEnvVariable {
|
|
1536
|
+
description: string;
|
|
1537
|
+
default?: string;
|
|
1538
|
+
required?: boolean;
|
|
1539
|
+
enum?: Array<string>;
|
|
1540
|
+
}
|
|
1432
1541
|
/**
|
|
1433
1542
|
* This is how we store services in the Alepha container.
|
|
1434
1543
|
*/
|
|
1435
1544
|
interface ServiceDefinition<T extends object = any> {
|
|
1436
1545
|
/**
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1546
|
+
* The instance of the class or type definition.
|
|
1547
|
+
* Mostly used for caching / singleton but can be used for other purposes like forcing the instance.
|
|
1548
|
+
*/
|
|
1440
1549
|
instance: T;
|
|
1441
1550
|
/**
|
|
1442
|
-
|
|
1443
|
-
|
|
1551
|
+
* List of classes which use this class.
|
|
1552
|
+
*/
|
|
1444
1553
|
parents: Array<Service | null>;
|
|
1445
1554
|
}
|
|
1446
1555
|
interface Env {
|
|
1447
1556
|
[key: string]: string | boolean | number | undefined;
|
|
1448
1557
|
/**
|
|
1449
|
-
|
|
1450
|
-
|
|
1558
|
+
* Optional environment variable that indicates the current environment.
|
|
1559
|
+
*/
|
|
1451
1560
|
NODE_ENV?: string;
|
|
1452
1561
|
/**
|
|
1453
|
-
|
|
1454
|
-
|
|
1562
|
+
* Optional name of the application.
|
|
1563
|
+
*/
|
|
1455
1564
|
APP_NAME?: string;
|
|
1456
1565
|
/**
|
|
1457
|
-
|
|
1458
|
-
|
|
1566
|
+
* Optional root module name.
|
|
1567
|
+
*/
|
|
1459
1568
|
MODULE_NAME?: string;
|
|
1460
1569
|
}
|
|
1461
1570
|
interface State {
|
|
1462
1571
|
/**
|
|
1463
|
-
|
|
1464
|
-
|
|
1572
|
+
* Environment variables for the application.
|
|
1573
|
+
*/
|
|
1465
1574
|
env?: Readonly<Env>;
|
|
1466
1575
|
/**
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1576
|
+
* Logger instance to be used by the Alepha container.
|
|
1577
|
+
*
|
|
1578
|
+
* @internal
|
|
1579
|
+
*/
|
|
1471
1580
|
"alepha.logger"?: LoggerInterface;
|
|
1472
1581
|
/**
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1582
|
+
* If defined, the Alepha container will only register this service and its dependencies.
|
|
1583
|
+
*
|
|
1584
|
+
* @example
|
|
1585
|
+
* ```ts
|
|
1586
|
+
* class MigrateCmd {
|
|
1587
|
+
* db = $inject(DatabaseProvider);
|
|
1588
|
+
* alepha = $inject(Alepha);
|
|
1589
|
+
* env = $env(
|
|
1590
|
+
* t.object({
|
|
1591
|
+
* MIGRATE: t.optional(t.boolean()),
|
|
1592
|
+
* }),
|
|
1593
|
+
* );
|
|
1594
|
+
*
|
|
1595
|
+
* constructor() {
|
|
1596
|
+
* if (this.env.MIGRATE) {
|
|
1597
|
+
* this.alepha.set("alepha.target", MigrateCmd);
|
|
1598
|
+
* }
|
|
1599
|
+
* }
|
|
1600
|
+
*
|
|
1601
|
+
* ready = $hook({
|
|
1602
|
+
* on: "ready",
|
|
1603
|
+
* handler: async () => {
|
|
1604
|
+
* if (this.env.MIGRATE) {
|
|
1605
|
+
* await this.db.migrate();
|
|
1606
|
+
* }
|
|
1607
|
+
* },
|
|
1608
|
+
* });
|
|
1609
|
+
* }
|
|
1610
|
+
* ```
|
|
1611
|
+
*/
|
|
1503
1612
|
"alepha.target"?: Service;
|
|
1504
1613
|
/**
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1614
|
+
* Bind to Vitest 'beforeAll' hook.
|
|
1615
|
+
* Used for testing purposes.
|
|
1616
|
+
* This is automatically attached if Alepha#create() detects a test environment and global 'beforeAll' is available.
|
|
1617
|
+
*/
|
|
1509
1618
|
"alepha.test.beforeAll"?: (run: any) => any;
|
|
1510
1619
|
/**
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1620
|
+
* Bind to Vitest 'afterAll' hook.
|
|
1621
|
+
* Used for testing purposes.
|
|
1622
|
+
* This is automatically attached if Alepha#create() detects a test environment and global 'afterAll' is available.
|
|
1623
|
+
*/
|
|
1515
1624
|
"alepha.test.afterAll"?: (run: any) => any;
|
|
1516
1625
|
/**
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1626
|
+
* Bind to Vitest 'afterEach' hook.
|
|
1627
|
+
* Used for testing purposes.
|
|
1628
|
+
* This is automatically attached if Alepha#create() detects a test environment and global 'afterEach' is available.
|
|
1629
|
+
*/
|
|
1521
1630
|
"alepha.test.afterEach"?: (run: any) => any;
|
|
1522
1631
|
/**
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1632
|
+
* Bind to Vitest 'onTestFinished' hook.
|
|
1633
|
+
* Used for testing purposes.
|
|
1634
|
+
* This is automatically attached if Alepha#create() detects a test environment and global 'onTestFinished' is available.
|
|
1635
|
+
*/
|
|
1527
1636
|
"alepha.test.onTestFinished"?: (run: any) => any;
|
|
1528
1637
|
/**
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1638
|
+
* List of static assets to be copied to the output directory during the build process.
|
|
1639
|
+
*
|
|
1640
|
+
* Used for Alepha-based applications that require static assets.
|
|
1641
|
+
*
|
|
1642
|
+
* See alepha/vite for more details.
|
|
1643
|
+
*/
|
|
1535
1644
|
"alepha.build.assets"?: Array<string>;
|
|
1536
1645
|
}
|
|
1537
1646
|
interface Hooks {
|
|
1538
1647
|
/**
|
|
1539
|
-
|
|
1540
|
-
|
|
1648
|
+
* Used for testing purposes.
|
|
1649
|
+
*/
|
|
1541
1650
|
echo: unknown;
|
|
1542
1651
|
/**
|
|
1543
|
-
|
|
1544
|
-
|
|
1652
|
+
* Triggered during the configuration phase. Before the start phase.
|
|
1653
|
+
*/
|
|
1545
1654
|
configure: Alepha;
|
|
1546
1655
|
/**
|
|
1547
|
-
|
|
1548
|
-
|
|
1656
|
+
* Triggered during the start phase. When `Alepha#start()` is called.
|
|
1657
|
+
*/
|
|
1549
1658
|
start: Alepha;
|
|
1550
1659
|
/**
|
|
1551
|
-
|
|
1552
|
-
|
|
1660
|
+
* Triggered during the ready phase. After the start phase.
|
|
1661
|
+
*/
|
|
1553
1662
|
ready: Alepha;
|
|
1554
1663
|
/**
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1664
|
+
* Triggered during the stop phase.
|
|
1665
|
+
*
|
|
1666
|
+
* - Stop should be called after a SIGINT or SIGTERM signal in order to gracefully shutdown the application. (@see `run()` method)
|
|
1667
|
+
*
|
|
1668
|
+
*/
|
|
1560
1669
|
stop: Alepha;
|
|
1561
1670
|
/**
|
|
1562
|
-
|
|
1563
|
-
|
|
1671
|
+
* Triggered when a state value is mutated.
|
|
1672
|
+
*/
|
|
1564
1673
|
"state:mutate": {
|
|
1565
1674
|
/**
|
|
1566
|
-
|
|
1567
|
-
|
|
1675
|
+
* The key of the state that was mutated.
|
|
1676
|
+
*/
|
|
1568
1677
|
key: keyof State;
|
|
1569
1678
|
/**
|
|
1570
|
-
|
|
1571
|
-
|
|
1679
|
+
* The new value of the state.
|
|
1680
|
+
*/
|
|
1572
1681
|
value: any;
|
|
1573
1682
|
/**
|
|
1574
|
-
|
|
1575
|
-
|
|
1683
|
+
* The previous value of the state.
|
|
1684
|
+
*/
|
|
1576
1685
|
prevValue: any;
|
|
1577
1686
|
};
|
|
1578
1687
|
}
|
|
@@ -1687,8 +1796,8 @@ type TPage<T extends TObject | TRecord> = TObject<{
|
|
|
1687
1796
|
*/
|
|
1688
1797
|
type Page<T> = {
|
|
1689
1798
|
/**
|
|
1690
|
-
|
|
1691
|
-
|
|
1799
|
+
* Array of items on the current page.
|
|
1800
|
+
*/
|
|
1692
1801
|
content: T[];
|
|
1693
1802
|
page: Static<typeof pageMetadataSchema>;
|
|
1694
1803
|
};
|
|
@@ -1696,12 +1805,11 @@ type PageMetadata = Static<typeof pageMetadataSchema>;
|
|
|
1696
1805
|
declare module "alepha" {
|
|
1697
1806
|
interface TypeProvider {
|
|
1698
1807
|
/**
|
|
1699
|
-
|
|
1700
|
-
|
|
1808
|
+
* Create a schema for a paginated response.
|
|
1809
|
+
*/
|
|
1701
1810
|
page<T extends TObject | TRecord>(itemSchema: T): TPage<T>;
|
|
1702
1811
|
}
|
|
1703
|
-
}
|
|
1704
|
-
//# sourceMappingURL=pageSchema.d.ts.map
|
|
1812
|
+
} //# sourceMappingURL=pageSchema.d.ts.map
|
|
1705
1813
|
//#endregion
|
|
1706
1814
|
//#region ../../src/core/helpers/createPagination.d.ts
|
|
1707
1815
|
/**
|
|
@@ -1857,14 +1965,14 @@ declare function jsonSchemaToTypeBox(schema: JsonSchemaObject): TSchema$1;
|
|
|
1857
1965
|
*/
|
|
1858
1966
|
interface PageRequest {
|
|
1859
1967
|
/**
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1968
|
+
* The page number to retrieve (0-indexed).
|
|
1969
|
+
* @default 0
|
|
1970
|
+
*/
|
|
1863
1971
|
page?: number;
|
|
1864
1972
|
/**
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1973
|
+
* The number of items per page.
|
|
1974
|
+
* @default 10
|
|
1975
|
+
*/
|
|
1868
1976
|
size?: number;
|
|
1869
1977
|
}
|
|
1870
1978
|
/**
|
|
@@ -1876,13 +1984,13 @@ type SortDirection = "asc" | "desc";
|
|
|
1876
1984
|
*/
|
|
1877
1985
|
interface SortField {
|
|
1878
1986
|
/**
|
|
1879
|
-
|
|
1880
|
-
|
|
1987
|
+
* The field/column name to sort by.
|
|
1988
|
+
*/
|
|
1881
1989
|
field: string;
|
|
1882
1990
|
/**
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1991
|
+
* The sort direction.
|
|
1992
|
+
* @default "asc"
|
|
1993
|
+
*/
|
|
1886
1994
|
direction: SortDirection;
|
|
1887
1995
|
}
|
|
1888
1996
|
//#endregion
|
|
@@ -1917,17 +2025,17 @@ interface SortField {
|
|
|
1917
2025
|
declare const $context: () => ContextPrimitive;
|
|
1918
2026
|
interface ContextPrimitive {
|
|
1919
2027
|
/**
|
|
1920
|
-
|
|
1921
|
-
|
|
2028
|
+
* Alepha instance.
|
|
2029
|
+
*/
|
|
1922
2030
|
alepha: Alepha;
|
|
1923
2031
|
/**
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
2032
|
+
* Service definition which is creating this primitive.
|
|
2033
|
+
* This is NOT the instance but the service definition.
|
|
2034
|
+
*/
|
|
1927
2035
|
service?: Service;
|
|
1928
2036
|
/**
|
|
1929
|
-
|
|
1930
|
-
|
|
2037
|
+
* Module definition, if any.
|
|
2038
|
+
*/
|
|
1931
2039
|
module?: Service;
|
|
1932
2040
|
}
|
|
1933
2041
|
//#endregion
|
|
@@ -1996,27 +2104,27 @@ type PageQuery = Static<typeof pageQuerySchema>;
|
|
|
1996
2104
|
//#region ../../src/core/interfaces/Run.d.ts
|
|
1997
2105
|
interface RunOptions {
|
|
1998
2106
|
/**
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2107
|
+
* Environment variables to be used by the application.
|
|
2108
|
+
* It will be merged with the current process environment.
|
|
2109
|
+
*/
|
|
2002
2110
|
env?: Env;
|
|
2003
2111
|
/**
|
|
2004
|
-
|
|
2005
|
-
|
|
2112
|
+
* A callback that will be executed before the application starts.
|
|
2113
|
+
*/
|
|
2006
2114
|
configure?: (alepha: Alepha) => Async<void>;
|
|
2007
2115
|
/**
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2116
|
+
* A callback that will be executed once the application is ready.
|
|
2117
|
+
* This is useful for initializing resources or starting background tasks.
|
|
2118
|
+
*/
|
|
2011
2119
|
ready?: (alepha: Alepha) => Async<void>;
|
|
2012
2120
|
/**
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2121
|
+
* If true, the application will .stop() after the ready callback is executed.
|
|
2122
|
+
* Useful for one-time tasks!
|
|
2123
|
+
*/
|
|
2016
2124
|
once?: boolean;
|
|
2017
2125
|
/**
|
|
2018
|
-
|
|
2019
|
-
|
|
2126
|
+
* If true, the application will run in cluster mode.
|
|
2127
|
+
*/
|
|
2020
2128
|
cluster?: boolean;
|
|
2021
2129
|
}
|
|
2022
2130
|
//#endregion
|
|
@@ -2038,5 +2146,5 @@ declare const AlephaCore: Service<Module>;
|
|
|
2038
2146
|
*/
|
|
2039
2147
|
declare const run: (entry: Alepha | Service | Array<Service>, opts?: RunOptions) => Alepha;
|
|
2040
2148
|
//#endregion
|
|
2041
|
-
export { $atom, $context, $env, $hook, $inject, $module, $use, AbstractClass, Alepha, AlephaCore, AlephaError, AlsProvider, AppNotStartedError, Async, AsyncFn, AsyncLocalStorageData, Atom, AtomOptions, AtomStatic, AtomWithValue, CircularDependencyError, CodecManager, ContainerLockedError, ContextPrimitive, DecodeOptions, EncodeOptions, EncodeResult, Encoding, Env, EventManager, FileLike, Format, Hook, HookOptions, HookPrimitive, Hooks, InjectOptions, InjectPrimitive, InstantiableClass, JsonSchemaCodec, JsonSchemaObject, KIND, LogLevel, LoggerInterface, MaybePromise, Module, ModulePrimitiveOptions, OPTIONS, Page, PageMetadata, PageQuery, PageRequest, Primitive, PrimitiveArgs, PrimitiveConfig, PrimitiveFactory, PrimitiveFactoryLike, RunFunction, SchemaCodec, Service, ServiceEntry, ServiceSubstitution, SetStateOptions, 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, Type, TypeBoxError, TypeBoxErrorParams, TypeGuard, TypeProvider, Value, WithModule, createPagination, createPrimitive, isClass, isFileLike, isTypeFile, isUUID, jsonSchemaToTypeBox, pageMetadataSchema, pageQuerySchema, pageSchema, run, t };
|
|
2149
|
+
export { $atom, $context, $env, $hook, $inject, $module, $use, AbstractClass, Alepha, AlephaCore, AlephaDump, AlephaDumpEnvVariable, AlephaError, AlsProvider, AppNotStartedError, Async, AsyncFn, AsyncLocalStorageData, Atom, AtomOptions, AtomStatic, AtomWithValue, CircularDependencyError, CodecManager, CodecRegisterOptions, CompileOptions, CompiledEventExecutor, ContainerLockedError, ContextPrimitive, DecodeOptions, EncodeOptions, EncodeResult, Encoding, Env, EventManager, FileLike, Format, Hook, HookOptions, HookPrimitive, Hooks, InjectOptions, InjectPrimitive, InstantiableClass, JsonSchemaCodec, JsonSchemaObject, KIND, KeylessCodec, KeylessJsonSchemaCodec, LogLevel, LoggerInterface, MaybePromise, Module, ModulePrimitiveOptions, OPTIONS, Page, PageMetadata, PageQuery, PageRequest, Primitive, PrimitiveArgs, PrimitiveConfig, PrimitiveFactory, PrimitiveFactoryLike, RunFunction, SchemaCodec, Service, ServiceEntry, ServiceSubstitution, SetStateOptions, 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, Type, TypeBoxError, TypeBoxErrorParams, TypeGuard, TypeProvider, Value, WithModule, createPagination, createPrimitive, isClass, isFileLike, isTypeFile, isUUID, jsonSchemaToTypeBox, pageMetadataSchema, pageQuerySchema, pageSchema, run, t };
|
|
2042
2150
|
//# sourceMappingURL=index.d.ts.map
|