devflare 1.0.0-next.3 → 1.0.0-next.31
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/LLM.md +15964 -1751
- package/README.md +392 -605
- package/bin/devflare.js +24 -14
- package/dist/account-g99mzrqp.js +475 -0
- package/dist/api-2n6dd2ws.js +33 -0
- package/dist/bridge/client.d.ts +48 -6
- 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 +3 -3
- 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 +74 -1
- package/dist/bridge/miniflare.d.ts.map +1 -1
- package/dist/bridge/proxy.d.ts +11 -10
- 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 +51 -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} +28 -4
- 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 +1 -1
- package/dist/browser-shim/handler.d.ts.map +1 -1
- package/dist/browser-shim/server.d.ts +63 -0
- package/dist/browser-shim/server.d.ts.map +1 -1
- package/dist/browser.d.ts +4621 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +147 -0
- package/dist/build-4tyjywn9.js +54 -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 +2 -0
- 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 +1 -1
- package/dist/cli/commands/account.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.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 +8 -0
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- 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/secrets.d.ts +4 -0
- package/dist/cli/commands/secrets.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 +112 -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.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 +1 -0
- 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/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 +12 -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/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.map +1 -1
- package/dist/cloudflare/index.d.ts +57 -2
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +49 -2
- 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/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 +30 -2
- 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 +270 -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/define.d.ts +7 -4
- 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 +1 -0
- 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 +31 -0
- package/dist/config/preview.d.ts.map +1 -0
- package/dist/config/ref.d.ts +14 -23
- 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 +1495 -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 +3023 -0
- package/dist/config/schema-env.d.ts.map +1 -0
- package/dist/config/schema-normalization.d.ts +184 -0
- package/dist/config/schema-normalization.d.ts.map +1 -0
- package/dist/config/schema-runtime.d.ts +500 -0
- package/dist/config/schema-runtime.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-platform.d.ts +378 -0
- package/dist/config/schema-types-bindings-platform.d.ts.map +1 -0
- package/dist/config/schema-types-bindings-resources.d.ts +551 -0
- package/dist/config/schema-types-bindings-resources.d.ts.map +1 -0
- package/dist/config/schema-types-bindings.d.ts +254 -0
- package/dist/config/schema-types-bindings.d.ts.map +1 -0
- package/dist/config/schema-types-build.d.ts +86 -0
- package/dist/config/schema-types-build.d.ts.map +1 -0
- package/dist/config/schema-types-runtime.d.ts +917 -0
- package/dist/config/schema-types-runtime.d.ts.map +1 -0
- package/dist/config/schema-types.d.ts +424 -0
- package/dist/config/schema-types.d.ts.map +1 -0
- package/dist/config/schema.d.ts +4537 -2214
- 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-88sdhx3w.js +105 -0
- package/dist/config-entry.d.ts +7 -0
- package/dist/config-entry.d.ts.map +1 -0
- package/dist/config-entry.js +16 -0
- package/dist/decorators/durable-object.d.ts.map +1 -1
- package/dist/deploy-8fpav2cw.js +1066 -0
- package/dist/dev-nxevkfdv.js +2609 -0
- 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/miniflare-bindings.d.ts +59 -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 +74 -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/{doctor-fmgb3d28.js → doctor-ztwx1y95.js} +104 -35
- package/dist/{durable-object-t4kbb0yt.js → durable-object-v3gsnybk.js} +1 -1
- package/dist/env.d.ts +10 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/index-11p28kxx.js +256 -0
- package/dist/index-15fpa5tx.js +232 -0
- package/dist/index-1d4jg11n.js +542 -0
- package/dist/index-3edvz3hs.js +124 -0
- package/dist/index-3jme4hgw.js +1234 -0
- package/dist/index-627srx16.js +45 -0
- package/dist/index-62b3gt2g.js +12 -0
- package/dist/index-67gr49zr.js +109 -0
- package/dist/index-69c0ed4a.js +895 -0
- package/dist/index-6sj0v0dk.js +2284 -0
- package/dist/index-7qd7nmdd.js +74 -0
- package/dist/index-85yjb686.js +413 -0
- package/dist/index-aabgympv.js +39 -0
- package/dist/{index-z14anrqp.js → index-aqrwyy57.js} +93 -31
- package/dist/index-c8p4njqy.js +479 -0
- package/dist/index-dfcp9hsd.js +1581 -0
- package/dist/index-dm9q84c7.js +360 -0
- package/dist/index-fcmj6641.js +147 -0
- package/dist/index-ft3trvra.js +476 -0
- package/dist/{index-18hvb6gb.js → index-gn5wy09x.js} +13 -2
- package/dist/index-hjjfxv02.js +708 -0
- package/dist/index-hpwa6vsw.js +239 -0
- package/dist/index-k9x5v335.js +1033 -0
- package/dist/index-mg8vwqxf.js +514 -0
- package/dist/index-ptwem1nt.js +1428 -0
- package/dist/{index-07q6yxyc.js → index-q8f4kawk.js} +68 -32
- package/dist/index-qmmqww7h.js +133 -0
- package/dist/{index-rbht7m9r.js → index-qwgr4q7s.js} +2 -1
- package/dist/index-qz6nbwpw.js +111 -0
- package/dist/index-rzp9ejrh.js +185 -0
- package/dist/index-s3km3y34.js +1205 -0
- package/dist/index-stgn34cr.js +148 -0
- package/dist/index-t9y0sve5.js +155 -0
- package/dist/index-vez803pp.js +52 -0
- package/dist/index-vhqww6tt.js +307 -0
- package/dist/index-xz18tstn.js +581 -0
- package/dist/{index-1xpj0m4r.js → index-z9gy8w6b.js} +1 -1
- package/dist/index-za0r01bx.js +588 -0
- package/dist/index.d.ts +3 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -269
- package/dist/{init-f9mgmew3.js → init-cwpergap.js} +63 -69
- package/dist/login-r5ve73kf.js +77 -0
- package/dist/previews-qjj98rpp.js +1337 -0
- package/dist/productions-gzdtge0e.js +505 -0
- 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 +8 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +108 -99
- package/dist/runtime/middleware.d.ts +102 -60
- 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 +17 -3
- 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/secrets-4w5166km.js +91 -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.js +169 -75
- 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 +19 -1
- 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/binding-hints.d.ts +11 -0
- package/dist/test/binding-hints.d.ts.map +1 -0
- package/dist/test/cf.d.ts +35 -21
- 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 +5 -8
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +4641 -43
- package/dist/test/offline-bindings.d.ts +65 -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 +63 -3
- 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 +7 -26
- package/dist/test/simple-context.d.ts.map +1 -1
- package/dist/test/tail.d.ts +2 -1
- package/dist/test/tail.d.ts.map +1 -1
- 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 +40 -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/workflows.d.ts +26 -0
- package/dist/test/utilities/workflows.d.ts.map +1 -0
- package/dist/test/utilities.d.ts +10 -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/token-35jcdqq8.js +419 -0
- package/dist/transform/durable-object.d.ts.map +1 -1
- package/dist/transform/worker-entrypoint.d.ts +5 -0
- package/dist/transform/worker-entrypoint.d.ts.map +1 -1
- package/dist/types-6vc02evc.js +705 -0
- package/dist/utils/entrypoint-discovery.d.ts +6 -3
- package/dist/utils/entrypoint-discovery.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 +19 -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 +1 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +25 -331
- 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-entrypoint-m9th0rg0.js → worker-entrypoint-3rmzd4c1.js} +3 -1
- package/dist/worker-f2v85f7d.js +513 -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 +154 -115
- package/dist/account-rvrj687w.js +0 -397
- 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-pa8dhm20.js +0 -2162
- package/dist/index-67qcae0f.js +0 -183
- 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-tfyxa77h.js +0 -850
- package/dist/index-tk6ej9dj.js +0 -94
- 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
|
@@ -0,0 +1,705 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveConfigCandidatePath
|
|
3
|
+
} from "./index-vez803pp.js";
|
|
4
|
+
import {
|
|
5
|
+
getDependencies
|
|
6
|
+
} from "./index-z9gy8w6b.js";
|
|
7
|
+
import {
|
|
8
|
+
bold,
|
|
9
|
+
createCliTheme,
|
|
10
|
+
dim
|
|
11
|
+
} from "./index-stgn34cr.js";
|
|
12
|
+
import"./index-3t6rypgc.js";
|
|
13
|
+
import {
|
|
14
|
+
discoverEntrypointsAsync,
|
|
15
|
+
resolvePackageSpecifier
|
|
16
|
+
} from "./index-3edvz3hs.js";
|
|
17
|
+
import {
|
|
18
|
+
DEFAULT_DO_PATTERN,
|
|
19
|
+
DEFAULT_ENTRYPOINT_PATTERN,
|
|
20
|
+
findFiles
|
|
21
|
+
} from "./index-qwgr4q7s.js";
|
|
22
|
+
import {
|
|
23
|
+
findDurableObjectClasses
|
|
24
|
+
} from "./index-vhqww6tt.js";
|
|
25
|
+
import"./index-hjjfxv02.js";
|
|
26
|
+
import {
|
|
27
|
+
loadConfig,
|
|
28
|
+
normalizeDOBinding
|
|
29
|
+
} from "./index-dfcp9hsd.js";
|
|
30
|
+
import"./index-1d4jg11n.js";
|
|
31
|
+
import"./index-mg8vwqxf.js";
|
|
32
|
+
import"./index-c8p4njqy.js";
|
|
33
|
+
import"./index-q8f4kawk.js";
|
|
34
|
+
import"./index-37x76zdn.js";
|
|
35
|
+
|
|
36
|
+
// src/cli/commands/types.ts
|
|
37
|
+
import { resolve } from "pathe";
|
|
38
|
+
|
|
39
|
+
// src/cli/commands/type-generation/discovery.ts
|
|
40
|
+
import { readFile } from "node:fs/promises";
|
|
41
|
+
import { dirname, relative } from "pathe";
|
|
42
|
+
var DEFAULT_INTERFACE_LOOKUP_KEYS = new Set(["Worker", "Default", "MathService"]);
|
|
43
|
+
var interfaceTypeCache = new Map;
|
|
44
|
+
async function readFileIfAvailable(filePath) {
|
|
45
|
+
try {
|
|
46
|
+
return await readFile(filePath, "utf-8");
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function getInterfaceSearchKey(searchDirs) {
|
|
52
|
+
return [...new Set(searchDirs)].sort((left, right) => left.localeCompare(right)).join("\x00");
|
|
53
|
+
}
|
|
54
|
+
function getPatternMatches(pattern, code) {
|
|
55
|
+
const matches = [];
|
|
56
|
+
pattern.lastIndex = 0;
|
|
57
|
+
let nextMatch = pattern.exec(code);
|
|
58
|
+
while (nextMatch !== null) {
|
|
59
|
+
matches.push(nextMatch);
|
|
60
|
+
nextMatch = pattern.exec(code);
|
|
61
|
+
}
|
|
62
|
+
return matches;
|
|
63
|
+
}
|
|
64
|
+
function getInterfaceBaseName(interfaceName) {
|
|
65
|
+
if (interfaceName.endsWith("Interface")) {
|
|
66
|
+
return interfaceName.slice(0, -9);
|
|
67
|
+
}
|
|
68
|
+
if (interfaceName.endsWith("Rpc")) {
|
|
69
|
+
return interfaceName.slice(0, -3);
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
function registerInterfaceType(interfaces, baseName, interfaceInfo) {
|
|
74
|
+
if (!interfaces.has(baseName)) {
|
|
75
|
+
interfaces.set(baseName, interfaceInfo);
|
|
76
|
+
}
|
|
77
|
+
if (!interfaces.has("__default__") && DEFAULT_INTERFACE_LOOKUP_KEYS.has(baseName)) {
|
|
78
|
+
interfaces.set("__default__", interfaceInfo);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function collectInterfaceTypesFromFile(interfaces, filePath) {
|
|
82
|
+
const code = await readFileIfAvailable(filePath);
|
|
83
|
+
if (!code) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const interfacePattern = /export\s+interface\s+(\w+(?:Interface|Rpc))\s*\{/g;
|
|
87
|
+
for (const match of getPatternMatches(interfacePattern, code)) {
|
|
88
|
+
const interfaceName = match[1];
|
|
89
|
+
const baseName = getInterfaceBaseName(interfaceName);
|
|
90
|
+
if (!baseName) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
registerInterfaceType(interfaces, baseName, {
|
|
94
|
+
filePath,
|
|
95
|
+
interfaceName
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async function parseConfigForRefs(configPath) {
|
|
100
|
+
const refs = [];
|
|
101
|
+
const serviceBindings = [];
|
|
102
|
+
const doBindings = [];
|
|
103
|
+
const code = await readFileIfAvailable(configPath);
|
|
104
|
+
if (!code) {
|
|
105
|
+
return {
|
|
106
|
+
refs,
|
|
107
|
+
serviceBindings,
|
|
108
|
+
doBindings
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
const refPattern = /const\s+(\w+)\s*=\s*ref\s*\(\s*(?:'[^']*'\s*,\s*)?(?:\(\s*\)\s*=>\s*)?import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
112
|
+
for (const match of getPatternMatches(refPattern, code)) {
|
|
113
|
+
refs.push({
|
|
114
|
+
varName: match[1],
|
|
115
|
+
importPath: match[2]
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
const servicePattern = /(\w+)\s*:\s*(\w+)\.worker(?:\s*\(\s*['"](\w+)['"]\s*\))?/g;
|
|
119
|
+
for (const match of getPatternMatches(servicePattern, code)) {
|
|
120
|
+
serviceBindings.push({
|
|
121
|
+
bindingName: match[1],
|
|
122
|
+
varName: match[2],
|
|
123
|
+
entrypoint: match[3]
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
const doPattern = /(\w+)\s*:\s*(\w+)\.([A-Z][A-Z0-9_]*)\s*[,\n\r}]/g;
|
|
127
|
+
for (const match of getPatternMatches(doPattern, code)) {
|
|
128
|
+
if (match[3] === "worker") {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
doBindings.push({
|
|
132
|
+
bindingName: match[1],
|
|
133
|
+
varName: match[2],
|
|
134
|
+
doName: match[3]
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
refs,
|
|
139
|
+
serviceBindings,
|
|
140
|
+
doBindings
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
async function findInterfaceTypes(searchDirs) {
|
|
144
|
+
const interfaces = new Map;
|
|
145
|
+
for (const dir of [...new Set(searchDirs)]) {
|
|
146
|
+
const typeFiles = await findFiles("**/*.types.ts", { cwd: dir });
|
|
147
|
+
const srcFiles = await findFiles("src/**/*.ts", { cwd: dir });
|
|
148
|
+
const allFiles = [...new Set([...typeFiles, ...srcFiles])];
|
|
149
|
+
for (const filePath of allFiles) {
|
|
150
|
+
await collectInterfaceTypesFromFile(interfaces, filePath);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return interfaces;
|
|
154
|
+
}
|
|
155
|
+
async function getCachedInterfaceTypes(searchDirs) {
|
|
156
|
+
const cacheKey = getInterfaceSearchKey(searchDirs);
|
|
157
|
+
const cached = interfaceTypeCache.get(cacheKey);
|
|
158
|
+
if (cached) {
|
|
159
|
+
return cached;
|
|
160
|
+
}
|
|
161
|
+
const pending = findInterfaceTypes(searchDirs);
|
|
162
|
+
interfaceTypeCache.set(cacheKey, pending);
|
|
163
|
+
try {
|
|
164
|
+
return await pending;
|
|
165
|
+
} catch (error) {
|
|
166
|
+
interfaceTypeCache.delete(cacheKey);
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
async function discoverDurableObjects(cwd, pattern = DEFAULT_DO_PATTERN) {
|
|
171
|
+
const discovered = [];
|
|
172
|
+
const files = await findFiles(pattern, { cwd });
|
|
173
|
+
for (const filePath of files) {
|
|
174
|
+
const code = await readFileIfAvailable(filePath);
|
|
175
|
+
if (!code) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
const classNames = findDurableObjectClasses(code);
|
|
179
|
+
for (const className of classNames) {
|
|
180
|
+
const bindingName = className.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").toUpperCase();
|
|
181
|
+
discovered.push({
|
|
182
|
+
className,
|
|
183
|
+
filePath,
|
|
184
|
+
bindingName
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return discovered;
|
|
189
|
+
}
|
|
190
|
+
function generateImportPath(cwd, filePath) {
|
|
191
|
+
let relativePath = relative(cwd, filePath);
|
|
192
|
+
relativePath = relativePath.replace(/\.(ts|tsx|js|jsx)$/, "");
|
|
193
|
+
if (!relativePath.startsWith(".") && !relativePath.startsWith("/")) {
|
|
194
|
+
relativePath = `./${relativePath}`;
|
|
195
|
+
}
|
|
196
|
+
return relativePath;
|
|
197
|
+
}
|
|
198
|
+
async function resolveReferencedConfigs(configPath, cwd) {
|
|
199
|
+
const referenced = [];
|
|
200
|
+
const { refs, serviceBindings, doBindings } = await parseConfigForRefs(configPath);
|
|
201
|
+
if (refs.length === 0) {
|
|
202
|
+
return referenced;
|
|
203
|
+
}
|
|
204
|
+
const configDir = dirname(configPath);
|
|
205
|
+
const referencedConfigDetailsByPath = new Map;
|
|
206
|
+
for (const ref of refs) {
|
|
207
|
+
const refImportPath = resolvePackageSpecifier(ref.importPath, configDir);
|
|
208
|
+
const refConfigPath = await resolveConfigCandidatePath(refImportPath);
|
|
209
|
+
if (!refConfigPath) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
try {
|
|
213
|
+
let referencedConfigDetails = referencedConfigDetailsByPath.get(refConfigPath);
|
|
214
|
+
if (!referencedConfigDetails) {
|
|
215
|
+
referencedConfigDetails = (async () => {
|
|
216
|
+
const refDir2 = dirname(refConfigPath);
|
|
217
|
+
return {
|
|
218
|
+
refDir: refDir2,
|
|
219
|
+
entrypoints: await discoverEntrypointsAsync(refDir2, DEFAULT_ENTRYPOINT_PATTERN),
|
|
220
|
+
refDOs: await discoverDurableObjects(refDir2, DEFAULT_DO_PATTERN),
|
|
221
|
+
interfaceMap: await getCachedInterfaceTypes([configDir, refDir2])
|
|
222
|
+
};
|
|
223
|
+
})();
|
|
224
|
+
referencedConfigDetailsByPath.set(refConfigPath, referencedConfigDetails);
|
|
225
|
+
}
|
|
226
|
+
const {
|
|
227
|
+
refDir,
|
|
228
|
+
entrypoints,
|
|
229
|
+
refDOs,
|
|
230
|
+
interfaceMap
|
|
231
|
+
} = await referencedConfigDetails;
|
|
232
|
+
const bindings = serviceBindings.filter((serviceBinding) => serviceBinding.varName === ref.varName).map((serviceBinding) => {
|
|
233
|
+
const info = {
|
|
234
|
+
bindingName: serviceBinding.bindingName,
|
|
235
|
+
entrypoint: serviceBinding.entrypoint
|
|
236
|
+
};
|
|
237
|
+
const lookupKey = serviceBinding.entrypoint || "__default__";
|
|
238
|
+
const interfaceInfo = interfaceMap.get(lookupKey) || (serviceBinding.entrypoint ? interfaceMap.get(serviceBinding.entrypoint) : undefined);
|
|
239
|
+
if (interfaceInfo) {
|
|
240
|
+
info.interfaceImport = generateImportPath(cwd, interfaceInfo.filePath);
|
|
241
|
+
info.interfaceType = interfaceInfo.interfaceName;
|
|
242
|
+
}
|
|
243
|
+
return info;
|
|
244
|
+
});
|
|
245
|
+
const crossWorkerDOs = doBindings.filter((doBinding) => doBinding.varName === ref.varName).map((doBinding) => {
|
|
246
|
+
const matchingDO = refDOs.find((doInfo) => doInfo.bindingName === doBinding.doName);
|
|
247
|
+
if (!matchingDO) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
const crossWorkerDO = {
|
|
251
|
+
bindingName: doBinding.bindingName,
|
|
252
|
+
doName: doBinding.doName,
|
|
253
|
+
className: matchingDO.className,
|
|
254
|
+
filePath: matchingDO.filePath
|
|
255
|
+
};
|
|
256
|
+
return crossWorkerDO;
|
|
257
|
+
}).filter((item) => item !== null);
|
|
258
|
+
referenced.push({
|
|
259
|
+
varName: ref.varName,
|
|
260
|
+
importPath: ref.importPath,
|
|
261
|
+
refDir,
|
|
262
|
+
entrypoints,
|
|
263
|
+
serviceBindings: bindings,
|
|
264
|
+
durableObjects: crossWorkerDOs
|
|
265
|
+
});
|
|
266
|
+
} catch {}
|
|
267
|
+
}
|
|
268
|
+
return referenced;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// src/cli/commands/type-generation/generator.ts
|
|
272
|
+
function generateBindingMembers(config, doClassMap, crossWorkerDOMap, serviceBindingMap, cwd, indent, options = {}) {
|
|
273
|
+
const lines = [];
|
|
274
|
+
const imports = [];
|
|
275
|
+
if (config.bindings) {
|
|
276
|
+
if (config.bindings.kv) {
|
|
277
|
+
for (const binding of Object.keys(config.bindings.kv)) {
|
|
278
|
+
lines.push(`${indent}${binding}: KVNamespace`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (config.bindings.d1) {
|
|
282
|
+
for (const binding of Object.keys(config.bindings.d1)) {
|
|
283
|
+
lines.push(`${indent}${binding}: D1Database`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (config.bindings.r2) {
|
|
287
|
+
for (const binding of Object.keys(config.bindings.r2)) {
|
|
288
|
+
lines.push(`${indent}${binding}: R2Bucket`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (config.bindings.durableObjects) {
|
|
292
|
+
for (const [binding, doConfig] of Object.entries(config.bindings.durableObjects)) {
|
|
293
|
+
const crossWorkerDO = crossWorkerDOMap.get(binding);
|
|
294
|
+
if (crossWorkerDO) {
|
|
295
|
+
const importPath = generateImportPath(cwd, crossWorkerDO.filePath);
|
|
296
|
+
lines.push(`${indent}${binding}: DurableObjectNamespace<Rpc.DurableObjectBranded & import('${importPath}').${crossWorkerDO.className}>`);
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
const className = doConfig.className;
|
|
300
|
+
if (className) {
|
|
301
|
+
const classInfo = doClassMap.get(className);
|
|
302
|
+
if (classInfo) {
|
|
303
|
+
lines.push(`${indent}${binding}: DurableObjectNamespace<Rpc.DurableObjectBranded & import('${classInfo.importPath}').${classInfo.className}>`);
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
lines.push(`${indent}${binding}: DurableObjectNamespace`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (config.bindings.queues?.producers) {
|
|
311
|
+
for (const binding of Object.keys(config.bindings.queues.producers)) {
|
|
312
|
+
lines.push(`${indent}${binding}: Queue`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (config.bindings.rateLimits) {
|
|
316
|
+
for (const binding of Object.keys(config.bindings.rateLimits)) {
|
|
317
|
+
lines.push(`${indent}${binding}: RateLimit`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (config.bindings.versionMetadata?.binding) {
|
|
321
|
+
lines.push(`${indent}${config.bindings.versionMetadata.binding}: WorkerVersionMetadata`);
|
|
322
|
+
}
|
|
323
|
+
if (config.bindings.workerLoaders) {
|
|
324
|
+
for (const binding of Object.keys(config.bindings.workerLoaders)) {
|
|
325
|
+
lines.push(`${indent}${binding}: WorkerLoader`);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (config.bindings.mtlsCertificates) {
|
|
329
|
+
for (const binding of Object.keys(config.bindings.mtlsCertificates)) {
|
|
330
|
+
lines.push(`${indent}${binding}: Fetcher`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (config.bindings.dispatchNamespaces) {
|
|
334
|
+
for (const binding of Object.keys(config.bindings.dispatchNamespaces)) {
|
|
335
|
+
lines.push(`${indent}${binding}: DispatchNamespace`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (config.bindings.workflows) {
|
|
339
|
+
for (const binding of Object.keys(config.bindings.workflows)) {
|
|
340
|
+
lines.push(`${indent}${binding}: Workflow`);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (config.bindings.pipelines) {
|
|
344
|
+
imports.push("import type { Pipeline } from 'cloudflare:pipelines'");
|
|
345
|
+
for (const binding of Object.keys(config.bindings.pipelines)) {
|
|
346
|
+
lines.push(`${indent}${binding}: Pipeline`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (config.bindings.images) {
|
|
350
|
+
for (const binding of Object.keys(config.bindings.images)) {
|
|
351
|
+
lines.push(`${indent}${binding}: ImagesBinding`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
if (config.bindings.media) {
|
|
355
|
+
for (const binding of Object.keys(config.bindings.media)) {
|
|
356
|
+
lines.push(`${indent}${binding}: MediaBinding`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
if (config.bindings.artifacts) {
|
|
360
|
+
for (const binding of Object.keys(config.bindings.artifacts)) {
|
|
361
|
+
lines.push(`${indent}${binding}: Artifacts`);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (config.bindings.secretsStore) {
|
|
365
|
+
for (const binding of Object.keys(config.bindings.secretsStore)) {
|
|
366
|
+
lines.push(`${indent}${binding}: SecretsStoreSecret`);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (config.bindings.services) {
|
|
370
|
+
for (const binding of Object.keys(config.bindings.services)) {
|
|
371
|
+
const serviceInfo = serviceBindingMap.get(binding);
|
|
372
|
+
if (serviceInfo?.interfaceType && serviceInfo.interfaceImport) {
|
|
373
|
+
imports.push(`import type { ${serviceInfo.interfaceType} } from '${serviceInfo.interfaceImport}'`);
|
|
374
|
+
lines.push(`${indent}${binding}: ${serviceInfo.interfaceType}`);
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
lines.push(`${indent}${binding}: Fetcher`);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
if (config.bindings.ai) {
|
|
381
|
+
lines.push(`${indent}${config.bindings.ai.binding}: Ai`);
|
|
382
|
+
}
|
|
383
|
+
if (config.bindings.aiSearchNamespaces) {
|
|
384
|
+
for (const binding of Object.keys(config.bindings.aiSearchNamespaces)) {
|
|
385
|
+
lines.push(`${indent}${binding}: AiSearchNamespace`);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (config.bindings.aiSearch) {
|
|
389
|
+
for (const binding of Object.keys(config.bindings.aiSearch)) {
|
|
390
|
+
lines.push(`${indent}${binding}: AiSearchInstance`);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (config.bindings.vectorize) {
|
|
394
|
+
for (const binding of Object.keys(config.bindings.vectorize)) {
|
|
395
|
+
lines.push(`${indent}${binding}: VectorizeIndex`);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (config.bindings.hyperdrive) {
|
|
399
|
+
for (const binding of Object.keys(config.bindings.hyperdrive)) {
|
|
400
|
+
lines.push(`${indent}${binding}: Hyperdrive`);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
if (config.bindings.browser) {
|
|
404
|
+
for (const binding of Object.keys(config.bindings.browser)) {
|
|
405
|
+
lines.push(`${indent}${binding}: Fetcher`);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (config.bindings.analyticsEngine) {
|
|
409
|
+
for (const binding of Object.keys(config.bindings.analyticsEngine)) {
|
|
410
|
+
lines.push(`${indent}${binding}: AnalyticsEngineDataset`);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
if (config.bindings.sendEmail) {
|
|
414
|
+
for (const binding of Object.keys(config.bindings.sendEmail)) {
|
|
415
|
+
lines.push(`${indent}${binding}: SendEmail`);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
if (options.includeVarsAsMembers !== false && config.vars) {
|
|
420
|
+
for (const key of Object.keys(config.vars)) {
|
|
421
|
+
lines.push(`${indent}${key}: string`);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
if (config.secrets) {
|
|
425
|
+
for (const secret of Object.keys(config.secrets)) {
|
|
426
|
+
lines.push(`${indent}${secret}: string`);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return { lines, imports };
|
|
430
|
+
}
|
|
431
|
+
function normalizeModuleDeclarationGlob(glob) {
|
|
432
|
+
return glob.replace(/\\/g, "/").replace(/^\.\//, "").replace(/^\*\*\//, "");
|
|
433
|
+
}
|
|
434
|
+
function generateModuleRuleDeclarations(config) {
|
|
435
|
+
const declarations = [];
|
|
436
|
+
const seen = new Set;
|
|
437
|
+
const typeByRuleType = {
|
|
438
|
+
Text: "string",
|
|
439
|
+
Data: "ArrayBuffer",
|
|
440
|
+
CompiledWasm: "WebAssembly.Module"
|
|
441
|
+
};
|
|
442
|
+
for (const rule of config.rules ?? []) {
|
|
443
|
+
const valueType = rule.type ? typeByRuleType[rule.type] : undefined;
|
|
444
|
+
if (!valueType) {
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
for (const glob of rule.globs ?? []) {
|
|
448
|
+
const specifier = normalizeModuleDeclarationGlob(glob);
|
|
449
|
+
const key = `${specifier}:${valueType}`;
|
|
450
|
+
if (seen.has(key)) {
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
seen.add(key);
|
|
454
|
+
declarations.push(`declare module '${specifier}' {`);
|
|
455
|
+
declarations.push(` const value: ${valueType}`);
|
|
456
|
+
declarations.push("\texport default value");
|
|
457
|
+
declarations.push("}");
|
|
458
|
+
declarations.push("");
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
return declarations;
|
|
462
|
+
}
|
|
463
|
+
function generateBindingTypes(config, discoveredDOs, discoveredEntrypoints, referencedConfigs, cwd, options = {}) {
|
|
464
|
+
const doClassMap = new Map;
|
|
465
|
+
for (const doInfo of discoveredDOs) {
|
|
466
|
+
doClassMap.set(doInfo.className, {
|
|
467
|
+
importPath: generateImportPath(cwd, doInfo.filePath),
|
|
468
|
+
className: doInfo.className
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
const crossWorkerDOMap = new Map;
|
|
472
|
+
for (const ref of referencedConfigs) {
|
|
473
|
+
for (const doInfo of ref.durableObjects) {
|
|
474
|
+
crossWorkerDOMap.set(doInfo.bindingName, doInfo);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
const serviceBindingMap = new Map;
|
|
478
|
+
for (const ref of referencedConfigs) {
|
|
479
|
+
for (const serviceBinding of ref.serviceBindings) {
|
|
480
|
+
serviceBindingMap.set(serviceBinding.bindingName, serviceBinding);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
const usedTypes = new Set;
|
|
484
|
+
if (config.bindings) {
|
|
485
|
+
if (config.bindings.kv && Object.keys(config.bindings.kv).length > 0)
|
|
486
|
+
usedTypes.add("KVNamespace");
|
|
487
|
+
if (config.bindings.d1 && Object.keys(config.bindings.d1).length > 0)
|
|
488
|
+
usedTypes.add("D1Database");
|
|
489
|
+
if (config.bindings.r2 && Object.keys(config.bindings.r2).length > 0)
|
|
490
|
+
usedTypes.add("R2Bucket");
|
|
491
|
+
if (config.bindings.durableObjects && Object.keys(config.bindings.durableObjects).length > 0)
|
|
492
|
+
usedTypes.add("DurableObjectNamespace");
|
|
493
|
+
if (config.bindings.queues?.producers && Object.keys(config.bindings.queues.producers).length > 0)
|
|
494
|
+
usedTypes.add("Queue");
|
|
495
|
+
if (config.bindings.rateLimits && Object.keys(config.bindings.rateLimits).length > 0)
|
|
496
|
+
usedTypes.add("RateLimit");
|
|
497
|
+
if (config.bindings.versionMetadata?.binding)
|
|
498
|
+
usedTypes.add("WorkerVersionMetadata");
|
|
499
|
+
if (config.bindings.workerLoaders && Object.keys(config.bindings.workerLoaders).length > 0)
|
|
500
|
+
usedTypes.add("WorkerLoader");
|
|
501
|
+
if (config.bindings.mtlsCertificates && Object.keys(config.bindings.mtlsCertificates).length > 0)
|
|
502
|
+
usedTypes.add("Fetcher");
|
|
503
|
+
if (config.bindings.dispatchNamespaces && Object.keys(config.bindings.dispatchNamespaces).length > 0)
|
|
504
|
+
usedTypes.add("DispatchNamespace");
|
|
505
|
+
if (config.bindings.workflows && Object.keys(config.bindings.workflows).length > 0)
|
|
506
|
+
usedTypes.add("Workflow");
|
|
507
|
+
if (config.bindings.images && Object.keys(config.bindings.images).length > 0)
|
|
508
|
+
usedTypes.add("ImagesBinding");
|
|
509
|
+
if (config.bindings.media && Object.keys(config.bindings.media).length > 0)
|
|
510
|
+
usedTypes.add("MediaBinding");
|
|
511
|
+
if (config.bindings.artifacts && Object.keys(config.bindings.artifacts).length > 0)
|
|
512
|
+
usedTypes.add("Artifacts");
|
|
513
|
+
if (config.bindings.secretsStore && Object.keys(config.bindings.secretsStore).length > 0)
|
|
514
|
+
usedTypes.add("SecretsStoreSecret");
|
|
515
|
+
if (config.bindings.services) {
|
|
516
|
+
const hasUntypedServices = Object.keys(config.bindings.services).some((name) => !serviceBindingMap.get(name)?.interfaceType);
|
|
517
|
+
if (hasUntypedServices)
|
|
518
|
+
usedTypes.add("Fetcher");
|
|
519
|
+
}
|
|
520
|
+
if (config.bindings.ai)
|
|
521
|
+
usedTypes.add("Ai");
|
|
522
|
+
if (config.bindings.aiSearchNamespaces && Object.keys(config.bindings.aiSearchNamespaces).length > 0) {
|
|
523
|
+
usedTypes.add("AiSearchNamespace");
|
|
524
|
+
}
|
|
525
|
+
if (config.bindings.aiSearch && Object.keys(config.bindings.aiSearch).length > 0) {
|
|
526
|
+
usedTypes.add("AiSearchInstance");
|
|
527
|
+
}
|
|
528
|
+
if (config.bindings.vectorize && Object.keys(config.bindings.vectorize).length > 0)
|
|
529
|
+
usedTypes.add("VectorizeIndex");
|
|
530
|
+
if (config.bindings.hyperdrive && Object.keys(config.bindings.hyperdrive).length > 0)
|
|
531
|
+
usedTypes.add("Hyperdrive");
|
|
532
|
+
if (config.bindings.browser && Object.keys(config.bindings.browser).length > 0)
|
|
533
|
+
usedTypes.add("Fetcher");
|
|
534
|
+
if (config.bindings.analyticsEngine && Object.keys(config.bindings.analyticsEngine).length > 0)
|
|
535
|
+
usedTypes.add("AnalyticsEngineDataset");
|
|
536
|
+
if (config.bindings.sendEmail && Object.keys(config.bindings.sendEmail).length > 0)
|
|
537
|
+
usedTypes.add("SendEmail");
|
|
538
|
+
}
|
|
539
|
+
const lines = [
|
|
540
|
+
"// Generated by devflare - DO NOT EDIT",
|
|
541
|
+
"// Run `devflare types` to regenerate",
|
|
542
|
+
""
|
|
543
|
+
];
|
|
544
|
+
const hasConfigVars = Boolean(config.vars && Object.keys(config.vars).length > 0);
|
|
545
|
+
const hasLocalDOsWithClasses = Boolean(config.bindings?.durableObjects && Object.values(config.bindings.durableObjects).some((doConfig) => doConfig.className && doClassMap.has(doConfig.className)));
|
|
546
|
+
const hasCrossWorkerDOs = crossWorkerDOMap.size > 0;
|
|
547
|
+
const hasDOsWithClasses = hasLocalDOsWithClasses || hasCrossWorkerDOs;
|
|
548
|
+
if (usedTypes.size > 0) {
|
|
549
|
+
const sortedTypes = [...usedTypes].sort();
|
|
550
|
+
if (hasDOsWithClasses) {
|
|
551
|
+
lines.push(`import type { ${sortedTypes.join(", ")}, Rpc } from '@cloudflare/workers-types'`);
|
|
552
|
+
} else {
|
|
553
|
+
lines.push(`import type { ${sortedTypes.join(", ")} } from '@cloudflare/workers-types'`);
|
|
554
|
+
}
|
|
555
|
+
lines.push("");
|
|
556
|
+
}
|
|
557
|
+
if (hasConfigVars) {
|
|
558
|
+
const configImportPath = options.configImportPath ?? "./devflare.config";
|
|
559
|
+
lines.push("import type { InferConfigVars } from 'devflare/config'");
|
|
560
|
+
lines.push(`type __DevflareConfigVars = InferConfigVars<Awaited<typeof import('${configImportPath}').default>>`);
|
|
561
|
+
lines.push("");
|
|
562
|
+
}
|
|
563
|
+
const { lines: bindingMembers, imports: serviceImports } = generateBindingMembers(config, doClassMap, crossWorkerDOMap, serviceBindingMap, cwd, "\t\t", { includeVarsAsMembers: !hasConfigVars });
|
|
564
|
+
const uniqueImports = [...new Set(serviceImports)];
|
|
565
|
+
if (uniqueImports.length > 0) {
|
|
566
|
+
lines.push(...uniqueImports);
|
|
567
|
+
lines.push("");
|
|
568
|
+
}
|
|
569
|
+
lines.push("declare global {");
|
|
570
|
+
if (hasConfigVars) {
|
|
571
|
+
lines.push("\tinterface DevflareVars extends __DevflareConfigVars {}");
|
|
572
|
+
lines.push("\tinterface DevflareEnv extends __DevflareConfigVars {");
|
|
573
|
+
} else {
|
|
574
|
+
lines.push("\tinterface DevflareEnv {");
|
|
575
|
+
}
|
|
576
|
+
lines.push(...bindingMembers);
|
|
577
|
+
lines.push("\t}");
|
|
578
|
+
lines.push("}");
|
|
579
|
+
lines.push("");
|
|
580
|
+
lines.push(...generateModuleRuleDeclarations(config));
|
|
581
|
+
if (discoveredEntrypoints.length > 0) {
|
|
582
|
+
const entrypointNames = discoveredEntrypoints.map((entrypoint) => `'${entrypoint.className}'`).join(" | ");
|
|
583
|
+
lines.push("/**");
|
|
584
|
+
lines.push(" * Named entrypoints discovered from ep.*.ts files.");
|
|
585
|
+
lines.push(" * Use with defineConfig<Entrypoints>() for type-safe cross-worker references.");
|
|
586
|
+
lines.push(" */");
|
|
587
|
+
lines.push(`export type Entrypoints = ${entrypointNames}`);
|
|
588
|
+
} else {
|
|
589
|
+
lines.push("/**");
|
|
590
|
+
lines.push(" * Named entrypoints (none discovered - add ep.*.ts files to enable).");
|
|
591
|
+
lines.push(" * Use with defineConfig<Entrypoints>() for type-safe cross-worker references.");
|
|
592
|
+
lines.push(" */");
|
|
593
|
+
lines.push("export type Entrypoints = string");
|
|
594
|
+
}
|
|
595
|
+
lines.push("");
|
|
596
|
+
return lines.join(`
|
|
597
|
+
`);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
// src/cli/commands/types.ts
|
|
601
|
+
function logTypesLine(logger, message = "") {
|
|
602
|
+
if (typeof logger.log === "function") {
|
|
603
|
+
logger.log(message);
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
if (typeof logger.info === "function") {
|
|
607
|
+
logger.info(message);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
async function runTypesCommand(parsed, logger, options) {
|
|
611
|
+
const cwd = options.cwd || process.cwd();
|
|
612
|
+
const configPath = parsed.options.config;
|
|
613
|
+
const outputPath = parsed.options.output || "env.d.ts";
|
|
614
|
+
const theme = createCliTheme(parsed.options);
|
|
615
|
+
logTypesLine(logger);
|
|
616
|
+
logTypesLine(logger, `${bold("types", theme)} ${dim("Generating TypeScript bindings", theme)}`);
|
|
617
|
+
try {
|
|
618
|
+
const config = await loadConfig({ cwd, configFile: configPath });
|
|
619
|
+
const requestedConfigPath = configPath ? resolve(cwd, configPath) : cwd;
|
|
620
|
+
const actualConfigPath = await resolveConfigCandidatePath(requestedConfigPath);
|
|
621
|
+
if (!actualConfigPath) {
|
|
622
|
+
throw new Error("Could not resolve the loaded devflare config file path");
|
|
623
|
+
}
|
|
624
|
+
const doPattern = typeof config.files?.durableObjects === "string" ? config.files.durableObjects : DEFAULT_DO_PATTERN;
|
|
625
|
+
let discoveredDOs = [];
|
|
626
|
+
if (config.files?.durableObjects !== false) {
|
|
627
|
+
discoveredDOs = await discoverDurableObjects(cwd, doPattern);
|
|
628
|
+
if (discoveredDOs.length > 0) {
|
|
629
|
+
logTypesLine(logger, `Discovered ${discoveredDOs.length} Durable Object class(es):`);
|
|
630
|
+
for (const doInfo of discoveredDOs) {
|
|
631
|
+
logTypesLine(logger, ` • ${doInfo.className} → ${doInfo.bindingName}`);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
if (config.bindings?.durableObjects) {
|
|
636
|
+
for (const [bindingName, doConfig] of Object.entries(config.bindings.durableObjects)) {
|
|
637
|
+
const normalized = normalizeDOBinding(doConfig);
|
|
638
|
+
const className = normalized.className;
|
|
639
|
+
if (!className) {
|
|
640
|
+
continue;
|
|
641
|
+
}
|
|
642
|
+
const existing = discoveredDOs.find((doInfo) => doInfo.className === className);
|
|
643
|
+
if (existing) {
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
if (normalized.scriptName && (normalized.scriptName.endsWith(".ts") || normalized.scriptName.endsWith(".js"))) {
|
|
647
|
+
const filePath = resolve(cwd, "src", normalized.scriptName);
|
|
648
|
+
discoveredDOs.push({
|
|
649
|
+
className,
|
|
650
|
+
filePath,
|
|
651
|
+
bindingName
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
const entrypointPattern = typeof config.files?.entrypoints === "string" ? config.files.entrypoints : DEFAULT_ENTRYPOINT_PATTERN;
|
|
657
|
+
let discoveredEntrypoints = [];
|
|
658
|
+
if (config.files?.entrypoints !== false) {
|
|
659
|
+
discoveredEntrypoints = await discoverEntrypointsAsync(cwd, entrypointPattern);
|
|
660
|
+
if (discoveredEntrypoints.length > 0) {
|
|
661
|
+
logTypesLine(logger, `Discovered ${discoveredEntrypoints.length} entrypoint class(es):`);
|
|
662
|
+
for (const entrypoint of discoveredEntrypoints) {
|
|
663
|
+
logTypesLine(logger, ` • ${entrypoint.className}`);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
const referencedConfigs = await resolveReferencedConfigs(actualConfigPath, cwd);
|
|
668
|
+
if (referencedConfigs.length > 0) {
|
|
669
|
+
logTypesLine(logger, `Found ${referencedConfigs.length} referenced worker(s):`);
|
|
670
|
+
for (const ref of referencedConfigs) {
|
|
671
|
+
const typedBindings = ref.serviceBindings.filter((serviceBinding) => serviceBinding.interfaceType);
|
|
672
|
+
if (typedBindings.length > 0) {
|
|
673
|
+
logTypesLine(logger, ` • ${ref.varName}: ${typedBindings.map((serviceBinding) => `${serviceBinding.bindingName} → ${serviceBinding.interfaceType}`).join(", ")}`);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
const normalizedConfig = {
|
|
678
|
+
...config,
|
|
679
|
+
bindings: config.bindings ? {
|
|
680
|
+
...config.bindings,
|
|
681
|
+
durableObjects: config.bindings.durableObjects ? Object.fromEntries(Object.entries(config.bindings.durableObjects).map(([name, doConfig]) => {
|
|
682
|
+
const normalized = normalizeDOBinding(doConfig);
|
|
683
|
+
return [name, { className: normalized.className, scriptName: normalized.scriptName }];
|
|
684
|
+
})) : undefined
|
|
685
|
+
} : undefined
|
|
686
|
+
};
|
|
687
|
+
const types = generateBindingTypes(normalizedConfig, discoveredDOs, discoveredEntrypoints, referencedConfigs, cwd, { configImportPath: generateImportPath(cwd, actualConfigPath) });
|
|
688
|
+
const { fs } = await getDependencies();
|
|
689
|
+
const fullPath = resolve(cwd, outputPath);
|
|
690
|
+
await fs.writeFile(fullPath, types, "utf-8");
|
|
691
|
+
logger.success(`Generated types: ${outputPath}`);
|
|
692
|
+
return { exitCode: 0 };
|
|
693
|
+
} catch (error) {
|
|
694
|
+
if (error instanceof Error) {
|
|
695
|
+
logger.error("Type generation failed:", error.message);
|
|
696
|
+
if (parsed.options.debug) {
|
|
697
|
+
logger.error(error.stack);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
return { exitCode: 1 };
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
export {
|
|
704
|
+
runTypesCommand
|
|
705
|
+
};
|