devflare 1.0.0-next.5 → 1.0.0-next.51
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 +397 -605
- package/bin/devflare.js +30 -14
- package/dist/_chunks/account-Csog80ie.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-Ccza8VQz.js +24 -0
- package/dist/_chunks/build-artifacts-BNssqhxE.js +483 -0
- package/dist/_chunks/cli-CU7wSG1-.js +1163 -0
- package/dist/_chunks/cloudflare-BaloqI3H.js +157 -0
- package/dist/_chunks/colors-DiK6wPJ5.js +13 -0
- package/dist/_chunks/command-utils-_bGRraDR.js +45 -0
- package/dist/_chunks/compiler-BtLp9T9N.js +500 -0
- package/dist/_chunks/config-QU8UEWmA.js +78 -0
- package/dist/_chunks/config-path-1yI7BiDU.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-aifBaMVv.js +1032 -0
- package/dist/_chunks/dev-DF_3baGr.js +3483 -0
- package/dist/_chunks/doctor-tR9kGT_Z.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-DKPp4wqj.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-OQ2AWpqm.js +1308 -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-CYoHfvQ1.js +123 -0
- package/dist/_chunks/local-workflow-entrypoints-8d_mXh8T.js +90 -0
- package/dist/_chunks/login-rVWUZOKC.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-DRWR0gaB.js +359 -0
- package/dist/_chunks/previews-BxNq8Y_J.js +1134 -0
- package/dist/_chunks/productions-DK7xwbEs.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-B6XiI8Sa.js +851 -0
- package/dist/_chunks/runtime-DL-Nz3k8.js +550 -0
- package/dist/_chunks/schema-normalization-GjhTATHL.js +666 -0
- package/dist/_chunks/secrets-qT1JaBGt.js +95 -0
- package/dist/_chunks/tail-CuWI04BL.js +239 -0
- package/dist/_chunks/token-Dmi0KXyX.js +333 -0
- package/dist/_chunks/tokens-iVcgNXi-.js +221 -0
- package/dist/_chunks/types-BquPXsFg.js +484 -0
- package/dist/_chunks/ui-BUoZApvE.js +103 -0
- package/dist/_chunks/usage-BBTGzjon.js +272 -0
- package/dist/_chunks/vite-D_wLDGBs.js +1267 -0
- package/dist/_chunks/vite-utils-OVLMV605.js +183 -0
- package/dist/_chunks/worker-DEF-e8LL.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 +85 -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 +5705 -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 +309 -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 +2087 -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 +3771 -0
- package/dist/config/schema-env.d.ts.map +1 -0
- package/dist/config/schema-normalization.d.ts +267 -0
- package/dist/config/schema-normalization.d.ts.map +1 -0
- package/dist/config/schema-runtime.d.ts +557 -0
- package/dist/config/schema-runtime.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-platform.d.ts +520 -0
- package/dist/config/schema-types-bindings-platform.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-resources.d.ts +802 -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-server.d.ts +122 -0
- package/dist/config/schema-types-runtime-server.d.ts.map +1 -0
- package/dist/config/schema-types-runtime.d.ts +913 -0
- package/dist/config/schema-types-runtime.d.ts.map +1 -0
- package/dist/config/schema-types.d.ts +458 -0
- package/dist/config/schema-types.d.ts.map +1 -0
- package/dist/config/schema.d.ts +5699 -2021
- 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 +90 -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 +93 -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 +4981 -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,462 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, resolve } from "pathe";
|
|
4
|
+
//#region src/config/env-vars.ts
|
|
5
|
+
const ENV_DESCRIPTOR_FLAG = "__devflareEnvDescriptor";
|
|
6
|
+
function createDescriptor(state) {
|
|
7
|
+
return {
|
|
8
|
+
[ENV_DESCRIPTOR_FLAG]: true,
|
|
9
|
+
__state: state,
|
|
10
|
+
optional() {
|
|
11
|
+
return createDescriptor({
|
|
12
|
+
...state,
|
|
13
|
+
optional: true
|
|
14
|
+
});
|
|
15
|
+
},
|
|
16
|
+
parse(parser) {
|
|
17
|
+
return createDescriptor({
|
|
18
|
+
...state,
|
|
19
|
+
parser
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
parser(parser) {
|
|
23
|
+
return this.parse(parser);
|
|
24
|
+
},
|
|
25
|
+
default(value) {
|
|
26
|
+
return createDescriptor({
|
|
27
|
+
...state,
|
|
28
|
+
defaultValue: value,
|
|
29
|
+
hasDefault: true,
|
|
30
|
+
optional: false
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
dev(value) {
|
|
34
|
+
return createDescriptor({
|
|
35
|
+
...state,
|
|
36
|
+
devValue: value,
|
|
37
|
+
hasDevDefault: true
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function createEnvVarDescriptor(name) {
|
|
43
|
+
return createDescriptor({
|
|
44
|
+
name,
|
|
45
|
+
optional: false,
|
|
46
|
+
hasDefault: false,
|
|
47
|
+
hasDevDefault: false
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Config-time environment variable descriptor factory.
|
|
52
|
+
*
|
|
53
|
+
* Accessing a property creates a descriptor for the exact environment variable
|
|
54
|
+
* name, so `env.SECRET` reads `SECRET=...` from Devflare-loaded `.env` files or
|
|
55
|
+
* from `process.env`.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { defineConfig, env } from 'devflare/config'
|
|
60
|
+
*
|
|
61
|
+
* export default defineConfig({
|
|
62
|
+
* vars: {
|
|
63
|
+
* secret: env.SECRET,
|
|
64
|
+
* mongo: {
|
|
65
|
+
* uri: env.MONGOURI,
|
|
66
|
+
* database: env.MONGODATABASE
|
|
67
|
+
* },
|
|
68
|
+
* retries: env.RETRIES.parse(Number)
|
|
69
|
+
* }
|
|
70
|
+
* })
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
const env = new Proxy({}, { get(_target, prop) {
|
|
74
|
+
if (typeof prop !== "string") return;
|
|
75
|
+
return createEnvVarDescriptor(prop);
|
|
76
|
+
} });
|
|
77
|
+
/**
|
|
78
|
+
* Return whether a value was created by the config-time {@link env} proxy.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* isEnvVarDescriptor(env.SECRET) // true
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
function isEnvVarDescriptor(value) {
|
|
86
|
+
return Boolean(value && typeof value === "object" && value[ENV_DESCRIPTOR_FLAG] === true);
|
|
87
|
+
}
|
|
88
|
+
function parseEnvValue(rawValue) {
|
|
89
|
+
const trimmed = rawValue.trim();
|
|
90
|
+
const quote = trimmed[0];
|
|
91
|
+
if ((quote === "\"" || quote === "'" || quote === "`") && trimmed.endsWith(quote) && trimmed.length >= 2) {
|
|
92
|
+
const inner = trimmed.slice(1, -1);
|
|
93
|
+
if (quote !== "\"") return inner;
|
|
94
|
+
return inner.replace(/\\n/g, "\n").replace(/\\r/g, "\r").replace(/\\t/g, " ").replace(/\\"/g, "\"").replace(/\\\\/g, "\\");
|
|
95
|
+
}
|
|
96
|
+
return trimmed;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Parse `.env` file contents with Devflare's no-expansion rules.
|
|
100
|
+
*
|
|
101
|
+
* Devflare intentionally does not expand `$OTHER_VARIABLE` references, so
|
|
102
|
+
* values are read as written instead of going through Bun's environment-file
|
|
103
|
+
* parser.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* parseDevflareEnvFile('TOKEN=abc$123')
|
|
108
|
+
* // { TOKEN: 'abc$123' }
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
function parseDevflareEnvFile(contents) {
|
|
112
|
+
const values = {};
|
|
113
|
+
for (const line of contents.split(/\r?\n/)) {
|
|
114
|
+
const trimmed = line.trim();
|
|
115
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
116
|
+
const assignment = trimmed.startsWith("export ") ? trimmed.slice(7).trimStart() : trimmed;
|
|
117
|
+
const equalsIndex = assignment.indexOf("=");
|
|
118
|
+
if (equalsIndex <= 0) continue;
|
|
119
|
+
const key = assignment.slice(0, equalsIndex).trim();
|
|
120
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) continue;
|
|
121
|
+
values[key] = parseEnvValue(assignment.slice(equalsIndex + 1));
|
|
122
|
+
}
|
|
123
|
+
return values;
|
|
124
|
+
}
|
|
125
|
+
function collectAncestorDirectories(startDir) {
|
|
126
|
+
const directories = [];
|
|
127
|
+
let current = resolve(startDir);
|
|
128
|
+
while (true) {
|
|
129
|
+
directories.push(current);
|
|
130
|
+
const parent = dirname(current);
|
|
131
|
+
if (parent === current) break;
|
|
132
|
+
current = parent;
|
|
133
|
+
}
|
|
134
|
+
return directories.reverse();
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Return `.env.dev` and `.env` candidate paths from the filesystem root to a
|
|
138
|
+
* project directory.
|
|
139
|
+
*
|
|
140
|
+
* Paths are ordered in the same precedence order as loading: parent files
|
|
141
|
+
* first, then closer files, with `.env` after `.env.dev` for each directory.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* getDevflareDotenvPaths(process.cwd())
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
function getDevflareDotenvPaths(startDir) {
|
|
149
|
+
return collectAncestorDirectories(startDir).flatMap((directory) => [resolve(directory, ".env.dev"), resolve(directory, ".env")]);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Load Devflare `.env.dev` and `.env` files without mutating `process.env`.
|
|
153
|
+
*
|
|
154
|
+
* Parent directories are loaded first, closer directories override them, and
|
|
155
|
+
* `.env` overrides `.env.dev` within the same directory.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* const { values } = await loadDevflareDotenv(process.cwd())
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
async function loadDevflareDotenv(startDir) {
|
|
163
|
+
const values = {};
|
|
164
|
+
const files = [];
|
|
165
|
+
for (const filePath of getDevflareDotenvPaths(startDir)) {
|
|
166
|
+
if (!existsSync(filePath)) continue;
|
|
167
|
+
Object.assign(values, parseDevflareEnvFile(await readFile(filePath, "utf8")));
|
|
168
|
+
files.push(filePath);
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
values,
|
|
172
|
+
files
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Load Devflare `.env` values into `process.env` without overwriting existing
|
|
177
|
+
* process-level values.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* await loadDevflareDotenvIntoProcess(process.cwd())
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
async function loadDevflareDotenvIntoProcess(startDir) {
|
|
185
|
+
const loaded = await loadDevflareDotenv(startDir);
|
|
186
|
+
for (const [key, value] of Object.entries(loaded.values)) if (process.env[key] === void 0) process.env[key] = value;
|
|
187
|
+
return loaded;
|
|
188
|
+
}
|
|
189
|
+
function formatMissingEnvTree(missing) {
|
|
190
|
+
const root = {};
|
|
191
|
+
for (const item of missing) {
|
|
192
|
+
let current = root;
|
|
193
|
+
for (const segment of item.path.slice(0, -1)) {
|
|
194
|
+
const next = current[segment];
|
|
195
|
+
if (!next || typeof next !== "object") current[segment] = {};
|
|
196
|
+
current = current[segment];
|
|
197
|
+
}
|
|
198
|
+
current[item.path[item.path.length - 1] ?? item.name] = item.name;
|
|
199
|
+
}
|
|
200
|
+
const lines = [];
|
|
201
|
+
const writeNode = (node, depth) => {
|
|
202
|
+
const indent = " ".repeat(depth);
|
|
203
|
+
for (const [key, value] of Object.entries(node)) if (value && typeof value === "object") {
|
|
204
|
+
lines.push(`${indent}${key}:`);
|
|
205
|
+
writeNode(value, depth + 1);
|
|
206
|
+
} else lines.push(`${indent}${key}: ${String(value)}`);
|
|
207
|
+
};
|
|
208
|
+
writeNode(root, 1);
|
|
209
|
+
return lines.join("\n");
|
|
210
|
+
}
|
|
211
|
+
var EnvVarResolutionError = class extends Error {
|
|
212
|
+
code = "ENV_VARS_MISSING";
|
|
213
|
+
constructor(missing, mode) {
|
|
214
|
+
super([
|
|
215
|
+
"These environment variables are missing:",
|
|
216
|
+
"",
|
|
217
|
+
formatMissingEnvTree(missing)
|
|
218
|
+
].join("\n"));
|
|
219
|
+
this.missing = missing;
|
|
220
|
+
this.mode = mode;
|
|
221
|
+
this.name = "EnvVarResolutionError";
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
var EnvVarParseError = class extends Error {
|
|
225
|
+
code = "ENV_VAR_PARSE_FAILED";
|
|
226
|
+
constructor(variableName, path, cause) {
|
|
227
|
+
super(`Could not parse environment variable ${variableName} for vars.${path.join(".")}.\nParser error: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
228
|
+
this.variableName = variableName;
|
|
229
|
+
this.path = path;
|
|
230
|
+
this.name = "EnvVarParseError";
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
function isPlainObject(value) {
|
|
234
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || isEnvVarDescriptor(value)) return false;
|
|
235
|
+
const prototype = Object.getPrototypeOf(value);
|
|
236
|
+
return prototype === Object.prototype || prototype === null;
|
|
237
|
+
}
|
|
238
|
+
const OMIT_VALUE = Symbol("omit optional env var");
|
|
239
|
+
function resolveDescriptorValue(descriptor, sources, path, mode, missing) {
|
|
240
|
+
const state = descriptor.__state;
|
|
241
|
+
const rawValue = sources[state.name];
|
|
242
|
+
if (rawValue !== void 0) try {
|
|
243
|
+
return state.parser ? state.parser(rawValue) : rawValue;
|
|
244
|
+
} catch (error) {
|
|
245
|
+
throw new EnvVarParseError(state.name, path, error);
|
|
246
|
+
}
|
|
247
|
+
if (mode === "dev" && state.hasDevDefault) return state.devValue;
|
|
248
|
+
if (state.hasDefault) return state.defaultValue;
|
|
249
|
+
if (state.optional) return OMIT_VALUE;
|
|
250
|
+
missing.push({
|
|
251
|
+
path,
|
|
252
|
+
name: state.name
|
|
253
|
+
});
|
|
254
|
+
return OMIT_VALUE;
|
|
255
|
+
}
|
|
256
|
+
function resolveVarValue(value, sources, path, mode, missing) {
|
|
257
|
+
if (isEnvVarDescriptor(value)) return resolveDescriptorValue(value, sources, path, mode, missing);
|
|
258
|
+
if (Array.isArray(value)) return value.map((item, index) => resolveVarValue(item, sources, [...path, String(index)], mode, missing)).filter((item) => item !== OMIT_VALUE);
|
|
259
|
+
if (isPlainObject(value)) {
|
|
260
|
+
const resolved = {};
|
|
261
|
+
for (const [key, childValue] of Object.entries(value)) {
|
|
262
|
+
const child = resolveVarValue(childValue, sources, [...path, key], mode, missing);
|
|
263
|
+
if (child !== OMIT_VALUE) resolved[key] = child;
|
|
264
|
+
}
|
|
265
|
+
return resolved;
|
|
266
|
+
}
|
|
267
|
+
return value;
|
|
268
|
+
}
|
|
269
|
+
function resolveVarsObject(vars, sources, mode, missing) {
|
|
270
|
+
if (!vars) return vars;
|
|
271
|
+
const resolved = resolveVarValue(vars, sources, [], mode, missing);
|
|
272
|
+
return resolved === OMIT_VALUE ? void 0 : resolved;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Resolve all `env.NAME` descriptors under a config's `vars` object.
|
|
276
|
+
*
|
|
277
|
+
* @throws {EnvVarResolutionError} When required environment variables are missing.
|
|
278
|
+
* @throws {EnvVarParseError} When a descriptor parser throws.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* const resolved = await resolveConfigEnvVars(config, {
|
|
283
|
+
* cwd: process.cwd(),
|
|
284
|
+
* mode: 'build'
|
|
285
|
+
* })
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
async function resolveConfigEnvVars(config, options) {
|
|
289
|
+
const sources = {
|
|
290
|
+
...(await loadDevflareDotenv(options.configPath ? dirname(resolve(options.cwd, options.configPath)) : options.cwd)).values,
|
|
291
|
+
...process.env
|
|
292
|
+
};
|
|
293
|
+
const missing = [];
|
|
294
|
+
const vars = resolveVarsObject(config.vars, sources, options.mode, missing);
|
|
295
|
+
if (missing.length > 0) throw new EnvVarResolutionError(missing, options.mode);
|
|
296
|
+
return vars === config.vars ? config : {
|
|
297
|
+
...config,
|
|
298
|
+
vars
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/config/preview.ts
|
|
303
|
+
const PREVIEW_SCOPED_NAME_PREFIX = "__DEVFLARE_PREVIEW_SCOPE__:";
|
|
304
|
+
function getPreviewScopedSeparator(options) {
|
|
305
|
+
return options?.separator ?? "-";
|
|
306
|
+
}
|
|
307
|
+
function encodePreviewScopedName(value) {
|
|
308
|
+
return `${PREVIEW_SCOPED_NAME_PREFIX}${JSON.stringify(value)}`;
|
|
309
|
+
}
|
|
310
|
+
function invalidPreviewScopedName(reason) {
|
|
311
|
+
throw new Error(`Invalid Devflare preview-scoped value: ${reason}. Recreate it with preview.scope(...) instead of constructing preview markers manually.`);
|
|
312
|
+
}
|
|
313
|
+
function decodePreviewScopedName(value) {
|
|
314
|
+
const payload = value.slice(27);
|
|
315
|
+
let parsed;
|
|
316
|
+
try {
|
|
317
|
+
parsed = JSON.parse(payload);
|
|
318
|
+
} catch {
|
|
319
|
+
invalidPreviewScopedName("the encoded payload is not valid JSON");
|
|
320
|
+
}
|
|
321
|
+
const baseName = typeof parsed.baseName === "string" ? parsed.baseName : "";
|
|
322
|
+
if (!baseName.trim()) invalidPreviewScopedName("the encoded payload is missing a non-empty baseName");
|
|
323
|
+
return {
|
|
324
|
+
baseName,
|
|
325
|
+
separator: typeof parsed.separator === "string" && parsed.separator.length > 0 ? parsed.separator : "-"
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function normalizePreviewFragment(rawValue) {
|
|
329
|
+
let normalized = rawValue.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
|
|
330
|
+
if (!normalized) normalized = "preview";
|
|
331
|
+
if (!/^[a-z]/.test(normalized)) normalized = `b-${normalized}`;
|
|
332
|
+
return normalized;
|
|
333
|
+
}
|
|
334
|
+
function getPreviewIdentifierFromEnv(env) {
|
|
335
|
+
const explicitIdentifier = env.DEVFLARE_PREVIEW_IDENTIFIER?.trim();
|
|
336
|
+
if (explicitIdentifier) return {
|
|
337
|
+
identifier: normalizePreviewFragment(explicitIdentifier),
|
|
338
|
+
source: "env-identifier"
|
|
339
|
+
};
|
|
340
|
+
const previewPr = env.DEVFLARE_PREVIEW_PR?.trim();
|
|
341
|
+
if (previewPr) return {
|
|
342
|
+
identifier: normalizePreviewFragment(`pr-${previewPr}`),
|
|
343
|
+
source: "env-pr"
|
|
344
|
+
};
|
|
345
|
+
const previewBranch = env.DEVFLARE_PREVIEW_BRANCH?.trim();
|
|
346
|
+
if (previewBranch) return {
|
|
347
|
+
identifier: normalizePreviewFragment(previewBranch),
|
|
348
|
+
source: "env-branch"
|
|
349
|
+
};
|
|
350
|
+
return {
|
|
351
|
+
identifier: void 0,
|
|
352
|
+
source: "none"
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
function resolvePreviewIdentifier(options = {}) {
|
|
356
|
+
if (options.identifier?.trim()) return {
|
|
357
|
+
identifier: normalizePreviewFragment(options.identifier),
|
|
358
|
+
source: "identifier"
|
|
359
|
+
};
|
|
360
|
+
const envIdentifier = getPreviewIdentifierFromEnv(options.env ?? process.env);
|
|
361
|
+
if (envIdentifier.identifier) return envIdentifier;
|
|
362
|
+
return options.environment === "preview" ? {
|
|
363
|
+
identifier: "preview",
|
|
364
|
+
source: "environment"
|
|
365
|
+
} : {
|
|
366
|
+
identifier: void 0,
|
|
367
|
+
source: "none"
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function mapRecordValues(record, mapper) {
|
|
371
|
+
return Object.fromEntries(Object.entries(record).map(([key, value]) => [key, mapper(value)]));
|
|
372
|
+
}
|
|
373
|
+
const preview = { scope(defaults = {}) {
|
|
374
|
+
return (baseName, options = {}) => {
|
|
375
|
+
if (!baseName.trim()) throw new Error("preview.scope(...) requires a non-empty baseName.");
|
|
376
|
+
return encodePreviewScopedName({
|
|
377
|
+
baseName,
|
|
378
|
+
separator: getPreviewScopedSeparator({
|
|
379
|
+
...defaults,
|
|
380
|
+
...options
|
|
381
|
+
})
|
|
382
|
+
});
|
|
383
|
+
};
|
|
384
|
+
} };
|
|
385
|
+
function isPreviewScopedName(value) {
|
|
386
|
+
return typeof value === "string" && value.startsWith(PREVIEW_SCOPED_NAME_PREFIX);
|
|
387
|
+
}
|
|
388
|
+
function materializePreviewScopedString(value, options = {}) {
|
|
389
|
+
if (!isPreviewScopedName(value)) return value;
|
|
390
|
+
const scoped = decodePreviewScopedName(value);
|
|
391
|
+
const previewIdentifier = resolvePreviewIdentifier(options).identifier;
|
|
392
|
+
return previewIdentifier ? `${scoped.baseName}${scoped.separator}${previewIdentifier}` : scoped.baseName;
|
|
393
|
+
}
|
|
394
|
+
function materializePreviewScopedConfig(config, options = {}) {
|
|
395
|
+
if (!config.bindings) return config;
|
|
396
|
+
const bindings = config.bindings;
|
|
397
|
+
const hasPreviewIdentifier = Boolean(resolvePreviewIdentifier(options).identifier);
|
|
398
|
+
return {
|
|
399
|
+
...config,
|
|
400
|
+
bindings: {
|
|
401
|
+
...bindings,
|
|
402
|
+
...bindings.kv ? { kv: mapRecordValues(bindings.kv, (binding) => {
|
|
403
|
+
return typeof binding === "string" ? materializePreviewScopedString(binding, options) : binding;
|
|
404
|
+
}) } : {},
|
|
405
|
+
...bindings.d1 ? { d1: mapRecordValues(bindings.d1, (binding) => {
|
|
406
|
+
return typeof binding === "string" ? materializePreviewScopedString(binding, options) : binding;
|
|
407
|
+
}) } : {},
|
|
408
|
+
...bindings.r2 ? { r2: mapRecordValues(bindings.r2, (binding) => {
|
|
409
|
+
return typeof binding === "string" ? materializePreviewScopedString(binding, options) : {
|
|
410
|
+
...binding,
|
|
411
|
+
bucketName: materializePreviewScopedString(binding.bucketName, options)
|
|
412
|
+
};
|
|
413
|
+
}) } : {},
|
|
414
|
+
...bindings.queues ? { queues: {
|
|
415
|
+
...bindings.queues,
|
|
416
|
+
...bindings.queues.producers ? { producers: mapRecordValues(bindings.queues.producers, (producer) => {
|
|
417
|
+
return typeof producer === "string" ? materializePreviewScopedString(producer, options) : {
|
|
418
|
+
...producer,
|
|
419
|
+
queue: materializePreviewScopedString(producer.queue, options)
|
|
420
|
+
};
|
|
421
|
+
}) } : {},
|
|
422
|
+
...bindings.queues.consumers ? { consumers: bindings.queues.consumers.map((consumer) => ({
|
|
423
|
+
...consumer,
|
|
424
|
+
queue: materializePreviewScopedString(consumer.queue, options),
|
|
425
|
+
...consumer.deadLetterQueue ? { deadLetterQueue: materializePreviewScopedString(consumer.deadLetterQueue, options) } : {}
|
|
426
|
+
})) } : {}
|
|
427
|
+
} } : {},
|
|
428
|
+
...bindings.services ? { services: mapRecordValues(bindings.services, (binding) => ({
|
|
429
|
+
...binding,
|
|
430
|
+
service: materializePreviewScopedString(binding.service, options)
|
|
431
|
+
})) } : {},
|
|
432
|
+
...bindings.vectorize ? { vectorize: mapRecordValues(bindings.vectorize, (binding) => ({
|
|
433
|
+
...binding,
|
|
434
|
+
indexName: materializePreviewScopedString(binding.indexName, options)
|
|
435
|
+
})) } : {},
|
|
436
|
+
...bindings.hyperdrive ? { hyperdrive: mapRecordValues(bindings.hyperdrive, (binding) => {
|
|
437
|
+
if (typeof binding === "string") return materializePreviewScopedString(binding, options);
|
|
438
|
+
if (binding && typeof binding === "object" && "name" in binding && typeof binding.name === "string") {
|
|
439
|
+
if (hasPreviewIdentifier && binding.previewId) return {
|
|
440
|
+
id: binding.previewId,
|
|
441
|
+
...binding.localConnectionString && { localConnectionString: binding.localConnectionString },
|
|
442
|
+
...!binding.localConnectionString && binding.previewLocalConnectionString && { localConnectionString: binding.previewLocalConnectionString }
|
|
443
|
+
};
|
|
444
|
+
return {
|
|
445
|
+
...binding,
|
|
446
|
+
name: materializePreviewScopedString(binding.name, options)
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
return binding;
|
|
450
|
+
}) } : {},
|
|
451
|
+
...bindings.browser ? { browser: mapRecordValues(bindings.browser, (binding) => {
|
|
452
|
+
return typeof binding === "string" ? materializePreviewScopedString(binding, options) : binding;
|
|
453
|
+
}) } : {},
|
|
454
|
+
...bindings.analyticsEngine ? { analyticsEngine: mapRecordValues(bindings.analyticsEngine, (binding) => ({
|
|
455
|
+
...binding,
|
|
456
|
+
dataset: materializePreviewScopedString(binding.dataset, options)
|
|
457
|
+
})) } : {}
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
//#endregion
|
|
462
|
+
export { resolvePreviewIdentifier as a, getDevflareDotenvPaths as c, resolveConfigEnvVars as d, preview as i, isEnvVarDescriptor as l, materializePreviewScopedConfig as n, EnvVarResolutionError as o, materializePreviewScopedString as r, env as s, isPreviewScopedName as t, loadDevflareDotenvIntoProcess as u };
|