devflare 1.0.0-next.5 → 1.0.0-next.50
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/LICENSE +21 -0
- package/LLM.md +17312 -2139
- package/README.md +394 -605
- package/bin/devflare.js +30 -14
- package/dist/_chunks/account-BI3WZMDy.js +462 -0
- package/dist/_chunks/account-resources-CsmVowJp.js +159 -0
- package/dist/_chunks/ai-CBEuLdoP.js +322 -0
- package/dist/_chunks/api-TzdliH-6.js +568 -0
- package/dist/_chunks/build-artifacts-DU5V0J0Z.js +483 -0
- package/dist/_chunks/build-e0KR38-4.js +24 -0
- package/dist/_chunks/cli-DuUz10Mn.js +1163 -0
- package/dist/_chunks/cloudflare-BaloqI3H.js +157 -0
- package/dist/_chunks/colors-DiK6wPJ5.js +13 -0
- package/dist/_chunks/command-utils-DA0Qx9_K.js +45 -0
- package/dist/_chunks/compiler-Zw16C9Pi.js +489 -0
- package/dist/_chunks/config-Brju62xy.js +78 -0
- package/dist/_chunks/config-path-DaL1ylZ_.js +42 -0
- package/dist/_chunks/context-CX50Y2Kb.js +2250 -0
- package/dist/_chunks/decorators-QmV57ixr.js +19 -0
- package/dist/_chunks/dependencies-C2oxFjU_.js +57 -0
- package/dist/_chunks/deploy-B-Kku1Vk.js +1032 -0
- package/dist/_chunks/dev-D4e_RRZn.js +3471 -0
- package/dist/_chunks/doctor-jm_K4dxL.js +219 -0
- package/dist/_chunks/durable-object-DMtH0XYX.js +234 -0
- package/dist/_chunks/env-S0_nMVz1.js +125 -0
- package/dist/_chunks/family-_9-mGSfO.js +143 -0
- package/dist/_chunks/generated-artifacts-dMJY4KAt.js +32 -0
- package/dist/_chunks/glob-CmQOvunB.js +56 -0
- package/dist/_chunks/init-DnkJOmpW.js +165 -0
- package/dist/_chunks/loader-Cr0_OWPy.js +1288 -0
- package/dist/_chunks/local-dev-vars-CTSa-wvF.js +81 -0
- package/dist/_chunks/local-hyperdrive-CJ90j46O.js +119 -0
- package/dist/_chunks/local-media-bindings-DsAW4AMF.js +335 -0
- package/dist/_chunks/local-secrets-DMPkmOn3.js +123 -0
- package/dist/_chunks/local-workflow-entrypoints-Cq_WJajd.js +90 -0
- package/dist/_chunks/login-FjTAAQbi.js +51 -0
- package/dist/_chunks/package-metadata-DjHBLB-z.js +39 -0
- package/dist/_chunks/preferences-BKp_7XJx.js +241 -0
- package/dist/_chunks/preview-C3Cdr8an.js +462 -0
- package/dist/_chunks/preview-registry-ClAbLTHH.js +1186 -0
- package/dist/_chunks/preview-resources-CGMBjsYB.js +359 -0
- package/dist/_chunks/previews-C7hs9-BT.js +1134 -0
- package/dist/_chunks/productions-T9Als4fE.js +411 -0
- package/dist/_chunks/ref-CYJNAAe_.js +178 -0
- package/dist/_chunks/remote-CZnP-HLJ.js +79 -0
- package/dist/_chunks/remote-config-D39BY9ji.js +132 -0
- package/dist/_chunks/resolve-package-qizBfCIm.js +152 -0
- package/dist/_chunks/rolldown-runtime-CvQ6eiug.js +14 -0
- package/dist/_chunks/routes-BFYCqHb-.js +833 -0
- package/dist/_chunks/runtime-DL-Nz3k8.js +550 -0
- package/dist/_chunks/schema-normalization-BCwTLTGp.js +660 -0
- package/dist/_chunks/secrets-DIpJGe6C.js +95 -0
- package/dist/_chunks/tail-IY-ijYmv.js +239 -0
- package/dist/_chunks/token-Dmi0KXyX.js +333 -0
- package/dist/_chunks/tokens-iVcgNXi-.js +221 -0
- package/dist/_chunks/types-DoKsMYfm.js +484 -0
- package/dist/_chunks/ui-BUoZApvE.js +103 -0
- package/dist/_chunks/usage-BBTGzjon.js +272 -0
- package/dist/_chunks/vite-CGtVNf5E.js +1267 -0
- package/dist/_chunks/vite-utils-OVLMV605.js +183 -0
- package/dist/_chunks/worker-BEZI4od1.js +410 -0
- package/dist/_chunks/worker-bundler-dTTnYU3n.js +458 -0
- package/dist/_chunks/worker-entrypoint-CQW77lG8.js +247 -0
- package/dist/_chunks/workerName-CFJsLZA-.js +23 -0
- package/dist/bridge/client.d.ts +49 -7
- package/dist/bridge/client.d.ts.map +1 -1
- package/dist/bridge/gateway-runtime.d.ts +8 -0
- package/dist/bridge/gateway-runtime.d.ts.map +1 -0
- package/dist/bridge/index.d.ts +6 -6
- package/dist/bridge/index.d.ts.map +1 -1
- package/dist/bridge/log.d.ts +5 -0
- package/dist/bridge/log.d.ts.map +1 -0
- package/dist/bridge/miniflare.d.ts +82 -2
- package/dist/bridge/miniflare.d.ts.map +1 -1
- package/dist/bridge/proxy.d.ts +12 -11
- package/dist/bridge/proxy.d.ts.map +1 -1
- package/dist/bridge/server.d.ts +2 -1
- package/dist/bridge/server.d.ts.map +1 -1
- package/dist/bridge/v2/body-streams.d.ts +53 -0
- package/dist/bridge/v2/body-streams.d.ts.map +1 -0
- package/dist/bridge/v2/codec.d.ts +106 -0
- package/dist/bridge/v2/codec.d.ts.map +1 -0
- package/dist/bridge/v2/control-messages.d.ts +46 -0
- package/dist/bridge/v2/control-messages.d.ts.map +1 -0
- package/dist/bridge/v2/frames.d.ts +109 -0
- package/dist/bridge/v2/frames.d.ts.map +1 -0
- package/dist/bridge/v2/index.d.ts +11 -0
- package/dist/bridge/v2/index.d.ts.map +1 -0
- package/dist/bridge/v2/serialization.d.ts +48 -0
- package/dist/bridge/v2/serialization.d.ts.map +1 -0
- package/dist/bridge/v2/transport.d.ts +31 -0
- package/dist/bridge/v2/transport.d.ts.map +1 -0
- package/dist/bridge/v2/value-codec.d.ts +61 -0
- package/dist/bridge/v2/value-codec.d.ts.map +1 -0
- package/dist/bridge/{serialization.d.ts → v2/value-serialization.d.ts} +40 -18
- package/dist/bridge/v2/value-serialization.d.ts.map +1 -0
- package/dist/bridge/{protocol.d.ts → v2/wire.d.ts} +32 -8
- package/dist/bridge/v2/wire.d.ts.map +1 -0
- package/dist/bridge/v2/ws-relay.d.ts +53 -0
- package/dist/bridge/v2/ws-relay.d.ts.map +1 -0
- package/dist/browser-shim/handler.d.ts +2 -2
- package/dist/browser-shim/handler.d.ts.map +1 -1
- package/dist/browser-shim/index.d.ts +2 -2
- package/dist/browser-shim/server.d.ts +63 -0
- package/dist/browser-shim/server.d.ts.map +1 -1
- package/dist/browser.d.ts +5411 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +80 -0
- package/dist/bundler/defaults.d.ts +23 -0
- package/dist/bundler/defaults.d.ts.map +1 -0
- package/dist/bundler/do-bundler.d.ts +7 -0
- package/dist/bundler/do-bundler.d.ts.map +1 -1
- package/dist/bundler/index.d.ts +3 -1
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/rolldown-shared.d.ts +53 -0
- package/dist/bundler/rolldown-shared.d.ts.map +1 -0
- package/dist/bundler/worker-bundler.d.ts +13 -0
- package/dist/bundler/worker-bundler.d.ts.map +1 -0
- package/dist/bundler/worker-compat.d.ts +4 -0
- package/dist/bundler/worker-compat.d.ts.map +1 -0
- package/dist/cli/build-manifest.d.ts +66 -0
- package/dist/cli/build-manifest.d.ts.map +1 -0
- package/dist/cli/command-utils.d.ts +18 -0
- package/dist/cli/command-utils.d.ts.map +1 -0
- package/dist/cli/commands/account.d.ts +2 -2
- package/dist/cli/commands/account.d.ts.map +1 -1
- package/dist/cli/commands/ai.d.ts +1 -1
- package/dist/cli/commands/ai.d.ts.map +1 -1
- package/dist/cli/commands/build-artifacts.d.ts +40 -0
- package/dist/cli/commands/build-artifacts.d.ts.map +1 -0
- package/dist/cli/commands/build.d.ts +2 -2
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/config.d.ts +4 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/deploy/metadata.d.ts +18 -0
- package/dist/cli/commands/deploy/metadata.d.ts.map +1 -0
- package/dist/cli/commands/deploy/prepare.d.ts +23 -0
- package/dist/cli/commands/deploy/prepare.d.ts.map +1 -0
- package/dist/cli/commands/deploy/runtime.d.ts +4 -0
- package/dist/cli/commands/deploy/runtime.d.ts.map +1 -0
- package/dist/cli/commands/deploy/verification.d.ts +36 -0
- package/dist/cli/commands/deploy/verification.d.ts.map +1 -0
- package/dist/cli/commands/deploy.d.ts +2 -2
- package/dist/cli/commands/deploy.d.ts.map +1 -1
- package/dist/cli/commands/dev.d.ts +9 -1
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/doctor.d.ts +2 -2
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/cli/commands/init.d.ts +2 -2
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/login.d.ts +4 -0
- package/dist/cli/commands/login.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/cleanup.d.ts +9 -0
- package/dist/cli/commands/previews-support/cleanup.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/family.d.ts +10 -0
- package/dist/cli/commands/previews-support/family.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/render.d.ts +8 -0
- package/dist/cli/commands/previews-support/render.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/theme.d.ts +10 -0
- package/dist/cli/commands/previews-support/theme.d.ts.map +1 -0
- package/dist/cli/commands/previews-support/types.d.ts +70 -0
- package/dist/cli/commands/previews-support/types.d.ts.map +1 -0
- package/dist/cli/commands/previews.d.ts +4 -0
- package/dist/cli/commands/previews.d.ts.map +1 -0
- package/dist/cli/commands/productions.d.ts +4 -0
- package/dist/cli/commands/productions.d.ts.map +1 -0
- package/dist/cli/commands/remote.d.ts +1 -1
- package/dist/cli/commands/remote.d.ts.map +1 -1
- package/dist/cli/commands/secrets.d.ts +4 -0
- package/dist/cli/commands/secrets.d.ts.map +1 -0
- package/dist/cli/commands/tail.d.ts +44 -0
- package/dist/cli/commands/tail.d.ts.map +1 -0
- package/dist/cli/commands/token.d.ts +4 -0
- package/dist/cli/commands/token.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/discovery.d.ts +7 -0
- package/dist/cli/commands/type-generation/discovery.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/generator.d.ts +121 -0
- package/dist/cli/commands/type-generation/generator.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/models.d.ts +27 -0
- package/dist/cli/commands/type-generation/models.d.ts.map +1 -0
- package/dist/cli/commands/types.d.ts +2 -2
- package/dist/cli/commands/types.d.ts.map +1 -1
- package/dist/cli/commands/worker.d.ts +4 -0
- package/dist/cli/commands/worker.d.ts.map +1 -0
- package/dist/cli/config-path.d.ts +6 -0
- package/dist/cli/config-path.d.ts.map +1 -0
- package/dist/cli/dependencies.d.ts +2 -1
- package/dist/cli/dependencies.d.ts.map +1 -1
- package/dist/cli/deploy-strategy.d.ts +17 -0
- package/dist/cli/deploy-strategy.d.ts.map +1 -0
- package/dist/cli/deploy-target.d.ts +17 -0
- package/dist/cli/deploy-target.d.ts.map +1 -0
- package/dist/cli/generated-artifacts.d.ts +12 -0
- package/dist/cli/generated-artifacts.d.ts.map +1 -0
- package/dist/cli/gradual-deploy.d.ts +49 -0
- package/dist/cli/gradual-deploy.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/account.d.ts +3 -0
- package/dist/cli/help-pages/pages/account.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/core.d.ts +4 -0
- package/dist/cli/help-pages/pages/core.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/index.d.ts +3 -0
- package/dist/cli/help-pages/pages/index.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/misc.d.ts +3 -0
- package/dist/cli/help-pages/pages/misc.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/previews.d.ts +3 -0
- package/dist/cli/help-pages/pages/previews.d.ts.map +1 -0
- package/dist/cli/help-pages/pages/productions.d.ts +3 -0
- package/dist/cli/help-pages/pages/productions.d.ts.map +1 -0
- package/dist/cli/help-pages/render.d.ts +12 -0
- package/dist/cli/help-pages/render.d.ts.map +1 -0
- package/dist/cli/help-pages/shared.d.ts +15 -0
- package/dist/cli/help-pages/shared.d.ts.map +1 -0
- package/dist/cli/help-pages/types.d.ts +23 -0
- package/dist/cli/help-pages/types.d.ts.map +1 -0
- package/dist/cli/help.d.ts +6 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/package-metadata.d.ts +16 -0
- package/dist/cli/package-metadata.d.ts.map +1 -0
- package/dist/cli/preview-bindings.d.ts +49 -0
- package/dist/cli/preview-bindings.d.ts.map +1 -0
- package/dist/cli/preview.d.ts +10 -0
- package/dist/cli/preview.d.ts.map +1 -0
- package/dist/cli/ui.d.ts +37 -0
- package/dist/cli/ui.d.ts.map +1 -0
- package/dist/cli/workspace-build-guard.d.ts +14 -0
- package/dist/cli/workspace-build-guard.d.ts.map +1 -0
- package/dist/cli/wrangler-auth.d.ts +1 -1
- package/dist/cloudflare/account-core.d.ts +6 -0
- package/dist/cloudflare/account-core.d.ts.map +1 -0
- package/dist/cloudflare/account-resources.d.ts +40 -0
- package/dist/cloudflare/account-resources.d.ts.map +1 -0
- package/dist/cloudflare/account-status.d.ts +11 -0
- package/dist/cloudflare/account-status.d.ts.map +1 -0
- package/dist/cloudflare/account-workers.d.ts +14 -0
- package/dist/cloudflare/account-workers.d.ts.map +1 -0
- package/dist/cloudflare/account.d.ts +7 -64
- package/dist/cloudflare/account.d.ts.map +1 -1
- package/dist/cloudflare/api.d.ts +71 -3
- package/dist/cloudflare/api.d.ts.map +1 -1
- package/dist/cloudflare/auth.d.ts +1 -1
- package/dist/cloudflare/auth.d.ts.map +1 -1
- package/dist/cloudflare/index.d.ts +61 -6
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +4 -13
- package/dist/cloudflare/known-permission-group-ids.generated.d.ts +10 -0
- package/dist/cloudflare/known-permission-group-ids.generated.d.ts.map +1 -0
- package/dist/cloudflare/kv-namespace.d.ts +4 -0
- package/dist/cloudflare/kv-namespace.d.ts.map +1 -0
- package/dist/cloudflare/preferences.d.ts +7 -0
- package/dist/cloudflare/preferences.d.ts.map +1 -1
- package/dist/cloudflare/preview-registry-cache.d.ts +6 -0
- package/dist/cloudflare/preview-registry-cache.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-inference.d.ts +14 -0
- package/dist/cloudflare/preview-registry-inference.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-records.d.ts +4 -0
- package/dist/cloudflare/preview-registry-records.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-shape.d.ts +47 -0
- package/dist/cloudflare/preview-registry-shape.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-store.d.ts +14 -0
- package/dist/cloudflare/preview-registry-store.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-transport.d.ts +4 -0
- package/dist/cloudflare/preview-registry-transport.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry-types.d.ts +103 -0
- package/dist/cloudflare/preview-registry-types.d.ts.map +1 -0
- package/dist/cloudflare/preview-registry.d.ts +42 -0
- package/dist/cloudflare/preview-registry.d.ts.map +1 -0
- package/dist/cloudflare/preview-urls.d.ts +3 -0
- package/dist/cloudflare/preview-urls.d.ts.map +1 -0
- package/dist/cloudflare/registry-schema.d.ts +253 -0
- package/dist/cloudflare/registry-schema.d.ts.map +1 -0
- package/dist/cloudflare/remote-config.d.ts.map +1 -1
- package/dist/cloudflare/tokens.d.ts +44 -0
- package/dist/cloudflare/tokens.d.ts.map +1 -0
- package/dist/cloudflare/types.d.ts +124 -7
- package/dist/cloudflare/types.d.ts.map +1 -1
- package/dist/cloudflare/usage.d.ts +31 -3
- package/dist/cloudflare/usage.d.ts.map +1 -1
- package/dist/config/binding-resolution-helpers.d.ts +41 -0
- package/dist/config/binding-resolution-helpers.d.ts.map +1 -0
- package/dist/config/compatibility.d.ts +3 -0
- package/dist/config/compatibility.d.ts.map +1 -0
- package/dist/config/compiler/bindings.d.ts +14 -0
- package/dist/config/compiler/bindings.d.ts.map +1 -0
- package/dist/config/compiler/core-helpers.d.ts +6 -0
- package/dist/config/compiler/core-helpers.d.ts.map +1 -0
- package/dist/config/compiler/do-workers.d.ts +34 -0
- package/dist/config/compiler/do-workers.d.ts.map +1 -0
- package/dist/config/compiler/paths.d.ts +18 -0
- package/dist/config/compiler/paths.d.ts.map +1 -0
- package/dist/config/compiler/types.d.ts +298 -0
- package/dist/config/compiler/types.d.ts.map +1 -0
- package/dist/config/compiler.d.ts +22 -134
- package/dist/config/compiler.d.ts.map +1 -1
- package/dist/config/cron.d.ts +19 -0
- package/dist/config/cron.d.ts.map +1 -0
- package/dist/config/define.d.ts +8 -5
- package/dist/config/define.d.ts.map +1 -1
- package/dist/config/deploy-resources.d.ts +58 -0
- package/dist/config/deploy-resources.d.ts.map +1 -0
- package/dist/config/env-vars.d.ts +309 -0
- package/dist/config/env-vars.d.ts.map +1 -0
- package/dist/config/framework-providers.d.ts +9 -0
- package/dist/config/framework-providers.d.ts.map +1 -0
- package/dist/config/index.d.ts +12 -5
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/loader.d.ts +2 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/local-dev-vars.d.ts +15 -0
- package/dist/config/local-dev-vars.d.ts.map +1 -0
- package/dist/config/preview-resources.d.ts +83 -0
- package/dist/config/preview-resources.d.ts.map +1 -0
- package/dist/config/preview.d.ts +29 -0
- package/dist/config/preview.d.ts.map +1 -0
- package/dist/config/ref.d.ts +16 -25
- package/dist/config/ref.d.ts.map +1 -1
- package/dist/config/resolve-phased.d.ts +72 -0
- package/dist/config/resolve-phased.d.ts.map +1 -0
- package/dist/config/resolve.d.ts +11 -0
- package/dist/config/resolve.d.ts.map +1 -0
- package/dist/config/resource-resolution.d.ts +80 -0
- package/dist/config/resource-resolution.d.ts.map +1 -0
- package/dist/config/schema-bindings.d.ts +2025 -0
- package/dist/config/schema-bindings.d.ts.map +1 -0
- package/dist/config/schema-build.d.ts +67 -0
- package/dist/config/schema-build.d.ts.map +1 -0
- package/dist/config/schema-env.d.ts +3579 -0
- package/dist/config/schema-env.d.ts.map +1 -0
- package/dist/config/schema-normalization.d.ts +265 -0
- package/dist/config/schema-normalization.d.ts.map +1 -0
- package/dist/config/schema-runtime.d.ts +508 -0
- package/dist/config/schema-runtime.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-platform.d.ts +508 -0
- package/dist/config/schema-types-bindings-platform.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-resources.d.ts +767 -0
- package/dist/config/schema-types-bindings-resources.d.ts.map +1 -0
- package/dist/config/schema-types-bindings.d.ts +293 -0
- package/dist/config/schema-types-bindings.d.ts.map +1 -0
- package/dist/config/schema-types-build.d.ts +86 -0
- package/dist/config/schema-types-build.d.ts.map +1 -0
- package/dist/config/schema-types-runtime.d.ts +917 -0
- package/dist/config/schema-types-runtime.d.ts.map +1 -0
- package/dist/config/schema-types.d.ts +424 -0
- package/dist/config/schema-types.d.ts.map +1 -0
- package/dist/config/schema.d.ts +5324 -2011
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/service-bindings-validation.d.ts +36 -0
- package/dist/config/service-bindings-validation.d.ts.map +1 -0
- package/dist/config-entry.d.ts +7 -0
- package/dist/config-entry.d.ts.map +1 -0
- package/dist/config-entry.js +3 -0
- package/dist/decorators/durable-object.d.ts.map +1 -1
- package/dist/decorators/index.d.ts +2 -2
- package/dist/decorators/index.js +2 -9
- package/dist/dev-server/d1-migrations.d.ts +36 -0
- package/dist/dev-server/d1-migrations.d.ts.map +1 -0
- package/dist/dev-server/dev-server-state.d.ts +59 -0
- package/dist/dev-server/dev-server-state.d.ts.map +1 -0
- package/dist/dev-server/gateway-script.d.ts +21 -0
- package/dist/dev-server/gateway-script.d.ts.map +1 -0
- package/dist/dev-server/index.d.ts +1 -1
- package/dist/dev-server/miniflare-bindings.d.ts +81 -0
- package/dist/dev-server/miniflare-bindings.d.ts.map +1 -0
- package/dist/dev-server/miniflare-dev-config.d.ts +36 -0
- package/dist/dev-server/miniflare-dev-config.d.ts.map +1 -0
- package/dist/dev-server/miniflare-log.d.ts +20 -0
- package/dist/dev-server/miniflare-log.d.ts.map +1 -0
- package/dist/dev-server/miniflare-worker-config.d.ts +82 -0
- package/dist/dev-server/miniflare-worker-config.d.ts.map +1 -0
- package/dist/dev-server/reload-queue.d.ts +13 -0
- package/dist/dev-server/reload-queue.d.ts.map +1 -0
- package/dist/dev-server/runtime-stdio.d.ts +8 -0
- package/dist/dev-server/runtime-stdio.d.ts.map +1 -0
- package/dist/dev-server/server-startup-helpers.d.ts +84 -0
- package/dist/dev-server/server-startup-helpers.d.ts.map +1 -0
- package/dist/dev-server/server.d.ts +2 -0
- package/dist/dev-server/server.d.ts.map +1 -1
- package/dist/dev-server/vite-process.d.ts +15 -0
- package/dist/dev-server/vite-process.d.ts.map +1 -0
- package/dist/dev-server/vite-utils.d.ts +19 -1
- package/dist/dev-server/vite-utils.d.ts.map +1 -1
- package/dist/dev-server/worker-source-watcher.d.ts +17 -0
- package/dist/dev-server/worker-source-watcher.d.ts.map +1 -0
- package/dist/dev-server/worker-surface-paths.d.ts +6 -0
- package/dist/dev-server/worker-surface-paths.d.ts.map +1 -0
- package/dist/env.d.ts +10 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/index.d.ts +8 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -298
- package/dist/runtime/context-events.d.ts +13 -0
- package/dist/runtime/context-events.d.ts.map +1 -0
- package/dist/runtime/context-types.d.ts +82 -0
- package/dist/runtime/context-types.d.ts.map +1 -0
- package/dist/runtime/context.d.ts +20 -44
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/exports.d.ts +70 -55
- package/dist/runtime/exports.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +10 -3
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +5 -111
- package/dist/runtime/middleware.d.ts +119 -67
- package/dist/runtime/middleware.d.ts.map +1 -1
- package/dist/runtime/router/index.d.ts +7 -0
- package/dist/runtime/router/index.d.ts.map +1 -0
- package/dist/runtime/router/types.d.ts +24 -0
- package/dist/runtime/router/types.d.ts.map +1 -0
- package/dist/runtime/validation.d.ts +18 -4
- package/dist/runtime/validation.d.ts.map +1 -1
- package/dist/secrets/local-secrets.d.ts +46 -0
- package/dist/secrets/local-secrets.d.ts.map +1 -0
- package/dist/shims/local-hyperdrive.d.ts +12 -0
- package/dist/shims/local-hyperdrive.d.ts.map +1 -0
- package/dist/shims/local-media-bindings.d.ts +19 -0
- package/dist/shims/local-media-bindings.d.ts.map +1 -0
- package/dist/shims/local-worker-loader.d.ts +3 -0
- package/dist/shims/local-worker-loader.d.ts.map +1 -0
- package/dist/sveltekit/index.d.ts +1 -1
- package/dist/sveltekit/index.d.ts.map +1 -1
- package/dist/sveltekit/index.js +313 -167
- package/dist/sveltekit/local-bindings.d.ts +4 -0
- package/dist/sveltekit/local-bindings.d.ts.map +1 -0
- package/dist/sveltekit/platform.d.ts +20 -2
- package/dist/sveltekit/platform.d.ts.map +1 -1
- package/dist/test/ai-search.d.ts +39 -0
- package/dist/test/ai-search.d.ts.map +1 -0
- package/dist/test/alarm.d.ts +55 -0
- package/dist/test/alarm.d.ts.map +1 -0
- package/dist/test/binding-hints.d.ts +10 -0
- package/dist/test/binding-hints.d.ts.map +1 -0
- package/dist/test/cf.d.ts +71 -35
- package/dist/test/cf.d.ts.map +1 -1
- package/dist/test/containers.d.ts +87 -0
- package/dist/test/containers.d.ts.map +1 -0
- package/dist/test/email.d.ts +16 -7
- package/dist/test/email.d.ts.map +1 -1
- package/dist/test/index.d.ts +20 -21
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +4971 -70
- package/dist/test/offline-bindings.d.ts +115 -0
- package/dist/test/offline-bindings.d.ts.map +1 -0
- package/dist/test/queue.d.ts.map +1 -1
- package/dist/test/remote-ai.d.ts.map +1 -1
- package/dist/test/remote-cloudflare.d.ts +13 -0
- package/dist/test/remote-cloudflare.d.ts.map +1 -0
- package/dist/test/remote-vectorize.d.ts.map +1 -1
- package/dist/test/resolve-service-bindings.d.ts +64 -4
- package/dist/test/resolve-service-bindings.d.ts.map +1 -1
- package/dist/test/scheduled.d.ts.map +1 -1
- package/dist/test/should-skip.d.ts +14 -18
- package/dist/test/should-skip.d.ts.map +1 -1
- package/dist/test/simple-context-bindings.d.ts +13 -0
- package/dist/test/simple-context-bindings.d.ts.map +1 -0
- package/dist/test/simple-context-durable-objects.d.ts +6 -0
- package/dist/test/simple-context-durable-objects.d.ts.map +1 -0
- package/dist/test/simple-context-env.d.ts +35 -0
- package/dist/test/simple-context-env.d.ts.map +1 -0
- package/dist/test/simple-context-gateway-script.d.ts +2 -0
- package/dist/test/simple-context-gateway-script.d.ts.map +1 -0
- package/dist/test/simple-context-handlers.d.ts +12 -0
- package/dist/test/simple-context-handlers.d.ts.map +1 -0
- package/dist/test/simple-context-lifecycle.d.ts +32 -0
- package/dist/test/simple-context-lifecycle.d.ts.map +1 -0
- package/dist/test/simple-context-mfconfig.d.ts +10 -0
- package/dist/test/simple-context-mfconfig.d.ts.map +1 -0
- package/dist/test/simple-context-multi-worker.d.ts +16 -0
- package/dist/test/simple-context-multi-worker.d.ts.map +1 -0
- package/dist/test/simple-context-paths.d.ts +40 -0
- package/dist/test/simple-context-paths.d.ts.map +1 -0
- package/dist/test/simple-context-runtime.d.ts +19 -0
- package/dist/test/simple-context-runtime.d.ts.map +1 -0
- package/dist/test/simple-context-startup.d.ts +11 -0
- package/dist/test/simple-context-startup.d.ts.map +1 -0
- package/dist/test/simple-context-transport.d.ts +14 -0
- package/dist/test/simple-context-transport.d.ts.map +1 -0
- package/dist/test/simple-context.d.ts +8 -27
- package/dist/test/simple-context.d.ts.map +1 -1
- package/dist/test/tail.d.ts +3 -2
- package/dist/test/tail.d.ts.map +1 -1
- package/dist/test/utilities/analytics-engine.d.ts +22 -0
- package/dist/test/utilities/analytics-engine.d.ts.map +1 -0
- package/dist/test/utilities/artifacts.d.ts +11 -0
- package/dist/test/utilities/artifacts.d.ts.map +1 -0
- package/dist/test/utilities/context.d.ts +39 -0
- package/dist/test/utilities/context.d.ts.map +1 -0
- package/dist/test/utilities/d1.d.ts +21 -0
- package/dist/test/utilities/d1.d.ts.map +1 -0
- package/dist/test/utilities/env.d.ts +43 -0
- package/dist/test/utilities/env.d.ts.map +1 -0
- package/dist/test/utilities/kv.d.ts +11 -0
- package/dist/test/utilities/kv.d.ts.map +1 -0
- package/dist/test/utilities/media.d.ts +16 -0
- package/dist/test/utilities/media.d.ts.map +1 -0
- package/dist/test/utilities/platform.d.ts +41 -0
- package/dist/test/utilities/platform.d.ts.map +1 -0
- package/dist/test/utilities/queue.d.ts +5 -0
- package/dist/test/utilities/queue.d.ts.map +1 -0
- package/dist/test/utilities/r2.d.ts +2 -0
- package/dist/test/utilities/r2.d.ts.map +1 -0
- package/dist/test/utilities/stream-flagship.d.ts +27 -0
- package/dist/test/utilities/stream-flagship.d.ts.map +1 -0
- package/dist/test/utilities/vectorize.d.ts +38 -0
- package/dist/test/utilities/vectorize.d.ts.map +1 -0
- package/dist/test/utilities/workflows.d.ts +26 -0
- package/dist/test/utilities/workflows.d.ts.map +1 -0
- package/dist/test/utilities.d.ts +13 -98
- package/dist/test/utilities.d.ts.map +1 -1
- package/dist/test/worker.d.ts +6 -0
- package/dist/test/worker.d.ts.map +1 -1
- package/dist/transform/durable-object.d.ts.map +1 -1
- package/dist/transform/index.d.ts +2 -2
- package/dist/transform/worker-entrypoint.d.ts +5 -0
- package/dist/transform/worker-entrypoint.d.ts.map +1 -1
- package/dist/utils/entrypoint-discovery.d.ts +6 -3
- package/dist/utils/entrypoint-discovery.d.ts.map +1 -1
- package/dist/utils/glob.d.ts.map +1 -1
- package/dist/utils/resolve-package.d.ts.map +1 -1
- package/dist/utils/send-email.d.ts +15 -0
- package/dist/utils/send-email.d.ts.map +1 -0
- package/dist/utils/send-email.js +163 -0
- package/dist/vite/config-file.d.ts +25 -0
- package/dist/vite/config-file.d.ts.map +1 -0
- package/dist/vite/index.d.ts +3 -2
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +2 -339
- package/dist/vite/plugin-config-hook.d.ts +28 -0
- package/dist/vite/plugin-config-hook.d.ts.map +1 -0
- package/dist/vite/plugin-context.d.ts +27 -0
- package/dist/vite/plugin-context.d.ts.map +1 -0
- package/dist/vite/plugin-durable-objects.d.ts +18 -0
- package/dist/vite/plugin-durable-objects.d.ts.map +1 -0
- package/dist/vite/plugin-programmatic.d.ts +44 -0
- package/dist/vite/plugin-programmatic.d.ts.map +1 -0
- package/dist/vite/plugin-service-bindings.d.ts +13 -0
- package/dist/vite/plugin-service-bindings.d.ts.map +1 -0
- package/dist/vite/plugin-transform.d.ts +41 -0
- package/dist/vite/plugin-transform.d.ts.map +1 -0
- package/dist/vite/plugin.d.ts +10 -41
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/worker-entry/composed-worker.d.ts +7 -0
- package/dist/worker-entry/composed-worker.d.ts.map +1 -0
- package/dist/worker-entry/durable-object-discovery.d.ts +20 -0
- package/dist/worker-entry/durable-object-discovery.d.ts.map +1 -0
- package/dist/worker-entry/extensions.d.ts +5 -0
- package/dist/worker-entry/extensions.d.ts.map +1 -0
- package/dist/worker-entry/routes.d.ts +22 -0
- package/dist/worker-entry/routes.d.ts.map +1 -0
- package/dist/worker-entry/surface-paths.d.ts +26 -0
- package/dist/worker-entry/surface-paths.d.ts.map +1 -0
- package/dist/worker-entry/validate-fetch-style.d.ts +12 -0
- package/dist/worker-entry/validate-fetch-style.d.ts.map +1 -0
- package/dist/workflows/local-workflow-entrypoints.d.ts +7 -0
- package/dist/workflows/local-workflow-entrypoints.d.ts.map +1 -0
- package/package.json +159 -116
- package/R2.md +0 -170
- package/dist/account-rvrj687w.js +0 -397
- package/dist/ai-dx4fr9jh.js +0 -107
- package/dist/bridge/protocol.d.ts.map +0 -1
- package/dist/bridge/serialization.d.ts.map +0 -1
- package/dist/browser-shim/worker.d.ts +0 -14
- package/dist/browser-shim/worker.d.ts.map +0 -1
- package/dist/build-mnf6v8gd.js +0 -53
- package/dist/deploy-nhceck39.js +0 -70
- package/dist/dev-b9dmrj7b.js +0 -2417
- package/dist/doctor-fmgb3d28.js +0 -190
- package/dist/durable-object-t4kbb0yt.js +0 -13
- package/dist/index-07q6yxyc.js +0 -168
- package/dist/index-18hvb6gb.js +0 -194
- package/dist/index-1xpj0m4r.js +0 -57
- package/dist/index-37x76zdn.js +0 -4
- package/dist/index-3t6rypgc.js +0 -13
- package/dist/index-67qcae0f.js +0 -183
- package/dist/index-a855bdsx.js +0 -18
- package/dist/index-d8bdkx2h.js +0 -109
- package/dist/index-ep3445yc.js +0 -2225
- package/dist/index-gz1gndna.js +0 -307
- package/dist/index-hcex3rgh.js +0 -266
- package/dist/index-m2q41jwa.js +0 -462
- package/dist/index-n7rs26ft.js +0 -77
- package/dist/index-pf5s73n9.js +0 -1413
- package/dist/index-rbht7m9r.js +0 -36
- package/dist/index-tfyxa77h.js +0 -850
- package/dist/index-tk6ej9dj.js +0 -94
- package/dist/index-z14anrqp.js +0 -226
- package/dist/init-f9mgmew3.js +0 -186
- package/dist/remote-q59qk463.js +0 -97
- package/dist/test/bridge-context.d.ts +0 -76
- package/dist/test/bridge-context.d.ts.map +0 -1
- package/dist/test/multi-worker-context.d.ts +0 -114
- package/dist/test/multi-worker-context.d.ts.map +0 -1
- package/dist/types-5nyrz1sz.js +0 -454
- package/dist/worker-entrypoint-m9th0rg0.js +0 -13
|
@@ -0,0 +1,1288 @@
|
|
|
1
|
+
import { l as isEnvVarDescriptor, n as materializePreviewScopedConfig, u as loadDevflareDotenvIntoProcess } from "./preview-C3Cdr8an.js";
|
|
2
|
+
import { S as bindingsSchema, a as normalizeD1Binding, d as normalizeKVBinding, g as normalizeR2Binding, h as normalizeQueueProducer, l as normalizeHyperdriveBinding, n as getLocalKVNamespaceIdentifier, t as getLocalD1DatabaseIdentifier } from "./schema-normalization-BCwTLTGp.js";
|
|
3
|
+
import { d as getPrimaryAccount, n as getEffectiveAccountId } from "./preferences-BKp_7XJx.js";
|
|
4
|
+
import { _ as listR2Buckets, g as listQueues, h as listKVNamespaces, i as createR2Bucket, m as listHyperdrives, n as createKVNamespace, p as listD1Databases, r as createQueue, t as createD1Database, v as listVectorizeIndexes } from "./account-resources-CsmVowJp.js";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
7
|
+
import { readFile } from "node:fs/promises";
|
|
8
|
+
import { dirname, join, resolve } from "pathe";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
//#region src/config/compatibility.ts
|
|
11
|
+
const FORCED_COMPATIBILITY_FLAGS = ["nodejs_compat", "nodejs_als"];
|
|
12
|
+
function normalizeCompatibilityFlags(flags = []) {
|
|
13
|
+
return [...new Set([...FORCED_COMPATIBILITY_FLAGS, ...flags])];
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/config/schema-build.ts
|
|
17
|
+
const rolldownOptionsSchema = z.custom((value) => {
|
|
18
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19
|
+
}, { message: "Expected Rolldown options object" });
|
|
20
|
+
/**
|
|
21
|
+
* Rolldown configuration for Durable Object bundling.
|
|
22
|
+
* Controls Devflare's Rolldown-based DO bundler in local development.
|
|
23
|
+
*/
|
|
24
|
+
const rolldownConfigSchema = z.object({
|
|
25
|
+
target: z.string().optional(),
|
|
26
|
+
minify: z.boolean().optional(),
|
|
27
|
+
sourcemap: z.boolean().optional(),
|
|
28
|
+
options: rolldownOptionsSchema.optional()
|
|
29
|
+
}).optional();
|
|
30
|
+
/**
|
|
31
|
+
* Vite-related configuration namespace.
|
|
32
|
+
* This keeps Vite-specific configuration distinct from Rolldown/DO bundling.
|
|
33
|
+
*
|
|
34
|
+
* Note: raw Vite build/server configuration still belongs in `vite.config.*`.
|
|
35
|
+
* Devflare currently models `plugins` here and leaves room for future Vite-side
|
|
36
|
+
* config without overloading the root config shape.
|
|
37
|
+
*/
|
|
38
|
+
const viteConfigSchema = z.object({ plugins: z.array(z.unknown()).optional() }).catchall(z.unknown()).optional();
|
|
39
|
+
const envConfigSchemaInner = z.lazy(() => z.object(rootConfigShape).omit({
|
|
40
|
+
accountId: true,
|
|
41
|
+
wsRoutes: true
|
|
42
|
+
}).partial().strict());
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/config/cron.ts
|
|
45
|
+
const CRON_FIELDS = [
|
|
46
|
+
{
|
|
47
|
+
name: "minute",
|
|
48
|
+
min: 0,
|
|
49
|
+
max: 59
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "hour",
|
|
53
|
+
min: 0,
|
|
54
|
+
max: 23
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "day-of-month",
|
|
58
|
+
min: 1,
|
|
59
|
+
max: 31
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "month",
|
|
63
|
+
min: 1,
|
|
64
|
+
max: 12,
|
|
65
|
+
names: {
|
|
66
|
+
JAN: 1,
|
|
67
|
+
FEB: 2,
|
|
68
|
+
MAR: 3,
|
|
69
|
+
APR: 4,
|
|
70
|
+
MAY: 5,
|
|
71
|
+
JUN: 6,
|
|
72
|
+
JUL: 7,
|
|
73
|
+
AUG: 8,
|
|
74
|
+
SEP: 9,
|
|
75
|
+
OCT: 10,
|
|
76
|
+
NOV: 11,
|
|
77
|
+
DEC: 12
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "day-of-week",
|
|
82
|
+
min: 0,
|
|
83
|
+
max: 7,
|
|
84
|
+
names: {
|
|
85
|
+
SUN: 0,
|
|
86
|
+
MON: 1,
|
|
87
|
+
TUE: 2,
|
|
88
|
+
WED: 3,
|
|
89
|
+
THU: 4,
|
|
90
|
+
FRI: 5,
|
|
91
|
+
SAT: 6
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
/** Resolve a single value token (number or 3-letter name) for a field. */
|
|
96
|
+
function resolveFieldValue(token, field) {
|
|
97
|
+
if (/^\d+$/.test(token)) {
|
|
98
|
+
const value = Number.parseInt(token, 10);
|
|
99
|
+
if (value < field.min || value > field.max) return null;
|
|
100
|
+
return value;
|
|
101
|
+
}
|
|
102
|
+
if (field.names) {
|
|
103
|
+
const named = field.names[token.toUpperCase()];
|
|
104
|
+
if (named !== void 0) return named;
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
/** Validate a single non-`*` element (a number, range, or stepped form). */
|
|
109
|
+
function isValidFieldElement(element, field) {
|
|
110
|
+
let base = element;
|
|
111
|
+
let step = null;
|
|
112
|
+
const slashIndex = element.indexOf("/");
|
|
113
|
+
if (slashIndex !== -1) {
|
|
114
|
+
base = element.slice(0, slashIndex);
|
|
115
|
+
step = element.slice(slashIndex + 1);
|
|
116
|
+
if (!/^\d+$/.test(step) || Number.parseInt(step, 10) < 1) return false;
|
|
117
|
+
}
|
|
118
|
+
if (base === "*") return true;
|
|
119
|
+
const dashIndex = base.indexOf("-");
|
|
120
|
+
if (dashIndex !== -1) {
|
|
121
|
+
const startToken = base.slice(0, dashIndex);
|
|
122
|
+
const endToken = base.slice(dashIndex + 1);
|
|
123
|
+
const start = resolveFieldValue(startToken, field);
|
|
124
|
+
const end = resolveFieldValue(endToken, field);
|
|
125
|
+
if (start === null || end === null) return false;
|
|
126
|
+
return start <= end;
|
|
127
|
+
}
|
|
128
|
+
return resolveFieldValue(base, field) !== null;
|
|
129
|
+
}
|
|
130
|
+
/** Validate a single cron field (which may be a comma-separated list). */
|
|
131
|
+
function isValidCronField(value, field) {
|
|
132
|
+
if (value.length === 0) return false;
|
|
133
|
+
const elements = value.split(",");
|
|
134
|
+
for (const element of elements) if (element.length === 0 || !isValidFieldElement(element, field)) return false;
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Returns true when `expression` is a valid Cloudflare 5-field cron expression.
|
|
139
|
+
*
|
|
140
|
+
* Accepts `*`, numbers, ranges (`1-5`), lists (`1,3,5`), steps (`*\/5`,
|
|
141
|
+
* `1-30/5`, `5/15`) and the 3-letter month (`JAN`-`DEC`) / weekday
|
|
142
|
+
* (`SUN`-`SAT`) names, with the correct per-field numeric ranges. Cloudflare
|
|
143
|
+
* cron has no seconds and no year field, so anything other than 5 fields is
|
|
144
|
+
* rejected.
|
|
145
|
+
*/
|
|
146
|
+
function isValidCronExpression(expression) {
|
|
147
|
+
if (typeof expression !== "string") return false;
|
|
148
|
+
const fields = expression.trim().split(/\s+/);
|
|
149
|
+
if (fields.length !== CRON_FIELDS.length) return false;
|
|
150
|
+
for (let index = 0; index < CRON_FIELDS.length; index++) if (!isValidCronField(fields[index], CRON_FIELDS[index])) return false;
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Human-readable message for an invalid cron expression, naming the bad value.
|
|
155
|
+
*/
|
|
156
|
+
function formatInvalidCronMessage(expression) {
|
|
157
|
+
return `Invalid cron expression "${expression}". Cloudflare cron triggers use 5 fields: minute (0-59) hour (0-23) day-of-month (1-31) month (1-12 or JAN-DEC) day-of-week (0-7 or SUN-SAT). Each field accepts *, numbers, ranges (1-5), lists (1,3,5) and steps (*/5).`;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Throw a descriptive error when `expression` is not a valid cron expression.
|
|
161
|
+
*/
|
|
162
|
+
function assertValidCronExpression(expression) {
|
|
163
|
+
if (!isValidCronExpression(expression)) throw new Error(formatInvalidCronMessage(expression));
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Cloudflare Workers compatibility date schema.
|
|
167
|
+
* Must be in YYYY-MM-DD format (e.g., '2025-01-07').
|
|
168
|
+
*/
|
|
169
|
+
const compatibilityDateSchema = z.string().regex(/^\d{4}-\d{2}-\d{2}$/, { message: "Compatibility date must be in YYYY-MM-DD format" });
|
|
170
|
+
/**
|
|
171
|
+
* Built-in file router configuration used for `src/routes/**` discovery.
|
|
172
|
+
*/
|
|
173
|
+
const routesConfigSchema = z.object({
|
|
174
|
+
dir: z.string(),
|
|
175
|
+
prefix: z.string().optional()
|
|
176
|
+
});
|
|
177
|
+
/**
|
|
178
|
+
* File handler configuration.
|
|
179
|
+
* Maps handler types to their source file paths.
|
|
180
|
+
*/
|
|
181
|
+
const filesSchema = z.object({
|
|
182
|
+
fetch: z.union([z.string(), z.literal(false)]).optional(),
|
|
183
|
+
queue: z.union([z.string(), z.literal(false)]).optional(),
|
|
184
|
+
scheduled: z.union([z.string(), z.literal(false)]).optional(),
|
|
185
|
+
email: z.union([z.string(), z.literal(false)]).optional(),
|
|
186
|
+
tail: z.union([z.string(), z.literal(false)]).optional(),
|
|
187
|
+
durableObjects: z.union([z.string(), z.literal(false)]).optional(),
|
|
188
|
+
entrypoints: z.union([z.string(), z.literal(false)]).optional(),
|
|
189
|
+
workflows: z.union([z.string(), z.literal(false)]).optional(),
|
|
190
|
+
routes: z.union([routesConfigSchema, z.literal(false)]).optional(),
|
|
191
|
+
transport: z.union([z.string(), z.null()]).optional()
|
|
192
|
+
}).optional();
|
|
193
|
+
/**
|
|
194
|
+
* Tail Consumer configuration.
|
|
195
|
+
*/
|
|
196
|
+
const tailConsumerSchema = z.union([z.string().min(1), z.object({
|
|
197
|
+
service: z.string().min(1),
|
|
198
|
+
environment: z.string().min(1).optional()
|
|
199
|
+
}).strict()]);
|
|
200
|
+
/**
|
|
201
|
+
* Trigger configuration for scheduled (cron) events.
|
|
202
|
+
*
|
|
203
|
+
* Each cron expression is validated against the Cloudflare 5-field cron grammar
|
|
204
|
+
* at config-parse time, so a typo fails before deploy instead of silently never
|
|
205
|
+
* firing in production.
|
|
206
|
+
*/
|
|
207
|
+
const triggersSchema = z.object({ crons: z.array(z.string()).optional() }).superRefine((triggers, ctx) => {
|
|
208
|
+
if (!triggers.crons) return;
|
|
209
|
+
triggers.crons.forEach((cron, index) => {
|
|
210
|
+
if (!isValidCronExpression(cron)) ctx.addIssue({
|
|
211
|
+
code: z.ZodIssueCode.custom,
|
|
212
|
+
path: ["crons", index],
|
|
213
|
+
message: formatInvalidCronMessage(cron)
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
}).optional();
|
|
217
|
+
/**
|
|
218
|
+
* Preview-specific Devflare behavior.
|
|
219
|
+
*/
|
|
220
|
+
const previewsConfigSchema = z.object({ includeCrons: z.boolean().optional().default(false) }).optional();
|
|
221
|
+
/**
|
|
222
|
+
* Dev server configuration for `devflare dev`.
|
|
223
|
+
*
|
|
224
|
+
* Controls the host and port the local Miniflare runtime instance binds to.
|
|
225
|
+
* This is a development-only setting and is never emitted to compiled Wrangler
|
|
226
|
+
* output. CLI flags (`--runtime-port`, `--runtime-host`) and environment
|
|
227
|
+
* variables (`DEVFLARE_RUNTIME_PORT`, `DEVFLARE_RUNTIME_HOST`) take precedence
|
|
228
|
+
* over these values.
|
|
229
|
+
*/
|
|
230
|
+
const serverConfigSchema = z.object({
|
|
231
|
+
host: z.string().min(1).optional(),
|
|
232
|
+
port: z.number().int().min(1).max(65535).optional()
|
|
233
|
+
}).strict().optional();
|
|
234
|
+
/**
|
|
235
|
+
* Secret declaration options.
|
|
236
|
+
*/
|
|
237
|
+
const secretConfigSchema = z.object({ required: z.boolean().optional().default(true) });
|
|
238
|
+
/**
|
|
239
|
+
* Route configuration for worker deployment.
|
|
240
|
+
*/
|
|
241
|
+
const routeConfigSchema = z.object({
|
|
242
|
+
pattern: z.string(),
|
|
243
|
+
zone_name: z.string().optional(),
|
|
244
|
+
zone_id: z.string().optional(),
|
|
245
|
+
custom_domain: z.boolean().optional()
|
|
246
|
+
}).superRefine((route, ctx) => {
|
|
247
|
+
if (!route.custom_domain) return;
|
|
248
|
+
if (route.pattern.includes("*")) ctx.addIssue({
|
|
249
|
+
code: z.ZodIssueCode.custom,
|
|
250
|
+
path: ["pattern"],
|
|
251
|
+
message: "Wildcard operators (*) are not allowed in Custom Domains"
|
|
252
|
+
});
|
|
253
|
+
if (route.pattern.includes("/")) ctx.addIssue({
|
|
254
|
+
code: z.ZodIssueCode.custom,
|
|
255
|
+
path: ["pattern"],
|
|
256
|
+
message: "Paths are not allowed in Custom Domains"
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
/**
|
|
260
|
+
* WebSocket route configuration for dev mode Durable Object proxying.
|
|
261
|
+
*/
|
|
262
|
+
const wsRouteConfigSchema = z.object({
|
|
263
|
+
pattern: z.string(),
|
|
264
|
+
doNamespace: z.string(),
|
|
265
|
+
idParam: z.string().default("id"),
|
|
266
|
+
forwardPath: z.string().default("/websocket")
|
|
267
|
+
});
|
|
268
|
+
/**
|
|
269
|
+
* Static assets configuration.
|
|
270
|
+
*/
|
|
271
|
+
const assetsConfigSchema = z.object({
|
|
272
|
+
directory: z.string(),
|
|
273
|
+
binding: z.string().optional(),
|
|
274
|
+
html_handling: z.enum([
|
|
275
|
+
"auto-trailing-slash",
|
|
276
|
+
"force-trailing-slash",
|
|
277
|
+
"drop-trailing-slash",
|
|
278
|
+
"none"
|
|
279
|
+
]).optional(),
|
|
280
|
+
not_found_handling: z.enum([
|
|
281
|
+
"single-page-application",
|
|
282
|
+
"404-page",
|
|
283
|
+
"none"
|
|
284
|
+
]).optional(),
|
|
285
|
+
run_worker_first: z.union([z.boolean(), z.array(z.string())]).optional()
|
|
286
|
+
}).strict().optional();
|
|
287
|
+
const smartPlacementSchema = z.object({
|
|
288
|
+
mode: z.enum(["off", "smart"]),
|
|
289
|
+
hint: z.string().optional()
|
|
290
|
+
}).strict().superRefine((placement, ctx) => {
|
|
291
|
+
if (placement.hint !== void 0 && placement.mode !== "smart") ctx.addIssue({
|
|
292
|
+
code: z.ZodIssueCode.custom,
|
|
293
|
+
path: ["hint"],
|
|
294
|
+
message: "placement.hint can only be set when placement.mode is smart"
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
const targetedRegionPlacementSchema = z.object({
|
|
298
|
+
mode: z.literal("targeted").optional(),
|
|
299
|
+
region: z.string().min(1)
|
|
300
|
+
}).strict();
|
|
301
|
+
const targetedHostPlacementSchema = z.object({
|
|
302
|
+
mode: z.literal("targeted").optional(),
|
|
303
|
+
host: z.string().min(1)
|
|
304
|
+
}).strict();
|
|
305
|
+
const targetedHostnamePlacementSchema = z.object({
|
|
306
|
+
mode: z.literal("targeted").optional(),
|
|
307
|
+
hostname: z.string().min(1)
|
|
308
|
+
}).strict();
|
|
309
|
+
/**
|
|
310
|
+
* Worker placement configuration.
|
|
311
|
+
*/
|
|
312
|
+
const placementSchema = z.union([
|
|
313
|
+
smartPlacementSchema,
|
|
314
|
+
targetedRegionPlacementSchema,
|
|
315
|
+
targetedHostPlacementSchema,
|
|
316
|
+
targetedHostnamePlacementSchema
|
|
317
|
+
]).optional();
|
|
318
|
+
const samplingRateSchema = z.number().min(0).max(1);
|
|
319
|
+
const observabilityLogsSchema = z.object({
|
|
320
|
+
enabled: z.boolean().optional(),
|
|
321
|
+
head_sampling_rate: samplingRateSchema.optional(),
|
|
322
|
+
invocation_logs: z.boolean().optional(),
|
|
323
|
+
persist: z.boolean().optional(),
|
|
324
|
+
destinations: z.array(z.string()).optional()
|
|
325
|
+
}).strict();
|
|
326
|
+
const observabilityTracesSchema = z.object({
|
|
327
|
+
enabled: z.boolean().optional(),
|
|
328
|
+
head_sampling_rate: samplingRateSchema.optional(),
|
|
329
|
+
persist: z.boolean().optional(),
|
|
330
|
+
destinations: z.array(z.string()).optional()
|
|
331
|
+
}).strict();
|
|
332
|
+
/**
|
|
333
|
+
* Observability configuration for logs and traces.
|
|
334
|
+
*/
|
|
335
|
+
const observabilitySchema = z.object({
|
|
336
|
+
enabled: z.boolean().optional(),
|
|
337
|
+
head_sampling_rate: samplingRateSchema.optional(),
|
|
338
|
+
logs: observabilityLogsSchema.optional(),
|
|
339
|
+
traces: observabilityTracesSchema.optional()
|
|
340
|
+
}).strict().optional();
|
|
341
|
+
/**
|
|
342
|
+
* Resource limits configuration.
|
|
343
|
+
*/
|
|
344
|
+
const limitsSchema = z.object({
|
|
345
|
+
cpu_ms: z.number().optional(),
|
|
346
|
+
subrequests: z.number().optional()
|
|
347
|
+
}).strict().optional();
|
|
348
|
+
const rolloutStepPercentageSchema = z.union([z.number().int().positive(), z.array(z.number().int().positive()).min(1)]);
|
|
349
|
+
/**
|
|
350
|
+
* Cloudflare Containers configuration.
|
|
351
|
+
*
|
|
352
|
+
* Devflare authors this in camelCase and compiles to Wrangler's top-level
|
|
353
|
+
* `containers` array. Runtime launch/testing is handled by the local
|
|
354
|
+
* container test shim, not by Miniflare itself.
|
|
355
|
+
*/
|
|
356
|
+
const containerConfigSchema = z.object({
|
|
357
|
+
className: z.string().min(1),
|
|
358
|
+
image: z.string().min(1),
|
|
359
|
+
maxInstances: z.number().int().positive().optional(),
|
|
360
|
+
instanceType: z.string().min(1).optional(),
|
|
361
|
+
name: z.string().min(1).optional(),
|
|
362
|
+
imageBuildContext: z.string().min(1).optional(),
|
|
363
|
+
imageVars: z.record(z.string(), z.string()).optional(),
|
|
364
|
+
rolloutActiveGracePeriod: z.number().int().nonnegative().optional(),
|
|
365
|
+
rolloutStepPercentage: rolloutStepPercentageSchema.optional()
|
|
366
|
+
}).strict();
|
|
367
|
+
const containersConfigSchema = z.array(containerConfigSchema).optional();
|
|
368
|
+
/**
|
|
369
|
+
* Module rules for non-JavaScript Worker modules and imported assets.
|
|
370
|
+
*
|
|
371
|
+
* Wrangler also exposes Python-specific rule types while Python Workers are in
|
|
372
|
+
* beta. Devflare keeps those behind `wrangler.passthrough` until the local
|
|
373
|
+
* Python Worker toolchain has a stable Devflare integration point.
|
|
374
|
+
*/
|
|
375
|
+
const moduleRuleSchema = z.object({
|
|
376
|
+
type: z.enum([
|
|
377
|
+
"ESModule",
|
|
378
|
+
"CommonJS",
|
|
379
|
+
"CompiledWasm",
|
|
380
|
+
"Text",
|
|
381
|
+
"Data"
|
|
382
|
+
]),
|
|
383
|
+
globs: z.array(z.string()).min(1),
|
|
384
|
+
fallthrough: z.boolean().optional()
|
|
385
|
+
}).strict();
|
|
386
|
+
const moduleRulesSchema = z.array(moduleRuleSchema).optional();
|
|
387
|
+
/**
|
|
388
|
+
* Durable Object migration configuration.
|
|
389
|
+
*/
|
|
390
|
+
const renamedClassMigrationSchema = z.object({
|
|
391
|
+
from: z.string(),
|
|
392
|
+
to: z.string()
|
|
393
|
+
}).strict();
|
|
394
|
+
const migrationSchema = z.object({
|
|
395
|
+
tag: z.string(),
|
|
396
|
+
new_classes: z.array(z.string()).optional(),
|
|
397
|
+
renamed_classes: z.array(renamedClassMigrationSchema).optional(),
|
|
398
|
+
deleted_classes: z.array(z.string()).optional(),
|
|
399
|
+
new_sqlite_classes: z.array(z.string()).optional()
|
|
400
|
+
}).strict();
|
|
401
|
+
/**
|
|
402
|
+
* Wrangler configuration passthrough.
|
|
403
|
+
*/
|
|
404
|
+
const wranglerConfigSchema = z.object({ passthrough: z.record(z.string(), z.unknown()).optional() }).optional();
|
|
405
|
+
//#endregion
|
|
406
|
+
//#region src/config/schema.ts
|
|
407
|
+
/** Helper to get current date in YYYY-MM-DD format */
|
|
408
|
+
function getCurrentDate() {
|
|
409
|
+
return (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
410
|
+
}
|
|
411
|
+
function getSecretsStoreShorthandBindings(config) {
|
|
412
|
+
return Object.entries(config.bindings?.secretsStore ?? {}).filter(([, binding]) => typeof binding === "string").map(([bindingName]) => bindingName);
|
|
413
|
+
}
|
|
414
|
+
function addSecretsStoreShorthandIssues(ctx, config, pathPrefix = []) {
|
|
415
|
+
if (config.secretsStoreId) return;
|
|
416
|
+
for (const bindingName of getSecretsStoreShorthandBindings(config)) ctx.addIssue({
|
|
417
|
+
code: z.ZodIssueCode.custom,
|
|
418
|
+
path: [
|
|
419
|
+
...pathPrefix,
|
|
420
|
+
"bindings",
|
|
421
|
+
"secretsStore",
|
|
422
|
+
bindingName
|
|
423
|
+
],
|
|
424
|
+
message: `Secrets Store binding "${bindingName}" uses shorthand and requires top-level secretsStoreId.`
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
const varValueSchema = z.lazy(() => z.union([
|
|
428
|
+
z.string(),
|
|
429
|
+
z.number(),
|
|
430
|
+
z.boolean(),
|
|
431
|
+
z.null(),
|
|
432
|
+
z.custom(isEnvVarDescriptor),
|
|
433
|
+
z.array(varValueSchema),
|
|
434
|
+
z.record(z.string(), varValueSchema)
|
|
435
|
+
]));
|
|
436
|
+
/**
|
|
437
|
+
* Raw Zod shape of the root devflare configuration (excluding the `env` field,
|
|
438
|
+
* which references back into this shape via the environment override schema).
|
|
439
|
+
*
|
|
440
|
+
* Exported so `schema-env.ts` can derive the environment override schema from
|
|
441
|
+
* the single source of truth without hand-listing every field.
|
|
442
|
+
*/
|
|
443
|
+
const rootConfigShape = {
|
|
444
|
+
name: z.string({ required_error: "Worker name is required" }),
|
|
445
|
+
accountId: z.string().optional(),
|
|
446
|
+
secretsStoreId: z.string().min(1).optional(),
|
|
447
|
+
compatibilityDate: compatibilityDateSchema.optional().default(getCurrentDate),
|
|
448
|
+
compatibilityFlags: z.array(z.string()).optional().transform((flags = []) => normalizeCompatibilityFlags(flags)),
|
|
449
|
+
previews: previewsConfigSchema,
|
|
450
|
+
server: serverConfigSchema,
|
|
451
|
+
files: filesSchema,
|
|
452
|
+
bindings: bindingsSchema,
|
|
453
|
+
triggers: triggersSchema,
|
|
454
|
+
rules: moduleRulesSchema,
|
|
455
|
+
findAdditionalModules: z.boolean().optional(),
|
|
456
|
+
baseDir: z.string().optional(),
|
|
457
|
+
preserveFileNames: z.boolean().optional(),
|
|
458
|
+
logpush: z.boolean().optional(),
|
|
459
|
+
uploadSourceMaps: z.boolean().optional(),
|
|
460
|
+
keepVars: z.boolean().optional(),
|
|
461
|
+
tailConsumers: z.array(tailConsumerSchema).optional(),
|
|
462
|
+
vars: z.record(z.string(), varValueSchema).optional(),
|
|
463
|
+
secrets: z.record(z.string(), secretConfigSchema).optional(),
|
|
464
|
+
routes: z.array(routeConfigSchema).optional(),
|
|
465
|
+
wsRoutes: z.array(wsRouteConfigSchema).optional(),
|
|
466
|
+
assets: assetsConfigSchema,
|
|
467
|
+
containers: containersConfigSchema,
|
|
468
|
+
placement: placementSchema,
|
|
469
|
+
limits: limitsSchema,
|
|
470
|
+
observability: observabilitySchema,
|
|
471
|
+
migrations: z.array(migrationSchema).optional(),
|
|
472
|
+
rolldown: rolldownConfigSchema,
|
|
473
|
+
vite: viteConfigSchema,
|
|
474
|
+
wrangler: wranglerConfigSchema
|
|
475
|
+
};
|
|
476
|
+
const configSchema = z.object({
|
|
477
|
+
...rootConfigShape,
|
|
478
|
+
env: z.record(z.string(), envConfigSchemaInner).optional()
|
|
479
|
+
}).strict().superRefine((config, ctx) => {
|
|
480
|
+
addSecretsStoreShorthandIssues(ctx, config);
|
|
481
|
+
for (const [envName, envConfig] of Object.entries(config.env ?? {})) addSecretsStoreShorthandIssues(ctx, {
|
|
482
|
+
...envConfig,
|
|
483
|
+
secretsStoreId: envConfig.secretsStoreId ?? config.secretsStoreId
|
|
484
|
+
}, ["env", envName]);
|
|
485
|
+
});
|
|
486
|
+
//#endregion
|
|
487
|
+
//#region src/config/resolve.ts
|
|
488
|
+
function isPlainObject(value) {
|
|
489
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
490
|
+
const prototype = Object.getPrototypeOf(value);
|
|
491
|
+
return prototype === Object.prototype || prototype === null;
|
|
492
|
+
}
|
|
493
|
+
function mergeEnvironmentValue(base, override) {
|
|
494
|
+
if (override === void 0) return base;
|
|
495
|
+
if (Array.isArray(override)) return [...override];
|
|
496
|
+
if (isPlainObject(override)) {
|
|
497
|
+
const baseObject = isPlainObject(base) ? base : {};
|
|
498
|
+
const mergedObject = { ...baseObject };
|
|
499
|
+
for (const [key, value] of Object.entries(override)) mergedObject[key] = mergeEnvironmentValue(baseObject[key], value);
|
|
500
|
+
return mergedObject;
|
|
501
|
+
}
|
|
502
|
+
return override;
|
|
503
|
+
}
|
|
504
|
+
function withNormalizedCompatibilityFlags(config) {
|
|
505
|
+
return {
|
|
506
|
+
...config,
|
|
507
|
+
compatibilityFlags: normalizeCompatibilityFlags(config.compatibilityFlags)
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
function mergeConfigForEnvironment(config, environment) {
|
|
511
|
+
if (!environment || !config.env?.[environment]) return withNormalizedCompatibilityFlags(config);
|
|
512
|
+
return withNormalizedCompatibilityFlags(mergeEnvironmentValue(config, config.env[environment]));
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* @internal Prefer the unified `resolveResources(config, { phase: 'build' })`
|
|
516
|
+
* facade for the env-merge + preview-materialize pipeline. This lower-level
|
|
517
|
+
* helper remains exported as the implementation that the seam and the
|
|
518
|
+
* build-time compiler delegate to; it is not part of the recommended public
|
|
519
|
+
* surface.
|
|
520
|
+
*/
|
|
521
|
+
function resolveConfigForEnvironment(config, environment) {
|
|
522
|
+
return materializePreviewScopedConfig(mergeConfigForEnvironment(config, environment), { environment });
|
|
523
|
+
}
|
|
524
|
+
//#endregion
|
|
525
|
+
//#region src/config/framework-providers.ts
|
|
526
|
+
const SVELTE_CONFIG_FILES = [
|
|
527
|
+
"svelte.config.js",
|
|
528
|
+
"svelte.config.mjs",
|
|
529
|
+
"svelte.config.ts",
|
|
530
|
+
"svelte.config.cjs"
|
|
531
|
+
];
|
|
532
|
+
async function readTextIfExists(path) {
|
|
533
|
+
try {
|
|
534
|
+
return await readFile(path, "utf-8");
|
|
535
|
+
} catch {
|
|
536
|
+
return null;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
async function readPackageDependencies(cwd) {
|
|
540
|
+
const packageJsonText = await readTextIfExists(join(cwd, "package.json"));
|
|
541
|
+
if (!packageJsonText) return null;
|
|
542
|
+
try {
|
|
543
|
+
const packageJson = JSON.parse(packageJsonText);
|
|
544
|
+
return {
|
|
545
|
+
...packageJson.dependencies ?? {},
|
|
546
|
+
...packageJson.devDependencies ?? {},
|
|
547
|
+
...packageJson.peerDependencies ?? {}
|
|
548
|
+
};
|
|
549
|
+
} catch {
|
|
550
|
+
return null;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
async function findFirstExistingTextFile(cwd, candidates) {
|
|
554
|
+
for (const candidate of candidates) {
|
|
555
|
+
const fileText = await readTextIfExists(join(cwd, candidate));
|
|
556
|
+
if (fileText !== null) return fileText;
|
|
557
|
+
}
|
|
558
|
+
return null;
|
|
559
|
+
}
|
|
560
|
+
const frameworkProviders = [{
|
|
561
|
+
id: "sveltekit-cloudflare",
|
|
562
|
+
async resolve(context) {
|
|
563
|
+
const dependencies = await readPackageDependencies(context.cwd);
|
|
564
|
+
if (!dependencies?.["@sveltejs/kit"] || !dependencies["@sveltejs/adapter-cloudflare"]) return null;
|
|
565
|
+
const svelteConfigText = await findFirstExistingTextFile(context.cwd, SVELTE_CONFIG_FILES);
|
|
566
|
+
if (!svelteConfigText) return null;
|
|
567
|
+
if (!/@sveltejs\/adapter-cloudflare|adapter-cloudflare/.test(svelteConfigText)) return null;
|
|
568
|
+
return {
|
|
569
|
+
id: this.id,
|
|
570
|
+
config: {
|
|
571
|
+
files: { fetch: ".adapter-cloudflare/_worker.js" },
|
|
572
|
+
assets: {
|
|
573
|
+
binding: "ASSETS",
|
|
574
|
+
directory: ".adapter-cloudflare"
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
}];
|
|
580
|
+
function hasFrameworkInferenceGap(config) {
|
|
581
|
+
return config.files?.fetch === void 0 || config.assets?.directory === void 0 || config.assets?.binding === void 0;
|
|
582
|
+
}
|
|
583
|
+
function mergeInferredConfig(config, inferredConfig) {
|
|
584
|
+
const mergedFiles = inferredConfig.files ? {
|
|
585
|
+
...inferredConfig.files,
|
|
586
|
+
...config.files ?? {}
|
|
587
|
+
} : config.files;
|
|
588
|
+
const mergedAssets = inferredConfig.assets ? {
|
|
589
|
+
...inferredConfig.assets,
|
|
590
|
+
...config.assets ?? {}
|
|
591
|
+
} : config.assets;
|
|
592
|
+
return {
|
|
593
|
+
...config,
|
|
594
|
+
...mergedFiles && { files: mergedFiles },
|
|
595
|
+
...mergedAssets && { assets: mergedAssets }
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
async function applyFrameworkConfigProviders(config, context) {
|
|
599
|
+
if (!hasFrameworkInferenceGap(config)) return config;
|
|
600
|
+
for (const provider of frameworkProviders) {
|
|
601
|
+
const resolution = await provider.resolve({
|
|
602
|
+
...context,
|
|
603
|
+
config
|
|
604
|
+
});
|
|
605
|
+
if (!resolution) continue;
|
|
606
|
+
return mergeInferredConfig(config, resolution.config);
|
|
607
|
+
}
|
|
608
|
+
return config;
|
|
609
|
+
}
|
|
610
|
+
//#endregion
|
|
611
|
+
//#region src/config/binding-resolution-helpers.ts
|
|
612
|
+
function normalizeKVNameBinding(bindingConfig) {
|
|
613
|
+
const normalized = normalizeKVBinding(bindingConfig);
|
|
614
|
+
return {
|
|
615
|
+
id: normalized.namespaceId,
|
|
616
|
+
name: normalized.name
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
function normalizeD1NameBinding(bindingConfig) {
|
|
620
|
+
const normalized = normalizeD1Binding(bindingConfig);
|
|
621
|
+
return {
|
|
622
|
+
id: normalized.databaseId,
|
|
623
|
+
name: normalized.name
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
function normalizeHyperdriveNameBinding(bindingConfig) {
|
|
627
|
+
const normalized = normalizeHyperdriveBinding(bindingConfig);
|
|
628
|
+
return {
|
|
629
|
+
id: normalized.configurationId,
|
|
630
|
+
name: normalized.name
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
function materializeIdBindings(bindings, resolveId) {
|
|
634
|
+
return Object.fromEntries(Object.entries(bindings).map(([bindingName, bindingConfig]) => {
|
|
635
|
+
return [bindingName, { id: resolveId(bindingConfig) }];
|
|
636
|
+
}));
|
|
637
|
+
}
|
|
638
|
+
function materializeHyperdriveIdBindings(bindings, idsByName) {
|
|
639
|
+
if (!bindings) return;
|
|
640
|
+
return Object.fromEntries(Object.entries(bindings).map(([bindingName, bindingConfig]) => {
|
|
641
|
+
const normalized = normalizeHyperdriveBinding(bindingConfig);
|
|
642
|
+
return [bindingName, {
|
|
643
|
+
id: normalized.configurationId ?? idsByName?.get(normalized.name ?? "") ?? normalized.name ?? "",
|
|
644
|
+
...normalized.localConnectionString && { localConnectionString: normalized.localConnectionString }
|
|
645
|
+
}];
|
|
646
|
+
}));
|
|
647
|
+
}
|
|
648
|
+
function collectPendingNameBindings(bindings, normalizeBinding) {
|
|
649
|
+
if (!bindings) return [];
|
|
650
|
+
return Object.entries(bindings).map(([bindingName, bindingConfig]) => {
|
|
651
|
+
const normalized = normalizeBinding(bindingConfig);
|
|
652
|
+
return normalized.id ? null : {
|
|
653
|
+
bindingName,
|
|
654
|
+
resourceName: normalized.name ?? ""
|
|
655
|
+
};
|
|
656
|
+
}).filter((binding) => binding !== null);
|
|
657
|
+
}
|
|
658
|
+
function materializeResolvedNameBindings(bindings, normalizeBinding, idsByName) {
|
|
659
|
+
if (!bindings) return;
|
|
660
|
+
return materializeIdBindings(bindings, (bindingConfig) => {
|
|
661
|
+
const normalized = normalizeBinding(bindingConfig);
|
|
662
|
+
return normalized.id ?? idsByName.get(normalized.name ?? "") ?? "";
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
function withResolvedIdBindings(resolvedConfig, bindings) {
|
|
666
|
+
return {
|
|
667
|
+
...resolvedConfig,
|
|
668
|
+
bindings: {
|
|
669
|
+
...resolvedConfig.bindings,
|
|
670
|
+
...bindings.kv ? { kv: bindings.kv } : {},
|
|
671
|
+
...bindings.d1 ? { d1: bindings.d1 } : {},
|
|
672
|
+
...bindings.hyperdrive ? { hyperdrive: bindings.hyperdrive } : {}
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
function formatMissingBindings(missing) {
|
|
677
|
+
return missing.map(({ bindingName, resourceName }) => `${bindingName} → ${resourceName}`).join(", ");
|
|
678
|
+
}
|
|
679
|
+
//#endregion
|
|
680
|
+
//#region src/config/deploy-resources.ts
|
|
681
|
+
const defaultDeployResourcePreparationApi = {
|
|
682
|
+
getPrimaryAccount,
|
|
683
|
+
getEffectiveAccountId,
|
|
684
|
+
listKVNamespaces,
|
|
685
|
+
createKVNamespace,
|
|
686
|
+
listD1Databases,
|
|
687
|
+
createD1Database,
|
|
688
|
+
listR2Buckets,
|
|
689
|
+
createR2Bucket,
|
|
690
|
+
listQueues,
|
|
691
|
+
createQueue,
|
|
692
|
+
listHyperdrives,
|
|
693
|
+
listVectorizeIndexes
|
|
694
|
+
};
|
|
695
|
+
function createEmptyDeployResourceNames() {
|
|
696
|
+
return {
|
|
697
|
+
kv: [],
|
|
698
|
+
d1: [],
|
|
699
|
+
r2: [],
|
|
700
|
+
queues: [],
|
|
701
|
+
vectorize: [],
|
|
702
|
+
hyperdrive: []
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* C13 — surface partial-progress orphans on a failed deploy preparation.
|
|
707
|
+
*
|
|
708
|
+
* If any resource was already created before the throw, attach a clear
|
|
709
|
+
* footer to the error message listing what was created so the user can
|
|
710
|
+
* decide whether to keep, delete, or rerun. Auto-deletion is intentionally
|
|
711
|
+
* not performed: deletion is irreversible, has cross-binding side effects
|
|
712
|
+
* (DBs may have data, queues may be inflight), and the deploy may simply
|
|
713
|
+
* be retried after fixing the underlying error.
|
|
714
|
+
*/
|
|
715
|
+
function decorateOrphanError(err, created) {
|
|
716
|
+
const summaryParts = [];
|
|
717
|
+
if (created.kv.length > 0) summaryParts.push(`KV: ${created.kv.join(", ")}`);
|
|
718
|
+
if (created.d1.length > 0) summaryParts.push(`D1: ${created.d1.join(", ")}`);
|
|
719
|
+
if (created.hyperdrive.length > 0) summaryParts.push(`Hyperdrive: ${created.hyperdrive.join(", ")}`);
|
|
720
|
+
if (created.r2.length > 0) summaryParts.push(`R2: ${created.r2.join(", ")}`);
|
|
721
|
+
if (created.queues.length > 0) summaryParts.push(`Queues: ${created.queues.join(", ")}`);
|
|
722
|
+
if (created.vectorize.length > 0) summaryParts.push(`Vectorize: ${created.vectorize.join(", ")}`);
|
|
723
|
+
const base = err instanceof Error ? err : new Error(String(err));
|
|
724
|
+
if (summaryParts.length === 0) return base;
|
|
725
|
+
const orphanFooter = `\n\nDeploy preparation failed AFTER provisioning the following Cloudflare resources, which were left in your account:\n - ${summaryParts.join("\n - ")}\nRe-run \`devflare deploy\` after fixing the error to reuse them, or delete them manually if abandoning the deploy.`;
|
|
726
|
+
const decorated = /* @__PURE__ */ new Error(`${base.message}${orphanFooter}`);
|
|
727
|
+
if ("cause" in base && base.cause !== void 0) decorated.cause = base.cause;
|
|
728
|
+
else decorated.cause = base;
|
|
729
|
+
return decorated;
|
|
730
|
+
}
|
|
731
|
+
function resolveDeployResourcePreparationApi(overrides) {
|
|
732
|
+
return {
|
|
733
|
+
...defaultDeployResourcePreparationApi,
|
|
734
|
+
...overrides ?? {}
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
function resolveUniqueNames(values) {
|
|
738
|
+
const names = /* @__PURE__ */ new Set();
|
|
739
|
+
for (const value of values) {
|
|
740
|
+
const trimmed = value?.trim();
|
|
741
|
+
if (!trimmed) continue;
|
|
742
|
+
names.add(trimmed);
|
|
743
|
+
}
|
|
744
|
+
return [...names];
|
|
745
|
+
}
|
|
746
|
+
function collectQueueNames(config) {
|
|
747
|
+
const queues = config.bindings?.queues;
|
|
748
|
+
if (!queues) return [];
|
|
749
|
+
return resolveUniqueNames([...Object.values(queues.producers ?? {}).map((producer) => normalizeQueueProducer(producer).queue), ...(queues.consumers ?? []).flatMap((consumer) => [consumer.queue, consumer.deadLetterQueue])]);
|
|
750
|
+
}
|
|
751
|
+
function collectVectorizeIndexNames(config) {
|
|
752
|
+
return resolveUniqueNames(Object.values(config.bindings?.vectorize ?? {}).map((binding) => binding.indexName));
|
|
753
|
+
}
|
|
754
|
+
function resolveUniquePendingBindings(pendingBindings) {
|
|
755
|
+
return [...new Map(pendingBindings.map((binding) => [binding.resourceName, binding])).values()];
|
|
756
|
+
}
|
|
757
|
+
async function resolveLookupAccountId$1(config, options, cloudflareApi) {
|
|
758
|
+
const envAccountId = typeof process !== "undefined" ? process.env?.CLOUDFLARE_ACCOUNT_ID?.trim() : void 0;
|
|
759
|
+
const explicitAccountId = options.accountId ?? config.accountId ?? (envAccountId || void 0);
|
|
760
|
+
if (explicitAccountId) return explicitAccountId;
|
|
761
|
+
let primaryAccount;
|
|
762
|
+
try {
|
|
763
|
+
primaryAccount = await cloudflareApi.getPrimaryAccount();
|
|
764
|
+
} catch (error) {
|
|
765
|
+
throw new ConfigResourceResolutionError("Could not prepare Cloudflare-backed deploy resources because Devflare could not read your Cloudflare accounts. Set accountId in devflare.config.ts, configure a workspace/global default account, or log in with Wrangler.", error);
|
|
766
|
+
}
|
|
767
|
+
if (!primaryAccount) throw new ConfigResourceResolutionError("Could not prepare Cloudflare-backed deploy resources because no Cloudflare account is available. Set accountId in devflare.config.ts, configure a workspace/global default account, or log in with Wrangler.");
|
|
768
|
+
try {
|
|
769
|
+
const { accountId } = await cloudflareApi.getEffectiveAccountId(primaryAccount.id);
|
|
770
|
+
return accountId;
|
|
771
|
+
} catch (error) {
|
|
772
|
+
throw new ConfigResourceResolutionError(`Could not determine the effective Cloudflare account for deploy-time resource preparation after selecting primary account ${primaryAccount.id}.`, error);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
async function resolveOrCreateResourceIdsByName(pendingBindings, options) {
|
|
776
|
+
if (pendingBindings.length === 0) return {
|
|
777
|
+
idsByName: /* @__PURE__ */ new Map(),
|
|
778
|
+
created: [],
|
|
779
|
+
existing: []
|
|
780
|
+
};
|
|
781
|
+
let resources;
|
|
782
|
+
try {
|
|
783
|
+
resources = await options.listResources();
|
|
784
|
+
} catch (error) {
|
|
785
|
+
throw new ConfigResourceResolutionError(options.listFailureMessage, error);
|
|
786
|
+
}
|
|
787
|
+
const idsByName = new Map(resources.map((resource) => [resource.name, resource.id]));
|
|
788
|
+
const created = [];
|
|
789
|
+
const existing = resolveUniquePendingBindings(pendingBindings).filter(({ resourceName }) => idsByName.has(resourceName)).map(({ resourceName }) => resourceName);
|
|
790
|
+
const missingBindings = resolveUniquePendingBindings(pendingBindings).filter(({ resourceName }) => !idsByName.has(resourceName));
|
|
791
|
+
if (missingBindings.length === 0) return {
|
|
792
|
+
idsByName,
|
|
793
|
+
created,
|
|
794
|
+
existing
|
|
795
|
+
};
|
|
796
|
+
if (!options.createResource) throw new ConfigResourceResolutionError(options.missingFailureMessage(missingBindings));
|
|
797
|
+
for (const missingBinding of missingBindings) try {
|
|
798
|
+
const createdResource = await options.createResource(missingBinding.resourceName);
|
|
799
|
+
idsByName.set(createdResource.name, createdResource.id);
|
|
800
|
+
created.push(createdResource.name);
|
|
801
|
+
} catch (error) {
|
|
802
|
+
throw new ConfigResourceResolutionError(options.createFailureMessage?.(missingBinding.resourceName) ?? `Could not create Cloudflare resource "${missingBinding.resourceName}" during deploy preparation.`, error);
|
|
803
|
+
}
|
|
804
|
+
return {
|
|
805
|
+
idsByName,
|
|
806
|
+
created,
|
|
807
|
+
existing
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
async function ensureNamedResourcesExist(resourceNames, options) {
|
|
811
|
+
if (resourceNames.length === 0) return {
|
|
812
|
+
created: [],
|
|
813
|
+
existing: []
|
|
814
|
+
};
|
|
815
|
+
let resources;
|
|
816
|
+
try {
|
|
817
|
+
resources = await options.listResources();
|
|
818
|
+
} catch (error) {
|
|
819
|
+
throw new ConfigResourceResolutionError(options.listFailureMessage, error);
|
|
820
|
+
}
|
|
821
|
+
const existingNames = new Set(resources.map((resource) => resource.name));
|
|
822
|
+
const existing = resourceNames.filter((resourceName) => existingNames.has(resourceName));
|
|
823
|
+
const missingNames = resourceNames.filter((resourceName) => !existingNames.has(resourceName));
|
|
824
|
+
const created = [];
|
|
825
|
+
if (missingNames.length === 0) return {
|
|
826
|
+
created,
|
|
827
|
+
existing
|
|
828
|
+
};
|
|
829
|
+
if (!options.createResource) throw new ConfigResourceResolutionError(options.missingFailureMessage(missingNames));
|
|
830
|
+
for (const resourceName of missingNames) try {
|
|
831
|
+
const createdResource = await options.createResource(resourceName);
|
|
832
|
+
created.push(createdResource.name);
|
|
833
|
+
} catch (error) {
|
|
834
|
+
throw new ConfigResourceResolutionError(options.createFailureMessage?.(resourceName) ?? `Could not create Cloudflare resource "${resourceName}" during deploy preparation.`, error);
|
|
835
|
+
}
|
|
836
|
+
return {
|
|
837
|
+
created,
|
|
838
|
+
existing
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
async function prepareMaterializedConfigResourcesForDeploy(resolvedConfig, options = {}) {
|
|
842
|
+
const created = createEmptyDeployResourceNames();
|
|
843
|
+
const existing = createEmptyDeployResourceNames();
|
|
844
|
+
const warnings = [];
|
|
845
|
+
const kvBindings = resolvedConfig.bindings?.kv;
|
|
846
|
+
const d1Bindings = resolvedConfig.bindings?.d1;
|
|
847
|
+
const hyperdriveBindings = resolvedConfig.bindings?.hyperdrive;
|
|
848
|
+
const r2Names = resolveUniqueNames(Object.values(resolvedConfig.bindings?.r2 ?? {}).map((bucket) => normalizeR2Binding(bucket).bucketName));
|
|
849
|
+
const queueNames = collectQueueNames(resolvedConfig);
|
|
850
|
+
const vectorizeNames = collectVectorizeIndexNames(resolvedConfig);
|
|
851
|
+
if (!kvBindings && !d1Bindings && !hyperdriveBindings && r2Names.length === 0 && queueNames.length === 0 && vectorizeNames.length === 0) return {
|
|
852
|
+
config: brandAsDeployConfig(resolvedConfig),
|
|
853
|
+
created,
|
|
854
|
+
existing,
|
|
855
|
+
warnings
|
|
856
|
+
};
|
|
857
|
+
const pendingKVNameBindings = collectPendingNameBindings(kvBindings, normalizeKVNameBinding);
|
|
858
|
+
const pendingD1NameBindings = collectPendingNameBindings(d1Bindings, normalizeD1NameBinding);
|
|
859
|
+
const pendingHyperdriveNameBindings = collectPendingNameBindings(hyperdriveBindings, normalizeHyperdriveNameBinding);
|
|
860
|
+
if (pendingKVNameBindings.length === 0 && pendingD1NameBindings.length === 0 && pendingHyperdriveNameBindings.length === 0 && r2Names.length === 0 && queueNames.length === 0 && vectorizeNames.length === 0) return {
|
|
861
|
+
config: brandAsDeployConfig(withResolvedIdBindings(resolvedConfig, {
|
|
862
|
+
kv: kvBindings ? materializeIdBindings(kvBindings, getLocalKVNamespaceIdentifier) : void 0,
|
|
863
|
+
d1: d1Bindings ? materializeIdBindings(d1Bindings, getLocalD1DatabaseIdentifier) : void 0,
|
|
864
|
+
hyperdrive: materializeHyperdriveIdBindings(hyperdriveBindings)
|
|
865
|
+
})),
|
|
866
|
+
created,
|
|
867
|
+
existing,
|
|
868
|
+
warnings
|
|
869
|
+
};
|
|
870
|
+
const cloudflareApi = resolveDeployResourcePreparationApi(options.cloudflare);
|
|
871
|
+
const accountId = await resolveLookupAccountId$1(resolvedConfig, options, cloudflareApi);
|
|
872
|
+
if (options.describeOnly) {
|
|
873
|
+
cloudflareApi.createKVNamespace = (async (_acc, name) => ({
|
|
874
|
+
id: `<would-create:${name}>`,
|
|
875
|
+
name
|
|
876
|
+
}));
|
|
877
|
+
cloudflareApi.createD1Database = (async (_acc, name) => ({
|
|
878
|
+
id: `<would-create:${name}>`,
|
|
879
|
+
name,
|
|
880
|
+
version: "",
|
|
881
|
+
tableCount: 0,
|
|
882
|
+
sizeBytes: 0
|
|
883
|
+
}));
|
|
884
|
+
cloudflareApi.createR2Bucket = (async (_acc, name) => ({ name }));
|
|
885
|
+
cloudflareApi.createQueue = (async (_acc, name) => ({
|
|
886
|
+
id: `<would-create:${name}>`,
|
|
887
|
+
name
|
|
888
|
+
}));
|
|
889
|
+
}
|
|
890
|
+
try {
|
|
891
|
+
const hyperdriveIdsByName = await resolveOrCreateResourceIdsByName(pendingHyperdriveNameBindings, {
|
|
892
|
+
listResources: async () => cloudflareApi.listHyperdrives(accountId),
|
|
893
|
+
listFailureMessage: `Could not list Hyperdrive configurations for Cloudflare account ${accountId} while preparing deploy resources.`,
|
|
894
|
+
missingFailureMessage: (missingBindings) => {
|
|
895
|
+
return `Could not find Hyperdrive configuration(s) for ${formatMissingBindings(missingBindings)} in Cloudflare account ${accountId}. Cloudflare does not expose a create API that Devflare can use from only a binding name, so create the Hyperdrive config first or configure the binding with an explicit id.`;
|
|
896
|
+
}
|
|
897
|
+
});
|
|
898
|
+
created.hyperdrive.push(...hyperdriveIdsByName.created);
|
|
899
|
+
existing.hyperdrive.push(...hyperdriveIdsByName.existing);
|
|
900
|
+
const vectorizeState = await ensureNamedResourcesExist(vectorizeNames, {
|
|
901
|
+
listResources: async () => cloudflareApi.listVectorizeIndexes(accountId),
|
|
902
|
+
listFailureMessage: `Could not list Vectorize indexes for Cloudflare account ${accountId} while preparing deploy resources.`,
|
|
903
|
+
missingFailureMessage: (missingNames) => {
|
|
904
|
+
return `Could not find Vectorize index(es) ${missingNames.join(", ")} in Cloudflare account ${accountId}. Devflare can only auto-provision preview-scoped Vectorize indexes by cloning an existing base index; for normal deploys create the index first.`;
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
created.vectorize.push(...vectorizeState.created);
|
|
908
|
+
existing.vectorize.push(...vectorizeState.existing);
|
|
909
|
+
const namespaceIdsByName = await resolveOrCreateResourceIdsByName(pendingKVNameBindings, {
|
|
910
|
+
listResources: async () => cloudflareApi.listKVNamespaces(accountId),
|
|
911
|
+
createResource: async (resourceName) => cloudflareApi.createKVNamespace(accountId, resourceName),
|
|
912
|
+
listFailureMessage: `Could not list KV namespaces for Cloudflare account ${accountId} while preparing deploy resources.`,
|
|
913
|
+
missingFailureMessage: (missingBindings) => {
|
|
914
|
+
return `Could not find KV namespace(s) for ${formatMissingBindings(missingBindings)} in Cloudflare account ${accountId}.`;
|
|
915
|
+
},
|
|
916
|
+
createFailureMessage: (resourceName) => {
|
|
917
|
+
return `Could not create KV namespace "${resourceName}" in Cloudflare account ${accountId} during deploy preparation.`;
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
created.kv.push(...namespaceIdsByName.created);
|
|
921
|
+
existing.kv.push(...namespaceIdsByName.existing);
|
|
922
|
+
const databaseIdsByName = await resolveOrCreateResourceIdsByName(pendingD1NameBindings, {
|
|
923
|
+
listResources: async () => cloudflareApi.listD1Databases(accountId),
|
|
924
|
+
createResource: async (resourceName) => cloudflareApi.createD1Database(accountId, resourceName),
|
|
925
|
+
listFailureMessage: `Could not list D1 databases for Cloudflare account ${accountId} while preparing deploy resources.`,
|
|
926
|
+
missingFailureMessage: (missingBindings) => {
|
|
927
|
+
return `Could not find D1 database(s) for ${formatMissingBindings(missingBindings)} in Cloudflare account ${accountId}.`;
|
|
928
|
+
},
|
|
929
|
+
createFailureMessage: (resourceName) => {
|
|
930
|
+
return `Could not create D1 database "${resourceName}" in Cloudflare account ${accountId} during deploy preparation.`;
|
|
931
|
+
}
|
|
932
|
+
});
|
|
933
|
+
created.d1.push(...databaseIdsByName.created);
|
|
934
|
+
existing.d1.push(...databaseIdsByName.existing);
|
|
935
|
+
const r2State = await ensureNamedResourcesExist(r2Names, {
|
|
936
|
+
listResources: async () => cloudflareApi.listR2Buckets(accountId),
|
|
937
|
+
createResource: async (resourceName) => cloudflareApi.createR2Bucket(accountId, resourceName),
|
|
938
|
+
listFailureMessage: `Could not list R2 buckets for Cloudflare account ${accountId} while preparing deploy resources.`,
|
|
939
|
+
missingFailureMessage: (missingNames) => {
|
|
940
|
+
return `Could not find R2 bucket(s) ${missingNames.join(", ")} in Cloudflare account ${accountId}.`;
|
|
941
|
+
},
|
|
942
|
+
createFailureMessage: (resourceName) => {
|
|
943
|
+
return `Could not create R2 bucket "${resourceName}" in Cloudflare account ${accountId} during deploy preparation.`;
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
created.r2.push(...r2State.created);
|
|
947
|
+
existing.r2.push(...r2State.existing);
|
|
948
|
+
const queueState = await ensureNamedResourcesExist(queueNames, {
|
|
949
|
+
listResources: async () => cloudflareApi.listQueues(accountId),
|
|
950
|
+
createResource: async (resourceName) => cloudflareApi.createQueue(accountId, resourceName),
|
|
951
|
+
listFailureMessage: `Could not list Queues for Cloudflare account ${accountId} while preparing deploy resources.`,
|
|
952
|
+
missingFailureMessage: (missingNames) => {
|
|
953
|
+
return `Could not find Queue(s) ${missingNames.join(", ")} in Cloudflare account ${accountId}.`;
|
|
954
|
+
},
|
|
955
|
+
createFailureMessage: (resourceName) => {
|
|
956
|
+
return `Could not create Queue "${resourceName}" in Cloudflare account ${accountId} during deploy preparation.`;
|
|
957
|
+
}
|
|
958
|
+
});
|
|
959
|
+
created.queues.push(...queueState.created);
|
|
960
|
+
existing.queues.push(...queueState.existing);
|
|
961
|
+
return {
|
|
962
|
+
config: brandAsDeployConfig(withResolvedIdBindings(resolvedConfig, {
|
|
963
|
+
kv: kvBindings ? pendingKVNameBindings.length > 0 ? materializeResolvedNameBindings(kvBindings, normalizeKVNameBinding, namespaceIdsByName.idsByName) : materializeIdBindings(kvBindings, getLocalKVNamespaceIdentifier) : void 0,
|
|
964
|
+
d1: d1Bindings ? pendingD1NameBindings.length > 0 ? materializeResolvedNameBindings(d1Bindings, normalizeD1NameBinding, databaseIdsByName.idsByName) : materializeIdBindings(d1Bindings, getLocalD1DatabaseIdentifier) : void 0,
|
|
965
|
+
hyperdrive: hyperdriveBindings ? pendingHyperdriveNameBindings.length > 0 ? materializeHyperdriveIdBindings(hyperdriveBindings, hyperdriveIdsByName.idsByName) : materializeHyperdriveIdBindings(hyperdriveBindings) : void 0
|
|
966
|
+
})),
|
|
967
|
+
created,
|
|
968
|
+
existing,
|
|
969
|
+
warnings
|
|
970
|
+
};
|
|
971
|
+
} catch (err) {
|
|
972
|
+
throw decorateOrphanError(err, created);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
async function prepareConfigResourcesForDeploy(config, options = {}) {
|
|
976
|
+
return prepareMaterializedConfigResourcesForDeploy(await resolveResources(config, {
|
|
977
|
+
phase: "build",
|
|
978
|
+
environment: options.environment,
|
|
979
|
+
preview: {
|
|
980
|
+
environment: options.environment,
|
|
981
|
+
env: options.env,
|
|
982
|
+
identifier: options.identifier
|
|
983
|
+
}
|
|
984
|
+
}), {
|
|
985
|
+
accountId: options.accountId,
|
|
986
|
+
cloudflare: options.cloudflare,
|
|
987
|
+
describeOnly: options.describeOnly
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
//#endregion
|
|
991
|
+
//#region src/config/resolve-phased.ts
|
|
992
|
+
/**
|
|
993
|
+
* Cast helper used at the resolve-phase boundaries. The brand is a phantom
|
|
994
|
+
* intersection so this is a zero-cost reinterpretation.
|
|
995
|
+
*/
|
|
996
|
+
function brandAsLocalConfig(config) {
|
|
997
|
+
return config;
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Cast helper used at the resolve-phase boundaries. The brand is a phantom
|
|
1001
|
+
* intersection so this is a zero-cost reinterpretation.
|
|
1002
|
+
*/
|
|
1003
|
+
function brandAsDeployConfig(config) {
|
|
1004
|
+
return config;
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Unified phase-discriminated resource resolver. Facade over the legacy
|
|
1008
|
+
* per-phase helpers; stamps the appropriate phase brand on the returned
|
|
1009
|
+
* config so callers can narrow at the type layer.
|
|
1010
|
+
*/
|
|
1011
|
+
async function resolveResources(config, options) {
|
|
1012
|
+
const previewMerged = materializePreviewScopedConfig(mergeConfigForEnvironment(config, options.environment), {
|
|
1013
|
+
environment: options.environment,
|
|
1014
|
+
...options.preview
|
|
1015
|
+
});
|
|
1016
|
+
switch (options.phase) {
|
|
1017
|
+
case "build": return previewMerged;
|
|
1018
|
+
case "local": return resolveConfigForLocalRuntime(previewMerged, void 0);
|
|
1019
|
+
case "deploy":
|
|
1020
|
+
if (options.provision) return (await prepareMaterializedConfigResourcesForDeploy(previewMerged, options.preparation ?? {
|
|
1021
|
+
accountId: options.accountId,
|
|
1022
|
+
cloudflare: options.cloudflare
|
|
1023
|
+
})).config;
|
|
1024
|
+
return await resolveMaterializedConfigResources(previewMerged, {
|
|
1025
|
+
accountId: options.accountId,
|
|
1026
|
+
cloudflare: options.cloudflare
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
//#endregion
|
|
1031
|
+
//#region src/config/resource-resolution.ts
|
|
1032
|
+
const defaultCloudflareApi = {
|
|
1033
|
+
getPrimaryAccount,
|
|
1034
|
+
getEffectiveAccountId,
|
|
1035
|
+
listKVNamespaces,
|
|
1036
|
+
listD1Databases,
|
|
1037
|
+
listHyperdrives
|
|
1038
|
+
};
|
|
1039
|
+
var ConfigResourceResolutionError = class extends Error {
|
|
1040
|
+
code = "CONFIG_RESOURCE_RESOLUTION_ERROR";
|
|
1041
|
+
constructor(message, cause) {
|
|
1042
|
+
super(message);
|
|
1043
|
+
this.name = "ConfigResourceResolutionError";
|
|
1044
|
+
if (cause !== void 0) this.cause = cause;
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
function resolveCloudflareApi(overrides) {
|
|
1048
|
+
return {
|
|
1049
|
+
...defaultCloudflareApi,
|
|
1050
|
+
...overrides ?? {}
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
async function resolveLookupAccountId(config, options, cloudflareApi) {
|
|
1054
|
+
const explicitAccountId = options.accountId ?? config.accountId;
|
|
1055
|
+
if (explicitAccountId) return explicitAccountId;
|
|
1056
|
+
let primaryAccount;
|
|
1057
|
+
try {
|
|
1058
|
+
primaryAccount = await cloudflareApi.getPrimaryAccount();
|
|
1059
|
+
} catch (error) {
|
|
1060
|
+
throw new ConfigResourceResolutionError("Could not resolve Cloudflare-backed resource names because Devflare could not read your Cloudflare accounts. Set accountId in devflare.config.ts, configure a workspace/global default account, or log in with Wrangler.", error);
|
|
1061
|
+
}
|
|
1062
|
+
if (!primaryAccount) throw new ConfigResourceResolutionError("Could not resolve Cloudflare-backed resource names because no Cloudflare account is available. Set accountId in devflare.config.ts, configure a workspace/global default account, or log in with Wrangler.");
|
|
1063
|
+
try {
|
|
1064
|
+
const { accountId } = await cloudflareApi.getEffectiveAccountId(primaryAccount.id);
|
|
1065
|
+
return accountId;
|
|
1066
|
+
} catch (error) {
|
|
1067
|
+
throw new ConfigResourceResolutionError(`Could not determine the effective Cloudflare account for name-based resource resolution after selecting primary account ${primaryAccount.id}.`, error);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
async function resolveResourceIdsByName(pendingBindings, options) {
|
|
1071
|
+
if (pendingBindings.length === 0) return /* @__PURE__ */ new Map();
|
|
1072
|
+
let resources;
|
|
1073
|
+
try {
|
|
1074
|
+
resources = await options.listResources();
|
|
1075
|
+
} catch (error) {
|
|
1076
|
+
throw new ConfigResourceResolutionError(options.listFailureMessage, error);
|
|
1077
|
+
}
|
|
1078
|
+
const idsByName = new Map(resources.map((resource) => [resource.name, resource.id]));
|
|
1079
|
+
const missingBindings = pendingBindings.filter(({ resourceName }) => {
|
|
1080
|
+
return !idsByName.has(resourceName);
|
|
1081
|
+
});
|
|
1082
|
+
if (missingBindings.length > 0) throw new ConfigResourceResolutionError(options.missingFailureMessage(missingBindings));
|
|
1083
|
+
return idsByName;
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Resolve environment overrides and normalize KV/D1/Hyperdrive bindings for purely local runtimes.
|
|
1087
|
+
*
|
|
1088
|
+
* Local Miniflare/workerd flows can use either an explicit resource ID or the
|
|
1089
|
+
* stable resource name as the backing identifier, so this path avoids requiring
|
|
1090
|
+
* Cloudflare auth for local development and tests.
|
|
1091
|
+
*
|
|
1092
|
+
* @internal Prefer the unified `resolveResources(config, { phase: 'local' })`
|
|
1093
|
+
* facade. This lower-level helper remains exported for backwards compatibility
|
|
1094
|
+
* and as the implementation that the seam delegates to; it is not part of the
|
|
1095
|
+
* recommended public surface and may be removed in a future major release.
|
|
1096
|
+
*/
|
|
1097
|
+
function resolveConfigForLocalRuntime(config, environment) {
|
|
1098
|
+
const resolvedConfig = resolveConfigForEnvironment(config, environment);
|
|
1099
|
+
const kvBindings = resolvedConfig.bindings?.kv;
|
|
1100
|
+
const d1Bindings = resolvedConfig.bindings?.d1;
|
|
1101
|
+
const hyperdriveBindings = resolvedConfig.bindings?.hyperdrive;
|
|
1102
|
+
if (!kvBindings && !d1Bindings && !hyperdriveBindings) return brandAsLocalConfig(resolvedConfig);
|
|
1103
|
+
collectPendingNameBindings(kvBindings, normalizeKVNameBinding);
|
|
1104
|
+
return brandAsLocalConfig(withResolvedIdBindings(resolvedConfig, {
|
|
1105
|
+
kv: kvBindings ? materializeIdBindings(kvBindings, getLocalKVNamespaceIdentifier) : void 0,
|
|
1106
|
+
d1: d1Bindings ? materializeIdBindings(d1Bindings, getLocalD1DatabaseIdentifier) : void 0,
|
|
1107
|
+
hyperdrive: materializeHyperdriveIdBindings(hyperdriveBindings)
|
|
1108
|
+
}));
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Resolve Cloudflare-backed resource references such as KV/D1/Hyperdrive
|
|
1112
|
+
* name bindings into concrete IDs.
|
|
1113
|
+
*
|
|
1114
|
+
* Used by the deploy path and by automation/programmatic consumers that need
|
|
1115
|
+
* fully-resolved bindings against a live Cloudflare account. The build path
|
|
1116
|
+
* intentionally does NOT call this — `compileBuildConfig({ preserveNamedBindings: true })`
|
|
1117
|
+
* keeps name-only bindings symbolic in the build artifact so builds remain
|
|
1118
|
+
* reproducible offline. Pick this helper only when ID resolution is desired.
|
|
1119
|
+
*
|
|
1120
|
+
* @internal Prefer the unified `resolveResources(config, { phase: 'deploy' })`
|
|
1121
|
+
* facade. This lower-level helper remains exported as the implementation the
|
|
1122
|
+
* seam delegates to; it is not part of the recommended public surface.
|
|
1123
|
+
*/
|
|
1124
|
+
async function resolveMaterializedConfigResources(resolvedConfig, options = {}) {
|
|
1125
|
+
const kvBindings = resolvedConfig.bindings?.kv;
|
|
1126
|
+
const d1Bindings = resolvedConfig.bindings?.d1;
|
|
1127
|
+
const hyperdriveBindings = resolvedConfig.bindings?.hyperdrive;
|
|
1128
|
+
if (!kvBindings && !d1Bindings && !hyperdriveBindings) return brandAsDeployConfig(resolvedConfig);
|
|
1129
|
+
const pendingKVNameBindings = collectPendingNameBindings(kvBindings, normalizeKVNameBinding);
|
|
1130
|
+
const pendingD1NameBindings = collectPendingNameBindings(d1Bindings, normalizeD1NameBinding);
|
|
1131
|
+
const pendingHyperdriveNameBindings = collectPendingNameBindings(hyperdriveBindings, normalizeHyperdriveNameBinding);
|
|
1132
|
+
if (pendingKVNameBindings.length === 0 && pendingD1NameBindings.length === 0 && pendingHyperdriveNameBindings.length === 0) return brandAsDeployConfig(withResolvedIdBindings(resolvedConfig, {
|
|
1133
|
+
kv: kvBindings ? materializeIdBindings(kvBindings, getLocalKVNamespaceIdentifier) : void 0,
|
|
1134
|
+
d1: d1Bindings ? materializeIdBindings(d1Bindings, getLocalD1DatabaseIdentifier) : void 0,
|
|
1135
|
+
hyperdrive: materializeHyperdriveIdBindings(hyperdriveBindings)
|
|
1136
|
+
}));
|
|
1137
|
+
const cloudflareApi = resolveCloudflareApi(options.cloudflare);
|
|
1138
|
+
const accountId = await resolveLookupAccountId(resolvedConfig, options, cloudflareApi);
|
|
1139
|
+
const namespaceIdsByName = await resolveResourceIdsByName(pendingKVNameBindings, {
|
|
1140
|
+
listResources: async () => cloudflareApi.listKVNamespaces(accountId),
|
|
1141
|
+
listFailureMessage: `Could not list KV namespaces for Cloudflare account ${accountId} while resolving name-based KV bindings.`,
|
|
1142
|
+
missingFailureMessage: (missingBindings) => {
|
|
1143
|
+
return `Could not find KV namespace(s) for ${formatMissingBindings(missingBindings)} in Cloudflare account ${accountId}.`;
|
|
1144
|
+
}
|
|
1145
|
+
});
|
|
1146
|
+
const databaseIdsByName = await resolveResourceIdsByName(pendingD1NameBindings, {
|
|
1147
|
+
listResources: async () => cloudflareApi.listD1Databases(accountId),
|
|
1148
|
+
listFailureMessage: `Could not list D1 databases for Cloudflare account ${accountId} while resolving name-based D1 bindings.`,
|
|
1149
|
+
missingFailureMessage: (missingBindings) => {
|
|
1150
|
+
return `Could not find D1 database(s) for ${formatMissingBindings(missingBindings)} in Cloudflare account ${accountId}.`;
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
1153
|
+
const hyperdriveIdsByName = await resolveResourceIdsByName(pendingHyperdriveNameBindings, {
|
|
1154
|
+
listResources: async () => cloudflareApi.listHyperdrives(accountId),
|
|
1155
|
+
listFailureMessage: `Could not list Hyperdrive configurations for Cloudflare account ${accountId} while resolving name-based Hyperdrive bindings.`,
|
|
1156
|
+
missingFailureMessage: (missingBindings) => {
|
|
1157
|
+
return `Could not find Hyperdrive configuration(s) for ${formatMissingBindings(missingBindings)} in Cloudflare account ${accountId}.`;
|
|
1158
|
+
}
|
|
1159
|
+
});
|
|
1160
|
+
return brandAsDeployConfig(withResolvedIdBindings(resolvedConfig, {
|
|
1161
|
+
kv: materializeResolvedNameBindings(kvBindings, normalizeKVNameBinding, namespaceIdsByName),
|
|
1162
|
+
d1: materializeResolvedNameBindings(d1Bindings, normalizeD1NameBinding, databaseIdsByName),
|
|
1163
|
+
hyperdrive: materializeHyperdriveIdBindings(hyperdriveBindings, hyperdriveIdsByName)
|
|
1164
|
+
}));
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Resolve Cloudflare-backed resource references such as KV/D1/Hyperdrive name bindings into
|
|
1168
|
+
* concrete IDs for build, deploy, and automation workflows.
|
|
1169
|
+
*
|
|
1170
|
+
* @internal Prefer the unified `resolveResources(config, { phase: 'deploy' })`
|
|
1171
|
+
* facade. This wrapper is now a thin shim over the seam, retained for
|
|
1172
|
+
* backwards compatibility with existing callers (`loadResolvedConfig`, etc.).
|
|
1173
|
+
*/
|
|
1174
|
+
async function resolveConfigResources(config, options = {}) {
|
|
1175
|
+
return resolveResources(config, {
|
|
1176
|
+
phase: "deploy",
|
|
1177
|
+
environment: options.environment,
|
|
1178
|
+
preview: {
|
|
1179
|
+
environment: options.environment,
|
|
1180
|
+
env: options.env,
|
|
1181
|
+
identifier: options.identifier
|
|
1182
|
+
},
|
|
1183
|
+
accountId: options.accountId,
|
|
1184
|
+
cloudflare: options.cloudflare
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Load devflare.config.* and resolve any Cloudflare-backed resource references.
|
|
1189
|
+
*
|
|
1190
|
+
* This is the public Node-side API for external automation that needs the same
|
|
1191
|
+
* resolved values Devflare build/deploy flows use.
|
|
1192
|
+
*/
|
|
1193
|
+
async function loadResolvedConfig(options = {}) {
|
|
1194
|
+
return resolveConfigResources(await loadConfig(options), options);
|
|
1195
|
+
}
|
|
1196
|
+
//#endregion
|
|
1197
|
+
//#region src/config/loader.ts
|
|
1198
|
+
/**
|
|
1199
|
+
* Config file names to search for, in order of priority
|
|
1200
|
+
*/
|
|
1201
|
+
const CONFIG_FILES = [
|
|
1202
|
+
"devflare.config.ts",
|
|
1203
|
+
"devflare.config.mts",
|
|
1204
|
+
"devflare.config.js",
|
|
1205
|
+
"devflare.config.mjs"
|
|
1206
|
+
];
|
|
1207
|
+
function resolveC12Module(cwd) {
|
|
1208
|
+
const requireFromCwd = createRequire(join(cwd, "__devflare__.cjs"));
|
|
1209
|
+
try {
|
|
1210
|
+
return requireFromCwd("c12");
|
|
1211
|
+
} catch {
|
|
1212
|
+
return createRequire(import.meta.url)("c12");
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
async function resolveConfigDotenvDirectory(cwd, configFile) {
|
|
1216
|
+
const explicitConfigPath = resolve(cwd, configFile);
|
|
1217
|
+
if (existsSync(explicitConfigPath)) return dirname(explicitConfigPath);
|
|
1218
|
+
const discoveredConfigPath = await resolveConfigPath(cwd);
|
|
1219
|
+
return discoveredConfigPath ? dirname(discoveredConfigPath) : cwd;
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Resolve the config file path in a directory
|
|
1223
|
+
*
|
|
1224
|
+
* @param cwd - Directory to search in
|
|
1225
|
+
* @returns Path to config file or undefined
|
|
1226
|
+
*/
|
|
1227
|
+
async function resolveConfigPath(cwd) {
|
|
1228
|
+
for (const file of CONFIG_FILES) {
|
|
1229
|
+
const path = join(cwd, file);
|
|
1230
|
+
if (existsSync(path)) return path;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Load and validate devflare configuration
|
|
1235
|
+
*
|
|
1236
|
+
* @param options - Loading options
|
|
1237
|
+
* @returns Validated DevflareConfig
|
|
1238
|
+
* @throws When config file not found or validation fails
|
|
1239
|
+
*/
|
|
1240
|
+
async function loadConfig(options = {}) {
|
|
1241
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
1242
|
+
const configFile = options.configFile ?? "devflare.config";
|
|
1243
|
+
const { loadConfig: c12LoadConfig } = resolveC12Module(cwd);
|
|
1244
|
+
await loadDevflareDotenvIntoProcess(await resolveConfigDotenvDirectory(cwd, configFile));
|
|
1245
|
+
const { config, configFile: loadedFile } = await c12LoadConfig({
|
|
1246
|
+
name: "devflare",
|
|
1247
|
+
cwd,
|
|
1248
|
+
configFile,
|
|
1249
|
+
defaultConfig: void 0,
|
|
1250
|
+
rcFile: false,
|
|
1251
|
+
globalRc: false,
|
|
1252
|
+
dotenv: false
|
|
1253
|
+
});
|
|
1254
|
+
if (!config || !loadedFile) throw new ConfigNotFoundError(cwd, configFile);
|
|
1255
|
+
const result = configSchema.safeParse(config);
|
|
1256
|
+
if (!result.success) throw new ConfigValidationError(result.error.issues, loadedFile);
|
|
1257
|
+
return applyFrameworkConfigProviders(result.data, {
|
|
1258
|
+
cwd,
|
|
1259
|
+
configPath: loadedFile
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* Error thrown when config file is not found
|
|
1264
|
+
*/
|
|
1265
|
+
var ConfigNotFoundError = class extends Error {
|
|
1266
|
+
code = "CONFIG_NOT_FOUND";
|
|
1267
|
+
constructor(cwd, configFile) {
|
|
1268
|
+
super(`Config file not found in ${cwd}.\nExpected one of: ${CONFIG_FILES.join(", ")}\nRun 'devflare init' to create a new config.`);
|
|
1269
|
+
this.cwd = cwd;
|
|
1270
|
+
this.configFile = configFile;
|
|
1271
|
+
this.name = "ConfigNotFoundError";
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
/**
|
|
1275
|
+
* Error thrown when config validation fails
|
|
1276
|
+
*/
|
|
1277
|
+
var ConfigValidationError = class extends Error {
|
|
1278
|
+
code = "CONFIG_VALIDATION_ERROR";
|
|
1279
|
+
constructor(issues, configFile) {
|
|
1280
|
+
const issueMessages = issues.map((i) => ` - ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
1281
|
+
super(`Invalid config in ${configFile}:\n${issueMessages}`);
|
|
1282
|
+
this.issues = issues;
|
|
1283
|
+
this.configFile = configFile;
|
|
1284
|
+
this.name = "ConfigValidationError";
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
//#endregion
|
|
1288
|
+
export { ConfigResourceResolutionError as a, prepareConfigResourcesForDeploy as c, configSchema as d, assertValidCronExpression as f, resolveConfigPath as i, mergeConfigForEnvironment as l, ConfigValidationError as n, loadResolvedConfig as o, normalizeCompatibilityFlags as p, loadConfig as r, resolveResources as s, ConfigNotFoundError as t, resolveConfigForEnvironment as u };
|