alepha 0.15.1 → 0.15.3
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 +68 -80
- package/dist/api/audits/index.d.ts +10 -33
- 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 +10 -3
- 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 +43 -50
- 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 +1081 -760
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +2539 -218
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts +138 -132
- 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 +440 -8
- package/dist/bucket/index.d.ts.map +1 -1
- package/dist/bucket/index.js +1861 -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 +638 -5645
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2550 -368
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +203 -45
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +2060 -71
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +70 -40
- 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 +90 -40
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +70 -40
- 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 +323 -20
- package/dist/email/index.d.ts.map +1 -1
- package/dist/email/index.js +1857 -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 +10 -30
- 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 +39 -20
- package/dist/orm/index.bun.js.map +1 -1
- package/dist/orm/index.d.ts +517 -540
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +58 -71
- 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 +1974 -0
- package/dist/react/router/index.browser.js.map +1 -0
- package/dist/react/router/index.d.ts +1956 -0
- package/dist/react/router/index.d.ts.map +1 -0
- package/dist/react/router/index.js +4722 -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 +41 -44
- 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 +140 -49
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +164 -32
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +12 -7
- 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 +124 -23
- 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 +8 -2
- 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 +11 -6
- 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 +1853 -5
- package/dist/server/static/index.js.map +1 -1
- package/dist/server/swagger/index.d.ts +309 -6
- package/dist/server/swagger/index.d.ts.map +1 -1
- package/dist/server/swagger/index.js +1854 -6
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/sms/index.d.ts +309 -7
- package/dist/sms/index.d.ts.map +1 -1
- package/dist/sms/index.js +1856 -7
- package/dist/sms/index.js.map +1 -1
- package/dist/system/index.browser.js +1218 -0
- package/dist/system/index.browser.js.map +1 -0
- package/dist/{file → system}/index.d.ts +343 -16
- package/dist/system/index.d.ts.map +1 -0
- package/dist/{file → system}/index.js +419 -22
- 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 +5 -6272
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +23 -10
- 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 +82 -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 +55 -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 +10 -1
- package/src/cli/atoms/buildOptions.ts +99 -9
- package/src/cli/commands/build.ts +150 -37
- package/src/cli/commands/db.ts +22 -18
- 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 +588 -0
- package/src/cli/commands/init.ts +115 -58
- 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 +35 -16
- package/src/cli/services/AlephaCliUtils.ts +52 -121
- package/src/cli/services/PackageManagerUtils.ts +129 -11
- package/src/cli/services/ProjectScaffolder.spec.ts +97 -0
- package/src/cli/services/ProjectScaffolder.ts +148 -81
- package/src/cli/services/ViteUtils.ts +82 -0
- package/src/cli/{assets/claudeMd.ts → templates/agentMd.ts} +37 -24
- package/src/cli/templates/apiAppSecurityTs.ts +11 -0
- package/src/cli/templates/apiIndexTs.ts +30 -0
- 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 +74 -0
- package/src/cli/templates/webHelloComponentTsx.ts +30 -0
- package/src/command/helpers/Runner.spec.ts +139 -0
- package/src/command/helpers/Runner.ts +7 -22
- package/src/command/index.ts +12 -4
- package/src/command/providers/CliProvider.spec.ts +1392 -0
- package/src/command/providers/CliProvider.ts +320 -47
- package/src/core/Alepha.ts +34 -27
- 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 +5 -3
- package/src/orm/index.ts +23 -53
- package/src/orm/providers/drivers/BunSqliteProvider.ts +5 -1
- package/src/orm/providers/drivers/CloudflareD1Provider.ts +57 -30
- package/src/orm/providers/drivers/DatabaseProvider.ts +9 -1
- package/src/orm/providers/drivers/NodeSqliteProvider.ts +4 -1
- 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 +146 -0
- package/src/react/router/primitives/$page.browser.spec.tsx +851 -0
- package/src/react/router/primitives/$page.spec.tsx +676 -0
- package/src/react/router/primitives/$page.ts +489 -0
- package/src/react/router/providers/ReactBrowserProvider.ts +312 -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/ReactPreloadProvider.spec.ts +142 -0
- package/src/react/router/providers/ReactPreloadProvider.ts +85 -0
- package/src/react/router/providers/ReactServerProvider.spec.tsx +316 -0
- package/src/react/router/providers/ReactServerProvider.ts +487 -0
- package/src/react/router/providers/ReactServerTemplateProvider.spec.ts +210 -0
- package/src/react/router/providers/ReactServerTemplateProvider.ts +542 -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 +90 -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 +63 -41
- 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.spec.ts +9 -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 +36 -0
- package/src/system/index.ts +62 -0
- package/src/system/index.workerd.ts +1 -0
- package/src/{file → system}/providers/FileSystemProvider.ts +24 -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 +47 -2
- 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 +19 -13
- package/src/vite/tasks/generateCloudflare.ts +10 -7
- package/src/vite/tasks/generateDocker.ts +4 -0
- 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/apiIndexTs.ts +0 -16
- package/src/cli/assets/mainServerTs.ts +0 -24
- package/src/cli/assets/webAppRouterTs.ts +0 -16
- package/src/cli/assets/webHelloComponentTsx.ts +0 -20
- 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}/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
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import { $inject, $module, Alepha, t } from "alepha";
|
|
2
|
+
import { $action, ForbiddenError, NotFoundError, okSchema } from "alepha/server";
|
|
3
|
+
import { $entity, $repository, db, pageQuerySchema, sql } from "alepha/orm";
|
|
4
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
5
|
+
import { $cache } from "alepha/cache";
|
|
6
|
+
import { DateTimeProvider } from "alepha/datetime";
|
|
7
|
+
import { $logger } from "alepha/logger";
|
|
8
|
+
|
|
9
|
+
//#region ../../src/api/keys/schemas/adminApiKeyQuerySchema.ts
|
|
10
|
+
const adminApiKeyQuerySchema = t.extend(pageQuerySchema, {
|
|
11
|
+
userId: t.optional(t.uuid()),
|
|
12
|
+
includeRevoked: t.optional(t.boolean())
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region ../../src/api/keys/schemas/adminApiKeyResourceSchema.ts
|
|
17
|
+
const adminApiKeyResourceSchema = t.object({
|
|
18
|
+
id: t.uuid(),
|
|
19
|
+
userId: t.uuid(),
|
|
20
|
+
name: t.string(),
|
|
21
|
+
description: t.optional(t.string()),
|
|
22
|
+
tokenPrefix: t.string(),
|
|
23
|
+
tokenSuffix: t.string(),
|
|
24
|
+
roles: t.array(t.string()),
|
|
25
|
+
createdAt: t.datetime(),
|
|
26
|
+
lastUsedAt: t.optional(t.datetime()),
|
|
27
|
+
lastUsedIp: t.optional(t.string()),
|
|
28
|
+
expiresAt: t.optional(t.datetime()),
|
|
29
|
+
revokedAt: t.optional(t.datetime()),
|
|
30
|
+
usageCount: t.integer()
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region ../../src/api/keys/entities/apiKeyEntity.ts
|
|
35
|
+
const apiKeyEntity = $entity({
|
|
36
|
+
name: "api_keys",
|
|
37
|
+
schema: t.object({
|
|
38
|
+
id: db.primaryKey(t.uuid()),
|
|
39
|
+
createdAt: db.createdAt(),
|
|
40
|
+
updatedAt: db.updatedAt(),
|
|
41
|
+
userId: t.uuid(),
|
|
42
|
+
name: t.text({ maxLength: 100 }),
|
|
43
|
+
description: t.optional(t.text({ maxLength: 500 })),
|
|
44
|
+
tokenHash: t.string({ maxLength: 256 }),
|
|
45
|
+
tokenPrefix: t.string({ maxLength: 10 }),
|
|
46
|
+
tokenSuffix: t.string({ maxLength: 8 }),
|
|
47
|
+
roles: db.default(t.array(t.string()), []),
|
|
48
|
+
lastUsedAt: t.optional(t.datetime()),
|
|
49
|
+
lastUsedIp: t.optional(t.string({ maxLength: 45 })),
|
|
50
|
+
usageCount: db.default(t.integer(), 0),
|
|
51
|
+
expiresAt: t.optional(t.datetime()),
|
|
52
|
+
revokedAt: t.optional(t.datetime())
|
|
53
|
+
}),
|
|
54
|
+
indexes: [{
|
|
55
|
+
columns: ["userId", "name"],
|
|
56
|
+
unique: true
|
|
57
|
+
}, {
|
|
58
|
+
columns: ["tokenHash"],
|
|
59
|
+
unique: true
|
|
60
|
+
}]
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region ../../src/api/keys/services/ApiKeyService.ts
|
|
65
|
+
var ApiKeyService = class {
|
|
66
|
+
alepha = $inject(Alepha);
|
|
67
|
+
dateTimeProvider = $inject(DateTimeProvider);
|
|
68
|
+
log = $logger();
|
|
69
|
+
repo = $repository(apiKeyEntity);
|
|
70
|
+
/**
|
|
71
|
+
* Cache validated API keys for 15 minutes.
|
|
72
|
+
*/
|
|
73
|
+
validationCache = $cache({
|
|
74
|
+
name: "api-key-validation",
|
|
75
|
+
ttl: [15, "minutes"]
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* Create an issuer resolver for API key authentication.
|
|
79
|
+
* Lower priority means it runs before JWT resolver.
|
|
80
|
+
*
|
|
81
|
+
* @param options.priority - Priority of this resolver (default: 50, JWT is 100)
|
|
82
|
+
* @param options.prefix - API key prefix to match in Bearer header (default: "ak")
|
|
83
|
+
*/
|
|
84
|
+
createResolver(options = {}) {
|
|
85
|
+
const { priority = 50, prefix = "ak" } = options;
|
|
86
|
+
const prefixPattern = `${prefix}_`;
|
|
87
|
+
return {
|
|
88
|
+
priority,
|
|
89
|
+
onRequest: async (req) => {
|
|
90
|
+
let token = (typeof req.url === "string" ? new URL(req.url) : req.url).searchParams.get("api_key");
|
|
91
|
+
if (!token) {
|
|
92
|
+
const auth = req.headers.authorization;
|
|
93
|
+
if (auth?.startsWith("Bearer ")) {
|
|
94
|
+
const bearerToken = auth.slice(7);
|
|
95
|
+
if (bearerToken.startsWith(prefixPattern)) token = bearerToken;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!token) return null;
|
|
99
|
+
return this.validate(token);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Create a new API key for a user.
|
|
105
|
+
* Returns both the API key entity and the plain token (which is only available once).
|
|
106
|
+
*/
|
|
107
|
+
async create(options) {
|
|
108
|
+
const prefix = options.prefix ?? "ak";
|
|
109
|
+
const token = `${prefix}_${randomBytes(24).toString("base64url")}`;
|
|
110
|
+
const hash = this.hashToken(token);
|
|
111
|
+
const suffix = token.slice(-8);
|
|
112
|
+
const apiKey = await this.repo.create({
|
|
113
|
+
userId: options.userId,
|
|
114
|
+
name: options.name,
|
|
115
|
+
description: options.description,
|
|
116
|
+
tokenHash: hash,
|
|
117
|
+
tokenPrefix: prefix,
|
|
118
|
+
tokenSuffix: suffix,
|
|
119
|
+
roles: options.roles,
|
|
120
|
+
expiresAt: options.expiresAt?.toISOString()
|
|
121
|
+
});
|
|
122
|
+
this.log.info("API key created", {
|
|
123
|
+
apiKeyId: apiKey.id,
|
|
124
|
+
userId: options.userId,
|
|
125
|
+
name: options.name
|
|
126
|
+
});
|
|
127
|
+
return {
|
|
128
|
+
apiKey,
|
|
129
|
+
token
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* List all non-revoked API keys for a user.
|
|
134
|
+
*/
|
|
135
|
+
async list(userId) {
|
|
136
|
+
return this.repo.findMany({
|
|
137
|
+
where: {
|
|
138
|
+
userId: { eq: userId },
|
|
139
|
+
revokedAt: { isNull: true }
|
|
140
|
+
},
|
|
141
|
+
orderBy: {
|
|
142
|
+
column: "createdAt",
|
|
143
|
+
direction: "desc"
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Find all API keys with optional filtering (admin only).
|
|
149
|
+
*/
|
|
150
|
+
async findAll(query) {
|
|
151
|
+
query.sort ??= "-createdAt";
|
|
152
|
+
const where = this.repo.createQueryWhere();
|
|
153
|
+
if (query.userId) where.userId = { eq: query.userId };
|
|
154
|
+
if (!query.includeRevoked) where.revokedAt = { isNull: true };
|
|
155
|
+
return this.repo.paginate(query, { where }, { count: true });
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Get an API key by ID (admin only).
|
|
159
|
+
*/
|
|
160
|
+
async getById(id) {
|
|
161
|
+
const apiKey = await this.repo.findById(id).catch(() => null);
|
|
162
|
+
if (!apiKey) throw new NotFoundError("API key not found");
|
|
163
|
+
return apiKey;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Revoke any API key (admin only).
|
|
167
|
+
*/
|
|
168
|
+
async revokeByAdmin(id) {
|
|
169
|
+
const apiKey = await this.repo.findById(id).catch(() => null);
|
|
170
|
+
if (!apiKey) throw new NotFoundError("API key not found");
|
|
171
|
+
if (apiKey.revokedAt) return;
|
|
172
|
+
await this.validationCache.invalidate(apiKey.tokenHash);
|
|
173
|
+
await this.repo.updateById(id, { revokedAt: this.dateTimeProvider.now().toISOString() });
|
|
174
|
+
this.log.info("API key revoked by admin", {
|
|
175
|
+
apiKeyId: id,
|
|
176
|
+
userId: apiKey.userId
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Revoke an API key. Only the owner can revoke their own keys.
|
|
181
|
+
*/
|
|
182
|
+
async revoke(id, userId) {
|
|
183
|
+
const apiKey = await this.repo.findById(id).catch(() => null);
|
|
184
|
+
if (!apiKey) throw new NotFoundError("API key not found");
|
|
185
|
+
if (apiKey.userId !== userId) throw new ForbiddenError("Not your API key");
|
|
186
|
+
await this.validationCache.invalidate(apiKey.tokenHash);
|
|
187
|
+
await this.repo.updateById(id, { revokedAt: this.dateTimeProvider.now().toISOString() });
|
|
188
|
+
this.log.info("API key revoked", {
|
|
189
|
+
apiKeyId: id,
|
|
190
|
+
userId
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Validate an API key token and return user info if valid.
|
|
195
|
+
*/
|
|
196
|
+
async validate(token) {
|
|
197
|
+
if (!token.includes("_")) return null;
|
|
198
|
+
const hash = this.hashToken(token);
|
|
199
|
+
let apiKey = await this.validationCache.get(hash);
|
|
200
|
+
if (apiKey === void 0) {
|
|
201
|
+
apiKey = await this.repo.findOne({ where: { tokenHash: { eq: hash } } }).catch(() => null);
|
|
202
|
+
if (apiKey) await this.validationCache.set(hash, apiKey);
|
|
203
|
+
}
|
|
204
|
+
if (!apiKey) return null;
|
|
205
|
+
if (apiKey.revokedAt) return null;
|
|
206
|
+
if (apiKey.expiresAt && this.dateTimeProvider.now().isAfter(apiKey.expiresAt)) return null;
|
|
207
|
+
this.updateUsage(apiKey.id).catch((error) => {
|
|
208
|
+
this.log.warn("Failed to update API key usage", { error });
|
|
209
|
+
});
|
|
210
|
+
return {
|
|
211
|
+
id: apiKey.userId,
|
|
212
|
+
roles: apiKey.roles
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Update usage statistics for an API key.
|
|
217
|
+
*/
|
|
218
|
+
async updateUsage(id) {
|
|
219
|
+
const request = this.alepha.context.get("request");
|
|
220
|
+
await this.repo.updateById(id, {
|
|
221
|
+
lastUsedAt: this.dateTimeProvider.now().toISOString(),
|
|
222
|
+
lastUsedIp: request?.ip,
|
|
223
|
+
usageCount: sql`${this.repo.table.usageCount} + 1`
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Hash a token using SHA-256.
|
|
228
|
+
*/
|
|
229
|
+
hashToken(token) {
|
|
230
|
+
return createHash("sha256").update(token).digest("hex");
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region ../../src/api/keys/controllers/AdminApiKeyController.ts
|
|
236
|
+
/**
|
|
237
|
+
* REST API controller for admin API key management.
|
|
238
|
+
* Admins can list, view, and revoke any API key.
|
|
239
|
+
*/
|
|
240
|
+
var AdminApiKeyController = class {
|
|
241
|
+
url = "/admin/api-keys";
|
|
242
|
+
group = "admin:api-keys";
|
|
243
|
+
apiKeyService = $inject(ApiKeyService);
|
|
244
|
+
/**
|
|
245
|
+
* Find all API keys with optional filtering.
|
|
246
|
+
*/
|
|
247
|
+
findApiKeys = $action({
|
|
248
|
+
path: this.url,
|
|
249
|
+
group: this.group,
|
|
250
|
+
secure: true,
|
|
251
|
+
description: "Find API keys with pagination and filtering",
|
|
252
|
+
schema: {
|
|
253
|
+
query: adminApiKeyQuerySchema,
|
|
254
|
+
response: t.page(adminApiKeyResourceSchema)
|
|
255
|
+
},
|
|
256
|
+
handler: ({ query }) => {
|
|
257
|
+
const { userId, includeRevoked, ...pagination } = query;
|
|
258
|
+
return this.apiKeyService.findAll({
|
|
259
|
+
userId,
|
|
260
|
+
includeRevoked,
|
|
261
|
+
...pagination
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
/**
|
|
266
|
+
* Get an API key by ID.
|
|
267
|
+
*/
|
|
268
|
+
getApiKey = $action({
|
|
269
|
+
path: `${this.url}/:id`,
|
|
270
|
+
group: this.group,
|
|
271
|
+
secure: true,
|
|
272
|
+
description: "Get an API key by ID",
|
|
273
|
+
schema: {
|
|
274
|
+
params: t.object({ id: t.uuid() }),
|
|
275
|
+
response: adminApiKeyResourceSchema
|
|
276
|
+
},
|
|
277
|
+
handler: ({ params }) => this.apiKeyService.getById(params.id)
|
|
278
|
+
});
|
|
279
|
+
/**
|
|
280
|
+
* Revoke any API key.
|
|
281
|
+
*/
|
|
282
|
+
revokeApiKey = $action({
|
|
283
|
+
method: "DELETE",
|
|
284
|
+
path: `${this.url}/:id`,
|
|
285
|
+
group: this.group,
|
|
286
|
+
secure: true,
|
|
287
|
+
description: "Revoke an API key",
|
|
288
|
+
schema: {
|
|
289
|
+
params: t.object({ id: t.uuid() }),
|
|
290
|
+
response: okSchema
|
|
291
|
+
},
|
|
292
|
+
handler: async ({ params }) => {
|
|
293
|
+
await this.apiKeyService.revokeByAdmin(params.id);
|
|
294
|
+
return {
|
|
295
|
+
ok: true,
|
|
296
|
+
id: params.id
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region ../../src/api/keys/schemas/createApiKeyBodySchema.ts
|
|
304
|
+
const createApiKeyBodySchema = t.object({
|
|
305
|
+
name: t.text({
|
|
306
|
+
minLength: 1,
|
|
307
|
+
maxLength: 100
|
|
308
|
+
}),
|
|
309
|
+
description: t.optional(t.text({ maxLength: 500 })),
|
|
310
|
+
expiresAt: t.optional(t.datetime())
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region ../../src/api/keys/schemas/createApiKeyResponseSchema.ts
|
|
315
|
+
const createApiKeyResponseSchema = t.object({
|
|
316
|
+
id: t.uuid(),
|
|
317
|
+
name: t.string(),
|
|
318
|
+
token: t.string(),
|
|
319
|
+
tokenSuffix: t.string(),
|
|
320
|
+
roles: t.array(t.string()),
|
|
321
|
+
createdAt: t.datetime(),
|
|
322
|
+
expiresAt: t.optional(t.datetime())
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region ../../src/api/keys/schemas/listApiKeyResponseSchema.ts
|
|
327
|
+
const listApiKeyItemSchema = t.object({
|
|
328
|
+
id: t.uuid(),
|
|
329
|
+
name: t.string(),
|
|
330
|
+
tokenPrefix: t.string(),
|
|
331
|
+
tokenSuffix: t.string(),
|
|
332
|
+
roles: t.array(t.string()),
|
|
333
|
+
createdAt: t.datetime(),
|
|
334
|
+
lastUsedAt: t.optional(t.datetime()),
|
|
335
|
+
expiresAt: t.optional(t.datetime()),
|
|
336
|
+
usageCount: t.integer()
|
|
337
|
+
});
|
|
338
|
+
const listApiKeyResponseSchema = t.array(listApiKeyItemSchema);
|
|
339
|
+
|
|
340
|
+
//#endregion
|
|
341
|
+
//#region ../../src/api/keys/schemas/revokeApiKeyParamsSchema.ts
|
|
342
|
+
const revokeApiKeyParamsSchema = t.object({ id: t.uuid() });
|
|
343
|
+
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region ../../src/api/keys/schemas/revokeApiKeyResponseSchema.ts
|
|
346
|
+
const revokeApiKeyResponseSchema = t.object({ ok: t.boolean() });
|
|
347
|
+
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region ../../src/api/keys/controllers/ApiKeyController.ts
|
|
350
|
+
/**
|
|
351
|
+
* REST API controller for user's own API key management.
|
|
352
|
+
* Users can create, list, and revoke their own API keys.
|
|
353
|
+
*/
|
|
354
|
+
var ApiKeyController = class {
|
|
355
|
+
url = "/api-keys";
|
|
356
|
+
group = "api-keys";
|
|
357
|
+
apiKeyService = $inject(ApiKeyService);
|
|
358
|
+
/**
|
|
359
|
+
* Create a new API key for the authenticated user.
|
|
360
|
+
* The token is only returned once upon creation.
|
|
361
|
+
*/
|
|
362
|
+
createApiKey = $action({
|
|
363
|
+
method: "POST",
|
|
364
|
+
path: this.url,
|
|
365
|
+
group: this.group,
|
|
366
|
+
description: "Create a new API key",
|
|
367
|
+
secure: true,
|
|
368
|
+
schema: {
|
|
369
|
+
body: createApiKeyBodySchema,
|
|
370
|
+
response: createApiKeyResponseSchema
|
|
371
|
+
},
|
|
372
|
+
handler: async (request) => {
|
|
373
|
+
const { apiKey, token } = await this.apiKeyService.create({
|
|
374
|
+
userId: request.user.id,
|
|
375
|
+
name: request.body.name,
|
|
376
|
+
description: request.body.description,
|
|
377
|
+
roles: request.user.roles ?? [],
|
|
378
|
+
expiresAt: request.body.expiresAt ? new Date(request.body.expiresAt) : void 0
|
|
379
|
+
});
|
|
380
|
+
return {
|
|
381
|
+
id: apiKey.id,
|
|
382
|
+
name: apiKey.name,
|
|
383
|
+
token,
|
|
384
|
+
tokenSuffix: apiKey.tokenSuffix,
|
|
385
|
+
roles: apiKey.roles,
|
|
386
|
+
createdAt: apiKey.createdAt,
|
|
387
|
+
expiresAt: apiKey.expiresAt
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
/**
|
|
392
|
+
* List all active API keys for the authenticated user.
|
|
393
|
+
* Does not return the actual tokens.
|
|
394
|
+
*/
|
|
395
|
+
listApiKeys = $action({
|
|
396
|
+
path: this.url,
|
|
397
|
+
group: this.group,
|
|
398
|
+
description: "List your API keys",
|
|
399
|
+
secure: true,
|
|
400
|
+
schema: { response: listApiKeyResponseSchema },
|
|
401
|
+
handler: async (request) => {
|
|
402
|
+
return (await this.apiKeyService.list(request.user.id)).map((apiKey) => ({
|
|
403
|
+
id: apiKey.id,
|
|
404
|
+
name: apiKey.name,
|
|
405
|
+
tokenPrefix: apiKey.tokenPrefix,
|
|
406
|
+
tokenSuffix: apiKey.tokenSuffix,
|
|
407
|
+
roles: apiKey.roles,
|
|
408
|
+
createdAt: apiKey.createdAt,
|
|
409
|
+
lastUsedAt: apiKey.lastUsedAt,
|
|
410
|
+
expiresAt: apiKey.expiresAt,
|
|
411
|
+
usageCount: apiKey.usageCount
|
|
412
|
+
}));
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
/**
|
|
416
|
+
* Revoke an API key. Only the owner can revoke their own keys.
|
|
417
|
+
*/
|
|
418
|
+
revokeApiKey = $action({
|
|
419
|
+
method: "DELETE",
|
|
420
|
+
path: `${this.url}/:id`,
|
|
421
|
+
group: this.group,
|
|
422
|
+
description: "Revoke an API key",
|
|
423
|
+
secure: true,
|
|
424
|
+
schema: {
|
|
425
|
+
params: revokeApiKeyParamsSchema,
|
|
426
|
+
response: revokeApiKeyResponseSchema
|
|
427
|
+
},
|
|
428
|
+
handler: async (request) => {
|
|
429
|
+
await this.apiKeyService.revoke(request.params.id, request.user.id);
|
|
430
|
+
return { ok: true };
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region ../../src/api/keys/index.ts
|
|
437
|
+
/**
|
|
438
|
+
* | type | quality | stability |
|
|
439
|
+
* |------|---------|--------------|
|
|
440
|
+
* | backend | good | experimental |
|
|
441
|
+
*
|
|
442
|
+
* API key management module for programmatic access.
|
|
443
|
+
*
|
|
444
|
+
* **Features:**
|
|
445
|
+
* - Create API keys with role snapshots
|
|
446
|
+
* - List and revoke API keys
|
|
447
|
+
* - 15-minute validation caching
|
|
448
|
+
* - Query param (?api_key=) and Bearer header support
|
|
449
|
+
*
|
|
450
|
+
* **Integration:**
|
|
451
|
+
* To enable API key authentication for an issuer, register the resolver:
|
|
452
|
+
*
|
|
453
|
+
* ```ts
|
|
454
|
+
* class MyApp {
|
|
455
|
+
* apiKeyService = $inject(ApiKeyService);
|
|
456
|
+
* issuer = $issuer({
|
|
457
|
+
* secret: env.APP_SECRET,
|
|
458
|
+
* resolvers: [this.apiKeyService.createResolver()],
|
|
459
|
+
* });
|
|
460
|
+
* }
|
|
461
|
+
* ```
|
|
462
|
+
*
|
|
463
|
+
* @module alepha.api.keys
|
|
464
|
+
*/
|
|
465
|
+
const AlephaApiKeys = $module({
|
|
466
|
+
name: "alepha.api.keys",
|
|
467
|
+
services: [
|
|
468
|
+
ApiKeyService,
|
|
469
|
+
ApiKeyController,
|
|
470
|
+
AdminApiKeyController
|
|
471
|
+
]
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
//#endregion
|
|
475
|
+
export { AdminApiKeyController, AlephaApiKeys, ApiKeyController, ApiKeyService, adminApiKeyQuerySchema, adminApiKeyResourceSchema, apiKeyEntity, createApiKeyBodySchema, createApiKeyResponseSchema, listApiKeyItemSchema, listApiKeyResponseSchema, revokeApiKeyParamsSchema, revokeApiKeyResponseSchema };
|
|
476
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/api/keys/schemas/adminApiKeyQuerySchema.ts","../../../src/api/keys/schemas/adminApiKeyResourceSchema.ts","../../../src/api/keys/entities/apiKeyEntity.ts","../../../src/api/keys/services/ApiKeyService.ts","../../../src/api/keys/controllers/AdminApiKeyController.ts","../../../src/api/keys/schemas/createApiKeyBodySchema.ts","../../../src/api/keys/schemas/createApiKeyResponseSchema.ts","../../../src/api/keys/schemas/listApiKeyResponseSchema.ts","../../../src/api/keys/schemas/revokeApiKeyParamsSchema.ts","../../../src/api/keys/schemas/revokeApiKeyResponseSchema.ts","../../../src/api/keys/controllers/ApiKeyController.ts","../../../src/api/keys/index.ts"],"sourcesContent":["import { t } from \"alepha\";\nimport { pageQuerySchema } from \"alepha/orm\";\n\nexport const adminApiKeyQuerySchema = t.extend(pageQuerySchema, {\n userId: t.optional(t.uuid()),\n includeRevoked: t.optional(t.boolean()),\n});\n","import { t } from \"alepha\";\n\nexport const adminApiKeyResourceSchema = t.object({\n id: t.uuid(),\n userId: t.uuid(),\n name: t.string(),\n description: t.optional(t.string()),\n tokenPrefix: t.string(),\n tokenSuffix: t.string(),\n roles: t.array(t.string()),\n createdAt: t.datetime(),\n lastUsedAt: t.optional(t.datetime()),\n lastUsedIp: t.optional(t.string()),\n expiresAt: t.optional(t.datetime()),\n revokedAt: t.optional(t.datetime()),\n usageCount: t.integer(),\n});\n","import { type Static, t } from \"alepha\";\nimport { $entity, db } from \"alepha/orm\";\n\nexport const apiKeyEntity = $entity({\n name: \"api_keys\",\n schema: t.object({\n id: db.primaryKey(t.uuid()),\n createdAt: db.createdAt(),\n updatedAt: db.updatedAt(),\n\n // Owner\n userId: t.uuid(),\n\n // Key metadata\n name: t.text({ maxLength: 100 }),\n description: t.optional(t.text({ maxLength: 500 })),\n\n // Token (hashed) - internal, not user input\n tokenHash: t.string({ maxLength: 256 }),\n tokenPrefix: t.string({ maxLength: 10 }),\n tokenSuffix: t.string({ maxLength: 8 }),\n\n // Roles (snapshot from user at creation)\n roles: db.default(t.array(t.string()), []),\n\n // Tracking\n lastUsedAt: t.optional(t.datetime()),\n lastUsedIp: t.optional(t.string({ maxLength: 45 })),\n usageCount: db.default(t.integer(), 0),\n\n // Lifecycle\n expiresAt: t.optional(t.datetime()),\n revokedAt: t.optional(t.datetime()),\n }),\n indexes: [\n { columns: [\"userId\", \"name\"], unique: true },\n { columns: [\"tokenHash\"], unique: true },\n ],\n});\n\nexport type ApiKeyEntity = Static<typeof apiKeyEntity.schema>;\n","import { createHash, randomBytes } from \"node:crypto\";\nimport { $inject, Alepha } from \"alepha\";\nimport { $cache } from \"alepha/cache\";\nimport { DateTimeProvider } from \"alepha/datetime\";\nimport { $logger } from \"alepha/logger\";\nimport { $repository, sql } from \"alepha/orm\";\nimport type { IssuerResolver, UserInfo } from \"alepha/security\";\nimport {\n ForbiddenError,\n NotFoundError,\n type ServerRequest,\n} from \"alepha/server\";\nimport { type ApiKeyEntity, apiKeyEntity } from \"../entities/apiKeyEntity.ts\";\n\nexport class ApiKeyService {\n protected readonly alepha = $inject(Alepha);\n protected readonly dateTimeProvider = $inject(DateTimeProvider);\n protected readonly log = $logger();\n protected readonly repo = $repository(apiKeyEntity);\n\n /**\n * Cache validated API keys for 15 minutes.\n */\n protected readonly validationCache = $cache<ApiKeyEntity | null, [string]>({\n name: \"api-key-validation\",\n ttl: [15, \"minutes\"],\n });\n\n // -------------------------------------------------------------------------\n // Resolver\n // -------------------------------------------------------------------------\n\n /**\n * Create an issuer resolver for API key authentication.\n * Lower priority means it runs before JWT resolver.\n *\n * @param options.priority - Priority of this resolver (default: 50, JWT is 100)\n * @param options.prefix - API key prefix to match in Bearer header (default: \"ak\")\n */\n public createResolver(\n options: { priority?: number; prefix?: string } = {},\n ): IssuerResolver {\n const { priority = 50, prefix = \"ak\" } = options;\n const prefixPattern = `${prefix}_`;\n\n return {\n priority,\n onRequest: async (req: ServerRequest) => {\n // Try query param first\n const url = typeof req.url === \"string\" ? new URL(req.url) : req.url;\n let token = url.searchParams.get(\"api_key\");\n\n // Try Bearer header - only if token starts with expected prefix\n if (!token) {\n const auth = req.headers.authorization;\n if (auth?.startsWith(\"Bearer \")) {\n const bearerToken = auth.slice(7);\n if (bearerToken.startsWith(prefixPattern)) {\n token = bearerToken;\n }\n }\n }\n\n if (!token) {\n return null;\n }\n\n return this.validate(token);\n },\n };\n }\n\n // -------------------------------------------------------------------------\n // CRUD\n // -------------------------------------------------------------------------\n\n /**\n * Create a new API key for a user.\n * Returns both the API key entity and the plain token (which is only available once).\n */\n public async create(options: {\n userId: string;\n name: string;\n roles: string[];\n description?: string;\n expiresAt?: Date;\n prefix?: string;\n }): Promise<{ apiKey: ApiKeyEntity; token: string }> {\n const prefix = options.prefix ?? \"ak\";\n const random = randomBytes(24).toString(\"base64url\");\n const token = `${prefix}_${random}`;\n const hash = this.hashToken(token);\n const suffix = token.slice(-8);\n\n const apiKey = await this.repo.create({\n userId: options.userId,\n name: options.name,\n description: options.description,\n tokenHash: hash,\n tokenPrefix: prefix,\n tokenSuffix: suffix,\n roles: options.roles,\n expiresAt: options.expiresAt?.toISOString(),\n });\n\n this.log.info(\"API key created\", {\n apiKeyId: apiKey.id,\n userId: options.userId,\n name: options.name,\n });\n\n return { apiKey, token };\n }\n\n /**\n * List all non-revoked API keys for a user.\n */\n public async list(userId: string): Promise<ApiKeyEntity[]> {\n return this.repo.findMany({\n where: {\n userId: { eq: userId },\n revokedAt: { isNull: true },\n },\n orderBy: { column: \"createdAt\", direction: \"desc\" },\n });\n }\n\n // -------------------------------------------------------------------------\n // Admin Operations\n // -------------------------------------------------------------------------\n\n /**\n * Find all API keys with optional filtering (admin only).\n */\n public async findAll(query: {\n userId?: string;\n includeRevoked?: boolean;\n page?: number;\n size?: number;\n sort?: string;\n }) {\n query.sort ??= \"-createdAt\";\n\n const where = this.repo.createQueryWhere();\n\n if (query.userId) {\n where.userId = { eq: query.userId };\n }\n\n if (!query.includeRevoked) {\n where.revokedAt = { isNull: true };\n }\n\n return this.repo.paginate(query, { where }, { count: true });\n }\n\n /**\n * Get an API key by ID (admin only).\n */\n public async getById(id: string): Promise<ApiKeyEntity> {\n const apiKey = await this.repo.findById(id).catch(() => null);\n\n if (!apiKey) {\n throw new NotFoundError(\"API key not found\");\n }\n\n return apiKey;\n }\n\n /**\n * Revoke any API key (admin only).\n */\n public async revokeByAdmin(id: string): Promise<void> {\n const apiKey = await this.repo.findById(id).catch(() => null);\n\n if (!apiKey) {\n throw new NotFoundError(\"API key not found\");\n }\n\n if (apiKey.revokedAt) {\n return; // Already revoked\n }\n\n // Invalidate cache\n await this.validationCache.invalidate(apiKey.tokenHash);\n\n await this.repo.updateById(id, {\n revokedAt: this.dateTimeProvider.now().toISOString(),\n });\n\n this.log.info(\"API key revoked by admin\", {\n apiKeyId: id,\n userId: apiKey.userId,\n });\n }\n\n // -------------------------------------------------------------------------\n // User Operations\n // -------------------------------------------------------------------------\n\n /**\n * Revoke an API key. Only the owner can revoke their own keys.\n */\n public async revoke(id: string, userId: string): Promise<void> {\n const apiKey = await this.repo.findById(id).catch(() => null);\n\n if (!apiKey) {\n throw new NotFoundError(\"API key not found\");\n }\n\n if (apiKey.userId !== userId) {\n throw new ForbiddenError(\"Not your API key\");\n }\n\n await this.validationCache.invalidate(apiKey.tokenHash);\n\n await this.repo.updateById(id, {\n revokedAt: this.dateTimeProvider.now().toISOString(),\n });\n\n this.log.info(\"API key revoked\", {\n apiKeyId: id,\n userId,\n });\n }\n\n // -------------------------------------------------------------------------\n // Validation\n // -------------------------------------------------------------------------\n\n /**\n * Validate an API key token and return user info if valid.\n */\n public async validate(token: string): Promise<UserInfo | null> {\n // Quick check for API key format\n if (!token.includes(\"_\")) {\n return null;\n }\n\n const hash = this.hashToken(token);\n\n // Try cache first\n let apiKey = await this.validationCache.get(hash);\n\n // If not in cache, look up in database\n if (apiKey === undefined) {\n apiKey = await this.repo\n .findOne({\n where: { tokenHash: { eq: hash } },\n })\n .catch(() => null);\n\n // Store in cache (even if null, to prevent repeated lookups)\n if (apiKey) {\n await this.validationCache.set(hash, apiKey);\n }\n }\n\n if (!apiKey) {\n return null;\n }\n\n // Check revocation\n if (apiKey.revokedAt) {\n return null;\n }\n\n // Check expiration\n if (\n apiKey.expiresAt &&\n this.dateTimeProvider.now().isAfter(apiKey.expiresAt)\n ) {\n return null;\n }\n\n // Update usage stats (fire and forget)\n this.updateUsage(apiKey.id).catch((error) => {\n this.log.warn(\"Failed to update API key usage\", { error });\n });\n\n return {\n id: apiKey.userId,\n roles: apiKey.roles,\n };\n }\n\n /**\n * Update usage statistics for an API key.\n */\n protected async updateUsage(id: string): Promise<void> {\n const request = this.alepha.context.get<ServerRequest>(\"request\");\n\n await this.repo.updateById(id, {\n lastUsedAt: this.dateTimeProvider.now().toISOString(),\n lastUsedIp: request?.ip,\n usageCount: sql`${this.repo.table.usageCount} + 1`,\n });\n }\n\n /**\n * Hash a token using SHA-256.\n */\n protected hashToken(token: string): string {\n return createHash(\"sha256\").update(token).digest(\"hex\");\n }\n}\n","import { $inject, t } from \"alepha\";\nimport { $action, okSchema } from \"alepha/server\";\nimport { adminApiKeyQuerySchema } from \"../schemas/adminApiKeyQuerySchema.ts\";\nimport { adminApiKeyResourceSchema } from \"../schemas/adminApiKeyResourceSchema.ts\";\nimport { ApiKeyService } from \"../services/ApiKeyService.ts\";\n\n/**\n * REST API controller for admin API key management.\n * Admins can list, view, and revoke any API key.\n */\nexport class AdminApiKeyController {\n protected readonly url = \"/admin/api-keys\";\n protected readonly group = \"admin:api-keys\";\n protected readonly apiKeyService = $inject(ApiKeyService);\n\n /**\n * Find all API keys with optional filtering.\n */\n public readonly findApiKeys = $action({\n path: this.url,\n group: this.group,\n secure: true,\n description: \"Find API keys with pagination and filtering\",\n schema: {\n query: adminApiKeyQuerySchema,\n response: t.page(adminApiKeyResourceSchema),\n },\n handler: ({ query }) => {\n const { userId, includeRevoked, ...pagination } = query;\n return this.apiKeyService.findAll({\n userId,\n includeRevoked,\n ...pagination,\n });\n },\n });\n\n /**\n * Get an API key by ID.\n */\n public readonly getApiKey = $action({\n path: `${this.url}/:id`,\n group: this.group,\n secure: true,\n description: \"Get an API key by ID\",\n schema: {\n params: t.object({\n id: t.uuid(),\n }),\n response: adminApiKeyResourceSchema,\n },\n handler: ({ params }) => this.apiKeyService.getById(params.id),\n });\n\n /**\n * Revoke any API key.\n */\n public readonly revokeApiKey = $action({\n method: \"DELETE\",\n path: `${this.url}/:id`,\n group: this.group,\n secure: true,\n description: \"Revoke an API key\",\n schema: {\n params: t.object({\n id: t.uuid(),\n }),\n response: okSchema,\n },\n handler: async ({ params }) => {\n await this.apiKeyService.revokeByAdmin(params.id);\n return { ok: true, id: params.id };\n },\n });\n}\n","import { t } from \"alepha\";\n\nexport const createApiKeyBodySchema = t.object({\n name: t.text({ minLength: 1, maxLength: 100 }),\n description: t.optional(t.text({ maxLength: 500 })),\n expiresAt: t.optional(t.datetime()),\n});\n","import { t } from \"alepha\";\n\nexport const createApiKeyResponseSchema = t.object({\n id: t.uuid(),\n name: t.string(),\n token: t.string(),\n tokenSuffix: t.string(),\n roles: t.array(t.string()),\n createdAt: t.datetime(),\n expiresAt: t.optional(t.datetime()),\n});\n","import { t } from \"alepha\";\n\nexport const listApiKeyItemSchema = t.object({\n id: t.uuid(),\n name: t.string(),\n tokenPrefix: t.string(),\n tokenSuffix: t.string(),\n roles: t.array(t.string()),\n createdAt: t.datetime(),\n lastUsedAt: t.optional(t.datetime()),\n expiresAt: t.optional(t.datetime()),\n usageCount: t.integer(),\n});\n\nexport const listApiKeyResponseSchema = t.array(listApiKeyItemSchema);\n","import { t } from \"alepha\";\n\nexport const revokeApiKeyParamsSchema = t.object({\n id: t.uuid(),\n});\n","import { t } from \"alepha\";\n\nexport const revokeApiKeyResponseSchema = t.object({\n ok: t.boolean(),\n});\n","import { $inject } from \"alepha\";\nimport { $action } from \"alepha/server\";\nimport { createApiKeyBodySchema } from \"../schemas/createApiKeyBodySchema.ts\";\nimport { createApiKeyResponseSchema } from \"../schemas/createApiKeyResponseSchema.ts\";\nimport { listApiKeyResponseSchema } from \"../schemas/listApiKeyResponseSchema.ts\";\nimport { revokeApiKeyParamsSchema } from \"../schemas/revokeApiKeyParamsSchema.ts\";\nimport { revokeApiKeyResponseSchema } from \"../schemas/revokeApiKeyResponseSchema.ts\";\nimport { ApiKeyService } from \"../services/ApiKeyService.ts\";\n\n/**\n * REST API controller for user's own API key management.\n * Users can create, list, and revoke their own API keys.\n */\nexport class ApiKeyController {\n protected readonly url = \"/api-keys\";\n protected readonly group = \"api-keys\";\n protected readonly apiKeyService = $inject(ApiKeyService);\n\n /**\n * Create a new API key for the authenticated user.\n * The token is only returned once upon creation.\n */\n public readonly createApiKey = $action({\n method: \"POST\",\n path: this.url,\n group: this.group,\n description: \"Create a new API key\",\n secure: true,\n schema: {\n body: createApiKeyBodySchema,\n response: createApiKeyResponseSchema,\n },\n handler: async (request) => {\n const { apiKey, token } = await this.apiKeyService.create({\n userId: request.user.id,\n name: request.body.name,\n description: request.body.description,\n roles: request.user.roles ?? [],\n expiresAt: request.body.expiresAt\n ? new Date(request.body.expiresAt)\n : undefined,\n });\n\n return {\n id: apiKey.id,\n name: apiKey.name,\n token,\n tokenSuffix: apiKey.tokenSuffix,\n roles: apiKey.roles,\n createdAt: apiKey.createdAt,\n expiresAt: apiKey.expiresAt,\n };\n },\n });\n\n /**\n * List all active API keys for the authenticated user.\n * Does not return the actual tokens.\n */\n public readonly listApiKeys = $action({\n path: this.url,\n group: this.group,\n description: \"List your API keys\",\n secure: true,\n schema: {\n response: listApiKeyResponseSchema,\n },\n handler: async (request) => {\n const apiKeys = await this.apiKeyService.list(request.user.id);\n\n return apiKeys.map((apiKey) => ({\n id: apiKey.id,\n name: apiKey.name,\n tokenPrefix: apiKey.tokenPrefix,\n tokenSuffix: apiKey.tokenSuffix,\n roles: apiKey.roles,\n createdAt: apiKey.createdAt,\n lastUsedAt: apiKey.lastUsedAt,\n expiresAt: apiKey.expiresAt,\n usageCount: apiKey.usageCount,\n }));\n },\n });\n\n /**\n * Revoke an API key. Only the owner can revoke their own keys.\n */\n public readonly revokeApiKey = $action({\n method: \"DELETE\",\n path: `${this.url}/:id`,\n group: this.group,\n description: \"Revoke an API key\",\n secure: true,\n schema: {\n params: revokeApiKeyParamsSchema,\n response: revokeApiKeyResponseSchema,\n },\n handler: async (request) => {\n await this.apiKeyService.revoke(request.params.id, request.user.id);\n return { ok: true };\n },\n });\n}\n","import { $module } from \"alepha\";\nimport { AdminApiKeyController } from \"./controllers/AdminApiKeyController.ts\";\nimport { ApiKeyController } from \"./controllers/ApiKeyController.ts\";\nimport { ApiKeyService } from \"./services/ApiKeyService.ts\";\n\nexport * from \"./controllers/AdminApiKeyController.ts\";\nexport * from \"./controllers/ApiKeyController.ts\";\nexport * from \"./entities/apiKeyEntity.ts\";\nexport * from \"./schemas/adminApiKeyQuerySchema.ts\";\nexport * from \"./schemas/adminApiKeyResourceSchema.ts\";\nexport * from \"./schemas/createApiKeyBodySchema.ts\";\nexport * from \"./schemas/createApiKeyResponseSchema.ts\";\nexport * from \"./schemas/listApiKeyResponseSchema.ts\";\nexport * from \"./schemas/revokeApiKeyParamsSchema.ts\";\nexport * from \"./schemas/revokeApiKeyResponseSchema.ts\";\nexport * from \"./services/ApiKeyService.ts\";\n\n/**\n * | type | quality | stability |\n * |------|---------|--------------|\n * | backend | good | experimental |\n *\n * API key management module for programmatic access.\n *\n * **Features:**\n * - Create API keys with role snapshots\n * - List and revoke API keys\n * - 15-minute validation caching\n * - Query param (?api_key=) and Bearer header support\n *\n * **Integration:**\n * To enable API key authentication for an issuer, register the resolver:\n *\n * ```ts\n * class MyApp {\n * apiKeyService = $inject(ApiKeyService);\n * issuer = $issuer({\n * secret: env.APP_SECRET,\n * resolvers: [this.apiKeyService.createResolver()],\n * });\n * }\n * ```\n *\n * @module alepha.api.keys\n */\nexport const AlephaApiKeys = $module({\n name: \"alepha.api.keys\",\n services: [ApiKeyService, ApiKeyController, AdminApiKeyController],\n});\n"],"mappings":";;;;;;;;;AAGA,MAAa,yBAAyB,EAAE,OAAO,iBAAiB;CAC9D,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;CAC5B,gBAAgB,EAAE,SAAS,EAAE,SAAS,CAAC;CACxC,CAAC;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-553,12 +553,18 @@ type NotificationContactPreferences = Static<typeof notificationContactPreferenc
|
|
|
553
553
|
//#endregion
|
|
554
554
|
//#region ../../src/api/notifications/index.d.ts
|
|
555
555
|
/**
|
|
556
|
-
*
|
|
556
|
+
* | type | quality | stability |
|
|
557
|
+
* |------|---------|-----------|
|
|
558
|
+
* | backend | standard | stable |
|
|
557
559
|
*
|
|
558
|
-
*
|
|
559
|
-
* and user notification preferences management.
|
|
560
|
+
* User notification management.
|
|
560
561
|
*
|
|
561
|
-
*
|
|
562
|
+
* **Features:**
|
|
563
|
+
* - Notification definitions
|
|
564
|
+
* - Email/SMS notification sending
|
|
565
|
+
* - Status tracking
|
|
566
|
+
* - User preferences
|
|
567
|
+
* - Queue integration
|
|
562
568
|
*
|
|
563
569
|
* @module alepha.api.notifications
|
|
564
570
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/orm/schemas/insertSchema.ts","../../../src/orm/schemas/updateSchema.ts","../../../src/orm/primitives/$entity.ts","../../../src/orm/constants/PG_SYMBOLS.ts","../../../src/orm/helpers/pgAttr.ts","../../../src/api/notifications/entities/notifications.ts","../../../src/api/notifications/schemas/notificationCreateSchema.ts","../../../src/api/notifications/schemas/notificationQuerySchema.ts","../../../src/api/notifications/primitives/$notification.ts","../../../src/api/notifications/services/NotificationSenderService.ts","../../../src/api/notifications/services/NotificationService.ts","../../../src/api/notifications/controllers/AdminNotificationController.ts","../../../src/api/notifications/jobs/NotificationJobs.ts","../../../src/api/notifications/queues/NotificationQueues.ts","../../../src/api/notifications/schemas/notificationContactPreferencesSchema.ts","../../../src/api/notifications/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;KAaY,aAAA,WAAwB,OAAA,IAAW,OAAA,eACjC,CAAA,iBAAkB,CAAA,eAAgB,CAAA;EAAA,CACvC,UAAA;AAAA;EACD,WAAA;AAAA,IACF,SAAA,CAAU,CAAA,eAAgB,CAAA,KAC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kBAAA,GAAqB,OAAA;AAAA;;;cC3GjD,2BAAA;EAAA,mBACQ,GAAA;EAAA,mBACA,KAAA;EAAA,mBACA,mBAAA,EAAmB,mBAAA;;;;WAKtB,iBAAA,iBAAiB,iBAAA;;gCALK,SAAA,CAAA,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCT3B,gBAAA;;;cCIA,kBAAA;EAAA,mBACQ,yBAAA,EAAyB,yBAAA;EAAA,SAI5B,mBAAA,EAAmB,aAAA,CAAA,cAAA,WAAA,OAAA;oBAJS,SAAA,CAAA,OAAA;EAAA;AAAA;;;cCHjC,oCAAA,YAAoC,OAAA;gCAG/C,SAAA,CAAA,OAAA;;;KAEU,8BAAA,GAAiC,MAAA,QACpC,oCAAA;;;;;;;;;;;;AdKT
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/orm/schemas/insertSchema.ts","../../../src/orm/schemas/updateSchema.ts","../../../src/orm/primitives/$entity.ts","../../../src/orm/constants/PG_SYMBOLS.ts","../../../src/orm/helpers/pgAttr.ts","../../../src/api/notifications/entities/notifications.ts","../../../src/api/notifications/schemas/notificationCreateSchema.ts","../../../src/api/notifications/schemas/notificationQuerySchema.ts","../../../src/api/notifications/primitives/$notification.ts","../../../src/api/notifications/services/NotificationSenderService.ts","../../../src/api/notifications/services/NotificationService.ts","../../../src/api/notifications/controllers/AdminNotificationController.ts","../../../src/api/notifications/jobs/NotificationJobs.ts","../../../src/api/notifications/queues/NotificationQueues.ts","../../../src/api/notifications/schemas/notificationContactPreferencesSchema.ts","../../../src/api/notifications/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;KAaY,aAAA,WAAwB,OAAA,IAAW,OAAA,eACjC,CAAA,iBAAkB,CAAA,eAAgB,CAAA;EAAA,CACvC,UAAA;AAAA;EACD,WAAA;AAAA,IACF,SAAA,CAAU,CAAA,eAAgB,CAAA,KAC1B,CAAA,eAAgB,CAAA;;;;;;;;;;;;KCDV,aA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EAAA,mBACQ,GAAA;EAAA,mBACA,KAAA;EAAA,mBACA,mBAAA,EAAmB,mBAAA;;;;WAKtB,iBAAA,iBAAiB,iBAAA;;gCALK,SAAA,CAAA,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCT3B,gBAAA;;;cCIA,kBAAA;EAAA,mBACQ,yBAAA,EAAyB,yBAAA;EAAA,SAI5B,mBAAA,EAAmB,aAAA,CAAA,cAAA,WAAA,OAAA;oBAJS,SAAA,CAAA,OAAA;EAAA;AAAA;;;cCHjC,oCAAA,YAAoC,OAAA;gCAG/C,SAAA,CAAA,OAAA;;;KAEU,8BAAA,GAAiC,MAAA,QACpC,oCAAA;;;;;;;;;;;;AdKT;;;;;;;ce6Ba,sBAAA,EAAsB,SAAA,CAAA,OAAA,CAsBjC,SAAA,CAtBiC,MAAA"}
|
|
@@ -367,12 +367,18 @@ const notificationContactPreferencesSchema = t.object({
|
|
|
367
367
|
//#endregion
|
|
368
368
|
//#region ../../src/api/notifications/index.ts
|
|
369
369
|
/**
|
|
370
|
-
*
|
|
370
|
+
* | type | quality | stability |
|
|
371
|
+
* |------|---------|-----------|
|
|
372
|
+
* | backend | standard | stable |
|
|
371
373
|
*
|
|
372
|
-
*
|
|
373
|
-
* and user notification preferences management.
|
|
374
|
+
* User notification management.
|
|
374
375
|
*
|
|
375
|
-
*
|
|
376
|
+
* **Features:**
|
|
377
|
+
* - Notification definitions
|
|
378
|
+
* - Email/SMS notification sending
|
|
379
|
+
* - Status tracking
|
|
380
|
+
* - User preferences
|
|
381
|
+
* - Queue integration
|
|
376
382
|
*
|
|
377
383
|
* @module alepha.api.notifications
|
|
378
384
|
*/
|