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
package/dist/command/index.cjs
DELETED
|
@@ -1,693 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
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 alepha = require("alepha");
|
|
29
|
-
let node_process = require("node:process");
|
|
30
|
-
let node_readline_promises = require("node:readline/promises");
|
|
31
|
-
let alepha_logger = require("alepha/logger");
|
|
32
|
-
let alepha_datetime = require("alepha/datetime");
|
|
33
|
-
let node_child_process = require("node:child_process");
|
|
34
|
-
let node_fs_promises = require("node:fs/promises");
|
|
35
|
-
node_fs_promises = __toESM(node_fs_promises);
|
|
36
|
-
|
|
37
|
-
//#region src/command/descriptors/$command.ts
|
|
38
|
-
/**
|
|
39
|
-
* Declares a CLI command.
|
|
40
|
-
*
|
|
41
|
-
* This descriptor allows you to define a command, its flags, and its handler
|
|
42
|
-
* within your Alepha application structure.
|
|
43
|
-
*/
|
|
44
|
-
const $command = (options) => (0, alepha.createDescriptor)(CommandDescriptor, options);
|
|
45
|
-
var CommandDescriptor = class extends alepha.Descriptor {
|
|
46
|
-
flags = this.options.flags ?? alepha.t.object({});
|
|
47
|
-
aliases = this.options.aliases ?? [];
|
|
48
|
-
get name() {
|
|
49
|
-
if (this.options.root) return "";
|
|
50
|
-
return this.options.name ?? `${this.config.propertyKey}`;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
$command[alepha.KIND] = CommandDescriptor;
|
|
54
|
-
|
|
55
|
-
//#endregion
|
|
56
|
-
//#region src/command/helpers/Asker.ts
|
|
57
|
-
var Asker = class {
|
|
58
|
-
log = (0, alepha_logger.$logger)();
|
|
59
|
-
ask;
|
|
60
|
-
alepha = (0, alepha.$inject)(alepha.Alepha);
|
|
61
|
-
constructor() {
|
|
62
|
-
this.ask = this.createAskMethod();
|
|
63
|
-
}
|
|
64
|
-
createAskMethod() {
|
|
65
|
-
const askFn = async (question, options = {}) => {
|
|
66
|
-
return await this.prompt(question, options);
|
|
67
|
-
};
|
|
68
|
-
return askFn;
|
|
69
|
-
}
|
|
70
|
-
async prompt(question, options) {
|
|
71
|
-
const rl = this.createPromptInterface();
|
|
72
|
-
let value;
|
|
73
|
-
try {
|
|
74
|
-
do
|
|
75
|
-
try {
|
|
76
|
-
const answer = await rl.question(`${question}\n> `);
|
|
77
|
-
if (options.schema) value = this.alepha.codec.decode(options.schema, answer ? answer.trim() : void 0);
|
|
78
|
-
else value = String(answer.trim());
|
|
79
|
-
if (options.validate) options.validate(value);
|
|
80
|
-
} catch (error) {
|
|
81
|
-
if (error instanceof alepha.AlephaError) {
|
|
82
|
-
this.log.error(`${error.message}\n`);
|
|
83
|
-
value = void 0;
|
|
84
|
-
} else throw error;
|
|
85
|
-
}
|
|
86
|
-
while (value === void 0);
|
|
87
|
-
} finally {
|
|
88
|
-
rl.close();
|
|
89
|
-
}
|
|
90
|
-
return value;
|
|
91
|
-
}
|
|
92
|
-
createPromptInterface() {
|
|
93
|
-
return (0, node_readline_promises.createInterface)({
|
|
94
|
-
input: node_process.stdin,
|
|
95
|
-
output: node_process.stdout
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region src/command/helpers/PrettyPrint.ts
|
|
102
|
-
var PrettyPrint = class {
|
|
103
|
-
dateTimeProvider = (0, alepha.$inject)(alepha_datetime.DateTimeProvider);
|
|
104
|
-
spinnerInterval;
|
|
105
|
-
frames = [
|
|
106
|
-
"⠋",
|
|
107
|
-
"⠙",
|
|
108
|
-
"⠹",
|
|
109
|
-
"⠸",
|
|
110
|
-
"⠼",
|
|
111
|
-
"⠴",
|
|
112
|
-
"⠦",
|
|
113
|
-
"⠧",
|
|
114
|
-
"⠇",
|
|
115
|
-
"⠏"
|
|
116
|
-
];
|
|
117
|
-
tasks = /* @__PURE__ */ new Map();
|
|
118
|
-
lastLineCount = 0;
|
|
119
|
-
header;
|
|
120
|
-
commandStartTime;
|
|
121
|
-
colors = {
|
|
122
|
-
reset: "\x1B[0m",
|
|
123
|
-
cyan: "\x1B[36m",
|
|
124
|
-
green: "\x1B[32m",
|
|
125
|
-
red: "\x1B[31m",
|
|
126
|
-
dim: "\x1B[2m"
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Start a new command session with header
|
|
130
|
-
*/
|
|
131
|
-
startCommand(cliName, commandName) {
|
|
132
|
-
this.header = commandName ? `${cliName} ${commandName}` : cliName;
|
|
133
|
-
this.commandStartTime = Date.now();
|
|
134
|
-
this.tasks.clear();
|
|
135
|
-
this.lastLineCount = 0;
|
|
136
|
-
process.stdout.write(`┌─ ${this.header}\n`);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* End the command session with footer
|
|
140
|
-
*/
|
|
141
|
-
endCommand() {
|
|
142
|
-
if (this.commandStartTime) {
|
|
143
|
-
const totalDuration = ((Date.now() - this.commandStartTime) / 1e3).toFixed(1);
|
|
144
|
-
process.stdout.write(`└─ Done in ${totalDuration}s\n`);
|
|
145
|
-
}
|
|
146
|
-
this.header = void 0;
|
|
147
|
-
this.commandStartTime = void 0;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Start an animated spinner with a task name
|
|
151
|
-
*/
|
|
152
|
-
startSpinner(id, taskName) {
|
|
153
|
-
this.tasks.set(id, {
|
|
154
|
-
taskName,
|
|
155
|
-
frameIndex: 0,
|
|
156
|
-
status: "running"
|
|
157
|
-
});
|
|
158
|
-
if (!this.spinnerInterval) this.spinnerInterval = this.dateTimeProvider.createInterval(() => this.updateDisplay(), 80, true);
|
|
159
|
-
this.updateDisplay();
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Stop the spinner and show success with a tick
|
|
163
|
-
*/
|
|
164
|
-
success(id, taskName, duration) {
|
|
165
|
-
const task = this.tasks.get(id);
|
|
166
|
-
if (task) {
|
|
167
|
-
task.status = "success";
|
|
168
|
-
if (taskName) task.taskName = taskName;
|
|
169
|
-
if (duration) task.duration = duration;
|
|
170
|
-
this.updateDisplay();
|
|
171
|
-
}
|
|
172
|
-
this.checkIfAllDone();
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Stop the spinner and show error with a cross
|
|
176
|
-
*/
|
|
177
|
-
error(id, taskName) {
|
|
178
|
-
const task = this.tasks.get(id);
|
|
179
|
-
if (task) {
|
|
180
|
-
task.status = "error";
|
|
181
|
-
if (taskName) task.taskName = taskName;
|
|
182
|
-
this.updateDisplay();
|
|
183
|
-
}
|
|
184
|
-
this.checkIfAllDone();
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Update the display for all tasks
|
|
188
|
-
*/
|
|
189
|
-
updateDisplay() {
|
|
190
|
-
if (this.lastLineCount > 0) for (let i = 0; i < this.lastLineCount; i++) process.stdout.write("\x1B[1A\x1B[2K");
|
|
191
|
-
const taskArray = Array.from(this.tasks.values());
|
|
192
|
-
const prefix = this.header ? "│ " : "";
|
|
193
|
-
for (const task of taskArray) {
|
|
194
|
-
let line = prefix;
|
|
195
|
-
if (task.status === "running") {
|
|
196
|
-
const frame = this.frames[task.frameIndex];
|
|
197
|
-
line += `${this.colors.cyan}${frame}${this.colors.reset} ${this.colors.dim}${task.taskName}${this.colors.reset}`;
|
|
198
|
-
task.frameIndex = (task.frameIndex + 1) % this.frames.length;
|
|
199
|
-
} else if (task.status === "success") {
|
|
200
|
-
const durationStr = task.duration ? ` ${this.colors.dim}${task.duration}${this.colors.reset}` : "";
|
|
201
|
-
line += `${this.colors.green}✓${this.colors.reset} ${task.taskName}${durationStr}`;
|
|
202
|
-
} else if (task.status === "error") line += `${this.colors.red}✗${this.colors.reset} ${task.taskName}`;
|
|
203
|
-
process.stdout.write(`${line}\n`);
|
|
204
|
-
}
|
|
205
|
-
this.lastLineCount = taskArray.length;
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Check if all tasks are done and stop the interval
|
|
209
|
-
*/
|
|
210
|
-
checkIfAllDone() {
|
|
211
|
-
if (!Array.from(this.tasks.values()).some((task) => task.status === "running") && this.spinnerInterval) {
|
|
212
|
-
this.dateTimeProvider.clearInterval(this.spinnerInterval);
|
|
213
|
-
this.spinnerInterval = void 0;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Stop the spinner without showing any symbol
|
|
218
|
-
*/
|
|
219
|
-
stopSpinner() {
|
|
220
|
-
if (this.spinnerInterval) {
|
|
221
|
-
this.dateTimeProvider.clearInterval(this.spinnerInterval);
|
|
222
|
-
this.spinnerInterval = void 0;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Clear all tasks
|
|
227
|
-
*/
|
|
228
|
-
clear() {
|
|
229
|
-
this.tasks.clear();
|
|
230
|
-
this.stopSpinner();
|
|
231
|
-
this.lastLineCount = 0;
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region src/command/errors/CommandError.ts
|
|
237
|
-
var CommandError = class extends alepha.AlephaError {
|
|
238
|
-
name = "CommandError";
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
//#endregion
|
|
242
|
-
//#region src/command/helpers/Runner.ts
|
|
243
|
-
var Runner = class {
|
|
244
|
-
log = (0, alepha_logger.$logger)();
|
|
245
|
-
timers = [];
|
|
246
|
-
startTime = Date.now();
|
|
247
|
-
prettyPrint = (0, alepha.$inject)(PrettyPrint);
|
|
248
|
-
alepha = (0, alepha.$inject)(alepha.Alepha);
|
|
249
|
-
run;
|
|
250
|
-
cliName = "";
|
|
251
|
-
commandName = "";
|
|
252
|
-
firstTaskStarted = false;
|
|
253
|
-
constructor() {
|
|
254
|
-
this.run = this.createRunMethod();
|
|
255
|
-
}
|
|
256
|
-
get useDynamicLogger() {
|
|
257
|
-
if (this.alepha.isCI()) return false;
|
|
258
|
-
return this.alepha.env.LOG_FORMAT === "raw";
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Start a new command session with header (for pretty print mode)
|
|
262
|
-
*/
|
|
263
|
-
startCommand(cliName, commandName) {
|
|
264
|
-
this.cliName = cliName;
|
|
265
|
-
this.commandName = commandName;
|
|
266
|
-
}
|
|
267
|
-
createRunMethod() {
|
|
268
|
-
const runFn = async (cmd, options) => {
|
|
269
|
-
if (this.useDynamicLogger && !this.firstTaskStarted) this.prettyPrint.startCommand(this.cliName, this.commandName);
|
|
270
|
-
this.firstTaskStarted = true;
|
|
271
|
-
if (Array.isArray(cmd)) return await this.execute(cmd.map((it) => typeof it === "string" ? {
|
|
272
|
-
name: it,
|
|
273
|
-
handler: () => this.exec(it)
|
|
274
|
-
} : it));
|
|
275
|
-
const name = (typeof options === "object" ? options.alias : void 0) ?? (typeof cmd === "string" ? cmd : cmd.name);
|
|
276
|
-
const handler = typeof options === "function" ? options : typeof cmd === "string" ? () => this.exec(cmd) : cmd.handler;
|
|
277
|
-
return await this.execute({
|
|
278
|
-
name,
|
|
279
|
-
handler
|
|
280
|
-
});
|
|
281
|
-
};
|
|
282
|
-
runFn.rm = async (files, options = {}) => {
|
|
283
|
-
if (Array.isArray(files) || files.includes("*")) return runFn({
|
|
284
|
-
name: options.alias ?? `rm -rf ${Array.isArray(files) ? files.join(" ") : files}`,
|
|
285
|
-
handler: async () => {
|
|
286
|
-
for await (const file of (0, node_fs_promises.glob)(files)) {
|
|
287
|
-
this.log.trace(`Removing ${file}`);
|
|
288
|
-
await (0, node_fs_promises.rm)(file, {
|
|
289
|
-
recursive: true,
|
|
290
|
-
force: true
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
this.log.trace(`Removing ${files}`);
|
|
296
|
-
return runFn({
|
|
297
|
-
name: options.alias ?? `rm -rf ${files}`,
|
|
298
|
-
handler: () => (0, node_fs_promises.rm)(files, {
|
|
299
|
-
recursive: true,
|
|
300
|
-
force: true
|
|
301
|
-
})
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
runFn.cp = async (source, dist, options = {}) => {
|
|
305
|
-
this.log.trace(`Copying ${source} to ${dist}`);
|
|
306
|
-
return runFn({
|
|
307
|
-
name: options.alias ?? `cp -r ${source} ${dist}`,
|
|
308
|
-
handler: () => (0, node_fs_promises.cp)(source, dist, { recursive: true })
|
|
309
|
-
}, options);
|
|
310
|
-
};
|
|
311
|
-
return runFn;
|
|
312
|
-
}
|
|
313
|
-
async exec(cmd) {
|
|
314
|
-
return await new Promise((resolve, reject) => {
|
|
315
|
-
(0, node_child_process.exec)(cmd, { env: {
|
|
316
|
-
...process.env,
|
|
317
|
-
LOG_FORMAT: "pretty"
|
|
318
|
-
} }, (err, stdout) => {
|
|
319
|
-
if (err) {
|
|
320
|
-
err.stdout = stdout;
|
|
321
|
-
reject(err);
|
|
322
|
-
} else resolve(stdout);
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Executes one or more tasks.
|
|
328
|
-
*
|
|
329
|
-
* @param task - A single task or an array of tasks to run in parallel.
|
|
330
|
-
*/
|
|
331
|
-
async execute(task) {
|
|
332
|
-
if (Array.isArray(task)) {
|
|
333
|
-
await Promise.all(task.map((t$2) => this.executeTask(t$2)));
|
|
334
|
-
return "";
|
|
335
|
-
} else return await this.executeTask(task);
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Prints a summary of all executed tasks and their durations.
|
|
339
|
-
*/
|
|
340
|
-
summary() {
|
|
341
|
-
if (this.useDynamicLogger && this.firstTaskStarted) {
|
|
342
|
-
this.prettyPrint.endCommand();
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
if (this.timers.length === 0) return;
|
|
346
|
-
this.log.info("");
|
|
347
|
-
const totalTime = ((Date.now() - this.startTime) / 1e3).toFixed(1);
|
|
348
|
-
this.log.info(`Total time: ${totalTime}s`);
|
|
349
|
-
this.log.info(``);
|
|
350
|
-
}
|
|
351
|
-
async executeTask(task) {
|
|
352
|
-
const now = Date.now();
|
|
353
|
-
const taskId = task.name;
|
|
354
|
-
if (this.useDynamicLogger) this.prettyPrint.startSpinner(taskId, task.name);
|
|
355
|
-
else this.log.info(`Starting '${task.name}' ...`);
|
|
356
|
-
let stdout = "";
|
|
357
|
-
try {
|
|
358
|
-
stdout = String(await task.handler() ?? "");
|
|
359
|
-
} catch (error) {
|
|
360
|
-
if (this.useDynamicLogger) this.prettyPrint.error(taskId, task.name);
|
|
361
|
-
if (error instanceof Error && "stdout" in error) this.log.info(`\n\n${error.stdout}`);
|
|
362
|
-
throw new CommandError(`Task '${task.name}' failed`, { cause: error });
|
|
363
|
-
}
|
|
364
|
-
if (stdout) this.log.trace(stdout);
|
|
365
|
-
const duration = ((Date.now() - now) / 1e3).toFixed(1);
|
|
366
|
-
if (this.useDynamicLogger) this.prettyPrint.success(taskId, task.name, `${duration}s`);
|
|
367
|
-
else this.log.info(`Finished '${task.name}' after ${duration}s`);
|
|
368
|
-
this.timers.push({
|
|
369
|
-
name: task.name,
|
|
370
|
-
duration: `${duration}s`
|
|
371
|
-
});
|
|
372
|
-
return stdout;
|
|
373
|
-
}
|
|
374
|
-
renderTable(data) {
|
|
375
|
-
if (data.length === 0) return;
|
|
376
|
-
const col1Width = Math.max(...data.map(([col1]) => col1.length), 7);
|
|
377
|
-
const col2Width = Math.max(...data.map(([, col2]) => col2.length), 8);
|
|
378
|
-
const divider = `+${"-".repeat(col1Width + 2)}+${"-".repeat(col2Width + 2)}+`;
|
|
379
|
-
this.log.info(divider);
|
|
380
|
-
this.log.info(`| ${"Command".padEnd(col1Width)} | ${"Duration".padEnd(col2Width)} |`);
|
|
381
|
-
this.log.info(divider);
|
|
382
|
-
for (const [col1, col2] of data) this.log.info(`| ${col1.padEnd(col1Width)} | ${col2.padEnd(col2Width)} |`);
|
|
383
|
-
this.log.info(divider);
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
//#endregion
|
|
388
|
-
//#region src/command/providers/CliProvider.ts
|
|
389
|
-
const envSchema = alepha.t.object({
|
|
390
|
-
CLI_NAME: alepha.t.text({
|
|
391
|
-
default: "cli",
|
|
392
|
-
description: "Name of the CLI application."
|
|
393
|
-
}),
|
|
394
|
-
CLI_DESCRIPTION: alepha.t.text({
|
|
395
|
-
default: "",
|
|
396
|
-
description: "Description of the CLI application."
|
|
397
|
-
})
|
|
398
|
-
});
|
|
399
|
-
/**
|
|
400
|
-
* CLI provider configuration atom
|
|
401
|
-
*/
|
|
402
|
-
const cliOptions = (0, alepha.$atom)({
|
|
403
|
-
name: "alepha.command.cli.options",
|
|
404
|
-
schema: alepha.t.object({
|
|
405
|
-
name: alepha.t.optional(alepha.t.string({ description: "Name of the CLI application." })),
|
|
406
|
-
description: alepha.t.optional(alepha.t.string({ description: "Description of the CLI application." })),
|
|
407
|
-
argv: alepha.t.optional(alepha.t.array(alepha.t.string(), { description: "Command line arguments to parse." }))
|
|
408
|
-
}),
|
|
409
|
-
default: {}
|
|
410
|
-
});
|
|
411
|
-
var CliProvider = class {
|
|
412
|
-
env = (0, alepha.$env)(envSchema);
|
|
413
|
-
alepha = (0, alepha.$inject)(alepha.Alepha);
|
|
414
|
-
log = (0, alepha_logger.$logger)();
|
|
415
|
-
runner = (0, alepha.$inject)(Runner);
|
|
416
|
-
asker = (0, alepha.$inject)(Asker);
|
|
417
|
-
options = (0, alepha.$use)(cliOptions);
|
|
418
|
-
get name() {
|
|
419
|
-
return this.options.name || this.env.CLI_NAME;
|
|
420
|
-
}
|
|
421
|
-
get description() {
|
|
422
|
-
return this.options.description || this.env.CLI_DESCRIPTION;
|
|
423
|
-
}
|
|
424
|
-
get argv() {
|
|
425
|
-
return this.options.argv || (typeof process !== "undefined" ? process.argv.slice(2) : []);
|
|
426
|
-
}
|
|
427
|
-
globalFlags = { help: {
|
|
428
|
-
aliases: ["h", "help"],
|
|
429
|
-
description: "Show this help message",
|
|
430
|
-
schema: alepha.t.boolean()
|
|
431
|
-
} };
|
|
432
|
-
onReady = (0, alepha.$hook)({
|
|
433
|
-
on: "ready",
|
|
434
|
-
handler: async () => {
|
|
435
|
-
const argv = [...this.argv];
|
|
436
|
-
const commandName = argv.find((arg) => !arg.startsWith("-")) ?? "";
|
|
437
|
-
let command = this.findCommand(commandName);
|
|
438
|
-
if (this.parseFlags(argv, Object.entries(this.getAllGlobalFlags()).map(([key, value]) => ({
|
|
439
|
-
key,
|
|
440
|
-
...value
|
|
441
|
-
}))).help) {
|
|
442
|
-
this.printHelp(command);
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
if (!command) {
|
|
446
|
-
const rootCommand = this.findCommand("");
|
|
447
|
-
if (rootCommand?.options.args) command = rootCommand;
|
|
448
|
-
else {
|
|
449
|
-
if (commandName !== "") {
|
|
450
|
-
this.log.error(`Unknown command: '${commandName}'`);
|
|
451
|
-
this.printHelp();
|
|
452
|
-
}
|
|
453
|
-
return;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
const commandFlags = this.parseCommandFlags(argv, command.flags);
|
|
457
|
-
const commandArgs = this.parseCommandArgs(argv, command.options.args);
|
|
458
|
-
await this.alepha.context.run(async () => {
|
|
459
|
-
this.log.debug(`Executing command '${command.name}'...`, {
|
|
460
|
-
flags: commandFlags,
|
|
461
|
-
args: commandArgs
|
|
462
|
-
});
|
|
463
|
-
const runner = this.runner;
|
|
464
|
-
runner.startCommand(this.name, command.name);
|
|
465
|
-
const args = {
|
|
466
|
-
flags: commandFlags,
|
|
467
|
-
args: commandArgs,
|
|
468
|
-
run: runner.run,
|
|
469
|
-
ask: this.asker.ask,
|
|
470
|
-
fs: node_fs_promises,
|
|
471
|
-
glob: node_fs_promises.glob,
|
|
472
|
-
root: process.cwd()
|
|
473
|
-
};
|
|
474
|
-
await command.options.handler(args);
|
|
475
|
-
if (command.options.summary !== false) runner.summary();
|
|
476
|
-
this.log.debug(`Command '${command.name}' executed successfully.`);
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
});
|
|
480
|
-
get commands() {
|
|
481
|
-
return this.alepha.descriptors($command);
|
|
482
|
-
}
|
|
483
|
-
findCommand(name) {
|
|
484
|
-
return this.commands.find((command) => command.name === name || command.aliases.includes(name));
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* Get all global flags including those from the root command (name === "")
|
|
488
|
-
*/
|
|
489
|
-
getAllGlobalFlags() {
|
|
490
|
-
const rootCommand = this.commands.find((cmd) => cmd.name === "");
|
|
491
|
-
const allGlobalFlags = { ...this.globalFlags };
|
|
492
|
-
if (rootCommand) for (const [key, value] of Object.entries(rootCommand.flags.properties)) allGlobalFlags[key] = {
|
|
493
|
-
aliases: [key, ...value.aliases ?? (value.alias ? [value.alias] : void 0) ?? []],
|
|
494
|
-
description: value.description,
|
|
495
|
-
schema: value
|
|
496
|
-
};
|
|
497
|
-
return allGlobalFlags;
|
|
498
|
-
}
|
|
499
|
-
parseCommandFlags(argv, schema) {
|
|
500
|
-
const flagDefs = Object.entries(schema.properties).map(([key, value]) => ({
|
|
501
|
-
key,
|
|
502
|
-
aliases: [key, ...value.aliases ?? (value.alias ? [value.alias] : void 0) ?? []],
|
|
503
|
-
description: value.description,
|
|
504
|
-
schema: value
|
|
505
|
-
}));
|
|
506
|
-
const parsed = this.parseFlags(argv, flagDefs);
|
|
507
|
-
for (const [key, value] of Object.entries(schema.properties)) if (!(key in parsed) && alepha.t.schema.isOptional(value)) {
|
|
508
|
-
const innerSchema = value;
|
|
509
|
-
if (innerSchema && "default" in innerSchema) parsed[key] = innerSchema.default;
|
|
510
|
-
}
|
|
511
|
-
try {
|
|
512
|
-
return this.alepha.codec.decode(schema, parsed);
|
|
513
|
-
} catch (error) {
|
|
514
|
-
if (error instanceof alepha.TypeBoxError) throw new CommandError(`Invalid flag: ${error.cause.instancePath || "command"} ${error.cause.message}`);
|
|
515
|
-
throw error;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
parseFlags(argv, flagDefs) {
|
|
519
|
-
const result = {};
|
|
520
|
-
for (const arg of argv.filter((a) => a.startsWith("-"))) {
|
|
521
|
-
const [rawKey, ...valueParts] = arg.replace(/^-{1,2}/, "").split("=");
|
|
522
|
-
const value = valueParts.join("=");
|
|
523
|
-
const def = flagDefs.find((d) => d.aliases.includes(rawKey));
|
|
524
|
-
if (!def) continue;
|
|
525
|
-
if (alepha.t.schema.isBoolean(def.schema)) result[def.key] = true;
|
|
526
|
-
else if (value) try {
|
|
527
|
-
if (alepha.t.schema.isObject(def.schema) || alepha.t.schema.isArray(def.schema)) result[def.key] = JSON.parse(value);
|
|
528
|
-
else result[def.key] = value;
|
|
529
|
-
} catch {
|
|
530
|
-
throw new CommandError(`Invalid JSON value for flag --${rawKey}`);
|
|
531
|
-
}
|
|
532
|
-
else throw new CommandError(`Flag --${rawKey} requires a value.`);
|
|
533
|
-
}
|
|
534
|
-
return result;
|
|
535
|
-
}
|
|
536
|
-
parseCommandArgs(argv, schema) {
|
|
537
|
-
if (!schema) return;
|
|
538
|
-
const argsOnly = argv.filter((arg) => !arg.startsWith("-")).slice(1);
|
|
539
|
-
try {
|
|
540
|
-
if (alepha.t.schema.isOptional(schema)) {
|
|
541
|
-
if (argsOnly.length === 0) return;
|
|
542
|
-
return this.parseArgumentValue(argsOnly[0], schema);
|
|
543
|
-
} else if (alepha.t.schema.isTuple(schema) && schema.items) {
|
|
544
|
-
const result = [];
|
|
545
|
-
const items = schema.items;
|
|
546
|
-
for (let i = 0; i < items.length; i++) {
|
|
547
|
-
const itemSchema = items[i];
|
|
548
|
-
if (i < argsOnly.length) result.push(this.parseArgumentValue(argsOnly[i], itemSchema));
|
|
549
|
-
else if (alepha.t.schema.isOptional(itemSchema)) result.push(void 0);
|
|
550
|
-
else throw new CommandError(`Missing required argument at position ${i + 1}`);
|
|
551
|
-
}
|
|
552
|
-
return result;
|
|
553
|
-
} else {
|
|
554
|
-
if (argsOnly.length === 0) throw new CommandError("Missing required argument");
|
|
555
|
-
return this.parseArgumentValue(argsOnly[0], schema);
|
|
556
|
-
}
|
|
557
|
-
} catch (error) {
|
|
558
|
-
if (error instanceof alepha.TypeBoxError) throw new CommandError(`Invalid argument: ${error.value.message}`);
|
|
559
|
-
throw error;
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
parseArgumentValue(value, schema) {
|
|
563
|
-
if (alepha.t.schema.isString(schema)) return value;
|
|
564
|
-
if (alepha.t.schema.isNumber(schema) || alepha.t.schema.isInteger(schema)) {
|
|
565
|
-
const num = Number(value);
|
|
566
|
-
if (Number.isNaN(num)) throw new CommandError(`Expected number, got "${value}"`);
|
|
567
|
-
if (alepha.t.schema.isInteger(schema) && !Number.isInteger(num)) throw new CommandError(`Expected integer, got "${value}"`);
|
|
568
|
-
return num;
|
|
569
|
-
}
|
|
570
|
-
if (alepha.t.schema.isBoolean(schema)) {
|
|
571
|
-
const lower = value.toLowerCase();
|
|
572
|
-
if (lower === "true" || lower === "1") return true;
|
|
573
|
-
if (lower === "false" || lower === "0") return false;
|
|
574
|
-
throw new CommandError(`Expected boolean, got "${value}"`);
|
|
575
|
-
}
|
|
576
|
-
return value;
|
|
577
|
-
}
|
|
578
|
-
generateArgsUsage(schema) {
|
|
579
|
-
if (!schema) return "";
|
|
580
|
-
if (alepha.t.schema.isOptional(schema)) {
|
|
581
|
-
const typeName$1 = this.getTypeName(schema);
|
|
582
|
-
return ` [${"title" in schema ? schema.title : "arg1"}${typeName$1}]`;
|
|
583
|
-
}
|
|
584
|
-
if (alepha.t.schema.isTuple(schema) && schema.items) return ` ${schema.items.map((item, index) => {
|
|
585
|
-
const argName = `arg${index + 1}`;
|
|
586
|
-
const typeName$1 = this.getTypeName(item);
|
|
587
|
-
if (alepha.t.schema.isOptional(item)) return `[${argName}${typeName$1}]`;
|
|
588
|
-
return `<${argName}${typeName$1}>`;
|
|
589
|
-
}).join(" ")}`;
|
|
590
|
-
const typeName = this.getTypeName(schema);
|
|
591
|
-
return ` <${"title" in schema ? schema.title : "arg1"}${typeName}>`;
|
|
592
|
-
}
|
|
593
|
-
getTypeName(schema) {
|
|
594
|
-
if (!schema) return "";
|
|
595
|
-
if (alepha.t.schema.isString(schema)) return "";
|
|
596
|
-
if (alepha.t.schema.isNumber(schema)) return ": number";
|
|
597
|
-
if (alepha.t.schema.isInteger(schema)) return ": integer";
|
|
598
|
-
if (alepha.t.schema.isBoolean(schema)) return ": boolean";
|
|
599
|
-
return "";
|
|
600
|
-
}
|
|
601
|
-
printHelp(command) {
|
|
602
|
-
const cliName = this.name || "cli";
|
|
603
|
-
this.log.info("");
|
|
604
|
-
if (command?.name) {
|
|
605
|
-
const argsUsage = this.generateArgsUsage(command.options.args);
|
|
606
|
-
const usage = `${cliName} ${command.name}${argsUsage}`.trim();
|
|
607
|
-
this.log.info(`Usage: \`${usage}\``);
|
|
608
|
-
if (command.options.description) {
|
|
609
|
-
this.log.info(``);
|
|
610
|
-
this.log.info(`\t${command.options.description}`);
|
|
611
|
-
}
|
|
612
|
-
this.log.info("");
|
|
613
|
-
this.log.info("Flags:");
|
|
614
|
-
const flags = [...Object.entries(command.flags.properties).map(([key, value]) => ({
|
|
615
|
-
key,
|
|
616
|
-
schema: value,
|
|
617
|
-
aliases: value.alias ?? [key],
|
|
618
|
-
description: value.description
|
|
619
|
-
})), ...Object.entries(this.getAllGlobalFlags()).map(([key, value]) => ({
|
|
620
|
-
key,
|
|
621
|
-
...value
|
|
622
|
-
}))];
|
|
623
|
-
const maxFlagLength = this.getMaxFlagLength(flags);
|
|
624
|
-
for (const { aliases, description } of flags) {
|
|
625
|
-
const flagStr = (Array.isArray(aliases) ? aliases : [aliases]).map((a) => a.length === 1 ? `-${a}` : `--${a}`).join(", ");
|
|
626
|
-
this.log.info(` ${flagStr.padEnd(maxFlagLength)} # ${description ?? ""}`);
|
|
627
|
-
}
|
|
628
|
-
} else {
|
|
629
|
-
this.log.info(this.description || "Available commands:");
|
|
630
|
-
this.log.info("");
|
|
631
|
-
this.log.info("Commands:");
|
|
632
|
-
const maxCmdLength = this.getMaxCmdLength(this.commands);
|
|
633
|
-
for (const command$1 of this.commands) {
|
|
634
|
-
if (command$1.name === "") continue;
|
|
635
|
-
const fullCmdStr = `${[command$1.name, ...command$1.aliases].join(", ")}${this.generateArgsUsage(command$1.options.args)}`;
|
|
636
|
-
this.log.info(` ${cliName} ${fullCmdStr.padEnd(maxCmdLength)} # ${command$1.options.description ?? ""}`);
|
|
637
|
-
}
|
|
638
|
-
this.log.info("");
|
|
639
|
-
this.log.info("Flags:");
|
|
640
|
-
const globalFlags = Object.values(this.getAllGlobalFlags());
|
|
641
|
-
const maxFlagLength = this.getMaxFlagLength(globalFlags);
|
|
642
|
-
for (const { aliases, description } of globalFlags) {
|
|
643
|
-
const flagStr = aliases.map((a) => a.length === 1 ? `-${a}` : `--${a}`).join(", ");
|
|
644
|
-
this.log.info(` ${flagStr.padEnd(maxFlagLength)} # ${description ?? ""}`);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
this.log.info("");
|
|
648
|
-
}
|
|
649
|
-
getMaxCmdLength(commands) {
|
|
650
|
-
return Math.max(...commands.map((c) => {
|
|
651
|
-
return `${[c.name, ...c.aliases].join(", ")}${this.generateArgsUsage(c.options.args)}`.length;
|
|
652
|
-
}));
|
|
653
|
-
}
|
|
654
|
-
getMaxFlagLength(flags) {
|
|
655
|
-
return Math.max(...flags.map((f) => {
|
|
656
|
-
return (Array.isArray(f.aliases) ? f.aliases : [f.aliases]).map((a) => a.length === 1 ? `-${a}` : `--${a}`).join(", ").length;
|
|
657
|
-
}));
|
|
658
|
-
}
|
|
659
|
-
};
|
|
660
|
-
|
|
661
|
-
//#endregion
|
|
662
|
-
//#region src/command/index.ts
|
|
663
|
-
/**
|
|
664
|
-
* This module provides a powerful way to build command-line interfaces
|
|
665
|
-
* directly within your Alepha application, using declarative descriptors.
|
|
666
|
-
*
|
|
667
|
-
* It allows you to define commands using the `$command` descriptor.
|
|
668
|
-
*
|
|
669
|
-
* @see {@link $command}
|
|
670
|
-
* @module alepha.command
|
|
671
|
-
*/
|
|
672
|
-
const AlephaCommand = (0, alepha.$module)({
|
|
673
|
-
name: "alepha.command",
|
|
674
|
-
descriptors: [$command],
|
|
675
|
-
services: [
|
|
676
|
-
CliProvider,
|
|
677
|
-
Runner,
|
|
678
|
-
Asker,
|
|
679
|
-
PrettyPrint
|
|
680
|
-
]
|
|
681
|
-
});
|
|
682
|
-
|
|
683
|
-
//#endregion
|
|
684
|
-
exports.$command = $command;
|
|
685
|
-
exports.AlephaCommand = AlephaCommand;
|
|
686
|
-
exports.Asker = Asker;
|
|
687
|
-
exports.CliProvider = CliProvider;
|
|
688
|
-
exports.CommandDescriptor = CommandDescriptor;
|
|
689
|
-
exports.CommandError = CommandError;
|
|
690
|
-
exports.PrettyPrint = PrettyPrint;
|
|
691
|
-
exports.Runner = Runner;
|
|
692
|
-
exports.cliOptions = cliOptions;
|
|
693
|
-
//# sourceMappingURL=index.cjs.map
|