devflare 1.0.0-next.7 → 1.0.0-next.70
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 +17315 -2144
- package/README.md +398 -607
- package/bin/devflare.js +30 -14
- package/dist/_chunks/account-BHY3fvrA.js +462 -0
- package/dist/_chunks/account-resources-BdKj8q1h.js +159 -0
- package/dist/_chunks/ai-CN_SREim.js +322 -0
- package/dist/_chunks/api-BKClUlUf.js +568 -0
- package/dist/_chunks/build-DplSo6Gc.js +24 -0
- package/dist/_chunks/build-artifacts-CkwCap5N.js +483 -0
- package/dist/_chunks/cli-ZJYtm-lW.js +1214 -0
- package/dist/_chunks/cloudflare-Ic5ubQza.js +157 -0
- package/dist/_chunks/colors-D0NVzAFN.js +13 -0
- package/dist/_chunks/command-utils-DjaaMQX7.js +45 -0
- package/dist/_chunks/compiler-UxXQgEPq.js +521 -0
- package/dist/_chunks/config-path-CYGlwKDs.js +42 -0
- package/dist/_chunks/config-zQd4jmXU.js +78 -0
- package/dist/_chunks/context-DGMev2AF.js +2515 -0
- package/dist/_chunks/decorators-eXNZ1S0N.js +19 -0
- package/dist/_chunks/dependencies-wKqrxKV_.js +57 -0
- package/dist/_chunks/deploy-z1_wbNn2.js +1032 -0
- package/dist/_chunks/dev-BagtFegV.js +952 -0
- package/dist/_chunks/doctor-CAsJ-rSZ.js +219 -0
- package/dist/_chunks/durable-object-DuMPM8re.js +234 -0
- package/dist/_chunks/env-D4uJqqgu.js +125 -0
- package/dist/_chunks/family-BTTpTwUk.js +143 -0
- package/dist/_chunks/generated-artifacts-Bb13pGUG.js +32 -0
- package/dist/_chunks/glob-DRw9sbfF.js +56 -0
- package/dist/_chunks/init-DJ5y3mu5.js +165 -0
- package/dist/_chunks/loader-BC0skbnH.js +1330 -0
- package/dist/_chunks/local-dev-vars-BFLS-HoI.js +81 -0
- package/dist/_chunks/local-hyperdrive-CcORzo76.js +119 -0
- package/dist/_chunks/local-media-bindings-ZQe-epuw.js +335 -0
- package/dist/_chunks/local-secrets-C0n5oRgI.js +123 -0
- package/dist/_chunks/login-CgNcbpEq.js +51 -0
- package/dist/_chunks/package-metadata-CLI488gB.js +39 -0
- package/dist/_chunks/preferences-CbYERA_m.js +241 -0
- package/dist/_chunks/preview-j9Kbx4-G.js +462 -0
- package/dist/_chunks/preview-registry-CTXU4mBc.js +1186 -0
- package/dist/_chunks/preview-resources-CQIu2-NY.js +359 -0
- package/dist/_chunks/previews-BIaw6NVC.js +1133 -0
- package/dist/_chunks/productions-CF8oQcX7.js +504 -0
- package/dist/_chunks/r2-presign-runtime-C75FkLMd.js +291 -0
- package/dist/_chunks/ref-CYJNAAe_.js +178 -0
- package/dist/_chunks/remote-8jEHLVGg.js +79 -0
- package/dist/_chunks/remote-config-Bw6qIVM4.js +132 -0
- package/dist/_chunks/resolve-package-DeJUGxoE.js +152 -0
- package/dist/_chunks/rolldown-runtime-CvQ6eiug.js +14 -0
- package/dist/_chunks/routes-CRXB3-iw.js +851 -0
- package/dist/_chunks/runtime-BlKTWIgD.js +874 -0
- package/dist/_chunks/schema-normalization-CTdiY17P.js +667 -0
- package/dist/_chunks/secrets-BJuEa9Jz.js +95 -0
- package/dist/_chunks/tail-DjGRt8gw.js +239 -0
- package/dist/_chunks/token-wmeF8-IQ.js +333 -0
- package/dist/_chunks/tokens-KaEr4B8e.js +221 -0
- package/dist/_chunks/types-BLGfxIq-.js +484 -0
- package/dist/_chunks/ui-BhCdDC2N.js +103 -0
- package/dist/_chunks/usage-rRusKejc.js +272 -0
- package/dist/_chunks/vite-Bml-Whp8.js +1267 -0
- package/dist/_chunks/vite-process-CDa3yQui.js +2929 -0
- package/dist/_chunks/vite-utils-D8kPPxUy.js +183 -0
- package/dist/_chunks/worker-DgczaXVW.js +410 -0
- package/dist/_chunks/worker-bundler-Isj5jiW6.js +458 -0
- package/dist/_chunks/worker-entrypoint-C8j23t6d.js +247 -0
- package/dist/_chunks/workerName-kEXwmV2m.js +23 -0
- package/dist/_chunks/workspace-CrvqPLTX.js +517 -0
- package/dist/_chunks/workspace-Ds3xMjOE.js +175 -0
- package/dist/bridge/client.d.ts +93 -8
- package/dist/bridge/client.d.ts.map +1 -1
- package/dist/bridge/do-rpc-dispatch.d.ts +23 -0
- package/dist/bridge/do-rpc-dispatch.d.ts.map +1 -0
- package/dist/bridge/do-websocket-connect.d.ts +33 -0
- package/dist/bridge/do-websocket-connect.d.ts.map +1 -0
- 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-gateway.d.ts +45 -0
- package/dist/bridge/miniflare-gateway.d.ts.map +1 -0
- package/dist/bridge/miniflare.d.ts +92 -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/r2-presign-runtime.d.ts +9 -0
- package/dist/bridge/r2-presign-runtime.d.ts.map +1 -0
- 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/v2/value-serialization.d.ts +139 -0
- 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/bridge/websocket-constructor.d.ts +38 -0
- package/dist/bridge/websocket-constructor.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 +5778 -43
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +73 -142
- 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/commands/workspace.d.ts +8 -0
- package/dist/cli/commands/workspace.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 +308 -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 +13 -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 +2124 -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 +3821 -0
- package/dist/config/schema-env.d.ts.map +1 -0
- package/dist/config/schema-normalization.d.ts +272 -0
- package/dist/config/schema-normalization.d.ts.map +1 -0
- package/dist/config/schema-runtime.d.ts +597 -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 +196 -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 +5796 -2023
- 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/workspace.d.ts +282 -0
- package/dist/config/workspace.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 +22 -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 +57 -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 +100 -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-health.d.ts +79 -0
- package/dist/dev-server/runtime-health.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 +24 -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/dev-server/workspace/merge-config.d.ts +81 -0
- package/dist/dev-server/workspace/merge-config.d.ts.map +1 -0
- package/dist/dev-server/workspace/prepare-app.d.ts +84 -0
- package/dist/dev-server/workspace/prepare-app.d.ts.map +1 -0
- package/dist/dev-server/workspace/server.d.ts +47 -0
- package/dist/dev-server/workspace/server.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 +10 -297
- 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 +11 -5
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +5 -184
- package/dist/runtime/middleware.d.ts +119 -67
- package/dist/runtime/middleware.d.ts.map +1 -1
- package/dist/runtime/r2-presign.d.ts +164 -0
- package/dist/runtime/r2-presign.d.ts.map +1 -0
- 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 +377 -169
- 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 +42 -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 +5115 -75
- package/dist/test/offline-bindings.d.ts +124 -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 +18 -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 +45 -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/send-email.d.ts +27 -0
- package/dist/test/utilities/send-email.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 +14 -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 -407
- 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 +5 -8
- package/dist/worker-entry/composed-worker.d.ts.map +1 -1
- 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 +160 -117
- 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 +0 -83
- 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-9myaxf07.js +0 -70
- package/dist/deploy-h1wz5p7m.js +0 -86
- package/dist/dev-rsdssknb.js +0 -2707
- package/dist/doctor-v7jy4s3r.js +0 -190
- package/dist/durable-object-t4kbb0yt.js +0 -13
- 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-62b3gt2g.js +0 -12
- package/dist/index-67qcae0f.js +0 -183
- package/dist/index-9ats0s83.js +0 -70
- package/dist/index-a0fjkq68.js +0 -198
- package/dist/index-a855bdsx.js +0 -18
- package/dist/index-ccrh4w3t.js +0 -1133
- package/dist/index-d8bdkx2h.js +0 -109
- package/dist/index-f8qh2tyh.js +0 -2152
- package/dist/index-gz1gndna.js +0 -307
- package/dist/index-hcex3rgh.js +0 -266
- package/dist/index-k7r18na8.js +0 -0
- package/dist/index-n3np2d6t.js +0 -462
- package/dist/index-n7rs26ft.js +0 -77
- package/dist/index-npc1c8jx.js +0 -44
- package/dist/index-p7g30wd2.js +0 -281
- package/dist/index-rbht7m9r.js +0 -36
- package/dist/index-tfyxa77h.js +0 -850
- package/dist/index-tk6ej9dj.js +0 -94
- package/dist/index-v8vvsn9x.js +0 -169
- 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-wdcpnfvy.js +0 -487
- package/dist/worker-entrypoint-m9th0rg0.js +0 -13
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
import { r as loadConfig } from "./loader-BC0skbnH.js";
|
|
2
|
+
import { o as normalizeDOBinding } from "./schema-normalization-CTdiY17P.js";
|
|
3
|
+
import { n as bold, o as dim, r as createCliTheme } from "./ui-BhCdDC2N.js";
|
|
4
|
+
import { n as findDurableObjectClasses } from "./durable-object-DuMPM8re.js";
|
|
5
|
+
import { i as findFiles, n as DEFAULT_ENTRYPOINT_PATTERN, t as DEFAULT_DO_PATTERN } from "./glob-DRw9sbfF.js";
|
|
6
|
+
import { n as discoverEntrypointsAsync, t as resolvePackageSpecifier } from "./resolve-package-DeJUGxoE.js";
|
|
7
|
+
import { t as getDependencies } from "./dependencies-wKqrxKV_.js";
|
|
8
|
+
import { r as resolveConfigCandidatePath } from "./config-path-CYGlwKDs.js";
|
|
9
|
+
import { dirname, relative, resolve } from "pathe";
|
|
10
|
+
import { readFile } from "node:fs/promises";
|
|
11
|
+
//#region src/cli/commands/type-generation/discovery.ts
|
|
12
|
+
const DEFAULT_INTERFACE_LOOKUP_KEYS = new Set([
|
|
13
|
+
"Worker",
|
|
14
|
+
"Default",
|
|
15
|
+
"MathService"
|
|
16
|
+
]);
|
|
17
|
+
const interfaceTypeCache = /* @__PURE__ */ new Map();
|
|
18
|
+
async function readFileIfAvailable(filePath) {
|
|
19
|
+
try {
|
|
20
|
+
return await readFile(filePath, "utf-8");
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function getInterfaceSearchKey(searchDirs) {
|
|
26
|
+
return [...new Set(searchDirs)].sort((left, right) => left.localeCompare(right)).join("\0");
|
|
27
|
+
}
|
|
28
|
+
function getPatternMatches(pattern, code) {
|
|
29
|
+
const matches = [];
|
|
30
|
+
pattern.lastIndex = 0;
|
|
31
|
+
let nextMatch = pattern.exec(code);
|
|
32
|
+
while (nextMatch !== null) {
|
|
33
|
+
matches.push(nextMatch);
|
|
34
|
+
nextMatch = pattern.exec(code);
|
|
35
|
+
}
|
|
36
|
+
return matches;
|
|
37
|
+
}
|
|
38
|
+
function getInterfaceBaseName(interfaceName) {
|
|
39
|
+
if (interfaceName.endsWith("Interface")) return interfaceName.slice(0, -9);
|
|
40
|
+
if (interfaceName.endsWith("Rpc")) return interfaceName.slice(0, -3);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
function registerInterfaceType(interfaces, baseName, interfaceInfo) {
|
|
44
|
+
if (!interfaces.has(baseName)) interfaces.set(baseName, interfaceInfo);
|
|
45
|
+
if (!interfaces.has("__default__") && DEFAULT_INTERFACE_LOOKUP_KEYS.has(baseName)) interfaces.set("__default__", interfaceInfo);
|
|
46
|
+
}
|
|
47
|
+
async function collectInterfaceTypesFromFile(interfaces, filePath) {
|
|
48
|
+
const code = await readFileIfAvailable(filePath);
|
|
49
|
+
if (!code) return;
|
|
50
|
+
for (const match of getPatternMatches(/export\s+interface\s+(\w+(?:Interface|Rpc))\s*\{/g, code)) {
|
|
51
|
+
const interfaceName = match[1];
|
|
52
|
+
const baseName = getInterfaceBaseName(interfaceName);
|
|
53
|
+
if (!baseName) continue;
|
|
54
|
+
registerInterfaceType(interfaces, baseName, {
|
|
55
|
+
filePath,
|
|
56
|
+
interfaceName
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async function parseConfigForRefs(configPath) {
|
|
61
|
+
const refs = [];
|
|
62
|
+
const serviceBindings = [];
|
|
63
|
+
const doBindings = [];
|
|
64
|
+
const code = await readFileIfAvailable(configPath);
|
|
65
|
+
if (!code) return {
|
|
66
|
+
refs,
|
|
67
|
+
serviceBindings,
|
|
68
|
+
doBindings
|
|
69
|
+
};
|
|
70
|
+
for (const match of getPatternMatches(/const\s+(\w+)\s*=\s*ref\s*\(\s*(?:'[^']*'\s*,\s*)?(?:\(\s*\)\s*=>\s*)?import\s*\(\s*['"]([^'"]+)['"]\s*\)/g, code)) refs.push({
|
|
71
|
+
varName: match[1],
|
|
72
|
+
importPath: match[2]
|
|
73
|
+
});
|
|
74
|
+
for (const match of getPatternMatches(/(\w+)\s*:\s*(\w+)\.worker(?:\s*\(\s*['"](\w+)['"]\s*\))?/g, code)) serviceBindings.push({
|
|
75
|
+
bindingName: match[1],
|
|
76
|
+
varName: match[2],
|
|
77
|
+
entrypoint: match[3]
|
|
78
|
+
});
|
|
79
|
+
for (const match of getPatternMatches(/(\w+)\s*:\s*(\w+)\.([A-Z][A-Z0-9_]*)\s*[,\n\r}]/g, code)) {
|
|
80
|
+
if (match[3] === "worker") continue;
|
|
81
|
+
doBindings.push({
|
|
82
|
+
bindingName: match[1],
|
|
83
|
+
varName: match[2],
|
|
84
|
+
doName: match[3]
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
refs,
|
|
89
|
+
serviceBindings,
|
|
90
|
+
doBindings
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
async function findInterfaceTypes(searchDirs) {
|
|
94
|
+
const interfaces = /* @__PURE__ */ new Map();
|
|
95
|
+
for (const dir of [...new Set(searchDirs)]) {
|
|
96
|
+
const typeFiles = await findFiles("**/*.types.ts", { cwd: dir });
|
|
97
|
+
const srcFiles = await findFiles("src/**/*.ts", { cwd: dir });
|
|
98
|
+
const allFiles = [...new Set([...typeFiles, ...srcFiles])];
|
|
99
|
+
for (const filePath of allFiles) await collectInterfaceTypesFromFile(interfaces, filePath);
|
|
100
|
+
}
|
|
101
|
+
return interfaces;
|
|
102
|
+
}
|
|
103
|
+
async function getCachedInterfaceTypes(searchDirs) {
|
|
104
|
+
const cacheKey = getInterfaceSearchKey(searchDirs);
|
|
105
|
+
const cached = interfaceTypeCache.get(cacheKey);
|
|
106
|
+
if (cached) return cached;
|
|
107
|
+
const pending = findInterfaceTypes(searchDirs);
|
|
108
|
+
interfaceTypeCache.set(cacheKey, pending);
|
|
109
|
+
try {
|
|
110
|
+
return await pending;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
interfaceTypeCache.delete(cacheKey);
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async function discoverDurableObjects(cwd, pattern = DEFAULT_DO_PATTERN) {
|
|
117
|
+
const discovered = [];
|
|
118
|
+
const files = await findFiles(pattern, { cwd });
|
|
119
|
+
for (const filePath of files) {
|
|
120
|
+
const code = await readFileIfAvailable(filePath);
|
|
121
|
+
if (!code) continue;
|
|
122
|
+
const classNames = findDurableObjectClasses(code);
|
|
123
|
+
for (const className of classNames) {
|
|
124
|
+
const bindingName = className.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").toUpperCase();
|
|
125
|
+
discovered.push({
|
|
126
|
+
className,
|
|
127
|
+
filePath,
|
|
128
|
+
bindingName
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return discovered;
|
|
133
|
+
}
|
|
134
|
+
function generateImportPath(cwd, filePath) {
|
|
135
|
+
let relativePath = relative(cwd, filePath);
|
|
136
|
+
relativePath = relativePath.replace(/\.(ts|tsx|js|jsx)$/, "");
|
|
137
|
+
if (!relativePath.startsWith(".") && !relativePath.startsWith("/")) relativePath = `./${relativePath}`;
|
|
138
|
+
return relativePath;
|
|
139
|
+
}
|
|
140
|
+
async function resolveReferencedConfigs(configPath, cwd) {
|
|
141
|
+
const referenced = [];
|
|
142
|
+
const { refs, serviceBindings, doBindings } = await parseConfigForRefs(configPath);
|
|
143
|
+
if (refs.length === 0) return referenced;
|
|
144
|
+
const configDir = dirname(configPath);
|
|
145
|
+
const referencedConfigDetailsByPath = /* @__PURE__ */ new Map();
|
|
146
|
+
for (const ref of refs) {
|
|
147
|
+
const refConfigPath = await resolveConfigCandidatePath(resolvePackageSpecifier(ref.importPath, configDir));
|
|
148
|
+
if (!refConfigPath) continue;
|
|
149
|
+
try {
|
|
150
|
+
let referencedConfigDetails = referencedConfigDetailsByPath.get(refConfigPath);
|
|
151
|
+
if (!referencedConfigDetails) {
|
|
152
|
+
referencedConfigDetails = (async () => {
|
|
153
|
+
const refDir = dirname(refConfigPath);
|
|
154
|
+
return {
|
|
155
|
+
refDir,
|
|
156
|
+
entrypoints: await discoverEntrypointsAsync(refDir, DEFAULT_ENTRYPOINT_PATTERN),
|
|
157
|
+
refDOs: await discoverDurableObjects(refDir, DEFAULT_DO_PATTERN),
|
|
158
|
+
interfaceMap: await getCachedInterfaceTypes([configDir, refDir])
|
|
159
|
+
};
|
|
160
|
+
})();
|
|
161
|
+
referencedConfigDetailsByPath.set(refConfigPath, referencedConfigDetails);
|
|
162
|
+
}
|
|
163
|
+
const { refDir, entrypoints, refDOs, interfaceMap } = await referencedConfigDetails;
|
|
164
|
+
const bindings = serviceBindings.filter((serviceBinding) => serviceBinding.varName === ref.varName).map((serviceBinding) => {
|
|
165
|
+
const info = {
|
|
166
|
+
bindingName: serviceBinding.bindingName,
|
|
167
|
+
entrypoint: serviceBinding.entrypoint
|
|
168
|
+
};
|
|
169
|
+
const lookupKey = serviceBinding.entrypoint || "__default__";
|
|
170
|
+
const interfaceInfo = interfaceMap.get(lookupKey) || (serviceBinding.entrypoint ? interfaceMap.get(serviceBinding.entrypoint) : void 0);
|
|
171
|
+
if (interfaceInfo) {
|
|
172
|
+
info.interfaceImport = generateImportPath(cwd, interfaceInfo.filePath);
|
|
173
|
+
info.interfaceType = interfaceInfo.interfaceName;
|
|
174
|
+
}
|
|
175
|
+
return info;
|
|
176
|
+
});
|
|
177
|
+
const crossWorkerDOs = doBindings.filter((doBinding) => doBinding.varName === ref.varName).map((doBinding) => {
|
|
178
|
+
const matchingDO = refDOs.find((doInfo) => doInfo.bindingName === doBinding.doName);
|
|
179
|
+
if (!matchingDO) return null;
|
|
180
|
+
return {
|
|
181
|
+
bindingName: doBinding.bindingName,
|
|
182
|
+
doName: doBinding.doName,
|
|
183
|
+
className: matchingDO.className,
|
|
184
|
+
filePath: matchingDO.filePath
|
|
185
|
+
};
|
|
186
|
+
}).filter((item) => item !== null);
|
|
187
|
+
referenced.push({
|
|
188
|
+
varName: ref.varName,
|
|
189
|
+
importPath: ref.importPath,
|
|
190
|
+
refDir,
|
|
191
|
+
entrypoints,
|
|
192
|
+
serviceBindings: bindings,
|
|
193
|
+
durableObjects: crossWorkerDOs
|
|
194
|
+
});
|
|
195
|
+
} catch {}
|
|
196
|
+
}
|
|
197
|
+
return referenced;
|
|
198
|
+
}
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/cli/commands/type-generation/generator.ts
|
|
201
|
+
function generateBindingMembers(config, doClassMap, crossWorkerDOMap, serviceBindingMap, cwd, indent, options = {}) {
|
|
202
|
+
const lines = [];
|
|
203
|
+
const imports = [];
|
|
204
|
+
if (config.bindings) {
|
|
205
|
+
if (config.bindings.kv) for (const binding of Object.keys(config.bindings.kv)) lines.push(`${indent}${binding}: KVNamespace`);
|
|
206
|
+
if (config.bindings.d1) for (const binding of Object.keys(config.bindings.d1)) lines.push(`${indent}${binding}: D1Database`);
|
|
207
|
+
if (config.bindings.r2) for (const binding of Object.keys(config.bindings.r2)) lines.push(`${indent}${binding}: R2Bucket`);
|
|
208
|
+
if (config.bindings.durableObjects) for (const [binding, doConfig] of Object.entries(config.bindings.durableObjects)) {
|
|
209
|
+
const crossWorkerDO = crossWorkerDOMap.get(binding);
|
|
210
|
+
if (crossWorkerDO) {
|
|
211
|
+
const importPath = generateImportPath(cwd, crossWorkerDO.filePath);
|
|
212
|
+
lines.push(`${indent}${binding}: DurableObjectNamespace<Rpc.DurableObjectBranded & import('${importPath}').${crossWorkerDO.className}>`);
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const className = doConfig.className;
|
|
216
|
+
if (className) {
|
|
217
|
+
const classInfo = doClassMap.get(className);
|
|
218
|
+
if (classInfo) {
|
|
219
|
+
lines.push(`${indent}${binding}: DurableObjectNamespace<Rpc.DurableObjectBranded & import('${classInfo.importPath}').${classInfo.className}>`);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
lines.push(`${indent}${binding}: DurableObjectNamespace`);
|
|
224
|
+
}
|
|
225
|
+
if (config.bindings.queues?.producers) for (const binding of Object.keys(config.bindings.queues.producers)) lines.push(`${indent}${binding}: Queue`);
|
|
226
|
+
if (config.bindings.rateLimits) for (const binding of Object.keys(config.bindings.rateLimits)) lines.push(`${indent}${binding}: RateLimit`);
|
|
227
|
+
if (config.bindings.versionMetadata?.binding) lines.push(`${indent}${config.bindings.versionMetadata.binding}: WorkerVersionMetadata`);
|
|
228
|
+
if (config.bindings.workerLoaders) for (const binding of Object.keys(config.bindings.workerLoaders)) lines.push(`${indent}${binding}: WorkerLoader`);
|
|
229
|
+
if (config.bindings.mtlsCertificates) for (const binding of Object.keys(config.bindings.mtlsCertificates)) lines.push(`${indent}${binding}: Fetcher`);
|
|
230
|
+
if (config.bindings.dispatchNamespaces) for (const binding of Object.keys(config.bindings.dispatchNamespaces)) lines.push(`${indent}${binding}: DispatchNamespace`);
|
|
231
|
+
if (config.bindings.workflows) for (const binding of Object.keys(config.bindings.workflows)) lines.push(`${indent}${binding}: Workflow`);
|
|
232
|
+
if (config.bindings.pipelines) {
|
|
233
|
+
imports.push("import type { Pipeline } from 'cloudflare:pipelines'");
|
|
234
|
+
for (const binding of Object.keys(config.bindings.pipelines)) lines.push(`${indent}${binding}: Pipeline`);
|
|
235
|
+
}
|
|
236
|
+
if (config.bindings.images) for (const binding of Object.keys(config.bindings.images)) lines.push(`${indent}${binding}: ImagesBinding`);
|
|
237
|
+
if (config.bindings.media) for (const binding of Object.keys(config.bindings.media)) lines.push(`${indent}${binding}: MediaBinding`);
|
|
238
|
+
if (config.bindings.stream) for (const binding of Object.keys(config.bindings.stream)) lines.push(`${indent}${binding}: StreamBinding`);
|
|
239
|
+
if (config.bindings.flagship) for (const binding of Object.keys(config.bindings.flagship)) lines.push(`${indent}${binding}: Flagship`);
|
|
240
|
+
if (config.bindings.vpcServices) for (const binding of Object.keys(config.bindings.vpcServices)) lines.push(`${indent}${binding}: Fetcher`);
|
|
241
|
+
if (config.bindings.vpcNetworks) for (const binding of Object.keys(config.bindings.vpcNetworks)) lines.push(`${indent}${binding}: Fetcher`);
|
|
242
|
+
if (config.bindings.artifacts) for (const binding of Object.keys(config.bindings.artifacts)) lines.push(`${indent}${binding}: Artifacts`);
|
|
243
|
+
if (config.bindings.secretsStore) for (const binding of Object.keys(config.bindings.secretsStore)) lines.push(`${indent}${binding}: SecretsStoreSecret`);
|
|
244
|
+
if (config.bindings.services) for (const binding of Object.keys(config.bindings.services)) {
|
|
245
|
+
const serviceInfo = serviceBindingMap.get(binding);
|
|
246
|
+
if (serviceInfo?.interfaceType && serviceInfo.interfaceImport) {
|
|
247
|
+
imports.push(`import type { ${serviceInfo.interfaceType} } from '${serviceInfo.interfaceImport}'`);
|
|
248
|
+
lines.push(`${indent}${binding}: ${serviceInfo.interfaceType}`);
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
lines.push(`${indent}${binding}: Fetcher`);
|
|
252
|
+
}
|
|
253
|
+
if (config.bindings.ai) lines.push(`${indent}${config.bindings.ai.binding}: Ai`);
|
|
254
|
+
if (config.bindings.aiSearchNamespaces) for (const binding of Object.keys(config.bindings.aiSearchNamespaces)) lines.push(`${indent}${binding}: AiSearchNamespace`);
|
|
255
|
+
if (config.bindings.aiSearch) for (const binding of Object.keys(config.bindings.aiSearch)) lines.push(`${indent}${binding}: AiSearchInstance`);
|
|
256
|
+
if (config.bindings.vectorize) for (const binding of Object.keys(config.bindings.vectorize)) lines.push(`${indent}${binding}: VectorizeIndex`);
|
|
257
|
+
if (config.bindings.hyperdrive) for (const binding of Object.keys(config.bindings.hyperdrive)) lines.push(`${indent}${binding}: Hyperdrive`);
|
|
258
|
+
if (config.bindings.browser) for (const binding of Object.keys(config.bindings.browser)) lines.push(`${indent}${binding}: Fetcher`);
|
|
259
|
+
if (config.bindings.analyticsEngine) for (const binding of Object.keys(config.bindings.analyticsEngine)) lines.push(`${indent}${binding}: AnalyticsEngineDataset`);
|
|
260
|
+
if (config.bindings.sendEmail) for (const binding of Object.keys(config.bindings.sendEmail)) lines.push(`${indent}${binding}: SendEmail`);
|
|
261
|
+
}
|
|
262
|
+
if (options.includeVarsAsMembers !== false && config.vars) for (const key of Object.keys(config.vars)) lines.push(`${indent}${key}: string`);
|
|
263
|
+
if (config.secrets) for (const secret of Object.keys(config.secrets)) lines.push(`${indent}${secret}: string`);
|
|
264
|
+
return {
|
|
265
|
+
lines,
|
|
266
|
+
imports
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function normalizeModuleDeclarationGlob(glob) {
|
|
270
|
+
return glob.replace(/\\/g, "/").replace(/^\.\//, "").replace(/^\*\*\//, "");
|
|
271
|
+
}
|
|
272
|
+
function generateModuleRuleDeclarations(config) {
|
|
273
|
+
const declarations = [];
|
|
274
|
+
const seen = /* @__PURE__ */ new Set();
|
|
275
|
+
const typeByRuleType = {
|
|
276
|
+
Text: "string",
|
|
277
|
+
Data: "ArrayBuffer",
|
|
278
|
+
CompiledWasm: "WebAssembly.Module"
|
|
279
|
+
};
|
|
280
|
+
for (const rule of config.rules ?? []) {
|
|
281
|
+
const valueType = rule.type ? typeByRuleType[rule.type] : void 0;
|
|
282
|
+
if (!valueType) continue;
|
|
283
|
+
for (const glob of rule.globs ?? []) {
|
|
284
|
+
const specifier = normalizeModuleDeclarationGlob(glob);
|
|
285
|
+
const key = `${specifier}:${valueType}`;
|
|
286
|
+
if (seen.has(key)) continue;
|
|
287
|
+
seen.add(key);
|
|
288
|
+
declarations.push(`declare module '${specifier}' {`);
|
|
289
|
+
declarations.push(`\tconst value: ${valueType}`);
|
|
290
|
+
declarations.push(" export default value");
|
|
291
|
+
declarations.push("}");
|
|
292
|
+
declarations.push("");
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return declarations;
|
|
296
|
+
}
|
|
297
|
+
function generateBindingTypes(config, discoveredDOs, discoveredEntrypoints, referencedConfigs, cwd, options = {}) {
|
|
298
|
+
const doClassMap = /* @__PURE__ */ new Map();
|
|
299
|
+
for (const doInfo of discoveredDOs) doClassMap.set(doInfo.className, {
|
|
300
|
+
importPath: generateImportPath(cwd, doInfo.filePath),
|
|
301
|
+
className: doInfo.className
|
|
302
|
+
});
|
|
303
|
+
const crossWorkerDOMap = /* @__PURE__ */ new Map();
|
|
304
|
+
for (const ref of referencedConfigs) for (const doInfo of ref.durableObjects) crossWorkerDOMap.set(doInfo.bindingName, doInfo);
|
|
305
|
+
const serviceBindingMap = /* @__PURE__ */ new Map();
|
|
306
|
+
for (const ref of referencedConfigs) for (const serviceBinding of ref.serviceBindings) serviceBindingMap.set(serviceBinding.bindingName, serviceBinding);
|
|
307
|
+
const usedTypes = /* @__PURE__ */ new Set();
|
|
308
|
+
if (config.bindings) {
|
|
309
|
+
if (config.bindings.kv && Object.keys(config.bindings.kv).length > 0) usedTypes.add("KVNamespace");
|
|
310
|
+
if (config.bindings.d1 && Object.keys(config.bindings.d1).length > 0) usedTypes.add("D1Database");
|
|
311
|
+
if (config.bindings.r2 && Object.keys(config.bindings.r2).length > 0) usedTypes.add("R2Bucket");
|
|
312
|
+
if (config.bindings.durableObjects && Object.keys(config.bindings.durableObjects).length > 0) usedTypes.add("DurableObjectNamespace");
|
|
313
|
+
if (config.bindings.queues?.producers && Object.keys(config.bindings.queues.producers).length > 0) usedTypes.add("Queue");
|
|
314
|
+
if (config.bindings.rateLimits && Object.keys(config.bindings.rateLimits).length > 0) usedTypes.add("RateLimit");
|
|
315
|
+
if (config.bindings.versionMetadata?.binding) usedTypes.add("WorkerVersionMetadata");
|
|
316
|
+
if (config.bindings.workerLoaders && Object.keys(config.bindings.workerLoaders).length > 0) usedTypes.add("WorkerLoader");
|
|
317
|
+
if (config.bindings.mtlsCertificates && Object.keys(config.bindings.mtlsCertificates).length > 0) usedTypes.add("Fetcher");
|
|
318
|
+
if (config.bindings.dispatchNamespaces && Object.keys(config.bindings.dispatchNamespaces).length > 0) usedTypes.add("DispatchNamespace");
|
|
319
|
+
if (config.bindings.workflows && Object.keys(config.bindings.workflows).length > 0) usedTypes.add("Workflow");
|
|
320
|
+
if (config.bindings.images && Object.keys(config.bindings.images).length > 0) usedTypes.add("ImagesBinding");
|
|
321
|
+
if (config.bindings.media && Object.keys(config.bindings.media).length > 0) usedTypes.add("MediaBinding");
|
|
322
|
+
if (config.bindings.stream && Object.keys(config.bindings.stream).length > 0) usedTypes.add("StreamBinding");
|
|
323
|
+
if (config.bindings.flagship && Object.keys(config.bindings.flagship).length > 0) usedTypes.add("Flagship");
|
|
324
|
+
if (config.bindings.vpcServices && Object.keys(config.bindings.vpcServices).length > 0) usedTypes.add("Fetcher");
|
|
325
|
+
if (config.bindings.vpcNetworks && Object.keys(config.bindings.vpcNetworks).length > 0) usedTypes.add("Fetcher");
|
|
326
|
+
if (config.bindings.artifacts && Object.keys(config.bindings.artifacts).length > 0) usedTypes.add("Artifacts");
|
|
327
|
+
if (config.bindings.secretsStore && Object.keys(config.bindings.secretsStore).length > 0) usedTypes.add("SecretsStoreSecret");
|
|
328
|
+
if (config.bindings.services) {
|
|
329
|
+
if (Object.keys(config.bindings.services).some((name) => !serviceBindingMap.get(name)?.interfaceType)) usedTypes.add("Fetcher");
|
|
330
|
+
}
|
|
331
|
+
if (config.bindings.ai) usedTypes.add("Ai");
|
|
332
|
+
if (config.bindings.aiSearchNamespaces && Object.keys(config.bindings.aiSearchNamespaces).length > 0) usedTypes.add("AiSearchNamespace");
|
|
333
|
+
if (config.bindings.aiSearch && Object.keys(config.bindings.aiSearch).length > 0) usedTypes.add("AiSearchInstance");
|
|
334
|
+
if (config.bindings.vectorize && Object.keys(config.bindings.vectorize).length > 0) usedTypes.add("VectorizeIndex");
|
|
335
|
+
if (config.bindings.hyperdrive && Object.keys(config.bindings.hyperdrive).length > 0) usedTypes.add("Hyperdrive");
|
|
336
|
+
if (config.bindings.browser && Object.keys(config.bindings.browser).length > 0) usedTypes.add("Fetcher");
|
|
337
|
+
if (config.bindings.analyticsEngine && Object.keys(config.bindings.analyticsEngine).length > 0) usedTypes.add("AnalyticsEngineDataset");
|
|
338
|
+
if (config.bindings.sendEmail && Object.keys(config.bindings.sendEmail).length > 0) usedTypes.add("SendEmail");
|
|
339
|
+
}
|
|
340
|
+
const lines = [
|
|
341
|
+
"// Generated by devflare - DO NOT EDIT",
|
|
342
|
+
"// Run `devflare types` to regenerate",
|
|
343
|
+
""
|
|
344
|
+
];
|
|
345
|
+
const hasConfigVars = Boolean(config.vars && Object.keys(config.vars).length > 0);
|
|
346
|
+
const hasLocalDOsWithClasses = Boolean(config.bindings?.durableObjects && Object.values(config.bindings.durableObjects).some((doConfig) => doConfig.className && doClassMap.has(doConfig.className)));
|
|
347
|
+
const hasCrossWorkerDOs = crossWorkerDOMap.size > 0;
|
|
348
|
+
const hasDOsWithClasses = hasLocalDOsWithClasses || hasCrossWorkerDOs;
|
|
349
|
+
if (usedTypes.size > 0) {
|
|
350
|
+
const sortedTypes = [...usedTypes].sort();
|
|
351
|
+
if (hasDOsWithClasses) lines.push(`import type { ${sortedTypes.join(", ")}, Rpc } from '@cloudflare/workers-types'`);
|
|
352
|
+
else lines.push(`import type { ${sortedTypes.join(", ")} } from '@cloudflare/workers-types'`);
|
|
353
|
+
lines.push("");
|
|
354
|
+
}
|
|
355
|
+
if (hasConfigVars) {
|
|
356
|
+
const configImportPath = options.configImportPath ?? "./devflare.config";
|
|
357
|
+
lines.push("import type { InferConfigVars } from 'devflare/config'");
|
|
358
|
+
lines.push(`type __DevflareConfigVars = InferConfigVars<Awaited<typeof import('${configImportPath}').default>>`);
|
|
359
|
+
lines.push("");
|
|
360
|
+
}
|
|
361
|
+
const { lines: bindingMembers, imports: serviceImports } = generateBindingMembers(config, doClassMap, crossWorkerDOMap, serviceBindingMap, cwd, " ", { includeVarsAsMembers: !hasConfigVars });
|
|
362
|
+
const uniqueImports = [...new Set(serviceImports)];
|
|
363
|
+
if (uniqueImports.length > 0) {
|
|
364
|
+
lines.push(...uniqueImports);
|
|
365
|
+
lines.push("");
|
|
366
|
+
}
|
|
367
|
+
lines.push("declare global {");
|
|
368
|
+
if (hasConfigVars) {
|
|
369
|
+
lines.push(" interface DevflareVars extends __DevflareConfigVars {}");
|
|
370
|
+
lines.push(" interface DevflareEnv extends __DevflareConfigVars {");
|
|
371
|
+
} else lines.push(" interface DevflareEnv {");
|
|
372
|
+
lines.push(...bindingMembers);
|
|
373
|
+
lines.push(" }");
|
|
374
|
+
lines.push("}");
|
|
375
|
+
lines.push("");
|
|
376
|
+
lines.push(...generateModuleRuleDeclarations(config));
|
|
377
|
+
if (discoveredEntrypoints.length > 0) {
|
|
378
|
+
const entrypointNames = discoveredEntrypoints.map((entrypoint) => `'${entrypoint.className}'`).join(" | ");
|
|
379
|
+
lines.push("/**");
|
|
380
|
+
lines.push(" * Named entrypoints discovered from ep.*.ts files.");
|
|
381
|
+
lines.push(" * Use with defineConfig<Entrypoints>() for type-safe cross-worker references.");
|
|
382
|
+
lines.push(" */");
|
|
383
|
+
lines.push(`export type Entrypoints = ${entrypointNames}`);
|
|
384
|
+
} else {
|
|
385
|
+
lines.push("/**");
|
|
386
|
+
lines.push(" * Named entrypoints (none discovered - add ep.*.ts files to enable).");
|
|
387
|
+
lines.push(" * Use with defineConfig<Entrypoints>() for type-safe cross-worker references.");
|
|
388
|
+
lines.push(" */");
|
|
389
|
+
lines.push("export type Entrypoints = string");
|
|
390
|
+
}
|
|
391
|
+
lines.push("");
|
|
392
|
+
return lines.join("\n");
|
|
393
|
+
}
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region src/cli/commands/types.ts
|
|
396
|
+
function logTypesLine(logger, message = "") {
|
|
397
|
+
if (typeof logger.log === "function") {
|
|
398
|
+
logger.log(message);
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
if (typeof logger.info === "function") logger.info(message);
|
|
402
|
+
}
|
|
403
|
+
async function runTypesCommand(parsed, logger, options) {
|
|
404
|
+
const cwd = options.cwd || process.cwd();
|
|
405
|
+
const configPath = parsed.options.config;
|
|
406
|
+
const outputPath = parsed.options.output || "env.d.ts";
|
|
407
|
+
const theme = createCliTheme(parsed.options);
|
|
408
|
+
logTypesLine(logger);
|
|
409
|
+
logTypesLine(logger, `${bold("types", theme)} ${dim("Generating TypeScript bindings", theme)}`);
|
|
410
|
+
try {
|
|
411
|
+
const config = await loadConfig({
|
|
412
|
+
cwd,
|
|
413
|
+
configFile: configPath
|
|
414
|
+
});
|
|
415
|
+
const actualConfigPath = await resolveConfigCandidatePath(configPath ? resolve(cwd, configPath) : cwd);
|
|
416
|
+
if (!actualConfigPath) throw new Error("Could not resolve the loaded devflare config file path");
|
|
417
|
+
const doPattern = typeof config.files?.durableObjects === "string" ? config.files.durableObjects : DEFAULT_DO_PATTERN;
|
|
418
|
+
let discoveredDOs = [];
|
|
419
|
+
if (config.files?.durableObjects !== false) {
|
|
420
|
+
discoveredDOs = await discoverDurableObjects(cwd, doPattern);
|
|
421
|
+
if (discoveredDOs.length > 0) {
|
|
422
|
+
logTypesLine(logger, `Discovered ${discoveredDOs.length} Durable Object class(es):`);
|
|
423
|
+
for (const doInfo of discoveredDOs) logTypesLine(logger, ` • ${doInfo.className} → ${doInfo.bindingName}`);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
if (config.bindings?.durableObjects) for (const [bindingName, doConfig] of Object.entries(config.bindings.durableObjects)) {
|
|
427
|
+
const normalized = normalizeDOBinding(doConfig);
|
|
428
|
+
const className = normalized.className;
|
|
429
|
+
if (!className) continue;
|
|
430
|
+
if (discoveredDOs.find((doInfo) => doInfo.className === className)) continue;
|
|
431
|
+
if (normalized.scriptName && (normalized.scriptName.endsWith(".ts") || normalized.scriptName.endsWith(".js"))) {
|
|
432
|
+
const filePath = resolve(cwd, "src", normalized.scriptName);
|
|
433
|
+
discoveredDOs.push({
|
|
434
|
+
className,
|
|
435
|
+
filePath,
|
|
436
|
+
bindingName
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
const entrypointPattern = typeof config.files?.entrypoints === "string" ? config.files.entrypoints : DEFAULT_ENTRYPOINT_PATTERN;
|
|
441
|
+
let discoveredEntrypoints = [];
|
|
442
|
+
if (config.files?.entrypoints !== false) {
|
|
443
|
+
discoveredEntrypoints = await discoverEntrypointsAsync(cwd, entrypointPattern);
|
|
444
|
+
if (discoveredEntrypoints.length > 0) {
|
|
445
|
+
logTypesLine(logger, `Discovered ${discoveredEntrypoints.length} entrypoint class(es):`);
|
|
446
|
+
for (const entrypoint of discoveredEntrypoints) logTypesLine(logger, ` • ${entrypoint.className}`);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
const referencedConfigs = await resolveReferencedConfigs(actualConfigPath, cwd);
|
|
450
|
+
if (referencedConfigs.length > 0) {
|
|
451
|
+
logTypesLine(logger, `Found ${referencedConfigs.length} referenced worker(s):`);
|
|
452
|
+
for (const ref of referencedConfigs) {
|
|
453
|
+
const typedBindings = ref.serviceBindings.filter((serviceBinding) => serviceBinding.interfaceType);
|
|
454
|
+
if (typedBindings.length > 0) logTypesLine(logger, ` • ${ref.varName}: ${typedBindings.map((serviceBinding) => `${serviceBinding.bindingName} → ${serviceBinding.interfaceType}`).join(", ")}`);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
const types = generateBindingTypes({
|
|
458
|
+
...config,
|
|
459
|
+
bindings: config.bindings ? {
|
|
460
|
+
...config.bindings,
|
|
461
|
+
durableObjects: config.bindings.durableObjects ? Object.fromEntries(Object.entries(config.bindings.durableObjects).map(([name, doConfig]) => {
|
|
462
|
+
const normalized = normalizeDOBinding(doConfig);
|
|
463
|
+
return [name, {
|
|
464
|
+
className: normalized.className,
|
|
465
|
+
scriptName: normalized.scriptName
|
|
466
|
+
}];
|
|
467
|
+
})) : void 0
|
|
468
|
+
} : void 0
|
|
469
|
+
}, discoveredDOs, discoveredEntrypoints, referencedConfigs, cwd, { configImportPath: generateImportPath(cwd, actualConfigPath) });
|
|
470
|
+
const { fs } = await getDependencies();
|
|
471
|
+
const fullPath = resolve(cwd, outputPath);
|
|
472
|
+
await fs.writeFile(fullPath, types, "utf-8");
|
|
473
|
+
logger.success(`Generated types: ${outputPath}`);
|
|
474
|
+
return { exitCode: 0 };
|
|
475
|
+
} catch (error) {
|
|
476
|
+
if (error instanceof Error) {
|
|
477
|
+
logger.error("Type generation failed:", error.message);
|
|
478
|
+
if (parsed.options.debug) logger.error(error.stack);
|
|
479
|
+
}
|
|
480
|
+
return { exitCode: 1 };
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
//#endregion
|
|
484
|
+
export { runTypesCommand };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { a as DIM, c as RESET, i as CYAN_BOLD, l as WHITE, n as BOLD, o as GREEN, r as CYAN, s as RED, u as YELLOW } from "./colors-D0NVzAFN.js";
|
|
2
|
+
//#region src/cli/ui.ts
|
|
3
|
+
const ANSI_REGEX = /\x1b\[[0-9;]*m/g;
|
|
4
|
+
function createCliTheme(options = {}) {
|
|
5
|
+
if (options["no-color"] === true) return { useColor: false };
|
|
6
|
+
if (process.env.NO_COLOR?.trim()) return { useColor: false };
|
|
7
|
+
if (process.env.TERM === "dumb") return { useColor: false };
|
|
8
|
+
return { useColor: process.stdout?.isTTY === true };
|
|
9
|
+
}
|
|
10
|
+
function paint(value, code, theme) {
|
|
11
|
+
return theme.useColor ? `${code}${value}${RESET}` : value;
|
|
12
|
+
}
|
|
13
|
+
function dim(value, theme) {
|
|
14
|
+
return paint(value, DIM, theme);
|
|
15
|
+
}
|
|
16
|
+
function bold(value, theme) {
|
|
17
|
+
return paint(value, BOLD, theme);
|
|
18
|
+
}
|
|
19
|
+
function cyan(value, theme) {
|
|
20
|
+
return paint(value, CYAN, theme);
|
|
21
|
+
}
|
|
22
|
+
function cyanBold(value, theme) {
|
|
23
|
+
return paint(value, CYAN_BOLD, theme);
|
|
24
|
+
}
|
|
25
|
+
function green(value, theme) {
|
|
26
|
+
return paint(value, GREEN, theme);
|
|
27
|
+
}
|
|
28
|
+
function yellow(value, theme) {
|
|
29
|
+
return paint(value, YELLOW, theme);
|
|
30
|
+
}
|
|
31
|
+
function yellowBold(value, theme) {
|
|
32
|
+
return paint(value, `${BOLD}${YELLOW}`, theme);
|
|
33
|
+
}
|
|
34
|
+
function red(value, theme) {
|
|
35
|
+
return paint(value, RED, theme);
|
|
36
|
+
}
|
|
37
|
+
function whiteDim(value, theme) {
|
|
38
|
+
return paint(value, `${DIM}${WHITE}`, theme);
|
|
39
|
+
}
|
|
40
|
+
function accent(value, theme, kind = "cyan") {
|
|
41
|
+
switch (kind) {
|
|
42
|
+
case "yellow": return yellowBold(value, theme);
|
|
43
|
+
case "green": return green(value, theme);
|
|
44
|
+
case "red": return red(value, theme);
|
|
45
|
+
case "dim": return dim(value, theme);
|
|
46
|
+
case "bold": return bold(value, theme);
|
|
47
|
+
case "white-dim": return whiteDim(value, theme);
|
|
48
|
+
default: return cyanBold(value, theme);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function logLine(logger, message = "") {
|
|
52
|
+
logger.log(message);
|
|
53
|
+
}
|
|
54
|
+
function stripAnsi(value) {
|
|
55
|
+
return value.replace(ANSI_REGEX, "");
|
|
56
|
+
}
|
|
57
|
+
function truncateCell(value, width) {
|
|
58
|
+
if (value.length <= width) return value;
|
|
59
|
+
if (width <= 1) return "…";
|
|
60
|
+
return `${value.slice(0, width - 1)}…`;
|
|
61
|
+
}
|
|
62
|
+
function truncateStyledCell(value, width) {
|
|
63
|
+
const plainValue = stripAnsi(value);
|
|
64
|
+
if (plainValue.length <= width) return value;
|
|
65
|
+
const truncatedPlainValue = truncateCell(plainValue, width);
|
|
66
|
+
const prefixMatch = value.match(/^((?:\x1b\[[0-9;]*m)+)/);
|
|
67
|
+
const suffixMatch = value.match(/((?:\x1b\[[0-9;]*m)+)$/);
|
|
68
|
+
const prefix = prefixMatch?.[1] ?? "";
|
|
69
|
+
return `${prefix}${truncatedPlainValue}${prefix ? RESET : suffixMatch?.[1] ?? ""}`;
|
|
70
|
+
}
|
|
71
|
+
function padStyledCell(value, width) {
|
|
72
|
+
const truncatedValue = truncateStyledCell(value, width);
|
|
73
|
+
const visibleLength = stripAnsi(truncatedValue).length;
|
|
74
|
+
return `${truncatedValue}${" ".repeat(Math.max(width - visibleLength, 0))}`;
|
|
75
|
+
}
|
|
76
|
+
function formatTableLine(values, widths) {
|
|
77
|
+
return values.map((value, index) => {
|
|
78
|
+
const width = widths[index];
|
|
79
|
+
if (width === void 0 || index === values.length - 1) return value;
|
|
80
|
+
return padStyledCell(value, width);
|
|
81
|
+
}).join(" ");
|
|
82
|
+
}
|
|
83
|
+
function renderTable(rows, columns, theme) {
|
|
84
|
+
if (rows.length === 0) return [];
|
|
85
|
+
const widths = columns.map((column) => column.width);
|
|
86
|
+
return [formatTableLine(columns.map((column) => dim(column.label, theme)), widths), ...rows.map((row) => formatTableLine(columns.map((column) => column.value(row)), widths))];
|
|
87
|
+
}
|
|
88
|
+
function logTable(logger, options) {
|
|
89
|
+
if (options.rows.length === 0) return;
|
|
90
|
+
logLine(logger, `${accent(options.title, options.theme, options.titleAccent)} ${dim(`(${options.rows.length})`, options.theme)}`);
|
|
91
|
+
for (const line of renderTable(options.rows, options.columns, options.theme)) logLine(logger, line);
|
|
92
|
+
}
|
|
93
|
+
function formatLabelValue(label, value, theme, labelWidth = 12) {
|
|
94
|
+
return `${dim(label.padEnd(labelWidth), theme)} ${value}`;
|
|
95
|
+
}
|
|
96
|
+
function formatCommand(command, description, theme) {
|
|
97
|
+
return ` ${cyan(command, theme)}${dim(" — ", theme)}${description}`;
|
|
98
|
+
}
|
|
99
|
+
function formatBullet(text, theme, bullet = "•") {
|
|
100
|
+
return ` ${dim(bullet, theme)} ${text}`;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { yellowBold as _, cyanBold as a, formatCommand as c, green as d, logLine as f, yellow as g, whiteDim as h, cyan as i, formatLabelValue as l, red as m, bold as n, dim as o, logTable as p, createCliTheme as r, formatBullet as s, accent as t, formatTableLine as u };
|