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,90 @@
|
|
|
1
|
+
import { x as normalizeWorkflowBinding } from "./schema-normalization-GjhTATHL.js";
|
|
2
|
+
import { i as findFiles, r as DEFAULT_WORKFLOW_PATTERN } from "./glob-CmQOvunB.js";
|
|
3
|
+
import { t as bundleWorkerEntry } from "./worker-bundler-dTTnYU3n.js";
|
|
4
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
5
|
+
import { join, relative, resolve } from "pathe";
|
|
6
|
+
//#region src/workflows/local-workflow-entrypoints.ts
|
|
7
|
+
function findExportedClasses(code) {
|
|
8
|
+
const classes = [];
|
|
9
|
+
const classPattern = /export\s+class\s+(\w+)/g;
|
|
10
|
+
let match = classPattern.exec(code);
|
|
11
|
+
while (match !== null) {
|
|
12
|
+
classes.push(match[1]);
|
|
13
|
+
match = classPattern.exec(code);
|
|
14
|
+
}
|
|
15
|
+
return classes;
|
|
16
|
+
}
|
|
17
|
+
function toImportSpecifier(fromDir, filePath) {
|
|
18
|
+
const relativePath = relative(fromDir, filePath).replace(/\\/g, "/");
|
|
19
|
+
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
20
|
+
}
|
|
21
|
+
async function discoverWorkflowClasses(config, configDir) {
|
|
22
|
+
const classToFilePath = /* @__PURE__ */ new Map();
|
|
23
|
+
const workflowPatternConfig = config.files?.workflows;
|
|
24
|
+
const workflowPattern = typeof workflowPatternConfig === "string" ? workflowPatternConfig : DEFAULT_WORKFLOW_PATTERN;
|
|
25
|
+
if (workflowPatternConfig === false) return classToFilePath;
|
|
26
|
+
const files = await findFiles(workflowPattern, { cwd: configDir });
|
|
27
|
+
for (const filePath of files) try {
|
|
28
|
+
const code = await readFile(filePath, "utf-8");
|
|
29
|
+
for (const className of findExportedClasses(code)) classToFilePath.set(className, filePath);
|
|
30
|
+
} catch {}
|
|
31
|
+
return classToFilePath;
|
|
32
|
+
}
|
|
33
|
+
async function resolveLocalWorkflowEntrypoints(config, configDir) {
|
|
34
|
+
const workflows = config.bindings?.workflows;
|
|
35
|
+
if (!workflows || Object.keys(workflows).length === 0) return [];
|
|
36
|
+
const classToFilePath = await discoverWorkflowClasses(config, configDir);
|
|
37
|
+
const entrypoints = [];
|
|
38
|
+
for (const [bindingName, binding] of Object.entries(workflows)) {
|
|
39
|
+
const normalized = normalizeWorkflowBinding(binding);
|
|
40
|
+
if (normalized.scriptName) continue;
|
|
41
|
+
const scriptPath = classToFilePath.get(normalized.className);
|
|
42
|
+
if (!scriptPath) throw new Error(`Workflow binding ${bindingName} (className: '${normalized.className}') not found.\nEither set files.workflows to match the workflow source file, or set scriptName when the workflow lives in another worker.`);
|
|
43
|
+
entrypoints.push({
|
|
44
|
+
bindingName,
|
|
45
|
+
className: normalized.className,
|
|
46
|
+
scriptPath
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return entrypoints;
|
|
50
|
+
}
|
|
51
|
+
function buildWorkflowVirtualEntry(entrypoints, entryDir) {
|
|
52
|
+
const imports = entrypoints.map((entrypoint, index) => {
|
|
53
|
+
const importName = `__DevflareWorkflow${index}`;
|
|
54
|
+
const importPath = toImportSpecifier(entryDir, entrypoint.scriptPath);
|
|
55
|
+
return {
|
|
56
|
+
importName,
|
|
57
|
+
className: entrypoint.className,
|
|
58
|
+
line: `import { ${entrypoint.className} as ${importName} } from '${importPath}'`
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
const exports = imports.map((entrypoint) => {
|
|
62
|
+
return `export { ${entrypoint.importName} as ${entrypoint.className} }`;
|
|
63
|
+
});
|
|
64
|
+
return [
|
|
65
|
+
...imports.map((entrypoint) => entrypoint.line),
|
|
66
|
+
"",
|
|
67
|
+
...exports
|
|
68
|
+
].join("\n");
|
|
69
|
+
}
|
|
70
|
+
async function bundleWorkflowEntrypointScript(config, configDir, options = {}) {
|
|
71
|
+
const entrypoints = await resolveLocalWorkflowEntrypoints(config, configDir);
|
|
72
|
+
if (entrypoints.length === 0) return "";
|
|
73
|
+
const entryDir = resolve(configDir, ".devflare", "workflow-entrypoints");
|
|
74
|
+
const entryPath = join(entryDir, "__entry.ts");
|
|
75
|
+
const outFile = join(entryDir, "index.js");
|
|
76
|
+
await mkdir(entryDir, { recursive: true });
|
|
77
|
+
await writeFile(entryPath, buildWorkflowVirtualEntry(entrypoints, entryDir));
|
|
78
|
+
await bundleWorkerEntry({
|
|
79
|
+
cwd: configDir,
|
|
80
|
+
inputFile: entryPath,
|
|
81
|
+
outFile,
|
|
82
|
+
rolldownOptions: config.rolldown?.options,
|
|
83
|
+
sourcemap: config.rolldown?.sourcemap,
|
|
84
|
+
minify: config.rolldown?.minify,
|
|
85
|
+
logger: options.logger
|
|
86
|
+
});
|
|
87
|
+
return await readFile(outFile, "utf-8");
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { bundleWorkflowEntrypointScript as t };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { t as account } from "./cloudflare-BaloqI3H.js";
|
|
2
|
+
import { d as green, f as logLine, g as yellow, h as whiteDim, o as dim, r as createCliTheme } from "./ui-BUoZApvE.js";
|
|
3
|
+
import { n as getConfiguredAccountId } from "./command-utils-_bGRraDR.js";
|
|
4
|
+
import { t as getDependencies } from "./dependencies-C2oxFjU_.js";
|
|
5
|
+
//#region src/cli/commands/login.ts
|
|
6
|
+
async function logResolvedAccount(cwd, logger, theme) {
|
|
7
|
+
try {
|
|
8
|
+
const primaryAccount = await account.getPrimaryAccount();
|
|
9
|
+
if (primaryAccount) {
|
|
10
|
+
logLine(logger, `${dim("Primary account:", theme)} ${green(primaryAccount.name, theme)} ${whiteDim(`(${primaryAccount.id})`, theme)}`);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
} catch {}
|
|
14
|
+
const configuredAccountId = await getConfiguredAccountId(cwd);
|
|
15
|
+
if (!configuredAccountId) {
|
|
16
|
+
logLine(logger, dim("Run `devflare account` to inspect available accounts.", theme));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const configuredAccount = await account.getAccountById(configuredAccountId);
|
|
20
|
+
if (configuredAccount) {
|
|
21
|
+
logLine(logger, `${dim("Configured account:", theme)} ${green(configuredAccount.name, theme)} ${whiteDim(`(${configuredAccount.id})`, theme)}`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
logLine(logger, `${dim("Configured account ID:", theme)} ${whiteDim(configuredAccountId, theme)}`);
|
|
25
|
+
logLine(logger, dim("Run `devflare account --account <id>` to inspect the configured account.", theme));
|
|
26
|
+
}
|
|
27
|
+
async function runLoginCommand(parsed, logger, options) {
|
|
28
|
+
const force = parsed.options.force === true;
|
|
29
|
+
const cwd = options.cwd ?? process.cwd();
|
|
30
|
+
const theme = createCliTheme(parsed.options);
|
|
31
|
+
if (!force && await account.isAuthenticated()) {
|
|
32
|
+
logger.success("Already authenticated with Cloudflare");
|
|
33
|
+
await logResolvedAccount(cwd, logger, theme);
|
|
34
|
+
logLine(logger, dim("Use `devflare login --force` to open Wrangler login again.", theme));
|
|
35
|
+
return { exitCode: 0 };
|
|
36
|
+
}
|
|
37
|
+
logLine(logger);
|
|
38
|
+
logLine(logger, `${yellow("login", theme)} ${dim("Opening Wrangler login…", theme)}`);
|
|
39
|
+
if ((await (await getDependencies()).exec.exec("bunx", ["wrangler", "login"], {
|
|
40
|
+
cwd,
|
|
41
|
+
stdio: "inherit"
|
|
42
|
+
})).exitCode !== 0) {
|
|
43
|
+
logger.error("Wrangler login failed");
|
|
44
|
+
return { exitCode: 1 };
|
|
45
|
+
}
|
|
46
|
+
logger.success("Authenticated with Cloudflare");
|
|
47
|
+
await logResolvedAccount(cwd, logger, theme);
|
|
48
|
+
return { exitCode: 0 };
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { runLoginCommand };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, resolve } from "pathe";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
//#region src/cli/package-metadata.ts
|
|
5
|
+
let packageMetadataPromise = null;
|
|
6
|
+
async function loadPackageMetadata() {
|
|
7
|
+
let currentDir = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
while (true) {
|
|
9
|
+
const packageJsonPath = resolve(currentDir, "package.json");
|
|
10
|
+
try {
|
|
11
|
+
const packageJson = await readFile(packageJsonPath, "utf8");
|
|
12
|
+
const metadata = JSON.parse(packageJson);
|
|
13
|
+
if (metadata.name === "devflare") return metadata;
|
|
14
|
+
} catch {}
|
|
15
|
+
const parentDir = dirname(currentDir);
|
|
16
|
+
if (parentDir === currentDir) throw new Error("Could not resolve the devflare package.json file");
|
|
17
|
+
currentDir = parentDir;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function getPackageMetadata() {
|
|
21
|
+
if (!packageMetadataPromise) packageMetadataPromise = loadPackageMetadata();
|
|
22
|
+
return packageMetadataPromise;
|
|
23
|
+
}
|
|
24
|
+
async function getPackageVersion() {
|
|
25
|
+
return (await getPackageMetadata()).version ?? "0.0.0";
|
|
26
|
+
}
|
|
27
|
+
async function getInitDependencyVersions() {
|
|
28
|
+
const metadata = await getPackageMetadata();
|
|
29
|
+
const dependencies = metadata.dependencies ?? {};
|
|
30
|
+
const devDependencies = metadata.devDependencies ?? {};
|
|
31
|
+
return {
|
|
32
|
+
devflare: `^${metadata.version ?? "0.0.0"}`,
|
|
33
|
+
typescript: dependencies.typescript ?? devDependencies.typescript ?? "^5.7.0",
|
|
34
|
+
wrangler: dependencies.wrangler ?? devDependencies.wrangler ?? "^4.85.0",
|
|
35
|
+
workersTypes: devDependencies["@cloudflare/workers-types"] ?? "^4.20250109.0"
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { getPackageVersion as n, getInitDependencyVersions as t };
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { a as apiGetAll, d as kvGet, f as kvPut, i as apiGet, s as apiPost, u as kvDelete } from "./api-TzdliH-6.js";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
//#region src/cloudflare/account-core.ts
|
|
6
|
+
async function getAccounts(options) {
|
|
7
|
+
return (await apiGetAll("/accounts", options)).map((account) => ({
|
|
8
|
+
id: account.id,
|
|
9
|
+
name: account.name,
|
|
10
|
+
type: account.type,
|
|
11
|
+
createdOn: account.created_on ? new Date(account.created_on) : void 0
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
async function getPrimaryAccount(options) {
|
|
15
|
+
return (await getAccounts(options))[0] ?? null;
|
|
16
|
+
}
|
|
17
|
+
async function getAccountById(accountId, options) {
|
|
18
|
+
try {
|
|
19
|
+
const account = await apiGet(`/accounts/${accountId}`, options);
|
|
20
|
+
return {
|
|
21
|
+
id: account.id,
|
|
22
|
+
name: account.name,
|
|
23
|
+
type: account.type,
|
|
24
|
+
createdOn: account.created_on ? new Date(account.created_on) : void 0
|
|
25
|
+
};
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/cloudflare/kv-namespace.ts
|
|
32
|
+
const DEVFLARE_KV_NAMESPACE_TITLE = "devflare-usage";
|
|
33
|
+
async function getOrCreateNamedKVNamespace(accountId, title = DEVFLARE_KV_NAMESPACE_TITLE, options) {
|
|
34
|
+
const existing = (await apiGetAll(`/accounts/${accountId}/storage/kv/namespaces`, options)).find((namespace) => namespace.title === title);
|
|
35
|
+
if (existing) return existing.id;
|
|
36
|
+
return (await apiPost(`/accounts/${accountId}/storage/kv/namespaces`, { title }, options)).id;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/cloudflare/preferences.ts
|
|
40
|
+
const GLOBAL_ACCOUNT_KEY = "settings:defaultAccountId";
|
|
41
|
+
const LOCAL_CACHE_DIR = ".devflare";
|
|
42
|
+
const LOCAL_CACHE_FILE = "preferences.json";
|
|
43
|
+
/**
|
|
44
|
+
* Write a file atomically by writing to a temp sibling and renaming into place.
|
|
45
|
+
* Prevents corruption if the process is killed mid-write.
|
|
46
|
+
*
|
|
47
|
+
* @internal exported for tests only
|
|
48
|
+
*/
|
|
49
|
+
function writeFileAtomic(path, contents) {
|
|
50
|
+
const tmpPath = path + ".tmp-" + process.pid + "-" + Date.now();
|
|
51
|
+
writeFileSync(tmpPath, contents, "utf-8");
|
|
52
|
+
try {
|
|
53
|
+
renameSync(tmpPath, path);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
try {
|
|
56
|
+
unlinkSync(tmpPath);
|
|
57
|
+
} catch {}
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the path to the local preferences file
|
|
63
|
+
*/
|
|
64
|
+
function getLocalPreferencesPath() {
|
|
65
|
+
return join(homedir(), LOCAL_CACHE_DIR, LOCAL_CACHE_FILE);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Read local preferences from disk
|
|
69
|
+
*/
|
|
70
|
+
function readLocalPreferences() {
|
|
71
|
+
const path = getLocalPreferencesPath();
|
|
72
|
+
if (!existsSync(path)) return {};
|
|
73
|
+
try {
|
|
74
|
+
const content = readFileSync(path, "utf-8");
|
|
75
|
+
return JSON.parse(content);
|
|
76
|
+
} catch {
|
|
77
|
+
return {};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Write local preferences to disk
|
|
82
|
+
*/
|
|
83
|
+
function writeLocalPreferences(prefs) {
|
|
84
|
+
const path = getLocalPreferencesPath();
|
|
85
|
+
const dir = join(homedir(), LOCAL_CACHE_DIR);
|
|
86
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
87
|
+
writeFileAtomic(path, JSON.stringify(prefs, null, " "));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Find the nearest package.json (searching upward from cwd)
|
|
91
|
+
*/
|
|
92
|
+
function findPackageJsonPath(startDir) {
|
|
93
|
+
let dir = startDir ?? process.cwd();
|
|
94
|
+
while (dir !== join(dir, "..")) {
|
|
95
|
+
const pkgPath = join(dir, "package.json");
|
|
96
|
+
if (existsSync(pkgPath)) return pkgPath;
|
|
97
|
+
dir = join(dir, "..");
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Read package.json from a path
|
|
103
|
+
*/
|
|
104
|
+
function readPackageJson(path) {
|
|
105
|
+
try {
|
|
106
|
+
const content = readFileSync(path, "utf-8");
|
|
107
|
+
return JSON.parse(content);
|
|
108
|
+
} catch {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Write package.json to a path
|
|
114
|
+
*/
|
|
115
|
+
function writePackageJson(path, pkg) {
|
|
116
|
+
writeFileAtomic(path, JSON.stringify(pkg, null, " ") + "\n");
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get workspace account ID from nearest package.json
|
|
120
|
+
*/
|
|
121
|
+
function getWorkspaceAccountId() {
|
|
122
|
+
const pkgPath = findPackageJsonPath();
|
|
123
|
+
if (!pkgPath) return null;
|
|
124
|
+
return readPackageJson(pkgPath)?.devflare?.accountId ?? null;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Set workspace account ID in nearest package.json
|
|
128
|
+
* Creates package.json if it doesn't exist
|
|
129
|
+
*/
|
|
130
|
+
function setWorkspaceAccountId(accountId) {
|
|
131
|
+
let pkgPath = findPackageJsonPath();
|
|
132
|
+
let pkg;
|
|
133
|
+
if (pkgPath) pkg = readPackageJson(pkgPath) ?? {};
|
|
134
|
+
else {
|
|
135
|
+
pkgPath = join(process.cwd(), "package.json");
|
|
136
|
+
pkg = {
|
|
137
|
+
name: "workspace",
|
|
138
|
+
private: true
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
if (!pkg.devflare) pkg.devflare = {};
|
|
142
|
+
pkg.devflare.accountId = accountId;
|
|
143
|
+
writePackageJson(pkgPath, pkg);
|
|
144
|
+
return pkgPath;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Find or create the devflare-managed KV namespace
|
|
148
|
+
* (Reuses the same namespace as usage tracking)
|
|
149
|
+
*/
|
|
150
|
+
async function getOrCreatePreferencesNamespace(accountId) {
|
|
151
|
+
return getOrCreateNamedKVNamespace(accountId, DEVFLARE_KV_NAMESPACE_TITLE);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get the global default account ID
|
|
155
|
+
*
|
|
156
|
+
* Priority:
|
|
157
|
+
* 1. Local cache (fast, no network)
|
|
158
|
+
* 2. Cloud KV (if local cache is missing)
|
|
159
|
+
*
|
|
160
|
+
* Returns null if no default is set
|
|
161
|
+
*/
|
|
162
|
+
async function getGlobalDefaultAccountId(fallbackAccountId) {
|
|
163
|
+
const local = readLocalPreferences();
|
|
164
|
+
if (local.defaultAccountId) return local.defaultAccountId;
|
|
165
|
+
try {
|
|
166
|
+
const value = await kvGet(fallbackAccountId, await getOrCreatePreferencesNamespace(fallbackAccountId), GLOBAL_ACCOUNT_KEY);
|
|
167
|
+
if (value) {
|
|
168
|
+
writeLocalPreferences({
|
|
169
|
+
...local,
|
|
170
|
+
defaultAccountId: value,
|
|
171
|
+
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
172
|
+
});
|
|
173
|
+
return value;
|
|
174
|
+
}
|
|
175
|
+
} catch (error) {
|
|
176
|
+
console.debug("[devflare preferences] cloud KV sync failed:", error instanceof Error ? error.message : String(error));
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Set the global default account ID
|
|
182
|
+
* Saves to both local cache and cloud KV
|
|
183
|
+
*
|
|
184
|
+
* @param accountId - The account ID to set as default
|
|
185
|
+
* @param anyAccountId - Any account ID to use for accessing KV (can be the same)
|
|
186
|
+
*/
|
|
187
|
+
async function setGlobalDefaultAccountId(accountId, anyAccountId) {
|
|
188
|
+
const kvAccountId = anyAccountId ?? accountId;
|
|
189
|
+
writeLocalPreferences({
|
|
190
|
+
...readLocalPreferences(),
|
|
191
|
+
defaultAccountId: accountId,
|
|
192
|
+
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
193
|
+
});
|
|
194
|
+
try {
|
|
195
|
+
await kvPut(kvAccountId, await getOrCreatePreferencesNamespace(kvAccountId), GLOBAL_ACCOUNT_KEY, accountId);
|
|
196
|
+
} catch (error) {
|
|
197
|
+
console.debug("[devflare preferences] cloud KV sync failed:", error instanceof Error ? error.message : String(error));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Get the effective account ID to use
|
|
202
|
+
*
|
|
203
|
+
* Priority:
|
|
204
|
+
* 1. Workspace (package.json) - highest priority
|
|
205
|
+
* 2. Global default (local cache + cloud KV)
|
|
206
|
+
* 3. Primary account (first account in list)
|
|
207
|
+
*
|
|
208
|
+
* @param primaryAccountId - The primary account ID to use as fallback
|
|
209
|
+
*/
|
|
210
|
+
async function getEffectiveAccountId(primaryAccountId) {
|
|
211
|
+
const workspaceId = getWorkspaceAccountId();
|
|
212
|
+
if (workspaceId) return {
|
|
213
|
+
accountId: workspaceId,
|
|
214
|
+
source: "workspace"
|
|
215
|
+
};
|
|
216
|
+
const globalId = await getGlobalDefaultAccountId(primaryAccountId);
|
|
217
|
+
if (globalId) return {
|
|
218
|
+
accountId: globalId,
|
|
219
|
+
source: "global"
|
|
220
|
+
};
|
|
221
|
+
return {
|
|
222
|
+
accountId: primaryAccountId,
|
|
223
|
+
source: "primary"
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Clear the global default account ID (both local and cloud)
|
|
228
|
+
*/
|
|
229
|
+
async function clearGlobalDefaultAccountId(anyAccountId) {
|
|
230
|
+
const local = readLocalPreferences();
|
|
231
|
+
delete local.defaultAccountId;
|
|
232
|
+
local.lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
|
|
233
|
+
writeLocalPreferences(local);
|
|
234
|
+
try {
|
|
235
|
+
await kvDelete(anyAccountId, await getOrCreatePreferencesNamespace(anyAccountId), GLOBAL_ACCOUNT_KEY);
|
|
236
|
+
} catch (error) {
|
|
237
|
+
console.debug("[devflare preferences] cloud KV sync failed:", error instanceof Error ? error.message : String(error));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
241
|
+
export { setGlobalDefaultAccountId as a, getOrCreateNamedKVNamespace as c, getPrimaryAccount as d, getWorkspaceAccountId as i, getAccountById as l, getEffectiveAccountId as n, setWorkspaceAccountId as o, getGlobalDefaultAccountId as r, DEVFLARE_KV_NAMESPACE_TITLE as s, clearGlobalDefaultAccountId as t, getAccounts as u };
|