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,46 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
let node_async_hooks = require("node:async_hooks");
|
|
29
|
-
let node_cluster = require("node:cluster");
|
|
30
|
-
node_cluster = __toESM(node_cluster);
|
|
31
|
-
let node_os = require("node:os");
|
|
32
|
-
let typebox_compile = require("typebox/compile");
|
|
33
|
-
let typebox = require("typebox");
|
|
34
|
-
typebox = __toESM(typebox);
|
|
35
|
-
let typebox_format = require("typebox/format");
|
|
36
|
-
typebox_format = __toESM(typebox_format);
|
|
37
|
-
let typebox_system = require("typebox/system");
|
|
38
|
-
let typebox_value = require("typebox/value");
|
|
39
|
-
typebox_value = __toESM(typebox_value);
|
|
1
|
+
import { Compile } from "typebox/compile";
|
|
2
|
+
import * as TypeBox from "typebox";
|
|
3
|
+
import { Type } from "typebox";
|
|
4
|
+
import TypeBoxFormat from "typebox/format";
|
|
5
|
+
import { Locale } from "typebox/system";
|
|
6
|
+
import * as TypeBoxValue from "typebox/value";
|
|
40
7
|
|
|
41
8
|
//#region src/core/constants/KIND.ts
|
|
42
9
|
/**
|
|
43
|
-
* Used for identifying
|
|
10
|
+
* Used for identifying primitives.
|
|
44
11
|
*
|
|
45
12
|
* @internal
|
|
46
13
|
*/
|
|
@@ -58,7 +25,7 @@ const MODULE = Symbol.for("Alepha.Module");
|
|
|
58
25
|
//#endregion
|
|
59
26
|
//#region src/core/constants/OPTIONS.ts
|
|
60
27
|
/**
|
|
61
|
-
* Used for
|
|
28
|
+
* Used for primitives options.
|
|
62
29
|
*
|
|
63
30
|
* @internal
|
|
64
31
|
*/
|
|
@@ -73,98 +40,6 @@ var AlephaError = class extends Error {
|
|
|
73
40
|
name = "AlephaError";
|
|
74
41
|
};
|
|
75
42
|
|
|
76
|
-
//#endregion
|
|
77
|
-
//#region src/core/descriptors/$module.ts
|
|
78
|
-
/**
|
|
79
|
-
* Wrap Services and Descriptors into a Module.
|
|
80
|
-
*
|
|
81
|
-
* - A module is just a Service with some extra {@link Module}.
|
|
82
|
-
* - You must attach a `name` to it.
|
|
83
|
-
* - Name must follow the pattern: `project.module.submodule`. (e.g. `myapp.users.auth`).
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```ts
|
|
87
|
-
* import { $module } from "alepha";
|
|
88
|
-
* import { MyService } from "./MyService.ts";
|
|
89
|
-
*
|
|
90
|
-
* // export MyService, so it can be used everywhere (optional)
|
|
91
|
-
* export * from "./MyService.ts";
|
|
92
|
-
*
|
|
93
|
-
* export default $module({
|
|
94
|
-
* name: "my.project.module",
|
|
95
|
-
* // MyService will have a module context "my.project.module"
|
|
96
|
-
* services: [MyService],
|
|
97
|
-
* });
|
|
98
|
-
* ```
|
|
99
|
-
*
|
|
100
|
-
* ### Why Modules?
|
|
101
|
-
*
|
|
102
|
-
* #### Logging
|
|
103
|
-
*
|
|
104
|
-
* By default, AlephaLogger will log the module name in the logs.
|
|
105
|
-
* This helps to identify where the logs are coming from.
|
|
106
|
-
*
|
|
107
|
-
* You can also set different log levels for different modules.
|
|
108
|
-
* It means you can set 'some.very.specific.module' to 'debug' and keep the rest of the application to 'info'.
|
|
109
|
-
*
|
|
110
|
-
* #### Modulith
|
|
111
|
-
*
|
|
112
|
-
* Force to structure your application in modules, even if it's a single deployable unit.
|
|
113
|
-
* It helps to keep a clean architecture and avoid monolithic applications.
|
|
114
|
-
*
|
|
115
|
-
* A strict mode flag will probably come to enforce module boundaries.
|
|
116
|
-
* -> Throwing errors when a service from another module is injected.
|
|
117
|
-
* But it's not implemented yet.
|
|
118
|
-
*
|
|
119
|
-
* ### When not to use Modules?
|
|
120
|
-
*
|
|
121
|
-
* Small applications does not need modules. It's better to keep it simple.
|
|
122
|
-
* Modules are more useful when the application grows and needs to be structured.
|
|
123
|
-
* If we speak with number of `$actions`, a module should be used when you have more than 30 actions in a single module.
|
|
124
|
-
* Meaning that if you have 100 actions, you should have at least 3 modules.
|
|
125
|
-
*/
|
|
126
|
-
const $module = (options) => {
|
|
127
|
-
const { services = [], descriptors = [], name } = options;
|
|
128
|
-
if (!name || !Module.NAME_REGEX.test(name)) throw new AlephaError(`Invalid module name '${name}'. It should be in the format of 'project.module.submodule'`);
|
|
129
|
-
const $ = class extends Module {
|
|
130
|
-
options = options;
|
|
131
|
-
register(alepha) {
|
|
132
|
-
if (typeof options.register === "function") {
|
|
133
|
-
options.register(alepha);
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
for (const service of services) alepha.inject(service, { parent: this.constructor });
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
Object.defineProperty($, "name", {
|
|
140
|
-
value: name,
|
|
141
|
-
writable: false
|
|
142
|
-
});
|
|
143
|
-
for (const service of services) if (!Module.is(service)) service[MODULE] = $;
|
|
144
|
-
for (const factory of descriptors) if (typeof factory[KIND] === "function") factory[KIND][MODULE] = $;
|
|
145
|
-
return $;
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* Base class for all modules.
|
|
149
|
-
*/
|
|
150
|
-
var Module = class Module {
|
|
151
|
-
static NAME_REGEX = /^[a-z]+(\.[a-z][a-z0-9-]*)*$/;
|
|
152
|
-
/**
|
|
153
|
-
* Check if a Service is a Module.
|
|
154
|
-
*/
|
|
155
|
-
static is(ctor) {
|
|
156
|
-
return ctor.prototype instanceof Module;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Get the Module of a Service.
|
|
160
|
-
*
|
|
161
|
-
* Returns undefined if the Service is not part of a Module.
|
|
162
|
-
*/
|
|
163
|
-
static of(ctor) {
|
|
164
|
-
return ctor[MODULE];
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
|
|
168
43
|
//#endregion
|
|
169
44
|
//#region src/core/errors/CircularDependencyError.ts
|
|
170
45
|
var CircularDependencyError = class extends AlephaError {
|
|
@@ -213,7 +88,7 @@ const __alephaRef = {};
|
|
|
213
88
|
/**
|
|
214
89
|
* Note:
|
|
215
90
|
*
|
|
216
|
-
* This file is used to share context between $
|
|
91
|
+
* This file is used to share context between $primitives and the Alepha core during the injection phase.
|
|
217
92
|
*
|
|
218
93
|
* There is no side effect as long as Alepha is not used concurrently in multiple contexts (which is not the case).
|
|
219
94
|
*
|
|
@@ -252,11 +127,11 @@ const __alephaRef = {};
|
|
|
252
127
|
*/
|
|
253
128
|
|
|
254
129
|
//#endregion
|
|
255
|
-
//#region src/core/
|
|
130
|
+
//#region src/core/primitives/$context.ts
|
|
256
131
|
/**
|
|
257
132
|
* Get Alepha instance and current service from the current context.
|
|
258
133
|
*
|
|
259
|
-
* It can only be used inside $
|
|
134
|
+
* It can only be used inside $primitive functions.
|
|
260
135
|
*
|
|
261
136
|
* ```ts
|
|
262
137
|
* import { $context } from "alepha";
|
|
@@ -265,7 +140,7 @@ const __alephaRef = {};
|
|
|
265
140
|
* const { alepha, service, module } = $context();
|
|
266
141
|
*
|
|
267
142
|
* // alepha - alepha instance
|
|
268
|
-
* // service - class which is creating this
|
|
143
|
+
* // service - class which is creating this primitive, this is NOT the instance but the service definition
|
|
269
144
|
* // module - module definition, if any
|
|
270
145
|
*
|
|
271
146
|
* return {};
|
|
@@ -290,8 +165,8 @@ const $context = () => {
|
|
|
290
165
|
};
|
|
291
166
|
|
|
292
167
|
//#endregion
|
|
293
|
-
//#region src/core/helpers/
|
|
294
|
-
var
|
|
168
|
+
//#region src/core/helpers/primitive.ts
|
|
169
|
+
var Primitive = class {
|
|
295
170
|
alepha;
|
|
296
171
|
options;
|
|
297
172
|
config;
|
|
@@ -305,14 +180,14 @@ var Descriptor = class {
|
|
|
305
180
|
};
|
|
306
181
|
}
|
|
307
182
|
/**
|
|
308
|
-
* Called automatically by Alepha after the
|
|
183
|
+
* Called automatically by Alepha after the primitive is created.
|
|
309
184
|
*/
|
|
310
185
|
onInit() {}
|
|
311
186
|
};
|
|
312
|
-
const
|
|
187
|
+
const createPrimitive = (primitive, options) => {
|
|
313
188
|
const { alepha, service } = $context();
|
|
314
|
-
if (MODULE in
|
|
315
|
-
return alepha.inject(
|
|
189
|
+
if (MODULE in primitive && primitive[MODULE]) alepha.with(primitive[MODULE]);
|
|
190
|
+
return alepha.inject(primitive, {
|
|
316
191
|
lifetime: "transient",
|
|
317
192
|
args: [{
|
|
318
193
|
options,
|
|
@@ -330,6 +205,98 @@ function isClass(func) {
|
|
|
330
205
|
return !!descriptor && !descriptor.writable;
|
|
331
206
|
}
|
|
332
207
|
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/core/primitives/$module.ts
|
|
210
|
+
/**
|
|
211
|
+
* Wrap Services and Primitives into a Module.
|
|
212
|
+
*
|
|
213
|
+
* - A module is just a Service with some extra {@link Module}.
|
|
214
|
+
* - You must attach a `name` to it.
|
|
215
|
+
* - Name must follow the pattern: `project.module.submodule`. (e.g. `myapp.users.auth`).
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* import { $module } from "alepha";
|
|
220
|
+
* import { MyService } from "./MyService.ts";
|
|
221
|
+
*
|
|
222
|
+
* // export MyService, so it can be used everywhere (optional)
|
|
223
|
+
* export * from "./MyService.ts";
|
|
224
|
+
*
|
|
225
|
+
* export default $module({
|
|
226
|
+
* name: "my.project.module",
|
|
227
|
+
* // MyService will have a module context "my.project.module"
|
|
228
|
+
* services: [MyService],
|
|
229
|
+
* });
|
|
230
|
+
* ```
|
|
231
|
+
*
|
|
232
|
+
* ### Why Modules?
|
|
233
|
+
*
|
|
234
|
+
* #### Logging
|
|
235
|
+
*
|
|
236
|
+
* By default, AlephaLogger will log the module name in the logs.
|
|
237
|
+
* This helps to identify where the logs are coming from.
|
|
238
|
+
*
|
|
239
|
+
* You can also set different log levels for different modules.
|
|
240
|
+
* It means you can set 'some.very.specific.module' to 'debug' and keep the rest of the application to 'info'.
|
|
241
|
+
*
|
|
242
|
+
* #### Modulith
|
|
243
|
+
*
|
|
244
|
+
* Force to structure your application in modules, even if it's a single deployable unit.
|
|
245
|
+
* It helps to keep a clean architecture and avoid monolithic applications.
|
|
246
|
+
*
|
|
247
|
+
* A strict mode flag will probably come to enforce module boundaries.
|
|
248
|
+
* -> Throwing errors when a service from another module is injected.
|
|
249
|
+
* But it's not implemented yet.
|
|
250
|
+
*
|
|
251
|
+
* ### When not to use Modules?
|
|
252
|
+
*
|
|
253
|
+
* Small applications does not need modules. It's better to keep it simple.
|
|
254
|
+
* Modules are more useful when the application grows and needs to be structured.
|
|
255
|
+
* If we speak with number of `$actions`, a module should be used when you have more than 30 actions in a single module.
|
|
256
|
+
* Meaning that if you have 100 actions, you should have at least 3 modules.
|
|
257
|
+
*/
|
|
258
|
+
const $module = (options) => {
|
|
259
|
+
const { services = [], primitives = [], name } = options;
|
|
260
|
+
if (!name || !Module.NAME_REGEX.test(name)) throw new AlephaError(`Invalid module name '${name}'. It should be in the format of 'project.module.submodule'`);
|
|
261
|
+
const $ = class extends Module {
|
|
262
|
+
options = options;
|
|
263
|
+
register(alepha) {
|
|
264
|
+
if (typeof options.register === "function") {
|
|
265
|
+
options.register(alepha);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
for (const service of services) alepha.inject(service, { parent: this.constructor });
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
Object.defineProperty($, "name", {
|
|
272
|
+
value: name,
|
|
273
|
+
writable: false
|
|
274
|
+
});
|
|
275
|
+
for (const service of services) if (!Module.is(service)) service[MODULE] = $;
|
|
276
|
+
for (const factory of primitives) if (typeof factory[KIND] === "function") factory[KIND][MODULE] = $;
|
|
277
|
+
return $;
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* Base class for all modules.
|
|
281
|
+
*/
|
|
282
|
+
var Module = class Module {
|
|
283
|
+
static NAME_REGEX = /^[a-z]+(\.[a-z][a-z0-9-]*)*$/;
|
|
284
|
+
/**
|
|
285
|
+
* Check if a Service is a Module.
|
|
286
|
+
*/
|
|
287
|
+
static is(ctor) {
|
|
288
|
+
return ctor.prototype instanceof Module;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Get the Module of a Service.
|
|
292
|
+
*
|
|
293
|
+
* Returns undefined if the Service is not part of a Module.
|
|
294
|
+
*/
|
|
295
|
+
static of(ctor) {
|
|
296
|
+
return ctor[MODULE];
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
|
|
333
300
|
//#endregion
|
|
334
301
|
//#region src/core/providers/AlsProvider.ts
|
|
335
302
|
var AlsProvider = class AlsProvider {
|
|
@@ -363,7 +330,7 @@ var AlsProvider = class AlsProvider {
|
|
|
363
330
|
};
|
|
364
331
|
|
|
365
332
|
//#endregion
|
|
366
|
-
//#region src/core/
|
|
333
|
+
//#region src/core/primitives/$inject.ts
|
|
367
334
|
/**
|
|
368
335
|
* Get the instance of the specified type from the context.
|
|
369
336
|
*
|
|
@@ -382,7 +349,7 @@ const $inject = (type, opts = {}) => {
|
|
|
382
349
|
...opts
|
|
383
350
|
});
|
|
384
351
|
};
|
|
385
|
-
var
|
|
352
|
+
var InjectPrimitive = class extends Primitive {};
|
|
386
353
|
|
|
387
354
|
//#endregion
|
|
388
355
|
//#region src/core/providers/Json.ts
|
|
@@ -475,7 +442,7 @@ var SchemaValidator = class {
|
|
|
475
442
|
}
|
|
476
443
|
getValidator(schema) {
|
|
477
444
|
if (this.cache.has(schema)) return this.cache.get(schema);
|
|
478
|
-
const validator =
|
|
445
|
+
const validator = Compile(schema);
|
|
479
446
|
this.cache.set(schema, validator);
|
|
480
447
|
return validator;
|
|
481
448
|
}
|
|
@@ -650,7 +617,7 @@ var EventManager = class {
|
|
|
650
617
|
};
|
|
651
618
|
|
|
652
619
|
//#endregion
|
|
653
|
-
//#region src/core/
|
|
620
|
+
//#region src/core/primitives/$atom.ts
|
|
654
621
|
/**
|
|
655
622
|
* Define an atom for state management.
|
|
656
623
|
*
|
|
@@ -853,7 +820,7 @@ var StateManager = class {
|
|
|
853
820
|
* // You can access the environment variables using alepha.env
|
|
854
821
|
* console.log(alepha.env.MY_VAR); // "value"
|
|
855
822
|
*
|
|
856
|
-
* // But you should use $env()
|
|
823
|
+
* // But you should use $env() primitive to get typed values from the environment.
|
|
857
824
|
* class App {
|
|
858
825
|
* env = $env(
|
|
859
826
|
* t.object({
|
|
@@ -866,7 +833,7 @@ var StateManager = class {
|
|
|
866
833
|
* ### Modules
|
|
867
834
|
*
|
|
868
835
|
* Modules are a way to group services together.
|
|
869
|
-
* You can register a module using the `$module`
|
|
836
|
+
* You can register a module using the `$module` primitive.
|
|
870
837
|
*
|
|
871
838
|
* ```ts
|
|
872
839
|
* import { $module } from "alepha";
|
|
@@ -884,7 +851,7 @@ var StateManager = class {
|
|
|
884
851
|
* ### Hooks
|
|
885
852
|
*
|
|
886
853
|
* Hooks are a way to run async functions from all registered providers/services.
|
|
887
|
-
* You can register a hook using the `$hook`
|
|
854
|
+
* You can register a hook using the `$hook` primitive.
|
|
888
855
|
*
|
|
889
856
|
* ```ts
|
|
890
857
|
* import { $hook } from "alepha";
|
|
@@ -945,7 +912,7 @@ var Alepha = class Alepha {
|
|
|
945
912
|
try {
|
|
946
913
|
onTestFinished?.(() => alepha.stop());
|
|
947
914
|
} catch (_error) {}
|
|
948
|
-
alepha.
|
|
915
|
+
alepha.store.set("alepha.test.beforeAll", beforeAll).set("alepha.test.afterAll", afterAll).set("alepha.test.afterEach", afterEach).set("alepha.test.onTestFinished", onTestFinished);
|
|
949
916
|
}
|
|
950
917
|
return alepha;
|
|
951
918
|
}
|
|
@@ -999,9 +966,9 @@ var Alepha = class Alepha {
|
|
|
999
966
|
*/
|
|
1000
967
|
substitutions = /* @__PURE__ */ new Map();
|
|
1001
968
|
/**
|
|
1002
|
-
* Registry of
|
|
969
|
+
* Registry of primitives.
|
|
1003
970
|
*/
|
|
1004
|
-
|
|
971
|
+
primitiveRegistry = /* @__PURE__ */ new Map();
|
|
1005
972
|
/**
|
|
1006
973
|
* List of all services + how they are provided.
|
|
1007
974
|
*/
|
|
@@ -1025,7 +992,7 @@ var Alepha = class Alepha {
|
|
|
1025
992
|
/**
|
|
1026
993
|
* State manager to store arbitrary values.
|
|
1027
994
|
*/
|
|
1028
|
-
get
|
|
995
|
+
get store() {
|
|
1029
996
|
this.events;
|
|
1030
997
|
return this.inject(StateManager, { args: [this.init] });
|
|
1031
998
|
}
|
|
@@ -1041,13 +1008,13 @@ var Alepha = class Alepha {
|
|
|
1041
1008
|
* Get logger instance.
|
|
1042
1009
|
*/
|
|
1043
1010
|
get log() {
|
|
1044
|
-
return this.
|
|
1011
|
+
return this.store.get("alepha.logger");
|
|
1045
1012
|
}
|
|
1046
1013
|
/**
|
|
1047
1014
|
* The environment variables for the App.
|
|
1048
1015
|
*/
|
|
1049
1016
|
get env() {
|
|
1050
|
-
return this.
|
|
1017
|
+
return this.store.get("env") ?? {};
|
|
1051
1018
|
}
|
|
1052
1019
|
constructor(init = {}) {
|
|
1053
1020
|
this.init = init;
|
|
@@ -1136,7 +1103,7 @@ var Alepha = class Alepha {
|
|
|
1136
1103
|
* Starts the App.
|
|
1137
1104
|
*
|
|
1138
1105
|
* - Lock any further changes to the container.
|
|
1139
|
-
* - Run "configure" hook for all services.
|
|
1106
|
+
* - Run "configure" hook for all services. Primitives will be processed.
|
|
1140
1107
|
* - Run "start" hook for all services. Providers will connect/listen/...
|
|
1141
1108
|
* - Run "ready" hook for all services. This is the point where the App is ready to serve requests.
|
|
1142
1109
|
*
|
|
@@ -1156,10 +1123,10 @@ var Alepha = class Alepha {
|
|
|
1156
1123
|
const now = Date.now();
|
|
1157
1124
|
this.log?.info("Starting App...");
|
|
1158
1125
|
for (const [key] of this.substitutions.entries()) this.inject(key);
|
|
1159
|
-
const target = this.
|
|
1126
|
+
const target = this.store.get("alepha.target");
|
|
1160
1127
|
if (target) {
|
|
1161
1128
|
this.registry = /* @__PURE__ */ new Map();
|
|
1162
|
-
this.
|
|
1129
|
+
this.primitiveRegistry = /* @__PURE__ */ new Map();
|
|
1163
1130
|
this.with(target);
|
|
1164
1131
|
}
|
|
1165
1132
|
this.locked = true;
|
|
@@ -1294,8 +1261,8 @@ var Alepha = class Alepha {
|
|
|
1294
1261
|
}
|
|
1295
1262
|
if (this.started) throw new ContainerLockedError(`Container is locked. No more services can be added. ${parent?.name} -> ${service.name}`);
|
|
1296
1263
|
}
|
|
1297
|
-
const module
|
|
1298
|
-
if (module
|
|
1264
|
+
const module = service[MODULE];
|
|
1265
|
+
if (module && typeof module === "function") this.with(module);
|
|
1299
1266
|
if (this.has(service, { registry }) && !transient) return this.inject(service, {
|
|
1300
1267
|
parent,
|
|
1301
1268
|
lifetime
|
|
@@ -1342,8 +1309,8 @@ var Alepha = class Alepha {
|
|
|
1342
1309
|
graph[provide.name] = { from: parents.filter((it) => !!it).map((it) => it.name) };
|
|
1343
1310
|
const aliases = this.substitutions.entries().filter((it) => it[1].use === provide).map((it) => it[0].name).toArray();
|
|
1344
1311
|
if (aliases.length) graph[provide.name].as = aliases;
|
|
1345
|
-
const module
|
|
1346
|
-
if (module
|
|
1312
|
+
const module = Module.of(provide);
|
|
1313
|
+
if (module) graph[provide.name].module = module.name;
|
|
1347
1314
|
}
|
|
1348
1315
|
return graph;
|
|
1349
1316
|
}
|
|
@@ -1353,19 +1320,19 @@ var Alepha = class Alepha {
|
|
|
1353
1320
|
return list;
|
|
1354
1321
|
}
|
|
1355
1322
|
/**
|
|
1356
|
-
* Get all
|
|
1323
|
+
* Get all primitives of the specified type.
|
|
1357
1324
|
*/
|
|
1358
|
-
|
|
1325
|
+
primitives(factory) {
|
|
1359
1326
|
if (typeof factory === "string") {
|
|
1360
1327
|
const key1 = factory.toLowerCase().replace("$", "");
|
|
1361
|
-
const key2 = `${key1}
|
|
1362
|
-
for (const [key, value] of this.
|
|
1328
|
+
const key2 = `${key1}primitive`;
|
|
1329
|
+
for (const [key, value] of this.primitiveRegistry.entries()) {
|
|
1363
1330
|
const name = key.name.toLowerCase();
|
|
1364
1331
|
if (name === key1 || name === key2) return value;
|
|
1365
1332
|
}
|
|
1366
1333
|
return [];
|
|
1367
1334
|
}
|
|
1368
|
-
return this.
|
|
1335
|
+
return this.primitiveRegistry.get(factory[KIND]) ?? [];
|
|
1369
1336
|
}
|
|
1370
1337
|
new(service, args = []) {
|
|
1371
1338
|
this.pendingInstantiations.push(service);
|
|
@@ -1374,10 +1341,10 @@ var Alepha = class Alepha {
|
|
|
1374
1341
|
const instance = isClass(service) ? new service(...args) : service(...args) ?? {};
|
|
1375
1342
|
const obj = instance;
|
|
1376
1343
|
for (const [key, value] of Object.entries(obj)) {
|
|
1377
|
-
if (value instanceof
|
|
1344
|
+
if (value instanceof Primitive) this.processPrimitive(value, key);
|
|
1378
1345
|
if (typeof value === "object" && value !== null && typeof value[OPTIONS] === "object" && "getter" in value[OPTIONS]) {
|
|
1379
1346
|
const getter = value[OPTIONS].getter;
|
|
1380
|
-
Object.defineProperty(obj, key, { get: () => this.
|
|
1347
|
+
Object.defineProperty(obj, key, { get: () => this.store.get(getter) });
|
|
1381
1348
|
}
|
|
1382
1349
|
}
|
|
1383
1350
|
this.pendingInstantiations.pop();
|
|
@@ -1385,15 +1352,95 @@ var Alepha = class Alepha {
|
|
|
1385
1352
|
__alephaRef.service = this.pendingInstantiations[this.pendingInstantiations.length - 1];
|
|
1386
1353
|
return instance;
|
|
1387
1354
|
}
|
|
1388
|
-
|
|
1355
|
+
processPrimitive(value, propertyKey = "") {
|
|
1389
1356
|
value.config.propertyKey = propertyKey;
|
|
1390
1357
|
value.onInit();
|
|
1391
1358
|
const kind = value.constructor;
|
|
1392
|
-
const list = this.
|
|
1393
|
-
this.
|
|
1359
|
+
const list = this.primitiveRegistry.get(kind) ?? [];
|
|
1360
|
+
this.primitiveRegistry.set(kind, [...list, value]);
|
|
1394
1361
|
}
|
|
1395
1362
|
};
|
|
1396
1363
|
|
|
1364
|
+
//#endregion
|
|
1365
|
+
//#region src/core/errors/AppNotStartedError.ts
|
|
1366
|
+
var AppNotStartedError = class extends AlephaError {
|
|
1367
|
+
name = "AppNotStartedError";
|
|
1368
|
+
constructor() {
|
|
1369
|
+
super("App not started. Please start the app before.");
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
|
|
1373
|
+
//#endregion
|
|
1374
|
+
//#region src/core/helpers/createPagination.ts
|
|
1375
|
+
/**
|
|
1376
|
+
* Create a pagination object from an array of entities.
|
|
1377
|
+
*
|
|
1378
|
+
* This is a pure function that works with any data source (databases, APIs, caches, arrays, etc.).
|
|
1379
|
+
* It handles the core pagination logic including:
|
|
1380
|
+
* - Slicing the content to the requested page size
|
|
1381
|
+
* - Calculating pagination metadata (offset, page number, etc.)
|
|
1382
|
+
* - Determining navigation state (isFirst, isLast)
|
|
1383
|
+
* - Including sort metadata when provided
|
|
1384
|
+
*
|
|
1385
|
+
* @param entities - The entities to paginate (should include one extra item to detect if there's a next page)
|
|
1386
|
+
* @param limit - The limit of the pagination (page size)
|
|
1387
|
+
* @param offset - The offset of the pagination (starting position)
|
|
1388
|
+
* @param sort - Optional sort metadata to include in response
|
|
1389
|
+
* @returns A complete Page object with content and metadata
|
|
1390
|
+
*
|
|
1391
|
+
* @example Basic pagination
|
|
1392
|
+
* ```ts
|
|
1393
|
+
* const users = await fetchUsers({ limit: 11, offset: 0 }); // Fetch limit + 1
|
|
1394
|
+
* const page = createPagination(users, 10, 0);
|
|
1395
|
+
* // page.content has max 10 items
|
|
1396
|
+
* // page.page.isLast tells us if there are more pages
|
|
1397
|
+
* ```
|
|
1398
|
+
*
|
|
1399
|
+
* @example With sorting
|
|
1400
|
+
* ```ts
|
|
1401
|
+
* const page = createPagination(
|
|
1402
|
+
* entities,
|
|
1403
|
+
* 10,
|
|
1404
|
+
* 0,
|
|
1405
|
+
* [{ column: "name", direction: "asc" }]
|
|
1406
|
+
* );
|
|
1407
|
+
* ```
|
|
1408
|
+
*
|
|
1409
|
+
* @example In a custom service
|
|
1410
|
+
* ```ts
|
|
1411
|
+
* class MyService {
|
|
1412
|
+
* async listItems(page: number, size: number) {
|
|
1413
|
+
* const items = await this.fetchItems({ limit: size + 1, offset: page * size });
|
|
1414
|
+
* return createPagination(items, size, page * size);
|
|
1415
|
+
* }
|
|
1416
|
+
* }
|
|
1417
|
+
* ```
|
|
1418
|
+
*/
|
|
1419
|
+
function createPagination(entities, limit = 10, offset = 0, sort) {
|
|
1420
|
+
const content = entities.slice(0, limit);
|
|
1421
|
+
const hasNext = entities.length === limit + 1;
|
|
1422
|
+
const pageNumber = Math.floor(offset / limit);
|
|
1423
|
+
return {
|
|
1424
|
+
content,
|
|
1425
|
+
page: {
|
|
1426
|
+
number: pageNumber,
|
|
1427
|
+
size: limit,
|
|
1428
|
+
offset,
|
|
1429
|
+
numberOfElements: content.length,
|
|
1430
|
+
isEmpty: content.length === 0,
|
|
1431
|
+
isFirst: pageNumber === 0,
|
|
1432
|
+
isLast: !hasNext,
|
|
1433
|
+
...sort && sort.length > 0 ? { sort: {
|
|
1434
|
+
sorted: true,
|
|
1435
|
+
fields: sort.map((s) => ({
|
|
1436
|
+
field: s.column,
|
|
1437
|
+
direction: s.direction
|
|
1438
|
+
}))
|
|
1439
|
+
} } : {}
|
|
1440
|
+
}
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1397
1444
|
//#endregion
|
|
1398
1445
|
//#region src/core/helpers/FileLike.ts
|
|
1399
1446
|
const isTypeFile = (value) => {
|
|
@@ -1405,33 +1452,33 @@ const isFileLike = (value) => {
|
|
|
1405
1452
|
|
|
1406
1453
|
//#endregion
|
|
1407
1454
|
//#region src/core/providers/TypeProvider.ts
|
|
1408
|
-
const isUUID =
|
|
1409
|
-
const isEmail =
|
|
1410
|
-
const isURL =
|
|
1411
|
-
const isDateTime =
|
|
1412
|
-
const isDate =
|
|
1413
|
-
const isTime =
|
|
1414
|
-
const isDuration =
|
|
1455
|
+
const isUUID = TypeBoxFormat.IsUuid;
|
|
1456
|
+
const isEmail = TypeBoxFormat.IsEmail;
|
|
1457
|
+
const isURL = TypeBoxFormat.IsUrl;
|
|
1458
|
+
const isDateTime = TypeBoxFormat.IsDateTime;
|
|
1459
|
+
const isDate = TypeBoxFormat.IsDate;
|
|
1460
|
+
const isTime = TypeBoxFormat.IsTime;
|
|
1461
|
+
const isDuration = TypeBoxFormat.IsDuration;
|
|
1415
1462
|
var TypeGuard = class {
|
|
1416
|
-
isBigInt = (value) =>
|
|
1417
|
-
isUUID = (value) =>
|
|
1418
|
-
isObject =
|
|
1419
|
-
isNumber =
|
|
1420
|
-
isString =
|
|
1421
|
-
isBoolean =
|
|
1422
|
-
isAny =
|
|
1423
|
-
isArray =
|
|
1424
|
-
isOptional =
|
|
1425
|
-
isUnion =
|
|
1426
|
-
isInteger =
|
|
1427
|
-
isNull =
|
|
1428
|
-
isUndefined =
|
|
1429
|
-
isUnsafe =
|
|
1430
|
-
isRecord =
|
|
1431
|
-
isTuple =
|
|
1432
|
-
isVoid =
|
|
1433
|
-
isLiteral =
|
|
1434
|
-
isSchema =
|
|
1463
|
+
isBigInt = (value) => TypeBox.IsString(value) && "format" in value && value.format === "bigint";
|
|
1464
|
+
isUUID = (value) => TypeBox.IsString(value) && "format" in value && value.format === "uuid";
|
|
1465
|
+
isObject = TypeBox.IsObject;
|
|
1466
|
+
isNumber = TypeBox.IsNumber;
|
|
1467
|
+
isString = TypeBox.IsString;
|
|
1468
|
+
isBoolean = TypeBox.IsBoolean;
|
|
1469
|
+
isAny = TypeBox.IsAny;
|
|
1470
|
+
isArray = TypeBox.IsArray;
|
|
1471
|
+
isOptional = TypeBox.IsOptional;
|
|
1472
|
+
isUnion = TypeBox.IsUnion;
|
|
1473
|
+
isInteger = TypeBox.IsInteger;
|
|
1474
|
+
isNull = TypeBox.IsNull;
|
|
1475
|
+
isUndefined = TypeBox.IsUndefined;
|
|
1476
|
+
isUnsafe = TypeBox.IsUnsafe;
|
|
1477
|
+
isRecord = TypeBox.IsRecord;
|
|
1478
|
+
isTuple = TypeBox.IsTuple;
|
|
1479
|
+
isVoid = TypeBox.IsVoid;
|
|
1480
|
+
isLiteral = TypeBox.IsLiteral;
|
|
1481
|
+
isSchema = TypeBox.IsSchema;
|
|
1435
1482
|
isFile = isTypeFile;
|
|
1436
1483
|
isDateTime = (schema) => {
|
|
1437
1484
|
return t.schema.isString(schema) && schema.format === "date-time";
|
|
@@ -1447,23 +1494,23 @@ var TypeGuard = class {
|
|
|
1447
1494
|
};
|
|
1448
1495
|
};
|
|
1449
1496
|
var TypeProvider = class TypeProvider {
|
|
1450
|
-
static format =
|
|
1497
|
+
static format = TypeBoxFormat;
|
|
1451
1498
|
static {
|
|
1452
|
-
|
|
1499
|
+
TypeBoxFormat.Set("bigint", (value) => TypeProvider.isValidBigInt(value));
|
|
1453
1500
|
}
|
|
1454
1501
|
static translateError(error, locale) {
|
|
1455
1502
|
if (!locale) return error.cause.message;
|
|
1456
|
-
for (const [key, value] of Object.entries(
|
|
1503
|
+
for (const [key, value] of Object.entries(Locale)) {
|
|
1457
1504
|
if (key === "Set" || key === "Get" || key === "Reset") continue;
|
|
1458
1505
|
if (key === locale || key.startsWith(`${locale}_`)) return value(error.cause);
|
|
1459
1506
|
}
|
|
1460
1507
|
return error.cause.message;
|
|
1461
1508
|
}
|
|
1462
1509
|
static setLocale(locale) {
|
|
1463
|
-
for (const [key, value] of Object.entries(
|
|
1510
|
+
for (const [key, value] of Object.entries(Locale)) {
|
|
1464
1511
|
if (key === "Set" || key === "Get" || key === "Reset") continue;
|
|
1465
1512
|
if (key === locale || key.startsWith(`${locale}_`)) {
|
|
1466
|
-
|
|
1513
|
+
Locale.Set(value);
|
|
1467
1514
|
return;
|
|
1468
1515
|
}
|
|
1469
1516
|
}
|
|
@@ -1523,16 +1570,16 @@ var TypeProvider = class TypeProvider {
|
|
|
1523
1570
|
* It can be overridden in the array options.
|
|
1524
1571
|
*/
|
|
1525
1572
|
static DEFAULT_ARRAY_MAX_ITEMS = 1e3;
|
|
1526
|
-
raw =
|
|
1527
|
-
any =
|
|
1528
|
-
void =
|
|
1529
|
-
undefined =
|
|
1530
|
-
record =
|
|
1531
|
-
union =
|
|
1532
|
-
tuple =
|
|
1533
|
-
null =
|
|
1534
|
-
const =
|
|
1535
|
-
options =
|
|
1573
|
+
raw = Type;
|
|
1574
|
+
any = Type.Any;
|
|
1575
|
+
void = Type.Void;
|
|
1576
|
+
undefined = Type.Undefined;
|
|
1577
|
+
record = Type.Record;
|
|
1578
|
+
union = Type.Union;
|
|
1579
|
+
tuple = Type.Tuple;
|
|
1580
|
+
null = Type.Null;
|
|
1581
|
+
const = Type.Literal;
|
|
1582
|
+
options = Type.Options;
|
|
1536
1583
|
/**
|
|
1537
1584
|
* Type guards to check the type of schema.
|
|
1538
1585
|
* This is not a runtime type check, but a compile-time type guard.
|
|
@@ -1546,25 +1593,25 @@ var TypeProvider = class TypeProvider {
|
|
|
1546
1593
|
*/
|
|
1547
1594
|
schema = new TypeGuard();
|
|
1548
1595
|
extend(schema, properties, options) {
|
|
1549
|
-
return
|
|
1596
|
+
return Type.Interface(Array.isArray(schema) ? schema : [schema], properties, {
|
|
1550
1597
|
additionalProperties: false,
|
|
1551
1598
|
...options
|
|
1552
1599
|
});
|
|
1553
1600
|
}
|
|
1554
1601
|
pick(schema, keys, options) {
|
|
1555
|
-
return
|
|
1602
|
+
return Type.Pick(schema, keys, {
|
|
1556
1603
|
additionalProperties: false,
|
|
1557
1604
|
...options
|
|
1558
1605
|
});
|
|
1559
1606
|
}
|
|
1560
1607
|
omit(schema, keys, options) {
|
|
1561
|
-
return
|
|
1608
|
+
return Type.Omit(schema, keys, {
|
|
1562
1609
|
additionalProperties: false,
|
|
1563
1610
|
...options
|
|
1564
1611
|
});
|
|
1565
1612
|
}
|
|
1566
1613
|
partial(schema, options) {
|
|
1567
|
-
return
|
|
1614
|
+
return Type.Partial(schema, {
|
|
1568
1615
|
additionalProperties: false,
|
|
1569
1616
|
...options
|
|
1570
1617
|
});
|
|
@@ -1582,7 +1629,7 @@ var TypeProvider = class TypeProvider {
|
|
|
1582
1629
|
* ```
|
|
1583
1630
|
*/
|
|
1584
1631
|
object(properties, options) {
|
|
1585
|
-
return
|
|
1632
|
+
return Type.Object(properties, {
|
|
1586
1633
|
additionalProperties: false,
|
|
1587
1634
|
...options
|
|
1588
1635
|
});
|
|
@@ -1594,7 +1641,7 @@ var TypeProvider = class TypeProvider {
|
|
|
1594
1641
|
* @see TypeProvider.DEFAULT_ARRAY_MAX_ITEMS
|
|
1595
1642
|
*/
|
|
1596
1643
|
array(schema, options) {
|
|
1597
|
-
return
|
|
1644
|
+
return Type.Array(schema, {
|
|
1598
1645
|
maxItems: TypeProvider.DEFAULT_ARRAY_MAX_ITEMS,
|
|
1599
1646
|
...options
|
|
1600
1647
|
});
|
|
@@ -1606,7 +1653,7 @@ var TypeProvider = class TypeProvider {
|
|
|
1606
1653
|
* If you need a string with specific format (e.g. email, uuid), consider using the corresponding method (e.g. `t.email()`, `t.uuid()`).
|
|
1607
1654
|
*/
|
|
1608
1655
|
string(options = {}) {
|
|
1609
|
-
return
|
|
1656
|
+
return Type.String({ ...options });
|
|
1610
1657
|
}
|
|
1611
1658
|
/**
|
|
1612
1659
|
* Create a schema for a string with length limits.
|
|
@@ -1617,7 +1664,7 @@ var TypeProvider = class TypeProvider {
|
|
|
1617
1664
|
text(options = {}) {
|
|
1618
1665
|
const { size, ...rest } = options;
|
|
1619
1666
|
const maxLength = size === "short" ? TypeProvider.DEFAULT_SHORT_STRING_MAX_LENGTH : size === "long" ? TypeProvider.DEFAULT_LONG_STRING_MAX_LENGTH : size === "rich" ? TypeProvider.DEFAULT_RICH_STRING_MAX_LENGTH : TypeProvider.DEFAULT_STRING_MAX_LENGTH;
|
|
1620
|
-
return
|
|
1667
|
+
return Type.String({
|
|
1621
1668
|
maxLength,
|
|
1622
1669
|
"~options": {
|
|
1623
1670
|
trim: options.trim ?? true,
|
|
@@ -1637,22 +1684,22 @@ var TypeProvider = class TypeProvider {
|
|
|
1637
1684
|
* Create a schema for a boolean.
|
|
1638
1685
|
*/
|
|
1639
1686
|
boolean(options) {
|
|
1640
|
-
return
|
|
1687
|
+
return Type.Boolean({ ...options });
|
|
1641
1688
|
}
|
|
1642
1689
|
/**
|
|
1643
1690
|
* Create a schema for a number.
|
|
1644
1691
|
*/
|
|
1645
1692
|
number(options) {
|
|
1646
|
-
return
|
|
1693
|
+
return Type.Number({ ...options });
|
|
1647
1694
|
}
|
|
1648
1695
|
/**
|
|
1649
1696
|
* Create a schema for an integer.
|
|
1650
1697
|
*/
|
|
1651
1698
|
integer(options) {
|
|
1652
|
-
return
|
|
1699
|
+
return Type.Integer({ ...options });
|
|
1653
1700
|
}
|
|
1654
1701
|
int32(options) {
|
|
1655
|
-
return
|
|
1702
|
+
return Type.Integer({
|
|
1656
1703
|
minimum: -2147483647,
|
|
1657
1704
|
maximum: 2147483647,
|
|
1658
1705
|
...options
|
|
@@ -1666,7 +1713,7 @@ var TypeProvider = class TypeProvider {
|
|
|
1666
1713
|
* Use `t.bigint()` for true int64 values represented as strings.
|
|
1667
1714
|
*/
|
|
1668
1715
|
int64(options) {
|
|
1669
|
-
return
|
|
1716
|
+
return Type.Number({
|
|
1670
1717
|
format: "int64",
|
|
1671
1718
|
multipleOf: 1,
|
|
1672
1719
|
minimum: -9007199254740991,
|
|
@@ -1678,23 +1725,23 @@ var TypeProvider = class TypeProvider {
|
|
|
1678
1725
|
* Make a schema optional.
|
|
1679
1726
|
*/
|
|
1680
1727
|
optional(schema) {
|
|
1681
|
-
return
|
|
1728
|
+
return Type.Optional(schema);
|
|
1682
1729
|
}
|
|
1683
1730
|
/**
|
|
1684
1731
|
* Make a schema nullable.
|
|
1685
1732
|
*/
|
|
1686
1733
|
nullable(schema, options) {
|
|
1687
|
-
return
|
|
1734
|
+
return Type.Union([Type.Null(), schema], options);
|
|
1688
1735
|
}
|
|
1689
1736
|
/**
|
|
1690
1737
|
* Create a schema that maps all properties of an object schema to nullable.
|
|
1691
1738
|
*/
|
|
1692
|
-
nullify = (schema, options) =>
|
|
1739
|
+
nullify = (schema, options) => Type.Mapped(Type.Identifier("K"), Type.KeyOf(schema), Type.Ref("K"), Type.Union([Type.Index(schema, Type.Ref("K")), Type.Null()]), options);
|
|
1693
1740
|
/**
|
|
1694
1741
|
* Create a schema for a string enum.
|
|
1695
1742
|
*/
|
|
1696
1743
|
enum(values, options) {
|
|
1697
|
-
return
|
|
1744
|
+
return Type.Unsafe(t.text({
|
|
1698
1745
|
enum: values,
|
|
1699
1746
|
pattern: values.map((v) => `^${v}$`).join("|"),
|
|
1700
1747
|
...options
|
|
@@ -1745,7 +1792,7 @@ var TypeProvider = class TypeProvider {
|
|
|
1745
1792
|
* Implementation of file-like objects is handled by "alepha/file" package.
|
|
1746
1793
|
*/
|
|
1747
1794
|
file(options) {
|
|
1748
|
-
return
|
|
1795
|
+
return Type.Unsafe(Type.Any({
|
|
1749
1796
|
[OPTIONS]: options,
|
|
1750
1797
|
format: "binary"
|
|
1751
1798
|
}));
|
|
@@ -1754,7 +1801,7 @@ var TypeProvider = class TypeProvider {
|
|
|
1754
1801
|
* @experimental
|
|
1755
1802
|
*/
|
|
1756
1803
|
stream() {
|
|
1757
|
-
return
|
|
1804
|
+
return Type.Unsafe(Type.Any({
|
|
1758
1805
|
format: "stream",
|
|
1759
1806
|
type: "string"
|
|
1760
1807
|
}));
|
|
@@ -1849,7 +1896,7 @@ var TypeProvider = class TypeProvider {
|
|
|
1849
1896
|
const t = new TypeProvider();
|
|
1850
1897
|
|
|
1851
1898
|
//#endregion
|
|
1852
|
-
//#region src/core/
|
|
1899
|
+
//#region src/core/primitives/$env.ts
|
|
1853
1900
|
/**
|
|
1854
1901
|
* Get typed values from environment variables.
|
|
1855
1902
|
*
|
|
@@ -1883,7 +1930,7 @@ const $env = (type) => {
|
|
|
1883
1930
|
};
|
|
1884
1931
|
|
|
1885
1932
|
//#endregion
|
|
1886
|
-
//#region src/core/
|
|
1933
|
+
//#region src/core/primitives/$hook.ts
|
|
1887
1934
|
/**
|
|
1888
1935
|
* Registers a new hook.
|
|
1889
1936
|
*
|
|
@@ -1923,8 +1970,8 @@ const $env = (type) => {
|
|
|
1923
1970
|
* ```
|
|
1924
1971
|
*
|
|
1925
1972
|
*/
|
|
1926
|
-
const $hook = (options) =>
|
|
1927
|
-
var
|
|
1973
|
+
const $hook = (options) => createPrimitive(HookPrimitive, options);
|
|
1974
|
+
var HookPrimitive = class extends Primitive {
|
|
1928
1975
|
called = 0;
|
|
1929
1976
|
onInit() {
|
|
1930
1977
|
this.alepha.events.on(this.options.on, {
|
|
@@ -1937,10 +1984,10 @@ var HookDescriptor = class extends Descriptor {
|
|
|
1937
1984
|
});
|
|
1938
1985
|
}
|
|
1939
1986
|
};
|
|
1940
|
-
$hook[KIND] =
|
|
1987
|
+
$hook[KIND] = HookPrimitive;
|
|
1941
1988
|
|
|
1942
1989
|
//#endregion
|
|
1943
|
-
//#region src/core/
|
|
1990
|
+
//#region src/core/primitives/$use.ts
|
|
1944
1991
|
/**
|
|
1945
1992
|
* Subscribes to an atom's state and returns its current value for use in components.
|
|
1946
1993
|
*
|
|
@@ -1965,94 +2012,14 @@ $hook[KIND] = HookDescriptor;
|
|
|
1965
2012
|
*/
|
|
1966
2013
|
const $use = (atom) => {
|
|
1967
2014
|
const { alepha } = $context();
|
|
1968
|
-
alepha.
|
|
1969
|
-
const init = alepha.
|
|
2015
|
+
alepha.store.register(atom);
|
|
2016
|
+
const init = alepha.store.get(atom.key);
|
|
1970
2017
|
return {
|
|
1971
2018
|
[OPTIONS]: { getter: atom.key },
|
|
1972
2019
|
...init
|
|
1973
2020
|
};
|
|
1974
2021
|
};
|
|
1975
2022
|
|
|
1976
|
-
//#endregion
|
|
1977
|
-
//#region src/core/errors/AppNotStartedError.ts
|
|
1978
|
-
var AppNotStartedError = class extends AlephaError {
|
|
1979
|
-
name = "AppNotStartedError";
|
|
1980
|
-
constructor() {
|
|
1981
|
-
super("App not started. Please start the app before.");
|
|
1982
|
-
}
|
|
1983
|
-
};
|
|
1984
|
-
|
|
1985
|
-
//#endregion
|
|
1986
|
-
//#region src/core/helpers/createPagination.ts
|
|
1987
|
-
/**
|
|
1988
|
-
* Create a pagination object from an array of entities.
|
|
1989
|
-
*
|
|
1990
|
-
* This is a pure function that works with any data source (databases, APIs, caches, arrays, etc.).
|
|
1991
|
-
* It handles the core pagination logic including:
|
|
1992
|
-
* - Slicing the content to the requested page size
|
|
1993
|
-
* - Calculating pagination metadata (offset, page number, etc.)
|
|
1994
|
-
* - Determining navigation state (isFirst, isLast)
|
|
1995
|
-
* - Including sort metadata when provided
|
|
1996
|
-
*
|
|
1997
|
-
* @param entities - The entities to paginate (should include one extra item to detect if there's a next page)
|
|
1998
|
-
* @param limit - The limit of the pagination (page size)
|
|
1999
|
-
* @param offset - The offset of the pagination (starting position)
|
|
2000
|
-
* @param sort - Optional sort metadata to include in response
|
|
2001
|
-
* @returns A complete Page object with content and metadata
|
|
2002
|
-
*
|
|
2003
|
-
* @example Basic pagination
|
|
2004
|
-
* ```ts
|
|
2005
|
-
* const users = await fetchUsers({ limit: 11, offset: 0 }); // Fetch limit + 1
|
|
2006
|
-
* const page = createPagination(users, 10, 0);
|
|
2007
|
-
* // page.content has max 10 items
|
|
2008
|
-
* // page.page.isLast tells us if there are more pages
|
|
2009
|
-
* ```
|
|
2010
|
-
*
|
|
2011
|
-
* @example With sorting
|
|
2012
|
-
* ```ts
|
|
2013
|
-
* const page = createPagination(
|
|
2014
|
-
* entities,
|
|
2015
|
-
* 10,
|
|
2016
|
-
* 0,
|
|
2017
|
-
* [{ column: "name", direction: "asc" }]
|
|
2018
|
-
* );
|
|
2019
|
-
* ```
|
|
2020
|
-
*
|
|
2021
|
-
* @example In a custom service
|
|
2022
|
-
* ```ts
|
|
2023
|
-
* class MyService {
|
|
2024
|
-
* async listItems(page: number, size: number) {
|
|
2025
|
-
* const items = await this.fetchItems({ limit: size + 1, offset: page * size });
|
|
2026
|
-
* return createPagination(items, size, page * size);
|
|
2027
|
-
* }
|
|
2028
|
-
* }
|
|
2029
|
-
* ```
|
|
2030
|
-
*/
|
|
2031
|
-
function createPagination(entities, limit = 10, offset = 0, sort) {
|
|
2032
|
-
const content = entities.slice(0, limit);
|
|
2033
|
-
const hasNext = entities.length === limit + 1;
|
|
2034
|
-
const pageNumber = Math.floor(offset / limit);
|
|
2035
|
-
return {
|
|
2036
|
-
content,
|
|
2037
|
-
page: {
|
|
2038
|
-
number: pageNumber,
|
|
2039
|
-
size: limit,
|
|
2040
|
-
offset,
|
|
2041
|
-
numberOfElements: content.length,
|
|
2042
|
-
isEmpty: content.length === 0,
|
|
2043
|
-
isFirst: pageNumber === 0,
|
|
2044
|
-
isLast: !hasNext,
|
|
2045
|
-
...sort && sort.length > 0 ? { sort: {
|
|
2046
|
-
sorted: true,
|
|
2047
|
-
fields: sort.map((s) => ({
|
|
2048
|
-
field: s.column,
|
|
2049
|
-
direction: s.direction
|
|
2050
|
-
}))
|
|
2051
|
-
} } : {}
|
|
2052
|
-
}
|
|
2053
|
-
};
|
|
2054
|
-
}
|
|
2055
|
-
|
|
2056
2023
|
//#endregion
|
|
2057
2024
|
//#region src/core/schemas/pageQuerySchema.ts
|
|
2058
2025
|
const pageQuerySchema = t.object({
|
|
@@ -2119,146 +2086,28 @@ const pageSchema = (objectSchema, options) => t.object({
|
|
|
2119
2086
|
TypeProvider.prototype.page = (itemSchema) => pageSchema(itemSchema);
|
|
2120
2087
|
|
|
2121
2088
|
//#endregion
|
|
2122
|
-
//#region src/core/index.ts
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
* ```
|
|
2136
|
-
*/
|
|
2089
|
+
//#region src/core/index.native.ts
|
|
2090
|
+
if (!Promise.withResolvers) Promise.withResolvers = () => {
|
|
2091
|
+
let resolve;
|
|
2092
|
+
let reject;
|
|
2093
|
+
return {
|
|
2094
|
+
promise: new Promise((res, rej) => {
|
|
2095
|
+
resolve = res;
|
|
2096
|
+
reject = rej;
|
|
2097
|
+
}),
|
|
2098
|
+
resolve,
|
|
2099
|
+
reject
|
|
2100
|
+
};
|
|
2101
|
+
};
|
|
2137
2102
|
const run = (entry, opts) => {
|
|
2138
|
-
const
|
|
2139
|
-
const alepha = entry instanceof Alepha ? entry : Alepha.create({ env: {
|
|
2140
|
-
...env,
|
|
2141
|
-
...opts?.env
|
|
2142
|
-
} });
|
|
2103
|
+
const alepha = entry instanceof Alepha ? entry : Alepha.create({ env: { ...opts?.env } });
|
|
2143
2104
|
if (!(entry instanceof Alepha)) {
|
|
2144
2105
|
const entries = Array.isArray(entry) ? entry : [entry];
|
|
2145
2106
|
for (const e of entries) alepha.with(e);
|
|
2146
2107
|
}
|
|
2147
|
-
globalThis.__alepha = alepha;
|
|
2148
|
-
if (env.ALEPHA_CLI_IMPORT) globalThis.__cli_alepha = alepha;
|
|
2149
|
-
if (alepha.isServerless() || alepha.isViteDev() || env.ALEPHA_CLI_IMPORT) return alepha;
|
|
2150
|
-
if (opts?.cluster) {
|
|
2151
|
-
withCluster(entry, opts);
|
|
2152
|
-
return alepha;
|
|
2153
|
-
}
|
|
2154
|
-
(async () => {
|
|
2155
|
-
try {
|
|
2156
|
-
await opts?.configure?.(alepha);
|
|
2157
|
-
await alepha.start();
|
|
2158
|
-
if (opts?.ready) await opts.ready(alepha);
|
|
2159
|
-
if (opts?.once) {
|
|
2160
|
-
await alepha.stop();
|
|
2161
|
-
return alepha;
|
|
2162
|
-
}
|
|
2163
|
-
if (typeof process === "object") for (const trap of [
|
|
2164
|
-
"SIGTERM",
|
|
2165
|
-
"SIGINT",
|
|
2166
|
-
"SIGUSR2",
|
|
2167
|
-
"uncaughtException"
|
|
2168
|
-
]) process.once(trap, async (err) => {
|
|
2169
|
-
if (trap === "uncaughtException") alepha.log?.error("Uncaught Exception", err);
|
|
2170
|
-
else alepha.log?.info("Received signal", { trap });
|
|
2171
|
-
try {
|
|
2172
|
-
await alepha.stop();
|
|
2173
|
-
console.log(" ");
|
|
2174
|
-
process.exit(0);
|
|
2175
|
-
} catch (error) {
|
|
2176
|
-
alepha.log?.error("Alepha failed to stop", error);
|
|
2177
|
-
process.exit(1);
|
|
2178
|
-
}
|
|
2179
|
-
});
|
|
2180
|
-
} catch (error) {
|
|
2181
|
-
alepha.log?.error("Alepha failed to start", error);
|
|
2182
|
-
if (typeof process === "object") process.exit(1);
|
|
2183
|
-
}
|
|
2184
|
-
})();
|
|
2185
2108
|
return alepha;
|
|
2186
2109
|
};
|
|
2187
|
-
AlsProvider.create = () => new node_async_hooks.AsyncLocalStorage();
|
|
2188
|
-
/**
|
|
2189
|
-
* Run Alepha in cluster mode, forking workers based on the number of CPU cores.
|
|
2190
|
-
*/
|
|
2191
|
-
const withCluster = (entry, opts) => {
|
|
2192
|
-
const numCPUs = (0, node_os.cpus)().length;
|
|
2193
|
-
if (node_cluster.default.isPrimary) for (let i = 0; i < numCPUs; i++) node_cluster.default.fork();
|
|
2194
|
-
else run(entry, {
|
|
2195
|
-
...opts,
|
|
2196
|
-
env: {
|
|
2197
|
-
...opts?.env,
|
|
2198
|
-
APP_NAME: `${opts?.env?.APP_NAME || "P"}-${node_cluster.default.worker?.id}`
|
|
2199
|
-
},
|
|
2200
|
-
cluster: false
|
|
2201
|
-
});
|
|
2202
|
-
};
|
|
2203
2110
|
|
|
2204
2111
|
//#endregion
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
exports.$env = $env;
|
|
2208
|
-
exports.$hook = $hook;
|
|
2209
|
-
exports.$inject = $inject;
|
|
2210
|
-
exports.$module = $module;
|
|
2211
|
-
exports.$use = $use;
|
|
2212
|
-
exports.Alepha = Alepha;
|
|
2213
|
-
exports.AlephaError = AlephaError;
|
|
2214
|
-
exports.AlsProvider = AlsProvider;
|
|
2215
|
-
exports.AppNotStartedError = AppNotStartedError;
|
|
2216
|
-
exports.Atom = Atom;
|
|
2217
|
-
exports.CircularDependencyError = CircularDependencyError;
|
|
2218
|
-
exports.CodecManager = CodecManager;
|
|
2219
|
-
exports.ContainerLockedError = ContainerLockedError;
|
|
2220
|
-
exports.Descriptor = Descriptor;
|
|
2221
|
-
exports.EventManager = EventManager;
|
|
2222
|
-
exports.HookDescriptor = HookDescriptor;
|
|
2223
|
-
exports.InjectDescriptor = InjectDescriptor;
|
|
2224
|
-
exports.JsonSchemaCodec = JsonSchemaCodec;
|
|
2225
|
-
exports.KIND = KIND;
|
|
2226
|
-
exports.Module = Module;
|
|
2227
|
-
exports.OPTIONS = OPTIONS;
|
|
2228
|
-
exports.SchemaCodec = SchemaCodec;
|
|
2229
|
-
exports.StateManager = StateManager;
|
|
2230
|
-
exports.TooLateSubstitutionError = TooLateSubstitutionError;
|
|
2231
|
-
Object.defineProperty(exports, 'TypeBox', {
|
|
2232
|
-
enumerable: true,
|
|
2233
|
-
get: function () {
|
|
2234
|
-
return typebox;
|
|
2235
|
-
}
|
|
2236
|
-
});
|
|
2237
|
-
exports.TypeBoxError = TypeBoxError;
|
|
2238
|
-
exports.TypeBoxFormat = typebox_format.default;
|
|
2239
|
-
Object.defineProperty(exports, 'TypeBoxValue', {
|
|
2240
|
-
enumerable: true,
|
|
2241
|
-
get: function () {
|
|
2242
|
-
return typebox_value;
|
|
2243
|
-
}
|
|
2244
|
-
});
|
|
2245
|
-
exports.TypeGuard = TypeGuard;
|
|
2246
|
-
exports.TypeProvider = TypeProvider;
|
|
2247
|
-
exports.createDescriptor = createDescriptor;
|
|
2248
|
-
exports.createPagination = createPagination;
|
|
2249
|
-
exports.isClass = isClass;
|
|
2250
|
-
exports.isDate = isDate;
|
|
2251
|
-
exports.isDateTime = isDateTime;
|
|
2252
|
-
exports.isDuration = isDuration;
|
|
2253
|
-
exports.isEmail = isEmail;
|
|
2254
|
-
exports.isFileLike = isFileLike;
|
|
2255
|
-
exports.isTime = isTime;
|
|
2256
|
-
exports.isTypeFile = isTypeFile;
|
|
2257
|
-
exports.isURL = isURL;
|
|
2258
|
-
exports.isUUID = isUUID;
|
|
2259
|
-
exports.pageMetadataSchema = pageMetadataSchema;
|
|
2260
|
-
exports.pageQuerySchema = pageQuerySchema;
|
|
2261
|
-
exports.pageSchema = pageSchema;
|
|
2262
|
-
exports.run = run;
|
|
2263
|
-
exports.t = t;
|
|
2264
|
-
//# sourceMappingURL=index.cjs.map
|
|
2112
|
+
export { $atom, $context, $env, $hook, $inject, $module, $use, Alepha, AlephaError, AlsProvider, AppNotStartedError, Atom, CircularDependencyError, CodecManager, ContainerLockedError, EventManager, HookPrimitive, InjectPrimitive, JsonSchemaCodec, KIND, Module, OPTIONS, Primitive, SchemaCodec, StateManager, TooLateSubstitutionError, TypeBox, TypeBoxError, TypeBoxFormat, TypeBoxValue, TypeGuard, TypeProvider, createPagination, createPrimitive, isClass, isDate, isDateTime, isDuration, isEmail, isFileLike, isTime, isTypeFile, isURL, isUUID, pageMetadataSchema, pageQuerySchema, pageSchema, run, t };
|
|
2113
|
+
//# sourceMappingURL=index.native.js.map
|