devflare 1.0.0-next.14 → 1.0.0-next.16
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 +9360 -1784
- package/README.md +391 -32
- package/bin/devflare.js +17 -7
- package/dist/account-0w8wdzjv.js +475 -0
- package/dist/account-eygq6qx7.js +475 -0
- package/dist/account-fw8nafav.js +475 -0
- package/dist/account-pzq69nys.js +475 -0
- package/dist/account-s66jb15j.js +475 -0
- package/dist/api-d6ekexs5.js +25 -0
- package/dist/bridge/index.d.ts +1 -1
- package/dist/bridge/index.d.ts.map +1 -1
- package/dist/bridge/miniflare.d.ts.map +1 -1
- package/dist/bridge/protocol.d.ts +1 -1
- package/dist/bridge/protocol.d.ts.map +1 -1
- package/dist/bridge/proxy.d.ts +0 -4
- package/dist/bridge/proxy.d.ts.map +1 -1
- package/dist/bridge/serialization.d.ts.map +1 -1
- package/dist/bridge/server.d.ts +1 -1
- package/dist/bridge/server.d.ts.map +1 -1
- package/dist/browser-shim/handler.d.ts +1 -1
- package/dist/browser-shim/handler.d.ts.map +1 -1
- package/dist/browser.d.ts +1651 -34
- package/dist/browser.d.ts.map +1 -1
- package/dist/build-1kmkwqgh.js +53 -0
- package/dist/build-506kjhcm.js +53 -0
- package/dist/build-66866ahs.js +53 -0
- package/dist/build-g1adm3ww.js +53 -0
- package/dist/build-p3r3117t.js +53 -0
- package/dist/bundler/do-bundler.d.ts.map +1 -1
- package/dist/bundler/rolldown-shared.d.ts +24 -0
- package/dist/bundler/rolldown-shared.d.ts.map +1 -0
- package/dist/bundler/worker-bundler.d.ts +0 -1
- package/dist/bundler/worker-bundler.d.ts.map +1 -1
- 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 +27 -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.d.ts.map +1 -1
- 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/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 +44 -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 +2 -1
- package/dist/cli/config-path.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/preview-bindings.d.ts +42 -0
- package/dist/cli/preview-bindings.d.ts.map +1 -0
- package/dist/cli/preview.d.ts +11 -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 +4 -0
- package/dist/cloudflare/api.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/kv-namespace.d.ts +3 -0
- package/dist/cloudflare/kv-namespace.d.ts.map +1 -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-records.d.ts +61 -0
- package/dist/cloudflare/preview-registry-records.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-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/registry-schema.d.ts +253 -0
- package/dist/cloudflare/registry-schema.d.ts.map +1 -0
- package/dist/cloudflare/tokens.d.ts +18 -0
- package/dist/cloudflare/tokens.d.ts.map +1 -0
- package/dist/cloudflare/types.d.ts +122 -5
- package/dist/cloudflare/types.d.ts.map +1 -1
- package/dist/cloudflare/usage.d.ts.map +1 -1
- package/dist/config/compiler.d.ts +4 -0
- package/dist/config/compiler.d.ts.map +1 -1
- 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 +5 -3
- 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/preview-resources.d.ts +77 -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 +0 -22
- package/dist/config/ref.d.ts.map +1 -1
- package/dist/config/resolve.d.ts +1 -0
- package/dist/config/resolve.d.ts.map +1 -1
- package/dist/config/resource-resolution.d.ts +60 -0
- package/dist/config/resource-resolution.d.ts.map +1 -0
- package/dist/config/schema-bindings.d.ts +693 -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 +1341 -0
- package/dist/config/schema-env.d.ts.map +1 -0
- package/dist/config/schema-normalization.d.ts +64 -0
- package/dist/config/schema-normalization.d.ts.map +1 -0
- package/dist/config/schema-runtime.d.ts +230 -0
- package/dist/config/schema-runtime.d.ts.map +1 -0
- package/dist/config/schema.d.ts +640 -3669
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config-entry.d.ts +5 -0
- package/dist/config-entry.d.ts.map +1 -0
- package/dist/config-fjwke42y.js +59 -0
- package/dist/config-hwdqjse7.js +59 -0
- package/dist/config-pxvewrhv.js +59 -0
- package/dist/config-q0g5qdga.js +59 -0
- package/dist/decorators/durable-object.d.ts.map +1 -1
- package/dist/deploy-7nmzc9r8.js +609 -0
- package/dist/deploy-csfhdr64.js +691 -0
- package/dist/deploy-ex4g5avz.js +621 -0
- package/dist/deploy-jnb0bhka.js +609 -0
- package/dist/deploy-tp0g6qdp.js +609 -0
- package/dist/deploy-ykpcjkc2.js +690 -0
- package/dist/{dev-c1xc1gq9.js → dev-2pd33m28.js} +392 -348
- package/dist/dev-7ef5e2j1.js +2409 -0
- package/dist/dev-8nssqatr.js +2409 -0
- package/dist/dev-grznx8fn.js +2409 -0
- package/dist/dev-server/d1-migrations.d.ts +14 -0
- package/dist/dev-server/d1-migrations.d.ts.map +1 -0
- package/dist/dev-server/gateway-script.d.ts +8 -0
- package/dist/dev-server/gateway-script.d.ts.map +1 -0
- package/dist/dev-server/runtime-stdio.d.ts.map +1 -1
- package/dist/dev-server/server.d.ts.map +1 -1
- package/dist/dev-server/vite-process.d.ts +14 -0
- package/dist/dev-server/vite-process.d.ts.map +1 -0
- package/dist/dev-server/vite-utils.d.ts +1 -1
- package/dist/dev-server/vite-utils.d.ts.map +1 -1
- package/dist/dev-server/worker-source-watcher.d.ts +11 -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-z4ffybce.js → doctor-04ammrrh.js} +67 -31
- package/dist/doctor-fmjj65mc.js +245 -0
- package/dist/doctor-fzkznce1.js +245 -0
- package/dist/doctor-sa5xv1bz.js +245 -0
- package/dist/index-091sh1ma.js +1229 -0
- package/dist/index-0apbm26n.js +788 -0
- package/dist/index-0eqksag4.js +418 -0
- package/dist/{index-dr6sbp8d.js → index-0kfzdywd.js} +15 -2
- package/dist/index-0w826dsr.js +379 -0
- package/dist/{index-rfhx0yd5.js → index-11m5a8wd.js} +110 -32
- package/dist/{index-xxwbb2nt.js → index-1sp39f2f.js} +114 -58
- package/dist/index-2jnrqbny.js +1301 -0
- package/dist/index-2pb7b9mw.js +378 -0
- package/dist/{index-0kzg8wed.js → index-2x53aqjm.js} +1071 -890
- package/dist/index-3ke5d2vn.js +1229 -0
- package/dist/index-43dq8yx8.js +788 -0
- package/dist/index-4rrttqj5.js +378 -0
- package/dist/index-4v9bc2pc.js +1367 -0
- package/dist/index-61jsjnsv.js +280 -0
- package/dist/index-6jef5emv.js +176 -0
- package/dist/index-6psz1h4c.js +788 -0
- package/dist/index-72mve6vh.js +168 -0
- package/dist/{index-zbvmtcn2.js → index-74198nxd.js} +179 -77
- package/dist/index-7g8zyws4.js +192 -0
- package/dist/index-7kcxjhta.js +456 -0
- package/dist/index-7v583xan.js +418 -0
- package/dist/index-7x0ybbtx.js +133 -0
- package/dist/index-816krz9p.js +52 -0
- package/dist/index-82f1z98k.js +41 -0
- package/dist/index-8t5nb4qx.js +133 -0
- package/dist/index-9az6s7ad.js +52 -0
- package/dist/{index-59df49vn.js → index-9ba1etyz.js} +29 -51
- package/dist/{index-001mw014.js → index-9fbtk7gv.js} +134 -248
- package/dist/index-9n6djthj.js +490 -0
- package/dist/index-aabgympv.js +39 -0
- package/dist/index-b8m6883k.js +74 -0
- package/dist/{index-5yxg30va.js → index-cgbvmse6.js} +15 -6
- package/dist/index-d8etnfef.js +1229 -0
- package/dist/index-e9yw4d6y.js +133 -0
- package/dist/index-epw1jxz5.js +1204 -0
- package/dist/index-f85s8gj3.js +2649 -0
- package/dist/index-fe2ngvh7.js +1229 -0
- package/dist/index-fvsadj32.js +192 -0
- package/dist/index-gs4y9gdf.js +456 -0
- package/dist/{index-fef08w43.js → index-h18pxvzs.js} +7 -6
- package/dist/index-hfj1a2c4.js +2649 -0
- package/dist/{index-8gtqgb3q.js → index-hjy8ctpc.js} +14 -92
- package/dist/index-htzf0py1.js +1204 -0
- package/dist/index-j185x270.js +897 -0
- package/dist/index-jb75kwa4.js +519 -0
- package/dist/index-jwd8pcb2.js +897 -0
- package/dist/index-k29yjhv0.js +52 -0
- package/dist/index-k6vq6kkt.js +456 -0
- package/dist/{index-vky23txa.js → index-m3fmw6mx.js} +2 -2
- package/dist/index-maxpsfk8.js +402 -0
- package/dist/index-mbdmrner.js +402 -0
- package/dist/index-mea5bc45.js +418 -0
- package/dist/index-mqekt778.js +185 -0
- package/dist/index-na3mnm1k.js +74 -0
- package/dist/index-p03n4qet.js +1367 -0
- package/dist/index-p296ban8.js +191 -0
- package/dist/index-pnbs1b8k.js +280 -0
- package/dist/index-q4kaz181.js +1207 -0
- package/dist/index-ry131z23.js +378 -0
- package/dist/index-sgb7c8nm.js +402 -0
- package/dist/index-sqrksgb2.js +133 -0
- package/dist/index-stgn34cr.js +148 -0
- package/dist/{index-v8vvsn9x.js → index-t08te69w.js} +1 -18
- package/dist/index-thna1tkd.js +280 -0
- package/dist/index-v5nmqthy.js +74 -0
- package/dist/{index-n932ytmq.js → index-vt4yxkmf.js} +2 -2
- package/dist/index-wyq6c6yj.js +402 -0
- package/dist/index-wztc9stx.js +418 -0
- package/dist/index-x9cwdxw5.js +456 -0
- package/dist/index-xk9djfjp.js +519 -0
- package/dist/index-yc0gcchc.js +418 -0
- package/dist/index-yqbxjysa.js +897 -0
- package/dist/index-yzddwp02.js +788 -0
- package/dist/index-zfhq6s96.js +74 -0
- package/dist/index-zt22fe2j.js +54 -0
- package/dist/index-zyt5byt6.js +2649 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/{init-na2atvz2.js → init-r4hnxan3.js} +24 -17
- package/dist/login-2hnz4m4n.js +77 -0
- package/dist/login-5bsxxpvc.js +77 -0
- package/dist/login-6tzvczw2.js +77 -0
- package/dist/login-bhaw72zc.js +77 -0
- package/dist/login-x8tgckqm.js +77 -0
- package/dist/previews-3rn8mz2c.js +1168 -0
- package/dist/previews-d487qde5.js +1200 -0
- package/dist/previews-gm3z0syj.js +1168 -0
- package/dist/previews-j9ymq4ys.js +1169 -0
- package/dist/previews-q031mx34.js +1168 -0
- package/dist/productions-120xg0aq.js +505 -0
- package/dist/productions-5ev5qweg.js +505 -0
- package/dist/productions-me3tdvr9.js +505 -0
- package/dist/productions-p5rbgp2f.js +505 -0
- package/dist/productions-x9p0pym1.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 +6 -267
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/exports.d.ts +3 -3
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/middleware.d.ts +8 -38
- package/dist/runtime/middleware.d.ts.map +1 -1
- package/dist/src/browser.js +23 -14
- package/dist/src/cli/index.js +3 -1
- package/dist/src/cloudflare/index.js +49 -2
- package/dist/src/config-entry.js +14 -0
- package/dist/src/index.js +33 -20
- package/dist/src/runtime/index.js +3 -9
- package/dist/src/sveltekit/index.js +10 -7
- package/dist/src/test/index.js +16 -18
- package/dist/src/vite/index.js +7 -4
- package/dist/sveltekit/platform.d.ts +1 -1
- package/dist/sveltekit/platform.d.ts.map +1 -1
- package/dist/test/cf.d.ts +10 -10
- package/dist/test/email.d.ts.map +1 -1
- package/dist/test/index.d.ts +1 -6
- package/dist/test/index.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/test/scheduled.d.ts.map +1 -1
- package/dist/test/should-skip.d.ts +0 -18
- package/dist/test/should-skip.d.ts.map +1 -1
- 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-gateway-script.d.ts +2 -0
- package/dist/test/simple-context-gateway-script.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.d.ts +1 -23
- package/dist/test/simple-context.d.ts.map +1 -1
- package/dist/test/tail.d.ts.map +1 -1
- package/dist/test/worker.d.ts.map +1 -1
- package/dist/token-kedhcret.js +419 -0
- package/dist/token-m8jmnjwk.js +419 -0
- package/dist/{types-sffr9681.js → types-0sqwkp7x.js} +244 -139
- package/dist/types-1gwr2ex6.js +572 -0
- package/dist/types-6e5yx6km.js +572 -0
- package/dist/types-p0gckpn6.js +572 -0
- package/dist/utils/send-email.d.ts.map +1 -1
- package/dist/vite/config-file.d.ts.map +1 -1
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/worker-0srh2jfr.js +513 -0
- package/dist/worker-4xrfd10a.js +513 -0
- package/dist/worker-entry/composed-worker.d.ts +0 -7
- package/dist/worker-entry/composed-worker.d.ts.map +1 -1
- package/dist/worker-entry/surface-paths.d.ts +15 -0
- package/dist/worker-entry/surface-paths.d.ts.map +1 -0
- package/dist/worker-qtam8grz.js +513 -0
- package/dist/worker-qzm0b7br.js +513 -0
- package/dist/worker-y9ha6g44.js +513 -0
- package/package.json +17 -10
- package/R2.md +0 -200
- package/dist/account-8psavtg6.js +0 -420
- package/dist/build-n639efmn.js +0 -101
- package/dist/deploy-zvnq6xh7.js +0 -117
- package/dist/index-2q3pmzrx.js +0 -90
- package/dist/index-f4q0jbnj.js +0 -195
- package/dist/index-n7rs26ft.js +0 -77
- package/dist/index-tfyxa77h.js +0 -850
- package/dist/index-wyf3s77s.js +0 -343
- package/dist/test/multi-worker-context.d.ts +0 -114
- package/dist/test/multi-worker-context.d.ts.map +0 -1
|
@@ -0,0 +1,788 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getEffectiveAccountId,
|
|
3
|
+
getPrimaryAccount,
|
|
4
|
+
listD1Databases,
|
|
5
|
+
listHyperdrives,
|
|
6
|
+
listKVNamespaces
|
|
7
|
+
} from "./index-jb75kwa4.js";
|
|
8
|
+
import {
|
|
9
|
+
materializePreviewScopedConfig
|
|
10
|
+
} from "./index-6jef5emv.js";
|
|
11
|
+
|
|
12
|
+
// src/config/schema-bindings.ts
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
var durableObjectBindingSchema = z.custom((val) => {
|
|
15
|
+
if (typeof val === "string") {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
if (val && typeof val === "object" && "className" in val) {
|
|
19
|
+
const obj = val;
|
|
20
|
+
return typeof obj.className === "string";
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
}, {
|
|
24
|
+
message: "Expected string or { className: string, scriptName?: string }"
|
|
25
|
+
});
|
|
26
|
+
var queueConsumerSchema = z.object({
|
|
27
|
+
queue: z.string(),
|
|
28
|
+
maxBatchSize: z.number().optional(),
|
|
29
|
+
maxBatchTimeout: z.number().optional(),
|
|
30
|
+
maxRetries: z.number().optional(),
|
|
31
|
+
deadLetterQueue: z.string().optional(),
|
|
32
|
+
maxConcurrency: z.number().optional(),
|
|
33
|
+
retryDelay: z.number().optional()
|
|
34
|
+
});
|
|
35
|
+
var queuesConfigSchema = z.object({
|
|
36
|
+
producers: z.record(z.string(), z.string()).optional(),
|
|
37
|
+
consumers: z.array(queueConsumerSchema).optional()
|
|
38
|
+
});
|
|
39
|
+
var serviceBindingSchema = z.custom((val) => {
|
|
40
|
+
if (typeof val !== "object" && typeof val !== "function") {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const obj = val;
|
|
44
|
+
return typeof obj.service === "string";
|
|
45
|
+
}, {
|
|
46
|
+
message: "Expected service binding object with { service: string } or ref().worker"
|
|
47
|
+
});
|
|
48
|
+
var aiBindingSchema = z.object({
|
|
49
|
+
binding: z.string()
|
|
50
|
+
});
|
|
51
|
+
var vectorizeBindingSchema = z.object({
|
|
52
|
+
indexName: z.string()
|
|
53
|
+
});
|
|
54
|
+
var hyperdriveBindingByIdSchema = z.object({
|
|
55
|
+
id: z.string()
|
|
56
|
+
}).strict();
|
|
57
|
+
var hyperdriveBindingByNameSchema = z.object({
|
|
58
|
+
name: z.string()
|
|
59
|
+
}).strict();
|
|
60
|
+
var hyperdriveBindingSchema = z.union([
|
|
61
|
+
z.string(),
|
|
62
|
+
hyperdriveBindingByIdSchema,
|
|
63
|
+
hyperdriveBindingByNameSchema
|
|
64
|
+
]);
|
|
65
|
+
var SINGLE_BROWSER_BINDING_ERROR_MESSAGE = "Devflare currently supports exactly one browser binding because Wrangler only supports a single browser binding.";
|
|
66
|
+
function formatBrowserBindingLimitMessage(bindingNames) {
|
|
67
|
+
if (bindingNames.length <= 1) {
|
|
68
|
+
return SINGLE_BROWSER_BINDING_ERROR_MESSAGE;
|
|
69
|
+
}
|
|
70
|
+
return `${SINGLE_BROWSER_BINDING_ERROR_MESSAGE} Configured bindings: ${bindingNames.join(", ")}`;
|
|
71
|
+
}
|
|
72
|
+
function getBrowserBindingNames(bindings) {
|
|
73
|
+
return bindings ? Object.keys(bindings) : [];
|
|
74
|
+
}
|
|
75
|
+
var browserBindingSchema = z.record(z.string(), z.string()).superRefine((bindings, ctx) => {
|
|
76
|
+
const bindingNames = getBrowserBindingNames(bindings);
|
|
77
|
+
if (bindingNames.length > 1) {
|
|
78
|
+
ctx.addIssue({
|
|
79
|
+
code: z.ZodIssueCode.custom,
|
|
80
|
+
message: formatBrowserBindingLimitMessage(bindingNames)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
var analyticsBindingSchema = z.object({
|
|
85
|
+
dataset: z.string()
|
|
86
|
+
});
|
|
87
|
+
var sendEmailBindingSchema = z.object({
|
|
88
|
+
destinationAddress: z.string().optional(),
|
|
89
|
+
allowedDestinationAddresses: z.array(z.string()).optional(),
|
|
90
|
+
allowedSenderAddresses: z.array(z.string()).optional()
|
|
91
|
+
}).refine((binding) => {
|
|
92
|
+
return !(binding.destinationAddress && binding.allowedDestinationAddresses);
|
|
93
|
+
}, {
|
|
94
|
+
message: "sendEmail bindings must use either destinationAddress or allowedDestinationAddresses, not both",
|
|
95
|
+
path: ["allowedDestinationAddresses"]
|
|
96
|
+
});
|
|
97
|
+
var d1BindingByIdSchema = z.object({
|
|
98
|
+
id: z.string()
|
|
99
|
+
}).strict();
|
|
100
|
+
var d1BindingByNameSchema = z.object({
|
|
101
|
+
name: z.string()
|
|
102
|
+
}).strict();
|
|
103
|
+
var d1BindingSchema = z.union([
|
|
104
|
+
z.string(),
|
|
105
|
+
d1BindingByIdSchema,
|
|
106
|
+
d1BindingByNameSchema
|
|
107
|
+
]);
|
|
108
|
+
var kvBindingByIdSchema = z.object({
|
|
109
|
+
id: z.string()
|
|
110
|
+
}).strict();
|
|
111
|
+
var kvBindingByNameSchema = z.object({
|
|
112
|
+
name: z.string()
|
|
113
|
+
}).strict();
|
|
114
|
+
var kvBindingSchema = z.union([
|
|
115
|
+
z.string(),
|
|
116
|
+
kvBindingByIdSchema,
|
|
117
|
+
kvBindingByNameSchema
|
|
118
|
+
]);
|
|
119
|
+
var bindingsSchema = z.object({
|
|
120
|
+
kv: z.record(z.string(), kvBindingSchema).optional(),
|
|
121
|
+
d1: z.record(z.string(), d1BindingSchema).optional(),
|
|
122
|
+
r2: z.record(z.string(), z.string()).optional(),
|
|
123
|
+
durableObjects: z.record(z.string(), durableObjectBindingSchema).optional(),
|
|
124
|
+
queues: queuesConfigSchema.optional(),
|
|
125
|
+
services: z.record(z.string(), serviceBindingSchema).optional(),
|
|
126
|
+
ai: aiBindingSchema.optional(),
|
|
127
|
+
vectorize: z.record(z.string(), vectorizeBindingSchema).optional(),
|
|
128
|
+
hyperdrive: z.record(z.string(), hyperdriveBindingSchema).optional(),
|
|
129
|
+
browser: browserBindingSchema.optional(),
|
|
130
|
+
analyticsEngine: z.record(z.string(), analyticsBindingSchema).optional(),
|
|
131
|
+
sendEmail: z.record(z.string(), sendEmailBindingSchema).optional()
|
|
132
|
+
}).optional();
|
|
133
|
+
|
|
134
|
+
// src/config/schema-normalization.ts
|
|
135
|
+
function getSingleBrowserBindingName(bindings) {
|
|
136
|
+
const bindingNames = getBrowserBindingNames(bindings);
|
|
137
|
+
if (bindingNames.length === 0) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (bindingNames.length > 1) {
|
|
141
|
+
throw new Error(formatBrowserBindingLimitMessage(bindingNames));
|
|
142
|
+
}
|
|
143
|
+
return bindingNames[0];
|
|
144
|
+
}
|
|
145
|
+
function normalizeDOBinding(config) {
|
|
146
|
+
if (typeof config === "string") {
|
|
147
|
+
return { className: config };
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
className: config.className,
|
|
151
|
+
scriptName: config.scriptName,
|
|
152
|
+
__ref: config.__ref
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function normalizeD1Binding(config) {
|
|
156
|
+
if (typeof config === "string") {
|
|
157
|
+
return { name: config };
|
|
158
|
+
}
|
|
159
|
+
if ("id" in config) {
|
|
160
|
+
return { databaseId: config.id };
|
|
161
|
+
}
|
|
162
|
+
return { name: config.name };
|
|
163
|
+
}
|
|
164
|
+
function normalizeKVBinding(config) {
|
|
165
|
+
if (typeof config === "string") {
|
|
166
|
+
return { name: config };
|
|
167
|
+
}
|
|
168
|
+
if ("id" in config) {
|
|
169
|
+
return { namespaceId: config.id };
|
|
170
|
+
}
|
|
171
|
+
return { name: config.name };
|
|
172
|
+
}
|
|
173
|
+
function normalizeHyperdriveBinding(config) {
|
|
174
|
+
if (typeof config === "string") {
|
|
175
|
+
return { name: config };
|
|
176
|
+
}
|
|
177
|
+
if ("id" in config) {
|
|
178
|
+
return { configurationId: config.id };
|
|
179
|
+
}
|
|
180
|
+
return { name: config.name };
|
|
181
|
+
}
|
|
182
|
+
function getLocalKVNamespaceIdentifier(config) {
|
|
183
|
+
const normalized = normalizeKVBinding(config);
|
|
184
|
+
return normalized.namespaceId ?? normalized.name ?? "";
|
|
185
|
+
}
|
|
186
|
+
function getLocalD1DatabaseIdentifier(config) {
|
|
187
|
+
const normalized = normalizeD1Binding(config);
|
|
188
|
+
return normalized.databaseId ?? normalized.name ?? "";
|
|
189
|
+
}
|
|
190
|
+
function getLocalHyperdriveConfigIdentifier(config) {
|
|
191
|
+
const normalized = normalizeHyperdriveBinding(config);
|
|
192
|
+
return normalized.configurationId ?? normalized.name ?? "";
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// src/config/schema.ts
|
|
196
|
+
import { z as z5 } from "zod";
|
|
197
|
+
|
|
198
|
+
// src/config/schema-build.ts
|
|
199
|
+
import { z as z2 } from "zod";
|
|
200
|
+
var rolldownOptionsSchema = z2.custom((value) => {
|
|
201
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
202
|
+
}, {
|
|
203
|
+
message: "Expected Rolldown options object"
|
|
204
|
+
});
|
|
205
|
+
var rolldownConfigSchema = z2.object({
|
|
206
|
+
target: z2.string().optional(),
|
|
207
|
+
minify: z2.boolean().optional(),
|
|
208
|
+
sourcemap: z2.boolean().optional(),
|
|
209
|
+
options: rolldownOptionsSchema.optional()
|
|
210
|
+
}).optional();
|
|
211
|
+
var viteConfigSchema = z2.object({
|
|
212
|
+
plugins: z2.array(z2.unknown()).optional()
|
|
213
|
+
}).catchall(z2.unknown()).optional();
|
|
214
|
+
|
|
215
|
+
// src/config/schema-env.ts
|
|
216
|
+
import { z as z4 } from "zod";
|
|
217
|
+
|
|
218
|
+
// src/config/schema-runtime.ts
|
|
219
|
+
import { z as z3 } from "zod";
|
|
220
|
+
var dateRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
221
|
+
var compatibilityDateSchema = z3.string().regex(dateRegex, {
|
|
222
|
+
message: "Compatibility date must be in YYYY-MM-DD format"
|
|
223
|
+
});
|
|
224
|
+
var routesConfigSchema = z3.object({
|
|
225
|
+
dir: z3.string(),
|
|
226
|
+
prefix: z3.string().optional()
|
|
227
|
+
});
|
|
228
|
+
var filesSchema = z3.object({
|
|
229
|
+
fetch: z3.union([z3.string(), z3.literal(false)]).optional(),
|
|
230
|
+
queue: z3.union([z3.string(), z3.literal(false)]).optional(),
|
|
231
|
+
scheduled: z3.union([z3.string(), z3.literal(false)]).optional(),
|
|
232
|
+
email: z3.union([z3.string(), z3.literal(false)]).optional(),
|
|
233
|
+
durableObjects: z3.union([z3.string(), z3.literal(false)]).optional(),
|
|
234
|
+
entrypoints: z3.union([z3.string(), z3.literal(false)]).optional(),
|
|
235
|
+
workflows: z3.union([z3.string(), z3.literal(false)]).optional(),
|
|
236
|
+
routes: z3.union([routesConfigSchema, z3.literal(false)]).optional(),
|
|
237
|
+
transport: z3.union([z3.string(), z3.null()]).optional()
|
|
238
|
+
}).optional();
|
|
239
|
+
var triggersSchema = z3.object({
|
|
240
|
+
crons: z3.array(z3.string()).optional()
|
|
241
|
+
}).optional();
|
|
242
|
+
var previewsConfigSchema = z3.object({
|
|
243
|
+
includeCrons: z3.boolean().optional().default(false)
|
|
244
|
+
}).optional();
|
|
245
|
+
var secretConfigSchema = z3.object({
|
|
246
|
+
required: z3.boolean().optional().default(true)
|
|
247
|
+
});
|
|
248
|
+
var routeConfigSchema = z3.object({
|
|
249
|
+
pattern: z3.string(),
|
|
250
|
+
zone_name: z3.string().optional(),
|
|
251
|
+
zone_id: z3.string().optional(),
|
|
252
|
+
custom_domain: z3.boolean().optional()
|
|
253
|
+
});
|
|
254
|
+
var wsRouteConfigSchema = z3.object({
|
|
255
|
+
pattern: z3.string(),
|
|
256
|
+
doNamespace: z3.string(),
|
|
257
|
+
idParam: z3.string().default("id"),
|
|
258
|
+
forwardPath: z3.string().default("/websocket")
|
|
259
|
+
});
|
|
260
|
+
var assetsConfigSchema = z3.object({
|
|
261
|
+
directory: z3.string(),
|
|
262
|
+
binding: z3.string().optional()
|
|
263
|
+
}).optional();
|
|
264
|
+
var observabilitySchema = z3.object({
|
|
265
|
+
enabled: z3.boolean().optional(),
|
|
266
|
+
head_sampling_rate: z3.number().min(0).max(1).optional()
|
|
267
|
+
}).optional();
|
|
268
|
+
var limitsSchema = z3.object({
|
|
269
|
+
cpu_ms: z3.number().optional()
|
|
270
|
+
}).optional();
|
|
271
|
+
var migrationSchema = z3.object({
|
|
272
|
+
tag: z3.string(),
|
|
273
|
+
new_classes: z3.array(z3.string()).optional(),
|
|
274
|
+
renamed_classes: z3.array(z3.object({
|
|
275
|
+
from: z3.string(),
|
|
276
|
+
to: z3.string()
|
|
277
|
+
})).optional(),
|
|
278
|
+
deleted_classes: z3.array(z3.string()).optional(),
|
|
279
|
+
new_sqlite_classes: z3.array(z3.string()).optional()
|
|
280
|
+
});
|
|
281
|
+
var wranglerConfigSchema = z3.object({
|
|
282
|
+
passthrough: z3.record(z3.string(), z3.unknown()).optional()
|
|
283
|
+
}).optional();
|
|
284
|
+
|
|
285
|
+
// src/config/schema-env.ts
|
|
286
|
+
var envConfigSchema = z4.object({
|
|
287
|
+
name: z4.string().optional(),
|
|
288
|
+
compatibilityDate: compatibilityDateSchema.optional(),
|
|
289
|
+
compatibilityFlags: z4.array(z4.string()).optional(),
|
|
290
|
+
previews: previewsConfigSchema,
|
|
291
|
+
files: filesSchema,
|
|
292
|
+
bindings: bindingsSchema,
|
|
293
|
+
triggers: triggersSchema,
|
|
294
|
+
vars: z4.record(z4.string(), z4.string()).optional(),
|
|
295
|
+
secrets: z4.record(z4.string(), secretConfigSchema).optional(),
|
|
296
|
+
routes: z4.array(routeConfigSchema).optional(),
|
|
297
|
+
assets: assetsConfigSchema,
|
|
298
|
+
limits: limitsSchema,
|
|
299
|
+
observability: observabilitySchema,
|
|
300
|
+
migrations: z4.array(migrationSchema).optional(),
|
|
301
|
+
rolldown: rolldownConfigSchema,
|
|
302
|
+
vite: viteConfigSchema,
|
|
303
|
+
wrangler: wranglerConfigSchema
|
|
304
|
+
}).partial().strict();
|
|
305
|
+
var envConfigSchemaInner = envConfigSchema;
|
|
306
|
+
|
|
307
|
+
// src/config/schema.ts
|
|
308
|
+
function getCurrentDate() {
|
|
309
|
+
const now = new Date;
|
|
310
|
+
return now.toISOString().split("T")[0];
|
|
311
|
+
}
|
|
312
|
+
var FORCED_COMPATIBILITY_FLAGS = ["nodejs_compat", "nodejs_als"];
|
|
313
|
+
var canonicalConfigSchema = z5.object({
|
|
314
|
+
name: z5.string({
|
|
315
|
+
required_error: "Worker name is required"
|
|
316
|
+
}),
|
|
317
|
+
accountId: z5.string().optional(),
|
|
318
|
+
compatibilityDate: compatibilityDateSchema.optional().default(getCurrentDate),
|
|
319
|
+
compatibilityFlags: z5.array(z5.string()).optional().transform((flags = []) => {
|
|
320
|
+
const merged = new Set([...FORCED_COMPATIBILITY_FLAGS, ...flags]);
|
|
321
|
+
return [...merged];
|
|
322
|
+
}),
|
|
323
|
+
previews: previewsConfigSchema,
|
|
324
|
+
files: filesSchema,
|
|
325
|
+
bindings: bindingsSchema,
|
|
326
|
+
triggers: triggersSchema,
|
|
327
|
+
vars: z5.record(z5.string(), z5.string()).optional(),
|
|
328
|
+
secrets: z5.record(z5.string(), secretConfigSchema).optional(),
|
|
329
|
+
routes: z5.array(routeConfigSchema).optional(),
|
|
330
|
+
wsRoutes: z5.array(wsRouteConfigSchema).optional(),
|
|
331
|
+
assets: assetsConfigSchema,
|
|
332
|
+
limits: limitsSchema,
|
|
333
|
+
observability: observabilitySchema,
|
|
334
|
+
migrations: z5.array(migrationSchema).optional(),
|
|
335
|
+
rolldown: rolldownConfigSchema,
|
|
336
|
+
vite: viteConfigSchema,
|
|
337
|
+
env: z5.record(z5.string(), envConfigSchemaInner).optional(),
|
|
338
|
+
wrangler: wranglerConfigSchema
|
|
339
|
+
});
|
|
340
|
+
var configSchema = canonicalConfigSchema.strict();
|
|
341
|
+
|
|
342
|
+
// src/config/loader.ts
|
|
343
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
344
|
+
import { createRequire } from "node:module";
|
|
345
|
+
import { dirname, join as join2, resolve } from "pathe";
|
|
346
|
+
|
|
347
|
+
// src/config/framework-providers.ts
|
|
348
|
+
import { readFile } from "node:fs/promises";
|
|
349
|
+
import { join } from "pathe";
|
|
350
|
+
var SVELTE_CONFIG_FILES = [
|
|
351
|
+
"svelte.config.js",
|
|
352
|
+
"svelte.config.mjs",
|
|
353
|
+
"svelte.config.ts",
|
|
354
|
+
"svelte.config.cjs"
|
|
355
|
+
];
|
|
356
|
+
async function readTextIfExists(path) {
|
|
357
|
+
try {
|
|
358
|
+
return await readFile(path, "utf-8");
|
|
359
|
+
} catch {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
async function readPackageDependencies(cwd) {
|
|
364
|
+
const packageJsonText = await readTextIfExists(join(cwd, "package.json"));
|
|
365
|
+
if (!packageJsonText) {
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
try {
|
|
369
|
+
const packageJson = JSON.parse(packageJsonText);
|
|
370
|
+
return {
|
|
371
|
+
...packageJson.dependencies ?? {},
|
|
372
|
+
...packageJson.devDependencies ?? {},
|
|
373
|
+
...packageJson.peerDependencies ?? {}
|
|
374
|
+
};
|
|
375
|
+
} catch {
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
async function findFirstExistingTextFile(cwd, candidates) {
|
|
380
|
+
for (const candidate of candidates) {
|
|
381
|
+
const fileText = await readTextIfExists(join(cwd, candidate));
|
|
382
|
+
if (fileText !== null) {
|
|
383
|
+
return fileText;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
var svelteKitCloudflareProvider = {
|
|
389
|
+
id: "sveltekit-cloudflare",
|
|
390
|
+
async resolve(context) {
|
|
391
|
+
const dependencies = await readPackageDependencies(context.cwd);
|
|
392
|
+
if (!dependencies?.["@sveltejs/kit"] || !dependencies["@sveltejs/adapter-cloudflare"]) {
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
const svelteConfigText = await findFirstExistingTextFile(context.cwd, SVELTE_CONFIG_FILES);
|
|
396
|
+
if (!svelteConfigText) {
|
|
397
|
+
return null;
|
|
398
|
+
}
|
|
399
|
+
if (!/@sveltejs\/adapter-cloudflare|adapter-cloudflare/.test(svelteConfigText)) {
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
return {
|
|
403
|
+
id: this.id,
|
|
404
|
+
config: {
|
|
405
|
+
files: {
|
|
406
|
+
fetch: ".adapter-cloudflare/_worker.js"
|
|
407
|
+
},
|
|
408
|
+
assets: {
|
|
409
|
+
binding: "ASSETS",
|
|
410
|
+
directory: ".adapter-cloudflare"
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
var frameworkProviders = [
|
|
417
|
+
svelteKitCloudflareProvider
|
|
418
|
+
];
|
|
419
|
+
function hasFrameworkInferenceGap(config) {
|
|
420
|
+
return config.files?.fetch === undefined || config.assets?.directory === undefined || config.assets?.binding === undefined;
|
|
421
|
+
}
|
|
422
|
+
function mergeInferredConfig(config, inferredConfig) {
|
|
423
|
+
const mergedFiles = inferredConfig.files ? {
|
|
424
|
+
...inferredConfig.files,
|
|
425
|
+
...config.files ?? {}
|
|
426
|
+
} : config.files;
|
|
427
|
+
const mergedAssets = inferredConfig.assets ? {
|
|
428
|
+
...inferredConfig.assets,
|
|
429
|
+
...config.assets ?? {}
|
|
430
|
+
} : config.assets;
|
|
431
|
+
return {
|
|
432
|
+
...config,
|
|
433
|
+
...mergedFiles && { files: mergedFiles },
|
|
434
|
+
...mergedAssets && { assets: mergedAssets }
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
async function applyFrameworkConfigProviders(config, context) {
|
|
438
|
+
if (!hasFrameworkInferenceGap(config)) {
|
|
439
|
+
return config;
|
|
440
|
+
}
|
|
441
|
+
for (const provider of frameworkProviders) {
|
|
442
|
+
const resolution = await provider.resolve({
|
|
443
|
+
...context,
|
|
444
|
+
config
|
|
445
|
+
});
|
|
446
|
+
if (!resolution) {
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
return mergeInferredConfig(config, resolution.config);
|
|
450
|
+
}
|
|
451
|
+
return config;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// src/config/loader.ts
|
|
455
|
+
var CONFIG_FILES = [
|
|
456
|
+
"devflare.config.ts",
|
|
457
|
+
"devflare.config.mts",
|
|
458
|
+
"devflare.config.js",
|
|
459
|
+
"devflare.config.mjs"
|
|
460
|
+
];
|
|
461
|
+
function resolveC12Module(cwd) {
|
|
462
|
+
const requireFromCwd = createRequire(join2(cwd, "__devflare__.cjs"));
|
|
463
|
+
try {
|
|
464
|
+
return requireFromCwd("c12");
|
|
465
|
+
} catch {
|
|
466
|
+
return createRequire(import.meta.url)("c12");
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
function hasWorkspacePackageJson(cwd) {
|
|
470
|
+
const packageJsonPath = join2(cwd, "package.json");
|
|
471
|
+
if (!existsSync(packageJsonPath)) {
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
474
|
+
try {
|
|
475
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
476
|
+
return packageJson.workspaces !== undefined;
|
|
477
|
+
} catch {
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
function resolveWorkspaceDotenvDirectory(cwd) {
|
|
482
|
+
let current = cwd;
|
|
483
|
+
let nearestDotenvDirectory;
|
|
484
|
+
while (true) {
|
|
485
|
+
if (existsSync(join2(current, ".env"))) {
|
|
486
|
+
nearestDotenvDirectory ??= current;
|
|
487
|
+
if (hasWorkspacePackageJson(current)) {
|
|
488
|
+
return current;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
const parent = dirname(current);
|
|
492
|
+
if (parent === current) {
|
|
493
|
+
return nearestDotenvDirectory;
|
|
494
|
+
}
|
|
495
|
+
current = parent;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
async function loadWorkspaceDotenv(cwd, setupDotenv) {
|
|
499
|
+
const dotenvDirectory = resolveWorkspaceDotenvDirectory(cwd);
|
|
500
|
+
if (!dotenvDirectory) {
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
await setupDotenv({
|
|
504
|
+
cwd: dotenvDirectory,
|
|
505
|
+
fileName: ".env",
|
|
506
|
+
env: process.env
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
async function resolveConfigPath(cwd) {
|
|
510
|
+
for (const file of CONFIG_FILES) {
|
|
511
|
+
const path = join2(cwd, file);
|
|
512
|
+
if (existsSync(path)) {
|
|
513
|
+
return path;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
async function loadConfig(options = {}) {
|
|
519
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
520
|
+
const configFile = options.configFile ?? "devflare.config";
|
|
521
|
+
const { loadConfig: c12LoadConfig, setupDotenv } = resolveC12Module(cwd);
|
|
522
|
+
await loadWorkspaceDotenv(cwd, setupDotenv);
|
|
523
|
+
const { config, configFile: loadedFile } = await c12LoadConfig({
|
|
524
|
+
name: "devflare",
|
|
525
|
+
cwd,
|
|
526
|
+
configFile,
|
|
527
|
+
defaultConfig: undefined,
|
|
528
|
+
rcFile: false,
|
|
529
|
+
globalRc: false,
|
|
530
|
+
dotenv: false
|
|
531
|
+
});
|
|
532
|
+
if (!config || !loadedFile) {
|
|
533
|
+
throw new ConfigNotFoundError(cwd, configFile);
|
|
534
|
+
}
|
|
535
|
+
const result = configSchema.safeParse(config);
|
|
536
|
+
if (!result.success) {
|
|
537
|
+
throw new ConfigValidationError(result.error.issues, loadedFile);
|
|
538
|
+
}
|
|
539
|
+
return applyFrameworkConfigProviders(result.data, {
|
|
540
|
+
cwd,
|
|
541
|
+
configPath: loadedFile
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
class ConfigNotFoundError extends Error {
|
|
546
|
+
cwd;
|
|
547
|
+
configFile;
|
|
548
|
+
code = "CONFIG_NOT_FOUND";
|
|
549
|
+
constructor(cwd, configFile) {
|
|
550
|
+
super(`Config file not found in ${cwd}.
|
|
551
|
+
` + `Expected one of: ${CONFIG_FILES.join(", ")}
|
|
552
|
+
` + `Run 'devflare init' to create a new config.`);
|
|
553
|
+
this.cwd = cwd;
|
|
554
|
+
this.configFile = configFile;
|
|
555
|
+
this.name = "ConfigNotFoundError";
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
class ConfigValidationError extends Error {
|
|
560
|
+
issues;
|
|
561
|
+
configFile;
|
|
562
|
+
code = "CONFIG_VALIDATION_ERROR";
|
|
563
|
+
constructor(issues, configFile) {
|
|
564
|
+
const issueMessages = issues.map((i) => ` - ${i.path.join(".")}: ${i.message}`).join(`
|
|
565
|
+
`);
|
|
566
|
+
super(`Invalid config in ${configFile}:
|
|
567
|
+
${issueMessages}`);
|
|
568
|
+
this.issues = issues;
|
|
569
|
+
this.configFile = configFile;
|
|
570
|
+
this.name = "ConfigValidationError";
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// src/config/resolve.ts
|
|
575
|
+
import { defu } from "defu";
|
|
576
|
+
function mergeConfigForEnvironment(config, environment) {
|
|
577
|
+
return environment && config.env?.[environment] ? defu(config.env[environment], config) : config;
|
|
578
|
+
}
|
|
579
|
+
function resolveConfigForEnvironment(config, environment) {
|
|
580
|
+
const mergedConfig = mergeConfigForEnvironment(config, environment);
|
|
581
|
+
return materializePreviewScopedConfig(mergedConfig, {
|
|
582
|
+
environment
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
// src/config/resource-resolution.ts
|
|
587
|
+
var defaultCloudflareApi = {
|
|
588
|
+
getPrimaryAccount,
|
|
589
|
+
getEffectiveAccountId,
|
|
590
|
+
listKVNamespaces,
|
|
591
|
+
listD1Databases,
|
|
592
|
+
listHyperdrives
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
class ConfigResourceResolutionError extends Error {
|
|
596
|
+
code = "CONFIG_RESOURCE_RESOLUTION_ERROR";
|
|
597
|
+
constructor(message, cause) {
|
|
598
|
+
super(message);
|
|
599
|
+
this.name = "ConfigResourceResolutionError";
|
|
600
|
+
if (cause !== undefined) {
|
|
601
|
+
this.cause = cause;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
function resolveCloudflareApi(overrides) {
|
|
606
|
+
return {
|
|
607
|
+
...defaultCloudflareApi,
|
|
608
|
+
...overrides ?? {}
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
function materializeIdBindings(bindings, resolveId) {
|
|
612
|
+
return Object.fromEntries(Object.entries(bindings).map(([bindingName, bindingConfig]) => {
|
|
613
|
+
return [bindingName, { id: resolveId(bindingConfig) }];
|
|
614
|
+
}));
|
|
615
|
+
}
|
|
616
|
+
function normalizeKVNameBinding(bindingConfig) {
|
|
617
|
+
const normalized = normalizeKVBinding(bindingConfig);
|
|
618
|
+
return {
|
|
619
|
+
id: normalized.namespaceId,
|
|
620
|
+
name: normalized.name
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
function normalizeD1NameBinding(bindingConfig) {
|
|
624
|
+
const normalized = normalizeD1Binding(bindingConfig);
|
|
625
|
+
return {
|
|
626
|
+
id: normalized.databaseId,
|
|
627
|
+
name: normalized.name
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
function normalizeHyperdriveNameBinding(bindingConfig) {
|
|
631
|
+
const normalized = normalizeHyperdriveBinding(bindingConfig);
|
|
632
|
+
return {
|
|
633
|
+
id: normalized.configurationId,
|
|
634
|
+
name: normalized.name
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
function collectPendingNameBindings(bindings, normalizeBinding) {
|
|
638
|
+
if (!bindings) {
|
|
639
|
+
return [];
|
|
640
|
+
}
|
|
641
|
+
return Object.entries(bindings).map(([bindingName, bindingConfig]) => {
|
|
642
|
+
const normalized = normalizeBinding(bindingConfig);
|
|
643
|
+
return normalized.id ? null : {
|
|
644
|
+
bindingName,
|
|
645
|
+
resourceName: normalized.name ?? ""
|
|
646
|
+
};
|
|
647
|
+
}).filter((binding) => binding !== null);
|
|
648
|
+
}
|
|
649
|
+
function materializeResolvedNameBindings(bindings, normalizeBinding, idsByName) {
|
|
650
|
+
if (!bindings) {
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
return materializeIdBindings(bindings, (bindingConfig) => {
|
|
654
|
+
const normalized = normalizeBinding(bindingConfig);
|
|
655
|
+
return normalized.id ?? idsByName.get(normalized.name ?? "") ?? "";
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
function withResolvedIdBindings(resolvedConfig, bindings) {
|
|
659
|
+
return {
|
|
660
|
+
...resolvedConfig,
|
|
661
|
+
bindings: {
|
|
662
|
+
...resolvedConfig.bindings,
|
|
663
|
+
...bindings.kv ? { kv: bindings.kv } : {},
|
|
664
|
+
...bindings.d1 ? { d1: bindings.d1 } : {},
|
|
665
|
+
...bindings.hyperdrive ? { hyperdrive: bindings.hyperdrive } : {}
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
async function resolveLookupAccountId(config, options, cloudflareApi) {
|
|
670
|
+
const explicitAccountId = options.accountId ?? config.accountId;
|
|
671
|
+
if (explicitAccountId) {
|
|
672
|
+
return explicitAccountId;
|
|
673
|
+
}
|
|
674
|
+
let primaryAccount;
|
|
675
|
+
try {
|
|
676
|
+
primaryAccount = await cloudflareApi.getPrimaryAccount();
|
|
677
|
+
} catch (error) {
|
|
678
|
+
throw new ConfigResourceResolutionError("Could not resolve Cloudflare-backed resource names because Devflare could not read your Cloudflare accounts. Set accountId in devflare.config.ts, configure a workspace/global default account, or log in with Wrangler.", error);
|
|
679
|
+
}
|
|
680
|
+
if (!primaryAccount) {
|
|
681
|
+
throw new ConfigResourceResolutionError("Could not resolve Cloudflare-backed resource names because no Cloudflare account is available. Set accountId in devflare.config.ts, configure a workspace/global default account, or log in with Wrangler.");
|
|
682
|
+
}
|
|
683
|
+
try {
|
|
684
|
+
const { accountId } = await cloudflareApi.getEffectiveAccountId(primaryAccount.id);
|
|
685
|
+
return accountId;
|
|
686
|
+
} catch (error) {
|
|
687
|
+
throw new ConfigResourceResolutionError(`Could not determine the effective Cloudflare account for name-based resource resolution after selecting primary account ${primaryAccount.id}.`, error);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
function formatMissingBindings(missing) {
|
|
691
|
+
return missing.map(({ bindingName, resourceName }) => `${bindingName} → ${resourceName}`).join(", ");
|
|
692
|
+
}
|
|
693
|
+
async function resolveResourceIdsByName(pendingBindings, options) {
|
|
694
|
+
if (pendingBindings.length === 0) {
|
|
695
|
+
return new Map;
|
|
696
|
+
}
|
|
697
|
+
let resources;
|
|
698
|
+
try {
|
|
699
|
+
resources = await options.listResources();
|
|
700
|
+
} catch (error) {
|
|
701
|
+
throw new ConfigResourceResolutionError(options.listFailureMessage, error);
|
|
702
|
+
}
|
|
703
|
+
const idsByName = new Map(resources.map((resource) => [resource.name, resource.id]));
|
|
704
|
+
const missingBindings = pendingBindings.filter(({ resourceName }) => {
|
|
705
|
+
return !idsByName.has(resourceName);
|
|
706
|
+
});
|
|
707
|
+
if (missingBindings.length > 0) {
|
|
708
|
+
throw new ConfigResourceResolutionError(options.missingFailureMessage(missingBindings));
|
|
709
|
+
}
|
|
710
|
+
return idsByName;
|
|
711
|
+
}
|
|
712
|
+
function resolveConfigForLocalRuntime(config, environment) {
|
|
713
|
+
const resolvedConfig = resolveConfigForEnvironment(config, environment);
|
|
714
|
+
const kvBindings = resolvedConfig.bindings?.kv;
|
|
715
|
+
const d1Bindings = resolvedConfig.bindings?.d1;
|
|
716
|
+
const hyperdriveBindings = resolvedConfig.bindings?.hyperdrive;
|
|
717
|
+
if (!kvBindings && !d1Bindings && !hyperdriveBindings) {
|
|
718
|
+
return resolvedConfig;
|
|
719
|
+
}
|
|
720
|
+
return withResolvedIdBindings(resolvedConfig, {
|
|
721
|
+
kv: kvBindings ? materializeIdBindings(kvBindings, getLocalKVNamespaceIdentifier) : undefined,
|
|
722
|
+
d1: d1Bindings ? materializeIdBindings(d1Bindings, getLocalD1DatabaseIdentifier) : undefined,
|
|
723
|
+
hyperdrive: hyperdriveBindings ? materializeIdBindings(hyperdriveBindings, getLocalHyperdriveConfigIdentifier) : undefined
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
async function resolveMaterializedConfigResources(resolvedConfig, options = {}) {
|
|
727
|
+
const kvBindings = resolvedConfig.bindings?.kv;
|
|
728
|
+
const d1Bindings = resolvedConfig.bindings?.d1;
|
|
729
|
+
const hyperdriveBindings = resolvedConfig.bindings?.hyperdrive;
|
|
730
|
+
if (!kvBindings && !d1Bindings && !hyperdriveBindings) {
|
|
731
|
+
return resolvedConfig;
|
|
732
|
+
}
|
|
733
|
+
const pendingKVNameBindings = collectPendingNameBindings(kvBindings, normalizeKVNameBinding);
|
|
734
|
+
const pendingD1NameBindings = collectPendingNameBindings(d1Bindings, normalizeD1NameBinding);
|
|
735
|
+
const pendingHyperdriveNameBindings = collectPendingNameBindings(hyperdriveBindings, normalizeHyperdriveNameBinding);
|
|
736
|
+
if (pendingKVNameBindings.length === 0 && pendingD1NameBindings.length === 0 && pendingHyperdriveNameBindings.length === 0) {
|
|
737
|
+
return withResolvedIdBindings(resolvedConfig, {
|
|
738
|
+
kv: kvBindings ? materializeIdBindings(kvBindings, getLocalKVNamespaceIdentifier) : undefined,
|
|
739
|
+
d1: d1Bindings ? materializeIdBindings(d1Bindings, getLocalD1DatabaseIdentifier) : undefined,
|
|
740
|
+
hyperdrive: hyperdriveBindings ? materializeIdBindings(hyperdriveBindings, getLocalHyperdriveConfigIdentifier) : undefined
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
const cloudflareApi = resolveCloudflareApi(options.cloudflare);
|
|
744
|
+
const accountId = await resolveLookupAccountId(resolvedConfig, options, cloudflareApi);
|
|
745
|
+
const namespaceIdsByName = await resolveResourceIdsByName(pendingKVNameBindings, {
|
|
746
|
+
listResources: async () => cloudflareApi.listKVNamespaces(accountId),
|
|
747
|
+
listFailureMessage: `Could not list KV namespaces for Cloudflare account ${accountId} while resolving name-based KV bindings.`,
|
|
748
|
+
missingFailureMessage: (missingBindings) => {
|
|
749
|
+
return `Could not find KV namespace(s) for ${formatMissingBindings(missingBindings)} in Cloudflare account ${accountId}.`;
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
const databaseIdsByName = await resolveResourceIdsByName(pendingD1NameBindings, {
|
|
753
|
+
listResources: async () => cloudflareApi.listD1Databases(accountId),
|
|
754
|
+
listFailureMessage: `Could not list D1 databases for Cloudflare account ${accountId} while resolving name-based D1 bindings.`,
|
|
755
|
+
missingFailureMessage: (missingBindings) => {
|
|
756
|
+
return `Could not find D1 database(s) for ${formatMissingBindings(missingBindings)} in Cloudflare account ${accountId}.`;
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
const hyperdriveIdsByName = await resolveResourceIdsByName(pendingHyperdriveNameBindings, {
|
|
760
|
+
listResources: async () => cloudflareApi.listHyperdrives(accountId),
|
|
761
|
+
listFailureMessage: `Could not list Hyperdrive configurations for Cloudflare account ${accountId} while resolving name-based Hyperdrive bindings.`,
|
|
762
|
+
missingFailureMessage: (missingBindings) => {
|
|
763
|
+
return `Could not find Hyperdrive configuration(s) for ${formatMissingBindings(missingBindings)} in Cloudflare account ${accountId}.`;
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
return withResolvedIdBindings(resolvedConfig, {
|
|
767
|
+
kv: materializeResolvedNameBindings(kvBindings, normalizeKVNameBinding, namespaceIdsByName),
|
|
768
|
+
d1: materializeResolvedNameBindings(d1Bindings, normalizeD1NameBinding, databaseIdsByName),
|
|
769
|
+
hyperdrive: materializeResolvedNameBindings(hyperdriveBindings, normalizeHyperdriveNameBinding, hyperdriveIdsByName)
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
async function resolveConfigResources(config, options = {}) {
|
|
773
|
+
const resolvedConfig = materializePreviewScopedConfig(mergeConfigForEnvironment(config, options.environment), {
|
|
774
|
+
environment: options.environment,
|
|
775
|
+
env: options.env,
|
|
776
|
+
identifier: options.identifier
|
|
777
|
+
});
|
|
778
|
+
return resolveMaterializedConfigResources(resolvedConfig, {
|
|
779
|
+
accountId: options.accountId,
|
|
780
|
+
cloudflare: options.cloudflare
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
async function loadResolvedConfig(options = {}) {
|
|
784
|
+
const config = await loadConfig(options);
|
|
785
|
+
return resolveConfigResources(config, options);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
export { getSingleBrowserBindingName, normalizeDOBinding, normalizeD1Binding, normalizeKVBinding, normalizeHyperdriveBinding, getLocalKVNamespaceIdentifier, getLocalD1DatabaseIdentifier, configSchema, mergeConfigForEnvironment, resolveConfigForEnvironment, ConfigResourceResolutionError, resolveConfigForLocalRuntime, resolveMaterializedConfigResources, resolveConfigResources, loadResolvedConfig, resolveConfigPath, loadConfig, ConfigNotFoundError, ConfigValidationError };
|