alepha 0.13.0 → 0.13.2
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 +1 -1
- package/dist/api-files/index.d.ts +28 -91
- package/dist/api-files/index.js +10 -755
- package/dist/api-files/index.js.map +1 -1
- package/dist/api-jobs/index.d.ts +67 -67
- package/dist/api-jobs/index.js +13 -13
- package/dist/api-jobs/index.js.map +1 -1
- package/dist/api-notifications/index.d.ts +129 -146
- package/dist/api-notifications/index.js +17 -39
- package/dist/api-notifications/index.js.map +1 -1
- package/dist/api-parameters/index.d.ts +21 -22
- package/dist/api-parameters/index.js +22 -22
- package/dist/api-parameters/index.js.map +1 -1
- package/dist/api-users/index.d.ts +224 -2001
- package/dist/api-users/index.js +914 -4787
- package/dist/api-users/index.js.map +1 -1
- package/dist/api-verifications/index.d.ts +96 -96
- package/dist/batch/index.d.ts +13 -13
- package/dist/batch/index.js +8 -8
- package/dist/batch/index.js.map +1 -1
- package/dist/bucket/index.d.ts +14 -14
- package/dist/bucket/index.js +12 -12
- package/dist/bucket/index.js.map +1 -1
- package/dist/cache/index.d.ts +11 -11
- package/dist/cache/index.js +9 -9
- package/dist/cache/index.js.map +1 -1
- package/dist/cli/{dist-Sz2EXvQX.cjs → dist-Dl9Vl7Ur.js} +17 -13
- package/dist/cli/{dist-BBPjuQ56.js.map → dist-Dl9Vl7Ur.js.map} +1 -1
- package/dist/cli/index.d.ts +31 -37
- package/dist/cli/index.js +152 -83
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +19 -19
- package/dist/command/index.js +25 -25
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +218 -218
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +232 -232
- package/dist/core/index.js +218 -218
- package/dist/core/index.js.map +1 -1
- package/dist/core/{index.cjs → index.native.js} +304 -455
- package/dist/core/index.native.js.map +1 -0
- package/dist/datetime/index.d.ts +9 -9
- package/dist/datetime/index.js +7 -7
- package/dist/datetime/index.js.map +1 -1
- package/dist/email/index.d.ts +16 -16
- package/dist/email/index.js +80 -82
- package/dist/email/index.js.map +1 -1
- package/dist/file/index.js +1 -1
- package/dist/file/index.js.map +1 -1
- package/dist/lock/index.d.ts +9 -9
- package/dist/lock/index.js +8 -8
- package/dist/lock/index.js.map +1 -1
- package/dist/lock-redis/index.js +3 -66
- package/dist/lock-redis/index.js.map +1 -1
- package/dist/logger/index.d.ts +5 -5
- package/dist/logger/index.js +8 -8
- package/dist/logger/index.js.map +1 -1
- package/dist/orm/index.browser.js +114 -114
- package/dist/orm/index.browser.js.map +1 -1
- package/dist/orm/index.d.ts +219 -219
- package/dist/orm/index.js +46 -46
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/index.d.ts +25 -25
- package/dist/queue/index.js +20 -20
- package/dist/queue/index.js.map +1 -1
- package/dist/queue-redis/index.d.ts +2 -2
- package/dist/redis/index.d.ts +10 -10
- package/dist/retry/index.d.ts +20 -20
- package/dist/retry/index.js +9 -9
- package/dist/retry/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +12 -12
- package/dist/scheduler/index.js +9 -9
- package/dist/scheduler/index.js.map +1 -1
- package/dist/security/index.d.ts +53 -53
- package/dist/security/index.js +32 -32
- package/dist/security/index.js.map +1 -1
- package/dist/server/index.browser.js +1 -1
- package/dist/server/index.browser.js.map +1 -1
- package/dist/server/index.d.ts +101 -101
- package/dist/server/index.js +17 -17
- package/dist/server/index.js.map +1 -1
- package/dist/server-auth/index.browser.js +4 -982
- package/dist/server-auth/index.browser.js.map +1 -1
- package/dist/server-auth/index.d.ts +204 -785
- package/dist/server-auth/index.js +47 -1239
- package/dist/server-auth/index.js.map +1 -1
- package/dist/server-cache/index.d.ts +10 -10
- package/dist/server-cache/index.js +2 -2
- package/dist/server-cache/index.js.map +1 -1
- package/dist/server-compress/index.d.ts +4 -4
- package/dist/server-compress/index.js +1 -1
- package/dist/server-compress/index.js.map +1 -1
- package/dist/server-cookies/index.browser.js +8 -8
- package/dist/server-cookies/index.browser.js.map +1 -1
- package/dist/server-cookies/index.d.ts +17 -17
- package/dist/server-cookies/index.js +10 -10
- package/dist/server-cookies/index.js.map +1 -1
- package/dist/server-cors/index.d.ts +17 -17
- package/dist/server-cors/index.js +9 -9
- package/dist/server-cors/index.js.map +1 -1
- package/dist/server-health/index.d.ts +2 -2
- package/dist/server-helmet/index.d.ts +1 -1
- package/dist/server-links/index.browser.js +12 -12
- package/dist/server-links/index.browser.js.map +1 -1
- package/dist/server-links/index.d.ts +59 -251
- package/dist/server-links/index.js +23 -502
- package/dist/server-links/index.js.map +1 -1
- package/dist/server-metrics/index.d.ts +4 -4
- package/dist/server-metrics/index.js +170 -174
- package/dist/server-metrics/index.js.map +1 -1
- package/dist/server-multipart/index.d.ts +2 -2
- package/dist/server-proxy/index.d.ts +12 -12
- package/dist/server-proxy/index.js +10 -10
- package/dist/server-proxy/index.js.map +1 -1
- package/dist/server-rate-limit/index.d.ts +22 -22
- package/dist/server-rate-limit/index.js +12 -12
- package/dist/server-rate-limit/index.js.map +1 -1
- package/dist/server-security/index.d.ts +24 -24
- package/dist/server-security/index.js +15 -15
- package/dist/server-security/index.js.map +1 -1
- package/dist/server-static/index.d.ts +14 -14
- package/dist/server-static/index.js +8 -8
- package/dist/server-static/index.js.map +1 -1
- package/dist/server-swagger/index.d.ts +25 -184
- package/dist/server-swagger/index.js +21 -724
- package/dist/server-swagger/index.js.map +1 -1
- package/dist/sms/index.d.ts +14 -14
- package/dist/sms/index.js +9 -9
- package/dist/sms/index.js.map +1 -1
- package/dist/thread/index.d.ts +11 -11
- package/dist/thread/index.js +17 -17
- package/dist/thread/index.js.map +1 -1
- package/dist/topic/index.d.ts +26 -26
- package/dist/topic/index.js +16 -16
- package/dist/topic/index.js.map +1 -1
- package/dist/topic-redis/index.d.ts +1 -1
- package/dist/vite/index.d.ts +3 -3
- package/dist/vite/index.js +12 -13
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js +11 -11
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.d.ts +51 -51
- package/dist/websocket/index.js +13 -13
- package/dist/websocket/index.js.map +1 -1
- package/package.json +62 -52
- package/src/api-files/services/FileService.ts +5 -7
- package/src/api-jobs/index.ts +1 -1
- package/src/api-jobs/{descriptors → primitives}/$job.ts +8 -8
- package/src/api-jobs/providers/JobProvider.ts +9 -9
- package/src/api-jobs/services/JobService.ts +5 -5
- package/src/api-notifications/index.ts +5 -15
- package/src/api-notifications/{descriptors → primitives}/$notification.ts +10 -10
- package/src/api-notifications/services/NotificationSenderService.ts +3 -3
- package/src/api-parameters/index.ts +1 -1
- package/src/api-parameters/{descriptors → primitives}/$config.ts +7 -12
- package/src/api-users/index.ts +1 -1
- package/src/api-users/{descriptors → primitives}/$userRealm.ts +8 -8
- package/src/api-users/providers/UserRealmProvider.ts +1 -1
- package/src/batch/index.ts +3 -3
- package/src/batch/{descriptors → primitives}/$batch.ts +13 -16
- package/src/bucket/index.ts +8 -8
- package/src/bucket/{descriptors → primitives}/$bucket.ts +8 -8
- package/src/bucket/providers/LocalFileStorageProvider.ts +3 -3
- package/src/cache/index.ts +4 -4
- package/src/cache/{descriptors → primitives}/$cache.ts +15 -15
- package/src/cli/apps/AlephaPackageBuilderCli.ts +30 -3
- package/src/cli/assets/appRouterTs.ts +9 -0
- package/src/cli/assets/indexHtml.ts +2 -1
- package/src/cli/assets/mainBrowserTs.ts +10 -0
- package/src/cli/commands/CoreCommands.ts +6 -5
- package/src/cli/commands/DrizzleCommands.ts +69 -61
- package/src/cli/commands/VerifyCommands.ts +2 -2
- package/src/cli/commands/ViteCommands.ts +6 -1
- package/src/cli/services/ProjectUtils.ts +78 -41
- package/src/command/index.ts +5 -5
- package/src/command/{descriptors → primitives}/$command.ts +9 -12
- package/src/command/providers/CliProvider.ts +10 -10
- package/src/core/Alepha.ts +30 -33
- package/src/core/constants/KIND.ts +1 -1
- package/src/core/constants/OPTIONS.ts +1 -1
- package/src/core/helpers/{descriptor.ts → primitive.ts} +18 -18
- package/src/core/helpers/ref.ts +1 -1
- package/src/core/index.shared.ts +8 -8
- package/src/core/{descriptors → primitives}/$context.ts +5 -5
- package/src/core/{descriptors → primitives}/$hook.ts +4 -4
- package/src/core/{descriptors → primitives}/$inject.ts +2 -2
- package/src/core/{descriptors → primitives}/$module.ts +9 -9
- package/src/core/{descriptors → primitives}/$use.ts +2 -2
- package/src/core/providers/CodecManager.ts +1 -1
- package/src/core/providers/JsonSchemaCodec.ts +1 -1
- package/src/core/providers/StateManager.ts +2 -2
- package/src/datetime/index.ts +3 -3
- package/src/datetime/{descriptors → primitives}/$interval.ts +6 -6
- package/src/email/index.ts +4 -4
- package/src/email/{descriptors → primitives}/$email.ts +8 -8
- package/src/file/index.ts +1 -1
- package/src/lock/index.ts +3 -3
- package/src/lock/{descriptors → primitives}/$lock.ts +10 -10
- package/src/logger/index.ts +8 -8
- package/src/logger/{descriptors → primitives}/$logger.ts +2 -2
- package/src/logger/services/Logger.ts +1 -1
- package/src/orm/constants/PG_SYMBOLS.ts +2 -2
- package/src/orm/index.browser.ts +2 -2
- package/src/orm/index.ts +8 -8
- package/src/orm/{descriptors → primitives}/$entity.ts +11 -11
- package/src/orm/{descriptors → primitives}/$repository.ts +2 -2
- package/src/orm/{descriptors → primitives}/$sequence.ts +8 -8
- package/src/orm/{descriptors → primitives}/$transaction.ts +4 -4
- package/src/orm/providers/DrizzleKitProvider.ts +1 -1
- package/src/orm/providers/PostgresTypeProvider.ts +3 -3
- package/src/orm/providers/RepositoryProvider.ts +4 -4
- package/src/orm/providers/drivers/DatabaseProvider.ts +7 -7
- package/src/orm/services/ModelBuilder.ts +9 -9
- package/src/orm/services/PgRelationManager.ts +2 -2
- package/src/orm/services/PostgresModelBuilder.ts +5 -5
- package/src/orm/services/Repository.ts +7 -7
- package/src/orm/services/SqliteModelBuilder.ts +5 -5
- package/src/queue/index.ts +7 -7
- package/src/queue/{descriptors → primitives}/$consumer.ts +15 -15
- package/src/queue/{descriptors → primitives}/$queue.ts +12 -12
- package/src/queue/providers/WorkerProvider.ts +7 -7
- package/src/retry/index.ts +3 -3
- package/src/retry/{descriptors → primitives}/$retry.ts +19 -17
- package/src/scheduler/index.ts +3 -3
- package/src/scheduler/{descriptors → primitives}/$scheduler.ts +9 -9
- package/src/scheduler/providers/CronProvider.ts +1 -1
- package/src/security/index.ts +9 -9
- package/src/security/{descriptors → primitives}/$permission.ts +7 -7
- package/src/security/{descriptors → primitives}/$realm.ts +6 -12
- package/src/security/{descriptors → primitives}/$role.ts +12 -12
- package/src/security/{descriptors → primitives}/$serviceAccount.ts +8 -8
- package/src/server/index.browser.ts +1 -1
- package/src/server/index.ts +14 -14
- package/src/server/{descriptors → primitives}/$action.ts +13 -13
- package/src/server/{descriptors → primitives}/$route.ts +9 -9
- package/src/server/providers/NodeHttpServerProvider.ts +2 -2
- package/src/server/services/HttpClient.ts +1 -1
- package/src/server-auth/index.browser.ts +1 -1
- package/src/server-auth/index.ts +6 -6
- package/src/server-auth/{descriptors → primitives}/$auth.ts +10 -10
- package/src/server-auth/{descriptors → primitives}/$authCredentials.ts +4 -4
- package/src/server-auth/{descriptors → primitives}/$authGithub.ts +4 -4
- package/src/server-auth/{descriptors → primitives}/$authGoogle.ts +4 -4
- package/src/server-auth/providers/ServerAuthProvider.ts +4 -4
- package/src/server-cache/providers/ServerCacheProvider.ts +7 -7
- package/src/server-compress/providers/ServerCompressProvider.ts +3 -3
- package/src/server-cookies/index.browser.ts +2 -2
- package/src/server-cookies/index.ts +5 -5
- package/src/server-cookies/{descriptors → primitives}/$cookie.browser.ts +12 -12
- package/src/server-cookies/{descriptors → primitives}/$cookie.ts +13 -13
- package/src/server-cookies/providers/ServerCookiesProvider.ts +4 -4
- package/src/server-cookies/services/CookieParser.ts +1 -1
- package/src/server-cors/index.ts +3 -3
- package/src/server-cors/{descriptors → primitives}/$cors.ts +11 -13
- package/src/server-cors/providers/ServerCorsProvider.ts +5 -5
- package/src/server-links/index.browser.ts +5 -5
- package/src/server-links/index.ts +9 -9
- package/src/server-links/{descriptors → primitives}/$remote.ts +11 -11
- package/src/server-links/providers/LinkProvider.ts +7 -7
- package/src/server-links/providers/{RemoteDescriptorProvider.ts → RemotePrimitiveProvider.ts} +6 -6
- package/src/server-links/providers/ServerLinksProvider.ts +3 -3
- package/src/server-proxy/index.ts +3 -3
- package/src/server-proxy/{descriptors → primitives}/$proxy.ts +8 -8
- package/src/server-proxy/providers/ServerProxyProvider.ts +4 -4
- package/src/server-rate-limit/index.ts +6 -6
- package/src/server-rate-limit/{descriptors → primitives}/$rateLimit.ts +13 -13
- package/src/server-rate-limit/providers/ServerRateLimitProvider.ts +5 -5
- package/src/server-security/index.ts +3 -3
- package/src/server-security/{descriptors → primitives}/$basicAuth.ts +13 -13
- package/src/server-security/providers/ServerBasicAuthProvider.ts +5 -5
- package/src/server-security/providers/ServerSecurityProvider.ts +4 -4
- package/src/server-static/index.ts +3 -3
- package/src/server-static/{descriptors → primitives}/$serve.ts +8 -10
- package/src/server-static/providers/ServerStaticProvider.ts +6 -6
- package/src/server-swagger/index.ts +5 -5
- package/src/server-swagger/{descriptors → primitives}/$swagger.ts +9 -9
- package/src/server-swagger/providers/ServerSwaggerProvider.ts +11 -10
- package/src/sms/index.ts +4 -4
- package/src/sms/{descriptors → primitives}/$sms.ts +8 -8
- package/src/thread/index.ts +3 -3
- package/src/thread/{descriptors → primitives}/$thread.ts +13 -13
- package/src/thread/providers/ThreadProvider.ts +7 -9
- package/src/topic/index.ts +5 -5
- package/src/topic/{descriptors → primitives}/$subscriber.ts +14 -14
- package/src/topic/{descriptors → primitives}/$topic.ts +10 -10
- package/src/topic/providers/TopicProvider.ts +4 -4
- package/src/vite/helpers/boot.ts +3 -3
- package/src/vite/tasks/copyAssets.ts +1 -1
- package/src/vite/tasks/generateSitemap.ts +3 -3
- package/src/vite/tasks/prerenderPages.ts +2 -2
- package/src/vite/tasks/runAlepha.ts +2 -2
- package/src/websocket/index.browser.ts +3 -3
- package/src/websocket/index.shared.ts +2 -2
- package/src/websocket/index.ts +4 -4
- package/src/websocket/interfaces/WebSocketInterfaces.ts +3 -3
- package/src/websocket/{descriptors → primitives}/$channel.ts +10 -10
- package/src/websocket/{descriptors → primitives}/$websocket.ts +8 -8
- package/src/websocket/providers/NodeWebSocketServerProvider.ts +7 -7
- package/src/websocket/providers/WebSocketServerProvider.ts +3 -3
- package/src/websocket/services/WebSocketClient.ts +5 -5
- package/dist/api-files/index.cjs +0 -1293
- package/dist/api-files/index.cjs.map +0 -1
- package/dist/api-files/index.d.cts +0 -829
- package/dist/api-jobs/index.cjs +0 -274
- package/dist/api-jobs/index.cjs.map +0 -1
- package/dist/api-jobs/index.d.cts +0 -654
- package/dist/api-notifications/index.cjs +0 -380
- package/dist/api-notifications/index.cjs.map +0 -1
- package/dist/api-notifications/index.d.cts +0 -289
- package/dist/api-parameters/index.cjs +0 -66
- package/dist/api-parameters/index.cjs.map +0 -1
- package/dist/api-parameters/index.d.cts +0 -84
- package/dist/api-users/index.cjs +0 -6009
- package/dist/api-users/index.cjs.map +0 -1
- package/dist/api-users/index.d.cts +0 -4740
- package/dist/api-verifications/index.cjs +0 -407
- package/dist/api-verifications/index.cjs.map +0 -1
- package/dist/api-verifications/index.d.cts +0 -207
- package/dist/batch/index.cjs +0 -408
- package/dist/batch/index.cjs.map +0 -1
- package/dist/batch/index.d.cts +0 -330
- package/dist/bin/index.cjs +0 -17
- package/dist/bin/index.cjs.map +0 -1
- package/dist/bin/index.d.cts +0 -1
- package/dist/bucket/index.cjs +0 -303
- package/dist/bucket/index.cjs.map +0 -1
- package/dist/bucket/index.d.cts +0 -355
- package/dist/cache/index.cjs +0 -241
- package/dist/cache/index.cjs.map +0 -1
- package/dist/cache/index.d.cts +0 -202
- package/dist/cache-redis/index.cjs +0 -84
- package/dist/cache-redis/index.cjs.map +0 -1
- package/dist/cache-redis/index.d.cts +0 -40
- package/dist/cli/chunk-DSlc6foC.cjs +0 -43
- package/dist/cli/dist-BBPjuQ56.js +0 -2778
- package/dist/cli/dist-Sz2EXvQX.cjs.map +0 -1
- package/dist/cli/index.cjs +0 -1241
- package/dist/cli/index.cjs.map +0 -1
- package/dist/cli/index.d.cts +0 -422
- package/dist/command/index.cjs +0 -693
- package/dist/command/index.cjs.map +0 -1
- package/dist/command/index.d.cts +0 -340
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.d.cts +0 -1927
- package/dist/datetime/index.cjs +0 -318
- package/dist/datetime/index.cjs.map +0 -1
- package/dist/datetime/index.d.cts +0 -145
- package/dist/email/index.cjs +0 -10874
- package/dist/email/index.cjs.map +0 -1
- package/dist/email/index.d.cts +0 -186
- package/dist/fake/index.cjs +0 -34641
- package/dist/fake/index.cjs.map +0 -1
- package/dist/fake/index.d.cts +0 -74
- package/dist/file/index.cjs +0 -1212
- package/dist/file/index.cjs.map +0 -1
- package/dist/file/index.d.cts +0 -698
- package/dist/lock/index.cjs +0 -226
- package/dist/lock/index.cjs.map +0 -1
- package/dist/lock/index.d.cts +0 -361
- package/dist/lock-redis/index.cjs +0 -113
- package/dist/lock-redis/index.cjs.map +0 -1
- package/dist/lock-redis/index.d.cts +0 -24
- package/dist/logger/index.cjs +0 -521
- package/dist/logger/index.cjs.map +0 -1
- package/dist/logger/index.d.cts +0 -281
- package/dist/orm/index.cjs +0 -2986
- package/dist/orm/index.cjs.map +0 -1
- package/dist/orm/index.d.cts +0 -2213
- package/dist/queue/index.cjs +0 -1044
- package/dist/queue/index.cjs.map +0 -1
- package/dist/queue/index.d.cts +0 -1265
- package/dist/queue-redis/index.cjs +0 -873
- package/dist/queue-redis/index.cjs.map +0 -1
- package/dist/queue-redis/index.d.cts +0 -82
- package/dist/redis/index.cjs +0 -153
- package/dist/redis/index.cjs.map +0 -1
- package/dist/redis/index.d.cts +0 -82
- package/dist/retry/index.cjs +0 -146
- package/dist/retry/index.cjs.map +0 -1
- package/dist/retry/index.d.cts +0 -172
- package/dist/router/index.cjs +0 -111
- package/dist/router/index.cjs.map +0 -1
- package/dist/router/index.d.cts +0 -46
- package/dist/scheduler/index.cjs +0 -576
- package/dist/scheduler/index.cjs.map +0 -1
- package/dist/scheduler/index.d.cts +0 -145
- package/dist/security/index.cjs +0 -2402
- package/dist/security/index.cjs.map +0 -1
- package/dist/security/index.d.cts +0 -598
- package/dist/server/index.cjs +0 -1680
- package/dist/server/index.cjs.map +0 -1
- package/dist/server/index.d.cts +0 -810
- package/dist/server-auth/index.cjs +0 -3146
- package/dist/server-auth/index.cjs.map +0 -1
- package/dist/server-auth/index.d.cts +0 -1164
- package/dist/server-cache/index.cjs +0 -252
- package/dist/server-cache/index.cjs.map +0 -1
- package/dist/server-cache/index.d.cts +0 -164
- package/dist/server-compress/index.cjs +0 -141
- package/dist/server-compress/index.cjs.map +0 -1
- package/dist/server-compress/index.d.cts +0 -38
- package/dist/server-cookies/index.cjs +0 -234
- package/dist/server-cookies/index.cjs.map +0 -1
- package/dist/server-cookies/index.d.cts +0 -144
- package/dist/server-cors/index.cjs +0 -201
- package/dist/server-cors/index.cjs.map +0 -1
- package/dist/server-cors/index.d.cts +0 -140
- package/dist/server-health/index.cjs +0 -62
- package/dist/server-health/index.cjs.map +0 -1
- package/dist/server-health/index.d.cts +0 -58
- package/dist/server-helmet/index.cjs +0 -131
- package/dist/server-helmet/index.cjs.map +0 -1
- package/dist/server-helmet/index.d.cts +0 -97
- package/dist/server-links/index.cjs +0 -992
- package/dist/server-links/index.cjs.map +0 -1
- package/dist/server-links/index.d.cts +0 -513
- package/dist/server-metrics/index.cjs +0 -4535
- package/dist/server-metrics/index.cjs.map +0 -1
- package/dist/server-metrics/index.d.cts +0 -35
- package/dist/server-multipart/index.cjs +0 -237
- package/dist/server-multipart/index.cjs.map +0 -1
- package/dist/server-multipart/index.d.cts +0 -50
- package/dist/server-proxy/index.cjs +0 -186
- package/dist/server-proxy/index.cjs.map +0 -1
- package/dist/server-proxy/index.d.cts +0 -234
- package/dist/server-rate-limit/index.cjs +0 -241
- package/dist/server-rate-limit/index.cjs.map +0 -1
- package/dist/server-rate-limit/index.d.cts +0 -183
- package/dist/server-security/index.cjs +0 -316
- package/dist/server-security/index.cjs.map +0 -1
- package/dist/server-security/index.d.cts +0 -173
- package/dist/server-static/index.cjs +0 -170
- package/dist/server-static/index.cjs.map +0 -1
- package/dist/server-static/index.d.cts +0 -121
- package/dist/server-swagger/index.cjs +0 -1021
- package/dist/server-swagger/index.cjs.map +0 -1
- package/dist/server-swagger/index.d.cts +0 -382
- package/dist/sms/index.cjs +0 -221
- package/dist/sms/index.cjs.map +0 -1
- package/dist/sms/index.d.cts +0 -130
- package/dist/thread/index.cjs +0 -350
- package/dist/thread/index.cjs.map +0 -1
- package/dist/thread/index.d.cts +0 -260
- package/dist/topic/index.cjs +0 -282
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.d.cts +0 -523
- package/dist/topic-redis/index.cjs +0 -71
- package/dist/topic-redis/index.cjs.map +0 -1
- package/dist/topic-redis/index.d.cts +0 -42
- package/dist/vite/index.cjs +0 -1077
- package/dist/vite/index.cjs.map +0 -1
- package/dist/vite/index.d.cts +0 -542
- package/dist/websocket/index.cjs +0 -1117
- package/dist/websocket/index.cjs.map +0 -1
- package/dist/websocket/index.d.cts +0 -861
- package/src/api-notifications/providers/MemorySmsProvider.ts +0 -20
- package/src/api-notifications/providers/SmsProvider.ts +0 -8
- /package/src/core/{descriptors → primitives}/$atom.ts +0 -0
- /package/src/core/{descriptors → primitives}/$env.ts +0 -0
- /package/src/server-auth/{descriptors → primitives}/$authApple.ts +0 -0
- /package/src/server-links/{descriptors → primitives}/$client.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.browser.js","names":["KIND: unique symbol","MODULE: unique symbol","OPTIONS: unique symbol","__alephaRef: {\n alepha?: Alepha;\n service?: Service & {\n [MODULE]?: Service;\n };\n parent?: Service;\n}","error: any","obj: any","ctx: any","atoms: Array<AtomWithValue>","entry: ServiceEntry<T>","instance: T","definition: ServiceDefinition<T>","parent","graph: Record<\n string,\n { from: string[]; as?: string[]; module?: string }\n >","list: Array<T>","t: TypeProvider"],"sources":["../../src/core/constants/KIND.ts","../../src/core/constants/MODULE.ts","../../src/core/constants/OPTIONS.ts","../../src/core/errors/AlephaError.ts","../../src/core/descriptors/$module.ts","../../src/core/errors/CircularDependencyError.ts","../../src/core/errors/ContainerLockedError.ts","../../src/core/errors/TooLateSubstitutionError.ts","../../src/core/errors/MissingContextError.ts","../../src/core/helpers/ref.ts","../../src/core/descriptors/$context.ts","../../src/core/helpers/descriptor.ts","../../src/core/interfaces/Service.ts","../../src/core/providers/AlsProvider.ts","../../src/core/descriptors/$inject.ts","../../src/core/providers/Json.ts","../../src/core/providers/SchemaCodec.ts","../../src/core/providers/JsonSchemaCodec.ts","../../src/core/errors/TypeBoxError.ts","../../src/core/providers/SchemaValidator.ts","../../src/core/providers/CodecManager.ts","../../src/core/providers/EventManager.ts","../../src/core/descriptors/$atom.ts","../../src/core/providers/StateManager.ts","../../src/core/Alepha.ts","../../src/core/helpers/FileLike.ts","../../src/core/providers/TypeProvider.ts","../../src/core/descriptors/$env.ts","../../src/core/descriptors/$hook.ts","../../src/core/descriptors/$use.ts","../../src/core/errors/AppNotStartedError.ts","../../src/core/helpers/createPagination.ts","../../src/core/schemas/pageQuerySchema.ts","../../src/core/schemas/pageSchema.ts","../../src/core/index.browser.ts"],"sourcesContent":["/**\n * Used for identifying descriptors.\n *\n * @internal\n */\nexport const KIND: unique symbol = Symbol.for(\"Alepha.Kind\");\n","/**\n * Used for identifying modules.\n *\n * @internal\n */\nexport const MODULE: unique symbol = Symbol.for(\"Alepha.Module\");\n","/**\n * Used for descriptors options.\n *\n * @internal\n */\nexport const OPTIONS: unique symbol = Symbol.for(\"Alepha.Options\");\n","// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Default error class for Alepha.\n */\nexport class AlephaError extends Error {\n name = \"AlephaError\";\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n","import type { Alepha } from \"../Alepha.ts\";\nimport { KIND } from \"../constants/KIND.ts\";\nimport { MODULE } from \"../constants/MODULE.ts\";\nimport { AlephaError } from \"../errors/AlephaError.ts\";\nimport type { DescriptorFactoryLike } from \"../helpers/descriptor.ts\";\nimport type { Service } from \"../interfaces/Service.ts\";\n\n/**\n * Wrap Services and Descriptors into a Module.\n *\n * - A module is just a Service with some extra {@link Module}.\n * - You must attach a `name` to it.\n * - Name must follow the pattern: `project.module.submodule`. (e.g. `myapp.users.auth`).\n *\n * @example\n * ```ts\n * import { $module } from \"alepha\";\n * import { MyService } from \"./MyService.ts\";\n *\n * // export MyService, so it can be used everywhere (optional)\n * export * from \"./MyService.ts\";\n *\n * export default $module({\n * name: \"my.project.module\",\n * // MyService will have a module context \"my.project.module\"\n * services: [MyService],\n * });\n * ```\n *\n * ### Why Modules?\n *\n * #### Logging\n *\n * By default, AlephaLogger will log the module name in the logs.\n * This helps to identify where the logs are coming from.\n *\n * You can also set different log levels for different modules.\n * It means you can set 'some.very.specific.module' to 'debug' and keep the rest of the application to 'info'.\n *\n * #### Modulith\n *\n * Force to structure your application in modules, even if it's a single deployable unit.\n * It helps to keep a clean architecture and avoid monolithic applications.\n *\n * A strict mode flag will probably come to enforce module boundaries.\n * -> Throwing errors when a service from another module is injected.\n * But it's not implemented yet.\n *\n * ### When not to use Modules?\n *\n * Small applications does not need modules. It's better to keep it simple.\n * Modules are more useful when the application grows and needs to be structured.\n * If we speak with number of `$actions`, a module should be used when you have more than 30 actions in a single module.\n * Meaning that if you have 100 actions, you should have at least 3 modules.\n */\nexport const $module = <T extends object = {}>(\n options: ModuleDescriptorOptions,\n): Service<Module> => {\n const { services = [], descriptors = [], name } = options;\n\n // ensure name is valid\n if (!name || !Module.NAME_REGEX.test(name)) {\n throw new AlephaError(\n `Invalid module name '${name}'. It should be in the format of 'project.module.submodule'`,\n );\n }\n\n const $ = class extends Module {\n options = options;\n\n register(alepha: Alepha): void {\n if (typeof options.register === \"function\") {\n options.register(alepha);\n return;\n }\n\n for (const service of services) {\n alepha.inject(service, {\n parent: this.constructor as Service<Module>,\n });\n }\n }\n };\n\n // force name property\n Object.defineProperty($, \"name\", {\n value: name,\n writable: false,\n });\n\n for (const service of services) {\n if (!Module.is(service)) {\n (service as WithModule)[MODULE] = $;\n }\n }\n\n for (const factory of descriptors) {\n if (typeof factory[KIND] === \"function\") {\n factory[KIND][MODULE] = $;\n }\n }\n\n return $; // module as Service<Module<T>>;\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface ModuleDescriptorOptions {\n /**\n * Name of the module.\n *\n * It should be in the format of `project.module.submodule`.\n */\n name: string;\n\n /**\n * List all services related to this module.\n *\n * If you don't declare 'register' function, all services will be registered automatically.\n * If you declare 'register' function, you must handle the registration of ALL services manually.\n */\n services?: Array<Service>;\n\n /**\n * List of $descriptors to register in the module.\n */\n descriptors?: Array<DescriptorFactoryLike>;\n\n /**\n * By default, module will register ALL services.\n * You can override this behavior by providing a register function.\n * It's useful when you want to register services conditionally or in a specific order.\n *\n * Again, if you declare 'register', you must handle the registration of ALL services manually.\n */\n register?: (alepha: Alepha) => void;\n}\n\n/**\n * Base class for all modules.\n */\nexport abstract class Module {\n public abstract readonly options: ModuleDescriptorOptions;\n\n public abstract register(alepha: Alepha): void;\n\n static NAME_REGEX = /^[a-z]+(\\.[a-z][a-z0-9-]*)*$/;\n\n /**\n * Check if a Service is a Module.\n */\n static is(ctor: Service): boolean {\n return ctor.prototype instanceof Module;\n }\n\n /**\n * Get the Module of a Service.\n *\n * Returns undefined if the Service is not part of a Module.\n */\n static of(ctor: Service): Service<Module> | undefined {\n return (ctor as WithModule)[MODULE];\n }\n}\n\n/**\n * Helper type to add Module metadata to a Service.\n */\nexport type WithModule<T extends object = any> = T & {\n [MODULE]?: Service;\n};\n","import { AlephaError } from \"./AlephaError.ts\";\n\nexport class CircularDependencyError extends AlephaError {\n readonly name = \"CircularDependencyError\";\n\n constructor(provider: string, parents?: string[]) {\n super(\n `Instance not available. Looks like a circular dependency. ? -> ${parents?.map((name) => `${name} -> `).join(\"\")}${provider} -> ?`,\n );\n }\n}\n","import { AlephaError } from \"./AlephaError.ts\";\n\nexport class ContainerLockedError extends AlephaError {\n readonly name = \"ContainerLockedError\";\n\n constructor(\n message = \"Container is locked. No more providers can be added.\",\n ) {\n super(message);\n }\n}\n","import { AlephaError } from \"./AlephaError.ts\";\n\nexport class TooLateSubstitutionError extends AlephaError {\n readonly name = \"TooLateSubstitutionError\";\n\n constructor(original: string, substitution: string) {\n super(\n `Service already substituted. Please, substitute Service '${original}' with Service '${substitution}' before using it.`,\n );\n }\n}\n","import { AlephaError } from \"./AlephaError.ts\";\n\nexport class MissingContextError extends AlephaError {\n readonly name = \"MissingContextError\";\n\n constructor() {\n super(\"Missing context. Did you forget to call Alepha.create()?\");\n this.name = \"MissingContextError\";\n }\n}\n","import type { Alepha } from \"../Alepha.ts\";\nimport { MODULE } from \"../constants/MODULE.ts\";\nimport type { Service } from \"../interfaces/Service.ts\";\n\n/**\n * Store the current context and definition during injection phase.\n *\n * @internal\n */\nexport const __alephaRef: {\n alepha?: Alepha;\n service?: Service & {\n [MODULE]?: Service;\n };\n parent?: Service;\n} = {};\n\n/**\n * Note:\n *\n * This file is used to share context between $descriptors and the Alepha core during the injection phase.\n *\n * There is no side effect as long as Alepha is not used concurrently in multiple contexts (which is not the case).\n *\n * // __alephaRef === undefined\n * // begin alepha.with()\n * // __alephaRef.context = alepha\n * // ... injection phase ...\n * // __alephaRef.context = undefined\n * // end alepha.with()\n * // __alephaRef === undefined\n *\n * As .with() is synchronous, there is no risk of context leakage.\n *\n * ---------------------------------------------------------------------------------------------------------------------\n *\n * Why this helper?\n *\n * It allows to avoid passing Alepha instance to every $hook, $inject, etc. calls. It's a beautiful syntactic sugar.\n *\n * With sugar:\n *\n * class A {\n * on = $hook( ... ) // <- __alephaRef is set here\n * }\n *\n * Without sugar:\n *\n * class A {\n * constructor(alepha: Alepha) {\n * this.on = $hook(alepha, ... ) // <- no need of __alephaRef\n * }\n * }\n *\n * One main goal of Alepha is working with classes but without the class verbosity.\n * Forcing to pass Alepha instance in constructors would be a step back in that direction!\n */\n","import type { Alepha } from \"../Alepha.ts\";\nimport { MODULE } from \"../constants/MODULE.ts\";\nimport { MissingContextError } from \"../errors/MissingContextError.ts\";\nimport { __alephaRef } from \"../helpers/ref.ts\";\nimport type { Service } from \"../interfaces/Service.ts\";\n\n/**\n * Get Alepha instance and current service from the current context.\n *\n * It can only be used inside $descriptor functions.\n *\n * ```ts\n * import { $context } from \"alepha\";\n *\n * const $hello = () => {\n * const { alepha, service, module } = $context();\n *\n * // alepha - alepha instance\n * // service - class which is creating this descriptor, this is NOT the instance but the service definition\n * // module - module definition, if any\n *\n * return {};\n * }\n *\n * class MyService {\n * hello = $hello();\n * }\n *\n * const alepha = new Alepha().with(MyService);\n * ```\n *\n * @internal\n */\nexport const $context = (): ContextDescriptor => {\n if (!__alephaRef.alepha) {\n throw new MissingContextError();\n }\n\n return {\n alepha: __alephaRef.alepha,\n service: __alephaRef.service,\n module: __alephaRef.service?.[MODULE],\n };\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface ContextDescriptor {\n /**\n * Alepha instance.\n */\n alepha: Alepha;\n /**\n * Service definition which is creating this descriptor.\n * This is NOT the instance but the service definition.\n */\n service?: Service;\n /**\n * Module definition, if any.\n */\n module?: Service;\n}\n","import { Alepha } from \"../Alepha.ts\";\nimport { KIND } from \"../constants/KIND.ts\";\nimport { MODULE } from \"../constants/MODULE.ts\";\nimport { $context } from \"../descriptors/$context.ts\";\nimport type { InstantiableClass, Service } from \"../interfaces/Service.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface DescriptorArgs<T extends object = {}> {\n options: T;\n alepha: Alepha;\n service: InstantiableClass<Service>;\n module?: Service;\n}\n\nexport interface DescriptorConfig {\n propertyKey: string;\n service: InstantiableClass<Service>;\n module?: Service;\n}\n\nexport abstract class Descriptor<T extends object = {}> {\n protected readonly alepha: Alepha;\n\n public readonly options: T;\n public readonly config: DescriptorConfig;\n\n constructor(args: DescriptorArgs<T>) {\n this.alepha = args.alepha;\n this.options = args.options;\n this.config = {\n propertyKey: \"\",\n service: args.service,\n module: args.module,\n };\n }\n\n /**\n * Called automatically by Alepha after the descriptor is created.\n */\n protected onInit(): void {\n // this method can be overridden by subclasses to perform initialization logic.\n // - use onInit instead of the constructor when you need to access `config.propertyKey`\n // - onInit must be synchronous\n }\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport type DescriptorFactory<TDescriptor extends Descriptor = Descriptor> = {\n (options: TDescriptor[\"options\"]): TDescriptor;\n [KIND]: InstantiableClass<TDescriptor>;\n};\n\nexport type DescriptorFactoryLike<T extends object = any> = {\n (options: T): any;\n [KIND]: any;\n};\n\nexport const createDescriptor = <TDescriptor extends Descriptor>(\n descriptor: InstantiableClass<TDescriptor> & { [MODULE]?: Service },\n options: TDescriptor[\"options\"],\n): TDescriptor => {\n const { alepha, service } = $context();\n\n if (MODULE in descriptor && descriptor[MODULE]) {\n alepha.with(descriptor[MODULE]);\n }\n\n return alepha.inject(descriptor, {\n lifetime: \"transient\",\n args: [\n {\n options,\n alepha: alepha,\n service: service ?? Alepha,\n },\n ],\n });\n};\n","// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * In Alepha, a service is a class that can be instantiated or an abstract class. Nothing more, nothing less...\n */\nexport type Service<T extends object = any> =\n | InstantiableClass<T>\n | AbstractClass<T>\n | RunFunction<T>;\n\nexport type RunFunction<T extends object = any> = (...args: any[]) => T | void;\n\nexport type InstantiableClass<T extends object = any> = new (\n ...args: any[]\n) => T;\n\n/**\n * Abstract class is a class that cannot be instantiated directly!\n * It widely used for defining interfaces.\n */\nexport type AbstractClass<T extends object = any> = abstract new (\n ...args: any[]\n) => T;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Service substitution allows you to register a class as a different class.\n * Providing class A, but using class B instead.\n * This is useful for testing, mocking, or providing a different implementation of a service.\n *\n * class A is mostly an AbstractClass, while class B is an InstantiableClass.\n */\nexport interface ServiceSubstitution<T extends object = any> {\n /**\n * Every time someone asks for this class, it will be provided with the 'use' class.\n */\n provide: Service<T>;\n\n /**\n * Service to use instead of the 'provide' service.\n *\n * Syntax is inspired by Angular's DI system.\n */\n use: Service<T>;\n\n /**\n * If true, if the service already exists -> just ignore the substitution and do not throw an error.\n * Mostly used for plugins to enforce a substitution without throwing an error.\n */\n optional?: boolean;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Every time you register a service, you can use this type to define it.\n *\n * alepha.with( ServiceEntry )\n * or\n * alepha.with( provide: ServiceEntry, use: MyOwnServiceEntry )\n *\n * And yes, you declare the *type* of the service, not the *instance*.\n */\nexport type ServiceEntry<T extends object = any> =\n | Service<T>\n | ServiceSubstitution<T>;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport function isClass(func: any): func is InstantiableClass {\n // Classes have a non-writable prototype.constructor\n if (typeof func !== \"function\") return false;\n\n const descriptor = Object.getOwnPropertyDescriptor(func, \"prototype\");\n return !!descriptor && !descriptor.writable;\n}\n","import type { AsyncLocalStorage } from \"node:async_hooks\";\n\nexport type AsyncLocalStorageData = any;\n\nexport class AlsProvider {\n static create = (): AsyncLocalStorage<AsyncLocalStorageData> | undefined => {\n return undefined;\n };\n\n public als?: AsyncLocalStorage<AsyncLocalStorageData>;\n\n constructor() {\n this.als = AlsProvider.create();\n }\n\n public createContextId(): string {\n return crypto.randomUUID();\n }\n\n public run<R>(callback: () => R, data: Record<string, any> = {}): R {\n if (!this.als) {\n return callback();\n }\n\n data.registry ??= new Map();\n data.context ??= this.createContextId();\n\n return this.als.run(data, callback);\n }\n\n public exists(): boolean {\n return !!this.get(\"context\");\n }\n\n public get<T>(key: string): T | undefined {\n if (!this.als) {\n return undefined;\n }\n\n const store = this.als.getStore();\n if (store) {\n return store[key] as T;\n }\n\n return undefined;\n }\n\n public set<T>(key: string, value: T): void {\n if (!this.als) {\n return;\n }\n\n const store = this.als.getStore();\n if (store) {\n store[key] = value;\n }\n }\n}\n","import { Descriptor } from \"../helpers/descriptor.ts\";\nimport type { InstantiableClass, Service } from \"../interfaces/Service.ts\";\nimport { $context } from \"./$context.ts\";\n\n/**\n * Get the instance of the specified type from the context.\n *\n * ```ts\n * class A { }\n * class B {\n * a = $inject(A);\n * }\n * ```\n */\nexport const $inject = <T extends object>(\n type: Service<T>,\n opts: InjectOptions<T> = {},\n): T => {\n const { alepha, service } = $context();\n\n // _ = $inject(Alepha)\n if (type === alepha.constructor) {\n return alepha as T;\n }\n\n return alepha.inject(type, {\n // keep the parent for better error messages and circular dependencies detection\n parent: service ?? (alepha.constructor as Service),\n ...opts,\n });\n};\n\nexport class InjectDescriptor extends Descriptor {}\n\nexport interface InjectOptions<T extends object = any> {\n /**\n * - 'transient' → Always a new instance on every inject. Zero caching.\n * - 'singleton' → One instance per Alepha runtime (per-thread). Never disposed until Alepha shuts down. (default)\n * - 'scoped' → One instance per AsyncLocalStorage context.\n * - A new scope is created when Alepha handles a request, a scheduled job, a queue worker task...\n * - You can also start a manual scope via alepha.context.run(() => { ... }).\n * - When the scope ends, the scoped registry is discarded.\n *\n * @default \"singleton\"\n */\n lifetime?: \"transient\" | \"singleton\" | \"scoped\";\n\n /**\n * Constructor arguments to pass when creating a new instance.\n */\n args?: ConstructorParameters<InstantiableClass<T>>;\n\n /**\n * Parent that requested the instance.\n *\n * @internal\n */\n parent?: Service | null;\n}\n","/**\n * Mimics the JSON global object with stringify and parse methods.\n *\n * Used across the codebase via dependency injection.\n */\nexport class Json {\n public stringify(\n value: any,\n replacer?: (this: any, key: string, value: any) => any,\n space?: string | number,\n ): string {\n return JSON.stringify(value, replacer, space);\n }\n\n public parse(\n text: string,\n reviver?: (this: any, key: string, value: any) => any,\n ) {\n return JSON.parse(text, reviver);\n }\n}\n","import type { Static, TSchema } from \"./TypeProvider.ts\";\n\nexport abstract class SchemaCodec {\n /**\n * Encode the value to a string format.\n */\n public abstract encodeToString<T extends TSchema>(\n schema: T,\n value: Static<T>,\n ): string;\n\n /**\n * Encode the value to a binary format.\n */\n public abstract encodeToBinary<T extends TSchema>(\n schema: T,\n value: Static<T>,\n ): Uint8Array;\n\n /**\n * Decode string, binary, or other formats to the schema type.\n */\n public abstract decode<T>(schema: TSchema, value: unknown): T;\n}\n","import type { TSchema } from \"typebox\";\nimport { $inject } from \"../descriptors/$inject.ts\";\nimport { Json } from \"./Json.ts\";\nimport { SchemaCodec } from \"./SchemaCodec.ts\";\nimport type { Static } from \"./TypeProvider.ts\";\n\nexport class JsonSchemaCodec extends SchemaCodec {\n protected readonly json = $inject(Json);\n protected readonly encoder = new TextEncoder();\n protected readonly decoder = new TextDecoder();\n\n public encodeToString<T extends TSchema>(\n schema: T,\n value: Static<T>,\n ): string {\n return this.json.stringify(value);\n }\n\n public encodeToBinary<T extends TSchema>(\n schema: T,\n value: Static<T>,\n ): Uint8Array {\n return this.encoder.encode(this.encodeToString(schema, value));\n }\n\n public decode<T>(schema: TSchema, value: unknown): T {\n if (value instanceof Uint8Array) {\n const text = this.decoder.decode(value);\n return this.json.parse(text);\n }\n\n if (typeof value === \"string\") {\n // Only parse if it looks like JSON (starts with { or [)\n const trimmed = value.trim();\n if (trimmed.startsWith(\"{\") || trimmed.startsWith(\"[\")) {\n return this.json.parse(value);\n }\n // Return plain strings as-is\n return value as T;\n }\n\n return value as T;\n }\n}\n","import type { TLocalizedValidationError } from \"typebox/error\";\nimport { AlephaError } from \"./AlephaError.ts\";\n\nexport class TypeBoxError extends AlephaError {\n name = \"TypeBoxError\";\n\n public readonly cause: TLocalizedValidationError;\n public readonly value: {\n path: string;\n message: string;\n };\n\n constructor(error: TLocalizedValidationError) {\n super(\n `Invalid input: ${error.message}${error.instancePath ? ` at ${error.instancePath}` : \"\"}`,\n {\n cause: error,\n },\n );\n const params = error.params as TypeBoxErrorParams;\n if (params?.requiredProperties) {\n this.value = {\n path: `/${params.requiredProperties[0]}`,\n message: \"must be defined\",\n };\n } else {\n this.value = {\n path: error.instancePath,\n message: error.message,\n };\n }\n\n this.cause = error;\n }\n}\n\nexport interface TypeBoxErrorParams {\n requiredProperties?: string[];\n}\n","import type { TSchema } from \"typebox\";\nimport { Compile, type Validator } from \"typebox/compile\";\nimport { TypeBoxError } from \"../errors/TypeBoxError.ts\";\nimport type { Static } from \"./TypeProvider.ts\";\n\nexport class SchemaValidator {\n protected cache = new Map<TSchema, Validator>();\n\n /**\n * Validate the value against the provided schema.\n *\n * Validation create a new value by applying some preprocessing. (e.g., trimming text)\n */\n public validate<T extends TSchema>(\n schema: T,\n value: unknown,\n options: ValidateOptions = {},\n ): Static<T> {\n const newValue = this.beforeParse(schema, value, {\n trim: options.trim ?? true,\n nullToUndefined: options.nullToUndefined ?? true,\n deleteUndefined: options.deleteUndefined ?? true,\n });\n\n try {\n return this.getValidator(schema).Parse(newValue);\n } catch (error: any) {\n if (error.cause?.errors?.[0]) {\n throw new TypeBoxError(error.cause.errors[0]);\n }\n throw error;\n }\n }\n\n protected getValidator<T extends TSchema>(schema: T): Validator<{}, T> {\n if (this.cache.has(schema)) {\n return this.cache.get(schema) as Validator<{}, T>;\n }\n\n const validator = Compile(schema);\n this.cache.set(schema, validator);\n return validator as Validator<{}, T>;\n }\n\n /**\n * Preprocess the value based on the schema before validation.\n *\n * - If the value is `null` and the schema does not allow `null`, it converts it to `undefined`.\n * - If the value is a string and the schema has a `~options.trim` flag, it trims whitespace from the string.\n */\n public beforeParse(schema: any, value: any, options: ValidateOptions): any {\n if (!schema) {\n return value;\n }\n\n if (\n value === null &&\n !this.isSchemaNullable(schema) &&\n options.nullToUndefined\n ) {\n return undefined;\n }\n\n if (Array.isArray(value)) {\n return value.map((it) => this.beforeParse(schema.items, it, options));\n }\n\n if (typeof value === \"string\" && schema.type === \"string\") {\n let str = value;\n\n if (options.trim && schema[\"~options\"]?.trim) {\n str = str.trim();\n }\n\n if (schema[\"~options\"]?.lowercase) {\n str = str.toLowerCase();\n }\n\n return str;\n }\n\n if (\n typeof value === \"object\" &&\n value !== null &&\n schema.type === \"object\"\n ) {\n const obj: any = {};\n\n for (const key in value) {\n const newValue = this.beforeParse(\n schema.properties?.[key],\n value[key],\n options,\n );\n\n if (newValue === undefined && options.deleteUndefined) {\n continue;\n }\n\n obj[key] = newValue;\n }\n\n return obj;\n }\n\n return value;\n }\n\n /**\n * Used by `beforeParse` to determine if a schema allows null values.\n */\n protected isSchemaNullable = (schema: any): boolean => {\n if (!schema) {\n return false;\n }\n if (schema.type === \"null\") {\n return true;\n }\n if (Array.isArray(schema.type) && schema.type.includes(\"null\")) {\n return true;\n }\n if (schema.anyOf) {\n return schema.anyOf.some((it: any) => this.isSchemaNullable(it));\n }\n if (schema.oneOf) {\n return schema.oneOf.some((it: any) => this.isSchemaNullable(it));\n }\n if (schema.allOf) {\n return schema.allOf.some((it: any) => this.isSchemaNullable(it));\n }\n return false;\n };\n}\n\nexport interface ValidateOptions {\n trim?: boolean;\n nullToUndefined?: boolean;\n deleteUndefined?: boolean;\n}\n","import type { StaticEncode, TSchema } from \"typebox\";\nimport { $inject } from \"../descriptors/$inject.ts\";\nimport { AlephaError } from \"../errors/AlephaError.ts\";\nimport { JsonSchemaCodec } from \"./JsonSchemaCodec.ts\";\nimport type { SchemaCodec } from \"./SchemaCodec.ts\";\nimport { SchemaValidator, type ValidateOptions } from \"./SchemaValidator.ts\";\nimport type { Static } from \"./TypeProvider.ts\";\n\nexport type Encoding = \"object\" | \"string\" | \"binary\";\n\nexport interface EncodeOptions<T extends Encoding = Encoding> {\n /**\n * The output encoding format:\n * - 'string': Returns JSON string\n * - 'binary': Returns Uint8Array (for protobuf, msgpack, etc.)\n *\n * @default \"string\"\n */\n as?: T;\n\n /**\n * The encoder to use (e.g., 'json', 'protobuf', 'msgpack')\n *\n * @default \"json\"\n */\n encoder?: string;\n\n /**\n * Validation options to apply before encoding.\n */\n validation?: ValidateOptions | false;\n}\n\nexport type EncodeResult<\n T extends TSchema,\n E extends Encoding,\n> = E extends \"string\"\n ? string\n : E extends \"binary\"\n ? Uint8Array\n : StaticEncode<T>;\n\nexport interface DecodeOptions {\n /**\n * The encoder to use (e.g., 'json', 'protobuf', 'msgpack')\n *\n * @default \"json\"\n */\n encoder?: string;\n\n /**\n * Validation options to apply before encoding.\n */\n validation?: ValidateOptions | false;\n}\n\n/**\n * CodecManager manages multiple codec formats and provides a unified interface\n * for encoding and decoding data with different formats.\n */\nexport class CodecManager {\n protected readonly codecs: Map<string, SchemaCodec> = new Map();\n protected readonly jsonCodec = $inject(JsonSchemaCodec);\n protected readonly schemaValidator = $inject(SchemaValidator);\n\n public default = \"json\";\n\n constructor() {\n // Register default JSON codec\n this.register(this.default, this.jsonCodec);\n }\n\n /**\n * Register a new codec format.\n *\n * @param name - The name of the codec (e.g., 'json', 'protobuf')\n * @param codec - The codec implementation\n */\n public register(name: string, codec: SchemaCodec): void {\n this.codecs.set(name, codec);\n }\n\n /**\n * Get a specific codec by name.\n *\n * @param name - The name of the codec\n * @returns The codec instance\n * @throws {AlephaError} If the codec is not found\n */\n public getCodec(name: string): SchemaCodec {\n const codec = this.codecs.get(name);\n if (!codec) {\n throw new AlephaError(\n `Codec \"${name}\" not found. Available codecs: ${Array.from(this.codecs.keys()).join(\", \")}`,\n );\n }\n return codec;\n }\n\n /**\n * Encode data using the specified codec and output format.\n */\n public encode<T extends TSchema, E extends Encoding = \"object\">(\n schema: T,\n value: unknown,\n options?: EncodeOptions<E>,\n ): EncodeResult<T, E> {\n const codec = this.getCodec(options?.encoder ?? this.default);\n const as = options?.as ?? \"object\";\n\n if (options?.validation !== false) {\n value = this.schemaValidator.validate(schema, value, options?.validation);\n }\n\n if (as === \"object\") {\n // Return the validated object as-is\n return value as EncodeResult<T, E>;\n }\n\n if (as === \"binary\") {\n // not used by JSON, but for other codecs like Protobuf, MsgPack, etc.\n return codec.encodeToBinary(schema, value as Static<T>) as EncodeResult<\n T,\n E\n >;\n }\n\n // encode directly to string\n return codec.encodeToString(schema, value as Static<T>) as EncodeResult<\n T,\n E\n >;\n }\n\n /**\n * Decode data using the specified codec.\n */\n public decode<T extends TSchema>(\n schema: T,\n data: any,\n options?: DecodeOptions,\n ): Static<T> {\n const encoderName = options?.encoder ?? this.default;\n const codec = this.getCodec(encoderName);\n let value = codec.decode(schema, data);\n\n if (options?.validation !== false) {\n value = this.schemaValidator.validate(schema, value, options?.validation);\n }\n\n return value as Static<T>;\n }\n\n /**\n * Validate decoded data against the schema.\n *\n * This is automatically called before encoding or after decoding.\n */\n public validate<T extends TSchema>(\n schema: T,\n value: unknown,\n options?: ValidateOptions,\n ): Static<T> {\n return this.schemaValidator.validate(schema, value, options);\n }\n}\n","import type { Hook, Hooks } from \"../Alepha.ts\";\nimport { AlephaError } from \"../errors/AlephaError.ts\";\nimport type { Async } from \"../interfaces/Async.ts\";\nimport type { LoggerInterface } from \"../interfaces/LoggerInterface.ts\";\n\nexport class EventManager {\n protected logFn?: () => LoggerInterface | undefined;\n\n /**\n * List of events that can be triggered. Powered by $hook().\n */\n protected events: Record<string, Array<Hook>> = {};\n\n constructor(logFn?: () => LoggerInterface | undefined) {\n this.logFn = logFn;\n }\n\n protected get log(): LoggerInterface | undefined {\n return this.logFn?.();\n }\n\n /**\n * Registers a hook for the specified event.\n */\n public on<T extends keyof Hooks>(\n event: T,\n hookOrFunc: Hook<T> | ((payload: Hooks[T]) => Async<void>),\n ): () => void {\n if (!this.events[event]) {\n this.events[event] = [];\n }\n\n const hook =\n typeof hookOrFunc === \"function\" ? { callback: hookOrFunc } : hookOrFunc;\n\n if (hook.priority === \"first\") {\n this.events[event].unshift(hook);\n } else if (hook.priority === \"last\") {\n this.events[event].push(hook);\n } else {\n const index = this.events[event].findIndex(\n (it) => it.priority === \"last\",\n );\n if (index !== -1) {\n this.events[event].splice(index, 0, hook);\n } else {\n this.events[event].push(hook);\n }\n }\n\n return () => {\n this.events[event] = this.events[event].filter(\n (it) => it.callback !== hook.callback,\n );\n };\n }\n\n /**\n * Emits the specified event with the given payload.\n */\n public async emit<T extends keyof Hooks>(\n func: T,\n payload: Hooks[T],\n options: {\n /**\n * If true, the hooks will be executed in reverse order.\n * This is useful for \"stop\" hooks that should be executed in reverse order.\n *\n * @default false\n */\n reverse?: boolean;\n /**\n * If true, the hooks will be logged with their execution time.\n *\n * @default false\n */\n log?: boolean;\n /**\n * If true, errors will be caught and logged instead of throwing.\n *\n * @default false\n */\n catch?: boolean;\n } = {},\n ): Promise<void> {\n const ctx: any = {};\n\n if (options.log) {\n ctx.now = Date.now();\n this.log?.trace(`${func} ...`);\n }\n\n let events = this.events[func] ?? [];\n\n if (options.reverse) {\n events = events.toReversed();\n }\n\n for (const hook of events) {\n const name = hook.caller?.name ?? \"unknown\";\n if (options.log) {\n ctx.now2 = Date.now();\n this.log?.trace(`${func}(${name}) ...`);\n }\n\n try {\n await hook.callback(payload);\n } catch (error) {\n if (options.catch) {\n this.log?.error(`${func}(${name}) ERROR`, error);\n continue;\n }\n if (options.log) {\n throw new AlephaError(\n `Failed during '${func}()' hook for service: ${name}`,\n { cause: error },\n );\n }\n throw error;\n }\n\n if (options.log) {\n this.log?.debug(`${func}(${name}) OK [${Date.now() - ctx.now2}ms]`);\n }\n }\n\n if (options.log) {\n this.log?.debug(`${func} OK [${Date.now() - ctx.now}ms]`);\n }\n }\n}\n","import type { TArray } from \"typebox\";\nimport { KIND } from \"../constants/KIND.ts\";\nimport type {\n Static,\n TObject,\n TOptionalAdd,\n} from \"../providers/TypeProvider.ts\";\n\n/**\n * Define an atom for state management.\n *\n * Atom lets you define a piece of state with a name, schema, and default value.\n *\n * By default, Alepha state is just a simple key-value store.\n * Using atoms allows you to have type safety, validation, and default values for your state.\n *\n * You control how state is structured and validated.\n *\n * Features:\n * - Set a schema for validation\n * - Set a default value for initial state\n * - Rules, like read-only, custom validation, etc.\n * - Automatic getter access in services with {@link $use}\n * - SSR support (server state automatically serialized and hydrated on client)\n * - React integration (useAtom hook for automatic component re-renders)\n * - Middleware\n * - Persistence adapters (localStorage, Redis, database, file system, cookie, etc.)\n * - State migrations (version upgrades when schema changes)\n * - Documentation generation & devtools integration\n *\n * Common use cases:\n * - user preferences\n * - feature flags\n * - configuration options\n * - session data\n *\n * Atom must contain only serializable data.\n * Avoid storing complex objects like class instances, functions, or DOM elements.\n * If you need to store complex data, consider using identifiers or references instead.\n */\nexport const $atom = <\n T extends TObject<TProperties> | TArray,\n N extends string,\n>(\n options: AtomOptions<T, N>,\n): Atom<T, N> => {\n return new Atom<T, N>(options);\n};\n\nexport type AtomOptions<T extends TAtomObject, N extends string> = {\n name: N;\n schema: T;\n description?: string;\n} & (T extends TOptionalAdd<T>\n ? {\n default?: Static<T>;\n }\n : {\n default: Static<T>;\n });\n\nexport class Atom<T extends TAtomObject = TObject, N extends string = string> {\n public readonly options: AtomOptions<T, N>;\n\n public get schema(): T {\n return this.options.schema;\n }\n\n public get key(): N {\n return this.options.name;\n }\n\n constructor(options: AtomOptions<T, N>) {\n this.options = options;\n }\n}\n\n$atom[KIND] = \"atom\";\n\ntype TProperties = any; // it's required to avoid required [ string ] error, ...\n\nexport type TAtomObject = TObject<any> | TArray;\nexport type AtomStatic<T extends TAtomObject> =\n T extends TOptionalAdd<T> ? Static<T> | undefined : Static<T>;\n","import type { TObject } from \"typebox\";\nimport type { State as AlephaState } from \"../Alepha.ts\";\nimport {\n Atom,\n type AtomStatic,\n type TAtomObject,\n} from \"../descriptors/$atom.ts\";\nimport { $inject } from \"../descriptors/$inject.ts\";\nimport { AlsProvider } from \"./AlsProvider.ts\";\nimport { EventManager } from \"./EventManager.ts\";\nimport { JsonSchemaCodec } from \"./JsonSchemaCodec.ts\";\nimport type { Static } from \"./TypeProvider.ts\";\n\nexport interface AtomWithValue {\n atom: Atom;\n value: unknown;\n}\n\nexport class StateManager<State extends object = AlephaState> {\n protected readonly als = $inject(AlsProvider);\n protected readonly events = $inject(EventManager);\n protected readonly codec = $inject(JsonSchemaCodec);\n protected readonly atoms = new Map<keyof State, Atom>();\n\n protected store: Partial<State> = {};\n\n constructor(store: Partial<State> = {}) {\n this.store = store;\n }\n\n public getAtoms(context = true): Array<AtomWithValue> {\n const atoms: Array<AtomWithValue> = [];\n\n if (context && this.als?.exists()) {\n // for each this.atoms, check if key is present in als, if yes, add to new map\n for (const atom of this.atoms.values()) {\n const value = this.als.get(atom.key);\n if (value !== undefined) {\n atoms.push({ atom, value });\n }\n }\n } else {\n for (const [key, atom] of this.atoms.entries()) {\n atoms.push({ atom, value: this.store[key] as unknown });\n }\n }\n\n return atoms;\n }\n\n public register(atom: Atom<any>): this {\n const key = atom.key as keyof State;\n\n if (!this.atoms.has(key)) {\n this.atoms.set(key, atom);\n if (!(key in this.store)) {\n this.set(key, atom.options.default as State[keyof State]);\n }\n }\n\n return this;\n }\n\n /**\n * Get a value from the state with proper typing\n */\n public get<T extends TAtomObject>(target: Atom<T>): Static<T>;\n public get<Key extends keyof State>(target: Key): State[Key] | undefined;\n public get(target: string | object): any {\n if (target instanceof Atom) {\n this.register(target);\n }\n\n const key = target instanceof Atom ? target.key : target;\n const store = this.store as Record<string, any>;\n\n return this.als?.exists()\n ? (this.als.get(key as string) ?? store[key])\n : store[key];\n }\n\n /**\n * Set a value in the state\n */\n public set<T extends TAtomObject>(\n target: Atom<T>,\n value: AtomStatic<T>,\n ): this;\n public set<Key extends keyof State>(\n target: Key,\n value: State[Key] | undefined,\n ): this;\n public set(target: any, value: any): this {\n if (target instanceof Atom) {\n this.register(target);\n }\n\n const key = target instanceof Atom ? target.key : target;\n const store = this.store as Record<string, any>;\n\n const prevValue = this.get(key);\n if (prevValue === value) {\n return this;\n }\n\n if (this.als?.exists()) {\n this.als.set(key as string, value);\n } else {\n store[key] = value;\n }\n\n this.events\n ?.emit(\n \"state:mutate\",\n { key: key as keyof AlephaState, value, prevValue },\n { catch: true },\n )\n .catch(() => null);\n\n return this;\n }\n\n /**\n * Mutate a value in the state.\n */\n public mut<T extends TObject>(\n target: Atom<T>,\n mutator: (current: Static<T>) => Static<T>,\n ): this;\n public mut<Key extends keyof State>(\n target: Key,\n mutator: (current: State[Key] | undefined) => State[Key] | undefined,\n ): this;\n public mut(target: any, mutator: (current: any) => any): this {\n const current = this.get(target);\n const updated = mutator(current);\n return this.set(target, updated);\n }\n\n /**\n * Check if a key exists in the state\n */\n public has<Key extends keyof State>(key: Key): boolean {\n return key in this.store;\n }\n\n /**\n * Delete a key from the state (set to undefined)\n */\n public del<Key extends keyof State>(key: Key): this {\n return this.set(key, undefined);\n }\n\n /**\n * Push a value to an array in the state\n */\n public push<Key extends keyof OnlyArray<State>>(\n key: Key,\n value: NonNullable<State[Key]> extends Array<infer U> ? U : never,\n ): this {\n const current = (this.get(key) ?? []) as Array<any>; // default to empty array\n if (Array.isArray(current)) {\n this.set(key, [...current, value] as State[Key]);\n }\n return this;\n }\n\n /**\n * Clear all state\n */\n public clear(): this {\n this.store = {};\n return this;\n }\n\n /**\n * Get all keys that exist in the state\n */\n public keys(): (keyof State)[] {\n return Object.keys(this.store) as (keyof State)[];\n }\n}\n\ntype OnlyArray<T extends object> = {\n [K in keyof T]: NonNullable<T[K]> extends Array<any> ? K : never;\n};\n","import type { Static, TObject } from \"typebox\";\nimport { KIND } from \"./constants/KIND.ts\";\nimport { MODULE } from \"./constants/MODULE.ts\";\nimport { OPTIONS } from \"./constants/OPTIONS.ts\";\nimport type { InjectOptions } from \"./descriptors/$inject.ts\";\nimport { Module, type WithModule } from \"./descriptors/$module.ts\";\nimport { AlephaError } from \"./errors/AlephaError.ts\";\nimport { CircularDependencyError } from \"./errors/CircularDependencyError.ts\";\nimport { ContainerLockedError } from \"./errors/ContainerLockedError.ts\";\nimport { TooLateSubstitutionError } from \"./errors/TooLateSubstitutionError.ts\";\nimport { Descriptor } from \"./helpers/descriptor.ts\";\nimport { __alephaRef } from \"./helpers/ref.ts\";\nimport type { Async } from \"./interfaces/Async.ts\";\nimport type { LoggerInterface } from \"./interfaces/LoggerInterface.ts\";\nimport {\n type InstantiableClass,\n isClass,\n type RunFunction,\n type Service,\n type ServiceEntry,\n} from \"./interfaces/Service.ts\";\nimport { AlsProvider } from \"./providers/AlsProvider.ts\";\nimport { CodecManager } from \"./providers/CodecManager.ts\";\nimport { EventManager } from \"./providers/EventManager.ts\";\nimport { StateManager } from \"./providers/StateManager.ts\";\nimport type { TSchema } from \"./providers/TypeProvider.ts\";\n\n/**\n * Core container of the Alepha framework.\n *\n * It is responsible for managing the lifecycle of services,\n * handling dependency injection,\n * and providing a unified interface for the application.\n *\n * @example\n * ```ts\n * import { Alepha, run } from \"alepha\";\n *\n * class MyService {\n * // business logic here\n * }\n *\n * const alepha = Alepha.create({\n * // state, env, and other properties\n * })\n *\n * alepha.with(MyService);\n *\n * run(alepha); // trigger .start (and .stop) automatically\n * ```\n *\n * ### Alepha Factory\n *\n * Alepha.create() is an enhanced version of new Alepha().\n * - It merges `process.env` with the provided state.env when available.\n * - It populates the test hooks for Vitest or Jest environments when available.\n *\n * new Alepha() is fine if you don't need these helpers.\n *\n * ### Platforms & Environments\n *\n * Alepha is designed to work in various environments:\n * - **Browser**: Runs in the browser, using the global `window` object.\n * - **Serverless**: Runs in serverless environments like Vercel or Vite.\n * - **Test**: Runs in test environments like Jest or Vitest.\n * - **Production**: Runs in production environments, typically with NODE_ENV set to \"production\".\n * * You can check the current environment using the following methods:\n *\n * - `isBrowser()`: Returns true if the App is running in a browser environment.\n * - `isServerless()`: Returns true if the App is running in a serverless environment.\n * - `isTest()`: Returns true if the App is running in a test environment.\n * - `isProduction()`: Returns true if the App is running in a production environment.\n *\n * ### State & Environment\n *\n * The state of the Alepha container is stored in the `store` property.\n * Most important property is `store.env`, which contains the environment variables.\n *\n * ```ts\n * const alepha = Alepha.create({ env: { MY_VAR: \"value\" } });\n *\n * // You can access the environment variables using alepha.env\n * console.log(alepha.env.MY_VAR); // \"value\"\n *\n * // But you should use $env() descriptor to get typed values from the environment.\n * class App {\n * env = $env(\n * t.object({\n * \t MY_VAR: t.text(),\n * })\n * );\n * }\n * ```\n *\n * ### Modules\n *\n * Modules are a way to group services together.\n * You can register a module using the `$module` descriptor.\n *\n * ```ts\n * import { $module } from \"alepha\";\n *\n * class MyLib {}\n *\n * const myModule = $module({\n * name: \"my.project.module\",\n * services: [MyLib],\n * });\n * ```\n *\n * Do not use modules for small applications.\n *\n * ### Hooks\n *\n * Hooks are a way to run async functions from all registered providers/services.\n * You can register a hook using the `$hook` descriptor.\n *\n * ```ts\n * import { $hook } from \"alepha\";\n *\n * class App {\n * \t log = $logger();\n * \t onCustomerHook = $hook({\n * \t\t\ton: \"my:custom:hook\",\n * \t\t\thandler: () => {\n * \t\t \t this.log?.info(\"App is being configured\");\n * \t \t\t},\n * \t });\n * \t}\n *\n * Alepha.create()\n * \t .with(App)\n * \t .start()\n * \t .then(alepha => alepha.events.emit(\"my:custom:hook\"));\n * ```\n *\n * \tHooks are fully typed. You can create your own hooks by using module augmentation:\n *\n * \t```ts\n * \tdeclare module \"alepha\" {\n * \t\tinterface Hooks {\n * \t\t \"my:custom:hook\": {\n * \t\t\t\targ1: string;\n * \t\t }\n * \t\t}\n * \t}\n * \t```\n *\n * \t@module alepha\n */\nexport class Alepha {\n /**\n * Creates a new instance of the Alepha container with some helpers:\n *\n * - merges `process.env` with the provided state.env when available.\n * - populates the test hooks for Vitest or Jest environments when available.\n *\n * If you are not interested about these helpers, you can use the constructor directly.\n */\n public static create(state: Partial<State> = {}): Alepha {\n // merge process.env with the state.env\n if (typeof process === \"object\" && typeof process.env === \"object\") {\n state.env = {\n ...state.env,\n ...process.env,\n };\n }\n\n const alepha = new Alepha(state);\n\n if (alepha.isTest()) {\n // inject global hooks for testing purposes\n // > for vitest, { globals: true } is required in the config\n const g = globalThis as any;\n const beforeAll = state[\"alepha.test.beforeAll\"] ?? g.beforeAll;\n const afterAll = state[\"alepha.test.afterAll\"] ?? g.afterAll;\n const afterEach = state[\"alepha.test.afterEach\"] ?? g.afterEach;\n const onTestFinished =\n state[\"alepha.test.onTestFinished\"] ?? g.onTestFinished;\n\n beforeAll?.(() => alepha.start());\n afterAll?.(() => alepha.stop());\n\n try {\n onTestFinished?.(() => alepha.stop());\n } catch (_error) {\n // ignore\n }\n\n alepha.state\n .set(\"alepha.test.beforeAll\", beforeAll)\n .set(\"alepha.test.afterAll\", afterAll)\n .set(\"alepha.test.afterEach\", afterEach)\n .set(\"alepha.test.onTestFinished\", onTestFinished);\n }\n\n return alepha;\n }\n\n /**\n * Flag indicating whether the App won't accept any further changes.\n * Pass to true when #start() is called.\n */\n protected locked = false;\n\n /**\n * True if the App has been configured.\n */\n protected configured = false;\n\n /**\n * True if the App has started.\n */\n protected started = false;\n\n /**\n * True if the App is ready.\n */\n protected ready = false;\n\n /**\n * A promise that resolves when the App has started.\n */\n protected starting?: PromiseWithResolvers<this>;\n\n /**\n * Initial state of the container.\n *\n * > Used to initialize the StateManager.\n */\n protected init: Partial<State>;\n\n /**\n * During the instantiation process, we keep a list of pending instantiations.\n * > It allows us to detect circular dependencies.\n */\n protected pendingInstantiations: Service[] = [];\n\n /**\n * Cache for environment variables.\n * > It allows us to avoid parsing the same schema multiple times.\n */\n protected cacheEnv: Map<TSchema, any> = new Map();\n\n /**\n * List of modules that are registered in the container.\n *\n * Modules are used to group services and provide a way to register them in the container.\n */\n protected modules: Array<Module> = [];\n\n /**\n * List of service substitutions.\n *\n * Services registered here will be replaced by the specified service when injected.\n */\n protected substitutions = new Map<Service, { use: Service }>();\n\n /**\n * Registry of descriptors.\n */\n protected descriptorRegistry = new Map<\n Service<Descriptor>,\n Array<Descriptor>\n >();\n\n /**\n * List of all services + how they are provided.\n */\n protected registry: Map<Service, ServiceDefinition> = new Map();\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Node.js feature that allows to store context across asynchronous calls.\n *\n * This is used for logging, tracing, and other context-related features.\n *\n * Mocked for browser environments.\n */\n public get context(): AlsProvider {\n return this.inject(AlsProvider);\n }\n\n /**\n * Event manager to handle lifecycle events and custom events.\n */\n public get events(): EventManager {\n return this.inject(EventManager, {\n args: [() => this.log],\n });\n }\n\n /**\n * State manager to store arbitrary values.\n */\n public get state(): StateManager<State> {\n this.events; // ensure events is initialized first (TODO: move this to constructor?)\n return this.inject(StateManager, {\n args: [this.init],\n });\n }\n\n /**\n * Codec manager for encoding and decoding data with different formats.\n *\n * Supports multiple codec formats (JSON, Protobuf, etc.) with a unified interface.\n */\n public get codec(): CodecManager {\n return this.inject(CodecManager);\n }\n\n /**\n * Get logger instance.\n */\n public get log(): LoggerInterface | undefined {\n return this.state.get(\"alepha.logger\");\n }\n\n /**\n * The environment variables for the App.\n */\n public get env(): Readonly<Env> {\n return this.state.get(\"env\") ?? {};\n }\n\n constructor(init: Partial<State> = {}) {\n this.init = init;\n }\n\n /**\n * True when start() is called.\n *\n * -> No more services can be added, it's over, bye!\n */\n public isLocked(): boolean {\n return this.locked;\n }\n\n /**\n * Returns whether the App is configured.\n *\n * It means that Alepha#configure() has been called.\n *\n * > By default, configure() is called automatically when start() is called, but you can also call it manually.\n */\n public isConfigured(): boolean {\n return this.configured;\n }\n\n /**\n * Returns whether the App has started.\n *\n * It means that #start() has been called but maybe not all services are ready.\n */\n public isStarted(): boolean {\n return this.started;\n }\n\n /**\n * True if the App is ready. It means that Alepha is started AND ready() hook has beed called.\n */\n public isReady(): boolean {\n return this.ready;\n }\n\n /**\n * True if the App is running in a Continuous Integration environment.\n */\n public isCI(): boolean {\n if (this.env.GITHUB_ACTIONS) {\n return true;\n }\n\n return !!this.env.CI;\n }\n\n /**\n * True if the App is running in a browser environment.\n */\n public isBrowser(): boolean {\n return typeof window !== \"undefined\"; // pretty cheap check\n }\n\n /**\n * Returns whether the App is running in Vite dev mode.\n */\n public isViteDev(): boolean {\n if (this.isBrowser()) {\n return false;\n }\n\n return !!this.env.VITE_ALEPHA_DEV;\n }\n\n public isBun(): boolean {\n return \"Bun\" in globalThis;\n }\n\n /**\n * Returns whether the App is running in a serverless environment.\n */\n public isServerless(): boolean {\n if (this.isBrowser()) {\n return false;\n }\n\n if (this.env.VERCEL_REGION) {\n return true;\n }\n\n if (this.env.ALEPHA_SERVERLESS) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Returns whether the App is in test mode. (Running in a test environment)\n *\n * > This is automatically set when running tests with Jest or Vitest.\n */\n public isTest(): boolean {\n const env = this.env.NODE_ENV;\n return env === \"test\";\n }\n\n /**\n * Returns whether the App is in production mode. (Running in a production environment)\n *\n * > This is automatically set by Vite or Vercel. However, you have to set it manually when running Docker apps.\n */\n public isProduction(): boolean {\n const env = this.env.NODE_ENV;\n return env === \"production\";\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Starts the App.\n *\n * - Lock any further changes to the container.\n * - Run \"configure\" hook for all services. Descriptors will be processed.\n * - Run \"start\" hook for all services. Providers will connect/listen/...\n * - Run \"ready\" hook for all services. This is the point where the App is ready to serve requests.\n *\n * @return A promise that resolves when the App has started.\n */\n public async start(): Promise<this> {\n if (this.ready) {\n this.log?.debug(\"App is already started, skipping...\");\n return this;\n }\n\n // make sure that start is called only once\n if (this.starting) {\n this.log?.warn(\"App is already starting, waiting for it to finish...\");\n return this.starting.promise;\n }\n\n this.codec; // ensure codec is initialized\n\n this.starting = Promise.withResolvers();\n\n const now = Date.now();\n\n this.log?.info(\"Starting App...\");\n\n for (const [key] of this.substitutions.entries()) {\n this.inject(key);\n }\n\n const target = this.state.get(\"alepha.target\");\n if (target) {\n this.registry = new Map();\n this.descriptorRegistry = new Map();\n this.with(target);\n }\n\n this.locked = true;\n\n await this.events.emit(\"configure\", this, { log: true });\n\n this.configured = true;\n\n await this.events.emit(\"start\", this, { log: true });\n\n this.started = true;\n\n await this.events.emit(\"ready\", this, { log: true });\n\n this.log?.info(`App is now ready [${Date.now() - now}ms]`);\n\n this.ready = true;\n\n this.starting.resolve(this);\n this.starting = undefined;\n\n return this;\n }\n\n /**\n * Stops the App.\n *\n * - Run \"stop\" hook for all services.\n *\n * Stop will NOT reset the container.\n * Stop will NOT unlock the container.\n *\n * > Stop is used to gracefully shut down the application, nothing more. There is no \"restart\".\n *\n * @return A promise that resolves when the App has stopped.\n */\n public async stop(): Promise<void> {\n if (!this.started) {\n return;\n }\n\n this.log?.info(\"Stopping App...\");\n await this.events.emit(\"stop\", this, { reverse: true, log: true });\n this.log?.info(\"App is now off\");\n\n this.started = false;\n this.ready = false;\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Check if entry is registered in the container.\n */\n public has(\n entry: ServiceEntry,\n opts: {\n /**\n * Check if the entry is registered in the pending instantiation stack.\n *\n * @default true\n */\n inStack?: boolean;\n /**\n * Check if the entry is registered in the container registry.\n *\n * @default true\n */\n inRegistry?: boolean;\n /**\n * Check if the entry is registered in the substitutions.\n *\n * @default true\n */\n inSubstitutions?: boolean;\n /**\n * Where to look for registered services.\n *\n * @default this.registry\n */\n registry?: Map<Service, ServiceDefinition>;\n } = {},\n ): boolean {\n if (entry === Alepha) {\n return true;\n }\n\n const {\n inStack = true,\n inRegistry = true,\n inSubstitutions = true,\n registry = this.registry,\n } = opts;\n\n const { provide } =\n typeof entry === \"object\" && \"provide\" in entry\n ? entry\n : { provide: entry };\n\n if (inSubstitutions) {\n const substitute = this.substitutions.get(provide);\n if (substitute) {\n return true;\n }\n }\n\n if (inRegistry) {\n const match = registry.get(provide);\n if (match) {\n return true;\n }\n }\n\n if (inStack) {\n const substitute = this.substitutions.get(provide)?.use;\n if (substitute && this.pendingInstantiations.includes(substitute)) {\n return true;\n }\n\n return this.pendingInstantiations.includes(provide);\n }\n\n return false;\n }\n\n /**\n * Registers the specified service in the container.\n *\n * - If the service is ALREADY registered, the method does nothing.\n * - If the service is NOT registered, a new instance is created and registered.\n *\n * Method is chainable, so you can register multiple services in a single call.\n *\n * > ServiceEntry allows to provide a service **substitution** feature.\n *\n * @example\n * ```ts\n * class A { value = \"a\"; }\n * class B { value = \"b\"; }\n * class M { a = $inject(A); }\n *\n * Alepha.create().with({ provide: A, use: B }).get(M).a.value; // \"b\"\n * ```\n *\n * > **Substitution** is an advanced feature that allows you to replace a service with another service.\n * > It's useful for testing or for providing different implementations of a service.\n * > If you are interested in configuring a service, use Alepha#configure() instead.\n *\n * @param serviceEntry - The service to register in the container.\n * @return Current instance of Alepha.\n */\n public with<T extends object>(\n serviceEntry: ServiceEntry<T> | { default: ServiceEntry<T> },\n ): this {\n const entry: ServiceEntry<T> =\n \"default\" in serviceEntry ? serviceEntry.default : serviceEntry;\n\n // just check if the entry is not present in the pending instantiation stack\n // Alepha#get will handle the rest\n if (\n this.has(entry, {\n inSubstitutions: false,\n inRegistry: false,\n })\n ) {\n return this;\n }\n\n const isSubstitution = typeof entry === \"object\";\n if (isSubstitution) {\n if (entry.provide === entry.use) {\n this.inject(entry.provide);\n return this;\n }\n\n if (!this.substitutions.has(entry.provide) && !this.has(entry.provide)) {\n if (this.started) {\n throw new ContainerLockedError();\n }\n\n // inherit of module, if service has no module\n if (\n MODULE in entry.provide &&\n typeof entry.provide[MODULE] === \"function\"\n ) {\n (entry.use as WithModule)[MODULE] ??= entry.provide[MODULE];\n }\n\n this.substitutions.set(entry.provide, {\n use: entry.use,\n });\n } else if (!entry.optional) {\n throw new TooLateSubstitutionError(entry.provide.name, entry.use.name);\n }\n\n return this;\n }\n\n this.inject(entry);\n\n return this;\n }\n\n /**\n * Get an instance of the specified service from the container.\n *\n * @see {@link InjectOptions} for the available options.\n */\n public inject<T extends object>(\n service: Service<T> | string,\n opts: InjectOptions<T> = {},\n ): T {\n const lifetime = opts.lifetime ?? \"singleton\";\n const parent =\n opts.parent !== undefined ? opts.parent : (__alephaRef?.parent ?? Alepha);\n\n const transient = lifetime === \"transient\";\n const registry =\n lifetime === \"scoped\"\n ? (this.context.get<Map<Service, ServiceDefinition>>(\"registry\") ??\n this.registry)\n : this.registry;\n\n // If the requested type is the container, the current instance is returned.\n if ((service as any) === Alepha) {\n return this as any;\n }\n\n if (typeof service === \"string\") {\n for (const [key, value] of registry.entries()) {\n if (key.name === service) {\n return value.instance as T;\n }\n }\n throw new AlephaError(`Service not found: ${service}`);\n }\n\n const substitute = this.substitutions.get(service);\n if (substitute) {\n return this.inject(substitute.use, {\n parent,\n lifetime,\n });\n }\n\n const index = this.pendingInstantiations.indexOf(service);\n if (index !== -1 && !transient) {\n throw new CircularDependencyError(\n service.name,\n this.pendingInstantiations.slice(0, index).map((it) => it.name),\n );\n }\n\n if (!transient) {\n // the requested type is searched in the container\n const match = registry.get(service);\n if (match) {\n if (!match.parents.includes(parent) && parent !== service) {\n match.parents.push(parent);\n }\n\n return match.instance;\n }\n\n if (this.started) {\n throw new ContainerLockedError(\n `Container is locked. No more services can be added. ${parent?.name} -> ${service.name}`,\n );\n }\n }\n\n const module = (service as WithModule)[MODULE];\n if (module && typeof module === \"function\") {\n this.with(module);\n }\n\n // check if service has been registered by a module\n if (this.has(service, { registry }) && !transient) {\n // if the service is already registered, we just return the instance\n return this.inject(service, { parent, lifetime });\n }\n\n const instance: T = this.new(service, opts.args);\n\n const definition: ServiceDefinition<T> = {\n parents: [parent],\n instance,\n };\n\n if (!transient) {\n registry.set(service, definition);\n }\n\n // [feature]: modules - it's just a way to group services together\n if (instance instanceof Module) {\n this.modules.push(instance);\n\n const parent = __alephaRef.parent;\n\n // propagate the current module\n __alephaRef.parent = instance.constructor as Service;\n\n instance.register(this);\n\n // restore the previous $get context\n __alephaRef.parent = parent;\n }\n\n return instance;\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Applies environment variables to the provided schema and state object.\n *\n * It replaces also all templated $ENV inside string values.\n *\n * @param schema - The schema object to apply environment variables to.\n * @return The schema object with environment variables applied.\n */\n public parseEnv<T extends TObject>(schema: T): Static<T> {\n if (this.cacheEnv.has(schema)) {\n return this.cacheEnv.get(schema) as Static<T>;\n }\n\n const config = this.codec.validate(schema, this.env) as Record<string, any>;\n\n for (const key in config) {\n if (typeof config[key] === \"string\") {\n for (const env in config) {\n config[key] = config[key].replace(\n new RegExp(`\\\\$${env}`, \"gim\"),\n config[env],\n );\n }\n }\n }\n\n this.cacheEnv.set(schema, config);\n\n return config as Static<T>;\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Dump the current dependency graph of the App.\n *\n * This method returns a record where the keys are the names of the services.\n */\n public graph(): Record<\n string,\n { from: string[]; as?: string[]; module?: string }\n > {\n for (const [key] of this.substitutions.entries()) {\n if (!this.has(key)) {\n this.inject(key);\n }\n }\n\n const graph: Record<\n string,\n { from: string[]; as?: string[]; module?: string }\n > = {};\n\n for (const [provide, { parents }] of this.registry.entries()) {\n graph[provide.name] = {\n from: parents.filter((it) => !!it).map((it) => it.name),\n };\n\n const aliases = this.substitutions\n .entries()\n .filter((it) => it[1].use === provide)\n .map((it) => it[0].name)\n .toArray();\n\n if (aliases.length) {\n graph[provide.name].as = aliases;\n }\n\n const module = Module.of(provide);\n if (module) {\n graph[provide.name].module = module.name;\n }\n }\n\n return graph;\n }\n\n public services<T extends object>(base: Service<T>): Array<T> {\n const list: Array<T> = [];\n for (const [key, value] of this.registry.entries()) {\n if (value.instance instanceof base) {\n list.push(value.instance as T);\n }\n }\n return list;\n }\n\n /**\n * Get all descriptors of the specified type.\n */\n public descriptors<TDescriptor extends Descriptor>(\n factory:\n | {\n [KIND]: InstantiableClass<TDescriptor>;\n }\n | string,\n ): Array<TDescriptor> {\n if (typeof factory === \"string\") {\n const key1 = factory.toLowerCase().replace(\"$\", \"\");\n const key2 = `${key1}descriptor`;\n for (const [key, value] of this.descriptorRegistry.entries()) {\n const name = key.name.toLowerCase();\n if (name === key1 || name === key2) {\n return value as Array<TDescriptor>;\n }\n }\n return [];\n }\n return (this.descriptorRegistry.get(factory[KIND]) ??\n []) as Array<TDescriptor>;\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n protected new<T extends object>(service: Service<T>, args: any[] = []): T {\n // we keep a tree of dependencies to detect circular dependencies\n // it's also useful for cleaning are global cursor\n this.pendingInstantiations.push(service);\n\n //\n // we use a global cursor to store the current context and definition\n // as new() is synchronous, there is no worry to do that\n //\n __alephaRef.alepha = this;\n __alephaRef.service = service;\n\n const instance: T = isClass(service)\n ? new service(...args)\n : (((service as RunFunction)(...args) ?? {}) as T);\n\n const obj = instance as unknown as Record<string, any>;\n for (const [key, value] of Object.entries(obj)) {\n if (value instanceof Descriptor) {\n this.processDescriptor(value, key);\n }\n if (\n typeof value === \"object\" &&\n value !== null &&\n typeof value[OPTIONS] === \"object\" &&\n \"getter\" in value[OPTIONS]\n ) {\n const getter = value[OPTIONS].getter as keyof State;\n Object.defineProperty(obj, key, {\n get: () => this.state.get(getter),\n });\n }\n }\n\n this.pendingInstantiations.pop();\n\n // tree is empty, now we can clean the global cursor\n if (this.pendingInstantiations.length === 0) {\n __alephaRef.alepha = undefined;\n }\n\n __alephaRef.service =\n this.pendingInstantiations[this.pendingInstantiations.length - 1];\n\n return instance;\n }\n\n protected processDescriptor(value: Descriptor, propertyKey = \"\") {\n value.config.propertyKey = propertyKey;\n (value as any).onInit();\n\n const kind = value.constructor as Service;\n const list = this.descriptorRegistry.get(kind) ?? [];\n this.descriptorRegistry.set(kind, [...list, value]);\n }\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface Hook<T extends keyof Hooks = any> {\n caller?: Service;\n priority?: \"first\" | \"last\";\n callback: (payload: Hooks[T]) => Async<void>;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * This is how we store services in the Alepha container.\n */\ninterface ServiceDefinition<T extends object = any> {\n /**\n * The instance of the class or type definition.\n * Mostly used for caching / singleton but can be used for other purposes like forcing the instance.\n */\n instance: T;\n\n /**\n * List of classes which use this class.\n */\n parents: Array<Service | null>;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface Env {\n [key: string]: string | boolean | number | undefined;\n\n /**\n * Optional environment variable that indicates the current environment.\n */\n NODE_ENV?: \"dev\" | \"test\" | \"production\";\n\n /**\n * Optional name of the application.\n */\n APP_NAME?: string;\n\n /**\n * Optional root module name.\n */\n MODULE_NAME?: string;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface State {\n /**\n * Environment variables for the application.\n */\n env?: Readonly<Env>;\n\n /**\n * Logger instance to be used by the Alepha container.\n *\n * @internal\n */\n \"alepha.logger\"?: LoggerInterface;\n\n /**\n * If defined, the Alepha container will only register this service and its dependencies.\n */\n \"alepha.target\"?: Service;\n\n // test hooks\n\n /**\n * Bind to Vitest 'beforeAll' hook.\n * Used for testing purposes.\n * This is automatically attached if Alepha#create() detects a test environment and global 'beforeAll' is available.\n */\n \"alepha.test.beforeAll\"?: (run: any) => any;\n\n /**\n * Bind to Vitest 'afterAll' hook.\n * Used for testing purposes.\n * This is automatically attached if Alepha#create() detects a test environment and global 'afterAll' is available.\n */\n \"alepha.test.afterAll\"?: (run: any) => any;\n\n /**\n * Bind to Vitest 'afterEach' hook.\n * Used for testing purposes.\n * This is automatically attached if Alepha#create() detects a test environment and global 'afterEach' is available.\n */\n \"alepha.test.afterEach\"?: (run: any) => any;\n\n /**\n * Bind to Vitest 'onTestFinished' hook.\n * Used for testing purposes.\n * This is automatically attached if Alepha#create() detects a test environment and global 'onTestFinished' is available.\n */\n \"alepha.test.onTestFinished\"?: (run: any) => any;\n\n /**\n * List of static assets to be copied to the output directory during the build process.\n *\n * Used for Alepha-based applications that require static assets.\n *\n * See alepha/vite for more details.\n */\n \"alepha.build.assets\"?: Array<string>;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface Hooks {\n /**\n * Used for testing purposes.\n */\n echo: unknown;\n\n /**\n * Triggered during the configuration phase. Before the start phase.\n */\n configure: Alepha;\n\n /**\n * Triggered during the start phase. When `Alepha#start()` is called.\n */\n start: Alepha;\n\n /**\n * Triggered during the ready phase. After the start phase.\n */\n ready: Alepha;\n\n /**\n * Triggered during the stop phase.\n *\n * - Stop should be called after a SIGINT or SIGTERM signal in order to gracefully shutdown the application. (@see `run()` method)\n *\n */\n stop: Alepha;\n\n /**\n * Triggered when a state value is mutated.\n */\n \"state:mutate\": {\n /**\n * The key of the state that was mutated.\n */\n key: keyof State;\n\n /**\n * The new value of the state.\n */\n value: any;\n\n /**\n * The previous value of the state.\n */\n prevValue: any;\n };\n}\n","import type { Readable } from \"node:stream\";\nimport type { ReadableStream as WebReadableStream } from \"node:stream/web\";\nimport type { TSchema, TUnsafe } from \"typebox\";\n\nexport interface FileLike {\n /**\n * Filename.\n * @default \"file\"\n */\n name: string;\n\n /**\n * Mandatory MIME type of the file.\n * @default \"application/octet-stream\"\n */\n type: string;\n\n /**\n * Size of the file in bytes.\n *\n * Always 0 for streams, as the size is not known until the stream is fully read.\n *\n * @default 0\n */\n size: number;\n\n /**\n * Last modified timestamp in milliseconds since epoch.\n *\n * Always the current timestamp for streams, as the last modified time is not known.\n * We use this field to ensure compatibility with File API.\n *\n * @default Date.now()\n */\n lastModified: number;\n\n /**\n * Returns a ReadableStream or Node.js Readable stream of the file content.\n *\n * For streams, this is the original stream.\n */\n stream(): StreamLike;\n\n /**\n * Returns the file content as an ArrayBuffer.\n *\n * For streams, this reads the entire stream into memory.\n */\n arrayBuffer(): Promise<ArrayBuffer>;\n\n /**\n * Returns the file content as a string.\n *\n * For streams, this reads the entire stream into memory and converts it to a string.\n */\n text(): Promise<string>;\n\n // -- node specific fields --\n\n /**\n * Optional file path, if the file is stored on disk.\n *\n * This is not from the File API, but rather a custom field to indicate where the file is stored.\n */\n filepath?: string;\n}\n\n/**\n * TypeBox view of FileLike.\n */\nexport type TFile = TUnsafe<FileLike>;\n\nexport const isTypeFile = (value: TSchema): value is TFile => {\n return (\n value &&\n typeof value === \"object\" &&\n \"format\" in value &&\n value.format === \"binary\"\n );\n};\n\nexport const isFileLike = (value: any): value is FileLike => {\n return (\n !!value &&\n typeof value === \"object\" &&\n !Array.isArray(value) &&\n typeof value.name === \"string\" &&\n typeof value.type === \"string\" &&\n typeof value.size === \"number\" &&\n typeof value.stream.bind(value) === \"function\"\n );\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n// TODO: remove it, replace with WebStream\nexport type StreamLike =\n | ReadableStream\n | WebReadableStream\n | Readable\n | NodeJS.ReadableStream;\n\nexport type TStream = TUnsafe<StreamLike>;\n","import type {\n TAny,\n TArray,\n TArrayOptions,\n TBoolean,\n TInteger,\n TInterface,\n TKeysToIndexer,\n TNull,\n TNumber,\n TNumberOptions,\n TObject,\n TObjectOptions,\n TOmit,\n TOptionalAdd,\n TPartial,\n TPick,\n TProperties,\n TRecord,\n TSchema,\n TSchemaOptions,\n TString,\n TStringOptions,\n TUnion,\n TUnsafe,\n} from \"typebox\";\nimport * as TypeBox from \"typebox\";\nimport { Type } from \"typebox\";\nimport type {\n TLocalizedValidationError,\n TLocalizedValidationMessageCallback,\n} from \"typebox/error\";\nimport TypeBoxFormat from \"typebox/format\";\nimport { Locale } from \"typebox/system\";\nimport * as TypeBoxValue from \"typebox/value\";\nimport { OPTIONS } from \"../constants/OPTIONS.ts\";\nimport { AlephaError } from \"../errors/AlephaError.ts\";\nimport type { TypeBoxError } from \"../errors/TypeBoxError.ts\";\nimport { isTypeFile, type TFile, type TStream } from \"../helpers/FileLike.ts\";\n\nexport { TypeBox, TypeBoxValue, TypeBoxFormat };\n\nexport const isUUID = TypeBoxFormat.IsUuid;\nexport const isEmail = TypeBoxFormat.IsEmail;\nexport const isURL = TypeBoxFormat.IsUrl;\nexport const isDateTime = TypeBoxFormat.IsDateTime;\nexport const isDate = TypeBoxFormat.IsDate;\nexport const isTime = TypeBoxFormat.IsTime;\nexport const isDuration = TypeBoxFormat.IsDuration;\n\nexport type {\n StaticDecode,\n StaticDecode as Static,\n StaticEncode,\n TAny,\n TArray,\n TBigInt,\n TBoolean,\n TInteger,\n TKeysToIndexer,\n TNull,\n TNumber,\n TNumberOptions,\n TObject,\n TObjectOptions,\n TOptional,\n TOptionalAdd,\n TPick,\n TProperties,\n TRecord,\n TSchema,\n TString,\n TStringOptions,\n TTuple,\n TUnion,\n TUnsafe,\n TVoid,\n} from \"typebox\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport class TypeGuard {\n // -------------------------------------------------------------------------------------------------------------------\n isBigInt = (value: TSchema): value is TString =>\n TypeBox.IsString(value) && \"format\" in value && value.format === \"bigint\";\n isUUID = (value: TSchema): value is TString =>\n TypeBox.IsString(value) && \"format\" in value && value.format === \"uuid\";\n isObject = TypeBox.IsObject;\n isNumber = TypeBox.IsNumber;\n isString = TypeBox.IsString;\n isBoolean = TypeBox.IsBoolean;\n isAny = TypeBox.IsAny;\n isArray = TypeBox.IsArray;\n isOptional = TypeBox.IsOptional;\n isUnion = TypeBox.IsUnion;\n isInteger = TypeBox.IsInteger;\n isNull = TypeBox.IsNull;\n isUndefined = TypeBox.IsUndefined;\n isUnsafe = TypeBox.IsUnsafe;\n isRecord = TypeBox.IsRecord;\n isTuple = TypeBox.IsTuple;\n isVoid = TypeBox.IsVoid;\n isLiteral = TypeBox.IsLiteral;\n isSchema = TypeBox.IsSchema;\n // -------------------------------------------------------------------------------------------------------------------\n isFile = isTypeFile;\n isDateTime = (schema: unknown) => {\n return t.schema.isString(schema) && schema.format === \"date-time\";\n };\n isDate = (schema: unknown) => {\n return t.schema.isString(schema) && schema.format === \"date\";\n };\n isTime = (schema: unknown) => {\n return t.schema.isString(schema) && schema.format === \"time\";\n };\n isDuration = (schema: unknown) => {\n return t.schema.isString(schema) && schema.format === \"duration\";\n };\n}\n\ndeclare module \"typebox\" {\n interface TString {\n format?: string;\n minLength?: number;\n maxLength?: number;\n }\n\n interface TNumber {\n format?: \"int64\";\n }\n}\n\nexport class TypeProvider {\n static format = TypeBoxFormat;\n\n static {\n TypeBoxFormat.Set(\"bigint\", (value: string | number) =>\n TypeProvider.isValidBigInt(value),\n );\n }\n\n static translateError(error: TypeBoxError, locale?: string): string {\n if (!locale) {\n return error.cause.message;\n }\n\n for (const [key, value] of Object.entries(Locale)) {\n if (key === \"Set\" || key === \"Get\" || key === \"Reset\") continue;\n if (key === locale || key.startsWith(`${locale}_`)) {\n return (value as (error: TLocalizedValidationError) => string)(\n error.cause,\n );\n }\n }\n return error.cause.message;\n }\n\n static setLocale(locale: string) {\n for (const [key, value] of Object.entries(Locale)) {\n if (key === \"Set\" || key === \"Get\" || key === \"Reset\") continue;\n if (key === locale || key.startsWith(`${locale}_`)) {\n Locale.Set(value as TLocalizedValidationMessageCallback);\n return;\n }\n }\n throw new AlephaError(`Locale not found: ${locale}`);\n }\n\n static isValidBigInt(value: string | number) {\n if (typeof value === \"number\") {\n return Number.isInteger(value);\n }\n\n // Reject empty or whitespace-only strings\n if (!value.trim()) return false;\n // Regex: optional minus, then digits only\n if (!/^-?\\d+$/.test(value)) return false;\n\n try {\n BigInt(value); // Will throw if invalid\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Default maximum length for strings.\n *\n * It can be set to a larger value:\n * ```ts\n * TypeProvider.DEFAULT_STRING_MAX_LENGTH = 1000000;\n * TypeProvider.DEFAULT_STRING_MAX_LENGTH = undefined; // no limit (not recommended)\n * ```\n */\n static DEFAULT_STRING_MAX_LENGTH: number | undefined = 255;\n\n /**\n * Maximum length for short strings, such as names or titles.\n */\n static DEFAULT_SHORT_STRING_MAX_LENGTH: number | undefined = 64;\n\n /**\n * Maximum length for long strings, such as descriptions or comments.\n * It can be overridden in the string options.\n *\n * It can be set to a larger value:\n * ```ts\n * TypeProvider.DEFAULT_LONG_STRING_MAX_LENGTH = 2048;\n * ```\n */\n static DEFAULT_LONG_STRING_MAX_LENGTH: number | undefined = 1024;\n\n /**\n * Maximum length for rich strings, such as HTML or Markdown.\n * This is a large value to accommodate rich text content.\n * > It's also the maximum length of PG's TEXT type.\n *\n * It can be overridden in the string options.\n *\n * It can be set to a larger value:\n * ```ts\n * TypeProvider.DEFAULT_RICH_STRING_MAX_LENGTH = 1000000;\n * ```\n */\n static DEFAULT_RICH_STRING_MAX_LENGTH: number | undefined = 65535;\n\n /**\n * Maximum number of items in an array.\n * This is a default value to prevent excessive memory usage.\n * It can be overridden in the array options.\n */\n static DEFAULT_ARRAY_MAX_ITEMS = 1000;\n\n // -------------------------------------------------------------------------------------------------------------------\n public raw = Type; // typebox reference\n public any = Type.Any;\n public void = Type.Void;\n public undefined = Type.Undefined;\n public record = Type.Record;\n public union = Type.Union;\n public tuple = Type.Tuple;\n public null = Type.Null;\n public const = Type.Literal;\n public options = Type.Options;\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Type guards to check the type of schema.\n * This is not a runtime type check, but a compile-time type guard.\n *\n * @example\n * ```ts\n * if (t.schema.isString(schema)) {\n * // schema is TString\n * }\n * ```\n */\n public readonly schema = new TypeGuard();\n\n // -------------------------------------------------------------------------------------------------------------------\n\n public extend<T extends TSchema[], U extends TProperties>(\n schema: [...T],\n properties: U,\n options?: TSchemaOptions,\n ): TInterface<T, U>;\n public extend<T extends TObject, U extends TProperties>(\n schema: T,\n properties: U,\n options?: TSchemaOptions,\n ): TInterface<[T], U>;\n public extend(\n schema: TSchema | TSchema[],\n properties: Record<string, any>,\n options?: TSchemaOptions,\n ): any {\n return Type.Interface(\n Array.isArray(schema) ? schema : [schema],\n properties,\n {\n additionalProperties: false,\n ...options,\n },\n );\n }\n\n public pick<T extends TObject, Indexer extends PropertyKey[]>(\n schema: T,\n keys: [...Indexer],\n options?: TObjectOptions,\n ): TPick<T, TKeysToIndexer<Indexer>> {\n return Type.Pick(schema, keys, {\n additionalProperties: false,\n ...options,\n });\n }\n\n public omit<T extends TObject, Indexer extends PropertyKey[]>(\n schema: T,\n keys: [...Indexer],\n options?: TObjectOptions,\n ): TOmit<T, TKeysToIndexer<Indexer>> {\n return Type.Omit(schema, keys, {\n additionalProperties: false,\n ...options,\n });\n }\n\n public partial<T extends TSchema>(\n schema: T,\n options?: TSchemaOptions,\n ): TPartial<T> {\n return Type.Partial(schema, {\n additionalProperties: false,\n ...options,\n });\n }\n\n /**\n * Create a schema for an object.\n * By default, additional properties are not allowed.\n *\n * @example\n * ```ts\n * const userSchema = t.object({\n * id: t.integer(),\n * name: t.string(),\n * });\n * ```\n */\n public object<T extends TProperties>(\n properties: T,\n options?: TObjectOptions,\n ): TObject<T> {\n return Type.Object(properties, {\n additionalProperties: false,\n ...options,\n });\n }\n\n /**\n * Create a schema for an array.\n * By default, the maximum number of items is limited to prevent excessive memory usage.\n *\n * @see TypeProvider.DEFAULT_ARRAY_MAX_ITEMS\n */\n public array<T extends TSchema>(\n schema: T,\n options?: TArrayOptions,\n ): TArray<T> {\n return Type.Array(schema, {\n maxItems: TypeProvider.DEFAULT_ARRAY_MAX_ITEMS,\n ...options,\n });\n }\n\n /**\n * Create a schema for a string.\n * For db or input fields, consider using `t.text()` instead, which has length limits.\n *\n * If you need a string with specific format (e.g. email, uuid), consider using the corresponding method (e.g. `t.email()`, `t.uuid()`).\n */\n public string(options: TStringOptions = {}): TString {\n return Type.String({\n ...options,\n });\n }\n\n /**\n * Create a schema for a string with length limits.\n * For internal strings without length limits, consider using `t.string()` instead.\n *\n * Default size is \"regular\", which has a max length of 255 characters.\n */\n public text(options: TTextOptions = {}): TString {\n const { size, ...rest } = options;\n const maxLength =\n size === \"short\"\n ? TypeProvider.DEFAULT_SHORT_STRING_MAX_LENGTH\n : size === \"long\"\n ? TypeProvider.DEFAULT_LONG_STRING_MAX_LENGTH\n : size === \"rich\"\n ? TypeProvider.DEFAULT_RICH_STRING_MAX_LENGTH\n : TypeProvider.DEFAULT_STRING_MAX_LENGTH;\n\n return Type.String({\n maxLength,\n \"~options\": {\n trim: options.trim ?? true,\n lowercase: options.lowercase ?? false,\n },\n ...rest,\n });\n }\n\n /**\n * Create a schema for a JSON object.\n * This is a record with string keys and any values.\n */\n public json(options?: TSchemaOptions): TRecord<string, TAny> {\n return t.record(t.text(), t.any(), options);\n }\n\n /**\n * Create a schema for a boolean.\n */\n public boolean(options?: TSchemaOptions): TBoolean {\n return Type.Boolean({\n ...options,\n });\n }\n\n /**\n * Create a schema for a number.\n */\n public number(options?: TNumberOptions): TNumber {\n return Type.Number({\n ...options,\n });\n }\n\n /**\n * Create a schema for an integer.\n */\n public integer(options?: TNumberOptions): TInteger {\n return Type.Integer({\n ...options,\n });\n }\n\n public int32(options?: TNumberOptions): TInteger {\n return Type.Integer({\n minimum: -2147483647,\n maximum: 2147483647,\n ...options,\n });\n }\n\n /**\n * Mimic a signed 64-bit integer.\n *\n * This is NOT a true int64, as JavaScript cannot represent all int64 values.\n * It is a number that is an integer and between -9007199254740991 and 9007199254740991.\n * Use `t.bigint()` for true int64 values represented as strings.\n */\n public int64(options?: TNumberOptions): TNumber {\n return Type.Number({\n format: \"int64\",\n multipleOf: 1,\n minimum: -9007199254740991,\n maximum: 9007199254740991,\n ...options,\n });\n }\n\n /**\n * Make a schema optional.\n */\n public optional<T extends TSchema>(schema: T): TOptionalAdd<T> {\n return Type.Optional(schema);\n }\n\n /**\n * Make a schema nullable.\n */\n public nullable<T extends TSchema>(\n schema: T,\n options?: TObjectOptions,\n ): TUnion<[TNull, T]> {\n return Type.Union([Type.Null(), schema], options);\n }\n\n /**\n * Create a schema that maps all properties of an object schema to nullable.\n */\n public nullify = <T extends TSchema>(schema: T, options?: TObjectOptions) =>\n Type.Mapped(\n Type.Identifier(\"K\"),\n Type.KeyOf(schema),\n Type.Ref(\"K\"),\n Type.Union([Type.Index(schema, Type.Ref(\"K\")), Type.Null()]),\n options,\n );\n\n /**\n * Create a schema for a string enum.\n */\n public enum<T extends string[]>(\n values: [...T],\n options?: TTextOptions,\n ): TUnsafe<T[number]> {\n return Type.Unsafe<T[number]>(\n t.text({\n enum: values,\n pattern: values.map((v) => `^${v}$`).join(\"|\"),\n ...options,\n }),\n );\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n // Codec types\n\n /**\n * Create a schema for a bigint represented as a string.\n * This is a string that validates bigint format (e.g. \"123456789\").\n */\n public bigint(options?: TStringOptions) {\n return t.string({\n ...options,\n format: \"bigint\",\n });\n }\n\n /**\n * Create a schema for a URL represented as a string.\n */\n public url(options?: TStringOptions) {\n return this.string({\n ...options,\n format: \"url\",\n });\n }\n\n /**\n * Create a schema for binary data represented as a base64 string.\n */\n public binary(options: TStringOptions) {\n return this.string({\n ...options,\n format: \"binary\",\n });\n }\n\n /**\n * Create a schema for uuid.\n */\n public uuid(options?: TStringOptions): TString {\n return this.string({\n ...options,\n format: \"uuid\",\n });\n }\n\n /**\n * Create a schema for a file-like object.\n *\n * File like mimics the File API in browsers, but is adapted to work in Node.js as well.\n *\n * Implementation of file-like objects is handled by \"alepha/file\" package.\n */\n public file(options?: { maxSize?: number }): TFile {\n return Type.Unsafe(\n Type.Any({\n [OPTIONS]: options,\n format: \"binary\",\n }),\n );\n }\n\n /**\n * @experimental\n */\n public stream(): TStream {\n return Type.Unsafe(\n Type.Any({\n format: \"stream\",\n type: \"string\",\n }),\n );\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n // Exotic types\n\n public email(options?: TStringOptions): TString {\n return this.text({\n ...options,\n format: \"email\",\n trim: true,\n lowercase: true,\n });\n }\n\n public e164(options?: TStringOptions): TString {\n return this.text({\n ...options,\n description: \"Phone number in E.164 format, e.g. +1234567890.\",\n pattern: \"^\\\\+[1-9]\\\\d{1,14}$\",\n });\n }\n\n public bcp47(options?: TStringOptions): TString {\n return this.text({\n ...options,\n description: \"BCP 47 language tag, e.g. en, en-US, fr, fr-CA.\",\n pattern: \"^[a-z]{2,3}(?:-[A-Z]{2})?$\",\n });\n }\n\n /**\n * Create a schema for short text, such as names or titles.\n * Default max length is 64 characters.\n */\n public shortText(options?: TStringOptions): TString {\n return this.text({\n size: \"short\",\n ...options,\n });\n }\n\n /**\n * Create a schema for long text, such as descriptions or comments.\n * Default max length is 1024 characters.\n */\n public longText(options?: TStringOptions): TString {\n return this.text({\n size: \"long\",\n ...options,\n });\n }\n\n /**\n * Create a schema for rich text, such as HTML or Markdown.\n * Default max length is 65535 characters.\n */\n public richText(options?: TStringOptions): TString {\n return this.text({\n size: \"rich\",\n ...options,\n });\n }\n\n /**\n * Create a schema for a string enum e.g. LIKE_THIS.\n */\n public snakeCase = (options?: TStringOptions) =>\n this.text({\n pattern: \"^[A-Z_-]+$\",\n ...options,\n });\n\n /**\n * Create a schema for an object with a value and label.\n */\n public valueLabel = (options?: TObjectOptions) =>\n this.object(\n {\n value: this.snakeCase({\n description: \"Machine-readable value.\",\n }),\n label: this.text({\n description: \"Human-readable label.\",\n }),\n description: this.optional(\n this.text({\n description: \"Description of the value.\",\n size: \"long\",\n }),\n ),\n },\n options,\n );\n\n public datetime = (options?: TStringOptions) =>\n t.text({\n ...options,\n format: \"date-time\",\n });\n\n public date = (options?: TStringOptions) =>\n t.text({\n ...options,\n format: \"date\",\n });\n\n public time = (options?: TStringOptions) =>\n t.text({\n ...options,\n format: \"time\",\n });\n\n public duration = (options?: TStringOptions) =>\n t.text({\n ...options,\n format: \"duration\",\n });\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport type TextLength = \"short\" | \"regular\" | \"long\" | \"rich\";\n\nexport interface TTextOptions extends TStringOptions {\n /**\n * Predefined size of the text.\n *\n * - `short` - short text, such as names or titles. Default max length is 64 characters.\n * - `regular` - regular text, such as single-line input. Default max length is 255 characters.\n * - `long` - long text, such as descriptions or comments. Default max length is 1024 characters.\n * - `rich` - rich text, such as HTML or Markdown. Default max length is 65535 characters.\n *\n * You can override the default max length by specifying `maxLength` in the options.\n *\n * @default \"regular\"\n */\n size?: TextLength;\n\n /**\n * Trim whitespace from both ends of the string.\n *\n * @default true\n */\n trim?: boolean;\n\n /**\n * Convert the string to lowercase.\n *\n * @default false\n */\n lowercase?: boolean;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport const t: TypeProvider = new TypeProvider();\n","import type { Static, TObject } from \"typebox\";\nimport { AlephaError } from \"../errors/AlephaError.ts\";\nimport { t } from \"../providers/TypeProvider.ts\";\nimport { $context } from \"./$context.ts\";\n\n/**\n * Get typed values from environment variables.\n *\n * @example\n * ```ts\n * const alepha = Alepha.create({\n * env: {\n * // Alepha.create() will also use process.env when running on Node.js\n * HELLO: \"world\",\n * }\n * });\n *\n * class App {\n * log = $logger();\n *\n * // program expect a var env \"HELLO\" as string to works\n * env = $env(t.object({\n * HELLO: t.text()\n * }));\n *\n * sayHello = () => this.log.info(\"Hello ${this.env.HELLO}\")\n * }\n *\n * run(alepha.with(App));\n * ```\n */\nexport const $env = <T extends TObject>(type: T): Static<T> => {\n const { alepha } = $context();\n\n // allow to inject TypeBox schemas\n if (!t.schema.isObject(type)) {\n throw new AlephaError(\"Type must be an TObject\");\n }\n\n return alepha.parseEnv(type) as Static<T>;\n};\n","import type { Hooks } from \"../Alepha.ts\";\nimport { KIND } from \"../constants/KIND.ts\";\nimport { createDescriptor, Descriptor } from \"../helpers/descriptor.ts\";\nimport type { Async } from \"../interfaces/Async.ts\";\n\n/**\n * Registers a new hook.\n *\n * ```ts\n * import { $hook } from \"alepha\";\n *\n * class MyProvider {\n * onStart = $hook({\n * name: \"start\", // or \"configure\", \"ready\", \"stop\", ...\n * handler: async (app) => {\n * // await db.connect(); ...\n * }\n * });\n * }\n * ```\n *\n * Hooks are used to run async functions from all registered providers/services.\n *\n * You can't register a hook after the App has started.\n *\n * It's used under the hood by the `configure`, `start`, and `stop` methods.\n * Some modules also use hooks to run their own logic. (e.g. `alepha/server`).\n *\n * You can create your own hooks by using module augmentation:\n *\n * ```ts\n * declare module \"alepha\" {\n *\n * interface Hooks {\n * \"my:custom:hook\": {\n * arg1: string;\n * }\n * }\n * }\n *\n * await alepha.events.emit(\"my:custom:hook\", { arg1: \"value\" });\n * ```\n *\n */\nexport const $hook = <T extends keyof Hooks>(options: HookOptions<T>) =>\n createDescriptor(HookDescriptor<T>, options);\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface HookOptions<T extends keyof Hooks> {\n /**\n * The name of the hook. \"configure\", \"start\", \"ready\", \"stop\", ...\n */\n on: T;\n\n /**\n * The handler to run when the hook is triggered.\n */\n handler: (args: Hooks[T]) => Async<any>;\n\n /**\n * Force the hook to run first or last on the list of hooks.\n */\n priority?: \"first\" | \"last\";\n\n /**\n * Empty placeholder, not implemented yet. :-)\n */\n before?: object | Array<object>;\n\n /**\n * Empty placeholder, not implemented yet. :-)\n */\n after?: object | Array<object>;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport class HookDescriptor<T extends keyof Hooks> extends Descriptor<\n HookOptions<T>\n> {\n public called = 0;\n\n protected onInit() {\n this.alepha.events.on(this.options.on, {\n caller: this.config.service,\n priority: this.options.priority,\n callback: async (args: any) => {\n this.called += 1;\n await this.options.handler(args);\n },\n });\n }\n}\n\n$hook[KIND] = HookDescriptor;\n","import type { State } from \"../Alepha.ts\";\nimport { OPTIONS } from \"../constants/OPTIONS.ts\";\nimport type { Static, TObject } from \"../providers/TypeProvider.ts\";\nimport type { Atom } from \"./$atom.ts\";\nimport { $context } from \"./$context.ts\";\n\n/**\n * Subscribes to an atom's state and returns its current value for use in components.\n *\n * Creates a reactive connection between an atom and a component, automatically registering\n * the atom in the application state if not already registered. The returned value is reactive\n * and will update when the atom's state changes.\n *\n * **Use Cases**: Accessing global state, sharing data between components, reactive UI updates\n *\n * @example\n * ```ts\n * const userState = $atom({ schema: t.object({ name: t.text(), role: t.text() }) });\n *\n * class UserComponent {\n * user = $use(userState); // Reactive reference to atom state\n *\n * render() {\n * return <div>Hello {this.user.name}!</div>;\n * }\n * }\n * ```\n */\nexport const $use = <T extends TObject, N extends string>(\n atom: Atom<T, N>,\n): Readonly<Static<T>> => {\n const { alepha } = $context();\n\n // register atom in state if not already registered\n alepha.state.register(atom);\n\n const init = alepha.state.get(atom.key as keyof State) as object;\n\n return {\n [OPTIONS]: { getter: atom.key }, // alepha will replace this with by a real 'get prop()'\n ...init,\n } as Static<T>;\n};\n","import { AlephaError } from \"./AlephaError.ts\";\n\nexport class AppNotStartedError extends AlephaError {\n readonly name = \"AppNotStartedError\";\n\n constructor() {\n super(\"App not started. Please start the app before.\");\n }\n}\n","import type { Page } from \"../schemas/pageSchema.ts\";\n\n/**\n * Create a pagination object from an array of entities.\n *\n * This is a pure function that works with any data source (databases, APIs, caches, arrays, etc.).\n * It handles the core pagination logic including:\n * - Slicing the content to the requested page size\n * - Calculating pagination metadata (offset, page number, etc.)\n * - Determining navigation state (isFirst, isLast)\n * - Including sort metadata when provided\n *\n * @param entities - The entities to paginate (should include one extra item to detect if there's a next page)\n * @param limit - The limit of the pagination (page size)\n * @param offset - The offset of the pagination (starting position)\n * @param sort - Optional sort metadata to include in response\n * @returns A complete Page object with content and metadata\n *\n * @example Basic pagination\n * ```ts\n * const users = await fetchUsers({ limit: 11, offset: 0 }); // Fetch limit + 1\n * const page = createPagination(users, 10, 0);\n * // page.content has max 10 items\n * // page.page.isLast tells us if there are more pages\n * ```\n *\n * @example With sorting\n * ```ts\n * const page = createPagination(\n * entities,\n * 10,\n * 0,\n * [{ column: \"name\", direction: \"asc\" }]\n * );\n * ```\n *\n * @example In a custom service\n * ```ts\n * class MyService {\n * async listItems(page: number, size: number) {\n * const items = await this.fetchItems({ limit: size + 1, offset: page * size });\n * return createPagination(items, size, page * size);\n * }\n * }\n * ```\n */\nexport function createPagination<T>(\n entities: T[],\n limit = 10,\n offset = 0,\n sort?: Array<{ column: string; direction: \"asc\" | \"desc\" }>,\n): Page<T> {\n const content = entities.slice(0, limit);\n const hasNext = entities.length === limit + 1;\n const pageNumber = Math.floor(offset / limit);\n\n return {\n content,\n page: {\n number: pageNumber,\n size: limit,\n offset,\n numberOfElements: content.length,\n isEmpty: content.length === 0,\n isFirst: pageNumber === 0,\n isLast: !hasNext,\n ...(sort && sort.length > 0\n ? {\n sort: {\n sorted: true,\n fields: sort.map((s) => ({\n field: s.column,\n direction: s.direction,\n })),\n },\n }\n : {}),\n },\n };\n}\n","import { type Static, t } from \"../providers/TypeProvider.ts\";\n\nexport const pageQuerySchema = t.object({\n page: t.optional(\n t.integer({\n description: \"The page number to retrieve.\",\n minimum: 0,\n default: 0,\n }),\n ),\n size: t.optional(\n t.integer({\n description: \"The number of items per page.\",\n minimum: 1,\n maximum: 100,\n default: 10,\n }),\n ),\n sort: t.optional(\n t.text({\n description:\n \"Sort by field(s). Multiple columns separated by comma. Prefix with '-' for DESC. Examples: 'name' (ASC), '-createdAt' (DESC), 'role,-name' (role ASC, name DESC)\",\n }),\n ),\n});\n\nexport type PageQuery = Static<typeof pageQuerySchema>;\n","import {\n type Static,\n type TArray,\n type TObject,\n type TObjectOptions,\n type TRecord,\n TypeProvider,\n t,\n} from \"../providers/TypeProvider.ts\";\n\nexport const pageMetadataSchema = t.object({\n number: t.integer({ description: \"Page number, starting from 0\" }),\n size: t.integer({\n description: \"Number of items per page (requested page size)\",\n }),\n offset: t.integer({\n description: \"Offset in the dataset (page × size)\",\n }),\n numberOfElements: t.integer({\n description:\n \"Number of elements in THIS page (content.length). Different from totalElements which is the total across all pages.\",\n }),\n totalElements: t.optional(\n t.integer({\n description:\n \"Total number of elements across all pages. Only available when counting is enabled.\",\n }),\n ),\n totalPages: t.optional(\n t.integer({\n description:\n \"Total number of pages. Only available when `totalElements` is present.\",\n }),\n ),\n isEmpty: t.boolean({\n description:\n \"Indicates if the current page has no items (numberOfElements === 0)\",\n }),\n isFirst: t.boolean({\n description: \"Indicates if this is the first page (number === 0)\",\n }),\n isLast: t.boolean({\n description:\n \"Indicates if this is the last page (no more pages after this)\",\n }),\n sort: t.optional(\n t.object({\n sorted: t.boolean({\n description: \"Whether the results are sorted\",\n }),\n fields: t.array(\n t.object({\n field: t.text({\n description: \"The field used for sorting\",\n }),\n direction: t.enum([\"asc\", \"desc\"], {\n description: \"The direction of the sort. Either 'asc' or 'desc'\",\n }),\n }),\n ),\n }),\n ),\n});\n\n/**\n * Create a pagination schema for the given object schema.\n *\n * Provides a standardized pagination response format compatible with Spring Data's Page interface.\n * This schema can be used across any data source (databases, APIs, caches, etc.).\n *\n * @example\n * ```ts\n * const userSchema = t.object({ id: t.integer(), name: t.text() });\n * const userPageSchema = pageSchema(userSchema);\n * ```\n *\n * @example In an API endpoint\n * ```ts\n * $action({\n * output: pageSchema(UserSchema),\n * handler: async () => {\n * return await userRepo.paginate();\n * }\n * })\n * ```\n */\nexport const pageSchema = <T extends TObject | TRecord>(\n objectSchema: T,\n options?: TObjectOptions,\n): TPage<T> =>\n t.object(\n {\n content: t.array(objectSchema),\n page: pageMetadataSchema,\n },\n options,\n );\n\nexport type TPage<T extends TObject | TRecord> = TObject<{\n content: TArray<T>;\n page: typeof pageMetadataSchema;\n}>;\n\n/**\n * Opinionated type definition for a paginated response.\n *\n * Inspired by Spring Data's Page interface with all essential pagination metadata.\n * This generic type can be used with any data source.\n *\n * @example\n * ```ts\n * const page: Page<User> = {\n * content: [user1, user2, ...],\n * page: {\n * number: 0,\n * size: 10,\n * offset: 0,\n * numberOfElements: 10,\n * totalElements: 1200,\n * totalPages: 120,\n * isEmpty: false,\n * isFirst: true,\n * isLast: false,\n * sort: {\n * sorted: true,\n * fields: [\n * { field: \"name\", direction: \"asc\" }\n * ]\n * }\n * }\n * }\n * ```\n */\nexport type Page<T> = {\n /**\n * Array of items on the current page.\n */\n content: T[];\n page: Static<typeof pageMetadataSchema>;\n};\n\nexport type PageMetadata = Static<typeof pageMetadataSchema>;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\ndeclare module \"alepha\" {\n interface TypeProvider {\n /**\n * Create a schema for a paginated response.\n */\n page<T extends TObject | TRecord>(itemSchema: T): TPage<T>;\n }\n}\n\nTypeProvider.prototype.page = (itemSchema) => pageSchema(itemSchema);\n","import { Alepha } from \"./Alepha.ts\";\nimport type { RunOptions } from \"./interfaces/Run.ts\";\nimport type { Service } from \"./interfaces/Service.ts\";\n\nexport * from \"./index.shared.ts\";\n\nexport const run = (\n entry: Alepha | Service | Array<Service>,\n opts?: RunOptions,\n): Alepha => {\n const alepha =\n entry instanceof Alepha ? entry : Alepha.create({ env: { ...opts?.env } });\n\n if (!(entry instanceof Alepha)) {\n const entries = Array.isArray(entry) ? entry : [entry];\n for (const e of entries) {\n alepha.with(e);\n }\n }\n\n if (import.meta?.hot) {\n import.meta.hot.on(\"alepha:reload\", async () => {\n window.location.reload();\n });\n }\n\n (async () => {\n try {\n await opts?.configure?.(alepha);\n\n await alepha.start();\n\n if (opts?.ready) {\n await opts.ready(alepha);\n }\n } catch (error) {\n alepha.log?.error(\"Alepha failed to start\", error);\n }\n })();\n\n (window as any).alepha = alepha;\n\n return alepha;\n};\n"],"mappings":";;;;;;;;;;;;;AAKA,MAAaA,OAAsB,OAAO,IAAI,cAAc;;;;;;;;;ACA5D,MAAaC,SAAwB,OAAO,IAAI,gBAAgB;;;;;;;;;ACAhE,MAAaC,UAAyB,OAAO,IAAI,iBAAiB;;;;;;;ACAlE,IAAa,cAAb,cAAiC,MAAM;CACrC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACiDT,MAAa,WACX,YACoB;CACpB,MAAM,EAAE,WAAW,EAAE,EAAE,cAAc,EAAE,EAAE,SAAS;AAGlD,KAAI,CAAC,QAAQ,CAAC,OAAO,WAAW,KAAK,KAAK,CACxC,OAAM,IAAI,YACR,wBAAwB,KAAK,6DAC9B;CAGH,MAAM,IAAI,cAAc,OAAO;EAC7B,UAAU;EAEV,SAAS,QAAsB;AAC7B,OAAI,OAAO,QAAQ,aAAa,YAAY;AAC1C,YAAQ,SAAS,OAAO;AACxB;;AAGF,QAAK,MAAM,WAAW,SACpB,QAAO,OAAO,SAAS,EACrB,QAAQ,KAAK,aACd,CAAC;;;AAMR,QAAO,eAAe,GAAG,QAAQ;EAC/B,OAAO;EACP,UAAU;EACX,CAAC;AAEF,MAAK,MAAM,WAAW,SACpB,KAAI,CAAC,OAAO,GAAG,QAAQ,CACrB,CAAC,QAAuB,UAAU;AAItC,MAAK,MAAM,WAAW,YACpB,KAAI,OAAO,QAAQ,UAAU,WAC3B,SAAQ,MAAM,UAAU;AAI5B,QAAO;;;;;AAuCT,IAAsB,SAAtB,MAAsB,OAAO;CAK3B,OAAO,aAAa;;;;CAKpB,OAAO,GAAG,MAAwB;AAChC,SAAO,KAAK,qBAAqB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,EACZ,aAAa,8BACd,CAAC;GACF,WAAW,EAAE,KAAK,CAAC,OAAO,OAAO,EAAE,EACjC,aAAa,qDACd,CAAC;GACH,CAAC,CACH;EACF,CAAC,CACH;CACF,CAAC;;;;;;;;;;;;;;;;;;;;;;;AAwBF,MAAa,cACX,cACA,YAEA,EAAE,OACA;CACE,SAAS,EAAE,MAAM,aAAa;CAC9B,MAAM;CACP,EACD,QACD;AA0DH,aAAa,UAAU,QAAQ,eAAe,WAAW,WAAW;;;;ACpJpE,MAAa,OACX,OACA,SACW;CACX,MAAM,SACJ,iBAAiB,SAAS,QAAQ,OAAO,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,KAAK,EAAE,CAAC;AAE5E,KAAI,EAAE,iBAAiB,SAAS;EAC9B,MAAM,UAAU,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM;AACtD,OAAK,MAAM,KAAK,QACd,QAAO,KAAK,EAAE;;AAIlB,KAAI,OAAO,MAAM,IACf,QAAO,KAAK,IAAI,GAAG,iBAAiB,YAAY;AAC9C,SAAO,SAAS,QAAQ;GACxB;AAGJ,EAAC,YAAY;AACX,MAAI;AACF,SAAM,MAAM,YAAY,OAAO;AAE/B,SAAM,OAAO,OAAO;AAEpB,OAAI,MAAM,MACR,OAAM,KAAK,MAAM,OAAO;WAEnB,OAAO;AACd,UAAO,KAAK,MAAM,0BAA0B,MAAM;;KAElD;AAEJ,CAAC,OAAe,SAAS;AAEzB,QAAO"}
|
|
1
|
+
{"version":3,"file":"index.browser.js","names":["KIND: unique symbol","MODULE: unique symbol","OPTIONS: unique symbol","__alephaRef: {\n alepha?: Alepha;\n service?: Service & {\n [MODULE]?: Service;\n };\n parent?: Service;\n}","error: any","obj: any","ctx: any","atoms: Array<AtomWithValue>","entry: ServiceEntry<T>","instance: T","definition: ServiceDefinition<T>","parent","graph: Record<\n string,\n { from: string[]; as?: string[]; module?: string }\n >","list: Array<T>","t: TypeProvider"],"sources":["../../src/core/constants/KIND.ts","../../src/core/constants/MODULE.ts","../../src/core/constants/OPTIONS.ts","../../src/core/errors/AlephaError.ts","../../src/core/errors/CircularDependencyError.ts","../../src/core/errors/ContainerLockedError.ts","../../src/core/errors/TooLateSubstitutionError.ts","../../src/core/errors/MissingContextError.ts","../../src/core/helpers/ref.ts","../../src/core/primitives/$context.ts","../../src/core/helpers/primitive.ts","../../src/core/interfaces/Service.ts","../../src/core/primitives/$module.ts","../../src/core/providers/AlsProvider.ts","../../src/core/primitives/$inject.ts","../../src/core/providers/Json.ts","../../src/core/providers/SchemaCodec.ts","../../src/core/providers/JsonSchemaCodec.ts","../../src/core/errors/TypeBoxError.ts","../../src/core/providers/SchemaValidator.ts","../../src/core/providers/CodecManager.ts","../../src/core/providers/EventManager.ts","../../src/core/primitives/$atom.ts","../../src/core/providers/StateManager.ts","../../src/core/Alepha.ts","../../src/core/errors/AppNotStartedError.ts","../../src/core/helpers/createPagination.ts","../../src/core/helpers/FileLike.ts","../../src/core/providers/TypeProvider.ts","../../src/core/primitives/$env.ts","../../src/core/primitives/$hook.ts","../../src/core/primitives/$use.ts","../../src/core/schemas/pageQuerySchema.ts","../../src/core/schemas/pageSchema.ts","../../src/core/index.browser.ts"],"sourcesContent":["/**\n * Used for identifying primitives.\n *\n * @internal\n */\nexport const KIND: unique symbol = Symbol.for(\"Alepha.Kind\");\n","/**\n * Used for identifying modules.\n *\n * @internal\n */\nexport const MODULE: unique symbol = Symbol.for(\"Alepha.Module\");\n","/**\n * Used for primitives options.\n *\n * @internal\n */\nexport const OPTIONS: unique symbol = Symbol.for(\"Alepha.Options\");\n","// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Default error class for Alepha.\n */\nexport class AlephaError extends Error {\n name = \"AlephaError\";\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n","import { AlephaError } from \"./AlephaError.ts\";\n\nexport class CircularDependencyError extends AlephaError {\n readonly name = \"CircularDependencyError\";\n\n constructor(provider: string, parents?: string[]) {\n super(\n `Instance not available. Looks like a circular dependency. ? -> ${parents?.map((name) => `${name} -> `).join(\"\")}${provider} -> ?`,\n );\n }\n}\n","import { AlephaError } from \"./AlephaError.ts\";\n\nexport class ContainerLockedError extends AlephaError {\n readonly name = \"ContainerLockedError\";\n\n constructor(\n message = \"Container is locked. No more providers can be added.\",\n ) {\n super(message);\n }\n}\n","import { AlephaError } from \"./AlephaError.ts\";\n\nexport class TooLateSubstitutionError extends AlephaError {\n readonly name = \"TooLateSubstitutionError\";\n\n constructor(original: string, substitution: string) {\n super(\n `Service already substituted. Please, substitute Service '${original}' with Service '${substitution}' before using it.`,\n );\n }\n}\n","import { AlephaError } from \"./AlephaError.ts\";\n\nexport class MissingContextError extends AlephaError {\n readonly name = \"MissingContextError\";\n\n constructor() {\n super(\"Missing context. Did you forget to call Alepha.create()?\");\n this.name = \"MissingContextError\";\n }\n}\n","import type { Alepha } from \"../Alepha.ts\";\nimport { MODULE } from \"../constants/MODULE.ts\";\nimport type { Service } from \"../interfaces/Service.ts\";\n\n/**\n * Store the current context and definition during injection phase.\n *\n * @internal\n */\nexport const __alephaRef: {\n alepha?: Alepha;\n service?: Service & {\n [MODULE]?: Service;\n };\n parent?: Service;\n} = {};\n\n/**\n * Note:\n *\n * This file is used to share context between $primitives and the Alepha core during the injection phase.\n *\n * There is no side effect as long as Alepha is not used concurrently in multiple contexts (which is not the case).\n *\n * // __alephaRef === undefined\n * // begin alepha.with()\n * // __alephaRef.context = alepha\n * // ... injection phase ...\n * // __alephaRef.context = undefined\n * // end alepha.with()\n * // __alephaRef === undefined\n *\n * As .with() is synchronous, there is no risk of context leakage.\n *\n * ---------------------------------------------------------------------------------------------------------------------\n *\n * Why this helper?\n *\n * It allows to avoid passing Alepha instance to every $hook, $inject, etc. calls. It's a beautiful syntactic sugar.\n *\n * With sugar:\n *\n * class A {\n * on = $hook( ... ) // <- __alephaRef is set here\n * }\n *\n * Without sugar:\n *\n * class A {\n * constructor(alepha: Alepha) {\n * this.on = $hook(alepha, ... ) // <- no need of __alephaRef\n * }\n * }\n *\n * One main goal of Alepha is working with classes but without the class verbosity.\n * Forcing to pass Alepha instance in constructors would be a step back in that direction!\n */\n","import type { Alepha } from \"../Alepha.ts\";\nimport { MODULE } from \"../constants/MODULE.ts\";\nimport { MissingContextError } from \"../errors/MissingContextError.ts\";\nimport { __alephaRef } from \"../helpers/ref.ts\";\nimport type { Service } from \"../interfaces/Service.ts\";\n\n/**\n * Get Alepha instance and current service from the current context.\n *\n * It can only be used inside $primitive functions.\n *\n * ```ts\n * import { $context } from \"alepha\";\n *\n * const $hello = () => {\n * const { alepha, service, module } = $context();\n *\n * // alepha - alepha instance\n * // service - class which is creating this primitive, this is NOT the instance but the service definition\n * // module - module definition, if any\n *\n * return {};\n * }\n *\n * class MyService {\n * hello = $hello();\n * }\n *\n * const alepha = new Alepha().with(MyService);\n * ```\n *\n * @internal\n */\nexport const $context = (): ContextPrimitive => {\n if (!__alephaRef.alepha) {\n throw new MissingContextError();\n }\n\n return {\n alepha: __alephaRef.alepha,\n service: __alephaRef.service,\n module: __alephaRef.service?.[MODULE],\n };\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface ContextPrimitive {\n /**\n * Alepha instance.\n */\n alepha: Alepha;\n /**\n * Service definition which is creating this primitive.\n * This is NOT the instance but the service definition.\n */\n service?: Service;\n /**\n * Module definition, if any.\n */\n module?: Service;\n}\n","import { Alepha } from \"../Alepha.ts\";\nimport { KIND } from \"../constants/KIND.ts\";\nimport { MODULE } from \"../constants/MODULE.ts\";\nimport type { InstantiableClass, Service } from \"../interfaces/Service.ts\";\nimport { $context } from \"../primitives/$context.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface PrimitiveArgs<T extends object = {}> {\n options: T;\n alepha: Alepha;\n service: InstantiableClass<Service>;\n module?: Service;\n}\n\nexport interface PrimitiveConfig {\n propertyKey: string;\n service: InstantiableClass<Service>;\n module?: Service;\n}\n\nexport abstract class Primitive<T extends object = {}> {\n protected readonly alepha: Alepha;\n\n public readonly options: T;\n public readonly config: PrimitiveConfig;\n\n constructor(args: PrimitiveArgs<T>) {\n this.alepha = args.alepha;\n this.options = args.options;\n this.config = {\n propertyKey: \"\",\n service: args.service,\n module: args.module,\n };\n }\n\n /**\n * Called automatically by Alepha after the primitive is created.\n */\n protected onInit(): void {\n // this method can be overridden by subclasses to perform initialization logic.\n // - use onInit instead of the constructor when you need to access `config.propertyKey`\n // - onInit must be synchronous\n }\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport type PrimitiveFactory<TPrimitive extends Primitive = Primitive> = {\n (options: TPrimitive[\"options\"]): TPrimitive;\n [KIND]: InstantiableClass<TPrimitive>;\n};\n\nexport type PrimitiveFactoryLike<T extends object = any> = {\n (options: T): any;\n [KIND]: any;\n};\n\nexport const createPrimitive = <TPrimitive extends Primitive>(\n primitive: InstantiableClass<TPrimitive> & { [MODULE]?: Service },\n options: TPrimitive[\"options\"],\n): TPrimitive => {\n const { alepha, service } = $context();\n\n if (MODULE in primitive && primitive[MODULE]) {\n alepha.with(primitive[MODULE]);\n }\n\n return alepha.inject(primitive, {\n lifetime: \"transient\",\n args: [\n {\n options,\n alepha: alepha,\n service: service ?? Alepha,\n },\n ],\n });\n};\n","// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * In Alepha, a service is a class that can be instantiated or an abstract class. Nothing more, nothing less...\n */\nexport type Service<T extends object = any> =\n | InstantiableClass<T>\n | AbstractClass<T>\n | RunFunction<T>;\n\nexport type RunFunction<T extends object = any> = (...args: any[]) => T | void;\n\nexport type InstantiableClass<T extends object = any> = new (\n ...args: any[]\n) => T;\n\n/**\n * Abstract class is a class that cannot be instantiated directly!\n * It widely used for defining interfaces.\n */\nexport type AbstractClass<T extends object = any> = abstract new (\n ...args: any[]\n) => T;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Service substitution allows you to register a class as a different class.\n * Providing class A, but using class B instead.\n * This is useful for testing, mocking, or providing a different implementation of a service.\n *\n * class A is mostly an AbstractClass, while class B is an InstantiableClass.\n */\nexport interface ServiceSubstitution<T extends object = any> {\n /**\n * Every time someone asks for this class, it will be provided with the 'use' class.\n */\n provide: Service<T>;\n\n /**\n * Service to use instead of the 'provide' service.\n *\n * Syntax is inspired by Angular's DI system.\n */\n use: Service<T>;\n\n /**\n * If true, if the service already exists -> just ignore the substitution and do not throw an error.\n * Mostly used for plugins to enforce a substitution without throwing an error.\n */\n optional?: boolean;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Every time you register a service, you can use this type to define it.\n *\n * alepha.with( ServiceEntry )\n * or\n * alepha.with( provide: ServiceEntry, use: MyOwnServiceEntry )\n *\n * And yes, you declare the *type* of the service, not the *instance*.\n */\nexport type ServiceEntry<T extends object = any> =\n | Service<T>\n | ServiceSubstitution<T>;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport function isClass(func: any): func is InstantiableClass {\n // Classes have a non-writable prototype.constructor\n if (typeof func !== \"function\") return false;\n\n const descriptor = Object.getOwnPropertyDescriptor(func, \"prototype\");\n return !!descriptor && !descriptor.writable;\n}\n","import type { Alepha } from \"../Alepha.ts\";\nimport { KIND } from \"../constants/KIND.ts\";\nimport { MODULE } from \"../constants/MODULE.ts\";\nimport { AlephaError } from \"../errors/AlephaError.ts\";\nimport type { PrimitiveFactoryLike } from \"../helpers/primitive.ts\";\nimport type { Service } from \"../interfaces/Service.ts\";\n\n/**\n * Wrap Services and Primitives into a Module.\n *\n * - A module is just a Service with some extra {@link Module}.\n * - You must attach a `name` to it.\n * - Name must follow the pattern: `project.module.submodule`. (e.g. `myapp.users.auth`).\n *\n * @example\n * ```ts\n * import { $module } from \"alepha\";\n * import { MyService } from \"./MyService.ts\";\n *\n * // export MyService, so it can be used everywhere (optional)\n * export * from \"./MyService.ts\";\n *\n * export default $module({\n * name: \"my.project.module\",\n * // MyService will have a module context \"my.project.module\"\n * services: [MyService],\n * });\n * ```\n *\n * ### Why Modules?\n *\n * #### Logging\n *\n * By default, AlephaLogger will log the module name in the logs.\n * This helps to identify where the logs are coming from.\n *\n * You can also set different log levels for different modules.\n * It means you can set 'some.very.specific.module' to 'debug' and keep the rest of the application to 'info'.\n *\n * #### Modulith\n *\n * Force to structure your application in modules, even if it's a single deployable unit.\n * It helps to keep a clean architecture and avoid monolithic applications.\n *\n * A strict mode flag will probably come to enforce module boundaries.\n * -> Throwing errors when a service from another module is injected.\n * But it's not implemented yet.\n *\n * ### When not to use Modules?\n *\n * Small applications does not need modules. It's better to keep it simple.\n * Modules are more useful when the application grows and needs to be structured.\n * If we speak with number of `$actions`, a module should be used when you have more than 30 actions in a single module.\n * Meaning that if you have 100 actions, you should have at least 3 modules.\n */\nexport const $module = <T extends object = {}>(\n options: ModulePrimitiveOptions,\n): Service<Module> => {\n const { services = [], primitives = [], name } = options;\n\n // ensure name is valid\n if (!name || !Module.NAME_REGEX.test(name)) {\n throw new AlephaError(\n `Invalid module name '${name}'. It should be in the format of 'project.module.submodule'`,\n );\n }\n\n const $ = class extends Module {\n options = options;\n\n register(alepha: Alepha): void {\n if (typeof options.register === \"function\") {\n options.register(alepha);\n return;\n }\n\n for (const service of services) {\n alepha.inject(service, {\n parent: this.constructor as Service<Module>,\n });\n }\n }\n };\n\n // force name property\n Object.defineProperty($, \"name\", {\n value: name,\n writable: false,\n });\n\n for (const service of services) {\n if (!Module.is(service)) {\n (service as WithModule)[MODULE] = $;\n }\n }\n\n for (const factory of primitives) {\n if (typeof factory[KIND] === \"function\") {\n factory[KIND][MODULE] = $;\n }\n }\n\n return $; // module as Service<Module<T>>;\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface ModulePrimitiveOptions {\n /**\n * Name of the module.\n *\n * It should be in the format of `project.module.submodule`.\n */\n name: string;\n\n /**\n * List all services related to this module.\n *\n * If you don't declare 'register' function, all services will be registered automatically.\n * If you declare 'register' function, you must handle the registration of ALL services manually.\n */\n services?: Array<Service>;\n\n /**\n * List of $primitives to register in the module.\n */\n primitives?: Array<PrimitiveFactoryLike>;\n\n /**\n * By default, module will register ALL services.\n * You can override this behavior by providing a register function.\n * It's useful when you want to register services conditionally or in a specific order.\n *\n * Again, if you declare 'register', you must handle the registration of ALL services manually.\n */\n register?: (alepha: Alepha) => void;\n}\n\n/**\n * Base class for all modules.\n */\nexport abstract class Module {\n public abstract readonly options: ModulePrimitiveOptions;\n\n public abstract register(alepha: Alepha): void;\n\n static NAME_REGEX = /^[a-z]+(\\.[a-z][a-z0-9-]*)*$/;\n\n /**\n * Check if a Service is a Module.\n */\n static is(ctor: Service): boolean {\n return ctor.prototype instanceof Module;\n }\n\n /**\n * Get the Module of a Service.\n *\n * Returns undefined if the Service is not part of a Module.\n */\n static of(ctor: Service): Service<Module> | undefined {\n return (ctor as WithModule)[MODULE];\n }\n}\n\n/**\n * Helper type to add Module metadata to a Service.\n */\nexport type WithModule<T extends object = any> = T & {\n [MODULE]?: Service;\n};\n","import type { AsyncLocalStorage } from \"node:async_hooks\";\n\nexport type AsyncLocalStorageData = any;\n\nexport class AlsProvider {\n static create = (): AsyncLocalStorage<AsyncLocalStorageData> | undefined => {\n return undefined;\n };\n\n public als?: AsyncLocalStorage<AsyncLocalStorageData>;\n\n constructor() {\n this.als = AlsProvider.create();\n }\n\n public createContextId(): string {\n return crypto.randomUUID();\n }\n\n public run<R>(callback: () => R, data: Record<string, any> = {}): R {\n if (!this.als) {\n return callback();\n }\n\n data.registry ??= new Map();\n data.context ??= this.createContextId();\n\n return this.als.run(data, callback);\n }\n\n public exists(): boolean {\n return !!this.get(\"context\");\n }\n\n public get<T>(key: string): T | undefined {\n if (!this.als) {\n return undefined;\n }\n\n const store = this.als.getStore();\n if (store) {\n return store[key] as T;\n }\n\n return undefined;\n }\n\n public set<T>(key: string, value: T): void {\n if (!this.als) {\n return;\n }\n\n const store = this.als.getStore();\n if (store) {\n store[key] = value;\n }\n }\n}\n","import { Primitive } from \"../helpers/primitive.ts\";\nimport type { InstantiableClass, Service } from \"../interfaces/Service.ts\";\nimport { $context } from \"./$context.ts\";\n\n/**\n * Get the instance of the specified type from the context.\n *\n * ```ts\n * class A { }\n * class B {\n * a = $inject(A);\n * }\n * ```\n */\nexport const $inject = <T extends object>(\n type: Service<T>,\n opts: InjectOptions<T> = {},\n): T => {\n const { alepha, service } = $context();\n\n // _ = $inject(Alepha)\n if (type === alepha.constructor) {\n return alepha as T;\n }\n\n return alepha.inject(type, {\n // keep the parent for better error messages and circular dependencies detection\n parent: service ?? (alepha.constructor as Service),\n ...opts,\n });\n};\n\nexport class InjectPrimitive extends Primitive {}\n\nexport interface InjectOptions<T extends object = any> {\n /**\n * - 'transient' → Always a new instance on every inject. Zero caching.\n * - 'singleton' → One instance per Alepha runtime (per-thread). Never disposed until Alepha shuts down. (default)\n * - 'scoped' → One instance per AsyncLocalStorage context.\n * - A new scope is created when Alepha handles a request, a scheduled job, a queue worker task...\n * - You can also start a manual scope via alepha.context.run(() => { ... }).\n * - When the scope ends, the scoped registry is discarded.\n *\n * @default \"singleton\"\n */\n lifetime?: \"transient\" | \"singleton\" | \"scoped\";\n\n /**\n * Constructor arguments to pass when creating a new instance.\n */\n args?: ConstructorParameters<InstantiableClass<T>>;\n\n /**\n * Parent that requested the instance.\n *\n * @internal\n */\n parent?: Service | null;\n}\n","/**\n * Mimics the JSON global object with stringify and parse methods.\n *\n * Used across the codebase via dependency injection.\n */\nexport class Json {\n public stringify(\n value: any,\n replacer?: (this: any, key: string, value: any) => any,\n space?: string | number,\n ): string {\n return JSON.stringify(value, replacer, space);\n }\n\n public parse(\n text: string,\n reviver?: (this: any, key: string, value: any) => any,\n ) {\n return JSON.parse(text, reviver);\n }\n}\n","import type { Static, TSchema } from \"./TypeProvider.ts\";\n\nexport abstract class SchemaCodec {\n /**\n * Encode the value to a string format.\n */\n public abstract encodeToString<T extends TSchema>(\n schema: T,\n value: Static<T>,\n ): string;\n\n /**\n * Encode the value to a binary format.\n */\n public abstract encodeToBinary<T extends TSchema>(\n schema: T,\n value: Static<T>,\n ): Uint8Array;\n\n /**\n * Decode string, binary, or other formats to the schema type.\n */\n public abstract decode<T>(schema: TSchema, value: unknown): T;\n}\n","import type { TSchema } from \"typebox\";\nimport { $inject } from \"../primitives/$inject.ts\";\nimport { Json } from \"./Json.ts\";\nimport { SchemaCodec } from \"./SchemaCodec.ts\";\nimport type { Static } from \"./TypeProvider.ts\";\n\nexport class JsonSchemaCodec extends SchemaCodec {\n protected readonly json = $inject(Json);\n protected readonly encoder = new TextEncoder();\n protected readonly decoder = new TextDecoder();\n\n public encodeToString<T extends TSchema>(\n schema: T,\n value: Static<T>,\n ): string {\n return this.json.stringify(value);\n }\n\n public encodeToBinary<T extends TSchema>(\n schema: T,\n value: Static<T>,\n ): Uint8Array {\n return this.encoder.encode(this.encodeToString(schema, value));\n }\n\n public decode<T>(schema: TSchema, value: unknown): T {\n if (value instanceof Uint8Array) {\n const text = this.decoder.decode(value);\n return this.json.parse(text);\n }\n\n if (typeof value === \"string\") {\n // Only parse if it looks like JSON (starts with { or [)\n const trimmed = value.trim();\n if (trimmed.startsWith(\"{\") || trimmed.startsWith(\"[\")) {\n return this.json.parse(value);\n }\n // Return plain strings as-is\n return value as T;\n }\n\n return value as T;\n }\n}\n","import type { TLocalizedValidationError } from \"typebox/error\";\nimport { AlephaError } from \"./AlephaError.ts\";\n\nexport class TypeBoxError extends AlephaError {\n name = \"TypeBoxError\";\n\n public readonly cause: TLocalizedValidationError;\n public readonly value: {\n path: string;\n message: string;\n };\n\n constructor(error: TLocalizedValidationError) {\n super(\n `Invalid input: ${error.message}${error.instancePath ? ` at ${error.instancePath}` : \"\"}`,\n {\n cause: error,\n },\n );\n const params = error.params as TypeBoxErrorParams;\n if (params?.requiredProperties) {\n this.value = {\n path: `/${params.requiredProperties[0]}`,\n message: \"must be defined\",\n };\n } else {\n this.value = {\n path: error.instancePath,\n message: error.message,\n };\n }\n\n this.cause = error;\n }\n}\n\nexport interface TypeBoxErrorParams {\n requiredProperties?: string[];\n}\n","import type { TSchema } from \"typebox\";\nimport { Compile, type Validator } from \"typebox/compile\";\nimport { TypeBoxError } from \"../errors/TypeBoxError.ts\";\nimport type { Static } from \"./TypeProvider.ts\";\n\nexport class SchemaValidator {\n protected cache = new Map<TSchema, Validator>();\n\n /**\n * Validate the value against the provided schema.\n *\n * Validation create a new value by applying some preprocessing. (e.g., trimming text)\n */\n public validate<T extends TSchema>(\n schema: T,\n value: unknown,\n options: ValidateOptions = {},\n ): Static<T> {\n const newValue = this.beforeParse(schema, value, {\n trim: options.trim ?? true,\n nullToUndefined: options.nullToUndefined ?? true,\n deleteUndefined: options.deleteUndefined ?? true,\n });\n\n try {\n return this.getValidator(schema).Parse(newValue);\n } catch (error: any) {\n if (error.cause?.errors?.[0]) {\n throw new TypeBoxError(error.cause.errors[0]);\n }\n throw error;\n }\n }\n\n protected getValidator<T extends TSchema>(schema: T): Validator<{}, T> {\n if (this.cache.has(schema)) {\n return this.cache.get(schema) as Validator<{}, T>;\n }\n\n const validator = Compile(schema);\n this.cache.set(schema, validator);\n return validator as Validator<{}, T>;\n }\n\n /**\n * Preprocess the value based on the schema before validation.\n *\n * - If the value is `null` and the schema does not allow `null`, it converts it to `undefined`.\n * - If the value is a string and the schema has a `~options.trim` flag, it trims whitespace from the string.\n */\n public beforeParse(schema: any, value: any, options: ValidateOptions): any {\n if (!schema) {\n return value;\n }\n\n if (\n value === null &&\n !this.isSchemaNullable(schema) &&\n options.nullToUndefined\n ) {\n return undefined;\n }\n\n if (Array.isArray(value)) {\n return value.map((it) => this.beforeParse(schema.items, it, options));\n }\n\n if (typeof value === \"string\" && schema.type === \"string\") {\n let str = value;\n\n if (options.trim && schema[\"~options\"]?.trim) {\n str = str.trim();\n }\n\n if (schema[\"~options\"]?.lowercase) {\n str = str.toLowerCase();\n }\n\n return str;\n }\n\n if (\n typeof value === \"object\" &&\n value !== null &&\n schema.type === \"object\"\n ) {\n const obj: any = {};\n\n for (const key in value) {\n const newValue = this.beforeParse(\n schema.properties?.[key],\n value[key],\n options,\n );\n\n if (newValue === undefined && options.deleteUndefined) {\n continue;\n }\n\n obj[key] = newValue;\n }\n\n return obj;\n }\n\n return value;\n }\n\n /**\n * Used by `beforeParse` to determine if a schema allows null values.\n */\n protected isSchemaNullable = (schema: any): boolean => {\n if (!schema) {\n return false;\n }\n if (schema.type === \"null\") {\n return true;\n }\n if (Array.isArray(schema.type) && schema.type.includes(\"null\")) {\n return true;\n }\n if (schema.anyOf) {\n return schema.anyOf.some((it: any) => this.isSchemaNullable(it));\n }\n if (schema.oneOf) {\n return schema.oneOf.some((it: any) => this.isSchemaNullable(it));\n }\n if (schema.allOf) {\n return schema.allOf.some((it: any) => this.isSchemaNullable(it));\n }\n return false;\n };\n}\n\nexport interface ValidateOptions {\n trim?: boolean;\n nullToUndefined?: boolean;\n deleteUndefined?: boolean;\n}\n","import type { StaticEncode, TSchema } from \"typebox\";\nimport { AlephaError } from \"../errors/AlephaError.ts\";\nimport { $inject } from \"../primitives/$inject.ts\";\nimport { JsonSchemaCodec } from \"./JsonSchemaCodec.ts\";\nimport type { SchemaCodec } from \"./SchemaCodec.ts\";\nimport { SchemaValidator, type ValidateOptions } from \"./SchemaValidator.ts\";\nimport type { Static } from \"./TypeProvider.ts\";\n\nexport type Encoding = \"object\" | \"string\" | \"binary\";\n\nexport interface EncodeOptions<T extends Encoding = Encoding> {\n /**\n * The output encoding format:\n * - 'string': Returns JSON string\n * - 'binary': Returns Uint8Array (for protobuf, msgpack, etc.)\n *\n * @default \"string\"\n */\n as?: T;\n\n /**\n * The encoder to use (e.g., 'json', 'protobuf', 'msgpack')\n *\n * @default \"json\"\n */\n encoder?: string;\n\n /**\n * Validation options to apply before encoding.\n */\n validation?: ValidateOptions | false;\n}\n\nexport type EncodeResult<\n T extends TSchema,\n E extends Encoding,\n> = E extends \"string\"\n ? string\n : E extends \"binary\"\n ? Uint8Array\n : StaticEncode<T>;\n\nexport interface DecodeOptions {\n /**\n * The encoder to use (e.g., 'json', 'protobuf', 'msgpack')\n *\n * @default \"json\"\n */\n encoder?: string;\n\n /**\n * Validation options to apply before encoding.\n */\n validation?: ValidateOptions | false;\n}\n\n/**\n * CodecManager manages multiple codec formats and provides a unified interface\n * for encoding and decoding data with different formats.\n */\nexport class CodecManager {\n protected readonly codecs: Map<string, SchemaCodec> = new Map();\n protected readonly jsonCodec = $inject(JsonSchemaCodec);\n protected readonly schemaValidator = $inject(SchemaValidator);\n\n public default = \"json\";\n\n constructor() {\n // Register default JSON codec\n this.register(this.default, this.jsonCodec);\n }\n\n /**\n * Register a new codec format.\n *\n * @param name - The name of the codec (e.g., 'json', 'protobuf')\n * @param codec - The codec implementation\n */\n public register(name: string, codec: SchemaCodec): void {\n this.codecs.set(name, codec);\n }\n\n /**\n * Get a specific codec by name.\n *\n * @param name - The name of the codec\n * @returns The codec instance\n * @throws {AlephaError} If the codec is not found\n */\n public getCodec(name: string): SchemaCodec {\n const codec = this.codecs.get(name);\n if (!codec) {\n throw new AlephaError(\n `Codec \"${name}\" not found. Available codecs: ${Array.from(this.codecs.keys()).join(\", \")}`,\n );\n }\n return codec;\n }\n\n /**\n * Encode data using the specified codec and output format.\n */\n public encode<T extends TSchema, E extends Encoding = \"object\">(\n schema: T,\n value: unknown,\n options?: EncodeOptions<E>,\n ): EncodeResult<T, E> {\n const codec = this.getCodec(options?.encoder ?? this.default);\n const as = options?.as ?? \"object\";\n\n if (options?.validation !== false) {\n value = this.schemaValidator.validate(schema, value, options?.validation);\n }\n\n if (as === \"object\") {\n // Return the validated object as-is\n return value as EncodeResult<T, E>;\n }\n\n if (as === \"binary\") {\n // not used by JSON, but for other codecs like Protobuf, MsgPack, etc.\n return codec.encodeToBinary(schema, value as Static<T>) as EncodeResult<\n T,\n E\n >;\n }\n\n // encode directly to string\n return codec.encodeToString(schema, value as Static<T>) as EncodeResult<\n T,\n E\n >;\n }\n\n /**\n * Decode data using the specified codec.\n */\n public decode<T extends TSchema>(\n schema: T,\n data: any,\n options?: DecodeOptions,\n ): Static<T> {\n const encoderName = options?.encoder ?? this.default;\n const codec = this.getCodec(encoderName);\n let value = codec.decode(schema, data);\n\n if (options?.validation !== false) {\n value = this.schemaValidator.validate(schema, value, options?.validation);\n }\n\n return value as Static<T>;\n }\n\n /**\n * Validate decoded data against the schema.\n *\n * This is automatically called before encoding or after decoding.\n */\n public validate<T extends TSchema>(\n schema: T,\n value: unknown,\n options?: ValidateOptions,\n ): Static<T> {\n return this.schemaValidator.validate(schema, value, options);\n }\n}\n","import type { Hook, Hooks } from \"../Alepha.ts\";\nimport { AlephaError } from \"../errors/AlephaError.ts\";\nimport type { Async } from \"../interfaces/Async.ts\";\nimport type { LoggerInterface } from \"../interfaces/LoggerInterface.ts\";\n\nexport class EventManager {\n protected logFn?: () => LoggerInterface | undefined;\n\n /**\n * List of events that can be triggered. Powered by $hook().\n */\n protected events: Record<string, Array<Hook>> = {};\n\n constructor(logFn?: () => LoggerInterface | undefined) {\n this.logFn = logFn;\n }\n\n protected get log(): LoggerInterface | undefined {\n return this.logFn?.();\n }\n\n /**\n * Registers a hook for the specified event.\n */\n public on<T extends keyof Hooks>(\n event: T,\n hookOrFunc: Hook<T> | ((payload: Hooks[T]) => Async<void>),\n ): () => void {\n if (!this.events[event]) {\n this.events[event] = [];\n }\n\n const hook =\n typeof hookOrFunc === \"function\" ? { callback: hookOrFunc } : hookOrFunc;\n\n if (hook.priority === \"first\") {\n this.events[event].unshift(hook);\n } else if (hook.priority === \"last\") {\n this.events[event].push(hook);\n } else {\n const index = this.events[event].findIndex(\n (it) => it.priority === \"last\",\n );\n if (index !== -1) {\n this.events[event].splice(index, 0, hook);\n } else {\n this.events[event].push(hook);\n }\n }\n\n return () => {\n this.events[event] = this.events[event].filter(\n (it) => it.callback !== hook.callback,\n );\n };\n }\n\n /**\n * Emits the specified event with the given payload.\n */\n public async emit<T extends keyof Hooks>(\n func: T,\n payload: Hooks[T],\n options: {\n /**\n * If true, the hooks will be executed in reverse order.\n * This is useful for \"stop\" hooks that should be executed in reverse order.\n *\n * @default false\n */\n reverse?: boolean;\n /**\n * If true, the hooks will be logged with their execution time.\n *\n * @default false\n */\n log?: boolean;\n /**\n * If true, errors will be caught and logged instead of throwing.\n *\n * @default false\n */\n catch?: boolean;\n } = {},\n ): Promise<void> {\n const ctx: any = {};\n\n if (options.log) {\n ctx.now = Date.now();\n this.log?.trace(`${func} ...`);\n }\n\n let events = this.events[func] ?? [];\n\n if (options.reverse) {\n events = events.toReversed();\n }\n\n for (const hook of events) {\n const name = hook.caller?.name ?? \"unknown\";\n if (options.log) {\n ctx.now2 = Date.now();\n this.log?.trace(`${func}(${name}) ...`);\n }\n\n try {\n await hook.callback(payload);\n } catch (error) {\n if (options.catch) {\n this.log?.error(`${func}(${name}) ERROR`, error);\n continue;\n }\n if (options.log) {\n throw new AlephaError(\n `Failed during '${func}()' hook for service: ${name}`,\n { cause: error },\n );\n }\n throw error;\n }\n\n if (options.log) {\n this.log?.debug(`${func}(${name}) OK [${Date.now() - ctx.now2}ms]`);\n }\n }\n\n if (options.log) {\n this.log?.debug(`${func} OK [${Date.now() - ctx.now}ms]`);\n }\n }\n}\n","import type { TArray } from \"typebox\";\nimport { KIND } from \"../constants/KIND.ts\";\nimport type {\n Static,\n TObject,\n TOptionalAdd,\n} from \"../providers/TypeProvider.ts\";\n\n/**\n * Define an atom for state management.\n *\n * Atom lets you define a piece of state with a name, schema, and default value.\n *\n * By default, Alepha state is just a simple key-value store.\n * Using atoms allows you to have type safety, validation, and default values for your state.\n *\n * You control how state is structured and validated.\n *\n * Features:\n * - Set a schema for validation\n * - Set a default value for initial state\n * - Rules, like read-only, custom validation, etc.\n * - Automatic getter access in services with {@link $use}\n * - SSR support (server state automatically serialized and hydrated on client)\n * - React integration (useAtom hook for automatic component re-renders)\n * - Middleware\n * - Persistence adapters (localStorage, Redis, database, file system, cookie, etc.)\n * - State migrations (version upgrades when schema changes)\n * - Documentation generation & devtools integration\n *\n * Common use cases:\n * - user preferences\n * - feature flags\n * - configuration options\n * - session data\n *\n * Atom must contain only serializable data.\n * Avoid storing complex objects like class instances, functions, or DOM elements.\n * If you need to store complex data, consider using identifiers or references instead.\n */\nexport const $atom = <\n T extends TObject<TProperties> | TArray,\n N extends string,\n>(\n options: AtomOptions<T, N>,\n): Atom<T, N> => {\n return new Atom<T, N>(options);\n};\n\nexport type AtomOptions<T extends TAtomObject, N extends string> = {\n name: N;\n schema: T;\n description?: string;\n} & (T extends TOptionalAdd<T>\n ? {\n default?: Static<T>;\n }\n : {\n default: Static<T>;\n });\n\nexport class Atom<T extends TAtomObject = TObject, N extends string = string> {\n public readonly options: AtomOptions<T, N>;\n\n public get schema(): T {\n return this.options.schema;\n }\n\n public get key(): N {\n return this.options.name;\n }\n\n constructor(options: AtomOptions<T, N>) {\n this.options = options;\n }\n}\n\n$atom[KIND] = \"atom\";\n\ntype TProperties = any; // it's required to avoid required [ string ] error, ...\n\nexport type TAtomObject = TObject<any> | TArray;\nexport type AtomStatic<T extends TAtomObject> =\n T extends TOptionalAdd<T> ? Static<T> | undefined : Static<T>;\n","import type { TObject } from \"typebox\";\nimport type { State as AlephaState } from \"../Alepha.ts\";\nimport {\n Atom,\n type AtomStatic,\n type TAtomObject,\n} from \"../primitives/$atom.ts\";\nimport { $inject } from \"../primitives/$inject.ts\";\nimport { AlsProvider } from \"./AlsProvider.ts\";\nimport { EventManager } from \"./EventManager.ts\";\nimport { JsonSchemaCodec } from \"./JsonSchemaCodec.ts\";\nimport type { Static } from \"./TypeProvider.ts\";\n\nexport interface AtomWithValue {\n atom: Atom;\n value: unknown;\n}\n\nexport class StateManager<State extends object = AlephaState> {\n protected readonly als = $inject(AlsProvider);\n protected readonly events = $inject(EventManager);\n protected readonly codec = $inject(JsonSchemaCodec);\n protected readonly atoms = new Map<keyof State, Atom>();\n\n protected store: Partial<State> = {};\n\n constructor(store: Partial<State> = {}) {\n this.store = store;\n }\n\n public getAtoms(context = true): Array<AtomWithValue> {\n const atoms: Array<AtomWithValue> = [];\n\n if (context && this.als?.exists()) {\n // for each this.atoms, check if key is present in als, if yes, add to new map\n for (const atom of this.atoms.values()) {\n const value = this.als.get(atom.key);\n if (value !== undefined) {\n atoms.push({ atom, value });\n }\n }\n } else {\n for (const [key, atom] of this.atoms.entries()) {\n atoms.push({ atom, value: this.store[key] as unknown });\n }\n }\n\n return atoms;\n }\n\n public register(atom: Atom<any>): this {\n const key = atom.key as keyof State;\n\n if (!this.atoms.has(key)) {\n this.atoms.set(key, atom);\n if (!(key in this.store)) {\n this.set(key, atom.options.default as State[keyof State]);\n }\n }\n\n return this;\n }\n\n /**\n * Get a value from the state with proper typing\n */\n public get<T extends TAtomObject>(target: Atom<T>): Static<T>;\n public get<Key extends keyof State>(target: Key): State[Key] | undefined;\n public get(target: string | object): any {\n if (target instanceof Atom) {\n this.register(target);\n }\n\n const key = target instanceof Atom ? target.key : target;\n const store = this.store as Record<string, any>;\n\n return this.als?.exists()\n ? (this.als.get(key as string) ?? store[key])\n : store[key];\n }\n\n /**\n * Set a value in the state\n */\n public set<T extends TAtomObject>(\n target: Atom<T>,\n value: AtomStatic<T>,\n ): this;\n public set<Key extends keyof State>(\n target: Key,\n value: State[Key] | undefined,\n ): this;\n public set(target: any, value: any): this {\n if (target instanceof Atom) {\n this.register(target);\n }\n\n const key = target instanceof Atom ? target.key : target;\n const store = this.store as Record<string, any>;\n\n const prevValue = this.get(key);\n if (prevValue === value) {\n return this;\n }\n\n if (this.als?.exists()) {\n this.als.set(key as string, value);\n } else {\n store[key] = value;\n }\n\n this.events\n ?.emit(\n \"state:mutate\",\n { key: key as keyof AlephaState, value, prevValue },\n { catch: true },\n )\n .catch(() => null);\n\n return this;\n }\n\n /**\n * Mutate a value in the state.\n */\n public mut<T extends TObject>(\n target: Atom<T>,\n mutator: (current: Static<T>) => Static<T>,\n ): this;\n public mut<Key extends keyof State>(\n target: Key,\n mutator: (current: State[Key] | undefined) => State[Key] | undefined,\n ): this;\n public mut(target: any, mutator: (current: any) => any): this {\n const current = this.get(target);\n const updated = mutator(current);\n return this.set(target, updated);\n }\n\n /**\n * Check if a key exists in the state\n */\n public has<Key extends keyof State>(key: Key): boolean {\n return key in this.store;\n }\n\n /**\n * Delete a key from the state (set to undefined)\n */\n public del<Key extends keyof State>(key: Key): this {\n return this.set(key, undefined);\n }\n\n /**\n * Push a value to an array in the state\n */\n public push<Key extends keyof OnlyArray<State>>(\n key: Key,\n value: NonNullable<State[Key]> extends Array<infer U> ? U : never,\n ): this {\n const current = (this.get(key) ?? []) as Array<any>; // default to empty array\n if (Array.isArray(current)) {\n this.set(key, [...current, value] as State[Key]);\n }\n return this;\n }\n\n /**\n * Clear all state\n */\n public clear(): this {\n this.store = {};\n return this;\n }\n\n /**\n * Get all keys that exist in the state\n */\n public keys(): (keyof State)[] {\n return Object.keys(this.store) as (keyof State)[];\n }\n}\n\ntype OnlyArray<T extends object> = {\n [K in keyof T]: NonNullable<T[K]> extends Array<any> ? K : never;\n};\n","import type { Static, TObject } from \"typebox\";\nimport { KIND } from \"./constants/KIND.ts\";\nimport { MODULE } from \"./constants/MODULE.ts\";\nimport { OPTIONS } from \"./constants/OPTIONS.ts\";\nimport { AlephaError } from \"./errors/AlephaError.ts\";\nimport { CircularDependencyError } from \"./errors/CircularDependencyError.ts\";\nimport { ContainerLockedError } from \"./errors/ContainerLockedError.ts\";\nimport { TooLateSubstitutionError } from \"./errors/TooLateSubstitutionError.ts\";\nimport { Primitive } from \"./helpers/primitive.ts\";\nimport { __alephaRef } from \"./helpers/ref.ts\";\nimport type { Async } from \"./interfaces/Async.ts\";\nimport type { LoggerInterface } from \"./interfaces/LoggerInterface.ts\";\nimport {\n type InstantiableClass,\n isClass,\n type RunFunction,\n type Service,\n type ServiceEntry,\n} from \"./interfaces/Service.ts\";\nimport type { InjectOptions } from \"./primitives/$inject.ts\";\nimport { Module, type WithModule } from \"./primitives/$module.ts\";\nimport { AlsProvider } from \"./providers/AlsProvider.ts\";\nimport { CodecManager } from \"./providers/CodecManager.ts\";\nimport { EventManager } from \"./providers/EventManager.ts\";\nimport { StateManager } from \"./providers/StateManager.ts\";\nimport type { TSchema } from \"./providers/TypeProvider.ts\";\n\n/**\n * Core container of the Alepha framework.\n *\n * It is responsible for managing the lifecycle of services,\n * handling dependency injection,\n * and providing a unified interface for the application.\n *\n * @example\n * ```ts\n * import { Alepha, run } from \"alepha\";\n *\n * class MyService {\n * // business logic here\n * }\n *\n * const alepha = Alepha.create({\n * // state, env, and other properties\n * })\n *\n * alepha.with(MyService);\n *\n * run(alepha); // trigger .start (and .stop) automatically\n * ```\n *\n * ### Alepha Factory\n *\n * Alepha.create() is an enhanced version of new Alepha().\n * - It merges `process.env` with the provided state.env when available.\n * - It populates the test hooks for Vitest or Jest environments when available.\n *\n * new Alepha() is fine if you don't need these helpers.\n *\n * ### Platforms & Environments\n *\n * Alepha is designed to work in various environments:\n * - **Browser**: Runs in the browser, using the global `window` object.\n * - **Serverless**: Runs in serverless environments like Vercel or Vite.\n * - **Test**: Runs in test environments like Jest or Vitest.\n * - **Production**: Runs in production environments, typically with NODE_ENV set to \"production\".\n * * You can check the current environment using the following methods:\n *\n * - `isBrowser()`: Returns true if the App is running in a browser environment.\n * - `isServerless()`: Returns true if the App is running in a serverless environment.\n * - `isTest()`: Returns true if the App is running in a test environment.\n * - `isProduction()`: Returns true if the App is running in a production environment.\n *\n * ### State & Environment\n *\n * The state of the Alepha container is stored in the `store` property.\n * Most important property is `store.env`, which contains the environment variables.\n *\n * ```ts\n * const alepha = Alepha.create({ env: { MY_VAR: \"value\" } });\n *\n * // You can access the environment variables using alepha.env\n * console.log(alepha.env.MY_VAR); // \"value\"\n *\n * // But you should use $env() primitive to get typed values from the environment.\n * class App {\n * env = $env(\n * t.object({\n * \t MY_VAR: t.text(),\n * })\n * );\n * }\n * ```\n *\n * ### Modules\n *\n * Modules are a way to group services together.\n * You can register a module using the `$module` primitive.\n *\n * ```ts\n * import { $module } from \"alepha\";\n *\n * class MyLib {}\n *\n * const myModule = $module({\n * name: \"my.project.module\",\n * services: [MyLib],\n * });\n * ```\n *\n * Do not use modules for small applications.\n *\n * ### Hooks\n *\n * Hooks are a way to run async functions from all registered providers/services.\n * You can register a hook using the `$hook` primitive.\n *\n * ```ts\n * import { $hook } from \"alepha\";\n *\n * class App {\n * \t log = $logger();\n * \t onCustomerHook = $hook({\n * \t\t\ton: \"my:custom:hook\",\n * \t\t\thandler: () => {\n * \t\t \t this.log?.info(\"App is being configured\");\n * \t \t\t},\n * \t });\n * \t}\n *\n * Alepha.create()\n * \t .with(App)\n * \t .start()\n * \t .then(alepha => alepha.events.emit(\"my:custom:hook\"));\n * ```\n *\n * \tHooks are fully typed. You can create your own hooks by using module augmentation:\n *\n * \t```ts\n * \tdeclare module \"alepha\" {\n * \t\tinterface Hooks {\n * \t\t \"my:custom:hook\": {\n * \t\t\t\targ1: string;\n * \t\t }\n * \t\t}\n * \t}\n * \t```\n *\n * \t@module alepha\n */\nexport class Alepha {\n /**\n * Creates a new instance of the Alepha container with some helpers:\n *\n * - merges `process.env` with the provided state.env when available.\n * - populates the test hooks for Vitest or Jest environments when available.\n *\n * If you are not interested about these helpers, you can use the constructor directly.\n */\n public static create(state: Partial<State> = {}): Alepha {\n // merge process.env with the state.env\n if (typeof process === \"object\" && typeof process.env === \"object\") {\n state.env = {\n ...state.env,\n ...process.env,\n };\n }\n\n const alepha = new Alepha(state);\n\n if (alepha.isTest()) {\n // inject global hooks for testing purposes\n // > for vitest, { globals: true } is required in the config\n const g = globalThis as any;\n const beforeAll = state[\"alepha.test.beforeAll\"] ?? g.beforeAll;\n const afterAll = state[\"alepha.test.afterAll\"] ?? g.afterAll;\n const afterEach = state[\"alepha.test.afterEach\"] ?? g.afterEach;\n const onTestFinished =\n state[\"alepha.test.onTestFinished\"] ?? g.onTestFinished;\n\n beforeAll?.(() => alepha.start());\n afterAll?.(() => alepha.stop());\n\n try {\n onTestFinished?.(() => alepha.stop());\n } catch (_error) {\n // ignore\n }\n\n alepha.store\n .set(\"alepha.test.beforeAll\", beforeAll)\n .set(\"alepha.test.afterAll\", afterAll)\n .set(\"alepha.test.afterEach\", afterEach)\n .set(\"alepha.test.onTestFinished\", onTestFinished);\n }\n\n return alepha;\n }\n\n /**\n * Flag indicating whether the App won't accept any further changes.\n * Pass to true when #start() is called.\n */\n protected locked = false;\n\n /**\n * True if the App has been configured.\n */\n protected configured = false;\n\n /**\n * True if the App has started.\n */\n protected started = false;\n\n /**\n * True if the App is ready.\n */\n protected ready = false;\n\n /**\n * A promise that resolves when the App has started.\n */\n protected starting?: PromiseWithResolvers<this>;\n\n /**\n * Initial state of the container.\n *\n * > Used to initialize the StateManager.\n */\n protected init: Partial<State>;\n\n /**\n * During the instantiation process, we keep a list of pending instantiations.\n * > It allows us to detect circular dependencies.\n */\n protected pendingInstantiations: Service[] = [];\n\n /**\n * Cache for environment variables.\n * > It allows us to avoid parsing the same schema multiple times.\n */\n protected cacheEnv: Map<TSchema, any> = new Map();\n\n /**\n * List of modules that are registered in the container.\n *\n * Modules are used to group services and provide a way to register them in the container.\n */\n protected modules: Array<Module> = [];\n\n /**\n * List of service substitutions.\n *\n * Services registered here will be replaced by the specified service when injected.\n */\n protected substitutions = new Map<Service, { use: Service }>();\n\n /**\n * Registry of primitives.\n */\n protected primitiveRegistry = new Map<Service<Primitive>, Array<Primitive>>();\n\n /**\n * List of all services + how they are provided.\n */\n protected registry: Map<Service, ServiceDefinition> = new Map();\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Node.js feature that allows to store context across asynchronous calls.\n *\n * This is used for logging, tracing, and other context-related features.\n *\n * Mocked for browser environments.\n */\n public get context(): AlsProvider {\n return this.inject(AlsProvider);\n }\n\n /**\n * Event manager to handle lifecycle events and custom events.\n */\n public get events(): EventManager {\n return this.inject(EventManager, {\n args: [() => this.log],\n });\n }\n\n /**\n * State manager to store arbitrary values.\n */\n public get store(): StateManager<State> {\n this.events; // ensure events is initialized first (TODO: move this to constructor?)\n return this.inject(StateManager, {\n args: [this.init],\n });\n }\n\n /**\n * Codec manager for encoding and decoding data with different formats.\n *\n * Supports multiple codec formats (JSON, Protobuf, etc.) with a unified interface.\n */\n public get codec(): CodecManager {\n return this.inject(CodecManager);\n }\n\n /**\n * Get logger instance.\n */\n public get log(): LoggerInterface | undefined {\n return this.store.get(\"alepha.logger\");\n }\n\n /**\n * The environment variables for the App.\n */\n public get env(): Readonly<Env> {\n return this.store.get(\"env\") ?? {};\n }\n\n constructor(init: Partial<State> = {}) {\n this.init = init;\n }\n\n /**\n * True when start() is called.\n *\n * -> No more services can be added, it's over, bye!\n */\n public isLocked(): boolean {\n return this.locked;\n }\n\n /**\n * Returns whether the App is configured.\n *\n * It means that Alepha#configure() has been called.\n *\n * > By default, configure() is called automatically when start() is called, but you can also call it manually.\n */\n public isConfigured(): boolean {\n return this.configured;\n }\n\n /**\n * Returns whether the App has started.\n *\n * It means that #start() has been called but maybe not all services are ready.\n */\n public isStarted(): boolean {\n return this.started;\n }\n\n /**\n * True if the App is ready. It means that Alepha is started AND ready() hook has beed called.\n */\n public isReady(): boolean {\n return this.ready;\n }\n\n /**\n * True if the App is running in a Continuous Integration environment.\n */\n public isCI(): boolean {\n if (this.env.GITHUB_ACTIONS) {\n return true;\n }\n\n return !!this.env.CI;\n }\n\n /**\n * True if the App is running in a browser environment.\n */\n public isBrowser(): boolean {\n return typeof window !== \"undefined\"; // pretty cheap check\n }\n\n /**\n * Returns whether the App is running in Vite dev mode.\n */\n public isViteDev(): boolean {\n if (this.isBrowser()) {\n return false;\n }\n\n return !!this.env.VITE_ALEPHA_DEV;\n }\n\n public isBun(): boolean {\n return \"Bun\" in globalThis;\n }\n\n /**\n * Returns whether the App is running in a serverless environment.\n */\n public isServerless(): boolean {\n if (this.isBrowser()) {\n return false;\n }\n\n if (this.env.VERCEL_REGION) {\n return true;\n }\n\n if (this.env.ALEPHA_SERVERLESS) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Returns whether the App is in test mode. (Running in a test environment)\n *\n * > This is automatically set when running tests with Jest or Vitest.\n */\n public isTest(): boolean {\n const env = this.env.NODE_ENV;\n return env === \"test\";\n }\n\n /**\n * Returns whether the App is in production mode. (Running in a production environment)\n *\n * > This is automatically set by Vite or Vercel. However, you have to set it manually when running Docker apps.\n */\n public isProduction(): boolean {\n const env = this.env.NODE_ENV;\n return env === \"production\";\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Starts the App.\n *\n * - Lock any further changes to the container.\n * - Run \"configure\" hook for all services. Primitives will be processed.\n * - Run \"start\" hook for all services. Providers will connect/listen/...\n * - Run \"ready\" hook for all services. This is the point where the App is ready to serve requests.\n *\n * @return A promise that resolves when the App has started.\n */\n public async start(): Promise<this> {\n if (this.ready) {\n this.log?.debug(\"App is already started, skipping...\");\n return this;\n }\n\n // make sure that start is called only once\n if (this.starting) {\n this.log?.warn(\"App is already starting, waiting for it to finish...\");\n return this.starting.promise;\n }\n\n this.codec; // ensure codec is initialized\n\n this.starting = Promise.withResolvers();\n\n const now = Date.now();\n\n this.log?.info(\"Starting App...\");\n\n for (const [key] of this.substitutions.entries()) {\n this.inject(key);\n }\n\n const target = this.store.get(\"alepha.target\");\n if (target) {\n this.registry = new Map();\n this.primitiveRegistry = new Map();\n this.with(target);\n }\n\n this.locked = true;\n\n await this.events.emit(\"configure\", this, { log: true });\n\n this.configured = true;\n\n await this.events.emit(\"start\", this, { log: true });\n\n this.started = true;\n\n await this.events.emit(\"ready\", this, { log: true });\n\n this.log?.info(`App is now ready [${Date.now() - now}ms]`);\n\n this.ready = true;\n\n this.starting.resolve(this);\n this.starting = undefined;\n\n return this;\n }\n\n /**\n * Stops the App.\n *\n * - Run \"stop\" hook for all services.\n *\n * Stop will NOT reset the container.\n * Stop will NOT unlock the container.\n *\n * > Stop is used to gracefully shut down the application, nothing more. There is no \"restart\".\n *\n * @return A promise that resolves when the App has stopped.\n */\n public async stop(): Promise<void> {\n if (!this.started) {\n return;\n }\n\n this.log?.info(\"Stopping App...\");\n await this.events.emit(\"stop\", this, { reverse: true, log: true });\n this.log?.info(\"App is now off\");\n\n this.started = false;\n this.ready = false;\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Check if entry is registered in the container.\n */\n public has(\n entry: ServiceEntry,\n opts: {\n /**\n * Check if the entry is registered in the pending instantiation stack.\n *\n * @default true\n */\n inStack?: boolean;\n /**\n * Check if the entry is registered in the container registry.\n *\n * @default true\n */\n inRegistry?: boolean;\n /**\n * Check if the entry is registered in the substitutions.\n *\n * @default true\n */\n inSubstitutions?: boolean;\n /**\n * Where to look for registered services.\n *\n * @default this.registry\n */\n registry?: Map<Service, ServiceDefinition>;\n } = {},\n ): boolean {\n if (entry === Alepha) {\n return true;\n }\n\n const {\n inStack = true,\n inRegistry = true,\n inSubstitutions = true,\n registry = this.registry,\n } = opts;\n\n const { provide } =\n typeof entry === \"object\" && \"provide\" in entry\n ? entry\n : { provide: entry };\n\n if (inSubstitutions) {\n const substitute = this.substitutions.get(provide);\n if (substitute) {\n return true;\n }\n }\n\n if (inRegistry) {\n const match = registry.get(provide);\n if (match) {\n return true;\n }\n }\n\n if (inStack) {\n const substitute = this.substitutions.get(provide)?.use;\n if (substitute && this.pendingInstantiations.includes(substitute)) {\n return true;\n }\n\n return this.pendingInstantiations.includes(provide);\n }\n\n return false;\n }\n\n /**\n * Registers the specified service in the container.\n *\n * - If the service is ALREADY registered, the method does nothing.\n * - If the service is NOT registered, a new instance is created and registered.\n *\n * Method is chainable, so you can register multiple services in a single call.\n *\n * > ServiceEntry allows to provide a service **substitution** feature.\n *\n * @example\n * ```ts\n * class A { value = \"a\"; }\n * class B { value = \"b\"; }\n * class M { a = $inject(A); }\n *\n * Alepha.create().with({ provide: A, use: B }).get(M).a.value; // \"b\"\n * ```\n *\n * > **Substitution** is an advanced feature that allows you to replace a service with another service.\n * > It's useful for testing or for providing different implementations of a service.\n * > If you are interested in configuring a service, use Alepha#configure() instead.\n *\n * @param serviceEntry - The service to register in the container.\n * @return Current instance of Alepha.\n */\n public with<T extends object>(\n serviceEntry: ServiceEntry<T> | { default: ServiceEntry<T> },\n ): this {\n const entry: ServiceEntry<T> =\n \"default\" in serviceEntry ? serviceEntry.default : serviceEntry;\n\n // just check if the entry is not present in the pending instantiation stack\n // Alepha#get will handle the rest\n if (\n this.has(entry, {\n inSubstitutions: false,\n inRegistry: false,\n })\n ) {\n return this;\n }\n\n const isSubstitution = typeof entry === \"object\";\n if (isSubstitution) {\n if (entry.provide === entry.use) {\n this.inject(entry.provide);\n return this;\n }\n\n if (!this.substitutions.has(entry.provide) && !this.has(entry.provide)) {\n if (this.started) {\n throw new ContainerLockedError();\n }\n\n // inherit of module, if service has no module\n if (\n MODULE in entry.provide &&\n typeof entry.provide[MODULE] === \"function\"\n ) {\n (entry.use as WithModule)[MODULE] ??= entry.provide[MODULE];\n }\n\n this.substitutions.set(entry.provide, {\n use: entry.use,\n });\n } else if (!entry.optional) {\n throw new TooLateSubstitutionError(entry.provide.name, entry.use.name);\n }\n\n return this;\n }\n\n this.inject(entry);\n\n return this;\n }\n\n /**\n * Get an instance of the specified service from the container.\n *\n * @see {@link InjectOptions} for the available options.\n */\n public inject<T extends object>(\n service: Service<T> | string,\n opts: InjectOptions<T> = {},\n ): T {\n const lifetime = opts.lifetime ?? \"singleton\";\n const parent =\n opts.parent !== undefined ? opts.parent : (__alephaRef?.parent ?? Alepha);\n\n const transient = lifetime === \"transient\";\n const registry =\n lifetime === \"scoped\"\n ? (this.context.get<Map<Service, ServiceDefinition>>(\"registry\") ??\n this.registry)\n : this.registry;\n\n // If the requested type is the container, the current instance is returned.\n if ((service as any) === Alepha) {\n return this as any;\n }\n\n if (typeof service === \"string\") {\n for (const [key, value] of registry.entries()) {\n if (key.name === service) {\n return value.instance as T;\n }\n }\n throw new AlephaError(`Service not found: ${service}`);\n }\n\n const substitute = this.substitutions.get(service);\n if (substitute) {\n return this.inject(substitute.use, {\n parent,\n lifetime,\n });\n }\n\n const index = this.pendingInstantiations.indexOf(service);\n if (index !== -1 && !transient) {\n throw new CircularDependencyError(\n service.name,\n this.pendingInstantiations.slice(0, index).map((it) => it.name),\n );\n }\n\n if (!transient) {\n // the requested type is searched in the container\n const match = registry.get(service);\n if (match) {\n if (!match.parents.includes(parent) && parent !== service) {\n match.parents.push(parent);\n }\n\n return match.instance;\n }\n\n if (this.started) {\n throw new ContainerLockedError(\n `Container is locked. No more services can be added. ${parent?.name} -> ${service.name}`,\n );\n }\n }\n\n const module = (service as WithModule)[MODULE];\n if (module && typeof module === \"function\") {\n this.with(module);\n }\n\n // check if service has been registered by a module\n if (this.has(service, { registry }) && !transient) {\n // if the service is already registered, we just return the instance\n return this.inject(service, { parent, lifetime });\n }\n\n const instance: T = this.new(service, opts.args);\n\n const definition: ServiceDefinition<T> = {\n parents: [parent],\n instance,\n };\n\n if (!transient) {\n registry.set(service, definition);\n }\n\n // [feature]: modules - it's just a way to group services together\n if (instance instanceof Module) {\n this.modules.push(instance);\n\n const parent = __alephaRef.parent;\n\n // propagate the current module\n __alephaRef.parent = instance.constructor as Service;\n\n instance.register(this);\n\n // restore the previous $get context\n __alephaRef.parent = parent;\n }\n\n return instance;\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Applies environment variables to the provided schema and state object.\n *\n * It replaces also all templated $ENV inside string values.\n *\n * @param schema - The schema object to apply environment variables to.\n * @return The schema object with environment variables applied.\n */\n public parseEnv<T extends TObject>(schema: T): Static<T> {\n if (this.cacheEnv.has(schema)) {\n return this.cacheEnv.get(schema) as Static<T>;\n }\n\n const config = this.codec.validate(schema, this.env) as Record<string, any>;\n\n for (const key in config) {\n if (typeof config[key] === \"string\") {\n for (const env in config) {\n config[key] = config[key].replace(\n new RegExp(`\\\\$${env}`, \"gim\"),\n config[env],\n );\n }\n }\n }\n\n this.cacheEnv.set(schema, config);\n\n return config as Static<T>;\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Dump the current dependency graph of the App.\n *\n * This method returns a record where the keys are the names of the services.\n */\n public graph(): Record<\n string,\n { from: string[]; as?: string[]; module?: string }\n > {\n for (const [key] of this.substitutions.entries()) {\n if (!this.has(key)) {\n this.inject(key);\n }\n }\n\n const graph: Record<\n string,\n { from: string[]; as?: string[]; module?: string }\n > = {};\n\n for (const [provide, { parents }] of this.registry.entries()) {\n graph[provide.name] = {\n from: parents.filter((it) => !!it).map((it) => it.name),\n };\n\n const aliases = this.substitutions\n .entries()\n .filter((it) => it[1].use === provide)\n .map((it) => it[0].name)\n .toArray();\n\n if (aliases.length) {\n graph[provide.name].as = aliases;\n }\n\n const module = Module.of(provide);\n if (module) {\n graph[provide.name].module = module.name;\n }\n }\n\n return graph;\n }\n\n public services<T extends object>(base: Service<T>): Array<T> {\n const list: Array<T> = [];\n for (const [key, value] of this.registry.entries()) {\n if (value.instance instanceof base) {\n list.push(value.instance as T);\n }\n }\n return list;\n }\n\n /**\n * Get all primitives of the specified type.\n */\n public primitives<TPrimitive extends Primitive>(\n factory:\n | {\n [KIND]: InstantiableClass<TPrimitive>;\n }\n | string,\n ): Array<TPrimitive> {\n if (typeof factory === \"string\") {\n const key1 = factory.toLowerCase().replace(\"$\", \"\");\n const key2 = `${key1}primitive`;\n for (const [key, value] of this.primitiveRegistry.entries()) {\n const name = key.name.toLowerCase();\n if (name === key1 || name === key2) {\n return value as Array<TPrimitive>;\n }\n }\n return [];\n }\n return (this.primitiveRegistry.get(factory[KIND]) ??\n []) as Array<TPrimitive>;\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n protected new<T extends object>(service: Service<T>, args: any[] = []): T {\n // we keep a tree of dependencies to detect circular dependencies\n // it's also useful for cleaning are global cursor\n this.pendingInstantiations.push(service);\n\n //\n // we use a global cursor to store the current context and definition\n // as new() is synchronous, there is no worry to do that\n //\n __alephaRef.alepha = this;\n __alephaRef.service = service;\n\n const instance: T = isClass(service)\n ? new service(...args)\n : (((service as RunFunction)(...args) ?? {}) as T);\n\n const obj = instance as unknown as Record<string, any>;\n for (const [key, value] of Object.entries(obj)) {\n if (value instanceof Primitive) {\n this.processPrimitive(value, key);\n }\n if (\n typeof value === \"object\" &&\n value !== null &&\n typeof value[OPTIONS] === \"object\" &&\n \"getter\" in value[OPTIONS]\n ) {\n const getter = value[OPTIONS].getter as keyof State;\n Object.defineProperty(obj, key, {\n get: () => this.store.get(getter),\n });\n }\n }\n\n this.pendingInstantiations.pop();\n\n // tree is empty, now we can clean the global cursor\n if (this.pendingInstantiations.length === 0) {\n __alephaRef.alepha = undefined;\n }\n\n __alephaRef.service =\n this.pendingInstantiations[this.pendingInstantiations.length - 1];\n\n return instance;\n }\n\n protected processPrimitive(value: Primitive, propertyKey = \"\") {\n value.config.propertyKey = propertyKey;\n (value as any).onInit();\n\n const kind = value.constructor as Service;\n const list = this.primitiveRegistry.get(kind) ?? [];\n this.primitiveRegistry.set(kind, [...list, value]);\n }\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface Hook<T extends keyof Hooks = any> {\n caller?: Service;\n priority?: \"first\" | \"last\";\n callback: (payload: Hooks[T]) => Async<void>;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * This is how we store services in the Alepha container.\n */\ninterface ServiceDefinition<T extends object = any> {\n /**\n * The instance of the class or type definition.\n * Mostly used for caching / singleton but can be used for other purposes like forcing the instance.\n */\n instance: T;\n\n /**\n * List of classes which use this class.\n */\n parents: Array<Service | null>;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface Env {\n [key: string]: string | boolean | number | undefined;\n\n /**\n * Optional environment variable that indicates the current environment.\n */\n NODE_ENV?: \"dev\" | \"test\" | \"production\";\n\n /**\n * Optional name of the application.\n */\n APP_NAME?: string;\n\n /**\n * Optional root module name.\n */\n MODULE_NAME?: string;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface State {\n /**\n * Environment variables for the application.\n */\n env?: Readonly<Env>;\n\n /**\n * Logger instance to be used by the Alepha container.\n *\n * @internal\n */\n \"alepha.logger\"?: LoggerInterface;\n\n /**\n * If defined, the Alepha container will only register this service and its dependencies.\n */\n \"alepha.target\"?: Service;\n\n // test hooks\n\n /**\n * Bind to Vitest 'beforeAll' hook.\n * Used for testing purposes.\n * This is automatically attached if Alepha#create() detects a test environment and global 'beforeAll' is available.\n */\n \"alepha.test.beforeAll\"?: (run: any) => any;\n\n /**\n * Bind to Vitest 'afterAll' hook.\n * Used for testing purposes.\n * This is automatically attached if Alepha#create() detects a test environment and global 'afterAll' is available.\n */\n \"alepha.test.afterAll\"?: (run: any) => any;\n\n /**\n * Bind to Vitest 'afterEach' hook.\n * Used for testing purposes.\n * This is automatically attached if Alepha#create() detects a test environment and global 'afterEach' is available.\n */\n \"alepha.test.afterEach\"?: (run: any) => any;\n\n /**\n * Bind to Vitest 'onTestFinished' hook.\n * Used for testing purposes.\n * This is automatically attached if Alepha#create() detects a test environment and global 'onTestFinished' is available.\n */\n \"alepha.test.onTestFinished\"?: (run: any) => any;\n\n /**\n * List of static assets to be copied to the output directory during the build process.\n *\n * Used for Alepha-based applications that require static assets.\n *\n * See alepha/vite for more details.\n */\n \"alepha.build.assets\"?: Array<string>;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface Hooks {\n /**\n * Used for testing purposes.\n */\n echo: unknown;\n\n /**\n * Triggered during the configuration phase. Before the start phase.\n */\n configure: Alepha;\n\n /**\n * Triggered during the start phase. When `Alepha#start()` is called.\n */\n start: Alepha;\n\n /**\n * Triggered during the ready phase. After the start phase.\n */\n ready: Alepha;\n\n /**\n * Triggered during the stop phase.\n *\n * - Stop should be called after a SIGINT or SIGTERM signal in order to gracefully shutdown the application. (@see `run()` method)\n *\n */\n stop: Alepha;\n\n /**\n * Triggered when a state value is mutated.\n */\n \"state:mutate\": {\n /**\n * The key of the state that was mutated.\n */\n key: keyof State;\n\n /**\n * The new value of the state.\n */\n value: any;\n\n /**\n * The previous value of the state.\n */\n prevValue: any;\n };\n}\n","import { AlephaError } from \"./AlephaError.ts\";\n\nexport class AppNotStartedError extends AlephaError {\n readonly name = \"AppNotStartedError\";\n\n constructor() {\n super(\"App not started. Please start the app before.\");\n }\n}\n","import type { Page } from \"../schemas/pageSchema.ts\";\n\n/**\n * Create a pagination object from an array of entities.\n *\n * This is a pure function that works with any data source (databases, APIs, caches, arrays, etc.).\n * It handles the core pagination logic including:\n * - Slicing the content to the requested page size\n * - Calculating pagination metadata (offset, page number, etc.)\n * - Determining navigation state (isFirst, isLast)\n * - Including sort metadata when provided\n *\n * @param entities - The entities to paginate (should include one extra item to detect if there's a next page)\n * @param limit - The limit of the pagination (page size)\n * @param offset - The offset of the pagination (starting position)\n * @param sort - Optional sort metadata to include in response\n * @returns A complete Page object with content and metadata\n *\n * @example Basic pagination\n * ```ts\n * const users = await fetchUsers({ limit: 11, offset: 0 }); // Fetch limit + 1\n * const page = createPagination(users, 10, 0);\n * // page.content has max 10 items\n * // page.page.isLast tells us if there are more pages\n * ```\n *\n * @example With sorting\n * ```ts\n * const page = createPagination(\n * entities,\n * 10,\n * 0,\n * [{ column: \"name\", direction: \"asc\" }]\n * );\n * ```\n *\n * @example In a custom service\n * ```ts\n * class MyService {\n * async listItems(page: number, size: number) {\n * const items = await this.fetchItems({ limit: size + 1, offset: page * size });\n * return createPagination(items, size, page * size);\n * }\n * }\n * ```\n */\nexport function createPagination<T>(\n entities: T[],\n limit = 10,\n offset = 0,\n sort?: Array<{ column: string; direction: \"asc\" | \"desc\" }>,\n): Page<T> {\n const content = entities.slice(0, limit);\n const hasNext = entities.length === limit + 1;\n const pageNumber = Math.floor(offset / limit);\n\n return {\n content,\n page: {\n number: pageNumber,\n size: limit,\n offset,\n numberOfElements: content.length,\n isEmpty: content.length === 0,\n isFirst: pageNumber === 0,\n isLast: !hasNext,\n ...(sort && sort.length > 0\n ? {\n sort: {\n sorted: true,\n fields: sort.map((s) => ({\n field: s.column,\n direction: s.direction,\n })),\n },\n }\n : {}),\n },\n };\n}\n","import type { Readable } from \"node:stream\";\nimport type { ReadableStream as WebReadableStream } from \"node:stream/web\";\nimport type { TSchema, TUnsafe } from \"typebox\";\n\nexport interface FileLike {\n /**\n * Filename.\n * @default \"file\"\n */\n name: string;\n\n /**\n * Mandatory MIME type of the file.\n * @default \"application/octet-stream\"\n */\n type: string;\n\n /**\n * Size of the file in bytes.\n *\n * Always 0 for streams, as the size is not known until the stream is fully read.\n *\n * @default 0\n */\n size: number;\n\n /**\n * Last modified timestamp in milliseconds since epoch.\n *\n * Always the current timestamp for streams, as the last modified time is not known.\n * We use this field to ensure compatibility with File API.\n *\n * @default Date.now()\n */\n lastModified: number;\n\n /**\n * Returns a ReadableStream or Node.js Readable stream of the file content.\n *\n * For streams, this is the original stream.\n */\n stream(): StreamLike;\n\n /**\n * Returns the file content as an ArrayBuffer.\n *\n * For streams, this reads the entire stream into memory.\n */\n arrayBuffer(): Promise<ArrayBuffer>;\n\n /**\n * Returns the file content as a string.\n *\n * For streams, this reads the entire stream into memory and converts it to a string.\n */\n text(): Promise<string>;\n\n // -- node specific fields --\n\n /**\n * Optional file path, if the file is stored on disk.\n *\n * This is not from the File API, but rather a custom field to indicate where the file is stored.\n */\n filepath?: string;\n}\n\n/**\n * TypeBox view of FileLike.\n */\nexport type TFile = TUnsafe<FileLike>;\n\nexport const isTypeFile = (value: TSchema): value is TFile => {\n return (\n value &&\n typeof value === \"object\" &&\n \"format\" in value &&\n value.format === \"binary\"\n );\n};\n\nexport const isFileLike = (value: any): value is FileLike => {\n return (\n !!value &&\n typeof value === \"object\" &&\n !Array.isArray(value) &&\n typeof value.name === \"string\" &&\n typeof value.type === \"string\" &&\n typeof value.size === \"number\" &&\n typeof value.stream.bind(value) === \"function\"\n );\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n// TODO: remove it, replace with WebStream\nexport type StreamLike =\n | ReadableStream\n | WebReadableStream\n | Readable\n | NodeJS.ReadableStream;\n\nexport type TStream = TUnsafe<StreamLike>;\n","import type {\n TAny,\n TArray,\n TArrayOptions,\n TBoolean,\n TInteger,\n TInterface,\n TKeysToIndexer,\n TNull,\n TNumber,\n TNumberOptions,\n TObject,\n TObjectOptions,\n TOmit,\n TOptionalAdd,\n TPartial,\n TPick,\n TProperties,\n TRecord,\n TSchema,\n TSchemaOptions,\n TString,\n TStringOptions,\n TUnion,\n TUnsafe,\n} from \"typebox\";\nimport * as TypeBox from \"typebox\";\nimport { Type } from \"typebox\";\nimport type {\n TLocalizedValidationError,\n TLocalizedValidationMessageCallback,\n} from \"typebox/error\";\nimport TypeBoxFormat from \"typebox/format\";\nimport { Locale } from \"typebox/system\";\nimport * as TypeBoxValue from \"typebox/value\";\nimport { OPTIONS } from \"../constants/OPTIONS.ts\";\nimport { AlephaError } from \"../errors/AlephaError.ts\";\nimport type { TypeBoxError } from \"../errors/TypeBoxError.ts\";\nimport { isTypeFile, type TFile, type TStream } from \"../helpers/FileLike.ts\";\n\nexport { TypeBox, TypeBoxValue, TypeBoxFormat };\n\nexport const isUUID = TypeBoxFormat.IsUuid;\nexport const isEmail = TypeBoxFormat.IsEmail;\nexport const isURL = TypeBoxFormat.IsUrl;\nexport const isDateTime = TypeBoxFormat.IsDateTime;\nexport const isDate = TypeBoxFormat.IsDate;\nexport const isTime = TypeBoxFormat.IsTime;\nexport const isDuration = TypeBoxFormat.IsDuration;\n\nexport type {\n StaticDecode,\n StaticDecode as Static,\n StaticEncode,\n TAny,\n TArray,\n TBigInt,\n TBoolean,\n TInteger,\n TKeysToIndexer,\n TNull,\n TNumber,\n TNumberOptions,\n TObject,\n TObjectOptions,\n TOptional,\n TOptionalAdd,\n TPick,\n TProperties,\n TRecord,\n TSchema,\n TString,\n TStringOptions,\n TTuple,\n TUnion,\n TUnsafe,\n TVoid,\n} from \"typebox\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport class TypeGuard {\n // -------------------------------------------------------------------------------------------------------------------\n isBigInt = (value: TSchema): value is TString =>\n TypeBox.IsString(value) && \"format\" in value && value.format === \"bigint\";\n isUUID = (value: TSchema): value is TString =>\n TypeBox.IsString(value) && \"format\" in value && value.format === \"uuid\";\n isObject = TypeBox.IsObject;\n isNumber = TypeBox.IsNumber;\n isString = TypeBox.IsString;\n isBoolean = TypeBox.IsBoolean;\n isAny = TypeBox.IsAny;\n isArray = TypeBox.IsArray;\n isOptional = TypeBox.IsOptional;\n isUnion = TypeBox.IsUnion;\n isInteger = TypeBox.IsInteger;\n isNull = TypeBox.IsNull;\n isUndefined = TypeBox.IsUndefined;\n isUnsafe = TypeBox.IsUnsafe;\n isRecord = TypeBox.IsRecord;\n isTuple = TypeBox.IsTuple;\n isVoid = TypeBox.IsVoid;\n isLiteral = TypeBox.IsLiteral;\n isSchema = TypeBox.IsSchema;\n // -------------------------------------------------------------------------------------------------------------------\n isFile = isTypeFile;\n isDateTime = (schema: unknown) => {\n return t.schema.isString(schema) && schema.format === \"date-time\";\n };\n isDate = (schema: unknown) => {\n return t.schema.isString(schema) && schema.format === \"date\";\n };\n isTime = (schema: unknown) => {\n return t.schema.isString(schema) && schema.format === \"time\";\n };\n isDuration = (schema: unknown) => {\n return t.schema.isString(schema) && schema.format === \"duration\";\n };\n}\n\ndeclare module \"typebox\" {\n interface TString {\n format?: string;\n minLength?: number;\n maxLength?: number;\n }\n\n interface TNumber {\n format?: \"int64\";\n }\n}\n\nexport class TypeProvider {\n static format = TypeBoxFormat;\n\n static {\n TypeBoxFormat.Set(\"bigint\", (value: string | number) =>\n TypeProvider.isValidBigInt(value),\n );\n }\n\n static translateError(error: TypeBoxError, locale?: string): string {\n if (!locale) {\n return error.cause.message;\n }\n\n for (const [key, value] of Object.entries(Locale)) {\n if (key === \"Set\" || key === \"Get\" || key === \"Reset\") continue;\n if (key === locale || key.startsWith(`${locale}_`)) {\n return (value as (error: TLocalizedValidationError) => string)(\n error.cause,\n );\n }\n }\n return error.cause.message;\n }\n\n static setLocale(locale: string) {\n for (const [key, value] of Object.entries(Locale)) {\n if (key === \"Set\" || key === \"Get\" || key === \"Reset\") continue;\n if (key === locale || key.startsWith(`${locale}_`)) {\n Locale.Set(value as TLocalizedValidationMessageCallback);\n return;\n }\n }\n throw new AlephaError(`Locale not found: ${locale}`);\n }\n\n static isValidBigInt(value: string | number) {\n if (typeof value === \"number\") {\n return Number.isInteger(value);\n }\n\n // Reject empty or whitespace-only strings\n if (!value.trim()) return false;\n // Regex: optional minus, then digits only\n if (!/^-?\\d+$/.test(value)) return false;\n\n try {\n BigInt(value); // Will throw if invalid\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Default maximum length for strings.\n *\n * It can be set to a larger value:\n * ```ts\n * TypeProvider.DEFAULT_STRING_MAX_LENGTH = 1000000;\n * TypeProvider.DEFAULT_STRING_MAX_LENGTH = undefined; // no limit (not recommended)\n * ```\n */\n static DEFAULT_STRING_MAX_LENGTH: number | undefined = 255;\n\n /**\n * Maximum length for short strings, such as names or titles.\n */\n static DEFAULT_SHORT_STRING_MAX_LENGTH: number | undefined = 64;\n\n /**\n * Maximum length for long strings, such as descriptions or comments.\n * It can be overridden in the string options.\n *\n * It can be set to a larger value:\n * ```ts\n * TypeProvider.DEFAULT_LONG_STRING_MAX_LENGTH = 2048;\n * ```\n */\n static DEFAULT_LONG_STRING_MAX_LENGTH: number | undefined = 1024;\n\n /**\n * Maximum length for rich strings, such as HTML or Markdown.\n * This is a large value to accommodate rich text content.\n * > It's also the maximum length of PG's TEXT type.\n *\n * It can be overridden in the string options.\n *\n * It can be set to a larger value:\n * ```ts\n * TypeProvider.DEFAULT_RICH_STRING_MAX_LENGTH = 1000000;\n * ```\n */\n static DEFAULT_RICH_STRING_MAX_LENGTH: number | undefined = 65535;\n\n /**\n * Maximum number of items in an array.\n * This is a default value to prevent excessive memory usage.\n * It can be overridden in the array options.\n */\n static DEFAULT_ARRAY_MAX_ITEMS = 1000;\n\n // -------------------------------------------------------------------------------------------------------------------\n public raw = Type; // typebox reference\n public any = Type.Any;\n public void = Type.Void;\n public undefined = Type.Undefined;\n public record = Type.Record;\n public union = Type.Union;\n public tuple = Type.Tuple;\n public null = Type.Null;\n public const = Type.Literal;\n public options = Type.Options;\n // -------------------------------------------------------------------------------------------------------------------\n\n /**\n * Type guards to check the type of schema.\n * This is not a runtime type check, but a compile-time type guard.\n *\n * @example\n * ```ts\n * if (t.schema.isString(schema)) {\n * // schema is TString\n * }\n * ```\n */\n public readonly schema = new TypeGuard();\n\n // -------------------------------------------------------------------------------------------------------------------\n\n public extend<T extends TSchema[], U extends TProperties>(\n schema: [...T],\n properties: U,\n options?: TSchemaOptions,\n ): TInterface<T, U>;\n public extend<T extends TObject, U extends TProperties>(\n schema: T,\n properties: U,\n options?: TSchemaOptions,\n ): TInterface<[T], U>;\n public extend(\n schema: TSchema | TSchema[],\n properties: Record<string, any>,\n options?: TSchemaOptions,\n ): any {\n return Type.Interface(\n Array.isArray(schema) ? schema : [schema],\n properties,\n {\n additionalProperties: false,\n ...options,\n },\n );\n }\n\n public pick<T extends TObject, Indexer extends PropertyKey[]>(\n schema: T,\n keys: [...Indexer],\n options?: TObjectOptions,\n ): TPick<T, TKeysToIndexer<Indexer>> {\n return Type.Pick(schema, keys, {\n additionalProperties: false,\n ...options,\n });\n }\n\n public omit<T extends TObject, Indexer extends PropertyKey[]>(\n schema: T,\n keys: [...Indexer],\n options?: TObjectOptions,\n ): TOmit<T, TKeysToIndexer<Indexer>> {\n return Type.Omit(schema, keys, {\n additionalProperties: false,\n ...options,\n });\n }\n\n public partial<T extends TSchema>(\n schema: T,\n options?: TSchemaOptions,\n ): TPartial<T> {\n return Type.Partial(schema, {\n additionalProperties: false,\n ...options,\n });\n }\n\n /**\n * Create a schema for an object.\n * By default, additional properties are not allowed.\n *\n * @example\n * ```ts\n * const userSchema = t.object({\n * id: t.integer(),\n * name: t.string(),\n * });\n * ```\n */\n public object<T extends TProperties>(\n properties: T,\n options?: TObjectOptions,\n ): TObject<T> {\n return Type.Object(properties, {\n additionalProperties: false,\n ...options,\n });\n }\n\n /**\n * Create a schema for an array.\n * By default, the maximum number of items is limited to prevent excessive memory usage.\n *\n * @see TypeProvider.DEFAULT_ARRAY_MAX_ITEMS\n */\n public array<T extends TSchema>(\n schema: T,\n options?: TArrayOptions,\n ): TArray<T> {\n return Type.Array(schema, {\n maxItems: TypeProvider.DEFAULT_ARRAY_MAX_ITEMS,\n ...options,\n });\n }\n\n /**\n * Create a schema for a string.\n * For db or input fields, consider using `t.text()` instead, which has length limits.\n *\n * If you need a string with specific format (e.g. email, uuid), consider using the corresponding method (e.g. `t.email()`, `t.uuid()`).\n */\n public string(options: TStringOptions = {}): TString {\n return Type.String({\n ...options,\n });\n }\n\n /**\n * Create a schema for a string with length limits.\n * For internal strings without length limits, consider using `t.string()` instead.\n *\n * Default size is \"regular\", which has a max length of 255 characters.\n */\n public text(options: TTextOptions = {}): TString {\n const { size, ...rest } = options;\n const maxLength =\n size === \"short\"\n ? TypeProvider.DEFAULT_SHORT_STRING_MAX_LENGTH\n : size === \"long\"\n ? TypeProvider.DEFAULT_LONG_STRING_MAX_LENGTH\n : size === \"rich\"\n ? TypeProvider.DEFAULT_RICH_STRING_MAX_LENGTH\n : TypeProvider.DEFAULT_STRING_MAX_LENGTH;\n\n return Type.String({\n maxLength,\n \"~options\": {\n trim: options.trim ?? true,\n lowercase: options.lowercase ?? false,\n },\n ...rest,\n });\n }\n\n /**\n * Create a schema for a JSON object.\n * This is a record with string keys and any values.\n */\n public json(options?: TSchemaOptions): TRecord<string, TAny> {\n return t.record(t.text(), t.any(), options);\n }\n\n /**\n * Create a schema for a boolean.\n */\n public boolean(options?: TSchemaOptions): TBoolean {\n return Type.Boolean({\n ...options,\n });\n }\n\n /**\n * Create a schema for a number.\n */\n public number(options?: TNumberOptions): TNumber {\n return Type.Number({\n ...options,\n });\n }\n\n /**\n * Create a schema for an integer.\n */\n public integer(options?: TNumberOptions): TInteger {\n return Type.Integer({\n ...options,\n });\n }\n\n public int32(options?: TNumberOptions): TInteger {\n return Type.Integer({\n minimum: -2147483647,\n maximum: 2147483647,\n ...options,\n });\n }\n\n /**\n * Mimic a signed 64-bit integer.\n *\n * This is NOT a true int64, as JavaScript cannot represent all int64 values.\n * It is a number that is an integer and between -9007199254740991 and 9007199254740991.\n * Use `t.bigint()` for true int64 values represented as strings.\n */\n public int64(options?: TNumberOptions): TNumber {\n return Type.Number({\n format: \"int64\",\n multipleOf: 1,\n minimum: -9007199254740991,\n maximum: 9007199254740991,\n ...options,\n });\n }\n\n /**\n * Make a schema optional.\n */\n public optional<T extends TSchema>(schema: T): TOptionalAdd<T> {\n return Type.Optional(schema);\n }\n\n /**\n * Make a schema nullable.\n */\n public nullable<T extends TSchema>(\n schema: T,\n options?: TObjectOptions,\n ): TUnion<[TNull, T]> {\n return Type.Union([Type.Null(), schema], options);\n }\n\n /**\n * Create a schema that maps all properties of an object schema to nullable.\n */\n public nullify = <T extends TSchema>(schema: T, options?: TObjectOptions) =>\n Type.Mapped(\n Type.Identifier(\"K\"),\n Type.KeyOf(schema),\n Type.Ref(\"K\"),\n Type.Union([Type.Index(schema, Type.Ref(\"K\")), Type.Null()]),\n options,\n );\n\n /**\n * Create a schema for a string enum.\n */\n public enum<T extends string[]>(\n values: [...T],\n options?: TTextOptions,\n ): TUnsafe<T[number]> {\n return Type.Unsafe<T[number]>(\n t.text({\n enum: values,\n pattern: values.map((v) => `^${v}$`).join(\"|\"),\n ...options,\n }),\n );\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n\n // Codec types\n\n /**\n * Create a schema for a bigint represented as a string.\n * This is a string that validates bigint format (e.g. \"123456789\").\n */\n public bigint(options?: TStringOptions) {\n return t.string({\n ...options,\n format: \"bigint\",\n });\n }\n\n /**\n * Create a schema for a URL represented as a string.\n */\n public url(options?: TStringOptions) {\n return this.string({\n ...options,\n format: \"url\",\n });\n }\n\n /**\n * Create a schema for binary data represented as a base64 string.\n */\n public binary(options: TStringOptions) {\n return this.string({\n ...options,\n format: \"binary\",\n });\n }\n\n /**\n * Create a schema for uuid.\n */\n public uuid(options?: TStringOptions): TString {\n return this.string({\n ...options,\n format: \"uuid\",\n });\n }\n\n /**\n * Create a schema for a file-like object.\n *\n * File like mimics the File API in browsers, but is adapted to work in Node.js as well.\n *\n * Implementation of file-like objects is handled by \"alepha/file\" package.\n */\n public file(options?: { maxSize?: number }): TFile {\n return Type.Unsafe(\n Type.Any({\n [OPTIONS]: options,\n format: \"binary\",\n }),\n );\n }\n\n /**\n * @experimental\n */\n public stream(): TStream {\n return Type.Unsafe(\n Type.Any({\n format: \"stream\",\n type: \"string\",\n }),\n );\n }\n\n // -------------------------------------------------------------------------------------------------------------------\n // Exotic types\n\n public email(options?: TStringOptions): TString {\n return this.text({\n ...options,\n format: \"email\",\n trim: true,\n lowercase: true,\n });\n }\n\n public e164(options?: TStringOptions): TString {\n return this.text({\n ...options,\n description: \"Phone number in E.164 format, e.g. +1234567890.\",\n pattern: \"^\\\\+[1-9]\\\\d{1,14}$\",\n });\n }\n\n public bcp47(options?: TStringOptions): TString {\n return this.text({\n ...options,\n description: \"BCP 47 language tag, e.g. en, en-US, fr, fr-CA.\",\n pattern: \"^[a-z]{2,3}(?:-[A-Z]{2})?$\",\n });\n }\n\n /**\n * Create a schema for short text, such as names or titles.\n * Default max length is 64 characters.\n */\n public shortText(options?: TStringOptions): TString {\n return this.text({\n size: \"short\",\n ...options,\n });\n }\n\n /**\n * Create a schema for long text, such as descriptions or comments.\n * Default max length is 1024 characters.\n */\n public longText(options?: TStringOptions): TString {\n return this.text({\n size: \"long\",\n ...options,\n });\n }\n\n /**\n * Create a schema for rich text, such as HTML or Markdown.\n * Default max length is 65535 characters.\n */\n public richText(options?: TStringOptions): TString {\n return this.text({\n size: \"rich\",\n ...options,\n });\n }\n\n /**\n * Create a schema for a string enum e.g. LIKE_THIS.\n */\n public snakeCase = (options?: TStringOptions) =>\n this.text({\n pattern: \"^[A-Z_-]+$\",\n ...options,\n });\n\n /**\n * Create a schema for an object with a value and label.\n */\n public valueLabel = (options?: TObjectOptions) =>\n this.object(\n {\n value: this.snakeCase({\n description: \"Machine-readable value.\",\n }),\n label: this.text({\n description: \"Human-readable label.\",\n }),\n description: this.optional(\n this.text({\n description: \"Description of the value.\",\n size: \"long\",\n }),\n ),\n },\n options,\n );\n\n public datetime = (options?: TStringOptions) =>\n t.text({\n ...options,\n format: \"date-time\",\n });\n\n public date = (options?: TStringOptions) =>\n t.text({\n ...options,\n format: \"date\",\n });\n\n public time = (options?: TStringOptions) =>\n t.text({\n ...options,\n format: \"time\",\n });\n\n public duration = (options?: TStringOptions) =>\n t.text({\n ...options,\n format: \"duration\",\n });\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport type TextLength = \"short\" | \"regular\" | \"long\" | \"rich\";\n\nexport interface TTextOptions extends TStringOptions {\n /**\n * Predefined size of the text.\n *\n * - `short` - short text, such as names or titles. Default max length is 64 characters.\n * - `regular` - regular text, such as single-line input. Default max length is 255 characters.\n * - `long` - long text, such as descriptions or comments. Default max length is 1024 characters.\n * - `rich` - rich text, such as HTML or Markdown. Default max length is 65535 characters.\n *\n * You can override the default max length by specifying `maxLength` in the options.\n *\n * @default \"regular\"\n */\n size?: TextLength;\n\n /**\n * Trim whitespace from both ends of the string.\n *\n * @default true\n */\n trim?: boolean;\n\n /**\n * Convert the string to lowercase.\n *\n * @default false\n */\n lowercase?: boolean;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport const t: TypeProvider = new TypeProvider();\n","import type { Static, TObject } from \"typebox\";\nimport { AlephaError } from \"../errors/AlephaError.ts\";\nimport { t } from \"../providers/TypeProvider.ts\";\nimport { $context } from \"./$context.ts\";\n\n/**\n * Get typed values from environment variables.\n *\n * @example\n * ```ts\n * const alepha = Alepha.create({\n * env: {\n * // Alepha.create() will also use process.env when running on Node.js\n * HELLO: \"world\",\n * }\n * });\n *\n * class App {\n * log = $logger();\n *\n * // program expect a var env \"HELLO\" as string to works\n * env = $env(t.object({\n * HELLO: t.text()\n * }));\n *\n * sayHello = () => this.log.info(\"Hello ${this.env.HELLO}\")\n * }\n *\n * run(alepha.with(App));\n * ```\n */\nexport const $env = <T extends TObject>(type: T): Static<T> => {\n const { alepha } = $context();\n\n // allow to inject TypeBox schemas\n if (!t.schema.isObject(type)) {\n throw new AlephaError(\"Type must be an TObject\");\n }\n\n return alepha.parseEnv(type) as Static<T>;\n};\n","import type { Hooks } from \"../Alepha.ts\";\nimport { KIND } from \"../constants/KIND.ts\";\nimport { createPrimitive, Primitive } from \"../helpers/primitive.ts\";\nimport type { Async } from \"../interfaces/Async.ts\";\n\n/**\n * Registers a new hook.\n *\n * ```ts\n * import { $hook } from \"alepha\";\n *\n * class MyProvider {\n * onStart = $hook({\n * name: \"start\", // or \"configure\", \"ready\", \"stop\", ...\n * handler: async (app) => {\n * // await db.connect(); ...\n * }\n * });\n * }\n * ```\n *\n * Hooks are used to run async functions from all registered providers/services.\n *\n * You can't register a hook after the App has started.\n *\n * It's used under the hood by the `configure`, `start`, and `stop` methods.\n * Some modules also use hooks to run their own logic. (e.g. `alepha/server`).\n *\n * You can create your own hooks by using module augmentation:\n *\n * ```ts\n * declare module \"alepha\" {\n *\n * interface Hooks {\n * \"my:custom:hook\": {\n * arg1: string;\n * }\n * }\n * }\n *\n * await alepha.events.emit(\"my:custom:hook\", { arg1: \"value\" });\n * ```\n *\n */\nexport const $hook = <T extends keyof Hooks>(options: HookOptions<T>) =>\n createPrimitive(HookPrimitive<T>, options);\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface HookOptions<T extends keyof Hooks> {\n /**\n * The name of the hook. \"configure\", \"start\", \"ready\", \"stop\", ...\n */\n on: T;\n\n /**\n * The handler to run when the hook is triggered.\n */\n handler: (args: Hooks[T]) => Async<any>;\n\n /**\n * Force the hook to run first or last on the list of hooks.\n */\n priority?: \"first\" | \"last\";\n\n /**\n * Empty placeholder, not implemented yet. :-)\n */\n before?: object | Array<object>;\n\n /**\n * Empty placeholder, not implemented yet. :-)\n */\n after?: object | Array<object>;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport class HookPrimitive<T extends keyof Hooks> extends Primitive<\n HookOptions<T>\n> {\n public called = 0;\n\n protected onInit() {\n this.alepha.events.on(this.options.on, {\n caller: this.config.service,\n priority: this.options.priority,\n callback: async (args: any) => {\n this.called += 1;\n await this.options.handler(args);\n },\n });\n }\n}\n\n$hook[KIND] = HookPrimitive;\n","import type { State } from \"../Alepha.ts\";\nimport { OPTIONS } from \"../constants/OPTIONS.ts\";\nimport type { Static, TObject } from \"../providers/TypeProvider.ts\";\nimport type { Atom } from \"./$atom.ts\";\nimport { $context } from \"./$context.ts\";\n\n/**\n * Subscribes to an atom's state and returns its current value for use in components.\n *\n * Creates a reactive connection between an atom and a component, automatically registering\n * the atom in the application state if not already registered. The returned value is reactive\n * and will update when the atom's state changes.\n *\n * **Use Cases**: Accessing global state, sharing data between components, reactive UI updates\n *\n * @example\n * ```ts\n * const userState = $atom({ schema: t.object({ name: t.text(), role: t.text() }) });\n *\n * class UserComponent {\n * user = $use(userState); // Reactive reference to atom state\n *\n * render() {\n * return <div>Hello {this.user.name}!</div>;\n * }\n * }\n * ```\n */\nexport const $use = <T extends TObject, N extends string>(\n atom: Atom<T, N>,\n): Readonly<Static<T>> => {\n const { alepha } = $context();\n\n // register atom in state if not already registered\n alepha.store.register(atom);\n\n const init = alepha.store.get(atom.key as keyof State) as object;\n\n return {\n [OPTIONS]: { getter: atom.key }, // alepha will replace this with by a real 'get prop()'\n ...init,\n } as Static<T>;\n};\n","import { type Static, t } from \"../providers/TypeProvider.ts\";\n\nexport const pageQuerySchema = t.object({\n page: t.optional(\n t.integer({\n description: \"The page number to retrieve.\",\n minimum: 0,\n default: 0,\n }),\n ),\n size: t.optional(\n t.integer({\n description: \"The number of items per page.\",\n minimum: 1,\n maximum: 100,\n default: 10,\n }),\n ),\n sort: t.optional(\n t.text({\n description:\n \"Sort by field(s). Multiple columns separated by comma. Prefix with '-' for DESC. Examples: 'name' (ASC), '-createdAt' (DESC), 'role,-name' (role ASC, name DESC)\",\n }),\n ),\n});\n\nexport type PageQuery = Static<typeof pageQuerySchema>;\n","import {\n type Static,\n type TArray,\n type TObject,\n type TObjectOptions,\n type TRecord,\n TypeProvider,\n t,\n} from \"../providers/TypeProvider.ts\";\n\nexport const pageMetadataSchema = t.object({\n number: t.integer({ description: \"Page number, starting from 0\" }),\n size: t.integer({\n description: \"Number of items per page (requested page size)\",\n }),\n offset: t.integer({\n description: \"Offset in the dataset (page × size)\",\n }),\n numberOfElements: t.integer({\n description:\n \"Number of elements in THIS page (content.length). Different from totalElements which is the total across all pages.\",\n }),\n totalElements: t.optional(\n t.integer({\n description:\n \"Total number of elements across all pages. Only available when counting is enabled.\",\n }),\n ),\n totalPages: t.optional(\n t.integer({\n description:\n \"Total number of pages. Only available when `totalElements` is present.\",\n }),\n ),\n isEmpty: t.boolean({\n description:\n \"Indicates if the current page has no items (numberOfElements === 0)\",\n }),\n isFirst: t.boolean({\n description: \"Indicates if this is the first page (number === 0)\",\n }),\n isLast: t.boolean({\n description:\n \"Indicates if this is the last page (no more pages after this)\",\n }),\n sort: t.optional(\n t.object({\n sorted: t.boolean({\n description: \"Whether the results are sorted\",\n }),\n fields: t.array(\n t.object({\n field: t.text({\n description: \"The field used for sorting\",\n }),\n direction: t.enum([\"asc\", \"desc\"], {\n description: \"The direction of the sort. Either 'asc' or 'desc'\",\n }),\n }),\n ),\n }),\n ),\n});\n\n/**\n * Create a pagination schema for the given object schema.\n *\n * Provides a standardized pagination response format compatible with Spring Data's Page interface.\n * This schema can be used across any data source (databases, APIs, caches, etc.).\n *\n * @example\n * ```ts\n * const userSchema = t.object({ id: t.integer(), name: t.text() });\n * const userPageSchema = pageSchema(userSchema);\n * ```\n *\n * @example In an API endpoint\n * ```ts\n * $action({\n * output: pageSchema(UserSchema),\n * handler: async () => {\n * return await userRepo.paginate();\n * }\n * })\n * ```\n */\nexport const pageSchema = <T extends TObject | TRecord>(\n objectSchema: T,\n options?: TObjectOptions,\n): TPage<T> =>\n t.object(\n {\n content: t.array(objectSchema),\n page: pageMetadataSchema,\n },\n options,\n );\n\nexport type TPage<T extends TObject | TRecord> = TObject<{\n content: TArray<T>;\n page: typeof pageMetadataSchema;\n}>;\n\n/**\n * Opinionated type definition for a paginated response.\n *\n * Inspired by Spring Data's Page interface with all essential pagination metadata.\n * This generic type can be used with any data source.\n *\n * @example\n * ```ts\n * const page: Page<User> = {\n * content: [user1, user2, ...],\n * page: {\n * number: 0,\n * size: 10,\n * offset: 0,\n * numberOfElements: 10,\n * totalElements: 1200,\n * totalPages: 120,\n * isEmpty: false,\n * isFirst: true,\n * isLast: false,\n * sort: {\n * sorted: true,\n * fields: [\n * { field: \"name\", direction: \"asc\" }\n * ]\n * }\n * }\n * }\n * ```\n */\nexport type Page<T> = {\n /**\n * Array of items on the current page.\n */\n content: T[];\n page: Static<typeof pageMetadataSchema>;\n};\n\nexport type PageMetadata = Static<typeof pageMetadataSchema>;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\ndeclare module \"alepha\" {\n interface TypeProvider {\n /**\n * Create a schema for a paginated response.\n */\n page<T extends TObject | TRecord>(itemSchema: T): TPage<T>;\n }\n}\n\nTypeProvider.prototype.page = (itemSchema) => pageSchema(itemSchema);\n","import { Alepha } from \"./Alepha.ts\";\nimport type { RunOptions } from \"./interfaces/Run.ts\";\nimport type { Service } from \"./interfaces/Service.ts\";\n\nexport * from \"./index.shared.ts\";\n\nexport const run = (\n entry: Alepha | Service | Array<Service>,\n opts?: RunOptions,\n): Alepha => {\n const alepha =\n entry instanceof Alepha ? entry : Alepha.create({ env: { ...opts?.env } });\n\n if (!(entry instanceof Alepha)) {\n const entries = Array.isArray(entry) ? entry : [entry];\n for (const e of entries) {\n alepha.with(e);\n }\n }\n\n if (import.meta?.hot) {\n import.meta.hot.on(\"alepha:reload\", async () => {\n window.location.reload();\n });\n }\n\n (async () => {\n try {\n await opts?.configure?.(alepha);\n\n await alepha.start();\n\n if (opts?.ready) {\n await opts.ready(alepha);\n }\n } catch (error) {\n alepha.log?.error(\"Alepha failed to start\", error);\n }\n })();\n\n (window as any).alepha = alepha;\n\n return alepha;\n};\n"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