alepha 0.15.1 → 0.15.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/dist/api/audits/index.d.ts +342 -365
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/audits/index.js +10 -33
- package/dist/api/audits/index.js.map +1 -1
- package/dist/api/files/index.d.ts +180 -173
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js +10 -3
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.d.ts +162 -155
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js +10 -3
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/keys/index.d.ts +413 -0
- package/dist/api/keys/index.d.ts.map +1 -0
- package/dist/api/keys/index.js +476 -0
- package/dist/api/keys/index.js.map +1 -0
- package/dist/api/notifications/index.d.ts +10 -4
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/notifications/index.js +10 -4
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/parameters/index.d.ts +294 -301
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/parameters/index.js +30 -37
- package/dist/api/parameters/index.js.map +1 -1
- package/dist/api/users/index.d.ts +1079 -769
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +2534 -218
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts +10 -4
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/api/verifications/index.js +12 -4
- package/dist/api/verifications/index.js.map +1 -1
- package/dist/batch/index.d.ts +20 -40
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js +31 -44
- package/dist/batch/index.js.map +1 -1
- package/dist/bucket/index.d.ts +432 -8
- package/dist/bucket/index.d.ts.map +1 -1
- package/dist/bucket/index.js +1856 -12
- package/dist/bucket/index.js.map +1 -1
- package/dist/cache/core/index.d.ts +179 -7
- package/dist/cache/core/index.d.ts.map +1 -1
- package/dist/cache/core/index.js +213 -7
- package/dist/cache/core/index.js.map +1 -1
- package/dist/cache/redis/index.d.ts +1 -0
- package/dist/cache/redis/index.d.ts.map +1 -1
- package/dist/cache/redis/index.js +4 -0
- package/dist/cache/redis/index.js.map +1 -1
- package/dist/cli/index.d.ts +488 -5612
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2326 -311
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +194 -46
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +1995 -60
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +42 -19
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +34 -13
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +62 -19
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +42 -19
- package/dist/core/index.native.js.map +1 -1
- package/dist/datetime/index.d.ts +15 -0
- package/dist/datetime/index.d.ts.map +1 -1
- package/dist/datetime/index.js +15 -0
- package/dist/datetime/index.js.map +1 -1
- package/dist/email/index.d.ts +315 -20
- package/dist/email/index.d.ts.map +1 -1
- package/dist/email/index.js +1852 -7
- package/dist/email/index.js.map +1 -1
- package/dist/fake/index.d.ts +90 -8
- package/dist/fake/index.d.ts.map +1 -1
- package/dist/fake/index.js +91 -20
- package/dist/fake/index.js.map +1 -1
- package/dist/lock/core/index.d.ts +11 -4
- package/dist/lock/core/index.d.ts.map +1 -1
- package/dist/lock/core/index.js +11 -4
- package/dist/lock/core/index.js.map +1 -1
- package/dist/logger/index.d.ts +17 -66
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +14 -63
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.d.ts +15 -35
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +12 -35
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/index.browser.js +3 -3
- package/dist/orm/index.browser.js.map +1 -1
- package/dist/orm/index.bun.js +7 -4
- package/dist/orm/index.bun.js.map +1 -1
- package/dist/orm/index.d.ts +514 -540
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +24 -49
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/core/index.d.ts +18 -10
- package/dist/queue/core/index.d.ts.map +1 -1
- package/dist/queue/core/index.js +14 -6
- package/dist/queue/core/index.js.map +1 -1
- package/dist/react/auth/index.browser.js +108 -0
- package/dist/react/auth/index.browser.js.map +1 -0
- package/dist/react/auth/index.d.ts +100 -0
- package/dist/react/auth/index.d.ts.map +1 -0
- package/dist/react/auth/index.js +145 -0
- package/dist/react/auth/index.js.map +1 -0
- package/dist/react/core/index.d.ts +469 -0
- package/dist/react/core/index.d.ts.map +1 -0
- package/dist/react/core/index.js +464 -0
- package/dist/react/core/index.js.map +1 -0
- package/dist/react/form/index.d.ts +232 -0
- package/dist/react/form/index.d.ts.map +1 -0
- package/dist/react/form/index.js +432 -0
- package/dist/react/form/index.js.map +1 -0
- package/dist/react/head/index.browser.js +423 -0
- package/dist/react/head/index.browser.js.map +1 -0
- package/dist/react/head/index.d.ts +288 -0
- package/dist/react/head/index.d.ts.map +1 -0
- package/dist/react/head/index.js +465 -0
- package/dist/react/head/index.js.map +1 -0
- package/dist/react/i18n/index.d.ts +175 -0
- package/dist/react/i18n/index.d.ts.map +1 -0
- package/dist/react/i18n/index.js +224 -0
- package/dist/react/i18n/index.js.map +1 -0
- package/dist/react/router/index.browser.js +1980 -0
- package/dist/react/router/index.browser.js.map +1 -0
- package/dist/react/router/index.d.ts +2068 -0
- package/dist/react/router/index.d.ts.map +1 -0
- package/dist/react/router/index.js +4932 -0
- package/dist/react/router/index.js.map +1 -0
- package/dist/react/websocket/index.d.ts +117 -0
- package/dist/react/websocket/index.d.ts.map +1 -0
- package/dist/react/websocket/index.js +107 -0
- package/dist/react/websocket/index.js.map +1 -0
- package/dist/redis/index.bun.js +4 -0
- package/dist/redis/index.bun.js.map +1 -1
- package/dist/redis/index.d.ts +22 -25
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js +16 -25
- package/dist/redis/index.js.map +1 -1
- package/dist/retry/index.d.ts +11 -2
- package/dist/retry/index.d.ts.map +1 -1
- package/dist/retry/index.js +11 -2
- package/dist/retry/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +11 -2
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js +11 -2
- package/dist/scheduler/index.js.map +1 -1
- package/dist/security/index.d.ts +110 -19
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +157 -26
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +179 -174
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +12 -7
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cache/index.d.ts +7 -22
- package/dist/server/cache/index.d.ts.map +1 -1
- package/dist/server/cache/index.js +7 -22
- package/dist/server/cache/index.js.map +1 -1
- package/dist/server/compress/index.d.ts +10 -2
- package/dist/server/compress/index.d.ts.map +1 -1
- package/dist/server/compress/index.js +10 -2
- package/dist/server/compress/index.js.map +1 -1
- package/dist/server/cookies/index.d.ts +40 -16
- package/dist/server/cookies/index.d.ts.map +1 -1
- package/dist/server/cookies/index.js +7 -5
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/server/core/index.d.ts +115 -14
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +231 -14
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/cors/index.d.ts +13 -23
- package/dist/server/cors/index.d.ts.map +1 -1
- package/dist/server/cors/index.js +7 -21
- package/dist/server/cors/index.js.map +1 -1
- package/dist/server/health/index.d.ts +25 -19
- package/dist/server/health/index.d.ts.map +1 -1
- package/dist/server/health/index.js +8 -2
- package/dist/server/health/index.js.map +1 -1
- package/dist/server/helmet/index.d.ts +11 -3
- package/dist/server/helmet/index.d.ts.map +1 -1
- package/dist/server/helmet/index.js +11 -3
- package/dist/server/helmet/index.js.map +1 -1
- package/dist/server/links/index.d.ts +50 -45
- package/dist/server/links/index.d.ts.map +1 -1
- package/dist/server/links/index.js +11 -6
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/metrics/index.d.ts +10 -3
- package/dist/server/metrics/index.d.ts.map +1 -1
- package/dist/server/metrics/index.js +10 -3
- package/dist/server/metrics/index.js.map +1 -1
- package/dist/server/multipart/index.d.ts +9 -3
- package/dist/server/multipart/index.d.ts.map +1 -1
- package/dist/server/multipart/index.js +9 -3
- package/dist/server/multipart/index.js.map +1 -1
- package/dist/server/proxy/index.d.ts +8 -2
- package/dist/server/proxy/index.d.ts.map +1 -1
- package/dist/server/proxy/index.js +8 -2
- package/dist/server/proxy/index.js.map +1 -1
- package/dist/server/rate-limit/index.d.ts +30 -35
- package/dist/server/rate-limit/index.d.ts.map +1 -1
- package/dist/server/rate-limit/index.js +18 -55
- package/dist/server/rate-limit/index.js.map +1 -1
- package/dist/server/static/index.d.ts +137 -4
- package/dist/server/static/index.d.ts.map +1 -1
- package/dist/server/static/index.js +1848 -5
- package/dist/server/static/index.js.map +1 -1
- package/dist/server/swagger/index.d.ts +301 -6
- package/dist/server/swagger/index.d.ts.map +1 -1
- package/dist/server/swagger/index.js +1849 -6
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/sms/index.d.ts +301 -7
- package/dist/sms/index.d.ts.map +1 -1
- package/dist/sms/index.js +1851 -7
- package/dist/sms/index.js.map +1 -1
- package/dist/system/index.browser.js +496 -0
- package/dist/system/index.browser.js.map +1 -0
- package/dist/{file → system}/index.d.ts +335 -16
- package/dist/system/index.d.ts.map +1 -0
- package/dist/{file → system}/index.js +412 -20
- package/dist/system/index.js.map +1 -0
- package/dist/thread/index.d.ts +11 -2
- package/dist/thread/index.d.ts.map +1 -1
- package/dist/thread/index.js +11 -2
- package/dist/thread/index.js.map +1 -1
- package/dist/topic/core/index.d.ts +12 -5
- package/dist/topic/core/index.d.ts.map +1 -1
- package/dist/topic/core/index.js +12 -5
- package/dist/topic/core/index.js.map +1 -1
- package/dist/vite/index.d.ts +4 -6271
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +8 -3
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.d.ts +12 -8
- package/dist/websocket/index.d.ts.map +1 -1
- package/dist/websocket/index.js +12 -8
- package/dist/websocket/index.js.map +1 -1
- package/package.json +80 -11
- package/src/api/audits/index.ts +10 -33
- package/src/api/files/__tests__/$bucket.spec.ts +1 -1
- package/src/api/files/controllers/AdminFileStatsController.spec.ts +1 -1
- package/src/api/files/controllers/FileController.spec.ts +1 -1
- package/src/api/files/index.ts +10 -3
- package/src/api/files/jobs/FileJobs.spec.ts +1 -1
- package/src/api/files/services/FileService.spec.ts +1 -1
- package/src/api/jobs/index.ts +10 -3
- package/src/api/keys/controllers/AdminApiKeyController.ts +75 -0
- package/src/api/keys/controllers/ApiKeyController.ts +103 -0
- package/src/api/keys/entities/apiKeyEntity.ts +41 -0
- package/src/api/keys/index.ts +49 -0
- package/src/api/keys/schemas/adminApiKeyQuerySchema.ts +7 -0
- package/src/api/keys/schemas/adminApiKeyResourceSchema.ts +17 -0
- package/src/api/keys/schemas/createApiKeyBodySchema.ts +7 -0
- package/src/api/keys/schemas/createApiKeyResponseSchema.ts +11 -0
- package/src/api/keys/schemas/listApiKeyResponseSchema.ts +15 -0
- package/src/api/keys/schemas/revokeApiKeyParamsSchema.ts +5 -0
- package/src/api/keys/schemas/revokeApiKeyResponseSchema.ts +5 -0
- package/src/api/keys/services/ApiKeyService.spec.ts +553 -0
- package/src/api/keys/services/ApiKeyService.ts +306 -0
- package/src/api/logs/TODO.md +52 -0
- package/src/api/notifications/index.ts +10 -4
- package/src/api/parameters/index.ts +9 -30
- package/src/api/parameters/primitives/$config.ts +12 -4
- package/src/api/parameters/services/ConfigStore.ts +9 -3
- package/src/api/users/__tests__/ApiKeys-integration.spec.ts +1035 -0
- package/src/api/users/__tests__/ApiKeys.spec.ts +401 -0
- package/src/api/users/index.ts +14 -3
- package/src/api/users/primitives/$realm.ts +33 -5
- package/src/api/users/providers/RealmProvider.ts +1 -12
- package/src/api/users/services/SessionService.ts +1 -1
- package/src/api/verifications/controllers/VerificationController.ts +2 -0
- package/src/api/verifications/index.ts +10 -4
- package/src/batch/index.ts +9 -36
- package/src/batch/primitives/$batch.ts +0 -8
- package/src/batch/providers/BatchProvider.ts +29 -2
- package/src/bucket/__tests__/shared.ts +1 -1
- package/src/bucket/index.ts +13 -6
- package/src/bucket/primitives/$bucket.ts +1 -1
- package/src/bucket/providers/LocalFileStorageProvider.ts +1 -1
- package/src/bucket/providers/MemoryFileStorageProvider.ts +1 -1
- package/src/cache/core/__tests__/shared.ts +30 -0
- package/src/cache/core/index.ts +11 -6
- package/src/cache/core/primitives/$cache.spec.ts +5 -0
- package/src/cache/core/providers/CacheProvider.ts +17 -0
- package/src/cache/core/providers/MemoryCacheProvider.ts +300 -1
- package/src/cache/redis/__tests__/cache-redis.spec.ts +5 -0
- package/src/cache/redis/providers/RedisCacheProvider.ts +9 -0
- package/src/cli/apps/AlephaCli.ts +1 -14
- package/src/cli/apps/AlephaPackageBuilderCli.ts +1 -1
- package/src/cli/commands/build.ts +1 -5
- package/src/cli/commands/db.ts +17 -11
- package/src/cli/commands/deploy.ts +1 -1
- package/src/cli/commands/dev.ts +1 -20
- package/src/cli/commands/gen/env.ts +5 -2
- package/src/cli/commands/gen/openapi.ts +5 -2
- package/src/cli/commands/init.spec.ts +544 -0
- package/src/cli/commands/init.ts +89 -55
- package/src/cli/commands/lint.ts +7 -1
- package/src/cli/commands/typecheck.ts +11 -0
- package/src/cli/providers/AppEntryProvider.ts +1 -1
- package/src/cli/providers/ViteBuildProvider.ts +8 -50
- package/src/cli/providers/ViteDevServerProvider.ts +36 -8
- package/src/cli/services/AlephaCliUtils.ts +37 -122
- package/src/cli/services/PackageManagerUtils.ts +127 -11
- package/src/cli/services/ProjectScaffolder.ts +122 -77
- package/src/cli/services/ViteUtils.ts +82 -0
- package/src/cli/{assets/claudeMd.ts → templates/agentMd.ts} +32 -24
- package/src/cli/templates/gitignore.ts +39 -0
- package/src/cli/{assets → templates}/mainCss.ts +11 -2
- package/src/cli/templates/mainServerTs.ts +33 -0
- package/src/cli/templates/webAppRouterTs.ts +50 -0
- package/src/cli/{assets → templates}/webHelloComponentTsx.ts +2 -2
- package/src/command/helpers/Runner.spec.ts +4 -0
- package/src/command/helpers/Runner.ts +3 -21
- package/src/command/index.ts +12 -4
- package/src/command/providers/CliProvider.spec.ts +1067 -0
- package/src/command/providers/CliProvider.ts +203 -40
- package/src/core/Alepha.ts +2 -2
- package/src/core/__tests__/Alepha-start.spec.ts +4 -4
- package/src/core/helpers/jsonSchemaToTypeBox.spec.ts +771 -0
- package/src/core/helpers/jsonSchemaToTypeBox.ts +62 -10
- package/src/core/index.shared.ts +1 -0
- package/src/core/index.ts +20 -0
- package/src/core/providers/EventManager.spec.ts +0 -71
- package/src/core/providers/EventManager.ts +3 -15
- package/src/core/providers/Json.ts +2 -14
- package/src/datetime/index.ts +15 -0
- package/src/email/index.ts +10 -5
- package/src/email/providers/LocalEmailProvider.spec.ts +1 -1
- package/src/email/providers/LocalEmailProvider.ts +1 -1
- package/src/fake/__tests__/keyName.example.ts +1 -1
- package/src/fake/__tests__/keyName.spec.ts +5 -5
- package/src/fake/index.ts +9 -6
- package/src/fake/providers/FakeProvider.spec.ts +258 -40
- package/src/fake/providers/FakeProvider.ts +133 -19
- package/src/lock/core/index.ts +11 -4
- package/src/logger/index.ts +17 -66
- package/src/mcp/index.ts +10 -27
- package/src/mcp/transports/SseMcpTransport.ts +0 -11
- package/src/orm/__tests__/PostgresProvider.spec.ts +2 -2
- package/src/orm/index.browser.ts +2 -2
- package/src/orm/index.bun.ts +4 -2
- package/src/orm/index.ts +21 -47
- package/src/orm/providers/drivers/BunSqliteProvider.ts +1 -0
- package/src/orm/services/Repository.ts +7 -3
- package/src/queue/core/index.ts +14 -6
- package/src/react/auth/__tests__/$auth.spec.ts +202 -0
- package/src/react/auth/hooks/useAuth.ts +32 -0
- package/src/react/auth/index.browser.ts +13 -0
- package/src/react/auth/index.shared.ts +2 -0
- package/src/react/auth/index.ts +48 -0
- package/src/react/auth/providers/ReactAuthProvider.ts +16 -0
- package/src/react/auth/services/ReactAuth.ts +135 -0
- package/src/react/core/__tests__/Router.spec.tsx +169 -0
- package/src/react/core/components/ClientOnly.tsx +49 -0
- package/src/react/core/components/ErrorBoundary.tsx +73 -0
- package/src/react/core/contexts/AlephaContext.ts +7 -0
- package/src/react/core/contexts/AlephaProvider.tsx +42 -0
- package/src/react/core/hooks/useAction.browser.spec.tsx +569 -0
- package/src/react/core/hooks/useAction.ts +480 -0
- package/src/react/core/hooks/useAlepha.ts +26 -0
- package/src/react/core/hooks/useClient.ts +17 -0
- package/src/react/core/hooks/useEvents.ts +51 -0
- package/src/react/core/hooks/useInject.ts +12 -0
- package/src/react/core/hooks/useStore.ts +52 -0
- package/src/react/core/index.ts +90 -0
- package/src/react/form/components/FormState.tsx +17 -0
- package/src/react/form/errors/FormValidationError.ts +18 -0
- package/src/react/form/hooks/useForm.browser.spec.tsx +366 -0
- package/src/react/form/hooks/useForm.ts +47 -0
- package/src/react/form/hooks/useFormState.ts +130 -0
- package/src/react/form/index.ts +44 -0
- package/src/react/form/services/FormModel.ts +614 -0
- package/src/react/head/helpers/SeoExpander.spec.ts +203 -0
- package/src/react/head/helpers/SeoExpander.ts +142 -0
- package/src/react/head/hooks/useHead.spec.tsx +288 -0
- package/src/react/head/hooks/useHead.ts +62 -0
- package/src/react/head/index.browser.ts +26 -0
- package/src/react/head/index.ts +44 -0
- package/src/react/head/interfaces/Head.ts +105 -0
- package/src/react/head/primitives/$head.ts +25 -0
- package/src/react/head/providers/BrowserHeadProvider.browser.spec.ts +196 -0
- package/src/react/head/providers/BrowserHeadProvider.ts +212 -0
- package/src/react/head/providers/HeadProvider.ts +168 -0
- package/src/react/head/providers/ServerHeadProvider.ts +31 -0
- package/src/react/i18n/__tests__/integration.spec.tsx +239 -0
- package/src/react/i18n/components/Localize.spec.tsx +357 -0
- package/src/react/i18n/components/Localize.tsx +35 -0
- package/src/react/i18n/hooks/useI18n.browser.spec.tsx +438 -0
- package/src/react/i18n/hooks/useI18n.ts +18 -0
- package/src/react/i18n/index.ts +41 -0
- package/src/react/i18n/primitives/$dictionary.ts +69 -0
- package/src/react/i18n/providers/I18nProvider.spec.ts +389 -0
- package/src/react/i18n/providers/I18nProvider.ts +278 -0
- package/src/react/router/__tests__/page-head-browser.browser.spec.ts +95 -0
- package/src/react/router/__tests__/page-head.spec.ts +48 -0
- package/src/react/router/__tests__/seo-head.spec.ts +125 -0
- package/src/react/router/atoms/ssrManifestAtom.ts +58 -0
- package/src/react/router/components/ErrorViewer.tsx +872 -0
- package/src/react/router/components/Link.tsx +23 -0
- package/src/react/router/components/NestedView.tsx +223 -0
- package/src/react/router/components/NotFound.tsx +30 -0
- package/src/react/router/constants/PAGE_PRELOAD_KEY.ts +6 -0
- package/src/react/router/contexts/RouterLayerContext.ts +12 -0
- package/src/react/router/errors/Redirection.ts +28 -0
- package/src/react/router/hooks/useActive.ts +52 -0
- package/src/react/router/hooks/useQueryParams.ts +63 -0
- package/src/react/router/hooks/useRouter.ts +20 -0
- package/src/react/router/hooks/useRouterState.ts +11 -0
- package/src/react/router/index.browser.ts +45 -0
- package/src/react/router/index.shared.ts +19 -0
- package/src/react/router/index.ts +142 -0
- package/src/react/router/primitives/$page.browser.spec.tsx +851 -0
- package/src/react/router/primitives/$page.spec.tsx +708 -0
- package/src/react/router/primitives/$page.ts +497 -0
- package/src/react/router/providers/ReactBrowserProvider.ts +309 -0
- package/src/react/router/providers/ReactBrowserRendererProvider.ts +25 -0
- package/src/react/router/providers/ReactBrowserRouterProvider.ts +168 -0
- package/src/react/router/providers/ReactPageProvider.ts +726 -0
- package/src/react/router/providers/ReactServerProvider.spec.tsx +316 -0
- package/src/react/router/providers/ReactServerProvider.ts +558 -0
- package/src/react/router/providers/ReactServerTemplateProvider.ts +979 -0
- package/src/react/router/providers/SSRManifestProvider.ts +334 -0
- package/src/react/router/services/ReactPageServerService.ts +48 -0
- package/src/react/router/services/ReactPageService.ts +27 -0
- package/src/react/router/services/ReactRouter.ts +262 -0
- package/src/react/websocket/hooks/useRoom.tsx +242 -0
- package/src/react/websocket/index.ts +7 -0
- package/src/redis/__tests__/redis.spec.ts +13 -0
- package/src/redis/index.ts +9 -25
- package/src/redis/providers/BunRedisProvider.ts +9 -0
- package/src/redis/providers/NodeRedisProvider.ts +8 -0
- package/src/redis/providers/RedisProvider.ts +16 -0
- package/src/retry/index.ts +11 -2
- package/src/router/index.ts +15 -0
- package/src/scheduler/index.ts +11 -2
- package/src/security/__tests__/BasicAuth.spec.ts +2 -0
- package/src/security/__tests__/ServerSecurityProvider.spec.ts +13 -5
- package/src/security/index.ts +15 -10
- package/src/security/interfaces/IssuerResolver.ts +27 -0
- package/src/security/primitives/$issuer.ts +55 -0
- package/src/security/providers/SecurityProvider.ts +179 -0
- package/src/security/providers/ServerBasicAuthProvider.ts +6 -2
- package/src/security/providers/ServerSecurityProvider.ts +36 -22
- package/src/server/auth/index.ts +12 -7
- package/src/server/cache/index.ts +7 -22
- package/src/server/compress/index.ts +10 -2
- package/src/server/cookies/index.ts +7 -5
- package/src/server/cookies/primitives/$cookie.ts +33 -11
- package/src/server/core/index.ts +16 -6
- package/src/server/core/interfaces/ServerRequest.ts +83 -1
- package/src/server/core/primitives/$action.spec.ts +1 -1
- package/src/server/core/primitives/$action.ts +8 -3
- package/src/server/core/providers/NodeHttpServerProvider.ts +9 -3
- package/src/server/core/services/ServerRequestParser.spec.ts +520 -0
- package/src/server/core/services/ServerRequestParser.ts +306 -13
- package/src/server/cors/index.ts +7 -21
- package/src/server/cors/primitives/$cors.ts +6 -2
- package/src/server/health/index.ts +8 -2
- package/src/server/helmet/index.ts +11 -3
- package/src/server/links/index.ts +11 -6
- package/src/server/metrics/index.ts +10 -3
- package/src/server/multipart/index.ts +9 -3
- package/src/server/proxy/index.ts +8 -2
- package/src/server/rate-limit/index.ts +21 -25
- package/src/server/rate-limit/primitives/$rateLimit.ts +6 -2
- package/src/server/rate-limit/providers/ServerRateLimitProvider.spec.ts +38 -14
- package/src/server/rate-limit/providers/ServerRateLimitProvider.ts +22 -56
- package/src/server/static/index.ts +8 -2
- package/src/server/static/providers/ServerStaticProvider.ts +1 -1
- package/src/server/swagger/index.ts +9 -4
- package/src/server/swagger/providers/ServerSwaggerProvider.ts +1 -1
- package/src/sms/index.ts +9 -5
- package/src/sms/providers/LocalSmsProvider.spec.ts +1 -1
- package/src/sms/providers/LocalSmsProvider.ts +1 -1
- package/src/system/index.browser.ts +11 -0
- package/src/system/index.ts +62 -0
- package/src/{file → system}/providers/FileSystemProvider.ts +16 -0
- package/src/{file → system}/providers/MemoryFileSystemProvider.ts +116 -3
- package/src/system/providers/MemoryShellProvider.ts +164 -0
- package/src/{file → system}/providers/NodeFileSystemProvider.spec.ts +2 -2
- package/src/{file → system}/providers/NodeFileSystemProvider.ts +36 -0
- package/src/system/providers/NodeShellProvider.ts +184 -0
- package/src/system/providers/ShellProvider.ts +74 -0
- package/src/{file → system}/services/FileDetector.spec.ts +2 -2
- package/src/thread/index.ts +11 -2
- package/src/topic/core/index.ts +12 -5
- package/src/vite/tasks/buildClient.ts +2 -7
- package/src/vite/tasks/buildServer.ts +17 -1
- package/src/websocket/index.ts +12 -8
- package/dist/file/index.d.ts.map +0 -1
- package/dist/file/index.js.map +0 -1
- package/src/cli/assets/mainServerTs.ts +0 -24
- package/src/cli/assets/webAppRouterTs.ts +0 -16
- package/src/cli/providers/ViteTemplateProvider.ts +0 -27
- package/src/file/index.ts +0 -43
- /package/src/cli/{assets → templates}/apiHelloControllerTs.ts +0 -0
- /package/src/cli/{assets → templates}/apiIndexTs.ts +0 -0
- /package/src/cli/{assets → templates}/biomeJson.ts +0 -0
- /package/src/cli/{assets → templates}/dummySpecTs.ts +0 -0
- /package/src/cli/{assets → templates}/editorconfig.ts +0 -0
- /package/src/cli/{assets → templates}/mainBrowserTs.ts +0 -0
- /package/src/cli/{assets → templates}/tsconfigJson.ts +0 -0
- /package/src/cli/{assets → templates}/webIndexTs.ts +0 -0
- /package/src/{file → system}/errors/FileError.ts +0 -0
- /package/src/{file → system}/services/FileDetector.ts +0 -0
|
@@ -77,7 +77,37 @@ declare module "alepha" {
|
|
|
77
77
|
|
|
78
78
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* CLI provider for parsing and executing commands.
|
|
82
|
+
*
|
|
83
|
+
* Handles:
|
|
84
|
+
* - Command resolution (simple, nested, colon-notation)
|
|
85
|
+
* - Flag and argument parsing
|
|
86
|
+
* - Environment variable validation
|
|
87
|
+
* - Help generation
|
|
88
|
+
* - Pre/post command hooks
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* // Define a command
|
|
93
|
+
* class MyCommands {
|
|
94
|
+
* build = $command({
|
|
95
|
+
* name: "build",
|
|
96
|
+
* description: "Build the project",
|
|
97
|
+
* flags: t.object({ watch: t.optional(t.boolean()) }),
|
|
98
|
+
* handler: async ({ flags }) => { ... }
|
|
99
|
+
* });
|
|
100
|
+
* }
|
|
101
|
+
*
|
|
102
|
+
* // CLI automatically discovers and executes commands
|
|
103
|
+
* const alepha = Alepha.create().with(MyCommands);
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
80
106
|
export class CliProvider {
|
|
107
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
108
|
+
// Dependencies
|
|
109
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
110
|
+
|
|
81
111
|
protected readonly env = $env(envSchema);
|
|
82
112
|
protected readonly alepha = $inject(Alepha);
|
|
83
113
|
protected readonly log = $logger();
|
|
@@ -85,9 +115,12 @@ export class CliProvider {
|
|
|
85
115
|
protected readonly runner = $inject(Runner);
|
|
86
116
|
protected readonly asker = $inject(Asker);
|
|
87
117
|
protected readonly envUtils = $inject(EnvUtils);
|
|
88
|
-
|
|
89
118
|
protected readonly options = $use(cliOptions);
|
|
90
119
|
|
|
120
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
121
|
+
// Configuration
|
|
122
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
123
|
+
|
|
91
124
|
protected get name(): string {
|
|
92
125
|
return this.options.name || this.env.CLI_NAME;
|
|
93
126
|
}
|
|
@@ -103,6 +136,9 @@ export class CliProvider {
|
|
|
103
136
|
);
|
|
104
137
|
}
|
|
105
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Global flags available to all commands.
|
|
141
|
+
*/
|
|
106
142
|
protected readonly globalFlags = {
|
|
107
143
|
help: {
|
|
108
144
|
aliases: ["h", "help"],
|
|
@@ -111,6 +147,14 @@ export class CliProvider {
|
|
|
111
147
|
},
|
|
112
148
|
};
|
|
113
149
|
|
|
150
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
151
|
+
// Lifecycle
|
|
152
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Main entry point - resolves and executes the command from process.argv.
|
|
156
|
+
* This is the production execution path with full lifecycle support.
|
|
157
|
+
*/
|
|
114
158
|
protected readonly onReady = $hook({
|
|
115
159
|
on: "ready",
|
|
116
160
|
handler: async () => {
|
|
@@ -119,7 +163,7 @@ export class CliProvider {
|
|
|
119
163
|
// Extract positional arguments (potential command path)
|
|
120
164
|
const positionalArgs = argv.filter((arg) => !arg.startsWith("-"));
|
|
121
165
|
|
|
122
|
-
// Resolve command using
|
|
166
|
+
// Resolve command using space-separated or colon-notation
|
|
123
167
|
const { command, consumedArgs } = this.resolveCommand(positionalArgs);
|
|
124
168
|
|
|
125
169
|
const globalFlags = this.parseFlags(
|
|
@@ -128,6 +172,7 @@ export class CliProvider {
|
|
|
128
172
|
key,
|
|
129
173
|
...value,
|
|
130
174
|
})),
|
|
175
|
+
{ strict: false }, // Don't throw for command-specific flags
|
|
131
176
|
);
|
|
132
177
|
|
|
133
178
|
if (globalFlags.help) {
|
|
@@ -166,7 +211,15 @@ export class CliProvider {
|
|
|
166
211
|
});
|
|
167
212
|
|
|
168
213
|
/**
|
|
169
|
-
* Execute a command with
|
|
214
|
+
* Execute a command with full lifecycle support.
|
|
215
|
+
*
|
|
216
|
+
* This is the production execution path that includes:
|
|
217
|
+
* - Mode-based .env file loading
|
|
218
|
+
* - Pre/post command hooks
|
|
219
|
+
* - Runner session for pretty CLI output
|
|
220
|
+
* - Alepha context wrapper for proper scoping
|
|
221
|
+
*
|
|
222
|
+
* @see run() for a lightweight test-only alternative
|
|
170
223
|
*/
|
|
171
224
|
protected async executeCommand(
|
|
172
225
|
command: CommandPrimitive<TObject>,
|
|
@@ -186,7 +239,9 @@ export class CliProvider {
|
|
|
186
239
|
await this.loadModeEnv(root, modeValue);
|
|
187
240
|
}
|
|
188
241
|
|
|
189
|
-
const commandFlags = this.parseCommandFlags(argv, command.flags
|
|
242
|
+
const commandFlags = this.parseCommandFlags(argv, command.flags, {
|
|
243
|
+
modeEnabled: !!command.options.mode,
|
|
244
|
+
});
|
|
190
245
|
const commandArgs = this.parseCommandArgs(
|
|
191
246
|
argv,
|
|
192
247
|
command.options.args,
|
|
@@ -244,7 +299,7 @@ export class CliProvider {
|
|
|
244
299
|
}
|
|
245
300
|
|
|
246
301
|
/**
|
|
247
|
-
* Remove consumed command path arguments from argv.
|
|
302
|
+
* Remove consumed command path arguments from argv (keeps flags and remaining args).
|
|
248
303
|
*/
|
|
249
304
|
protected removeConsumedArgs(
|
|
250
305
|
argv: string[],
|
|
@@ -327,33 +382,113 @@ export class CliProvider {
|
|
|
327
382
|
return { command: currentCommand, consumedArgs };
|
|
328
383
|
}
|
|
329
384
|
|
|
385
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
386
|
+
// Public API
|
|
387
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Get all registered commands in the application.
|
|
391
|
+
*/
|
|
330
392
|
public get commands(): CommandPrimitive<any>[] {
|
|
331
393
|
return this.alepha.primitives($command);
|
|
332
394
|
}
|
|
333
395
|
|
|
396
|
+
/**
|
|
397
|
+
* Execute a command handler with given arguments.
|
|
398
|
+
*
|
|
399
|
+
* This is a **lightweight test helper** that directly invokes the command handler
|
|
400
|
+
* without the full production lifecycle. It intentionally skips:
|
|
401
|
+
* - Pre/post command hooks
|
|
402
|
+
* - Runner session (pretty CLI output)
|
|
403
|
+
* - Alepha context wrapper
|
|
404
|
+
* - .env.{mode} file loading
|
|
405
|
+
*
|
|
406
|
+
* For production execution, the `onReady` hook uses `executeCommand()` which
|
|
407
|
+
* provides the full lifecycle. Merging them would either make this method too
|
|
408
|
+
* heavy for simple testing or require many optional parameters to toggle behaviors.
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```typescript
|
|
412
|
+
* // In tests
|
|
413
|
+
* const cli = alepha.inject(CliProvider);
|
|
414
|
+
* const cmd = alepha.inject(InitCommand);
|
|
415
|
+
*
|
|
416
|
+
* await cli.run(cmd.init, "--agent --pm=yarn");
|
|
417
|
+
* await cli.run(cmd.init, { argv: "--agent", root: "/project" });
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
420
|
+
public async run<T extends TObject, A extends TSchema>(
|
|
421
|
+
command: CommandPrimitive<T, A>,
|
|
422
|
+
options:
|
|
423
|
+
| string
|
|
424
|
+
| string[]
|
|
425
|
+
| { argv?: string | string[]; root?: string } = {},
|
|
426
|
+
): Promise<void> {
|
|
427
|
+
const opts =
|
|
428
|
+
typeof options === "string" || Array.isArray(options)
|
|
429
|
+
? { argv: options }
|
|
430
|
+
: options;
|
|
431
|
+
const args =
|
|
432
|
+
typeof opts.argv === "string"
|
|
433
|
+
? opts.argv.split(" ").filter(Boolean)
|
|
434
|
+
: (opts.argv ?? []);
|
|
435
|
+
const root = opts.root ?? process.cwd();
|
|
436
|
+
|
|
437
|
+
const commandFlags = this.parseCommandFlags(args, command.flags, {
|
|
438
|
+
modeEnabled: !!command.options.mode,
|
|
439
|
+
});
|
|
440
|
+
const commandArgs = this.parseCommandArgs(
|
|
441
|
+
args,
|
|
442
|
+
command.options.args,
|
|
443
|
+
true,
|
|
444
|
+
command.flags,
|
|
445
|
+
);
|
|
446
|
+
const commandEnv = this.parseCommandEnv(command.env, command.name);
|
|
447
|
+
|
|
448
|
+
let modeValue: string | undefined;
|
|
449
|
+
if (command.options.mode) {
|
|
450
|
+
modeValue = this.parseModeFlag(args);
|
|
451
|
+
if (modeValue === undefined && typeof command.options.mode === "string") {
|
|
452
|
+
modeValue = command.options.mode;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
await command.options.handler({
|
|
457
|
+
flags: commandFlags,
|
|
458
|
+
args: commandArgs,
|
|
459
|
+
env: commandEnv,
|
|
460
|
+
run: this.runner.run,
|
|
461
|
+
ask: this.asker.ask,
|
|
462
|
+
fs,
|
|
463
|
+
glob,
|
|
464
|
+
root,
|
|
465
|
+
help: () => this.printHelp(command),
|
|
466
|
+
mode: modeValue,
|
|
467
|
+
} as CommandHandlerArgs<T, A>);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
471
|
+
// Command Resolution
|
|
472
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
473
|
+
|
|
474
|
+
/** Find a command by name or alias */
|
|
334
475
|
protected findCommand(name: string): CommandPrimitive<TObject> | undefined {
|
|
335
476
|
return this.commands.findLast(
|
|
336
477
|
(command) => command.name === name || command.aliases.includes(name),
|
|
337
478
|
);
|
|
338
479
|
}
|
|
339
480
|
|
|
340
|
-
/**
|
|
341
|
-
* Find all pre-hooks for a command.
|
|
342
|
-
*/
|
|
481
|
+
/** Find all pre-hooks for a command (commands named `pre{commandName}`) */
|
|
343
482
|
protected findPreHooks(commandName: string): CommandPrimitive<TObject>[] {
|
|
344
483
|
return this.commands.filter((cmd) => cmd.name === `pre${commandName}`);
|
|
345
484
|
}
|
|
346
485
|
|
|
347
|
-
/**
|
|
348
|
-
* Find all post-hooks for a command.
|
|
349
|
-
*/
|
|
486
|
+
/** Find all post-hooks for a command (commands named `post{commandName}`) */
|
|
350
487
|
protected findPostHooks(commandName: string): CommandPrimitive<TObject>[] {
|
|
351
488
|
return this.commands.filter((cmd) => cmd.name === `post${commandName}`);
|
|
352
489
|
}
|
|
353
490
|
|
|
354
|
-
/**
|
|
355
|
-
* Get global flags (help only, root command flags are NOT global).
|
|
356
|
-
*/
|
|
491
|
+
/** Get global flags (help only, root command flags are NOT global) */
|
|
357
492
|
protected getAllGlobalFlags(): Record<
|
|
358
493
|
string,
|
|
359
494
|
{ aliases: string[]; description?: string; schema: TSchema }
|
|
@@ -361,10 +496,17 @@ export class CliProvider {
|
|
|
361
496
|
return { ...this.globalFlags };
|
|
362
497
|
}
|
|
363
498
|
|
|
499
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
500
|
+
// Parsing (Flags, Args, Env)
|
|
501
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
502
|
+
|
|
503
|
+
/** Parse command flags from argv using the command's flag schema */
|
|
364
504
|
protected parseCommandFlags(
|
|
365
505
|
argv: string[],
|
|
366
506
|
schema: TObject,
|
|
507
|
+
options: { modeEnabled?: boolean } = {},
|
|
367
508
|
): Record<string, any> {
|
|
509
|
+
const { modeEnabled = false } = options;
|
|
368
510
|
const flagDefs = Object.entries(schema.properties).map(([key, value]) => ({
|
|
369
511
|
key,
|
|
370
512
|
aliases: [
|
|
@@ -377,8 +519,21 @@ export class CliProvider {
|
|
|
377
519
|
schema: value,
|
|
378
520
|
}));
|
|
379
521
|
|
|
522
|
+
// Add mode flags if mode is enabled (they're parsed elsewhere by parseModeFlag)
|
|
523
|
+
if (modeEnabled) {
|
|
524
|
+
flagDefs.push({
|
|
525
|
+
key: "__mode__",
|
|
526
|
+
aliases: ["mode", "m"],
|
|
527
|
+
description: undefined,
|
|
528
|
+
schema: t.string(),
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
|
|
380
532
|
const parsed = this.parseFlags(argv, flagDefs);
|
|
381
533
|
|
|
534
|
+
// Remove the mode flag from parsed result (it's handled separately)
|
|
535
|
+
delete parsed.__mode__;
|
|
536
|
+
|
|
382
537
|
// apply manually defaults for optional properties that have defaults
|
|
383
538
|
for (const [key, value] of Object.entries(schema.properties)) {
|
|
384
539
|
if (!(key in parsed) && t.schema.isOptional(value)) {
|
|
@@ -401,6 +556,7 @@ export class CliProvider {
|
|
|
401
556
|
}
|
|
402
557
|
}
|
|
403
558
|
|
|
559
|
+
/** Parse and validate environment variables using the command's env schema */
|
|
404
560
|
protected parseCommandEnv(
|
|
405
561
|
schema: TObject,
|
|
406
562
|
commandName: string,
|
|
@@ -442,9 +598,7 @@ export class CliProvider {
|
|
|
442
598
|
}
|
|
443
599
|
}
|
|
444
600
|
|
|
445
|
-
/**
|
|
446
|
-
* Parse --mode or -m flag from argv.
|
|
447
|
-
*/
|
|
601
|
+
/** Parse --mode or -m flag from argv for environment file loading */
|
|
448
602
|
protected parseModeFlag(argv: string[]): string | undefined {
|
|
449
603
|
for (let i = 0; i < argv.length; i++) {
|
|
450
604
|
const arg = argv[i];
|
|
@@ -467,9 +621,7 @@ export class CliProvider {
|
|
|
467
621
|
return undefined;
|
|
468
622
|
}
|
|
469
623
|
|
|
470
|
-
/**
|
|
471
|
-
* Load environment files based on mode.
|
|
472
|
-
*/
|
|
624
|
+
/** Load .env and .env.{mode} files into process.env */
|
|
473
625
|
protected async loadModeEnv(
|
|
474
626
|
root: string,
|
|
475
627
|
mode: string | undefined,
|
|
@@ -482,10 +634,13 @@ export class CliProvider {
|
|
|
482
634
|
await this.envUtils.loadEnv(root, envFiles);
|
|
483
635
|
}
|
|
484
636
|
|
|
637
|
+
/** Low-level flag parser - extracts flag values from argv based on definitions */
|
|
485
638
|
protected parseFlags(
|
|
486
639
|
argv: string[],
|
|
487
640
|
flagDefs: { key: string; aliases: string[]; schema: TSchema }[],
|
|
641
|
+
options: { strict?: boolean } = {},
|
|
488
642
|
): Record<string, any> {
|
|
643
|
+
const { strict = true } = options;
|
|
489
644
|
const result: Record<string, any> = {};
|
|
490
645
|
|
|
491
646
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -496,7 +651,12 @@ export class CliProvider {
|
|
|
496
651
|
let value = valueParts.join("=");
|
|
497
652
|
|
|
498
653
|
const def = flagDefs.find((d) => d.aliases.includes(rawKey));
|
|
499
|
-
if (!def)
|
|
654
|
+
if (!def) {
|
|
655
|
+
if (strict) {
|
|
656
|
+
throw new CommandError(`Unknown flag: --${rawKey}`);
|
|
657
|
+
}
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
500
660
|
|
|
501
661
|
if (t.schema.isBoolean(def.schema)) {
|
|
502
662
|
result[def.key] = true;
|
|
@@ -534,9 +694,7 @@ export class CliProvider {
|
|
|
534
694
|
return result;
|
|
535
695
|
}
|
|
536
696
|
|
|
537
|
-
/**
|
|
538
|
-
* Get indices of argv elements that are consumed by flags (including space-separated values).
|
|
539
|
-
*/
|
|
697
|
+
/** Get indices of argv elements consumed by flags (for separating args from flags) */
|
|
540
698
|
protected getFlagConsumedIndices(
|
|
541
699
|
argv: string[],
|
|
542
700
|
flagDefs: { key: string; aliases: string[]; schema: TSchema }[],
|
|
@@ -638,6 +796,7 @@ export class CliProvider {
|
|
|
638
796
|
}
|
|
639
797
|
}
|
|
640
798
|
|
|
799
|
+
/** Convert a string argument value to the appropriate type based on schema */
|
|
641
800
|
protected parseArgumentValue(value: string, schema: TSchema): any {
|
|
642
801
|
if (t.schema.isString(schema)) {
|
|
643
802
|
return value;
|
|
@@ -665,6 +824,11 @@ export class CliProvider {
|
|
|
665
824
|
return value;
|
|
666
825
|
}
|
|
667
826
|
|
|
827
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
828
|
+
// Help Generation
|
|
829
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
830
|
+
|
|
831
|
+
/** Generate usage string for command arguments (e.g., "<path>" or "[path]") */
|
|
668
832
|
protected generateArgsUsage(schema?: TSchema): string {
|
|
669
833
|
if (!schema) {
|
|
670
834
|
return "";
|
|
@@ -694,6 +858,7 @@ export class CliProvider {
|
|
|
694
858
|
return ` <${key}${typeName}>`;
|
|
695
859
|
}
|
|
696
860
|
|
|
861
|
+
/** Get display type name for a schema (e.g., ": number", ": boolean") */
|
|
697
862
|
protected getTypeName(schema: TSchema): string {
|
|
698
863
|
if (!schema) return "";
|
|
699
864
|
|
|
@@ -706,6 +871,12 @@ export class CliProvider {
|
|
|
706
871
|
return "";
|
|
707
872
|
}
|
|
708
873
|
|
|
874
|
+
/**
|
|
875
|
+
* Print help for a specific command or general CLI help.
|
|
876
|
+
*
|
|
877
|
+
* @param command - If provided, shows help for this specific command.
|
|
878
|
+
* If omitted, shows general CLI help with all commands.
|
|
879
|
+
*/
|
|
709
880
|
public printHelp(command?: CommandPrimitive<any>): void {
|
|
710
881
|
const cliName = this.name || "cli";
|
|
711
882
|
const c = this.color;
|
|
@@ -873,9 +1044,7 @@ export class CliProvider {
|
|
|
873
1044
|
this.log.info(""); // Newline
|
|
874
1045
|
}
|
|
875
1046
|
|
|
876
|
-
/**
|
|
877
|
-
* Generate colored args usage string for help display.
|
|
878
|
-
*/
|
|
1047
|
+
/** Generate colored usage string for command arguments (for help display) */
|
|
879
1048
|
protected generateColoredArgsUsage(schema?: TSchema): string {
|
|
880
1049
|
if (!schema) {
|
|
881
1050
|
return "";
|
|
@@ -907,9 +1076,7 @@ export class CliProvider {
|
|
|
907
1076
|
return ` ${c.set("CYAN", `<${key}${typeName}>`)}`;
|
|
908
1077
|
}
|
|
909
1078
|
|
|
910
|
-
/**
|
|
911
|
-
* Get the full command path (e.g., "deploy vercel" for a child command).
|
|
912
|
-
*/
|
|
1079
|
+
/** Get the full command path (e.g., "deploy vercel" for a nested command) */
|
|
913
1080
|
protected getCommandPath(command: CommandPrimitive<any>): string {
|
|
914
1081
|
const path: string[] = [command.name];
|
|
915
1082
|
let current = command;
|
|
@@ -925,9 +1092,7 @@ export class CliProvider {
|
|
|
925
1092
|
return path.join(" ");
|
|
926
1093
|
}
|
|
927
1094
|
|
|
928
|
-
/**
|
|
929
|
-
* Find the parent command of a given command.
|
|
930
|
-
*/
|
|
1095
|
+
/** Find the parent command of a nested command */
|
|
931
1096
|
protected findParentCommand(
|
|
932
1097
|
command: CommandPrimitive<any>,
|
|
933
1098
|
): CommandPrimitive<any> | undefined {
|
|
@@ -939,9 +1104,7 @@ export class CliProvider {
|
|
|
939
1104
|
return undefined;
|
|
940
1105
|
}
|
|
941
1106
|
|
|
942
|
-
/**
|
|
943
|
-
* Get top-level commands (commands that are not children of other commands).
|
|
944
|
-
*/
|
|
1107
|
+
/** Get top-level commands (commands that are not children of other commands) */
|
|
945
1108
|
protected getTopLevelCommands(): CommandPrimitive<any>[] {
|
|
946
1109
|
const allChildren = new Set<CommandPrimitive<any>>();
|
|
947
1110
|
|
|
@@ -956,9 +1119,7 @@ export class CliProvider {
|
|
|
956
1119
|
return this.commands.filter((cmd) => !allChildren.has(cmd));
|
|
957
1120
|
}
|
|
958
1121
|
|
|
959
|
-
/**
|
|
960
|
-
* Get max length for child command display.
|
|
961
|
-
*/
|
|
1122
|
+
/** Calculate max display length for child commands (for help alignment) */
|
|
962
1123
|
protected getMaxChildCmdLength(children: CommandPrimitive<any>[]): number {
|
|
963
1124
|
return Math.max(
|
|
964
1125
|
...children
|
|
@@ -972,6 +1133,7 @@ export class CliProvider {
|
|
|
972
1133
|
);
|
|
973
1134
|
}
|
|
974
1135
|
|
|
1136
|
+
/** Calculate max display length for commands (for help alignment) */
|
|
975
1137
|
protected getMaxCmdLength(commands: CommandPrimitive[]): number {
|
|
976
1138
|
return Math.max(
|
|
977
1139
|
...commands
|
|
@@ -986,7 +1148,8 @@ export class CliProvider {
|
|
|
986
1148
|
);
|
|
987
1149
|
}
|
|
988
1150
|
|
|
989
|
-
|
|
1151
|
+
/** Calculate max display length for flags (for help alignment) */
|
|
1152
|
+
protected getMaxFlagLength(flags: { aliases: string[] }[]): number {
|
|
990
1153
|
return Math.max(
|
|
991
1154
|
...flags.map((f) => {
|
|
992
1155
|
const aliases = Array.isArray(f.aliases) ? f.aliases : [f.aliases];
|
package/src/core/Alepha.ts
CHANGED
|
@@ -535,7 +535,7 @@ export class Alepha {
|
|
|
535
535
|
}
|
|
536
536
|
|
|
537
537
|
this.log?.info("Stopping App...");
|
|
538
|
-
await this.events.emit("stop", this, {
|
|
538
|
+
await this.events.emit("stop", this, { log: true });
|
|
539
539
|
this.log?.info("App is now off");
|
|
540
540
|
|
|
541
541
|
this.started = false;
|
|
@@ -760,7 +760,7 @@ export class Alepha {
|
|
|
760
760
|
if (this.started) {
|
|
761
761
|
const mod = (service as WithModule)[MODULE]?.name;
|
|
762
762
|
throw new ContainerLockedError(
|
|
763
|
-
`Container is locked. No more services can be added. Attempted to inject '${service.name}' from '${parent?.name}'. ${mod ? `
|
|
763
|
+
`Container is locked. No more services can be added. Attempted to inject '${service.name}' from '${parent?.name}'. ${mod ? `Module '${mod}' is not registered ?` : ""}`,
|
|
764
764
|
);
|
|
765
765
|
}
|
|
766
766
|
}
|
|
@@ -41,9 +41,9 @@ describe("Alepha#start", () => {
|
|
|
41
41
|
*
|
|
42
42
|
* - B should be configured after A.
|
|
43
43
|
* - B should be started after A.
|
|
44
|
+
* - A should be stopped before B (registration order).
|
|
44
45
|
*
|
|
45
|
-
*
|
|
46
|
-
* - B should be stopped before A.
|
|
46
|
+
* To control stop order, use `priority: "first"` on hooks.
|
|
47
47
|
*/
|
|
48
48
|
it("should execute hooks in correct order", async () => {
|
|
49
49
|
const stack: string[] = [];
|
|
@@ -110,8 +110,8 @@ describe("Alepha#start", () => {
|
|
|
110
110
|
"B.configure",
|
|
111
111
|
"A.start",
|
|
112
112
|
"B.start",
|
|
113
|
-
"B.stop",
|
|
114
113
|
"A.stop",
|
|
114
|
+
"B.stop",
|
|
115
115
|
]);
|
|
116
116
|
|
|
117
117
|
await app.stop();
|
|
@@ -121,8 +121,8 @@ describe("Alepha#start", () => {
|
|
|
121
121
|
"B.configure",
|
|
122
122
|
"A.start",
|
|
123
123
|
"B.start",
|
|
124
|
-
"B.stop",
|
|
125
124
|
"A.stop",
|
|
125
|
+
"B.stop",
|
|
126
126
|
]);
|
|
127
127
|
});
|
|
128
128
|
|