void 1.12.1 → 1.13.0
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/README.md +1 -0
- package/dist/{account-cmd-BU1Fy_Bf.mjs → account-cmd-4fQiXYX7.mjs} +6 -6
- package/dist/{application-analysis-DVeN8yoi.mjs → application-analysis-BjEwHTV2.mjs} +19 -13
- package/dist/{application-routing-KKw4Y84h.mjs → application-routing-COCfD2yc.mjs} +1 -1
- package/dist/args-DrnTI35r.mjs +88 -0
- package/dist/args-MnQnqypt.mjs +1 -0
- package/dist/{auth-CqwJwItO.mjs → auth-CeBmolb-.mjs} +3 -3
- package/dist/{auth-A7cZ8aXA.mjs → auth-CvaDxOMi.mjs} +1 -1
- package/dist/{auth-link-Duu2NvN5.mjs → auth-link-I4omV0pL.mjs} +6 -6
- package/dist/{auth-router-vgtOdb9j.mjs → auth-router-CXq4q7bb.mjs} +6 -5
- package/dist/{better-auth-shared-BS3pDQbT.d.mts → better-auth-shared-CrIkcN8I.d.mts} +2 -1
- package/dist/bindings-C7zOgxT3.d.mts +28 -0
- package/dist/browser-run-BKgZVwLk.mjs +124 -0
- package/dist/{build-cmd-B7OJ0U5R.mjs → build-cmd-Biz6u4rn.mjs} +6 -6
- package/dist/{cache-wSpi3aeM.mjs → cache-WkLMUrjQ.mjs} +6 -6
- package/dist/{cancel-deploy-DMWzkAlb.mjs → cancel-deploy-BRsrmyTk.mjs} +6 -5
- package/dist/{cf-access-DHklo7Rg.mjs → cf-access-B21j-nd6.mjs} +1 -1
- package/dist/{cf-build-output-Cso7Vh-t.mjs → cf-build-output-G-7Tdd8b.mjs} +6 -5
- package/dist/cf-build-output-Qc43LWzE.mjs +1 -0
- package/dist/{cf-command-values-5BPBRc9Z.mjs → cf-command-values-cUnJwCyG.mjs} +24 -1
- package/dist/{cf-config-migrate-D271BTiw.mjs → cf-config-migrate-CsbQGzMf.mjs} +200 -94
- package/dist/cf-user-agent-HHTRzfud.mjs +15 -0
- package/dist/cf-version-api-BWHMVtzw.mjs +1 -0
- package/dist/cf-version-api-XEEK2B9A.mjs +856 -0
- package/dist/cf-worker-settings-DJKdy97k.mjs +127 -0
- package/dist/cli/cli.mjs +1 -1
- package/dist/cli/cloudflare-operation-process.mjs +111 -47
- package/dist/cli/env-schema-probe.mjs +3 -3
- package/dist/cli/json-command-process.d.mts +6 -0
- package/dist/cli/json-command-process.mjs +91 -0
- package/dist/{cli-main-BrChcpE3.mjs → cli-main-CJTGhcYN.mjs} +84 -113
- package/dist/{client-eLZwqkPH.mjs → client-0um7Lzze.mjs} +1 -1
- package/dist/{client-DE2m2ldh.mjs → client-BEHI4UWn.mjs} +14 -8
- package/dist/{cloudflare-auth-eWfhdZCk.mjs → cloudflare-auth-iOgRurWm.mjs} +1 -1
- package/dist/{cloudflare-cmd-SsFlJe2B.mjs → cloudflare-cmd-DsSlXbNy.mjs} +5 -5
- package/dist/{cloudflare-config-D9UFH_A5.mjs → cloudflare-config-KPHKf57C.mjs} +2 -2
- package/dist/{cloudflare-connect-BgpHcSg3.mjs → cloudflare-connect-bEtneBjT.mjs} +5 -4
- package/dist/{cloudflare-operations-ByjFGats.mjs → cloudflare-operations-BmICrRnm.mjs} +1 -1
- package/dist/{cloudflare-operations-BIRQkYwL.mjs → cloudflare-operations-D-9psgPQ.mjs} +19 -11
- package/dist/cloudflare-preview-8eLSQPdO.mjs +1 -0
- package/dist/cloudflare-preview-BaeU-m74.mjs +112 -0
- package/dist/{cloudflare-process-60r4Z2Zf.mjs → cloudflare-process-DFNpqV_m.mjs} +57 -29
- package/dist/cloudflare-user-output-DFbD0l4l.mjs +36 -0
- package/dist/collect-Aam0GwAU.mjs +1 -0
- package/dist/{collect-rNLybAnF.mjs → collect-KC4cizWM.mjs} +6 -1
- package/dist/{config-DA6ZbLXO.d.mts → config-BdmM5ZzP.d.mts} +12 -2
- package/dist/{config-BFX5ZB1J.mjs → config-CUYGZqdN.mjs} +2 -2
- package/dist/{config-BSoW3QCB.mjs → config-C_UjzkVS.mjs} +3 -3
- package/dist/{config-DtjrUtPo.mjs → config-Ge-MytMU.mjs} +1 -1
- package/dist/{config-Dv5jri1-.mjs → config-KZAiI3gG.mjs} +32 -6
- package/dist/config-entry.d.mts +1 -1
- package/dist/config-write-dKLINlm2.mjs +80 -0
- package/dist/{connect-D0V0o40j.mjs → connect-Bqq3b9sX.mjs} +10 -9
- package/dist/{create-project-CbuDH5Hv.mjs → create-project-MXoP_rte.mjs} +1 -1
- package/dist/{create-project-8FdN6D2i.mjs → create-project-T-9AIQDe.mjs} +7 -6
- package/dist/{db-BNPIjLkK.mjs → db-B3eoVDNA.mjs} +50 -47
- package/dist/{db-args-CiQVg8SJ.mjs → db-args-BcvTZ8KE.mjs} +1 -1
- package/dist/db-args-Cx1y4vZn.mjs +1 -0
- package/dist/{db-types-B4Cf9dzR.mjs → db-types-BpgXVtQZ.mjs} +1 -1
- package/dist/{delete-WtLEfap2.mjs → delete-Cf6SroAw.mjs} +7 -6
- package/dist/deploy-DZ9j7MC4.mjs +2 -0
- package/dist/{deploy-BgSbagIP.mjs → deploy-UojYUEWr.mjs} +803 -1415
- package/dist/{deploy-managed-static-BWBsxOww.mjs → deploy-managed-static-DV_OmTWf.mjs} +54 -393
- package/dist/{deploy-security-notice-IRGy6Edf.mjs → deploy-security-notice-3jX71IeP.mjs} +6 -4
- package/dist/deploy-summary-Dkl0zvQy.mjs +377 -0
- package/dist/{deploy-transport-BKP_oV9q.mjs → deploy-transport-4ISWxx8n.mjs} +4 -3
- package/dist/deploy.mjs +14 -10
- package/dist/discover-BZWVWeQs.mjs +1 -0
- package/dist/{discover-IcspacCg.mjs → discover-BeFs7OPS.mjs} +1 -1
- package/dist/{dispatch-DIhDA3NI.mjs → dispatch-BUKbPdqb.mjs} +7 -7
- package/dist/{dist-Cr_xGE_K.mjs → dist-BngS28id.mjs} +6 -6
- package/dist/{dist-C47zy_kJ.mjs → dist-x99fIj4n.mjs} +1 -1
- package/dist/{domain-mweyYXSw.mjs → domain-BK6NWkWK.mjs} +7 -7
- package/dist/{drizzle-BJDMPrj7.mjs → drizzle-CnSbVeiZ.mjs} +12 -13
- package/dist/{drizzle-CQ5jWuDL.mjs → drizzle-CrkwVwK8.mjs} +1 -1
- package/dist/{email-DcQNP40O.mjs → email-BBSDV0J5.mjs} +13 -12
- package/dist/{email-cloudflare-DeYH3Ke7.mjs → email-cloudflare-C-guKEbz.mjs} +10 -8
- package/dist/{env-DaAoYR2-.mjs → env-BVnKiGYJ.mjs} +8 -8
- package/dist/{env-EjHqc7m9.mjs → env-CU2tMDdO.mjs} +6 -1
- package/dist/{env-types-D2hBodXP.mjs → env-types-B33fEHRH.mjs} +1 -1
- package/dist/{env-validation-j9pjCDfA.mjs → env-validation-BnAsx6gz.mjs} +1 -1
- package/dist/{env-validation-D-v5_CWL.mjs → env-validation-SXsjd6-Z.mjs} +4 -4
- package/dist/{fetch-CiEsvjpP.mjs → fetch-DL7OCgwB.mjs} +1 -1
- package/dist/{fetch-stream-BIG5lHW6.mjs → fetch-stream-DEilLTCc.mjs} +2 -2
- package/dist/{gen-aOtHhZLD.mjs → gen-BxuIN1bz.mjs} +10 -9
- package/dist/gen-DaayFP9v.mjs +1 -0
- package/dist/{generate-Dq2Bgw75.mjs → generate-Ck-L3e0e.mjs} +1 -1
- package/dist/{generate-C3ZAqCy-.mjs → generate-t1dDUYZZ.mjs} +1 -1
- package/dist/{github-cmd-BR19Ffdz.mjs → github-cmd-B7U9Hjmi.mjs} +7 -6
- package/dist/{handler-DCrDLzw2.mjs → handler-2wAywJgj.mjs} +11 -9
- package/dist/{headers-DqBsjDxg.mjs → headers-DPI4MDGC.mjs} +1 -1
- package/dist/{help-DvClCzqL.mjs → help-Bgiu5PMX.mjs} +36 -4
- package/dist/help-DWGHmt_n.mjs +1 -0
- package/dist/html-5sfGLjiI.d.mts +3 -0
- package/dist/html-DPSOBDCh.mjs +1 -0
- package/dist/{index-Dn2mkPr2.d.mts → index-CqF8_p9C.d.mts} +5 -105
- package/dist/index-Cvqotnhc.d.mts +91 -0
- package/dist/{index-BQ5qYiAw.d.mts → index-DAinHkj8.d.mts} +1 -1
- package/dist/{index-8cAgNdb6.d.mts → index-lnEWwVAS.d.mts} +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +536 -170
- package/dist/{info-P6MBiVJi.mjs → info-7COlpAfY.mjs} +32 -20
- package/dist/{init-C8YpkGIP.mjs → init-DftAx3L4.mjs} +237 -88
- package/dist/input-jcps6lAn.mjs +64 -0
- package/dist/interactive-prompts-EK0dilFu.mjs +43 -0
- package/dist/{limits-BCoQLpn3.mjs → limits-3I3VdX2E.mjs} +4 -1
- package/dist/{link-Dyz9IGcM.mjs → link-C3WMNFTG.mjs} +7 -7
- package/dist/{list-VGYBMjmx.mjs → list-K4EGVUZN.mjs} +9 -9
- package/dist/{load-user-env-B8qC0Q2Y.mjs → load-user-env-uMmQJ-Th.mjs} +1 -1
- package/dist/{local-d1-CYOYkVwO.mjs → local-d1-BtLCVC1p.mjs} +2 -2
- package/dist/login-BJwPhV_S.mjs +1 -0
- package/dist/{login-CWFr-G2I.mjs → login-DaugBfBG.mjs} +6 -5
- package/dist/{logs-kS1wuR4b.mjs → logs-BR2szdN5.mjs} +6 -6
- package/dist/migrate-BHD46A31.mjs +1 -0
- package/dist/{migrate-BNZL1hee.mjs → migrate-Dtlg8fC6.mjs} +7 -7
- package/dist/nitro.mjs +3 -3
- package/dist/{node-DVJWfV6s.mjs → node-BbKlLpHa.mjs} +5 -5
- package/dist/{operator-ai-logging-DD0n6zc2.mjs → operator-ai-logging-4Nvs6Ut3.mjs} +5 -5
- package/dist/{operator-args-nvetCWuz.mjs → operator-args-DWvqq3Ws.mjs} +31 -15
- package/dist/{operator-auth-DMvn-y9X.mjs → operator-auth-DtRMGXYY.mjs} +2 -2
- package/dist/{operator-client-dFNnXfyB.mjs → operator-client-BG0VIMMM.mjs} +2 -2
- package/dist/operator-cmd-CR3Q9k4c.mjs +1 -0
- package/dist/{operator-cmd-a7yOf2tH.mjs → operator-cmd-D4YcMKO-.mjs} +9 -9
- package/dist/{operator-security-D5MToU0p.mjs → operator-security-nVLo8vDt.mjs} +11 -5
- package/dist/{output-BZLnu0z8.mjs → output-DhJgS6Ve.mjs} +1 -1
- package/dist/output-OYwcEwok.mjs +1 -0
- package/dist/pages/client.d.mts +34 -20
- package/dist/pages/client.mjs +172 -74
- package/dist/pages/index.d.mts +11 -4
- package/dist/pages/index.mjs +5 -5
- package/dist/pages/islands-plugin.d.mts +2 -2
- package/dist/pages/islands-plugin.mjs +5 -3
- package/dist/pages/protocol.d.mts +3 -3
- package/dist/pages/protocol.mjs +3 -3
- package/dist/pages/serialize.d.mts +2 -2
- package/dist/pages/serialize.mjs +1 -1
- package/dist/parse-filename-DIPUjoCh.d.mts +2 -0
- package/dist/platform-C3Q44RJ8.mjs +250 -0
- package/dist/platform-args-BSyVZESg.mjs +1 -0
- package/dist/{platform-args-CvZSuhYS.mjs → platform-args-BnocJDC_.mjs} +1 -1
- package/dist/{platform-auth-config-CpszX-Ne.mjs → platform-auth-config-BbfNhjBc.mjs} +9 -9
- package/dist/{platform-auth-protection-DA6Tw8Og.mjs → platform-auth-protection-BHPV4MUf.mjs} +9 -8
- package/dist/{platform-auth-recovery-Cztrb1JC.mjs → platform-auth-recovery-DE0nArYy.mjs} +8 -7
- package/dist/{platform-cmd-m6Asj6nO.mjs → platform-cmd-CLRU3BRb.mjs} +11 -10
- package/dist/{platform-cmd-u1j88ggF.mjs → platform-cmd-Cs2LkT5L.mjs} +1 -1
- package/dist/{platform-discovery-CLxtixHJ.mjs → platform-discovery-CKeeeD82.mjs} +1 -1
- package/dist/{platform-domain-DJSznNTA.mjs → platform-domain-kn3WuKPG.mjs} +6 -5
- package/dist/{platform-lifecycle-BC-9p58d.mjs → platform-lifecycle-BoCEYy2w.mjs} +1 -1
- package/dist/{platform-lifecycle-GFeXv3NC.mjs → platform-lifecycle-CKwOg8wz.mjs} +244 -104
- package/dist/{platform-management-BwHkz46V.mjs → platform-management-CaSdFthX.mjs} +1 -1
- package/dist/{platform-management-DX1zINou.mjs → platform-management-fyrsq2Ra.mjs} +27 -14
- package/dist/{platform-plans-config-DiydtNKY.mjs → platform-plans-config-BSI-6Inu.mjs} +11 -5
- package/dist/{platform-recovery-CnzBbudV.mjs → platform-recovery-PwJ54AIZ.mjs} +3 -3
- package/dist/{platform-registry-DHH6fivm.mjs → platform-registry-zHH3RiIm.mjs} +2 -1
- package/dist/{platform-setup-Lph9i-rh.mjs → platform-setup-DwYITHfY.mjs} +3 -3
- package/dist/{plugin-inference-COlq96WJ.mjs → plugin-inference-D5MjBVMB.mjs} +60 -142
- package/dist/prepare-CLl_TA_r.mjs +1 -0
- package/dist/{prepare-WvijE289.mjs → prepare-DZEs5AGr.mjs} +3 -3
- package/dist/{prepare-co1o1FFd.mjs → prepare-DhVzN7CB.mjs} +14 -12
- package/dist/{project-uXKua1it.mjs → project-BXpm-vgG.mjs} +1 -1
- package/dist/{project-dh9431bN.mjs → project-DC-BqHef.mjs} +1 -1
- package/dist/{project-cmd-BWJTplpc.mjs → project-cmd-BKN3qT4R.mjs} +31 -21
- package/dist/{project-paths-2ENfCCih.mjs → project-paths-BeAxxqGh.mjs} +1 -1
- package/dist/{project-security-BV1xfj1K.mjs → project-security-B-SHxprt.mjs} +1 -1
- package/dist/{project-security-CY_aahvW.mjs → project-security-BWTd6cTU.mjs} +87 -46
- package/dist/{project-team-BlIFXlmT.mjs → project-team-jcn9reIB.mjs} +6 -6
- package/dist/{project-token-CMsB7I1-.mjs → project-token-BHkBKtzt.mjs} +6 -6
- package/dist/{project-tsconfig-BOA4ym99.mjs → project-tsconfig-LjgxDdj_.mjs} +1 -1
- package/dist/{project-zero-trust-BI6pdpx4.mjs → project-zero-trust-2t_qI6xa.mjs} +4 -4
- package/dist/{protocol-4rEnumif.mjs → protocol-DhMbnxzy.mjs} +120 -35
- package/dist/{protocol-ERy-n3jf.d.mts → protocol-wG7JP5Mm.d.mts} +27 -4
- package/dist/{provision-DFv7SJDn.mjs → provision-C04aXE3a.mjs} +1 -1
- package/dist/{provision-Bh44omGA.mjs → provision-CQykn8gu.mjs} +8 -4
- package/dist/{redirect-Dyvuil0Q.mjs → redirect-DjyA_hx_.mjs} +1 -1
- package/dist/{requests-CfmJxNYg.mjs → requests-BznxnxTT.mjs} +5 -5
- package/dist/resolve-project-Bob_rEi2.mjs +1 -0
- package/dist/{resolve-project-8WZ3iVmr.mjs → resolve-project-s_FGWyr-.mjs} +2 -2
- package/dist/resource-binding-5nI30acw.mjs +20 -0
- package/dist/{resource-name-DlJ9QXzg.mjs → resource-name-D_gw36kh.mjs} +5 -1
- package/dist/{rollback-DL5HuAsM.mjs → rollback-CLiINtpt.mjs} +25 -14
- package/dist/{route-types-CSed9-Dp.mjs → route-types-DxvqN5bL.mjs} +59 -9
- package/dist/{route-url-B41eQ8QI.mjs → route-url-CRC8yR_2.mjs} +2 -3
- package/dist/{route-url-Bd6IX-JZ.d.mts → route-url-zDfC-7DD.d.mts} +33 -5
- package/dist/routes-stub.d.mts +18 -2
- package/dist/routes-stub.mjs +1 -1
- package/dist/{runner-CeguHWJx.mjs → runner-CnUrhc8H.mjs} +1 -1
- package/dist/{runner-mysql-DOjbj-N1.mjs → runner-mysql-CW6bFa67.mjs} +1 -1
- package/dist/{runner-mysql-D549vGGm.mjs → runner-mysql-DSLGFOlC.mjs} +1 -1
- package/dist/{runner-pg-Buzw17hl.mjs → runner-pg-BcGF7iBR.mjs} +1 -1
- package/dist/{runner-pg-DMJquR3d.mjs → runner-pg-OeP0JpEo.mjs} +1 -1
- package/dist/{runner-Bf94YVJK.mjs → runner-rnXCGa20.mjs} +1 -1
- package/dist/runtime/ai/index.mjs +1 -1
- package/dist/runtime/auth/better-auth-d1.d.mts +1 -1
- package/dist/runtime/auth/better-auth-mysql.d.mts +1 -1
- package/dist/runtime/auth/better-auth-postgres.d.mts +1 -1
- package/dist/runtime/client/fetch-server.mjs +1 -1
- package/dist/runtime/client/fetch-stream.mjs +1 -1
- package/dist/runtime/client/fetch.mjs +1 -1
- package/dist/runtime/client/index.mjs +2 -2
- package/dist/runtime/client/react.mjs +2 -2
- package/dist/runtime/client/solid.mjs +2 -2
- package/dist/runtime/client/svelte.mjs +2 -2
- package/dist/runtime/client/vue.mjs +2 -2
- package/dist/runtime/durable/index.mjs +11 -26
- package/dist/runtime/env/runtime.d.mts +2 -10
- package/dist/runtime/handler/index.d.mts +3 -2
- package/dist/runtime/handler/index.mjs +2 -2
- package/dist/runtime/handler/validator.d.mts +1 -1
- package/dist/runtime/handler/validator.mjs +1 -1
- package/dist/runtime/html.d.mts +2 -0
- package/dist/runtime/html.mjs +1 -0
- package/dist/runtime/image/index.d.mts +103 -0
- package/dist/runtime/image/index.mjs +89 -0
- package/dist/runtime/jsx/index.d.mts +3 -0
- package/dist/runtime/jsx/index.mjs +2 -0
- package/dist/runtime/jsx/jsx-dev-runtime.d.mts +1 -0
- package/dist/runtime/jsx/jsx-dev-runtime.mjs +2 -0
- package/dist/runtime/jsx/jsx-runtime.d.mts +1 -0
- package/dist/runtime/jsx/jsx-runtime.mjs +2 -0
- package/dist/runtime/limits/index.mjs +1 -1
- package/dist/runtime/live/client.d.mts +2 -2
- package/dist/runtime/live/index.d.mts +1 -1
- package/dist/runtime/routing/index.d.mts +87 -4
- package/dist/runtime/routing/index.mjs +59 -20
- package/dist/runtime/routing/route-url.d.mts +2 -2
- package/dist/runtime/routing/route-url.mjs +1 -1
- package/dist/runtime/sandbox/index.mjs +1 -1
- package/dist/runtime/sse/client.d.mts +1 -1
- package/dist/runtime/workflows/entry.d.mts +8 -0
- package/dist/runtime/workflows/entry.mjs +49 -0
- package/dist/runtime/workflows/index.d.mts +3 -0
- package/dist/runtime/workflows/index.mjs +77 -0
- package/dist/runtime/ws/index.d.mts +1 -1
- package/dist/runtime/ws/index.mjs +2 -2
- package/dist/runtime/ws/room.d.mts +1 -1
- package/dist/runtime/ws/server.d.mts +2 -2
- package/dist/runtime-Db72hLY-.d.mts +11 -0
- package/dist/scan-BxhB4BA-.mjs +946 -0
- package/dist/scan-D2ISAobj.mjs +308 -0
- package/dist/{secret-C-WBaUSS.mjs → secret-Ck9N5xbU.mjs} +9 -8
- package/dist/{security-sarif-ClyYwtAW.mjs → security-sarif-DzTIqNwZ.mjs} +1 -1
- package/dist/{serialize-DN-envGQ.d.mts → serialize-Dr9B-0yV.d.mts} +10 -1
- package/dist/{serialize-BmB4BfKu.mjs → serialize-nW4IeEBI.mjs} +23 -2
- package/dist/{skills-C-csz78e.mjs → skills-BR7YHAF7.mjs} +1 -1
- package/dist/{scan-Ct_SEzH4.mjs → source-analysis-cache-Ccm_JSOl.mjs} +340 -902
- package/dist/standard-schema-DvMcZGMK.mjs +8 -0
- package/dist/{subcommand-prompt-B4LOLosl.mjs → subcommand-prompt-AFf2LcrC.mjs} +2 -2
- package/dist/{types-FDH6NuY1.d.mts → types-RYVujNS6.d.mts} +4 -2
- package/dist/{version-metadata-DqgLa6gc.mjs → untrusted-env-4oW0TdBP.mjs} +1 -23
- package/dist/{url-DBQluotE.mjs → url-DAQ1c3lh.mjs} +45 -1
- package/dist/{validate-CtBWCzez.mjs → validate-B1PsQ_mt.mjs} +1 -1
- package/dist/validate-p9b3r1k4.mjs +1 -0
- package/dist/{validation-error-CtcAvyI7.mjs → validation-error-EKI0wMWX.mjs} +2 -2
- package/dist/{validator-Dfh9kCDm.mjs → validator-JJcf9E48.mjs} +5 -8
- package/dist/version-metadata-CEla0kgi.mjs +23 -0
- package/dist/{wrangler-DVe5KV5G.mjs → wrangler-AyMfdVJK.mjs} +34 -69
- package/dist/wrangler-BT7qrzWc.mjs +1 -0
- package/dist/{wrapper-CcMYpOS8.mjs → wrapper-DPlTBVOx.mjs} +5 -5
- package/docs/guide/ai.md +1 -1
- package/docs/guide/app-types.md +6 -23
- package/docs/guide/auth.md +2 -4
- package/docs/guide/database/d1.md +21 -67
- package/docs/guide/database/mysql.md +8 -0
- package/docs/guide/database/postgresql.md +2 -2
- package/docs/guide/database.md +1 -1
- package/docs/guide/deployment.md +18 -0
- package/docs/guide/edge/prerendering.md +3 -7
- package/docs/guide/edge/redirects.md +1 -1
- package/docs/guide/edge/revalidation.md +8 -17
- package/docs/guide/edge/rewrites.md +1 -1
- package/docs/guide/edge/static-assets.md +10 -22
- package/docs/guide/email/domains.md +3 -1
- package/docs/guide/email/receiving.md +2 -2
- package/docs/guide/email/sending.md +3 -1
- package/docs/guide/env-vars.md +2 -0
- package/docs/guide/image-generation.md +142 -0
- package/docs/guide/index.md +17 -15
- package/docs/guide/jobs.md +2 -4
- package/docs/guide/kv.md +1 -1
- package/docs/guide/og-images.md +83 -0
- package/docs/guide/pages-routing/actions-and-forms.md +6 -4
- package/docs/guide/pages-routing/errors.md +20 -4
- package/docs/guide/pages-routing/head.md +5 -5
- package/docs/guide/pages-routing/islands.md +4 -14
- package/docs/guide/pages-routing/markdown.md +2 -2
- package/docs/guide/pages-routing/overview.md +129 -15
- package/docs/guide/platform/administration/plans.md +47 -16
- package/docs/guide/platform/administration/projects.md +10 -0
- package/docs/guide/platform/administration/security-audits.md +76 -30
- package/docs/guide/platform/administration/zero-trust.md +1 -1
- package/docs/guide/platform/installation/ci.md +0 -4
- package/docs/guide/platform/installation/credentials.md +1 -1
- package/docs/guide/platform/installation/maintenance.md +11 -9
- package/docs/guide/platform/installation/prerequisites.md +3 -1
- package/docs/guide/platform/installation/setup.md +7 -15
- package/docs/guide/platform/installation/uninstall.md +6 -12
- package/docs/guide/project-collaboration.md +1 -4
- package/docs/guide/queues.md +6 -8
- package/docs/guide/quickstart.md +6 -8
- package/docs/guide/sandboxes.md +1 -1
- package/docs/guide/self-hosted-platform.md +4 -7
- package/docs/guide/server-routing.md +5 -3
- package/docs/guide/ssg.md +1 -1
- package/docs/guide/type-safety.md +74 -10
- package/docs/guide/websockets.md +5 -7
- package/docs/guide/workflows.md +122 -0
- package/docs/index.md +2 -3
- package/docs/integrations/agents.md +3 -16
- package/docs/integrations/cloudflare.md +98 -2
- package/docs/integrations/frameworks/analog.md +9 -11
- package/docs/integrations/frameworks/astro.md +16 -17
- package/docs/integrations/frameworks/nuxt.md +11 -13
- package/docs/integrations/frameworks/overview.md +18 -20
- package/docs/integrations/frameworks/react-router.md +55 -6
- package/docs/integrations/frameworks/sveltekit.md +8 -6
- package/docs/integrations/frameworks/tanstack-start.md +10 -6
- package/docs/integrations/hono.md +27 -12
- package/docs/integrations/nodejs-bun-deno.md +10 -2
- package/docs/reference/api/database.md +8 -10
- package/docs/reference/api/env.md +2 -2
- package/docs/reference/api/handlers.md +1 -1
- package/docs/reference/api/html.md +45 -0
- package/docs/reference/api/pages.md +118 -167
- package/docs/reference/api/rewrites.md +5 -5
- package/docs/reference/api/types.md +13 -6
- package/docs/reference/api/workflows.md +48 -0
- package/docs/reference/api.md +7 -1
- package/docs/reference/cli/database.md +22 -10
- package/docs/reference/cli/deploy.md +49 -4
- package/docs/reference/cli/domains.md +7 -3
- package/docs/reference/cli/email.md +3 -1
- package/docs/reference/cli/platform-installation.md +9 -53
- package/docs/reference/cli/platform-security.md +36 -8
- package/docs/reference/cli/platform-users.md +11 -1
- package/docs/reference/cli/platform-zero-trust.md +1 -1
- package/docs/reference/cli/project.md +52 -11
- package/docs/reference/cli/setup.md +8 -10
- package/docs/reference/cli.md +49 -47
- package/docs/reference/config.md +22 -8
- package/docs/reference/resource-inference.md +8 -1
- package/docs/reference/structure.md +5 -0
- package/package.json +52 -25
- package/schema.json +20 -1
- package/skills/void/SKILL.md +60 -54
- package/dist/cf-build-output-Wpk_e5CI.mjs +0 -1
- package/dist/cf-worker-settings-BBdlhm9U.mjs +0 -41
- package/dist/cli/db-execute-process.d.mts +0 -2
- package/dist/cli/db-execute-process.mjs +0 -57
- package/dist/cloudflare-user-output-CCR99eQY.mjs +0 -19
- package/dist/collect-B6nlSnsb.mjs +0 -1
- package/dist/db-args-BvMwAber.mjs +0 -1
- package/dist/deploy-Do6FWqon.mjs +0 -2
- package/dist/discover-D2KGP3cR.mjs +0 -1
- package/dist/entry-Bwb9ev8K.mjs +0 -113
- package/dist/gen-vhBDHs3q.mjs +0 -1
- package/dist/help-fKPzcTJv.mjs +0 -1
- package/dist/isr-config-DiTnL9Tb.mjs +0 -115
- package/dist/login-DECm3e9b.mjs +0 -1
- package/dist/migrate-C9aoWLvY.mjs +0 -1
- package/dist/operator-cmd-CVfK5U0B.mjs +0 -1
- package/dist/output-D7K9TWIA.mjs +0 -1
- package/dist/platform-args-CMwMoiLp.mjs +0 -1
- package/dist/prepare-DcwigRUS.mjs +0 -1
- package/dist/providers-D5P8j_8D.d.mts +0 -5
- package/dist/resolve-project-YsTH-U9I.mjs +0 -1
- package/dist/static-exports-s7P86Ngp.mjs +0 -354
- package/dist/validate-CZYUIfR-.mjs +0 -1
- package/dist/wrangler-Dq269bjx.mjs +0 -1
- package/docs/guide/platform/development/local.md +0 -120
- package/docs/guide/platform/development/runtime.md +0 -115
- package/docs/guide/platform/development/schema-ci.md +0 -44
- package/docs/guide/platform-development.md +0 -16
|
@@ -0,0 +1,856 @@
|
|
|
1
|
+
import { a as join, r as extname, s as relative } from "./dist-DMYe8CZJ.mjs";
|
|
2
|
+
import { n as record } from "./cf-config-migrate-CsbQGzMf.mjs";
|
|
3
|
+
import { n as getVoidUserAgent } from "./cf-user-agent-HHTRzfud.mjs";
|
|
4
|
+
import { t as Buffer } from "./node-buffer-D7kgjaDs.mjs";
|
|
5
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
|
+
import { isDeepStrictEqual } from "node:util";
|
|
8
|
+
import { execFile } from "node:child_process";
|
|
9
|
+
import { getWorkerAssetsDir, getWorkerBundleDir, readBuildOutput } from "@cloudflare/build-output-utils";
|
|
10
|
+
import { convertToWranglerConfig } from "@cloudflare/config";
|
|
11
|
+
import mime from "mime";
|
|
12
|
+
import ignore from "ignore";
|
|
13
|
+
import { setTimeout } from "node:timers/promises";
|
|
14
|
+
// src/cli/cf-version-api.ts
|
|
15
|
+
var CloudflareApiError = class extends Error {
|
|
16
|
+
status;
|
|
17
|
+
code;
|
|
18
|
+
constructor(message, status, code) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.status = status;
|
|
21
|
+
this.code = code;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
/** Worker binding types whose value comes from a secret rather than the build output. */
|
|
25
|
+
function isSecretBindingType(type) {
|
|
26
|
+
return type === "secret" || type === "inherit" || type === "unsafe:inherit";
|
|
27
|
+
}
|
|
28
|
+
function assertUploaderUnchanged(verifyUploader) {
|
|
29
|
+
if (!verifyUploader()) throw new Error("The Cloudflare uploader changed during deployment.");
|
|
30
|
+
}
|
|
31
|
+
function requiredString(value, label) {
|
|
32
|
+
if (typeof value !== "string" || !value) throw new Error(`The Cloudflare ${label} is missing from the verified Worker output.`);
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
function textValue(value, label) {
|
|
36
|
+
if (typeof value !== "string") throw new Error(`The Cloudflare ${label} is missing from the verified Worker output.`);
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
/** Match cf's package collection for uploads that preserve secrets through the JSON API. */
|
|
40
|
+
async function readPackageDependencies(directory) {
|
|
41
|
+
try {
|
|
42
|
+
const pkg = record(JSON.parse(readFileSync(join(directory, "package.json"), "utf8")));
|
|
43
|
+
const declared = {
|
|
44
|
+
...record(pkg?.dependencies),
|
|
45
|
+
...record(pkg?.devDependencies)
|
|
46
|
+
};
|
|
47
|
+
const { getInstalledPackageVersion } = await import("@cloudflare/workers-utils");
|
|
48
|
+
const dependencies = [];
|
|
49
|
+
for (const [name, packageJsonVersion] of Object.entries(declared)) {
|
|
50
|
+
if (dependencies.length >= 200) break;
|
|
51
|
+
if (typeof packageJsonVersion !== "string" || /^(workspace|catalog|file|link):/.test(packageJsonVersion)) continue;
|
|
52
|
+
const installedVersion = getInstalledPackageVersion(name, directory);
|
|
53
|
+
if (installedVersion) dependencies.push({
|
|
54
|
+
name,
|
|
55
|
+
packageJsonVersion,
|
|
56
|
+
installedVersion
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return dependencies.length ? dependencies : void 0;
|
|
60
|
+
} catch {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const moduleContentTypes = /* @__PURE__ */ new Map([
|
|
65
|
+
["esm", "application/javascript+module"],
|
|
66
|
+
["cjs", "application/javascript"],
|
|
67
|
+
["wasm", "application/wasm"],
|
|
68
|
+
["text", "text/plain"],
|
|
69
|
+
["data", "application/octet-stream"],
|
|
70
|
+
["json", "text/plain"],
|
|
71
|
+
["sourcemap", "application/source-map"]
|
|
72
|
+
]);
|
|
73
|
+
function bindingsFromOutput(env, workerName, activeSecrets, explicitSecrets) {
|
|
74
|
+
const inherited = new Map(activeSecrets.bindings.map((binding) => [binding.name, binding.type]));
|
|
75
|
+
const names = /* @__PURE__ */ new Set([
|
|
76
|
+
...Object.keys(env),
|
|
77
|
+
...inherited.keys(),
|
|
78
|
+
...Object.keys(explicitSecrets)
|
|
79
|
+
]);
|
|
80
|
+
const bindings = [];
|
|
81
|
+
for (const name of names) {
|
|
82
|
+
const value = record(env[name]);
|
|
83
|
+
const explicit = explicitSecrets[name];
|
|
84
|
+
if (explicit !== void 0) {
|
|
85
|
+
if (typeof explicit !== "string" || inherited.get(name) === "secret_key" || value && value.type !== "secret") throw new Error(`Cloudflare secret ${name} has an invalid explicit value or binding.`);
|
|
86
|
+
bindings.push({
|
|
87
|
+
name,
|
|
88
|
+
type: "secret_text",
|
|
89
|
+
text: explicit
|
|
90
|
+
});
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (inherited.has(name)) {
|
|
94
|
+
if (value && !isSecretBindingType(value.type)) throw new Error(`Cloudflare secret ${name} conflicts with a Worker binding.`);
|
|
95
|
+
bindings.push({
|
|
96
|
+
name,
|
|
97
|
+
type: "inherit",
|
|
98
|
+
version_id: activeSecrets.versionId
|
|
99
|
+
});
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (!value) throw new Error(`Cloudflare binding ${name} is missing from the Worker output.`);
|
|
103
|
+
switch (value.type) {
|
|
104
|
+
case "text":
|
|
105
|
+
bindings.push({
|
|
106
|
+
name,
|
|
107
|
+
type: "plain_text",
|
|
108
|
+
text: textValue(value.value, name)
|
|
109
|
+
});
|
|
110
|
+
break;
|
|
111
|
+
case "json":
|
|
112
|
+
bindings.push({
|
|
113
|
+
name,
|
|
114
|
+
type: "json",
|
|
115
|
+
json: value.value
|
|
116
|
+
});
|
|
117
|
+
break;
|
|
118
|
+
case "kv":
|
|
119
|
+
bindings.push({
|
|
120
|
+
name,
|
|
121
|
+
type: "kv_namespace",
|
|
122
|
+
namespace_id: requiredString(value.id, name)
|
|
123
|
+
});
|
|
124
|
+
break;
|
|
125
|
+
case "d1":
|
|
126
|
+
bindings.push({
|
|
127
|
+
name,
|
|
128
|
+
type: "d1",
|
|
129
|
+
database_id: requiredString(value.id, name)
|
|
130
|
+
});
|
|
131
|
+
break;
|
|
132
|
+
case "r2":
|
|
133
|
+
bindings.push({
|
|
134
|
+
name,
|
|
135
|
+
type: "r2_bucket",
|
|
136
|
+
bucket_name: requiredString(value.name, name),
|
|
137
|
+
...value.jurisdiction ? { jurisdiction: value.jurisdiction } : {}
|
|
138
|
+
});
|
|
139
|
+
break;
|
|
140
|
+
case "durable-object":
|
|
141
|
+
bindings.push({
|
|
142
|
+
name,
|
|
143
|
+
type: "durable_object_namespace",
|
|
144
|
+
class_name: requiredString(value.exportName, name),
|
|
145
|
+
...value.worker !== workerName ? { script_name: requiredString(value.worker, name) } : {}
|
|
146
|
+
});
|
|
147
|
+
break;
|
|
148
|
+
case "unsafe:durable_object_namespace":
|
|
149
|
+
if (Object.keys(value).some((key) => ![
|
|
150
|
+
"type",
|
|
151
|
+
"class_name",
|
|
152
|
+
"dev"
|
|
153
|
+
].includes(key))) throw new Error(`Cloudflare binding ${name} is not a verified local Durable Object.`);
|
|
154
|
+
bindings.push({
|
|
155
|
+
name,
|
|
156
|
+
type: "durable_object_namespace",
|
|
157
|
+
class_name: requiredString(value.class_name, name)
|
|
158
|
+
});
|
|
159
|
+
break;
|
|
160
|
+
case "queue":
|
|
161
|
+
bindings.push({
|
|
162
|
+
name,
|
|
163
|
+
type: "queue",
|
|
164
|
+
queue_name: requiredString(value.name, name),
|
|
165
|
+
...value.deliveryDelay === void 0 ? {} : { delivery_delay: value.deliveryDelay }
|
|
166
|
+
});
|
|
167
|
+
break;
|
|
168
|
+
case "rate-limit":
|
|
169
|
+
bindings.push({
|
|
170
|
+
name,
|
|
171
|
+
type: "ratelimit",
|
|
172
|
+
namespace_id: requiredString(value.namespace, name),
|
|
173
|
+
simple: value.simple
|
|
174
|
+
});
|
|
175
|
+
break;
|
|
176
|
+
case "ai":
|
|
177
|
+
case "browser":
|
|
178
|
+
case "images":
|
|
179
|
+
bindings.push({
|
|
180
|
+
name,
|
|
181
|
+
type: value.type
|
|
182
|
+
});
|
|
183
|
+
break;
|
|
184
|
+
case "hyperdrive":
|
|
185
|
+
bindings.push({
|
|
186
|
+
name,
|
|
187
|
+
type: "hyperdrive",
|
|
188
|
+
id: requiredString(value.id, name)
|
|
189
|
+
});
|
|
190
|
+
break;
|
|
191
|
+
case "worker":
|
|
192
|
+
bindings.push({
|
|
193
|
+
name,
|
|
194
|
+
type: "service",
|
|
195
|
+
service: requiredString(value.worker, name),
|
|
196
|
+
...value.exportName === void 0 ? {} : { entrypoint: value.exportName },
|
|
197
|
+
...value.props === void 0 ? {} : { props: value.props }
|
|
198
|
+
});
|
|
199
|
+
break;
|
|
200
|
+
case "workflow":
|
|
201
|
+
bindings.push({
|
|
202
|
+
name,
|
|
203
|
+
type: "workflow",
|
|
204
|
+
workflow_name: requiredString(value.name, name),
|
|
205
|
+
...value.worker === workerName ? { class_name: requiredString(value.exportName, name) } : { script_name: requiredString(value.worker, name) }
|
|
206
|
+
});
|
|
207
|
+
break;
|
|
208
|
+
case "send-email":
|
|
209
|
+
bindings.push({
|
|
210
|
+
name,
|
|
211
|
+
type: "send_email",
|
|
212
|
+
...value.destinationAddress === void 0 ? {} : { destination_address: value.destinationAddress },
|
|
213
|
+
...value.allowedDestinationAddresses === void 0 ? {} : { allowed_destination_addresses: value.allowedDestinationAddresses },
|
|
214
|
+
...value.allowedSenderAddresses === void 0 ? {} : { allowed_sender_addresses: value.allowedSenderAddresses }
|
|
215
|
+
});
|
|
216
|
+
break;
|
|
217
|
+
case "analytics-engine-dataset":
|
|
218
|
+
bindings.push({
|
|
219
|
+
name,
|
|
220
|
+
type: "analytics_engine",
|
|
221
|
+
...value.name === void 0 ? {} : { dataset: value.name }
|
|
222
|
+
});
|
|
223
|
+
break;
|
|
224
|
+
case "vectorize":
|
|
225
|
+
bindings.push({
|
|
226
|
+
name,
|
|
227
|
+
type: "vectorize",
|
|
228
|
+
index_name: requiredString(value.name, name)
|
|
229
|
+
});
|
|
230
|
+
break;
|
|
231
|
+
case "dispatch-namespace": {
|
|
232
|
+
const outbound = record(value.outbound);
|
|
233
|
+
bindings.push({
|
|
234
|
+
name,
|
|
235
|
+
type: "dispatch_namespace",
|
|
236
|
+
namespace: requiredString(value.namespace, name),
|
|
237
|
+
...outbound ? { outbound: {
|
|
238
|
+
worker: { service: requiredString(outbound.worker, name) },
|
|
239
|
+
...Array.isArray(outbound.parameters) ? { params: outbound.parameters.map((parameter) => ({ name: parameter })) } : {}
|
|
240
|
+
} } : {}
|
|
241
|
+
});
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
case "assets":
|
|
245
|
+
bindings.push({
|
|
246
|
+
name,
|
|
247
|
+
type: "assets"
|
|
248
|
+
});
|
|
249
|
+
break;
|
|
250
|
+
case "version-metadata":
|
|
251
|
+
bindings.push({
|
|
252
|
+
name,
|
|
253
|
+
type: "version_metadata"
|
|
254
|
+
});
|
|
255
|
+
break;
|
|
256
|
+
case "worker-loader":
|
|
257
|
+
bindings.push({
|
|
258
|
+
name,
|
|
259
|
+
type: "worker_loader"
|
|
260
|
+
});
|
|
261
|
+
break;
|
|
262
|
+
default: throw new Error(`Cloudflare binding ${name} cannot be uploaded with pinned secrets.`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return bindings;
|
|
266
|
+
}
|
|
267
|
+
const durableObjectStates = /* @__PURE__ */ new Set([
|
|
268
|
+
"created",
|
|
269
|
+
"deleted",
|
|
270
|
+
"renamed",
|
|
271
|
+
"transferred",
|
|
272
|
+
"expecting-transfer"
|
|
273
|
+
]);
|
|
274
|
+
/**
|
|
275
|
+
* The `exports` that cf uploads for the same Build Output. cf converts them with
|
|
276
|
+
* `@cloudflare/config`'s `convertToWranglerConfig` (cf `build-*.mjs`), and its
|
|
277
|
+
* `resolveExportsUploadPayload` (cf `containers-*.mjs`) sends Worker entrypoints,
|
|
278
|
+
* then Durable Objects, then Workflows reduced to their identity. Cloudflare
|
|
279
|
+
* stages a version at 0% only when its exports are identical to the live
|
|
280
|
+
* version's, and that version may have been uploaded by cf.
|
|
281
|
+
*/
|
|
282
|
+
function exportsFromOutput(exports, bindings) {
|
|
283
|
+
if (exports === void 0) return;
|
|
284
|
+
const entries = record(exports);
|
|
285
|
+
if (!entries) throw new Error("Cloudflare Durable Object exports were not readable.");
|
|
286
|
+
const workflows = /* @__PURE__ */ new Map();
|
|
287
|
+
for (const [name, raw] of Object.entries(entries)) {
|
|
288
|
+
const value = record(raw);
|
|
289
|
+
if (value?.type === "workflow") {
|
|
290
|
+
const workflowName = requiredString(value.name, `Workflow export ${name} name`);
|
|
291
|
+
if (workflows.has(workflowName)) throw new Error(`Cloudflare Workflow ${workflowName} has multiple local exports.`);
|
|
292
|
+
workflows.set(workflowName, name);
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (value?.type === "worker") continue;
|
|
296
|
+
if (!value || value.type !== "durable-object") throw new Error(`Cloudflare export ${name} cannot be uploaded with pinned secrets.`);
|
|
297
|
+
const state = value.state ?? "created";
|
|
298
|
+
if (!durableObjectStates.has(String(state))) throw new Error(`Cloudflare Durable Object export ${name} has an unsupported state.`);
|
|
299
|
+
if (state === "renamed" || state === "transferred") requiredString(value[state === "renamed" ? "renamedTo" : "transferredTo"], name);
|
|
300
|
+
else if (state !== "deleted") {
|
|
301
|
+
if (value.storage !== "sqlite" && value.storage !== "legacy-kv") throw new Error(`Cloudflare Durable Object export ${name} has no storage type.`);
|
|
302
|
+
if (value.container !== void 0) requiredString(value.container, name);
|
|
303
|
+
if (state === "expecting-transfer") requiredString(value.transferFrom, name);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
for (const binding of bindings) {
|
|
307
|
+
if (binding.type !== "workflow") continue;
|
|
308
|
+
const localExport = workflows.get(String(binding.workflow_name));
|
|
309
|
+
if (localExport !== void 0 && (binding.script_name !== void 0 || binding.class_name !== localExport)) throw new Error(`Cloudflare Workflow binding ${binding.name} conflicts with its local export.`);
|
|
310
|
+
}
|
|
311
|
+
const converted = record(convertToWranglerConfig({
|
|
312
|
+
worker: { exports: entries },
|
|
313
|
+
containers: []
|
|
314
|
+
}).exports) ?? {};
|
|
315
|
+
const result = {};
|
|
316
|
+
for (const type of [
|
|
317
|
+
"worker",
|
|
318
|
+
"durable-object",
|
|
319
|
+
"workflow"
|
|
320
|
+
]) for (const [name, value] of Object.entries(converted)) {
|
|
321
|
+
const entry = record(value);
|
|
322
|
+
if (entry?.type !== type) continue;
|
|
323
|
+
result[name] = entry;
|
|
324
|
+
}
|
|
325
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
326
|
+
}
|
|
327
|
+
async function preflightWorkflowExports(options) {
|
|
328
|
+
for (const raw of Object.values(options.exports ?? {})) {
|
|
329
|
+
const entry = record(raw);
|
|
330
|
+
if (entry?.type !== "workflow") continue;
|
|
331
|
+
const name = requiredString(entry.name, "Workflow name");
|
|
332
|
+
let workflow;
|
|
333
|
+
try {
|
|
334
|
+
workflow = await apiResult(`${options.accountUrl}/workflows/${encodeURIComponent(name)}`, options.token, "GET", void 0, options.verifyUploader);
|
|
335
|
+
} catch (cause) {
|
|
336
|
+
if (cause instanceof CloudflareApiError && cause.status === 404 && cause.code === 10200) continue;
|
|
337
|
+
throw cause;
|
|
338
|
+
}
|
|
339
|
+
if (workflow.name !== name || workflow.script_name !== options.workerName || typeof workflow.class_name !== "string" || !workflow.class_name) throw new Error(`Cloudflare Workflow ${name} is not owned by this Worker.`);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function assetConfigFromOutput(value) {
|
|
343
|
+
if (value === void 0) return;
|
|
344
|
+
const config = record(value);
|
|
345
|
+
if (!config) throw new Error("Cloudflare asset configuration was not readable.");
|
|
346
|
+
const supported = /* @__PURE__ */ new Set([
|
|
347
|
+
"basePath",
|
|
348
|
+
"htmlHandling",
|
|
349
|
+
"notFoundHandling",
|
|
350
|
+
"runWorkerFirst"
|
|
351
|
+
]);
|
|
352
|
+
if (Object.keys(config).some((key) => !supported.has(key))) throw new Error("Cloudflare asset configuration has an unsupported setting.");
|
|
353
|
+
return {
|
|
354
|
+
...config.basePath === void 0 ? {} : { base_path: config.basePath },
|
|
355
|
+
...config.htmlHandling === void 0 ? {} : { html_handling: config.htmlHandling },
|
|
356
|
+
...config.notFoundHandling === void 0 ? {} : { not_found_handling: config.notFoundHandling },
|
|
357
|
+
...config.runWorkerFirst === void 0 ? {} : { run_worker_first: config.runWorkerFirst }
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
/** The region, host or hostname of a targeted placement. */
|
|
361
|
+
function placementTarget(placement) {
|
|
362
|
+
if (!placement) return;
|
|
363
|
+
for (const kind of [
|
|
364
|
+
"region",
|
|
365
|
+
"host",
|
|
366
|
+
"hostname"
|
|
367
|
+
]) {
|
|
368
|
+
const value = placement[kind];
|
|
369
|
+
if (typeof value === "string" && value) return {
|
|
370
|
+
kind,
|
|
371
|
+
value
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
/** The version API placement, in the shape cf's own version uploads send. */
|
|
376
|
+
function placementFromOutput(placement) {
|
|
377
|
+
if (!placement) return;
|
|
378
|
+
const hint = "hint" in placement ? placement.hint : void 0;
|
|
379
|
+
if (hint || placement.mode === "smart") return {
|
|
380
|
+
mode: "smart",
|
|
381
|
+
...hint ? { hint } : {}
|
|
382
|
+
};
|
|
383
|
+
const target = placementTarget(placement);
|
|
384
|
+
return target ? {
|
|
385
|
+
mode: "targeted",
|
|
386
|
+
[target.kind]: target.value
|
|
387
|
+
} : void 0;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Whether the upload reply still names the requested target. The Workers beta version
|
|
391
|
+
* endpoint has replied `placement: {}` after dropping one (terraform-provider-cloudflare#7273).
|
|
392
|
+
* It now replies with the target alone, e.g. `{ region }`.
|
|
393
|
+
*/
|
|
394
|
+
function keepsPlacementTarget(placement, target) {
|
|
395
|
+
const reply = record(placement);
|
|
396
|
+
if (!reply) return false;
|
|
397
|
+
const targets = reply.target === void 0 ? [reply] : reply.target;
|
|
398
|
+
return Array.isArray(targets) && targets.length === 1 && record(targets[0])?.[target.kind] === target.value;
|
|
399
|
+
}
|
|
400
|
+
async function apiResult(url, token, method, body, verifyUploader, timeout = 12e4, headers) {
|
|
401
|
+
assertUploaderUnchanged(verifyUploader);
|
|
402
|
+
const form = body instanceof FormData;
|
|
403
|
+
const response = await fetch(url, {
|
|
404
|
+
method,
|
|
405
|
+
headers: {
|
|
406
|
+
"User-Agent": getVoidUserAgent(),
|
|
407
|
+
Authorization: `Bearer ${token}`,
|
|
408
|
+
...body && !form ? { "Content-Type": "application/json" } : {},
|
|
409
|
+
...headers
|
|
410
|
+
},
|
|
411
|
+
...body ? { body: form ? body : JSON.stringify(body) } : {},
|
|
412
|
+
redirect: "manual",
|
|
413
|
+
signal: AbortSignal.timeout(timeout)
|
|
414
|
+
});
|
|
415
|
+
const parsed = record(await response.json());
|
|
416
|
+
const result = record(parsed?.result);
|
|
417
|
+
if (!response.ok || parsed?.success !== true || !result) {
|
|
418
|
+
const error = Array.isArray(parsed?.errors) ? record(parsed.errors[0]) : null;
|
|
419
|
+
const code = error && Number.isSafeInteger(error.code) ? ` [code: ${error.code}]` : "";
|
|
420
|
+
throw new CloudflareApiError(`Cloudflare version upload failed (${response.status})${code}.`, response.status, typeof error?.code === "number" ? error.code : void 0);
|
|
421
|
+
}
|
|
422
|
+
return result;
|
|
423
|
+
}
|
|
424
|
+
/** Durable Object namespace bindings that point at this Worker's own class. */
|
|
425
|
+
function localNamespaceBindings(bindings, className, workerName) {
|
|
426
|
+
return bindings.flatMap((item) => {
|
|
427
|
+
const binding = record(item);
|
|
428
|
+
return binding?.type === "durable_object_namespace" && binding.class_name === className && (binding.script_name === void 0 || binding.script_name === workerName) && binding.environment === void 0 && binding.dispatch_namespace === void 0 ? [binding] : [];
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
function assertContainerApplicationIdentity(application, plan, namespace) {
|
|
432
|
+
if (application.id !== namespace || application.name !== plan.name || application.scheduling_policy !== "durable_object" || record(application.durable_objects)?.namespace_id !== namespace) throw new Error(`Cloudflare Container ${plan.name} application identity does not match the uploaded namespace.`);
|
|
433
|
+
}
|
|
434
|
+
function compareFlagValues(left, right) {
|
|
435
|
+
const a = String(left);
|
|
436
|
+
const b = String(right);
|
|
437
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
438
|
+
}
|
|
439
|
+
function assertContainerApplicationSettings(application, plan) {
|
|
440
|
+
const desired = record(plan.settings.configuration) ?? {};
|
|
441
|
+
const current = record(application.configuration) ?? {};
|
|
442
|
+
const changedConfiguration = Object.entries(desired).some(([key, value]) => {
|
|
443
|
+
if (key === "wrangler_ssh") {
|
|
444
|
+
const ssh = record(current.wrangler_ssh) ?? {};
|
|
445
|
+
const expected = record(value) ?? {};
|
|
446
|
+
return !isDeepStrictEqual(ssh.enabled ?? false, expected.enabled) || expected.enabled === true && expected.port !== void 0 && !isDeepStrictEqual(ssh.port, expected.port);
|
|
447
|
+
}
|
|
448
|
+
if (key === "experimental_flags" && Array.isArray(value)) {
|
|
449
|
+
const flags = current.experimental_flags ?? [];
|
|
450
|
+
return !Array.isArray(flags) || !isDeepStrictEqual([...flags].sort(compareFlagValues), [...value].sort(compareFlagValues));
|
|
451
|
+
}
|
|
452
|
+
return !isDeepStrictEqual(current[key] ?? [], value);
|
|
453
|
+
});
|
|
454
|
+
const logs = record(record(plan.settings.observability)?.logs);
|
|
455
|
+
const currentLogs = record(record(application.observability)?.logs);
|
|
456
|
+
if (changedConfiguration || logs !== null && !isDeepStrictEqual(currentLogs?.enabled ?? false, logs.enabled)) throw new Error(`Cloudflare Container ${plan.name} settings differ from the live application. Version-aware deployment cannot safely change these shared settings. Keep the existing Container settings in your configuration, or update this Container explicitly in the Cloudflare dashboard before retrying.`);
|
|
457
|
+
}
|
|
458
|
+
async function preflightContainerApplications(plans, bindings, accountUrl, workerName, token, verifyUploader) {
|
|
459
|
+
for (const plan of plans) {
|
|
460
|
+
const matches = localNamespaceBindings(bindings, plan.className, workerName).filter((binding) => binding.namespace_id !== void 0);
|
|
461
|
+
const namespaces = new Set(matches.map((binding) => binding.namespace_id));
|
|
462
|
+
if (namespaces.size > 1) throw new Error(`Cloudflare Container ${plan.name} active namespace was ambiguous.`);
|
|
463
|
+
const namespace = [...namespaces][0];
|
|
464
|
+
if (namespace === void 0) {
|
|
465
|
+
if (Object.keys(plan.images).length === 0) throw new Error(`Cloudflare Container ${plan.name} has no images and no verified existing namespace application.`);
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
if (typeof namespace !== "string" || !/^[a-f0-9]{32}$/.test(namespace)) throw new Error("The active Container namespace ID was invalid.");
|
|
469
|
+
try {
|
|
470
|
+
const application = await apiResult(`${accountUrl}/containers/applications/${encodeURIComponent(namespace)}`, token, "GET", void 0, verifyUploader);
|
|
471
|
+
assertContainerApplicationIdentity(application, plan, namespace);
|
|
472
|
+
assertContainerApplicationSettings(application, plan);
|
|
473
|
+
} catch (cause) {
|
|
474
|
+
if (!(cause instanceof CloudflareApiError) || cause.status !== 404 || Object.keys(plan.images).length === 0) throw cause;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
function containerPlansFromOutput(containers, exports, bindings) {
|
|
479
|
+
const plans = [];
|
|
480
|
+
for (const { config } of containers) {
|
|
481
|
+
if (config.schedulingPolicy !== "durable-object") throw new Error("Scheduler-managed Cloudflare Containers cannot be uploaded with pinned secrets.");
|
|
482
|
+
const classes = Object.entries(exports ?? {}).filter(([, value]) => record(value)?.container === config.name);
|
|
483
|
+
if (classes.length !== 1) throw new Error(`Cloudflare Container ${config.name} needs exactly one local SQLite export.`);
|
|
484
|
+
const [className, raw] = classes[0];
|
|
485
|
+
const declaration = record(raw);
|
|
486
|
+
const localBindings = bindings.filter((binding) => binding.type === "durable_object_namespace" && binding.class_name === className && binding.script_name === void 0);
|
|
487
|
+
if (declaration?.storage !== "sqlite" || localBindings.length === 0) throw new Error(`Cloudflare Container ${config.name} needs a local SQLite Durable Object binding.`);
|
|
488
|
+
const unsafe = record(config.unsafe);
|
|
489
|
+
const configuration = record(unsafe?.configuration);
|
|
490
|
+
if (unsafe && Object.keys(unsafe).some((key) => key !== "configuration") || configuration && Object.keys(configuration).some((key) => key !== "experimental_flags")) throw new Error(`Cloudflare Container ${config.name} has an unsupported setting.`);
|
|
491
|
+
const settings = {
|
|
492
|
+
...configuration || config.ssh || config.authorizedKeys ? { configuration: {
|
|
493
|
+
...configuration ?? {},
|
|
494
|
+
...config.ssh ? { wrangler_ssh: config.ssh } : {},
|
|
495
|
+
...config.authorizedKeys ? { authorized_keys: config.authorizedKeys.map(({ name, publicKey }) => ({
|
|
496
|
+
name,
|
|
497
|
+
public_key: publicKey
|
|
498
|
+
})) } : {}
|
|
499
|
+
} } : {},
|
|
500
|
+
...config.observability ? { observability: { logs: { enabled: config.observability.enabled === true || config.observability.logs?.enabled === true } } } : {}
|
|
501
|
+
};
|
|
502
|
+
plans.push({
|
|
503
|
+
name: config.name,
|
|
504
|
+
className,
|
|
505
|
+
images: config.images ?? {},
|
|
506
|
+
settings
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
for (const [name, raw] of Object.entries(exports ?? {})) {
|
|
510
|
+
const container = record(raw)?.container;
|
|
511
|
+
if (container !== void 0 && !plans.some((plan) => plan.name === container && plan.className === name)) throw new Error(`Cloudflare export ${name} references a Container outside the verified output.`);
|
|
512
|
+
}
|
|
513
|
+
return plans;
|
|
514
|
+
}
|
|
515
|
+
async function dockerImageDigest(image, timeout, verifyUploader) {
|
|
516
|
+
assertUploaderUnchanged(verifyUploader);
|
|
517
|
+
const stdout = await new Promise((resolve, reject) => {
|
|
518
|
+
execFile(process.env.WRANGLER_DOCKER_BIN ?? "docker", [
|
|
519
|
+
"image",
|
|
520
|
+
"inspect",
|
|
521
|
+
"--format",
|
|
522
|
+
"{{json .RepoDigests}}",
|
|
523
|
+
image
|
|
524
|
+
], {
|
|
525
|
+
encoding: "utf8",
|
|
526
|
+
timeout,
|
|
527
|
+
maxBuffer: 1048576,
|
|
528
|
+
windowsHide: true
|
|
529
|
+
}, (error, stdout) => error ? reject(/* @__PURE__ */ new Error("Cloudflare Container image digest could not be verified after push.")) : resolve(stdout));
|
|
530
|
+
});
|
|
531
|
+
const digests = JSON.parse(stdout);
|
|
532
|
+
const repository = image.replace(/:[^/:]+$/, "");
|
|
533
|
+
const matching = Array.isArray(digests) ? digests.filter((digest) => typeof digest === "string" && digest.startsWith(`${repository}@sha256:`) && /^[a-f0-9]{64}$/.test(digest.slice(digest.lastIndexOf(":") + 1))) : [];
|
|
534
|
+
if (matching.length !== 1) throw new Error("Cloudflare Container image digest could not be verified after push.");
|
|
535
|
+
return matching[0];
|
|
536
|
+
}
|
|
537
|
+
async function prepareContainerMetadata(options) {
|
|
538
|
+
if (options.plans.length === 0) return [];
|
|
539
|
+
const deadline = Date.now() + 9e5;
|
|
540
|
+
const remaining = () => {
|
|
541
|
+
const duration = deadline - Date.now();
|
|
542
|
+
if (duration <= 0) throw new Error("Cloudflare Container image preparation timed out.");
|
|
543
|
+
return duration;
|
|
544
|
+
};
|
|
545
|
+
const prepared = /* @__PURE__ */ new Map();
|
|
546
|
+
const result = [];
|
|
547
|
+
for (const plan of options.plans) {
|
|
548
|
+
const images = {};
|
|
549
|
+
for (const [name, raw] of Object.entries(plan.images)) {
|
|
550
|
+
const source = record(raw);
|
|
551
|
+
const reference = requiredString(source?.localReference ?? source?.reference, `Container ${plan.name} image`);
|
|
552
|
+
let image = prepared.get(reference);
|
|
553
|
+
if (!image) {
|
|
554
|
+
image = reference;
|
|
555
|
+
if (source?.localReference !== void 0) {
|
|
556
|
+
if (!options.runCf || !options.verifyUploader()) throw new Error("The verified Cloudflare Container image uploader is unavailable.");
|
|
557
|
+
const pushed = await options.runCf([
|
|
558
|
+
"containers",
|
|
559
|
+
"push",
|
|
560
|
+
"--tag",
|
|
561
|
+
reference
|
|
562
|
+
], {
|
|
563
|
+
cwd: options.directory,
|
|
564
|
+
capture: true,
|
|
565
|
+
timeoutMs: remaining(),
|
|
566
|
+
maxOutputBytes: 16777216
|
|
567
|
+
});
|
|
568
|
+
if (pushed.status !== 0 || pushed.signal || pushed.error) throw new Error("Cloudflare Container image push failed.");
|
|
569
|
+
const matches = [...`${pushed.stdout}\n${pushed.stderr}`.matchAll(/Pushed image:\s*(\S+)/g)];
|
|
570
|
+
const remote = matches.length === 1 ? matches[0][1] : "";
|
|
571
|
+
if (!remote.startsWith(`registry.cloudflare.com/${options.accountId}/`) || Array.from(remote).some((character) => character.charCodeAt(0) <= 32 || character.charCodeAt(0) === 127)) throw new Error("Cloudflare Container image push did not return the verified account registry.");
|
|
572
|
+
image = await dockerImageDigest(remote, Math.min(12e4, remaining()), options.verifyUploader);
|
|
573
|
+
}
|
|
574
|
+
for (;;) {
|
|
575
|
+
const ready = await apiResult(`${options.accountUrl}/containers/image-preparations`, options.token, "POST", { image }, options.verifyUploader, Math.min(12e4, remaining()));
|
|
576
|
+
if (ready.image !== image) throw new Error("Cloudflare Container image preparation returned another image.");
|
|
577
|
+
if (ready.status === "ready") break;
|
|
578
|
+
if (ready.status !== "pending") throw new Error("Cloudflare Container image preparation failed or returned an unsupported state.");
|
|
579
|
+
await setTimeout(Math.min(2e3, remaining()));
|
|
580
|
+
}
|
|
581
|
+
prepared.set(reference, image);
|
|
582
|
+
}
|
|
583
|
+
images[name] = image;
|
|
584
|
+
}
|
|
585
|
+
result.push({
|
|
586
|
+
name: plan.name,
|
|
587
|
+
class_name: plan.className,
|
|
588
|
+
...Object.keys(images).length ? { images } : {}
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
return result;
|
|
592
|
+
}
|
|
593
|
+
async function ensureContainerApplications(options) {
|
|
594
|
+
if (options.plans.length === 0) return;
|
|
595
|
+
const deadline = Date.now() + 6e4;
|
|
596
|
+
let version;
|
|
597
|
+
for (;;) try {
|
|
598
|
+
version = await apiResult(`${options.accountUrl}/workers/scripts/${encodeURIComponent(options.workerName)}/versions/${encodeURIComponent(options.versionId)}`, options.token, "GET", void 0, options.verifyUploader, Math.max(1, Math.min(3e4, deadline - Date.now())));
|
|
599
|
+
break;
|
|
600
|
+
} catch (cause) {
|
|
601
|
+
if (!(cause instanceof CloudflareApiError) || cause.code !== 100146 || Date.now() >= deadline) throw cause;
|
|
602
|
+
await setTimeout(Math.min(2e3, deadline - Date.now()));
|
|
603
|
+
}
|
|
604
|
+
const versionBindings = record(version.resources)?.bindings;
|
|
605
|
+
if (version.id !== options.versionId || !Array.isArray(versionBindings)) throw new Error("The uploaded Container namespace could not be verified.");
|
|
606
|
+
const metadata = record(record(version.resources)?.script_runtime)?.containers;
|
|
607
|
+
if (!Array.isArray(metadata) || metadata.length !== options.containers.length || options.containers.some((expected) => {
|
|
608
|
+
const matching = metadata.map(record).filter((entry) => entry !== null && entry.name === expected.name && entry.class_name === expected.class_name);
|
|
609
|
+
const actual = matching[0];
|
|
610
|
+
return matching.length !== 1 || !actual || !isDeepStrictEqual(actual.images ?? {}, expected.images ?? {});
|
|
611
|
+
})) throw new Error("The uploaded Worker version did not retain the verified Container image metadata.");
|
|
612
|
+
for (const plan of options.plans) {
|
|
613
|
+
const matches = localNamespaceBindings(versionBindings, plan.className, options.workerName);
|
|
614
|
+
const namespaces = new Set(matches.map((binding) => binding.namespace_id));
|
|
615
|
+
if (matches.length === 0 || namespaces.size !== 1) throw new Error(`Cloudflare Container ${plan.name} has no unambiguous uploaded local namespace.`);
|
|
616
|
+
const namespace = requiredString([...namespaces][0], `Container ${plan.name} namespace`);
|
|
617
|
+
if (!/^[a-f0-9]{32}$/.test(namespace)) throw new Error("The uploaded Container namespace ID was invalid.");
|
|
618
|
+
const url = `${options.accountUrl}/containers/applications/${encodeURIComponent(namespace)}`;
|
|
619
|
+
let application;
|
|
620
|
+
try {
|
|
621
|
+
application = await apiResult(url, options.token, "GET", void 0, options.verifyUploader);
|
|
622
|
+
} catch (cause) {
|
|
623
|
+
if (!(cause instanceof CloudflareApiError) || cause.status !== 404) throw cause;
|
|
624
|
+
application = await apiResult(`${options.accountUrl}/containers/applications`, options.token, "POST", {
|
|
625
|
+
name: plan.name,
|
|
626
|
+
scheduling_policy: "durable_object",
|
|
627
|
+
durable_objects: { namespace_id: namespace },
|
|
628
|
+
...plan.settings
|
|
629
|
+
}, options.verifyUploader);
|
|
630
|
+
}
|
|
631
|
+
assertContainerApplicationIdentity(application, plan, namespace);
|
|
632
|
+
assertContainerApplicationSettings(application, plan);
|
|
633
|
+
const confirmed = await apiResult(url, options.token, "GET", void 0, options.verifyUploader);
|
|
634
|
+
assertContainerApplicationIdentity(confirmed, plan, namespace);
|
|
635
|
+
assertContainerApplicationSettings(confirmed, plan);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
function readAssetRuleFile(output, name) {
|
|
639
|
+
if (!output.assetsDirectory) return;
|
|
640
|
+
try {
|
|
641
|
+
return readFileSync(join(getWorkerAssetsDir(output.directory), name), "utf8");
|
|
642
|
+
} catch (cause) {
|
|
643
|
+
if (cause instanceof Error && "code" in cause && cause.code === "ENOENT") return;
|
|
644
|
+
throw cause;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
async function uploadAssets(options) {
|
|
648
|
+
if (!options.output.assetsDirectory) return;
|
|
649
|
+
const directory = getWorkerAssetsDir(options.output.directory);
|
|
650
|
+
const manifest = {};
|
|
651
|
+
const byHash = /* @__PURE__ */ new Map();
|
|
652
|
+
const ignored = ignore().add([
|
|
653
|
+
".DS_Store",
|
|
654
|
+
".env",
|
|
655
|
+
".env.*",
|
|
656
|
+
".dev.vars",
|
|
657
|
+
".dev.vars.*"
|
|
658
|
+
]);
|
|
659
|
+
const ignorePath = join(directory, ".assetsignore");
|
|
660
|
+
try {
|
|
661
|
+
ignored.add(readFileSync(ignorePath, "utf8"));
|
|
662
|
+
} catch (cause) {
|
|
663
|
+
if (!(cause instanceof Error && "code" in cause && cause.code === "ENOENT")) throw cause;
|
|
664
|
+
}
|
|
665
|
+
ignored.add([
|
|
666
|
+
"/.assetsignore",
|
|
667
|
+
"/_headers",
|
|
668
|
+
"/_redirects"
|
|
669
|
+
]);
|
|
670
|
+
for (const entry of readdirSync(directory, {
|
|
671
|
+
recursive: true,
|
|
672
|
+
withFileTypes: true
|
|
673
|
+
})) {
|
|
674
|
+
if (entry.isDirectory()) continue;
|
|
675
|
+
if (!entry.isFile()) throw new Error("The Cloudflare asset output contains an unsupported entry.");
|
|
676
|
+
const path = join(entry.parentPath, entry.name);
|
|
677
|
+
const relativeName = relative(directory, path).replaceAll("\\", "/");
|
|
678
|
+
if (ignored.ignores(relativeName)) continue;
|
|
679
|
+
const name = `/${relativeName}`;
|
|
680
|
+
const content = readFileSync(path);
|
|
681
|
+
const extension = extname(entry.name).slice(1);
|
|
682
|
+
const hash = createHash("sha256").update(content.toString("base64") + extension).digest("hex").slice(0, 32);
|
|
683
|
+
manifest[name] = {
|
|
684
|
+
hash,
|
|
685
|
+
size: content.length
|
|
686
|
+
};
|
|
687
|
+
byHash.set(hash, path);
|
|
688
|
+
}
|
|
689
|
+
const session = await apiResult(`${options.accountUrl}/workers/scripts/${encodeURIComponent(options.workerName)}/assets-upload-session`, options.token, "POST", { manifest }, options.verifyUploader);
|
|
690
|
+
const uploadJwt = requiredString(session.jwt, "asset upload token");
|
|
691
|
+
if (!Array.isArray(session.buckets)) throw new Error("Cloudflare did not provide asset upload batches.");
|
|
692
|
+
if (session.buckets.length === 0) return uploadJwt;
|
|
693
|
+
let completionJwt;
|
|
694
|
+
for (const bucket of session.buckets) {
|
|
695
|
+
if (!Array.isArray(bucket) || !bucket.every((hash) => typeof hash === "string")) throw new Error("Cloudflare returned an invalid asset upload batch.");
|
|
696
|
+
const form = new FormData();
|
|
697
|
+
for (const hash of bucket) {
|
|
698
|
+
const path = byHash.get(hash);
|
|
699
|
+
if (!path) throw new Error("Cloudflare requested an asset outside the verified Worker output.");
|
|
700
|
+
form.append(hash, new File([readFileSync(path).toString("base64")], hash, { type: mime.getType(path) ?? "application/null" }));
|
|
701
|
+
}
|
|
702
|
+
const uploaded = await apiResult(`${options.accountUrl}/workers/assets/upload?base64=true`, uploadJwt, "POST", form, options.verifyUploader);
|
|
703
|
+
if (uploaded.jwt !== void 0) completionJwt = requiredString(uploaded.jwt, "asset completion token");
|
|
704
|
+
}
|
|
705
|
+
return requiredString(completionJwt, "asset completion token");
|
|
706
|
+
}
|
|
707
|
+
/** The Workers beta API is the only upload endpoint that accepts a version UUID as an inheritance source. */
|
|
708
|
+
async function uploadPinnedCloudflareVersion(options) {
|
|
709
|
+
const activeSecrets = options.output.activeSecrets;
|
|
710
|
+
if (!activeSecrets) throw new Error("The active Worker secret source was not verified.");
|
|
711
|
+
const built = await readBuildOutput(options.output.directory);
|
|
712
|
+
const config = built.workers.default.config;
|
|
713
|
+
if (config.name !== options.workerName || !config.manifest || config.manifest.type !== "complete") throw new Error("The verified Cloudflare Worker output changed before upload.");
|
|
714
|
+
const unsupported = Object.keys(config).filter((key) => !(/* @__PURE__ */ new Set([
|
|
715
|
+
"name",
|
|
716
|
+
"compatibilityDate",
|
|
717
|
+
"compatibilityFlags",
|
|
718
|
+
"assets",
|
|
719
|
+
"domains",
|
|
720
|
+
"observability",
|
|
721
|
+
"workersDev",
|
|
722
|
+
"previewUrls",
|
|
723
|
+
"unsafe",
|
|
724
|
+
"env",
|
|
725
|
+
"exports",
|
|
726
|
+
"manifest",
|
|
727
|
+
"triggers",
|
|
728
|
+
"limits",
|
|
729
|
+
"placement",
|
|
730
|
+
"cache",
|
|
731
|
+
"logpush",
|
|
732
|
+
"tailConsumers"
|
|
733
|
+
])).has(key));
|
|
734
|
+
if (unsupported.length) throw new Error(`Cloudflare Worker setting ${unsupported[0]} cannot be uploaded with pinned secrets.`);
|
|
735
|
+
const placement = placementFromOutput(config.placement);
|
|
736
|
+
const unsafe = record(config.unsafe);
|
|
737
|
+
const metadata = record(unsafe?.metadata);
|
|
738
|
+
if (unsafe && Object.keys(unsafe).some((key) => key !== "metadata") || metadata && Object.keys(metadata).some((key) => key !== "keep_bindings") || metadata?.keep_bindings !== void 0 && (!Array.isArray(metadata.keep_bindings) || !metadata.keep_bindings.every((type) => typeof type === "string"))) throw new Error("Cloudflare Worker upload metadata has an unsupported setting.");
|
|
739
|
+
const explicitSecrets = options.secretsFilePath ? record(JSON.parse(readFileSync(options.secretsFilePath, "utf8"))) : {};
|
|
740
|
+
if (!explicitSecrets) throw new Error("The explicit Cloudflare secrets file was not readable.");
|
|
741
|
+
const bindings = bindingsFromOutput(config.env ?? {}, options.workerName, activeSecrets, explicitSecrets);
|
|
742
|
+
const exports = exportsFromOutput(config.exports, bindings);
|
|
743
|
+
const containerPlans = containerPlansFromOutput(built.containers, exports, bindings);
|
|
744
|
+
const accountUrl = `${options.apiBaseUrl.replace(/\/$/, "")}/accounts/${encodeURIComponent(options.accountId)}`;
|
|
745
|
+
const active = await apiResult(`${accountUrl}/workers/workers/${encodeURIComponent(options.workerName)}/versions/${encodeURIComponent(activeSecrets.versionId)}`, options.token, "GET", void 0, options.verifyUploader);
|
|
746
|
+
if (active.id !== activeSecrets.versionId || !Array.isArray(active.bindings)) throw new Error("The active Cloudflare Worker bindings could not be verified.");
|
|
747
|
+
const activeBindingNames = /* @__PURE__ */ new Set();
|
|
748
|
+
const candidateNames = new Set(bindings.map((binding) => String(binding.name)));
|
|
749
|
+
const keptTypes = new Set(metadata?.keep_bindings ?? []);
|
|
750
|
+
for (const entry of active.bindings) {
|
|
751
|
+
const binding = record(entry);
|
|
752
|
+
if (!binding || typeof binding.name !== "string" || typeof binding.type !== "string") throw new Error("The active Cloudflare Worker bindings could not be verified.");
|
|
753
|
+
activeBindingNames.add(binding.name);
|
|
754
|
+
if (!candidateNames.has(binding.name) && keptTypes.has(binding.type) && ["plain_text", "json"].includes(binding.type)) {
|
|
755
|
+
bindings.push({
|
|
756
|
+
name: binding.name,
|
|
757
|
+
type: "inherit",
|
|
758
|
+
version_id: activeSecrets.versionId
|
|
759
|
+
});
|
|
760
|
+
candidateNames.add(binding.name);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
if (activeSecrets.bindings.some(({ name }) => !activeBindingNames.has(name))) throw new Error("The active Cloudflare Worker secrets changed before upload.");
|
|
764
|
+
const assetConfig = assetConfigFromOutput(config.assets);
|
|
765
|
+
if (bindings.some((binding) => binding.type === "assets") && !options.output.assetsDirectory) throw new Error("The Cloudflare Worker has an assets binding without verified assets.");
|
|
766
|
+
const modules = [];
|
|
767
|
+
for (const [name, entry] of Object.entries(config.manifest.modules)) {
|
|
768
|
+
const type = moduleContentTypes.get(entry.type);
|
|
769
|
+
if (!type || name.startsWith("/") || name.split("/").includes("..")) throw new Error(`Cloudflare Worker module ${name} cannot be uploaded with pinned secrets.`);
|
|
770
|
+
modules.push({
|
|
771
|
+
name,
|
|
772
|
+
content_type: type,
|
|
773
|
+
content_base64: readFileSync(join(getWorkerBundleDir(options.output.directory), name)).toString("base64")
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
for (const name of ["_headers", "_redirects"]) {
|
|
777
|
+
if (name === "_redirects" && !options.output.forwardAssetRedirects) continue;
|
|
778
|
+
const content = readAssetRuleFile(options.output, name);
|
|
779
|
+
if (content === void 0) continue;
|
|
780
|
+
modules.push({
|
|
781
|
+
name,
|
|
782
|
+
content_type: "text/plain",
|
|
783
|
+
content_base64: Buffer.from(content).toString("base64")
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
await preflightWorkflowExports({
|
|
787
|
+
exports,
|
|
788
|
+
accountUrl,
|
|
789
|
+
workerName: options.workerName,
|
|
790
|
+
token: options.token,
|
|
791
|
+
verifyUploader: options.verifyUploader
|
|
792
|
+
});
|
|
793
|
+
await preflightContainerApplications(containerPlans, active.bindings, accountUrl, options.workerName, options.token, options.verifyUploader);
|
|
794
|
+
const containers = await prepareContainerMetadata({
|
|
795
|
+
plans: containerPlans,
|
|
796
|
+
directory: options.output.directory,
|
|
797
|
+
accountUrl,
|
|
798
|
+
accountId: options.accountId,
|
|
799
|
+
token: options.token,
|
|
800
|
+
verifyUploader: options.verifyUploader,
|
|
801
|
+
runCf: options.runCf
|
|
802
|
+
});
|
|
803
|
+
const jwt = await uploadAssets({
|
|
804
|
+
output: options.output,
|
|
805
|
+
accountUrl,
|
|
806
|
+
workerName: options.workerName,
|
|
807
|
+
token: options.token,
|
|
808
|
+
verifyUploader: options.verifyUploader
|
|
809
|
+
});
|
|
810
|
+
const uploaded = await apiResult(`${accountUrl}/workers/workers/${encodeURIComponent(options.workerName)}/versions${options.atomic ? "?deploy=true" : ""}`, options.token, "POST", {
|
|
811
|
+
main_module: config.manifest.mainModule,
|
|
812
|
+
modules,
|
|
813
|
+
compatibility_date: config.compatibilityDate,
|
|
814
|
+
compatibility_flags: config.compatibilityFlags,
|
|
815
|
+
package_dependencies: process.env.CLOUDFLARE_DEPENDENCIES_INSTRUMENTATION?.toLowerCase() === "false" ? void 0 : await readPackageDependencies(options.output.directory),
|
|
816
|
+
bindings,
|
|
817
|
+
...config.limits ? { limits: {
|
|
818
|
+
cpu_ms: config.limits.cpuMs,
|
|
819
|
+
subrequests: config.limits.subrequests
|
|
820
|
+
} } : {},
|
|
821
|
+
...placement ? { placement } : {},
|
|
822
|
+
...config.cache ? { cache_options: {
|
|
823
|
+
enabled: config.cache.enabled,
|
|
824
|
+
cross_version_cache: config.cache.crossVersionCache
|
|
825
|
+
} } : {},
|
|
826
|
+
...exports ? { exports } : {},
|
|
827
|
+
...containers.length ? { containers } : {},
|
|
828
|
+
...jwt ? { assets: {
|
|
829
|
+
jwt,
|
|
830
|
+
...assetConfig ? { config: assetConfig } : {}
|
|
831
|
+
} } : {},
|
|
832
|
+
annotations: { "workers/message": options.message ?? "" }
|
|
833
|
+
}, options.verifyUploader, void 0, Object.values(exports ?? {}).some((entry) => record(entry)?.type === "workflow") ? { "Cloudflare-Workers-Script-Api-Date": "2026-11-09" } : void 0);
|
|
834
|
+
const versionId = uploaded.id;
|
|
835
|
+
if (typeof versionId !== "string" || !/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(versionId)) throw new Error("Cloudflare accepted the Worker upload but returned an invalid version identity. Read back the Worker deployment before retrying.");
|
|
836
|
+
try {
|
|
837
|
+
await ensureContainerApplications({
|
|
838
|
+
plans: containerPlans,
|
|
839
|
+
containers,
|
|
840
|
+
accountUrl,
|
|
841
|
+
workerName: options.workerName,
|
|
842
|
+
versionId,
|
|
843
|
+
token: options.token,
|
|
844
|
+
verifyUploader: options.verifyUploader
|
|
845
|
+
});
|
|
846
|
+
} catch {
|
|
847
|
+
throw new Error(`Cloudflare Worker version ${versionId} was uploaded${options.atomic ? " and may already be published" : ""}, but its Container applications could not be verified. Read back the Worker deployment and Container identities before retrying.`);
|
|
848
|
+
}
|
|
849
|
+
const target = placementTarget(config.placement);
|
|
850
|
+
if (target && !keepsPlacementTarget(uploaded.placement, target)) throw new Error(`Cloudflare did not keep placement.${target.kind} "${target.value}" on Worker version ${versionId}${options.atomic ? ", which is already live" : ", so it was not deployed"}. Deploy again, or set cloudflare.placement to { mode: 'smart' } in void.config.ts.`);
|
|
851
|
+
return {
|
|
852
|
+
id: versionId,
|
|
853
|
+
urls: Array.isArray(uploaded.urls) ? uploaded.urls.filter((url) => typeof url === "string") : []
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
export { isSecretBindingType as n, uploadPinnedCloudflareVersion as r, exportsFromOutput as t };
|