alepha 0.19.3 → 0.19.5
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/assets/swagger-ui/swagger-ui-bundle.js +1 -1
- package/dist/api/invitations/index.d.ts +790 -0
- package/dist/api/invitations/index.d.ts.map +1 -0
- package/dist/api/invitations/index.js +665 -0
- package/dist/api/invitations/index.js.map +1 -0
- package/dist/api/issues/index.d.ts +810 -0
- package/dist/api/issues/index.d.ts.map +1 -0
- package/dist/api/issues/index.js +447 -0
- package/dist/api/issues/index.js.map +1 -0
- package/dist/api/jobs/index.browser.js +8 -9
- package/dist/api/jobs/index.browser.js.map +1 -1
- package/dist/api/jobs/index.d.ts +99 -43
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js +257 -40
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/notifications/index.browser.js +0 -1
- package/dist/api/notifications/index.browser.js.map +1 -1
- package/dist/api/notifications/index.d.ts +3 -3
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/notifications/index.js +0 -1
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/parameters/index.browser.js +112 -1
- package/dist/api/parameters/index.browser.js.map +1 -1
- package/dist/api/parameters/index.d.ts +90 -3
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/parameters/index.js +79 -12
- package/dist/api/parameters/index.js.map +1 -1
- package/dist/{billing → api/payments}/index.d.ts +67 -49
- package/dist/api/payments/index.d.ts.map +1 -0
- package/dist/{billing → api/payments}/index.js +108 -74
- package/dist/api/payments/index.js.map +1 -0
- package/dist/api/subscriptions/index.d.ts +1692 -0
- package/dist/api/subscriptions/index.d.ts.map +1 -0
- package/dist/api/subscriptions/index.js +1870 -0
- package/dist/api/subscriptions/index.js.map +1 -0
- package/dist/api/users/index.d.ts +24 -2
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +176 -36
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts +13 -13
- package/dist/api/workflows/index.browser.js +246 -0
- package/dist/api/workflows/index.browser.js.map +1 -0
- package/dist/api/workflows/index.d.ts +1618 -0
- package/dist/api/workflows/index.d.ts.map +1 -0
- package/dist/api/workflows/index.js +1504 -0
- package/dist/api/workflows/index.js.map +1 -0
- package/dist/captcha/index.d.ts +142 -0
- package/dist/captcha/index.d.ts.map +1 -0
- package/dist/captcha/index.js +177 -0
- package/dist/captcha/index.js.map +1 -0
- package/dist/cli/core/index.d.ts +126 -30
- package/dist/cli/core/index.d.ts.map +1 -1
- package/dist/cli/core/index.js +106 -67
- package/dist/cli/core/index.js.map +1 -1
- package/dist/cli/platform/index.d.ts +84 -10
- package/dist/cli/platform/index.d.ts.map +1 -1
- package/dist/cli/platform/index.js +92 -4
- package/dist/cli/platform/index.js.map +1 -1
- package/dist/cli/vendor/index.d.ts +60 -10
- package/dist/cli/vendor/index.d.ts.map +1 -1
- package/dist/cli/vendor/index.js +177 -45
- package/dist/cli/vendor/index.js.map +1 -1
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +2 -3
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +21 -2
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +33 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +21 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +21 -2
- package/dist/core/index.native.js.map +1 -1
- package/dist/core/index.workerd.js +21 -2
- package/dist/core/index.workerd.js.map +1 -1
- package/dist/email/smtp/index.js +24 -8
- package/dist/email/smtp/index.js.map +1 -1
- package/dist/orm/core/index.browser.js +0 -18
- package/dist/orm/core/index.browser.js.map +1 -1
- package/dist/orm/core/index.bun.js +6 -23
- package/dist/orm/core/index.bun.js.map +1 -1
- package/dist/orm/core/index.d.ts +1 -13
- package/dist/orm/core/index.d.ts.map +1 -1
- package/dist/orm/core/index.js +6 -23
- package/dist/orm/core/index.js.map +1 -1
- package/dist/orm/postgres/index.bun.js +3 -3
- package/dist/orm/postgres/index.bun.js.map +1 -1
- package/dist/orm/postgres/index.d.ts.map +1 -1
- package/dist/orm/postgres/index.js +3 -3
- package/dist/orm/postgres/index.js.map +1 -1
- package/dist/react/i18n/index.d.ts +1 -0
- package/dist/react/i18n/index.d.ts.map +1 -1
- package/dist/react/i18n/index.js +8 -4
- package/dist/react/i18n/index.js.map +1 -1
- package/dist/react/router/index.browser.js +25 -3
- package/dist/react/router/index.browser.js.map +1 -1
- package/dist/react/router/index.d.ts +16 -1
- package/dist/react/router/index.d.ts.map +1 -1
- package/dist/react/router/index.js +25 -3
- package/dist/react/router/index.js.map +1 -1
- package/dist/security/index.d.ts +28 -0
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +28 -0
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +145 -2
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +364 -63
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cookies/index.d.ts.map +1 -1
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/websocket/index.d.ts.map +1 -1
- package/dist/websocket/index.js.map +1 -1
- package/package.json +47 -20
- package/src/api/invitations/__tests__/InvitationService.spec.ts +439 -0
- package/src/api/invitations/controllers/AdminInvitationController.ts +86 -0
- package/src/api/invitations/controllers/InvitationController.ts +84 -0
- package/src/api/invitations/entities/invitations.ts +33 -0
- package/src/api/invitations/index.ts +65 -0
- package/src/api/invitations/jobs/InvitationJobs.ts +37 -0
- package/src/api/invitations/providers/InvitationProvider.ts +45 -0
- package/src/api/invitations/schemas/createInvitationSchema.ts +12 -0
- package/src/api/invitations/schemas/invitationConfigAtom.ts +20 -0
- package/src/api/invitations/schemas/invitationQuerySchema.ts +15 -0
- package/src/api/invitations/schemas/invitationResourceSchema.ts +6 -0
- package/src/api/invitations/schemas/invitationWithResourceInfoSchema.ts +22 -0
- package/src/api/invitations/schemas/myInvitationsQuerySchema.ts +10 -0
- package/src/api/invitations/services/InvitationService.ts +556 -0
- package/src/api/issues/__tests__/IssueService.spec.ts +263 -0
- package/src/api/issues/controllers/AdminIssueController.ts +149 -0
- package/src/api/issues/controllers/IssueController.ts +44 -0
- package/src/api/issues/entities/issues.ts +49 -0
- package/src/api/issues/index.ts +53 -0
- package/src/api/issues/schemas/createIssueSchema.ts +13 -0
- package/src/api/issues/schemas/issueConfigAtom.ts +13 -0
- package/src/api/issues/schemas/issueQuerySchema.ts +18 -0
- package/src/api/issues/schemas/issueResourceSchema.ts +6 -0
- package/src/api/issues/schemas/myIssueQuerySchema.ts +10 -0
- package/src/api/issues/schemas/updateIssueSchema.ts +13 -0
- package/src/api/issues/services/IssueService.ts +264 -0
- package/src/api/jobs/__tests__/$job.spec.ts +876 -0
- package/src/api/jobs/controllers/AdminJobController.ts +44 -0
- package/src/api/jobs/entities/jobExecutionEntity.ts +0 -2
- package/src/api/jobs/index.ts +0 -3
- package/src/api/jobs/primitives/$job.ts +22 -11
- package/src/api/jobs/providers/JobProvider.ts +229 -19
- package/src/api/jobs/schemas/jobConfigAtom.ts +4 -0
- package/src/api/jobs/schemas/jobCronInfoSchema.ts +1 -0
- package/src/api/jobs/schemas/jobExecutionQuerySchema.ts +0 -1
- package/src/api/jobs/schemas/jobQueueDepthSchema.ts +1 -0
- package/src/api/jobs/schemas/jobRegistrationSchema.ts +1 -6
- package/src/api/jobs/services/JobService.ts +51 -12
- package/src/api/notifications/schemas/notificationQuerySchema.ts +0 -1
- package/src/api/parameters/__tests__/$parameter.spec.ts +327 -0
- package/src/api/parameters/controllers/AdminParameterController.ts +29 -3
- package/src/api/parameters/index.browser.ts +12 -0
- package/src/api/parameters/primitives/$parameter.ts +20 -3
- package/src/api/parameters/services/ParameterProvider.ts +48 -7
- package/src/{billing → api/payments}/__tests__/PaymentMethodService.spec.ts +32 -6
- package/src/api/payments/__tests__/PaymentService.spec.ts +279 -0
- package/src/{billing/controllers/AdminBillingController.ts → api/payments/controllers/AdminPaymentController.ts} +26 -21
- package/src/{billing/controllers/BillingController.ts → api/payments/controllers/PaymentController.ts} +23 -11
- package/src/{billing → api/payments}/entities/paymentIntents.ts +1 -0
- package/src/{billing/errors/BillingError.ts → api/payments/errors/PaymentError.ts} +1 -1
- package/src/{billing → api/payments}/index.ts +31 -25
- package/src/{billing/providers/MemoryBillingProvider.ts → api/payments/providers/MemoryPaymentProvider.ts} +4 -4
- package/src/{billing/providers/BillingProvider.ts → api/payments/providers/PaymentProvider.ts} +9 -2
- package/src/{billing → api/payments}/services/PaymentMethodService.ts +5 -5
- package/src/{billing/services/BillingService.ts → api/payments/services/PaymentService.ts} +94 -18
- package/src/api/subscriptions/__tests__/BillingService.spec.ts +218 -0
- package/src/api/subscriptions/__tests__/SubscriptionService.spec.ts +278 -0
- package/src/api/subscriptions/controllers/AdminSubscriptionController.ts +212 -0
- package/src/api/subscriptions/controllers/SubscriptionController.ts +189 -0
- package/src/api/subscriptions/entities/subscriptionEvents.ts +54 -0
- package/src/api/subscriptions/entities/subscriptions.ts +68 -0
- package/src/api/subscriptions/index.ts +144 -0
- package/src/api/subscriptions/jobs/SubscriptionJobs.ts +382 -0
- package/src/api/subscriptions/middleware/$requireLimit.ts +50 -0
- package/src/api/subscriptions/middleware/$requirePlan.ts +49 -0
- package/src/api/subscriptions/notifications/SubscriptionNotifications.ts +110 -0
- package/src/api/subscriptions/schemas/cancelSubscriptionSchema.ts +8 -0
- package/src/api/subscriptions/schemas/changePlanSchema.ts +9 -0
- package/src/api/subscriptions/schemas/createSubscriptionSchema.ts +11 -0
- package/src/api/subscriptions/schemas/entitlementsSchema.ts +21 -0
- package/src/api/subscriptions/schemas/mrrSchema.ts +13 -0
- package/src/api/subscriptions/schemas/planDefinitionSchema.ts +71 -0
- package/src/api/subscriptions/schemas/planResourceSchema.ts +25 -0
- package/src/api/subscriptions/schemas/subscriptionEventResourceSchema.ts +8 -0
- package/src/api/subscriptions/schemas/subscriptionQuerySchema.ts +19 -0
- package/src/api/subscriptions/schemas/subscriptionResourceSchema.ts +6 -0
- package/src/api/subscriptions/schemas/subscriptionSettingsSchema.ts +32 -0
- package/src/api/subscriptions/schemas/subscriptionStatsSchema.ts +23 -0
- package/src/api/subscriptions/services/BillingService.ts +437 -0
- package/src/api/subscriptions/services/SubscriptionConfig.ts +56 -0
- package/src/api/subscriptions/services/SubscriptionService.ts +867 -0
- package/src/api/subscriptions/services/UsageService.ts +118 -0
- package/src/api/users/__tests__/AdminUserController.spec.ts +80 -1
- package/src/api/users/__tests__/CredentialService.spec.ts +177 -0
- package/src/api/users/__tests__/EmailVerification.spec.ts +29 -18
- package/src/api/users/__tests__/PasswordReset.spec.ts +3 -0
- package/src/api/users/__tests__/RegistrationService.spec.ts +148 -1
- package/src/api/users/__tests__/SessionService.spec.ts +142 -1
- package/src/api/users/atoms/realmAuthSettingsAtom.ts +10 -1
- package/src/api/users/controllers/UserController.ts +3 -8
- package/src/api/users/notifications/UserNotifications.ts +23 -0
- package/src/api/users/primitives/$realm.ts +24 -0
- package/src/api/users/schemas/loginSchema.ts +1 -1
- package/src/api/users/services/CredentialService.ts +57 -7
- package/src/api/users/services/RegistrationService.ts +50 -11
- package/src/api/users/services/SessionService.ts +64 -9
- package/src/api/users/services/UserService.ts +21 -12
- package/src/api/workflows/__tests__/$workflow.spec.ts +616 -0
- package/src/api/workflows/controllers/AdminWorkflowController.ts +191 -0
- package/src/api/workflows/entities/workflowExecutions.ts +74 -0
- package/src/api/workflows/entities/workflowStepExecutions.ts +74 -0
- package/src/api/workflows/entities/workflowStepLogs.ts +13 -0
- package/src/api/workflows/index.browser.ts +22 -0
- package/src/api/workflows/index.ts +124 -0
- package/src/api/workflows/jobs/WorkflowJobs.ts +77 -0
- package/src/api/workflows/primitives/$workflow.ts +202 -0
- package/src/api/workflows/providers/WorkflowProvider.ts +1284 -0
- package/src/api/workflows/schemas/workflowActivitySchema.ts +15 -0
- package/src/api/workflows/schemas/workflowConfigAtom.ts +51 -0
- package/src/api/workflows/schemas/workflowExecutionDetailSchema.ts +18 -0
- package/src/api/workflows/schemas/workflowExecutionQuerySchema.ts +26 -0
- package/src/api/workflows/schemas/workflowExecutionResourceSchema.ts +30 -0
- package/src/api/workflows/schemas/workflowRegistrationSchema.ts +26 -0
- package/src/api/workflows/schemas/workflowStatsSchema.ts +16 -0
- package/src/api/workflows/schemas/workflowStepExecutionResourceSchema.ts +15 -0
- package/src/api/workflows/services/WorkflowService.ts +382 -0
- package/src/captcha/__tests__/MemoryCaptchaProvider.spec.ts +74 -0
- package/src/captcha/index.ts +33 -0
- package/src/captcha/providers/CaptchaProvider.ts +17 -0
- package/src/captcha/providers/MemoryCaptchaProvider.ts +65 -0
- package/src/captcha/providers/TurnstileCaptchaProvider.ts +125 -0
- package/src/cli/core/atoms/buildOptions.ts +57 -0
- package/src/cli/core/commands/build.ts +2 -0
- package/src/cli/core/providers/ViteDevServerProvider.ts +1 -1
- package/src/cli/core/services/ViteUtils.ts +5 -2
- package/src/cli/core/tasks/BuildClientTask.ts +3 -1
- package/src/cli/core/tasks/BuildCloudflareTask.ts +4 -0
- package/src/cli/core/tasks/BuildPwaTask.ts +81 -0
- package/src/cli/core/templates/webAppRouterTs.ts +5 -58
- package/src/cli/platform/adapters/CloudflareAdapter.ts +24 -0
- package/src/cli/platform/atoms/platformOptions.ts +19 -3
- package/src/cli/platform/hooks/PlatformHook.ts +51 -0
- package/src/cli/platform/index.ts +1 -0
- package/src/cli/platform/services/CloudflareApi.ts +22 -1
- package/src/cli/platform/services/PlatformOrchestrator.ts +67 -2
- package/src/cli/vendor/__tests__/VendorService.spec.ts +322 -178
- package/src/cli/vendor/commands/VendorCommand.ts +41 -38
- package/src/cli/vendor/services/VendorService.ts +234 -31
- package/src/command/__tests__/CliProvider.spec.ts +45 -0
- package/src/command/providers/CliProvider.ts +3 -4
- package/src/core/__tests__/TypeProvider.spec.ts +4 -2
- package/src/core/providers/SchemaValidator.ts +1 -1
- package/src/core/providers/TypeProvider.ts +46 -3
- package/src/orm/__tests__/enums.spec.ts +22 -29
- package/src/orm/__tests__/orm-showcase-tests.ts +430 -0
- package/src/orm/__tests__/orm-showcase.spec.ts +167 -0
- package/src/orm/core/providers/DatabaseTypeProvider.ts +0 -29
- package/src/orm/core/services/Repository.ts +20 -6
- package/src/orm/postgres/services/PostgresModelBuilder.ts +3 -6
- package/src/react/i18n/__tests__/I18nProvider.spec.ts +83 -0
- package/src/react/i18n/providers/I18nProvider.ts +12 -10
- package/src/react/router/__tests__/$page.browser.spec.tsx +157 -0
- package/src/react/router/providers/ReactBrowserProvider.ts +39 -0
- package/src/react/router/providers/ReactBrowserRouterProvider.ts +22 -0
- package/src/security/__tests__/$secure-combinations.spec.ts +945 -0
- package/src/security/primitives/$issuer.ts +3 -1
- package/src/security/primitives/$secure.ts +28 -0
- package/src/server/auth/index.ts +7 -0
- package/src/server/auth/primitives/$auth.ts +37 -3
- package/src/server/auth/primitives/$authApple.ts +114 -4
- package/src/server/auth/primitives/$authFacebook.ts +98 -0
- package/src/server/auth/primitives/$authFranceConnect.ts +105 -0
- package/src/server/auth/primitives/$authGithub.ts +22 -16
- package/src/server/auth/primitives/$authMicrosoft.ts +88 -0
- package/src/server/auth/providers/ServerAuthProvider.ts +197 -72
- package/src/server/cookies/providers/ServerCookiesProvider.ts +3 -0
- package/src/server/core/__tests__/ServerRouterProvider-errorHandler.spec.ts +1 -1
- package/src/websocket/providers/NodeWebSocketServerProvider.ts +3 -1
- package/dist/billing/index.d.ts.map +0 -1
- package/dist/billing/index.js.map +0 -1
- package/src/billing/__tests__/BillingService.spec.ts +0 -136
- /package/src/{billing → api/payments}/entities/paymentMethods.ts +0 -0
- /package/src/{billing → api/payments}/entities/refunds.ts +0 -0
- /package/src/{billing → api/payments}/schemas/intentSchemas.ts +0 -0
- /package/src/{billing → api/payments}/schemas/paymentMethodSchemas.ts +0 -0
- /package/src/{billing → api/payments}/schemas/refundSchemas.ts +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { RunnerMethod } from "alepha/command";
|
|
2
|
+
import type { PlatformContext } from "../adapters/PlatformAdapter.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Context passed to platform hooks.
|
|
6
|
+
*
|
|
7
|
+
* Extends PlatformContext with the fully-qualified base URL of the
|
|
8
|
+
* deployed app (derived from `envConfig.domain` or the adapter's deploy
|
|
9
|
+
* URL) and the active RunnerMethod.
|
|
10
|
+
*/
|
|
11
|
+
export interface PlatformHookContext extends PlatformContext {
|
|
12
|
+
/**
|
|
13
|
+
* Fully-qualified base URL of the deployed app, e.g. "https://foo.com".
|
|
14
|
+
*/
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
run: RunnerMethod;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Third-party provisioning hook for `alepha platform up` / `down`.
|
|
21
|
+
*
|
|
22
|
+
* Plugins can extend this to register resources in external services
|
|
23
|
+
* (Stripe webhooks, Sentry projects, Resend domains, etc.) tied to a
|
|
24
|
+
* deployment. Hooks are discovered via `alepha.services(PlatformHook)`,
|
|
25
|
+
* so adding a plugin to `services: [...]` in `alepha.config.ts` is all
|
|
26
|
+
* it takes to wire one in.
|
|
27
|
+
*
|
|
28
|
+
* Lifecycle:
|
|
29
|
+
* - `register` runs after `deploy` and before `adapter.secrets()` so
|
|
30
|
+
* any secret a hook writes to `.env.<env>` is picked up in the same
|
|
31
|
+
* `up` cycle.
|
|
32
|
+
* - `unregister` runs on `down` before `adapter.teardown()`.
|
|
33
|
+
*
|
|
34
|
+
* Implementations MUST be idempotent: `register` is called on every `up`.
|
|
35
|
+
*/
|
|
36
|
+
export abstract class PlatformHook {
|
|
37
|
+
/**
|
|
38
|
+
* Stable identifier. Used for log output.
|
|
39
|
+
*/
|
|
40
|
+
abstract readonly name: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Create or update external resources. Must tolerate pre-existing state.
|
|
44
|
+
*/
|
|
45
|
+
abstract register(ctx: PlatformHookContext): Promise<void>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Remove external resources. Must tolerate missing state.
|
|
49
|
+
*/
|
|
50
|
+
abstract unregister(ctx: PlatformHookContext): Promise<void>;
|
|
51
|
+
}
|
|
@@ -101,6 +101,7 @@ export * from "./adapters/VercelAdapter.ts";
|
|
|
101
101
|
export * from "./atoms/platformOptions.ts";
|
|
102
102
|
export * from "./commands/platform.ts";
|
|
103
103
|
export * from "./commands/SecretsCommand.ts";
|
|
104
|
+
export * from "./hooks/PlatformHook.ts";
|
|
104
105
|
export * from "./providers/GitHubSecretStore.ts";
|
|
105
106
|
export * from "./providers/MemorySecretStore.ts";
|
|
106
107
|
export * from "./providers/PlatformCacheProvider.ts";
|
|
@@ -67,6 +67,19 @@ export class CloudflareApi {
|
|
|
67
67
|
|
|
68
68
|
protected token?: string;
|
|
69
69
|
protected accountId?: string;
|
|
70
|
+
protected jurisdiction?: "eu" | "fedramp";
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Set the Cloudflare data jurisdiction for R2 and D1 resources.
|
|
74
|
+
*
|
|
75
|
+
* R2 buckets and D1 databases created under a jurisdiction live in a
|
|
76
|
+
* separate namespace — every R2 API call (list/create/delete) must include
|
|
77
|
+
* the `cf-r2-jurisdiction` header, and D1 create must include the field
|
|
78
|
+
* in the request body. Omit / pass `undefined` for the default (global).
|
|
79
|
+
*/
|
|
80
|
+
public setJurisdiction(jurisdiction?: "eu" | "fedramp"): void {
|
|
81
|
+
this.jurisdiction = jurisdiction;
|
|
82
|
+
}
|
|
70
83
|
|
|
71
84
|
// -------------------------------------------------------------------------
|
|
72
85
|
// Auth
|
|
@@ -127,7 +140,11 @@ export class CloudflareApi {
|
|
|
127
140
|
`/accounts/${accountId}/d1/database`,
|
|
128
141
|
{
|
|
129
142
|
method: "POST",
|
|
130
|
-
body: {
|
|
143
|
+
body: {
|
|
144
|
+
name,
|
|
145
|
+
primary_location_hint: location,
|
|
146
|
+
...(this.jurisdiction ? { jurisdiction: this.jurisdiction } : {}),
|
|
147
|
+
},
|
|
131
148
|
bodySchema: createD1BodySchema,
|
|
132
149
|
schema: cloudflareD1Schema,
|
|
133
150
|
},
|
|
@@ -392,6 +409,10 @@ export class CloudflareApi {
|
|
|
392
409
|
Authorization: `Bearer ${token}`,
|
|
393
410
|
};
|
|
394
411
|
|
|
412
|
+
if (this.jurisdiction && /\/r2\//.test(path)) {
|
|
413
|
+
headers["cf-r2-jurisdiction"] = this.jurisdiction;
|
|
414
|
+
}
|
|
415
|
+
|
|
395
416
|
const init: RequestInit = { method, headers };
|
|
396
417
|
|
|
397
418
|
if (body) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $inject, AlephaError } from "alepha";
|
|
1
|
+
import { $inject, Alepha, AlephaError } from "alepha";
|
|
2
2
|
import type { RunnerMethod } from "alepha/command";
|
|
3
3
|
import { $logger, ConsoleColorProvider } from "alepha/logger";
|
|
4
4
|
import { CloudflareAdapter } from "../adapters/CloudflareAdapter.ts";
|
|
@@ -9,6 +9,10 @@ import type {
|
|
|
9
9
|
PlatformState,
|
|
10
10
|
} from "../adapters/PlatformAdapter.ts";
|
|
11
11
|
import { VercelAdapter } from "../adapters/VercelAdapter.ts";
|
|
12
|
+
import {
|
|
13
|
+
PlatformHook,
|
|
14
|
+
type PlatformHookContext,
|
|
15
|
+
} from "../hooks/PlatformHook.ts";
|
|
12
16
|
import { type NamingContext, NamingService } from "./NamingService.ts";
|
|
13
17
|
import {
|
|
14
18
|
PlatformInspector,
|
|
@@ -28,6 +32,7 @@ export class PlatformOrchestrator {
|
|
|
28
32
|
protected readonly naming = $inject(NamingService);
|
|
29
33
|
protected readonly cloudflareAdapter = $inject(CloudflareAdapter);
|
|
30
34
|
protected readonly vercelAdapter = $inject(VercelAdapter);
|
|
35
|
+
protected readonly alepha = $inject(Alepha);
|
|
31
36
|
|
|
32
37
|
// -------------------------------------------------------------------------
|
|
33
38
|
// Adapter resolution
|
|
@@ -104,7 +109,12 @@ export class PlatformOrchestrator {
|
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
111
|
|
|
107
|
-
// 7.
|
|
112
|
+
// 7. Platform hooks (register external resources: Stripe webhooks, etc.)
|
|
113
|
+
// Run before secrets() so any secret a hook writes to .env.<env>
|
|
114
|
+
// gets pushed to the deployed worker in the same up cycle.
|
|
115
|
+
await this.runHooks("register", ctx, urls, run);
|
|
116
|
+
|
|
117
|
+
// 8. Secrets (push .env.{env} secrets to deployed workers)
|
|
108
118
|
await adapter.secrets(ctx, run);
|
|
109
119
|
|
|
110
120
|
run.end();
|
|
@@ -166,6 +176,9 @@ export class PlatformOrchestrator {
|
|
|
166
176
|
// Auth
|
|
167
177
|
await adapter.authenticate(ctx, run);
|
|
168
178
|
|
|
179
|
+
// Platform hooks (tear down external resources first, while creds still valid)
|
|
180
|
+
await this.runHooks("unregister", ctx, [], run);
|
|
181
|
+
|
|
169
182
|
// Teardown
|
|
170
183
|
await adapter.teardown(ctx, run);
|
|
171
184
|
run.end();
|
|
@@ -173,6 +186,58 @@ export class PlatformOrchestrator {
|
|
|
173
186
|
return true;
|
|
174
187
|
}
|
|
175
188
|
|
|
189
|
+
// -------------------------------------------------------------------------
|
|
190
|
+
// Platform hooks
|
|
191
|
+
// -------------------------------------------------------------------------
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Run all registered PlatformHook instances.
|
|
195
|
+
*
|
|
196
|
+
* Discovered dynamically via `alepha.services(PlatformHook)`: any plugin
|
|
197
|
+
* that registers a PlatformHook subclass in its `$module.services`
|
|
198
|
+
* participates automatically, without the core knowing about it.
|
|
199
|
+
*/
|
|
200
|
+
protected async runHooks(
|
|
201
|
+
phase: "register" | "unregister",
|
|
202
|
+
ctx: PlatformContext,
|
|
203
|
+
deployUrls: string[],
|
|
204
|
+
run: RunnerMethod,
|
|
205
|
+
): Promise<void> {
|
|
206
|
+
const hooks = this.alepha.services(PlatformHook);
|
|
207
|
+
if (hooks.length === 0) return;
|
|
208
|
+
|
|
209
|
+
const baseUrl = ctx.envConfig.domain
|
|
210
|
+
? `https://${ctx.envConfig.domain}`
|
|
211
|
+
: deployUrls[0];
|
|
212
|
+
|
|
213
|
+
if (!baseUrl) {
|
|
214
|
+
this.log.debug("Skipping platform hooks: no base URL available");
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const hookCtx: PlatformHookContext = { ...ctx, baseUrl, run };
|
|
219
|
+
|
|
220
|
+
for (const hook of hooks) {
|
|
221
|
+
this.log.info(`Platform hook: ${hook.name} (${phase})`);
|
|
222
|
+
try {
|
|
223
|
+
if (phase === "register") {
|
|
224
|
+
await hook.register(hookCtx);
|
|
225
|
+
} else {
|
|
226
|
+
await hook.unregister(hookCtx);
|
|
227
|
+
}
|
|
228
|
+
} catch (err) {
|
|
229
|
+
// unregister must never block teardown
|
|
230
|
+
if (phase === "unregister") {
|
|
231
|
+
this.log.warn(
|
|
232
|
+
`Platform hook ${hook.name} failed to unregister: ${(err as Error).message}`,
|
|
233
|
+
);
|
|
234
|
+
} else {
|
|
235
|
+
throw err;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
176
241
|
// -------------------------------------------------------------------------
|
|
177
242
|
// plan
|
|
178
243
|
// -------------------------------------------------------------------------
|