alepha 0.21.2 → 0.22.0
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 +0 -1
- package/dist/api/audits/index.browser.js.map +1 -1
- package/dist/api/audits/index.d.ts +393 -403
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/audits/index.js +25 -56
- package/dist/api/audits/index.js.map +1 -1
- package/dist/api/files/index.browser.js +31 -1
- package/dist/api/files/index.browser.js.map +1 -1
- package/dist/api/files/index.d.ts +313 -208
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js +152 -42
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.browser.js +2 -2
- package/dist/api/jobs/index.browser.js.map +1 -1
- package/dist/api/jobs/index.d.ts +289 -292
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js +39 -33
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/keys/index.d.ts +211 -216
- package/dist/api/keys/index.d.ts.map +1 -1
- package/dist/api/keys/index.js.map +1 -1
- package/dist/api/notifications/index.browser.js.map +1 -1
- package/dist/api/notifications/index.d.ts +188 -195
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/oauth/index.d.ts +71 -76
- package/dist/api/oauth/index.d.ts.map +1 -1
- package/dist/api/oauth/index.js.map +1 -1
- package/dist/api/organizations/index.browser.js.map +1 -1
- package/dist/api/organizations/index.d.ts +104 -109
- package/dist/api/organizations/index.d.ts.map +1 -1
- package/dist/api/organizations/index.js.map +1 -1
- package/dist/api/parameters/index.browser.js +43 -16
- package/dist/api/parameters/index.browser.js.map +1 -1
- package/dist/api/parameters/index.d.ts +488 -344
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/parameters/index.js +175 -35
- package/dist/api/parameters/index.js.map +1 -1
- package/dist/api/payments/index.d.ts +396 -402
- package/dist/api/payments/index.d.ts.map +1 -1
- package/dist/api/payments/index.js.map +1 -1
- package/dist/api/subscriptions/index.d.ts +644 -652
- package/dist/api/subscriptions/index.d.ts.map +1 -1
- package/dist/api/subscriptions/index.js +1 -1
- package/dist/api/subscriptions/index.js.map +1 -1
- package/dist/api/users/index.browser.js +7 -0
- package/dist/api/users/index.browser.js.map +1 -1
- package/dist/api/users/index.d.ts +1073 -1006
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +283 -61
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.browser.js.map +1 -1
- package/dist/api/verifications/index.d.ts +134 -140
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/api/verifications/index.js.map +1 -1
- package/dist/background/index.d.ts +95 -0
- package/dist/background/index.d.ts.map +1 -0
- package/dist/background/index.js +121 -0
- package/dist/background/index.js.map +1 -0
- package/dist/background/index.workerd.js +110 -0
- package/dist/background/index.workerd.js.map +1 -0
- package/dist/batch/index.d.ts +5 -7
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js.map +1 -1
- package/dist/bin/index.js.map +1 -1
- package/dist/bucket/index.d.ts +76 -54
- package/dist/bucket/index.d.ts.map +1 -1
- package/dist/bucket/index.js +58 -11
- package/dist/bucket/index.js.map +1 -1
- package/dist/bucket/index.workerd.js +200 -5
- package/dist/bucket/index.workerd.js.map +1 -1
- package/dist/cache/core/index.d.ts +7 -10
- package/dist/cache/core/index.d.ts.map +1 -1
- package/dist/cache/core/index.js.map +1 -1
- package/dist/cache/core/index.workerd.js.map +1 -1
- package/dist/cache/database/index.d.ts +22 -26
- package/dist/cache/database/index.d.ts.map +1 -1
- package/dist/cache/database/index.js.map +1 -1
- package/dist/cache/redis/index.d.ts +4 -7
- package/dist/cache/redis/index.d.ts.map +1 -1
- package/dist/cache/redis/index.js.map +1 -1
- package/dist/captcha/index.d.ts +3 -6
- package/dist/captcha/index.d.ts.map +1 -1
- package/dist/captcha/index.js.map +1 -1
- package/dist/cli/config/index.d.ts.map +1 -1
- package/dist/cli/config/index.js.map +1 -1
- package/dist/cli/core/index.d.ts +417 -214
- package/dist/cli/core/index.d.ts.map +1 -1
- package/dist/cli/core/index.js +325 -563
- package/dist/cli/core/index.js.map +1 -1
- package/dist/cli/devtools/index.d.ts +3 -5
- package/dist/cli/devtools/index.d.ts.map +1 -1
- package/dist/cli/devtools/index.js.map +1 -1
- package/dist/cli/i18n/index.d.ts +8 -12
- package/dist/cli/i18n/index.d.ts.map +1 -1
- package/dist/cli/i18n/index.js.map +1 -1
- package/dist/cli/platform/index.d.ts +126 -1342
- package/dist/cli/platform/index.d.ts.map +1 -1
- package/dist/cli/platform/index.js +136 -2374
- package/dist/cli/platform/index.js.map +1 -1
- package/dist/cli/platform-lib/index.d.ts +1446 -0
- package/dist/cli/platform-lib/index.d.ts.map +1 -0
- package/dist/cli/platform-lib/index.js +2597 -0
- package/dist/cli/platform-lib/index.js.map +1 -0
- package/dist/cli/vendor/index.d.ts +17 -21
- package/dist/cli/vendor/index.d.ts.map +1 -1
- package/dist/cli/vendor/index.js.map +1 -1
- package/dist/command/index.d.ts +21 -20
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +39 -10
- package/dist/command/index.js.map +1 -1
- package/dist/{containers → container}/core/index.d.ts +13 -15
- package/dist/container/core/index.d.ts.map +1 -0
- package/dist/{containers → container}/core/index.js +23 -14
- package/dist/container/core/index.js.map +1 -0
- package/dist/{containers → container}/core/index.workerd.js +37 -22
- package/dist/container/core/index.workerd.js.map +1 -0
- package/dist/core/index.browser.js +27 -1
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +48 -24
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +27 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +27 -1
- package/dist/core/index.native.js.map +1 -1
- package/dist/core/index.workerd.js +27 -1
- package/dist/core/index.workerd.js.map +1 -1
- package/dist/crypto/index.browser.js.map +1 -1
- package/dist/crypto/index.d.ts +5 -8
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.js.map +1 -1
- package/dist/datetime/index.d.ts +3 -4
- package/dist/datetime/index.d.ts.map +1 -1
- package/dist/datetime/index.js.map +1 -1
- package/dist/email/brevo/index.d.ts +2 -4
- package/dist/email/brevo/index.d.ts.map +1 -1
- package/dist/email/brevo/index.js.map +1 -1
- package/dist/email/cloudflare/index.d.ts +20 -7
- package/dist/email/cloudflare/index.d.ts.map +1 -1
- package/dist/email/cloudflare/index.js +46 -9
- package/dist/email/cloudflare/index.js.map +1 -1
- package/dist/email/core/index.d.ts +6 -9
- package/dist/email/core/index.d.ts.map +1 -1
- package/dist/email/core/index.js.map +1 -1
- package/dist/email/core/index.workerd.js.map +1 -1
- package/dist/email/smtp/index.d.ts +10 -13
- package/dist/email/smtp/index.d.ts.map +1 -1
- package/dist/email/smtp/index.js +107 -32
- package/dist/email/smtp/index.js.map +1 -1
- package/dist/fake/index.d.ts +1 -2
- package/dist/fake/index.d.ts.map +1 -1
- package/dist/fake/index.js.map +1 -1
- package/dist/lock/core/index.d.ts +9 -14
- package/dist/lock/core/index.d.ts.map +1 -1
- package/dist/lock/core/index.js.map +1 -1
- package/dist/lock/redis/index.d.ts +2 -4
- package/dist/lock/redis/index.d.ts.map +1 -1
- package/dist/lock/redis/index.js.map +1 -1
- package/dist/logger/index.d.ts +105 -76
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +196 -174
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.d.ts +16 -20
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/core/index.browser.js.map +1 -1
- package/dist/orm/core/index.bun.js +19 -1
- package/dist/orm/core/index.bun.js.map +1 -1
- package/dist/orm/core/index.d.ts +76 -62
- package/dist/orm/core/index.d.ts.map +1 -1
- package/dist/orm/core/index.js +20 -2
- package/dist/orm/core/index.js.map +1 -1
- package/dist/orm/postgres/index.bun.js.map +1 -1
- package/dist/orm/postgres/index.d.ts +28 -20
- package/dist/orm/postgres/index.d.ts.map +1 -1
- package/dist/orm/postgres/index.js.map +1 -1
- package/dist/queue/core/index.d.ts +12 -15
- package/dist/queue/core/index.d.ts.map +1 -1
- package/dist/queue/core/index.js.map +1 -1
- package/dist/queue/core/index.workerd.js.map +1 -1
- package/dist/queue/redis/index.d.ts +3 -5
- package/dist/queue/redis/index.d.ts.map +1 -1
- package/dist/queue/redis/index.js.map +1 -1
- package/dist/react/auth/index.browser.js +9 -2
- package/dist/react/auth/index.browser.js.map +1 -1
- package/dist/react/auth/index.d.ts +14 -9
- package/dist/react/auth/index.d.ts.map +1 -1
- package/dist/react/auth/index.js +9 -2
- package/dist/react/auth/index.js.map +1 -1
- package/dist/react/core/index.d.ts +7 -8
- package/dist/react/core/index.d.ts.map +1 -1
- package/dist/react/core/index.js +6 -3
- package/dist/react/core/index.js.map +1 -1
- package/dist/react/form/index.d.ts +2 -4
- package/dist/react/form/index.d.ts.map +1 -1
- package/dist/react/form/index.js.map +1 -1
- package/dist/react/head/index.browser.js.map +1 -1
- package/dist/react/head/index.d.ts +2 -4
- package/dist/react/head/index.d.ts.map +1 -1
- package/dist/react/head/index.js.map +1 -1
- package/dist/react/i18n/index.d.ts +47 -11
- package/dist/react/i18n/index.d.ts.map +1 -1
- package/dist/react/i18n/index.js +33 -1
- package/dist/react/i18n/index.js.map +1 -1
- package/dist/react/intro/index.d.ts +1 -2
- package/dist/react/intro/index.d.ts.map +1 -1
- package/dist/react/intro/index.js +2 -2
- package/dist/react/intro/index.js.map +1 -1
- package/dist/react/router/index.browser.js +65 -19
- package/dist/react/router/index.browser.js.map +1 -1
- package/dist/react/router/index.d.ts +327 -222
- package/dist/react/router/index.d.ts.map +1 -1
- package/dist/react/router/index.js +65 -29
- package/dist/react/router/index.js.map +1 -1
- package/dist/react/testing/index.d.ts +1 -2
- package/dist/react/testing/index.d.ts.map +1 -1
- package/dist/react/testing/index.js +16 -17
- package/dist/react/testing/index.js.map +1 -1
- package/dist/react/ui/index.d.ts +20 -25
- package/dist/react/ui/index.d.ts.map +1 -1
- package/dist/react/ui/index.js.map +1 -1
- package/dist/redis/index.bun.js.map +1 -1
- package/dist/redis/index.d.ts +17 -19
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js.map +1 -1
- package/dist/retry/index.d.ts +2 -4
- package/dist/retry/index.d.ts.map +1 -1
- package/dist/retry/index.js.map +1 -1
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +10 -13
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js.map +1 -1
- package/dist/scheduler/index.workerd.js.map +1 -1
- package/dist/security/index.browser.js.map +1 -1
- package/dist/security/index.d.ts +45 -48
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.browser.js.map +1 -1
- package/dist/server/auth/index.d.ts +167 -172
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +4 -8
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cookies/index.browser.js.map +1 -1
- package/dist/server/cookies/index.d.ts +5 -7
- package/dist/server/cookies/index.d.ts.map +1 -1
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/server/core/index.browser.js.map +1 -1
- package/dist/server/core/index.d.ts +88 -73
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +19 -0
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/cors/index.d.ts +11 -14
- package/dist/server/cors/index.d.ts.map +1 -1
- package/dist/server/cors/index.js.map +1 -1
- package/dist/server/etag/index.d.ts +6 -9
- package/dist/server/etag/index.d.ts.map +1 -1
- package/dist/server/etag/index.js.map +1 -1
- package/dist/server/health/index.d.ts +18 -21
- package/dist/server/health/index.d.ts.map +1 -1
- package/dist/server/health/index.js.map +1 -1
- package/dist/server/links/index.browser.js +2 -0
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.d.ts +63 -67
- package/dist/server/links/index.d.ts.map +1 -1
- package/dist/server/links/index.js +2 -0
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/metrics/index.d.ts +5 -7
- package/dist/server/metrics/index.d.ts.map +1 -1
- package/dist/server/metrics/index.js.map +1 -1
- package/dist/server/proxy/index.d.ts +3 -5
- package/dist/server/proxy/index.d.ts.map +1 -1
- package/dist/server/proxy/index.js.map +1 -1
- package/dist/server/rate-limit/index.d.ts +10 -13
- package/dist/server/rate-limit/index.d.ts.map +1 -1
- package/dist/server/rate-limit/index.js.map +1 -1
- package/dist/server/static/index.d.ts +3 -5
- package/dist/server/static/index.d.ts.map +1 -1
- package/dist/server/static/index.js.map +1 -1
- package/dist/server/swagger/index.d.ts +5 -8
- package/dist/server/swagger/index.d.ts.map +1 -1
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/sms/index.d.ts +3 -5
- package/dist/sms/index.d.ts.map +1 -1
- package/dist/sms/index.js.map +1 -1
- package/dist/system/index.browser.js.map +1 -1
- package/dist/system/index.d.ts +2 -4
- package/dist/system/index.d.ts.map +1 -1
- package/dist/system/index.js.map +1 -1
- package/dist/system/index.workerd.js.map +1 -1
- package/dist/topic/core/index.d.ts +4 -6
- package/dist/topic/core/index.d.ts.map +1 -1
- package/dist/topic/core/index.js.map +1 -1
- package/dist/topic/redis/index.d.ts +5 -8
- package/dist/topic/redis/index.d.ts.map +1 -1
- package/dist/topic/redis/index.js.map +1 -1
- package/package.json +45 -22
- package/src/api/audits/__tests__/AuditService.spec.ts +18 -110
- package/src/api/audits/controllers/AdminAuditController.ts +14 -0
- package/src/api/audits/services/AuditService.ts +21 -88
- package/src/api/files/__tests__/FileService.spec.ts +207 -2
- package/src/api/files/index.ts +3 -0
- package/src/api/files/schemas/fileCreatorSummarySchema.ts +22 -0
- package/src/api/files/schemas/fileResourceSchema.ts +10 -1
- package/src/api/files/services/FileService.ts +170 -72
- package/src/api/jobs/__tests__/$job.spec.ts +24 -1
- package/src/api/jobs/index.ts +4 -3
- package/src/api/jobs/primitives/$job.ts +7 -3
- package/src/api/jobs/providers/DirectJobDispatcher.ts +17 -36
- package/src/api/jobs/providers/JobProvider.ts +53 -24
- package/src/api/jobs/schemas/jobConfigAtom.ts +1 -1
- package/src/api/jobs/schemas/jobExecutionResourceSchema.ts +4 -1
- package/src/api/keys/schemas/adminApiKeyResourceSchema.ts +3 -1
- package/src/api/parameters/__tests__/$parameter.spec.ts +19 -2
- package/src/api/parameters/audits/ParameterAudits.ts +17 -0
- package/src/api/parameters/controllers/AdminParameterController.ts +95 -19
- package/src/api/parameters/index.ts +3 -0
- package/src/api/parameters/schemas/activateParameterBodySchema.ts +3 -3
- package/src/api/parameters/schemas/createParameterVersionBodySchema.ts +3 -2
- package/src/api/parameters/schemas/parameterCreatorSummarySchema.ts +25 -0
- package/src/api/parameters/schemas/parameterResponseSchema.ts +5 -0
- package/src/api/parameters/schemas/rollbackParameterBodySchema.ts +4 -2
- package/src/api/parameters/services/ParameterProvider.ts +69 -6
- package/src/api/subscriptions/jobs/SubscriptionJobs.ts +1 -1
- package/src/api/users/__tests__/AdminSessionController.spec.ts +37 -0
- package/src/api/users/audits/SessionAudits.ts +33 -0
- package/src/api/users/audits/UserAudits.ts +19 -43
- package/src/api/users/controllers/AdminUserController.ts +66 -1
- package/src/api/users/entities/sessions.ts +6 -0
- package/src/api/users/entities/users.ts +2 -0
- package/src/api/users/index.ts +9 -1
- package/src/api/users/primitives/$realm.ts +3 -0
- package/src/api/users/schemas/sessionResourceSchema.ts +16 -0
- package/src/api/users/schemas/updateUserSchema.ts +1 -8
- package/src/api/users/schemas/userQuerySchema.ts +7 -0
- package/src/api/users/services/CredentialService.ts +15 -6
- package/src/api/users/services/IdentityService.ts +2 -1
- package/src/api/users/services/RegistrationService.ts +2 -1
- package/src/api/users/services/SessionCrudService.ts +19 -2
- package/src/api/users/services/SessionService.ts +39 -19
- package/src/api/users/services/UserService.ts +106 -8
- package/src/background/__tests__/BackgroundTaskProvider.spec.ts +96 -0
- package/src/background/index.ts +37 -0
- package/src/background/index.workerd.ts +28 -0
- package/src/background/providers/BackgroundTaskProvider.ts +70 -0
- package/src/background/providers/WorkerdBackgroundTaskProvider.ts +43 -0
- package/src/bucket/__tests__/$bucket.spec.ts +18 -0
- package/src/bucket/__tests__/LocalFileStorageProvider.spec.ts +5 -0
- package/src/bucket/__tests__/MemoryFileStorageProvider.spec.ts +5 -0
- package/src/bucket/__tests__/NodeS3BucketProvider.spec.ts +23 -4
- package/src/bucket/__tests__/shared.ts +30 -0
- package/src/bucket/index.ts +5 -5
- package/src/bucket/index.workerd.ts +11 -4
- package/src/bucket/primitives/$bucket.ts +27 -0
- package/src/bucket/providers/FileStorageProvider.ts +13 -0
- package/src/bucket/providers/LocalFileStorageProvider.ts +17 -1
- package/src/bucket/providers/MemoryFileStorageProvider.ts +7 -0
- package/src/bucket/providers/{CloudflareR2Provider.ts → R2FileStorageProvider.ts} +10 -1
- package/src/bucket/providers/{NodeS3BucketProvider.ts → S3FileStorageProvider.ts} +27 -5
- package/src/cli/core/__tests__/BuildDockerTask.spec.ts +25 -1
- package/src/cli/core/__tests__/init.spec.ts +0 -219
- package/src/cli/core/commands/__tests__/BuildCommand.spec.ts +43 -0
- package/src/cli/core/commands/build.ts +108 -30
- package/src/cli/core/commands/init.ts +0 -12
- package/src/cli/core/commands/pack.ts +133 -0
- package/src/cli/core/index.ts +3 -0
- package/src/cli/core/providers/ViteDevServerProvider.ts +40 -16
- package/src/cli/core/services/PackageManagerUtils.ts +0 -16
- package/src/cli/core/services/ProjectScaffolder.ts +29 -291
- package/src/cli/core/tasks/BuildCloudflareTask.ts +353 -47
- package/src/cli/core/tasks/BuildDockerTask.ts +33 -3
- package/src/cli/core/tasks/BuildTask.ts +34 -0
- package/src/cli/core/templates/apiIndexTs.ts +1 -22
- package/src/cli/core/templates/mainCss.ts +0 -1
- package/src/cli/core/templates/webAppRouterTs.ts +0 -99
- package/src/cli/core/templates/webIndexTs.ts +1 -22
- package/src/cli/platform/__tests__/SecretsCommand.spec.ts +5 -3
- package/src/cli/platform/commands/SecretsCommand.ts +8 -6
- package/src/cli/platform/commands/platform.ts +192 -46
- package/src/cli/platform/index.ts +12 -52
- package/src/cli/{platform → platform-lib}/__tests__/CloudflareAdapter.spec.ts +426 -169
- package/src/cli/{platform → platform-lib}/__tests__/NamingService.spec.ts +91 -4
- package/src/cli/{platform → platform-lib}/__tests__/VercelAdapter.spec.ts +56 -85
- package/src/cli/{platform → platform-lib}/adapters/CloudflareAdapter.ts +402 -165
- package/src/cli/{platform → platform-lib}/adapters/PlatformAdapter.ts +62 -35
- package/src/cli/{platform → platform-lib}/adapters/VercelAdapter.ts +6 -10
- package/src/cli/{platform → platform-lib}/atoms/platformOptions.ts +34 -1
- package/src/cli/platform-lib/index.ts +67 -0
- package/src/cli/platform-lib/services/NamingService.ts +136 -0
- package/src/cli/{platform → platform-lib}/services/PlatformInspector.ts +60 -13
- package/src/cli/{platform → platform-lib}/services/PlatformOrchestrator.ts +54 -43
- package/src/cli/{platform → platform-lib}/services/WranglerApi.ts +4 -2
- package/src/command/__tests__/Runner.spec.ts +20 -0
- package/src/command/helpers/EnvUtils.ts +19 -3
- package/src/command/helpers/Runner.ts +12 -2
- package/src/command/providers/CliProvider.ts +34 -1
- package/src/{containers → container}/core/__tests__/$container.spec.ts +5 -5
- package/src/{containers → container}/core/index.ts +4 -4
- package/src/{containers → container}/core/index.workerd.ts +19 -3
- package/src/{containers → container}/core/primitives/$container.ts +1 -1
- package/src/{containers → container}/core/providers/CloudflareContainerProvider.ts +17 -19
- package/src/{containers → container}/core/providers/ContainerProvider.ts +16 -2
- package/src/{containers → container}/core/providers/MockContainerProvider.ts +1 -1
- package/src/core/Alepha.ts +49 -1
- package/src/core/__tests__/$env.spec.ts +42 -0
- package/src/core/__tests__/dump.spec.ts +47 -0
- package/src/email/cloudflare/__tests__/CloudflareEmailProvider.spec.ts +42 -10
- package/src/email/cloudflare/index.ts +14 -5
- package/src/email/cloudflare/providers/CloudflareEmailProvider.ts +54 -9
- package/src/logger/__tests__/Logger.spec.ts +55 -0
- package/src/logger/index.ts +13 -0
- package/src/logger/services/Logger.ts +31 -1
- package/src/orm/__tests__/orm-showcase-tests.ts +27 -0
- package/src/orm/__tests__/orm-showcase.spec.ts +12 -0
- package/src/orm/core/interfaces/PgQuery.ts +4 -1
- package/src/orm/core/services/Repository.ts +27 -11
- package/src/react/auth/hooks/useAuth.ts +10 -5
- package/src/react/core/__tests__/useQuery.browser.spec.tsx +25 -0
- package/src/react/core/hooks/useAction.ts +14 -3
- package/src/react/core/hooks/useQuery.ts +24 -4
- package/src/react/i18n/components/Translate.tsx +47 -0
- package/src/react/i18n/index.ts +2 -0
- package/src/react/intro/components/GettingStartedAdminSlide.tsx +2 -2
- package/src/react/router/__tests__/$page.spec.tsx +3 -2
- package/src/react/router/__tests__/page-can.spec.ts +18 -13
- package/src/react/router/hooks/useQueryParams.ts +114 -14
- package/src/react/router/primitives/$page.ts +85 -4
- package/src/react/router/providers/ReactBrowserRouterProvider.ts +3 -7
- package/src/react/router/providers/ReactServerProvider.ts +4 -13
- package/src/react/ui/services/SchemaControl.ts +3 -4
- package/src/server/core/providers/ServerMultipartProvider.ts +19 -0
- package/src/server/links/providers/LinkProvider.ts +10 -0
- package/dist/containers/core/index.d.ts.map +0 -1
- package/dist/containers/core/index.js.map +0 -1
- package/dist/containers/core/index.workerd.js.map +0 -1
- package/src/cli/core/templates/componentsJsonTs.ts +0 -39
- package/src/cli/core/templates/saasAdminLayoutTsx.ts +0 -77
- package/src/cli/core/templates/saasAdminPagesTsx.ts +0 -26
- package/src/cli/core/templates/saasAuthLayoutTsx.ts +0 -22
- package/src/cli/core/templates/saasAuthPagesTsx.ts +0 -62
- package/src/cli/core/templates/saasRealmProviderTs.ts +0 -52
- package/src/cli/platform/services/NamingService.ts +0 -54
- /package/dist/orm/core/{chunk-o8xxKEmq.js → chunk-B4FMCO8f.js} +0 -0
- /package/dist/react/testing/{chunk-6Ep1yQYe.js → chunk-BpyX8vjI.js} +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/GitHubSecretStore.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/PlatformCacheProvider.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/PlatformInspector.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/PlatformOrchestrator.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/SecretFilterService.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/__tests__/detectResources.spec.ts +0 -0
- /package/src/cli/{platform → platform-lib}/providers/GitHubSecretStore.ts +0 -0
- /package/src/cli/{platform → platform-lib}/providers/MemorySecretStore.ts +0 -0
- /package/src/cli/{platform → platform-lib}/providers/PlatformCacheProvider.ts +0 -0
- /package/src/cli/{platform → platform-lib}/providers/SecretStoreProvider.ts +0 -0
- /package/src/cli/{platform → platform-lib}/schemas/cloudflare.ts +0 -0
- /package/src/cli/{platform → platform-lib}/schemas/platform.ts +0 -0
- /package/src/cli/{platform → platform-lib}/schemas/vercel.ts +0 -0
- /package/src/cli/{platform → platform-lib}/services/CloudflareApi.ts +0 -0
- /package/src/cli/{platform → platform-lib}/services/SecretFilterService.ts +0 -0
- /package/src/cli/{platform → platform-lib}/services/VercelApi.ts +0 -0
- /package/src/cli/{platform → platform-lib}/services/VercelCli.ts +0 -0
- /package/src/{containers → container}/core/interfaces/ContainerOptions.ts +0 -0
- /package/src/{containers → container}/core/providers/NodeContainerProvider.ts +0 -0
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { $inject, Alepha, AlephaError } from "alepha";
|
|
2
|
+
import type { AppEntry } from "alepha/cli";
|
|
2
3
|
import type { RunnerMethod } from "alepha/command";
|
|
3
4
|
import { $logger, ConsoleColorProvider } from "alepha/logger";
|
|
4
5
|
import { CloudflareAdapter } from "../adapters/CloudflareAdapter.ts";
|
|
5
6
|
import type {
|
|
6
|
-
|
|
7
|
+
DetectedResources,
|
|
7
8
|
PlatformAdapter,
|
|
8
9
|
PlatformContext,
|
|
9
10
|
PlatformState,
|
|
10
11
|
} from "../adapters/PlatformAdapter.ts";
|
|
11
12
|
import { VercelAdapter } from "../adapters/VercelAdapter.ts";
|
|
12
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
type NamingContext,
|
|
15
|
+
NamingService,
|
|
16
|
+
resolveTenant,
|
|
17
|
+
tenantDomain,
|
|
18
|
+
} from "./NamingService.ts";
|
|
13
19
|
import {
|
|
14
20
|
PlatformInspector,
|
|
15
21
|
type ResolvedPlatformConfig,
|
|
@@ -52,7 +58,8 @@ export class PlatformOrchestrator {
|
|
|
52
58
|
public async up(options: {
|
|
53
59
|
root: string;
|
|
54
60
|
env: string;
|
|
55
|
-
|
|
61
|
+
entry: AppEntry;
|
|
62
|
+
resources: DetectedResources;
|
|
56
63
|
run: RunnerMethod;
|
|
57
64
|
/**
|
|
58
65
|
* Pre-built mode — the artifact's `dist/` is already produced.
|
|
@@ -66,54 +73,43 @@ export class PlatformOrchestrator {
|
|
|
66
73
|
* per-tenant overrides on every deploy.
|
|
67
74
|
*/
|
|
68
75
|
prebuilt?: boolean;
|
|
76
|
+
/** Tenant slug (apps with tenancy optional|required). */
|
|
77
|
+
tenant?: string;
|
|
69
78
|
}): Promise<{ urls: string[]; domain?: string }> {
|
|
70
|
-
const { root, env,
|
|
79
|
+
const { root, env, entry, resources, run, prebuilt } = options;
|
|
71
80
|
const envConfig = await this.inspector.resolveEnvironment(root, env);
|
|
72
81
|
const config = await this.inspector.resolveConfig(root);
|
|
73
82
|
const adapter = this.resolveAdapter(envConfig.adapter);
|
|
74
|
-
const
|
|
83
|
+
const tenant = resolveTenant(config.tenancy, options.tenant);
|
|
84
|
+
const namingCtx = this.naming.forContext(config.project, env, tenant);
|
|
75
85
|
|
|
76
86
|
const ctx: PlatformContext = {
|
|
77
87
|
project: config.project,
|
|
78
88
|
env,
|
|
79
89
|
envConfig,
|
|
80
|
-
apps,
|
|
81
90
|
root,
|
|
91
|
+
entry,
|
|
92
|
+
resources,
|
|
82
93
|
naming: namingCtx,
|
|
94
|
+
tenant,
|
|
83
95
|
prebuilt,
|
|
84
96
|
};
|
|
85
97
|
|
|
86
|
-
// 1. Auth
|
|
87
98
|
await adapter.authenticate(ctx, run);
|
|
88
|
-
|
|
89
|
-
// 2. Provision (before build so resource IDs are available for wrangler config)
|
|
90
99
|
await adapter.provision(ctx, run);
|
|
91
|
-
|
|
92
|
-
//
|
|
93
|
-
|
|
94
|
-
// to do a full bundle build or just regenerate deploy config.
|
|
95
|
-
for (const a of apps) {
|
|
96
|
-
await adapter.build({ ...ctx, app: a }, run);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// 4. Migrate
|
|
100
|
+
// `build` always runs — adapter checks `ctx.prebuilt` to decide
|
|
101
|
+
// whether to do a full bundle build or only regenerate deploy config.
|
|
102
|
+
await adapter.build(ctx, run);
|
|
100
103
|
await adapter.migrate(ctx, run);
|
|
101
|
-
|
|
102
|
-
// 5. Deploy
|
|
103
|
-
const urls: string[] = [];
|
|
104
|
-
for (const a of apps) {
|
|
105
|
-
const url = await adapter.deploy({ ...ctx, app: a }, run);
|
|
106
|
-
if (url) {
|
|
107
|
-
urls.push(url);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// 6. Secrets (push .env.{env} secrets to deployed workers)
|
|
104
|
+
const url = await adapter.deploy(ctx, run);
|
|
112
105
|
await adapter.secrets(ctx, run);
|
|
113
106
|
|
|
114
107
|
run.end();
|
|
115
108
|
|
|
116
|
-
return {
|
|
109
|
+
return {
|
|
110
|
+
urls: url ? [url] : [],
|
|
111
|
+
domain: tenantDomain(envConfig.domain, tenant),
|
|
112
|
+
};
|
|
117
113
|
}
|
|
118
114
|
|
|
119
115
|
/**
|
|
@@ -146,23 +142,29 @@ export class PlatformOrchestrator {
|
|
|
146
142
|
public async down(options: {
|
|
147
143
|
root: string;
|
|
148
144
|
env: string;
|
|
149
|
-
|
|
145
|
+
entry: AppEntry;
|
|
146
|
+
resources: DetectedResources;
|
|
150
147
|
run: RunnerMethod;
|
|
151
148
|
confirm: (prompt: string) => Promise<string>;
|
|
149
|
+
/** Tenant slug (apps with tenancy optional|required). */
|
|
150
|
+
tenant?: string;
|
|
152
151
|
}): Promise<boolean> {
|
|
153
|
-
const { root, env,
|
|
152
|
+
const { root, env, entry, resources, run, confirm } = options;
|
|
154
153
|
const envConfig = await this.inspector.resolveEnvironment(root, env);
|
|
155
154
|
const config = await this.inspector.resolveConfig(root);
|
|
156
155
|
const adapter = this.resolveAdapter(envConfig.adapter);
|
|
157
|
-
const
|
|
156
|
+
const tenant = resolveTenant(config.tenancy, options.tenant);
|
|
157
|
+
const namingCtx = this.naming.forContext(config.project, env, tenant);
|
|
158
158
|
|
|
159
159
|
const ctx: PlatformContext = {
|
|
160
160
|
project: config.project,
|
|
161
161
|
env,
|
|
162
162
|
envConfig,
|
|
163
|
-
apps,
|
|
164
163
|
root,
|
|
164
|
+
entry,
|
|
165
|
+
resources,
|
|
165
166
|
naming: namingCtx,
|
|
167
|
+
tenant,
|
|
166
168
|
};
|
|
167
169
|
|
|
168
170
|
// Confirm (skip for tmp envs)
|
|
@@ -192,16 +194,19 @@ export class PlatformOrchestrator {
|
|
|
192
194
|
public async plan(options: {
|
|
193
195
|
root: string;
|
|
194
196
|
env: string;
|
|
195
|
-
|
|
197
|
+
resources: DetectedResources;
|
|
198
|
+
/** Tenant slug (apps with tenancy optional|required). */
|
|
199
|
+
tenant?: string;
|
|
196
200
|
}): Promise<{
|
|
197
201
|
config: ResolvedPlatformConfig;
|
|
198
202
|
naming: NamingContext;
|
|
199
|
-
|
|
203
|
+
resources: DetectedResources;
|
|
200
204
|
}> {
|
|
201
|
-
const { root, env,
|
|
205
|
+
const { root, env, resources } = options;
|
|
202
206
|
const config = await this.inspector.resolveConfig(root);
|
|
203
|
-
const
|
|
204
|
-
|
|
207
|
+
const tenant = resolveTenant(config.tenancy, options.tenant);
|
|
208
|
+
const namingCtx = this.naming.forContext(config.project, env, tenant);
|
|
209
|
+
return { config, naming: namingCtx, resources };
|
|
205
210
|
}
|
|
206
211
|
|
|
207
212
|
// -------------------------------------------------------------------------
|
|
@@ -211,22 +216,28 @@ export class PlatformOrchestrator {
|
|
|
211
216
|
public async status(options: {
|
|
212
217
|
root: string;
|
|
213
218
|
env: string;
|
|
214
|
-
|
|
219
|
+
entry: AppEntry;
|
|
220
|
+
resources: DetectedResources;
|
|
215
221
|
run: RunnerMethod;
|
|
222
|
+
/** Tenant slug (apps with tenancy optional|required). */
|
|
223
|
+
tenant?: string;
|
|
216
224
|
}): Promise<{ config: ResolvedPlatformConfig; state: PlatformState }> {
|
|
217
|
-
const { root, env,
|
|
225
|
+
const { root, env, entry, resources, run } = options;
|
|
218
226
|
const envConfig = await this.inspector.resolveEnvironment(root, env);
|
|
219
227
|
const config = await this.inspector.resolveConfig(root);
|
|
220
228
|
const adapter = this.resolveAdapter(envConfig.adapter);
|
|
221
|
-
const
|
|
229
|
+
const tenant = resolveTenant(config.tenancy, options.tenant);
|
|
230
|
+
const namingCtx = this.naming.forContext(config.project, env, tenant);
|
|
222
231
|
|
|
223
232
|
const ctx: PlatformContext = {
|
|
224
233
|
project: config.project,
|
|
225
234
|
env,
|
|
226
235
|
envConfig,
|
|
227
|
-
apps,
|
|
228
236
|
root,
|
|
237
|
+
entry,
|
|
238
|
+
resources,
|
|
229
239
|
naming: namingCtx,
|
|
240
|
+
tenant,
|
|
230
241
|
};
|
|
231
242
|
|
|
232
243
|
await adapter.authenticate(ctx, run);
|
|
@@ -98,10 +98,11 @@ export class WranglerApi {
|
|
|
98
98
|
public async deploy(
|
|
99
99
|
workerName: string,
|
|
100
100
|
configPath: string,
|
|
101
|
+
root?: string,
|
|
101
102
|
): Promise<string | undefined> {
|
|
102
103
|
const output = await this.runShell(
|
|
103
104
|
`wrangler deploy --name=${workerName} --no-bundle --config=${configPath}`,
|
|
104
|
-
{ resolve: true, capture: true },
|
|
105
|
+
{ resolve: true, capture: true, root },
|
|
105
106
|
);
|
|
106
107
|
|
|
107
108
|
const match = output.match(/https:\/\/[^\s]*\.workers\.dev/);
|
|
@@ -118,10 +119,11 @@ export class WranglerApi {
|
|
|
118
119
|
public async d1MigrationsApply(
|
|
119
120
|
dbName: string,
|
|
120
121
|
configPath: string,
|
|
122
|
+
root?: string,
|
|
121
123
|
): Promise<void> {
|
|
122
124
|
await this.runShell(
|
|
123
125
|
`wrangler d1 migrations apply ${dbName} --remote --config=${configPath}`,
|
|
124
|
-
{ resolve: true, env: { CI: "1" } },
|
|
126
|
+
{ resolve: true, env: { CI: "1" }, root },
|
|
125
127
|
);
|
|
126
128
|
}
|
|
127
129
|
}
|
|
@@ -37,6 +37,26 @@ describe("Runner", () => {
|
|
|
37
37
|
vi.clearAllMocks();
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
+
test("useDynamicLogger: state overrides disable the stylish UI even with LOG_FORMAT=raw", () => {
|
|
41
|
+
// env says "raw" (stylish), but a runtime state override (what the CLI
|
|
42
|
+
// `--verbose` flag sets) must win. Asserting the *false* direction is
|
|
43
|
+
// deterministic across CI/non-CI (the dynamic-on path is gated on isCI).
|
|
44
|
+
const alepha = Alepha.create({
|
|
45
|
+
env: { LOG_LEVEL: "info", LOG_FORMAT: "raw" },
|
|
46
|
+
}).with({
|
|
47
|
+
provide: LogDestinationProvider,
|
|
48
|
+
use: MemoryDestinationProvider,
|
|
49
|
+
});
|
|
50
|
+
const r = alepha.inject(Runner);
|
|
51
|
+
|
|
52
|
+
alepha.store.set("alepha.logger.format", "pretty");
|
|
53
|
+
expect(r.useDynamicLogger).toBe(false);
|
|
54
|
+
|
|
55
|
+
alepha.store.set("alepha.logger.format", undefined);
|
|
56
|
+
alepha.store.set("alepha.logger.level", "debug");
|
|
57
|
+
expect(r.useDynamicLogger).toBe(false);
|
|
58
|
+
});
|
|
59
|
+
|
|
40
60
|
test("should execute a single shell command via run.sh", async () => {
|
|
41
61
|
await runner.run(`echo "hello"`);
|
|
42
62
|
|
|
@@ -52,11 +52,27 @@ export class EnvUtils {
|
|
|
52
52
|
const trimmedKey = key.trim();
|
|
53
53
|
if (trimmedKey && !trimmedKey.startsWith("#")) {
|
|
54
54
|
let value = rest.join("=").trim();
|
|
55
|
-
|
|
55
|
+
const last = value.length - 1;
|
|
56
56
|
if (
|
|
57
57
|
value.length >= 2 &&
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
value[0] === '"' &&
|
|
59
|
+
value[last] === '"'
|
|
60
|
+
) {
|
|
61
|
+
// Double-quoted: JSON-decode so escapes round-trip with a
|
|
62
|
+
// `JSON.stringify`-based writer (e.g. Rocket's
|
|
63
|
+
// `.env.<env>.local` overrides, which write JSON values like
|
|
64
|
+
// CLUB_CONFIG_JSON). Falls back to a naive strip when the
|
|
65
|
+
// body isn't valid JSON (e.g. a Windows path with `\`), so
|
|
66
|
+
// simple `KEY="value"` still behaves as before.
|
|
67
|
+
try {
|
|
68
|
+
value = JSON.parse(value);
|
|
69
|
+
} catch {
|
|
70
|
+
value = value.slice(1, -1);
|
|
71
|
+
}
|
|
72
|
+
} else if (
|
|
73
|
+
value.length >= 2 &&
|
|
74
|
+
value[0] === "'" &&
|
|
75
|
+
value[last] === "'"
|
|
60
76
|
) {
|
|
61
77
|
value = value.slice(1, -1);
|
|
62
78
|
}
|
|
@@ -78,12 +78,22 @@ export class Runner {
|
|
|
78
78
|
return false;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
// Runtime state overrides the env defaults (e.g. the CLI `--verbose`
|
|
82
|
+
// flag sets level=debug + format=pretty), so a flag can flip the
|
|
83
|
+
// stylish task UI off without restarting with LOG_* env vars.
|
|
84
|
+
const logLevel = String(
|
|
85
|
+
this.alepha.store.get("alepha.logger.level") ??
|
|
86
|
+
this.alepha.env.LOG_LEVEL ??
|
|
87
|
+
"",
|
|
88
|
+
).toLowerCase();
|
|
82
89
|
if (logLevel === "debug" || logLevel === "trace") {
|
|
83
90
|
return false;
|
|
84
91
|
}
|
|
85
92
|
|
|
86
|
-
|
|
93
|
+
const format =
|
|
94
|
+
this.alepha.store.get("alepha.logger.format") ??
|
|
95
|
+
this.alepha.env.LOG_FORMAT;
|
|
96
|
+
return format === "raw";
|
|
87
97
|
}
|
|
88
98
|
|
|
89
99
|
/**
|
|
@@ -145,6 +145,13 @@ export class CliProvider {
|
|
|
145
145
|
description: "Show this help message",
|
|
146
146
|
schema: t.boolean(),
|
|
147
147
|
},
|
|
148
|
+
verbose: {
|
|
149
|
+
// No `-v` alias — it collides with `--version` on the root command.
|
|
150
|
+
aliases: ["verbose"],
|
|
151
|
+
description:
|
|
152
|
+
"Verbose output: debug logs in plain pretty format (turns off the dynamic CLI UI).",
|
|
153
|
+
schema: t.boolean(),
|
|
154
|
+
},
|
|
148
155
|
};
|
|
149
156
|
|
|
150
157
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -175,6 +182,14 @@ export class CliProvider {
|
|
|
175
182
|
{ strict: false }, // Don't throw for command-specific flags
|
|
176
183
|
);
|
|
177
184
|
|
|
185
|
+
// `--verbose` → flip the logger to debug + plain pretty output via
|
|
186
|
+
// state (read live by Logger + Runner). Set before the command runs
|
|
187
|
+
// so its output and task UI honor it.
|
|
188
|
+
if (globalFlags.verbose) {
|
|
189
|
+
this.alepha.store.set("alepha.logger.level", "debug");
|
|
190
|
+
this.alepha.store.set("alepha.logger.format", "pretty");
|
|
191
|
+
}
|
|
192
|
+
|
|
178
193
|
if (globalFlags.help) {
|
|
179
194
|
this.printHelp(command);
|
|
180
195
|
return;
|
|
@@ -552,10 +567,28 @@ export class CliProvider {
|
|
|
552
567
|
});
|
|
553
568
|
}
|
|
554
569
|
|
|
570
|
+
// Tolerate global flags (--help, --verbose) so strict command parsing
|
|
571
|
+
// doesn't reject them — they're consumed by the onReady global pass,
|
|
572
|
+
// not by the command. Skip any whose alias the command already claims
|
|
573
|
+
// (e.g. a command with its own `verbose` flag handles it directly).
|
|
574
|
+
const claimed = new Set(flagDefs.flatMap((d) => d.aliases));
|
|
575
|
+
for (const [key, value] of Object.entries(this.getAllGlobalFlags())) {
|
|
576
|
+
if (value.aliases.some((a: string) => claimed.has(a))) continue;
|
|
577
|
+
flagDefs.push({
|
|
578
|
+
key: `__global_${key}__`,
|
|
579
|
+
aliases: value.aliases,
|
|
580
|
+
description: undefined,
|
|
581
|
+
schema: value.schema,
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
|
|
555
585
|
const parsed = this.parseFlags(argv, flagDefs);
|
|
556
586
|
|
|
557
|
-
// Remove the mode
|
|
587
|
+
// Remove the mode + global flags from parsed result (handled separately)
|
|
558
588
|
parsed.__mode__ = undefined;
|
|
589
|
+
for (const key of Object.keys(parsed)) {
|
|
590
|
+
if (key.startsWith("__global_")) delete parsed[key];
|
|
591
|
+
}
|
|
559
592
|
|
|
560
593
|
// apply manually defaults for optional properties that have defaults
|
|
561
594
|
for (const [key, value] of Object.entries(schema.properties)) {
|
|
@@ -2,7 +2,7 @@ import { Alepha, t } from "alepha";
|
|
|
2
2
|
import { $action, AlephaServer } from "alepha/server";
|
|
3
3
|
import { AlephaServerLinks } from "alepha/server/links";
|
|
4
4
|
import { describe, it } from "vitest";
|
|
5
|
-
import {
|
|
5
|
+
import { AlephaContainer } from "../index.ts";
|
|
6
6
|
import { $container } from "../primitives/$container.ts";
|
|
7
7
|
import { ContainerProvider } from "../providers/ContainerProvider.ts";
|
|
8
8
|
import { NodeContainerProvider } from "../providers/NodeContainerProvider.ts";
|
|
@@ -28,13 +28,13 @@ describe("$container", () => {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
// In test mode
|
|
31
|
+
// In test mode AlephaContainer binds the Mock provider by default,
|
|
32
32
|
// which routes the proxy's `.createJob(...)` call back through
|
|
33
33
|
// LinkProvider — so RocketController must live on the same Alepha.
|
|
34
34
|
const alepha = Alepha.create({ env: { LOG_LEVEL: "warn" } })
|
|
35
35
|
.with(AlephaServer)
|
|
36
36
|
.with(AlephaServerLinks)
|
|
37
|
-
.with(
|
|
37
|
+
.with(AlephaContainer)
|
|
38
38
|
.with(RocketController)
|
|
39
39
|
.with(DeployService);
|
|
40
40
|
|
|
@@ -55,7 +55,7 @@ describe("$container", () => {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
const alepha = Alepha.create({ env: {} }).with(
|
|
58
|
+
const alepha = Alepha.create({ env: {} }).with(AlephaContainer).with(App);
|
|
59
59
|
|
|
60
60
|
// Force App instantiation so the primitive registers.
|
|
61
61
|
const app = alepha.inject(App);
|
|
@@ -71,7 +71,7 @@ describe("$container", () => {
|
|
|
71
71
|
|
|
72
72
|
const alepha = Alepha.create({ env: {} })
|
|
73
73
|
.with({ provide: ContainerProvider, use: NodeContainerProvider })
|
|
74
|
-
.with(
|
|
74
|
+
.with(AlephaContainer)
|
|
75
75
|
.with(App);
|
|
76
76
|
await alepha.start();
|
|
77
77
|
|
|
@@ -24,7 +24,7 @@ export * from "./providers/NodeContainerProvider.ts";
|
|
|
24
24
|
* - Pluggable transport: Node (plain `fetch` against a configured URL),
|
|
25
25
|
* Mock (in-process call via `LinkProvider.follow` for tests),
|
|
26
26
|
* Cloudflare workerd (`getContainer().fetch()` through the Containers
|
|
27
|
-
* binding — see `alepha/
|
|
27
|
+
* binding — see `alepha/container` workerd entry).
|
|
28
28
|
* - Build-time integration: `BuildCloudflareTask.enhanceContainers`
|
|
29
29
|
* emits the matching wrangler bindings and Durable Object class
|
|
30
30
|
* declarations.
|
|
@@ -33,10 +33,10 @@ export * from "./providers/NodeContainerProvider.ts";
|
|
|
33
33
|
* the spec — apps need to provide an explicit `url` per primitive
|
|
34
34
|
* until a `target=docker` adapter ships.
|
|
35
35
|
*
|
|
36
|
-
* @module alepha.
|
|
36
|
+
* @module alepha.container
|
|
37
37
|
*/
|
|
38
|
-
export const
|
|
39
|
-
name: "alepha.
|
|
38
|
+
export const AlephaContainer = $module({
|
|
39
|
+
name: "alepha.container",
|
|
40
40
|
primitives: [$container],
|
|
41
41
|
services: [ContainerProvider],
|
|
42
42
|
variants: [MockContainerProvider, NodeContainerProvider],
|
|
@@ -1,8 +1,24 @@
|
|
|
1
|
+
import { Container } from "@cloudflare/containers";
|
|
1
2
|
import { $module } from "alepha";
|
|
2
3
|
import { $container } from "./primitives/$container.ts";
|
|
3
4
|
import { CloudflareContainerProvider } from "./providers/CloudflareContainerProvider.ts";
|
|
4
5
|
import { ContainerProvider } from "./providers/ContainerProvider.ts";
|
|
5
6
|
|
|
7
|
+
// Stash the Cloudflare Containers `Container` base class on globalThis
|
|
8
|
+
// so `BuildCloudflareTask`'s post-Vite-emitted entry
|
|
9
|
+
// (`dist/main.cloudflare.js`) can declare
|
|
10
|
+
// `class <T> extends globalThis.__alepha_CloudflareContainer` without
|
|
11
|
+
// introducing a bare `@cloudflare/containers` specifier.
|
|
12
|
+
//
|
|
13
|
+
// The entry is written AFTER Vite — anything Vite hasn't seen
|
|
14
|
+
// survives as an unresolved import all the way to workerd (where the
|
|
15
|
+
// upload is `no_bundle: true`). This side-effect runs whenever an app
|
|
16
|
+
// imports anything from `alepha/container` (Vite picks this file via
|
|
17
|
+
// the `workerd` export condition), so by the time the entry's
|
|
18
|
+
// `import "./index.js"` finishes, the global is set and the
|
|
19
|
+
// `extends` expression resolves.
|
|
20
|
+
(globalThis as any).__alepha_CloudflareContainer = Container;
|
|
21
|
+
|
|
6
22
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
7
23
|
|
|
8
24
|
export * from "./interfaces/ContainerOptions.ts";
|
|
@@ -21,10 +37,10 @@ export * from "./providers/ContainerProvider.ts";
|
|
|
21
37
|
* `BuildCloudflareTask.enhanceContainers` (in `alepha/cli/core`) which
|
|
22
38
|
* emits the wrangler.jsonc bindings and DO class declarations.
|
|
23
39
|
*
|
|
24
|
-
* @module alepha.
|
|
40
|
+
* @module alepha.container
|
|
25
41
|
*/
|
|
26
|
-
export const
|
|
27
|
-
name: "alepha.
|
|
42
|
+
export const AlephaContainer = $module({
|
|
43
|
+
name: "alepha.container",
|
|
28
44
|
primitives: [$container],
|
|
29
45
|
services: [ContainerProvider, CloudflareContainerProvider],
|
|
30
46
|
register: (alepha) => {
|
|
@@ -23,7 +23,7 @@ import { ContainerProvider } from "../providers/ContainerProvider.ts";
|
|
|
23
23
|
*
|
|
24
24
|
* @example
|
|
25
25
|
* ```ts
|
|
26
|
-
* import { $container } from "alepha/
|
|
26
|
+
* import { $container } from "alepha/container";
|
|
27
27
|
* import type { RocketController } from "@alepha/rocket";
|
|
28
28
|
*
|
|
29
29
|
* class DeployService {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getContainer } from "@cloudflare/containers";
|
|
1
2
|
import { $inject, Alepha, AlephaError } from "alepha";
|
|
2
3
|
import type { ContainerPrimitive } from "../primitives/$container.ts";
|
|
3
4
|
import {
|
|
@@ -8,15 +9,18 @@ import {
|
|
|
8
9
|
/**
|
|
9
10
|
* Cloudflare Workers (workerd) container provider.
|
|
10
11
|
*
|
|
11
|
-
* Routes proxy calls through the Cloudflare Containers binding bound
|
|
12
|
-
* `env.<NAME>`, using a single shared instance per container
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* Routes proxy calls through the Cloudflare Containers binding bound
|
|
13
|
+
* on `env.<NAME>`, using a single shared instance per container.
|
|
14
|
+
* `getContainer` from `@cloudflare/containers` is a free function (not
|
|
15
|
+
* a method on the binding) — it takes the DO namespace and an id and
|
|
16
|
+
* returns a stub with a `.fetch()` method targeting the running
|
|
17
|
+
* container instance.
|
|
16
18
|
*
|
|
17
|
-
* The
|
|
18
|
-
*
|
|
19
|
-
*
|
|
19
|
+
* The binding is generated by `BuildCloudflareTask.enhanceContainers`
|
|
20
|
+
* from the `$container` primitives discovered in the app. The runtime
|
|
21
|
+
* `env` object is pulled from the Alepha store key `cloudflare.env`
|
|
22
|
+
* — the worker entry point publishes it there on every fetch
|
|
23
|
+
* (`__alepha.set("cloudflare.env", env)`).
|
|
20
24
|
*/
|
|
21
25
|
export class CloudflareContainerProvider extends ContainerProvider {
|
|
22
26
|
protected readonly alepha = $inject(Alepha);
|
|
@@ -35,21 +39,15 @@ export class CloudflareContainerProvider extends ContainerProvider {
|
|
|
35
39
|
);
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
fetch(req: Request): Promise<Response>;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
| undefined;
|
|
45
|
-
|
|
46
|
-
if (!binding?.getContainer) {
|
|
42
|
+
const bindingName = container.name.toUpperCase();
|
|
43
|
+
const binding = env[bindingName];
|
|
44
|
+
if (!binding) {
|
|
47
45
|
throw new AlephaError(
|
|
48
|
-
`Cloudflare Containers binding '${
|
|
46
|
+
`Cloudflare Containers binding '${bindingName}' not found on env — check wrangler.jsonc.`,
|
|
49
47
|
);
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
const instance =
|
|
50
|
+
const instance = getContainer(binding as never, "shared");
|
|
53
51
|
const { path, init } = this.buildRequest(action, config);
|
|
54
52
|
const request = new Request(`http://container${path}`, init);
|
|
55
53
|
const response = await instance.fetch(request);
|
|
@@ -33,7 +33,7 @@ export abstract class ContainerProvider {
|
|
|
33
33
|
void config;
|
|
34
34
|
throw new AlephaError(
|
|
35
35
|
`No ContainerProvider configured for container '${container.name}' (action '${action}'). ` +
|
|
36
|
-
`Set up alepha/
|
|
36
|
+
`Set up alepha/container via AlephaContainer and either supply 'url' (Node) or build for target=cloudflare.`,
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -54,11 +54,25 @@ export abstract class ContainerProvider {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// Match the route Alepha generates server-side when no explicit
|
|
58
|
+
// `path:` is set on `$action`: `/${name}` with one `/:<key>`
|
|
59
|
+
// segment appended per param. Params that match a `:key`
|
|
60
|
+
// placeholder are substituted in place; any remaining params are
|
|
61
|
+
// appended in declaration order so `params: {id:"abc"}` against a
|
|
62
|
+
// proxy action `getDeploy` yields `/api/getDeploy/abc`.
|
|
57
63
|
let path = `/api/${action}`;
|
|
58
64
|
if (config.params) {
|
|
65
|
+
const tail: string[] = [];
|
|
59
66
|
for (const [k, v] of Object.entries(config.params)) {
|
|
60
|
-
|
|
67
|
+
const placeholder = `:${k}`;
|
|
68
|
+
const encoded = encodeURIComponent(String(v));
|
|
69
|
+
if (path.includes(placeholder)) {
|
|
70
|
+
path = path.replace(placeholder, encoded);
|
|
71
|
+
} else {
|
|
72
|
+
tail.push(encoded);
|
|
73
|
+
}
|
|
61
74
|
}
|
|
75
|
+
if (tail.length) path += `/${tail.join("/")}`;
|
|
62
76
|
}
|
|
63
77
|
|
|
64
78
|
const search = params.toString();
|
package/src/core/Alepha.ts
CHANGED
|
@@ -971,6 +971,33 @@ export class Alepha {
|
|
|
971
971
|
|
|
972
972
|
// -------------------------------------------------------------------------------------------------------------------
|
|
973
973
|
|
|
974
|
+
/**
|
|
975
|
+
* Merge additional environment variables into the env store at runtime.
|
|
976
|
+
*
|
|
977
|
+
* Serverless entrypoints (Cloudflare Workers) receive their secrets and
|
|
978
|
+
* vars on the runtime `env` binding rather than `process.env`, so they are
|
|
979
|
+
* absent from `alepha.env` — which is frozen at `create()` from
|
|
980
|
+
* `process.env`. Call this from the entrypoint to lift the binding's string
|
|
981
|
+
* values into `alepha.env`, so `$env` and `alepha.env.*` resolve them (e.g.
|
|
982
|
+
* `PUBLIC_URL`).
|
|
983
|
+
*
|
|
984
|
+
* Only string values are lifted; non-string bindings (D1, R2, KV, queues,
|
|
985
|
+
* …) are skipped. Existing env values win, so explicit configuration is
|
|
986
|
+
* never clobbered. The env cache is cleared so subsequent `$env` reads see
|
|
987
|
+
* the merged values.
|
|
988
|
+
*/
|
|
989
|
+
public loadEnv(env: Record<string, unknown>): this {
|
|
990
|
+
const incoming: Record<string, string> = {};
|
|
991
|
+
for (const [key, value] of Object.entries(env)) {
|
|
992
|
+
if (typeof value === "string") {
|
|
993
|
+
incoming[key] = value;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
this.store.set("env", { ...incoming, ...this.env });
|
|
997
|
+
this.cacheEnv.clear();
|
|
998
|
+
return this;
|
|
999
|
+
}
|
|
1000
|
+
|
|
974
1001
|
/**
|
|
975
1002
|
* Applies environment variables to the provided schema and state object.
|
|
976
1003
|
*
|
|
@@ -1087,6 +1114,16 @@ export class Alepha {
|
|
|
1087
1114
|
}
|
|
1088
1115
|
|
|
1089
1116
|
public dump(): AlephaDump {
|
|
1117
|
+
// Force-instantiate the graph FIRST. `$env` is lazy — a key only lands in
|
|
1118
|
+
// `cacheEnv` once its owning service is constructed. `graph()` injects
|
|
1119
|
+
// every registered substitution (without emitting start/ready hooks), so
|
|
1120
|
+
// calling it before reading `cacheEnv` ensures `env` reflects the whole
|
|
1121
|
+
// app, not just whatever happened to be instantiated already. Reading
|
|
1122
|
+
// `cacheEnv` first (the old order) under-reported env on a not-yet-started
|
|
1123
|
+
// app and was internally inconsistent: dump() instantiated providers for
|
|
1124
|
+
// `providers` but never saw their env.
|
|
1125
|
+
const providers = this.graph();
|
|
1126
|
+
|
|
1090
1127
|
const env: Record<string, AlephaDumpEnvVariable> = {};
|
|
1091
1128
|
for (const [schema] of this.cacheEnv.entries()) {
|
|
1092
1129
|
const ref = schema as any;
|
|
@@ -1103,7 +1140,7 @@ export class Alepha {
|
|
|
1103
1140
|
|
|
1104
1141
|
return {
|
|
1105
1142
|
env,
|
|
1106
|
-
providers
|
|
1143
|
+
providers,
|
|
1107
1144
|
};
|
|
1108
1145
|
}
|
|
1109
1146
|
|
|
@@ -1271,6 +1308,17 @@ export interface Env {
|
|
|
1271
1308
|
* The secret key used for signing JWTs, encrypting cookies, and other security features.
|
|
1272
1309
|
*/
|
|
1273
1310
|
APP_SECRET?: string;
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* Public-facing base URL of the deployed app (e.g. "https://lore.alepha.dev").
|
|
1314
|
+
*
|
|
1315
|
+
* Used to render absolute links — emails, OAuth callbacks, sitemap. On the
|
|
1316
|
+
* Cloudflare platform it is auto-derived from the configured production
|
|
1317
|
+
* domain and pushed as a Worker secret by `alepha platform up`; otherwise
|
|
1318
|
+
* set it explicitly in `.env.<env>`. Unset → empty, and absolute-link
|
|
1319
|
+
* builders fall back to relative URLs.
|
|
1320
|
+
*/
|
|
1321
|
+
PUBLIC_URL?: string;
|
|
1274
1322
|
}
|
|
1275
1323
|
|
|
1276
1324
|
// ---------------------------------------------------------------------------------------------------------------------
|