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,168 @@
|
|
|
1
|
+
import {
|
|
2
|
+
apiDelete,
|
|
3
|
+
apiGetAll,
|
|
4
|
+
apiPost,
|
|
5
|
+
apiPut
|
|
6
|
+
} from "./index-0w826dsr.js";
|
|
7
|
+
|
|
8
|
+
// src/cloudflare/tokens.ts
|
|
9
|
+
var MAX_ACCOUNT_OWNED_TOKEN_PERMISSION_GROUPS = 300;
|
|
10
|
+
var DEVFLARE_MANAGED_TOKEN_PREFIX = "devflare-";
|
|
11
|
+
var ACCOUNT_OWNED_TOKEN_SCOPE = "com.cloudflare.api.account";
|
|
12
|
+
var ACCOUNT_API_TOKENS_PERMISSION_GROUP_NAME_PATTERN = /^Account API Tokens\b/i;
|
|
13
|
+
var DEVFLARE_MANAGED_TOKEN_NAME_PATTERN = /^devflare-/i;
|
|
14
|
+
var DEVFLARE_PERMISSION_GROUP_NAME_PATTERNS = [
|
|
15
|
+
/^Account Analytics Read$/i,
|
|
16
|
+
/^Account Settings Read$/i,
|
|
17
|
+
/^Analytics Read$/i,
|
|
18
|
+
/^AI /i,
|
|
19
|
+
/^Browser Rendering /i,
|
|
20
|
+
/^D1 (Metadata Read|Read|Write)$/i,
|
|
21
|
+
/^Email (Routing|Sending) /i,
|
|
22
|
+
/^Hyperdrive /i,
|
|
23
|
+
/^Queues /i,
|
|
24
|
+
/^Vectorize /i,
|
|
25
|
+
/^Workers /i
|
|
26
|
+
];
|
|
27
|
+
function dedupePermissionGroups(permissionGroups) {
|
|
28
|
+
const seenIds = new Set;
|
|
29
|
+
return permissionGroups.filter((permissionGroup) => {
|
|
30
|
+
if (seenIds.has(permissionGroup.id)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
seenIds.add(permissionGroup.id);
|
|
34
|
+
return true;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function dedupePermissionGroupIds(permissionGroupIds) {
|
|
38
|
+
return Array.from(new Set(permissionGroupIds.map((id) => id.trim()).filter(Boolean)));
|
|
39
|
+
}
|
|
40
|
+
function excludeAccountApiTokensPermissionGroups(permissionGroups) {
|
|
41
|
+
return permissionGroups.filter((permissionGroup) => {
|
|
42
|
+
return !ACCOUNT_API_TOKENS_PERMISSION_GROUP_NAME_PATTERN.test(permissionGroup.name);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function keepAccountOwnedTokenCompatiblePermissionGroups(permissionGroups) {
|
|
46
|
+
return permissionGroups.filter((permissionGroup) => {
|
|
47
|
+
return permissionGroup.scopes.some((scope) => scope.trim() === ACCOUNT_OWNED_TOKEN_SCOPE);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function selectReusableAccountOwnedTokenPermissionGroups(permissionGroups) {
|
|
51
|
+
return dedupePermissionGroups(excludeAccountApiTokensPermissionGroups(keepAccountOwnedTokenCompatiblePermissionGroups(permissionGroups)));
|
|
52
|
+
}
|
|
53
|
+
function parseOptionalDate(value) {
|
|
54
|
+
if (!value) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const parsed = new Date(value);
|
|
58
|
+
return Number.isNaN(parsed.getTime()) ? undefined : parsed;
|
|
59
|
+
}
|
|
60
|
+
function mapAccountOwnedAPITokenPolicy(policy) {
|
|
61
|
+
return {
|
|
62
|
+
id: policy.id,
|
|
63
|
+
effect: policy.effect,
|
|
64
|
+
permissionGroups: policy.permission_groups?.map((permissionGroup) => ({
|
|
65
|
+
id: permissionGroup.id,
|
|
66
|
+
name: permissionGroup.name
|
|
67
|
+
}))
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function mapAccountOwnedAPIToken(token) {
|
|
71
|
+
return {
|
|
72
|
+
id: token.id,
|
|
73
|
+
name: token.name ?? token.id,
|
|
74
|
+
status: token.status,
|
|
75
|
+
value: token.value,
|
|
76
|
+
issuedOn: parseOptionalDate(token.issued_on),
|
|
77
|
+
modifiedOn: parseOptionalDate(token.modified_on),
|
|
78
|
+
lastUsedOn: parseOptionalDate(token.last_used_on),
|
|
79
|
+
policies: token.policies?.map(mapAccountOwnedAPITokenPolicy)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function isDevflareManagedTokenName(name) {
|
|
83
|
+
return DEVFLARE_MANAGED_TOKEN_NAME_PATTERN.test(name.trim());
|
|
84
|
+
}
|
|
85
|
+
function normalizeDevflareTokenName(name) {
|
|
86
|
+
const trimmedName = name.trim();
|
|
87
|
+
if (!trimmedName) {
|
|
88
|
+
throw new Error("Devflare token name cannot be empty");
|
|
89
|
+
}
|
|
90
|
+
const suffix = isDevflareManagedTokenName(trimmedName) ? trimmedName.replace(DEVFLARE_MANAGED_TOKEN_NAME_PATTERN, "") : trimmedName;
|
|
91
|
+
if (!suffix) {
|
|
92
|
+
throw new Error("Devflare token name cannot be empty");
|
|
93
|
+
}
|
|
94
|
+
return `${DEVFLARE_MANAGED_TOKEN_PREFIX}${suffix}`;
|
|
95
|
+
}
|
|
96
|
+
function stripDevflareTokenNamePrefix(name) {
|
|
97
|
+
const trimmedName = name.trim();
|
|
98
|
+
if (!trimmedName) {
|
|
99
|
+
return trimmedName;
|
|
100
|
+
}
|
|
101
|
+
const strippedName = trimmedName.replace(DEVFLARE_MANAGED_TOKEN_NAME_PATTERN, "");
|
|
102
|
+
return strippedName || trimmedName;
|
|
103
|
+
}
|
|
104
|
+
function filterDevflareManagedTokens(tokens) {
|
|
105
|
+
return tokens.filter((token) => isDevflareManagedTokenName(token.name));
|
|
106
|
+
}
|
|
107
|
+
function selectDevflarePermissionGroups(permissionGroups) {
|
|
108
|
+
const selectedPermissionGroups = dedupePermissionGroups(selectReusableAccountOwnedTokenPermissionGroups(permissionGroups).filter((permissionGroup) => {
|
|
109
|
+
return DEVFLARE_PERMISSION_GROUP_NAME_PATTERNS.some((pattern) => {
|
|
110
|
+
return pattern.test(permissionGroup.name);
|
|
111
|
+
});
|
|
112
|
+
}));
|
|
113
|
+
if (selectedPermissionGroups.length === 0) {
|
|
114
|
+
throw new Error("Could not map the available Cloudflare permission groups to a Devflare token policy.");
|
|
115
|
+
}
|
|
116
|
+
if (selectedPermissionGroups.length > MAX_ACCOUNT_OWNED_TOKEN_PERMISSION_GROUPS) {
|
|
117
|
+
throw new Error(`Devflare selected ${selectedPermissionGroups.length} permission groups, which exceeds Cloudflare's ${MAX_ACCOUNT_OWNED_TOKEN_PERMISSION_GROUPS}-group limit for account-owned tokens.`);
|
|
118
|
+
}
|
|
119
|
+
return selectedPermissionGroups;
|
|
120
|
+
}
|
|
121
|
+
function selectAllReusablePermissionGroups(permissionGroups) {
|
|
122
|
+
const selectedPermissionGroups = selectReusableAccountOwnedTokenPermissionGroups(permissionGroups);
|
|
123
|
+
if (selectedPermissionGroups.length === 0) {
|
|
124
|
+
throw new Error("Could not find any reusable account-scoped Cloudflare permission groups for this Devflare token.");
|
|
125
|
+
}
|
|
126
|
+
if (selectedPermissionGroups.length > MAX_ACCOUNT_OWNED_TOKEN_PERMISSION_GROUPS) {
|
|
127
|
+
throw new Error(`Devflare selected ${selectedPermissionGroups.length} permission groups, which exceeds Cloudflare's ${MAX_ACCOUNT_OWNED_TOKEN_PERMISSION_GROUPS}-group limit for account-owned tokens.`);
|
|
128
|
+
}
|
|
129
|
+
return selectedPermissionGroups;
|
|
130
|
+
}
|
|
131
|
+
async function listAccountTokenPermissionGroups(accountId, options) {
|
|
132
|
+
const permissionGroups = await apiGetAll(`/accounts/${accountId}/tokens/permission_groups`, options);
|
|
133
|
+
return dedupePermissionGroups(permissionGroups);
|
|
134
|
+
}
|
|
135
|
+
async function listAccountOwnedAPITokens(accountId, options) {
|
|
136
|
+
const tokens = await apiGetAll(`/accounts/${accountId}/tokens`, options);
|
|
137
|
+
return tokens.map(mapAccountOwnedAPIToken);
|
|
138
|
+
}
|
|
139
|
+
async function deleteAccountOwnedAPIToken(accountId, tokenId, options) {
|
|
140
|
+
return apiDelete(`/accounts/${accountId}/tokens/${tokenId}`, options);
|
|
141
|
+
}
|
|
142
|
+
async function rollAccountOwnedAPITokenValue(accountId, tokenId, options) {
|
|
143
|
+
return apiPut(`/accounts/${accountId}/tokens/${tokenId}/value`, {}, options);
|
|
144
|
+
}
|
|
145
|
+
async function createAccountOwnedAPIToken(accountId, options, clientOptions) {
|
|
146
|
+
const permissionGroupIds = dedupePermissionGroupIds(options.permissionGroupIds);
|
|
147
|
+
if (permissionGroupIds.length === 0) {
|
|
148
|
+
throw new Error("Cannot create a Devflare token without any permission groups");
|
|
149
|
+
}
|
|
150
|
+
if (permissionGroupIds.length > MAX_ACCOUNT_OWNED_TOKEN_PERMISSION_GROUPS) {
|
|
151
|
+
throw new Error(`Cannot create a Devflare token with more than ${MAX_ACCOUNT_OWNED_TOKEN_PERMISSION_GROUPS} permission groups.`);
|
|
152
|
+
}
|
|
153
|
+
const createdToken = await apiPost(`/accounts/${accountId}/tokens`, {
|
|
154
|
+
name: options.name,
|
|
155
|
+
policies: [
|
|
156
|
+
{
|
|
157
|
+
effect: "allow",
|
|
158
|
+
resources: {
|
|
159
|
+
[`com.cloudflare.api.account.${accountId}`]: "*"
|
|
160
|
+
},
|
|
161
|
+
permission_groups: permissionGroupIds.map((id) => ({ id }))
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
}, clientOptions);
|
|
165
|
+
return mapAccountOwnedAPIToken(createdToken);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export { normalizeDevflareTokenName, stripDevflareTokenNamePrefix, filterDevflareManagedTokens, selectDevflarePermissionGroups, selectAllReusablePermissionGroups, listAccountTokenPermissionGroups, listAccountOwnedAPITokens, deleteAccountOwnedAPIToken, rollAccountOwnedAPITokenValue, createAccountOwnedAPIToken };
|
|
@@ -11,22 +11,31 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
compileConfig,
|
|
13
13
|
compileToProgrammaticConfig,
|
|
14
|
-
|
|
14
|
+
isolateViteBuildOutputPaths,
|
|
15
|
+
rebaseWranglerConfigPaths,
|
|
15
16
|
writeWranglerConfig
|
|
16
|
-
} from "./index-
|
|
17
|
+
} from "./index-pnbs1b8k.js";
|
|
17
18
|
import {
|
|
18
19
|
loadConfig,
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
loadResolvedConfig,
|
|
21
|
+
normalizeDOBinding,
|
|
22
|
+
resolveConfigForEnvironment,
|
|
23
|
+
resolveConfigForLocalRuntime,
|
|
24
|
+
resolveConfigPath,
|
|
25
|
+
resolveConfigResources
|
|
26
|
+
} from "./index-6psz1h4c.js";
|
|
21
27
|
import {
|
|
22
28
|
__require
|
|
23
29
|
} from "./index-37x76zdn.js";
|
|
24
30
|
|
|
25
31
|
// src/vite/plugin.ts
|
|
26
|
-
import { isAbsolute,
|
|
32
|
+
import { isAbsolute, resolve as resolve3 } from "pathe";
|
|
27
33
|
|
|
28
34
|
// src/worker-entry/composed-worker.ts
|
|
29
|
-
import { dirname, relative, resolve } from "pathe";
|
|
35
|
+
import { dirname, relative, resolve as resolve2 } from "pathe";
|
|
36
|
+
|
|
37
|
+
// src/worker-entry/surface-paths.ts
|
|
38
|
+
import { resolve } from "pathe";
|
|
30
39
|
var DEFAULT_FETCH_ENTRY_FILES = [
|
|
31
40
|
"src/fetch.ts",
|
|
32
41
|
"src/fetch.js",
|
|
@@ -51,20 +60,22 @@ var DEFAULT_EMAIL_ENTRY_FILES = [
|
|
|
51
60
|
"src/email.mts",
|
|
52
61
|
"src/email.mjs"
|
|
53
62
|
];
|
|
54
|
-
async function resolveWorkerHandlerPath(cwd, configuredPath, defaultEntries) {
|
|
63
|
+
async function resolveWorkerHandlerPath(cwd, configuredPath, defaultEntries, surfaceName = "worker") {
|
|
55
64
|
if (configuredPath === false) {
|
|
56
65
|
return null;
|
|
57
66
|
}
|
|
58
67
|
const fs = await import("node:fs/promises");
|
|
59
|
-
const candidates = new Set;
|
|
60
68
|
if (typeof configuredPath === "string" && configuredPath) {
|
|
61
|
-
|
|
69
|
+
const absolutePath = resolve(cwd, configuredPath);
|
|
70
|
+
try {
|
|
71
|
+
await fs.access(absolutePath);
|
|
72
|
+
return absolutePath;
|
|
73
|
+
} catch {
|
|
74
|
+
throw new Error(`Configured ${surfaceName} handler "${configuredPath}" was not found`);
|
|
75
|
+
}
|
|
62
76
|
}
|
|
63
77
|
for (const defaultEntry of defaultEntries) {
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
for (const candidate of candidates) {
|
|
67
|
-
const absolutePath = resolve(cwd, candidate);
|
|
78
|
+
const absolutePath = resolve(cwd, defaultEntry);
|
|
68
79
|
try {
|
|
69
80
|
await fs.access(absolutePath);
|
|
70
81
|
return absolutePath;
|
|
@@ -76,12 +87,17 @@ async function resolveWorkerHandlerPath(cwd, configuredPath, defaultEntries) {
|
|
|
76
87
|
}
|
|
77
88
|
async function resolveWorkerSurfacePaths(cwd, config) {
|
|
78
89
|
return {
|
|
79
|
-
fetch: await resolveWorkerHandlerPath(cwd, config.files?.fetch, DEFAULT_FETCH_ENTRY_FILES),
|
|
80
|
-
queue: await resolveWorkerHandlerPath(cwd, config.files?.queue, DEFAULT_QUEUE_ENTRY_FILES),
|
|
81
|
-
scheduled: await resolveWorkerHandlerPath(cwd, config.files?.scheduled, DEFAULT_SCHEDULED_ENTRY_FILES),
|
|
82
|
-
email: await resolveWorkerHandlerPath(cwd, config.files?.email, DEFAULT_EMAIL_ENTRY_FILES)
|
|
90
|
+
fetch: await resolveWorkerHandlerPath(cwd, config.files?.fetch, DEFAULT_FETCH_ENTRY_FILES, "fetch"),
|
|
91
|
+
queue: await resolveWorkerHandlerPath(cwd, config.files?.queue, DEFAULT_QUEUE_ENTRY_FILES, "queue"),
|
|
92
|
+
scheduled: await resolveWorkerHandlerPath(cwd, config.files?.scheduled, DEFAULT_SCHEDULED_ENTRY_FILES, "scheduled"),
|
|
93
|
+
email: await resolveWorkerHandlerPath(cwd, config.files?.email, DEFAULT_EMAIL_ENTRY_FILES, "email")
|
|
83
94
|
};
|
|
84
95
|
}
|
|
96
|
+
function hasWorkerSurfacePaths(surfacePaths) {
|
|
97
|
+
return Object.values(surfacePaths).some((surfacePath) => typeof surfacePath === "string" && surfacePath.length > 0);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// src/worker-entry/composed-worker.ts
|
|
85
101
|
function toImportSpecifier(fromFilePath, toFilePath) {
|
|
86
102
|
const specifier = relative(dirname(fromFilePath), toFilePath).replace(/\\/g, "/");
|
|
87
103
|
return specifier.startsWith(".") ? specifier : `./${specifier}`;
|
|
@@ -98,12 +114,65 @@ function createGeneratedRouteModuleImports(entryPath, routeDiscovery) {
|
|
|
98
114
|
segmentsJson: JSON.stringify(route.segments)
|
|
99
115
|
}));
|
|
100
116
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
117
|
+
async function createGeneratedDurableObjectExports(entryPath, cwd, config) {
|
|
118
|
+
if (config.files?.durableObjects === false || !config.bindings?.durableObjects) {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
const localClassNames = new Set(Object.values(config.bindings.durableObjects).map((binding) => normalizeDOBinding(binding)).filter((binding) => !binding.scriptName).map((binding) => binding.className));
|
|
122
|
+
if (localClassNames.size === 0) {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
const fs = await import("node:fs/promises");
|
|
126
|
+
const pattern = typeof config.files?.durableObjects === "string" ? config.files.durableObjects : DEFAULT_DO_PATTERN;
|
|
127
|
+
const matchedFiles = await findFiles(pattern, { cwd });
|
|
128
|
+
const exports = [];
|
|
129
|
+
const discoveredClassNames = new Set;
|
|
130
|
+
for (const filePath of matchedFiles) {
|
|
131
|
+
try {
|
|
132
|
+
const code = await fs.readFile(filePath, "utf-8");
|
|
133
|
+
const classNames = findDurableObjectClasses(code).filter((className) => localClassNames.has(className));
|
|
134
|
+
if (classNames.length === 0) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
for (const className of classNames) {
|
|
138
|
+
discoveredClassNames.add(className);
|
|
139
|
+
}
|
|
140
|
+
exports.push({
|
|
141
|
+
importPath: toImportSpecifier(entryPath, filePath),
|
|
142
|
+
filePath,
|
|
143
|
+
classNames
|
|
144
|
+
});
|
|
145
|
+
} catch {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const missingClassNames = Array.from(localClassNames).filter((className) => !discoveredClassNames.has(className));
|
|
150
|
+
if (missingClassNames.length > 0) {
|
|
151
|
+
throw new Error(`Failed to discover local Durable Object class${missingClassNames.length === 1 ? "" : "es"} ${missingClassNames.join(", ")} for worker composition. Ensure files.durableObjects matches the source file pattern for your do.* files.`);
|
|
152
|
+
}
|
|
153
|
+
return exports;
|
|
154
|
+
}
|
|
155
|
+
function needsComposedWorkerEntrypoint(cwd, surfacePaths, config, routeDiscovery) {
|
|
156
|
+
const hasAdditionalWorkerSurfaces = Boolean(surfacePaths.queue || surfacePaths.scheduled || surfacePaths.email || routeDiscovery?.routes.length);
|
|
157
|
+
if (hasAdditionalWorkerSurfaces) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
if (!surfacePaths.fetch) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
const assetsDirectory = config.assets?.directory;
|
|
164
|
+
if (assetsDirectory) {
|
|
165
|
+
const generatedAssetsWorkerPath = resolve2(cwd, assetsDirectory, "_worker.js");
|
|
166
|
+
if (surfacePaths.fetch === generatedAssetsWorkerPath) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return Boolean(surfacePaths.fetch);
|
|
103
171
|
}
|
|
104
|
-
function getComposedWorkerEntrypointSource(surfaceImportPaths, configuredLocalSendEmailBindings = {}, routeImports = [], options = {}) {
|
|
172
|
+
function getComposedWorkerEntrypointSource(surfaceImportPaths, configuredLocalSendEmailBindings = {}, durableObjectExports = [], routeImports = [], options = {}) {
|
|
105
173
|
const importLines = [`import { createEmailEvent, createFetchEvent, createQueueEvent, createRouteResolve, createScheduledEvent, invokeFetchModule, matchFetchRoute, runWithEventContext, setLocalSendEmailBindings } from 'devflare/runtime'`];
|
|
106
174
|
const moduleFallbackLines = [];
|
|
175
|
+
const durableObjectExportLines = durableObjectExports.map(({ classNames, importPath }) => `export { ${classNames.join(", ")} } from '${importPath}'`);
|
|
107
176
|
const localSendEmailBindings = JSON.stringify(configuredLocalSendEmailBindings);
|
|
108
177
|
const routeManifestEntries = routeImports.map(({ identifier, filePath, routePath, segmentsJson }) => {
|
|
109
178
|
return ` { filePath: ${JSON.stringify(filePath)}, routePath: ${JSON.stringify(routePath)}, segments: ${segmentsJson}, module: ${identifier} }`;
|
|
@@ -197,6 +266,8 @@ ${importLines.join(`
|
|
|
197
266
|
`)}
|
|
198
267
|
${moduleFallbackLines.join(`
|
|
199
268
|
`)}
|
|
269
|
+
${durableObjectExportLines.join(`
|
|
270
|
+
`)}
|
|
200
271
|
|
|
201
272
|
setLocalSendEmailBindings(${localSendEmailBindings})
|
|
202
273
|
|
|
@@ -303,12 +374,12 @@ async function prepareComposedWorkerEntrypoint(cwd, config, environment, options
|
|
|
303
374
|
}
|
|
304
375
|
const surfacePaths = await resolveWorkerSurfacePaths(cwd, resolvedConfig);
|
|
305
376
|
const routeDiscovery = await discoverRoutes(cwd, resolvedConfig);
|
|
306
|
-
if (!needsComposedWorkerEntrypoint(surfacePaths, routeDiscovery)) {
|
|
377
|
+
if (!needsComposedWorkerEntrypoint(cwd, surfacePaths, resolvedConfig, routeDiscovery)) {
|
|
307
378
|
return null;
|
|
308
379
|
}
|
|
309
380
|
const fs = await import("node:fs/promises");
|
|
310
|
-
const entryDir =
|
|
311
|
-
const entryPath =
|
|
381
|
+
const entryDir = resolve2(cwd, ".devflare", "worker-entrypoints");
|
|
382
|
+
const entryPath = resolve2(entryDir, "main.ts");
|
|
312
383
|
await fs.mkdir(entryDir, { recursive: true });
|
|
313
384
|
const surfaceImportPaths = {
|
|
314
385
|
fetch: surfacePaths.fetch ? toImportSpecifier(entryPath, surfacePaths.fetch) : null,
|
|
@@ -316,8 +387,9 @@ async function prepareComposedWorkerEntrypoint(cwd, config, environment, options
|
|
|
316
387
|
scheduled: surfacePaths.scheduled ? toImportSpecifier(entryPath, surfacePaths.scheduled) : null,
|
|
317
388
|
email: surfacePaths.email ? toImportSpecifier(entryPath, surfacePaths.email) : null
|
|
318
389
|
};
|
|
390
|
+
const durableObjectExports = await createGeneratedDurableObjectExports(entryPath, cwd, resolvedConfig);
|
|
319
391
|
const routeImports = createGeneratedRouteModuleImports(entryPath, routeDiscovery);
|
|
320
|
-
await fs.writeFile(entryPath, getComposedWorkerEntrypointSource(surfaceImportPaths, resolvedConfig.bindings?.sendEmail ?? {}, routeImports, options));
|
|
392
|
+
await fs.writeFile(entryPath, getComposedWorkerEntrypointSource(surfaceImportPaths, resolvedConfig.bindings?.sendEmail ?? {}, durableObjectExports, routeImports, options));
|
|
321
393
|
return ".devflare/worker-entrypoints/main.ts";
|
|
322
394
|
}
|
|
323
395
|
|
|
@@ -392,13 +464,6 @@ function createAuxiliaryWorkerConfig(wranglerConfig, discovery) {
|
|
|
392
464
|
}
|
|
393
465
|
};
|
|
394
466
|
}
|
|
395
|
-
function rebaseMainPathForConfigDir(projectRoot, configDir, mainEntry) {
|
|
396
|
-
if (!mainEntry) {
|
|
397
|
-
return mainEntry;
|
|
398
|
-
}
|
|
399
|
-
const absoluteMainPath = isAbsolute(mainEntry) ? mainEntry : resolve2(projectRoot, mainEntry);
|
|
400
|
-
return relative2(configDir, absoluteMainPath).replace(/\\/g, "/");
|
|
401
|
-
}
|
|
402
467
|
function logDiscoveredDurableObjects(projectRoot, discovery) {
|
|
403
468
|
if (!discovery || discovery.files.size === 0) {
|
|
404
469
|
return;
|
|
@@ -408,17 +473,21 @@ function logDiscoveredDurableObjects(projectRoot, discovery) {
|
|
|
408
473
|
console.log(` • ${filePath.replace(projectRoot, ".")} → ${classes.join(", ")}`);
|
|
409
474
|
}
|
|
410
475
|
}
|
|
411
|
-
async function buildPluginContextState(projectRoot, devflareConfig, environment) {
|
|
412
|
-
const
|
|
413
|
-
const
|
|
414
|
-
const
|
|
476
|
+
async function buildPluginContextState(projectRoot, devflareConfig, environment, mode = "serve") {
|
|
477
|
+
const effectiveConfig = mode === "build" ? await resolveConfigResources(devflareConfig, { environment }) : resolveConfigForLocalRuntime(devflareConfig, environment);
|
|
478
|
+
const compiledWranglerConfig = compileConfig(effectiveConfig);
|
|
479
|
+
const wranglerConfig = mode === "build" ? isolateViteBuildOutputPaths(projectRoot, compiledWranglerConfig) : compiledWranglerConfig;
|
|
480
|
+
const cloudflareConfig = {
|
|
481
|
+
...mode === "build" ? isolateViteBuildOutputPaths(projectRoot, compileToProgrammaticConfig(effectiveConfig)) : compileToProgrammaticConfig(effectiveConfig)
|
|
482
|
+
};
|
|
483
|
+
const composedMainEntry = mode === "build" ? null : await prepareComposedWorkerEntrypoint(projectRoot, effectiveConfig, environment);
|
|
415
484
|
if (composedMainEntry) {
|
|
416
485
|
wranglerConfig.main = composedMainEntry;
|
|
417
486
|
cloudflareConfig.main = composedMainEntry;
|
|
418
487
|
}
|
|
419
488
|
let durableObjects = null;
|
|
420
489
|
let auxiliaryWorkerConfig = null;
|
|
421
|
-
const doPatternConfig =
|
|
490
|
+
const doPatternConfig = effectiveConfig.files?.durableObjects;
|
|
422
491
|
const doPattern = typeof doPatternConfig === "string" ? doPatternConfig : DEFAULT_DO_PATTERN;
|
|
423
492
|
if (doPatternConfig !== false) {
|
|
424
493
|
const doWorkerName = `${wranglerConfig.name}-do`;
|
|
@@ -447,10 +516,10 @@ async function buildPluginContextState(projectRoot, devflareConfig, environment)
|
|
|
447
516
|
};
|
|
448
517
|
}
|
|
449
518
|
async function ensureGeneratedConfigDir(projectRoot) {
|
|
450
|
-
const configDir =
|
|
519
|
+
const configDir = resolve3(projectRoot, CONFIG_DIR);
|
|
451
520
|
const fs = await import("node:fs/promises");
|
|
452
521
|
await fs.mkdir(configDir, { recursive: true });
|
|
453
|
-
const gitignorePath =
|
|
522
|
+
const gitignorePath = resolve3(configDir, ".gitignore");
|
|
454
523
|
try {
|
|
455
524
|
await fs.access(gitignorePath);
|
|
456
525
|
} catch {
|
|
@@ -461,17 +530,12 @@ async function ensureGeneratedConfigDir(projectRoot) {
|
|
|
461
530
|
}
|
|
462
531
|
async function writeGeneratedWranglerConfig(projectRoot, wranglerConfig) {
|
|
463
532
|
const configDir = await ensureGeneratedConfigDir(projectRoot);
|
|
464
|
-
const wranglerFileConfig =
|
|
465
|
-
...wranglerConfig,
|
|
466
|
-
...wranglerConfig.main && {
|
|
467
|
-
main: rebaseMainPathForConfigDir(projectRoot, configDir, wranglerConfig.main)
|
|
468
|
-
}
|
|
469
|
-
};
|
|
533
|
+
const wranglerFileConfig = rebaseWranglerConfigPaths(projectRoot, configDir, wranglerConfig);
|
|
470
534
|
await writeWranglerConfig(configDir, wranglerFileConfig, "wrangler.jsonc");
|
|
471
535
|
}
|
|
472
536
|
async function resolvePluginConfigPath(projectRoot, configPath) {
|
|
473
537
|
if (configPath) {
|
|
474
|
-
return isAbsolute(configPath) ? configPath :
|
|
538
|
+
return isAbsolute(configPath) ? configPath : resolve3(projectRoot, configPath);
|
|
475
539
|
}
|
|
476
540
|
return await resolveConfigPath(projectRoot) ?? null;
|
|
477
541
|
}
|
|
@@ -568,7 +632,7 @@ export default { fetch: () => new Response("No DOs") }`;
|
|
|
568
632
|
cwd: projectRoot,
|
|
569
633
|
configFile: configPath
|
|
570
634
|
});
|
|
571
|
-
const pluginState = await buildPluginContextState(projectRoot, devflareConfig, environment);
|
|
635
|
+
const pluginState = await buildPluginContextState(projectRoot, devflareConfig, environment, config.command === "build" ? "build" : "serve");
|
|
572
636
|
Object.assign(pluginContext, {
|
|
573
637
|
projectRoot,
|
|
574
638
|
...pluginState
|
|
@@ -594,7 +658,7 @@ export default { fetch: () => new Response("No DOs") }`;
|
|
|
594
658
|
configureServer(server) {
|
|
595
659
|
if (!watchConfig)
|
|
596
660
|
return;
|
|
597
|
-
const fullConfigPath = resolvedPluginConfigPath ??
|
|
661
|
+
const fullConfigPath = resolvedPluginConfigPath ?? resolve3(projectRoot, configPath || "devflare.config.ts");
|
|
598
662
|
server.watcher.add(fullConfigPath);
|
|
599
663
|
server.watcher.on("change", async (changedPath) => {
|
|
600
664
|
if (changedPath === fullConfigPath) {
|
|
@@ -604,7 +668,7 @@ export default { fetch: () => new Response("No DOs") }`;
|
|
|
604
668
|
cwd: projectRoot,
|
|
605
669
|
configFile: configPath
|
|
606
670
|
});
|
|
607
|
-
const pluginState = await buildPluginContextState(projectRoot, devflareConfig, environment);
|
|
671
|
+
const pluginState = await buildPluginContextState(projectRoot, devflareConfig, environment, "serve");
|
|
608
672
|
Object.assign(pluginContext, {
|
|
609
673
|
projectRoot,
|
|
610
674
|
...pluginState
|
|
@@ -655,12 +719,13 @@ export default { fetch: () => new Response("No DOs") }`;
|
|
|
655
719
|
}
|
|
656
720
|
async function getCloudflareConfig(options = {}) {
|
|
657
721
|
const cwd = options.cwd ?? process.cwd();
|
|
658
|
-
const devflareConfig = await
|
|
722
|
+
const devflareConfig = await loadResolvedConfig({
|
|
659
723
|
cwd,
|
|
660
|
-
configFile: options.configPath
|
|
724
|
+
configFile: options.configPath,
|
|
725
|
+
environment: options.environment
|
|
661
726
|
});
|
|
662
|
-
const composedMainEntry = await prepareComposedWorkerEntrypoint(cwd, devflareConfig
|
|
663
|
-
const cloudflareConfig = compileToProgrammaticConfig(devflareConfig
|
|
727
|
+
const composedMainEntry = await prepareComposedWorkerEntrypoint(cwd, devflareConfig);
|
|
728
|
+
const cloudflareConfig = compileToProgrammaticConfig(devflareConfig);
|
|
664
729
|
if (composedMainEntry) {
|
|
665
730
|
cloudflareConfig.main = composedMainEntry;
|
|
666
731
|
}
|
|
@@ -668,12 +733,13 @@ async function getCloudflareConfig(options = {}) {
|
|
|
668
733
|
}
|
|
669
734
|
async function getDevflareConfigs(options = {}) {
|
|
670
735
|
const cwd = options.cwd ?? process.cwd();
|
|
671
|
-
const devflareConfig = await
|
|
736
|
+
const devflareConfig = await loadResolvedConfig({
|
|
672
737
|
cwd,
|
|
673
|
-
configFile: options.configPath
|
|
738
|
+
configFile: options.configPath,
|
|
739
|
+
environment: options.environment
|
|
674
740
|
});
|
|
675
|
-
const composedMainEntry = await prepareComposedWorkerEntrypoint(cwd, devflareConfig
|
|
676
|
-
const wranglerConfig = compileConfig(devflareConfig
|
|
741
|
+
const composedMainEntry = await prepareComposedWorkerEntrypoint(cwd, devflareConfig);
|
|
742
|
+
const wranglerConfig = compileConfig(devflareConfig);
|
|
677
743
|
const cloudflareConfig = { ...wranglerConfig };
|
|
678
744
|
if (composedMainEntry) {
|
|
679
745
|
wranglerConfig.main = composedMainEntry;
|
|
@@ -698,7 +764,6 @@ async function getDevflareConfigs(options = {}) {
|
|
|
698
764
|
return { cloudflareConfig, auxiliaryWorkers };
|
|
699
765
|
}
|
|
700
766
|
// src/vite/config-file.ts
|
|
701
|
-
import { loadConfigFromFile, mergeConfig } from "vite";
|
|
702
767
|
var CONFIG_DIR2 = ".devflare";
|
|
703
768
|
var GENERATED_VITE_CONFIG_FILENAME = "vite.config.mjs";
|
|
704
769
|
function hasInlineViteConfig(viteConfig) {
|
|
@@ -714,30 +779,34 @@ function resolveEffectiveViteProject(detection, config, environment) {
|
|
|
714
779
|
wantsViteIntegration: detection.wantsViteIntegration || hasDevflareConfig
|
|
715
780
|
};
|
|
716
781
|
}
|
|
717
|
-
function
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
return
|
|
782
|
+
function isPromiseLike(value) {
|
|
783
|
+
return (typeof value === "object" || typeof value === "function") && value !== null && typeof value.then === "function";
|
|
784
|
+
}
|
|
785
|
+
function normalizePluginOptions(pluginOption) {
|
|
786
|
+
if (typeof pluginOption === "undefined") {
|
|
787
|
+
return [];
|
|
723
788
|
}
|
|
724
|
-
|
|
725
|
-
|
|
789
|
+
return Array.isArray(pluginOption) ? pluginOption : [pluginOption];
|
|
790
|
+
}
|
|
791
|
+
function removePluginByName(pluginOption, pluginName) {
|
|
792
|
+
if (Array.isArray(pluginOption)) {
|
|
793
|
+
const filteredPlugins = pluginOption.map((nestedPlugin) => removePluginByName(nestedPlugin, pluginName)).filter((nestedPlugin) => typeof nestedPlugin !== "undefined");
|
|
794
|
+
return filteredPlugins.length > 0 ? filteredPlugins : undefined;
|
|
726
795
|
}
|
|
727
|
-
if (typeof pluginOption
|
|
728
|
-
return
|
|
796
|
+
if (!pluginOption || typeof pluginOption === "boolean" || isPromiseLike(pluginOption)) {
|
|
797
|
+
return pluginOption;
|
|
729
798
|
}
|
|
730
|
-
|
|
731
|
-
return plugins;
|
|
799
|
+
return pluginOption.name === pluginName ? undefined : pluginOption;
|
|
732
800
|
}
|
|
733
801
|
function withInjectedDevflarePlugin(config, pluginOptions) {
|
|
734
|
-
const existingPlugins =
|
|
802
|
+
const existingPlugins = normalizePluginOptions(config.plugins).map((pluginOption) => removePluginByName(pluginOption, "devflare")).filter((pluginOption) => typeof pluginOption !== "undefined");
|
|
735
803
|
return {
|
|
736
804
|
...config,
|
|
737
805
|
plugins: [devflarePlugin(pluginOptions), ...existingPlugins]
|
|
738
806
|
};
|
|
739
807
|
}
|
|
740
808
|
async function resolveViteUserConfig(configEnv, options = {}) {
|
|
809
|
+
const { loadConfigFromFile, mergeConfig } = await import("vite");
|
|
741
810
|
const cwd = options.cwd ?? process.cwd();
|
|
742
811
|
const devflareConfig = await loadConfig({
|
|
743
812
|
cwd,
|
|
@@ -759,10 +828,10 @@ async function resolveViteUserConfig(configEnv, options = {}) {
|
|
|
759
828
|
}
|
|
760
829
|
async function ensureGeneratedConfigDir2(cwd) {
|
|
761
830
|
const fs = await import("node:fs/promises");
|
|
762
|
-
const { resolve:
|
|
763
|
-
const configDir =
|
|
831
|
+
const { resolve: resolve4 } = await import("pathe");
|
|
832
|
+
const configDir = resolve4(cwd, CONFIG_DIR2);
|
|
764
833
|
await fs.mkdir(configDir, { recursive: true });
|
|
765
|
-
const gitignorePath =
|
|
834
|
+
const gitignorePath = resolve4(configDir, ".gitignore");
|
|
766
835
|
try {
|
|
767
836
|
await fs.access(gitignorePath);
|
|
768
837
|
} catch {
|
|
@@ -771,13 +840,46 @@ async function ensureGeneratedConfigDir2(cwd) {
|
|
|
771
840
|
}
|
|
772
841
|
return configDir;
|
|
773
842
|
}
|
|
843
|
+
async function resolveDevflarePackageRoot(currentFilePath) {
|
|
844
|
+
const fs = await import("node:fs/promises");
|
|
845
|
+
const { dirname: dirname2 } = await import("node:path");
|
|
846
|
+
const { resolve: resolve4 } = await import("pathe");
|
|
847
|
+
let currentDir = dirname2(currentFilePath);
|
|
848
|
+
while (true) {
|
|
849
|
+
const packageJsonPath = resolve4(currentDir, "package.json");
|
|
850
|
+
try {
|
|
851
|
+
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf-8"));
|
|
852
|
+
if (packageJson.name === "devflare") {
|
|
853
|
+
return currentDir;
|
|
854
|
+
}
|
|
855
|
+
} catch {}
|
|
856
|
+
const parentDir = dirname2(currentDir);
|
|
857
|
+
if (parentDir === currentDir) {
|
|
858
|
+
break;
|
|
859
|
+
}
|
|
860
|
+
currentDir = parentDir;
|
|
861
|
+
}
|
|
862
|
+
throw new Error("Could not resolve the devflare package root for generated Vite config imports.");
|
|
863
|
+
}
|
|
864
|
+
async function resolveGeneratedViteImportPath(configDir) {
|
|
865
|
+
const { extname, sep } = await import("node:path");
|
|
866
|
+
const { fileURLToPath } = await import("node:url");
|
|
867
|
+
const { relative: relative3, resolve: resolve4 } = await import("pathe");
|
|
868
|
+
const currentFilePath = fileURLToPath(import.meta.url);
|
|
869
|
+
const currentExtension = extname(currentFilePath);
|
|
870
|
+
const packageRoot = await resolveDevflarePackageRoot(currentFilePath);
|
|
871
|
+
const viteEntryPath = currentFilePath.includes(`${sep}dist${sep}`) ? resolve4(packageRoot, "dist/src/vite/index.js") : resolve4(packageRoot, `src/vite/index${currentExtension}`);
|
|
872
|
+
const relativeImportPath = relative3(configDir, viteEntryPath);
|
|
873
|
+
return relativeImportPath.startsWith(".") ? relativeImportPath : `./${relativeImportPath}`;
|
|
874
|
+
}
|
|
774
875
|
async function writeGeneratedViteConfig(options) {
|
|
775
876
|
const fs = await import("node:fs/promises");
|
|
776
|
-
const { resolve:
|
|
877
|
+
const { resolve: resolve4 } = await import("pathe");
|
|
777
878
|
const configDir = await ensureGeneratedConfigDir2(options.cwd);
|
|
778
|
-
const generatedConfigPath =
|
|
879
|
+
const generatedConfigPath = resolve4(configDir, GENERATED_VITE_CONFIG_FILENAME);
|
|
880
|
+
const viteImportPath = await resolveGeneratedViteImportPath(configDir);
|
|
779
881
|
const content = `import { defineConfig } from 'vite'
|
|
780
|
-
import { resolveViteUserConfig } from
|
|
882
|
+
import { resolveViteUserConfig } from ${JSON.stringify(viteImportPath)}
|
|
781
883
|
|
|
782
884
|
export default defineConfig(async (env) => {
|
|
783
885
|
return await resolveViteUserConfig(env, {
|
|
@@ -792,4 +894,4 @@ export default defineConfig(async (env) => {
|
|
|
792
894
|
await fs.writeFile(generatedConfigPath, content, "utf-8");
|
|
793
895
|
return generatedConfigPath;
|
|
794
896
|
}
|
|
795
|
-
export { prepareComposedWorkerEntrypoint, getPluginContext, devflarePlugin, getCloudflareConfig, getDevflareConfigs, hasInlineViteConfig, resolveEffectiveViteProject, resolveViteUserConfig, writeGeneratedViteConfig };
|
|
897
|
+
export { DEFAULT_FETCH_ENTRY_FILES, DEFAULT_QUEUE_ENTRY_FILES, DEFAULT_SCHEDULED_ENTRY_FILES, DEFAULT_EMAIL_ENTRY_FILES, resolveWorkerSurfacePaths, hasWorkerSurfacePaths, prepareComposedWorkerEntrypoint, getPluginContext, devflarePlugin, getCloudflareConfig, getDevflareConfigs, hasInlineViteConfig, resolveEffectiveViteProject, resolveViteUserConfig, writeGeneratedViteConfig };
|