void 1.6.1 → 1.7.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/dist/{account-cmd-DRhmCWcm.mjs → account-cmd-BfkJ_1PC.mjs} +6 -6
- package/dist/{application-analysis-HRFsZOv3.mjs → application-analysis-OV0CBJ80.mjs} +8 -19
- package/dist/{application-routing-P4TggvWp.mjs → application-routing-QpyC5G8z.mjs} +2 -1
- package/dist/{auth-CL-p_rqV.mjs → auth-BN0NU9dz.mjs} +1 -1
- package/dist/{auth-Dy8svcqQ.mjs → auth-CCk9Seol.mjs} +2 -2
- package/dist/{auth-CH4PLAX1.d.mts → auth-CZrthGxs.d.mts} +8 -1
- package/dist/{auth-YVjBX5NY.mjs → auth-DyWp-fSo.mjs} +7 -1
- package/dist/{auth-link-CVXP1G6G.mjs → auth-link-CW1Zh6FM.mjs} +6 -6
- package/dist/{auth-router-D1pGdbvB.mjs → auth-router-CNBKnEZi.mjs} +3 -3
- package/dist/{better-auth-shared-BJyG2mH0.d.mts → better-auth-shared-C-0uZg8-.d.mts} +1 -1
- package/dist/{better-auth-shared-C958aM7W.mjs → better-auth-shared-CdVyCUou.mjs} +1 -1
- package/dist/{build-cmd-DmjbuT6d.mjs → build-cmd-C9qOKW9W.mjs} +5 -5
- package/dist/{cache-2khBO1MR.mjs → cache-DVBBbWQL.mjs} +5 -5
- package/dist/{cancel-deploy-_itbbvY3.mjs → cancel-deploy-COavnjud.mjs} +4 -4
- package/dist/{cf-build-output-B1C8U83u.mjs → cf-build-output-CWNOH-KA.mjs} +2 -1
- package/dist/cf-build-output-DUZnAeZ1.mjs +1 -0
- package/dist/{cf-config-migrate-Dy8MrKgF.mjs → cf-config-migrate-Bb-EdAQq.mjs} +5 -1
- package/dist/cli/cli.mjs +68 -1868
- package/dist/cli/cloudflare-operation-process.mjs +10 -8
- package/dist/cli/env-schema-probe.mjs +3 -3
- package/dist/cli-main-DFteHrJI.mjs +1889 -0
- package/dist/client-BAxLpSKv.mjs +1 -0
- package/dist/{client-CoxPEhJq.mjs → client-BEZmTP6p.mjs} +10 -4
- package/dist/{cloudflare-auth-CEu-1Ps_.mjs → cloudflare-auth-DGIivpTb.mjs} +1 -1
- package/dist/{cloudflare-cmd-fZ6AMSWk.mjs → cloudflare-cmd-DJaxC-bc.mjs} +5 -5
- package/dist/{cloudflare-config-eQunqX6A.mjs → cloudflare-config-DtOGAbeB.mjs} +3 -3
- package/dist/{cloudflare-connect-9OZe4XVQ.mjs → cloudflare-connect-BjpWmglw.mjs} +3 -3
- package/dist/{cloudflare-operations-oLvAd9Nd.mjs → cloudflare-operations-CZkjFrzH.mjs} +1 -1
- package/dist/{cloudflare-operations-CrskD4_O.mjs → cloudflare-operations-k7wYUv56.mjs} +6 -6
- package/dist/{cloudflare-process-DjJ638A-.mjs → cloudflare-process-BcPvlMFd.mjs} +3 -3
- package/dist/{config-BITKQ3O6.mjs → config-5oSQhZNj.mjs} +7 -5
- package/dist/{config-CPxJmt4M.d.mts → config-CTlUaXWZ.d.mts} +3 -1
- package/dist/{config-BBlVXZCU.mjs → config-DcqUBGCb.mjs} +3 -3
- package/dist/{config-WlvEcL82.mjs → config-eeDzKBS9.mjs} +2 -2
- package/dist/config-entry.d.mts +1 -1
- package/dist/{config-BgysUhnm.mjs → config-wo2EaH0X.mjs} +1 -1
- package/dist/{connect-CKvmkl2R.mjs → connect-j1F1C_rW.mjs} +7 -7
- package/dist/{create-project-Bq0M8MtO.mjs → create-project-CE3jOmd5.mjs} +5 -5
- package/dist/{create-project-BiMmR5wA.mjs → create-project-DZH3aYGQ.mjs} +1 -1
- package/dist/{db-DjtGAcOz.mjs → db-DyLzzxvM.mjs} +39 -39
- package/dist/{db-types-C_8amnB0.mjs → db-types-DdHHUVPy.mjs} +1 -1
- package/dist/{delete-CY4L8fi2.mjs → delete-Dey6YoMA.mjs} +5 -5
- package/dist/{deploy-D_gEojD2.mjs → deploy-Ccw2D2lw.mjs} +507 -122
- package/dist/deploy-DEZkUS77.mjs +2 -0
- package/dist/{deploy-managed-static-BHVbB_-A.mjs → deploy-managed-static-BBVtpuGv.mjs} +18 -18
- package/dist/{deploy-transport-DEyOUfac.mjs → deploy-transport-Dt0IvSVW.mjs} +2 -2
- package/dist/deploy.mjs +8 -8
- package/dist/discover-1DJD4YXD.mjs +1 -0
- package/dist/{discover-Dhkzxgdt.mjs → discover-CVFCWU7W.mjs} +1 -1
- package/dist/{dispatch-BNLB5_Gm.mjs → dispatch-pYaww76u.mjs} +6 -6
- package/dist/{dist-D23AAMxT.mjs → dist-BQdgCVQF.mjs} +1 -1
- package/dist/{dist-eV_Ep60B.mjs → dist-DeTdhbZc.mjs} +1 -1
- package/dist/{domain-BlH90Ods.mjs → domain-Dh3mG8Vs.mjs} +6 -6
- package/dist/{email-Bkq8ZL1p.mjs → email-DKyMjOYM.mjs} +11 -11
- package/dist/{email-cloudflare-MvJIxrwx.mjs → email-cloudflare-CTt2n_W2.mjs} +13 -9
- package/dist/{entry-CBZsCy3O.mjs → entry-Bw-G1VVx.mjs} +2 -2
- package/dist/{env-AvuCSeCH.mjs → env-DkZzh_Dd.mjs} +7 -7
- package/dist/env-mask-D31Qztl9.mjs +46 -0
- package/dist/{env-types-DqzVBKnS.mjs → env-types-Dz9qkiOn.mjs} +1 -1
- package/dist/{env-validation-GV1oD4EV.mjs → env-validation-1snjKtDX.mjs} +4 -4
- package/dist/{env-validation-C8Cmvas0.mjs → env-validation-C8NL3lEH.mjs} +1 -1
- package/dist/{fetch-C8yhLoF3.mjs → fetch-CAIVkLvW.mjs} +1 -1
- package/dist/{fetch-B-gLGYVl.d.mts → fetch-CbI6lNnk.d.mts} +6 -4
- package/dist/{fetch-stream-DafNtVJC.mjs → fetch-stream-6Op0qlLd.mjs} +1 -1
- package/dist/{fetch-stream-DuwxWmBM.d.mts → fetch-stream-DoED9atq.d.mts} +1 -1
- package/dist/{gen-B9bCV5qu.mjs → gen-BZmFOGDQ.mjs} +7 -7
- package/dist/gen-C6iknRdI.mjs +1 -0
- package/dist/{github-cmd-CA-lBdkn.mjs → github-cmd-7Oky9qgH.mjs} +6 -6
- package/dist/{handler-CKeTtYID.mjs → handler-C9SnmeW1.mjs} +6 -5
- package/dist/{handler-BR6Tvjkp.d.mts → handler-DjqciiDc.d.mts} +20 -7
- package/dist/{headers-CuTEdP9C.mjs → headers-CimYIfQI.mjs} +1 -1
- package/dist/{help-1OCFDsRr.mjs → help-CNuUb47C.mjs} +7 -3
- package/dist/help-C_cqTByy.mjs +1 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +155 -110
- package/dist/{info-CJxua_db.mjs → info-DwB8IWIx.mjs} +4 -4
- package/dist/{init-B-4CluYx.mjs → init-CUGSmcED.mjs} +34 -32
- package/dist/{link-DAXOT-G_.mjs → link-BlRTGHan.mjs} +6 -6
- package/dist/{list-BYSOo9fm.mjs → list-iCg7d5Pa.mjs} +7 -7
- package/dist/{live-DF4HUl2m.mjs → live-CYJ4KGoR.mjs} +2 -2
- package/dist/{live-0xrcVpyq.d.mts → live-zKGbRT4h.d.mts} +2 -2
- package/dist/{local-d1-BLgsNUj9.mjs → local-d1-CFcH9Bx3.mjs} +2 -2
- package/dist/login-C4q1S-5b.mjs +1 -0
- package/dist/{login-CJopTWX4.mjs → login-TA51e5Fw.mjs} +5 -5
- package/dist/{logs-DE0weBsR.mjs → logs-BlyAxlvx.mjs} +6 -6
- package/dist/{migrate-ChHHZBTi.mjs → migrate-BH6LCr00.mjs} +6 -6
- package/dist/migrate-CVBsSFhC.mjs +1 -0
- package/dist/nitro.d.mts +5 -0
- package/dist/nitro.mjs +27 -8
- package/dist/{node-CZ6lGNLn.mjs → node-B0otYjDv.mjs} +4 -4
- package/dist/{operator-args-D79WQP70.mjs → operator-args-DuKAQ3Ks.mjs} +1 -1
- package/dist/{operator-auth-CfDcmzpo.mjs → operator-auth-CD3pap65.mjs} +1 -1
- package/dist/{operator-client-BIY4-N_6.mjs → operator-client-XvXTkea6.mjs} +2 -2
- package/dist/{operator-cmd-BUqsdk2K.mjs → operator-cmd-CoHlJjcT.mjs} +7 -7
- package/dist/operator-cmd-DnaCnCSP.mjs +1 -0
- package/dist/output-CNsMDEd2.mjs +1 -0
- package/dist/{output-BCdLioKP.mjs → output-CXJTIAtF.mjs} +1 -1
- package/dist/pages/client.d.mts +18 -13
- package/dist/pages/client.mjs +40 -69
- package/dist/pages/index.d.mts +4 -3
- package/dist/pages/index.mjs +11 -7
- package/dist/pages/islands-plugin.mjs +1 -1
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +1 -1
- package/dist/pages/serialize.d.mts +2 -2
- package/dist/pages/serialize.mjs +1 -1
- package/dist/platform-args-B7-wQ0_B.mjs +1 -0
- package/dist/{platform-args-Cx1M-7bq.mjs → platform-args-DfT8yQBF.mjs} +1 -1
- package/dist/{platform-auth-config-K4m_LE8b.mjs → platform-auth-config-MO0VdVs9.mjs} +10 -10
- package/dist/{platform-auth-protection-KF5Vo-1I.mjs → platform-auth-protection-Dv208eyL.mjs} +8 -8
- package/dist/{platform-auth-recovery-BOdFrl7R.mjs → platform-auth-recovery-DvAQ674F.mjs} +7 -7
- package/dist/{platform-cmd-DpCHawGF.mjs → platform-cmd-BpUA19r_.mjs} +1 -1
- package/dist/{platform-cmd-Ds3EAV5t.mjs → platform-cmd-dlSxrcQ7.mjs} +9 -9
- package/dist/{platform-domain-rWJshybd.mjs → platform-domain-DSO4eUEw.mjs} +5 -5
- package/dist/{platform-lifecycle-D9RdGub1.mjs → platform-lifecycle-BSvsyB_x.mjs} +17 -17
- package/dist/{platform-lifecycle-BH34I0rh.mjs → platform-lifecycle-CfcFygHb.mjs} +1 -1
- package/dist/{platform-management-BfLW0Zlo.mjs → platform-management-BMdyt667.mjs} +1 -1
- package/dist/{platform-management-BRefdHGD.mjs → platform-management-CrP1XhVd.mjs} +4 -4
- package/dist/{platform-plans-config-Dx1agneU.mjs → platform-plans-config-CgDiwflR.mjs} +5 -5
- package/dist/{platform-recovery-DZuZGJtt.mjs → platform-recovery-CHWwXVZ6.mjs} +3 -3
- package/dist/{platform-setup-Vw1AaUN8.mjs → platform-setup-BTQVbnTC.mjs} +3 -3
- package/dist/{plugin-inference-CdLbxZL_.mjs → plugin-inference-g66Q1Mx9.mjs} +5 -8
- package/dist/prepare-Bx4a8cb1.mjs +1 -0
- package/dist/{prepare-BuNbuFlA.mjs → prepare-DJYHjpzq.mjs} +3 -3
- package/dist/{prepare-BerOZiD4.mjs → prepare-DXduEwQp.mjs} +12 -9
- package/dist/{prerender-render-RlAj6hh8.mjs → prerender-render-BN9Lmebs.mjs} +29 -13
- package/dist/prerender-render.d.mts +10 -2
- package/dist/prerender-render.mjs +1 -1
- package/dist/{project-cmd-B_bUyZ3J.mjs → project-cmd-Dfb1Sg8w.mjs} +18 -18
- package/dist/{project-paths-CdGv9Tmi.mjs → project-paths-G0yut6Zz.mjs} +12 -8
- package/dist/{project-team-MjT5K4rQ.mjs → project-team-BO2dyc7S.mjs} +5 -5
- package/dist/{project-token-BKHGwY3k.mjs → project-token-ByO2mEI2.mjs} +5 -5
- package/dist/{project-tsconfig-Cf2NFjlM.mjs → project-tsconfig-nhnTWO_Y.mjs} +4 -2
- package/dist/{project-zero-trust-Bzdd05-h.mjs → project-zero-trust-CoQfwRBR.mjs} +5 -5
- package/dist/{protocol-CkwjASep.d.mts → protocol-xZMvWsrg.d.mts} +5 -3
- package/dist/{protocol-COyySMki.mjs → protocol-yxdHxFLN.mjs} +47 -11
- package/dist/{provision-DQF6Kw-6.mjs → provision-CMH4-8ri.mjs} +1 -1
- package/dist/{provision-BbCzpbXs.mjs → provision-D5q-ptD3.mjs} +2 -2
- package/dist/{requests-daJmVpjk.mjs → requests-CPOiDkjh.mjs} +4 -4
- package/dist/resolve-project-BALVa9q0.mjs +1 -0
- package/dist/{resolve-project-D0YNnJfm.mjs → resolve-project-ClvLMTI9.mjs} +1 -1
- package/dist/{rollback-BgL0wY1J.mjs → rollback-BfCs2la4.mjs} +7 -7
- package/dist/{route-types-CZc1YXjF.mjs → route-types-Cl3x0Q8B.mjs} +265 -12
- package/dist/{route-url-C_YIH_zO.d.mts → route-url-C3JwYrER.d.mts} +8 -3
- package/dist/{route-url-CRDF-I0I.mjs → route-url-CfCR4oMj.mjs} +4 -3
- package/dist/routes-stub.d.mts +10 -1
- package/dist/routes-stub.mjs +1 -1
- package/dist/{runner-QMeOpScZ.mjs → runner-CTk21HrO.mjs} +1 -1
- package/dist/{runner-mysql-0zVmB1JW.mjs → runner-mysql-CHvEg_sy.mjs} +1 -1
- package/dist/runtime/ai.mjs +1 -1
- package/dist/runtime/auth.d.mts +2 -2
- package/dist/runtime/auth.mjs +1 -1
- package/dist/runtime/better-auth-mysql.d.mts +1 -1
- package/dist/runtime/better-auth-mysql.mjs +1 -1
- package/dist/runtime/better-auth-pg.d.mts +1 -1
- package/dist/runtime/better-auth-pg.mjs +1 -1
- package/dist/runtime/better-auth.d.mts +1 -1
- package/dist/runtime/better-auth.mjs +1 -1
- package/dist/runtime/client-react.d.mts +3 -3
- package/dist/runtime/client-react.mjs +2 -2
- package/dist/runtime/client-solid.d.mts +3 -3
- package/dist/runtime/client-solid.mjs +2 -2
- package/dist/runtime/client-svelte.d.mts +3 -3
- package/dist/runtime/client-svelte.mjs +2 -2
- package/dist/runtime/client-vue.d.mts +3 -3
- package/dist/runtime/client-vue.mjs +2 -2
- package/dist/runtime/client.d.mts +3 -3
- package/dist/runtime/client.mjs +2 -2
- package/dist/runtime/email/testing.mjs +2 -2
- package/dist/runtime/email.mjs +3 -3
- package/dist/runtime/env-public.mjs +2 -46
- package/dist/runtime/fetch-server.d.mts +1 -1
- package/dist/runtime/fetch-server.mjs +1 -1
- package/dist/runtime/fetch-stream.d.mts +2 -2
- package/dist/runtime/fetch-stream.mjs +1 -1
- package/dist/runtime/fetch.d.mts +1 -1
- package/dist/runtime/fetch.mjs +1 -1
- package/dist/runtime/handler.d.mts +1 -1
- package/dist/runtime/handler.mjs +1 -1
- package/dist/runtime/isr.d.mts +3 -1
- package/dist/runtime/live-client.d.mts +11 -2
- package/dist/runtime/live-client.mjs +8 -0
- package/dist/runtime/live-server.mjs +1 -1
- package/dist/runtime/live.d.mts +1 -1
- package/dist/runtime/live.mjs +1 -1
- package/dist/runtime/log.mjs +1 -1
- package/dist/runtime/remote/index.mjs +1 -1
- package/dist/runtime/route-url.d.mts +2 -2
- package/dist/runtime/route-url.mjs +1 -1
- package/dist/runtime/routing.d.mts +15 -4
- package/dist/runtime/routing.mjs +94 -12
- package/dist/runtime/sandbox.mjs +1 -1
- package/dist/runtime/sse-client.d.mts +9 -1
- package/dist/runtime/sse-client.mjs +7 -0
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/validator.mjs +1 -1
- package/dist/runtime/ws-server.d.mts +3 -3
- package/dist/runtime/ws-server.mjs +1 -1
- package/dist/runtime/ws.d.mts +1 -1
- package/dist/runtime/ws.mjs +1 -1
- package/dist/{scan-X2rDDRNa.mjs → scan-L8OSv1f7.mjs} +68 -19
- package/dist/{secret-CPq-B_vp.mjs → secret-CuI6LTpD.mjs} +7 -7
- package/dist/serialize-DN-envGQ.d.mts +18 -0
- package/dist/serialize-Pf-CIQK_.mjs +39 -0
- package/dist/{skills-D393E4lB.mjs → skills-BBO9wMjB.mjs} +1 -1
- package/dist/{subcommand-prompt-CxJXporl.mjs → subcommand-prompt-BZMnCA8T.mjs} +2 -2
- package/dist/url-CuoEn0o3.mjs +43 -0
- package/dist/validator-8-NZs2Xr.mjs +168 -0
- package/dist/{version-metadata-C8hLzQkv.mjs → version-metadata-eUd6Ar_U.mjs} +1 -1
- package/dist/wrangler-R3kMdJfw.mjs +1 -0
- package/dist/{wrangler-DESSbN8L.mjs → wrangler-k40T7XTQ.mjs} +3 -3
- package/dist/{wrapper-C9SUxoj7.mjs → wrapper-BGsi_uHs.mjs} +12 -9
- package/dist/{ws-Dmjg5NH2.d.mts → ws-DB8Feytg.d.mts} +2 -2
- package/docs/guide/ai.md +2 -0
- package/docs/guide/auth.md +62 -0
- package/docs/guide/database.md +33 -0
- package/docs/guide/deployment.md +8 -0
- package/docs/guide/edge/headers.md +3 -1
- package/docs/guide/edge/prerendering.md +9 -4
- package/docs/guide/edge/redirects.md +1 -0
- package/docs/guide/edge/revalidation.md +3 -0
- package/docs/guide/edge/static-assets.md +1 -1
- package/docs/guide/live.md +2 -0
- package/docs/guide/pages-routing/actions-and-forms.md +29 -10
- package/docs/guide/pages-routing/head.md +3 -1
- package/docs/guide/pages-routing/islands.md +1 -1
- package/docs/guide/pages-routing/loaders.md +2 -0
- package/docs/guide/pages-routing/markdown.md +2 -2
- package/docs/guide/pages-routing/overview.md +139 -10
- package/docs/guide/quickstart.md +1 -0
- package/docs/guide/server-routing.md +14 -0
- package/docs/guide/sse.md +2 -0
- package/docs/guide/ssg.md +23 -2
- package/docs/guide/storage.md +6 -2
- package/docs/guide/type-safety.md +307 -26
- package/docs/guide/typed-fetch.md +7 -3
- package/docs/guide/websockets.md +5 -5
- package/docs/integrations/cloudflare.md +10 -10
- package/docs/integrations/frameworks/nuxt.md +2 -0
- package/docs/integrations/frameworks/overview.md +2 -0
- package/docs/integrations/nodejs-bun-deno.md +65 -0
- package/docs/reference/api/auth.md +19 -0
- package/docs/reference/api/client.md +6 -4
- package/docs/reference/api/handlers.md +3 -1
- package/docs/reference/api/pages.md +16 -8
- package/docs/reference/api/resources.md +3 -1
- package/docs/reference/api/rewrites.md +19 -5
- package/docs/reference/api/types.md +9 -2
- package/docs/reference/cli/database.md +2 -0
- package/docs/reference/cli/deploy.md +17 -11
- package/docs/reference/cli.md +3 -0
- package/docs/reference/config.md +24 -2
- package/package.json +25 -23
- package/schema.json +4 -0
- package/skills/void/SKILL.md +5 -0
- package/dist/cf-build-output-CmDOcA7K.mjs +0 -1
- package/dist/client-CEtr5UOR.mjs +0 -1
- package/dist/deploy-B029oHlE.mjs +0 -2
- package/dist/discover-D4mQthao.mjs +0 -1
- package/dist/gen-cCxrFp9L.mjs +0 -1
- package/dist/help-Ba8Dq5-r.mjs +0 -1
- package/dist/login-BpbYeu-n.mjs +0 -1
- package/dist/migrate-HdA6Kh2p.mjs +0 -1
- package/dist/operator-cmd-wBYyp8iQ.mjs +0 -1
- package/dist/output-E6gecbbV.mjs +0 -1
- package/dist/platform-args-C7XUw9mw.mjs +0 -1
- package/dist/prepare-Cz18kLkF.mjs +0 -1
- package/dist/resolve-project-CgfjtOwz.mjs +0 -1
- package/dist/serialize-DUuYuaY3.mjs +0 -29
- package/dist/serialize-I4EmS-Wf.d.mts +0 -16
- package/dist/validator-CTfmzZYb.mjs +0 -69
- package/dist/wrangler-DUB3MGHV.mjs +0 -1
- package/dist/{cf-access-BmBT2h8_.mjs → cf-access-Dnyw8KFY.mjs} +1 -1
- package/dist/{inbound-CdO-qY0w.mjs → inbound-C2H6Dzz1.mjs} +2 -2
- package/dist/{runner-5MCSimKx.mjs → runner-CMZb7jNU.mjs} +1 -1
- package/dist/{runner-mysql-Bdmsp_x4.mjs → runner-mysql-BXfcQQj3.mjs} +1 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// src/runtime/validator.ts
|
|
2
|
+
function flattenIssues(issues) {
|
|
3
|
+
return Array.from(issues, (issue) => ({
|
|
4
|
+
message: issue.message,
|
|
5
|
+
path: issue.path?.map((p) => typeof p === "object" ? p.key : p).join(".")
|
|
6
|
+
}));
|
|
7
|
+
}
|
|
8
|
+
async function validateSlot(schema, value) {
|
|
9
|
+
const result = await schema["~standard"].validate(value);
|
|
10
|
+
if (result.issues) return {
|
|
11
|
+
ok: false,
|
|
12
|
+
issues: result.issues
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
ok: true,
|
|
16
|
+
value: result.value
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const MAX_FORM_DEPTH = 32;
|
|
20
|
+
const MAX_FORM_NODES = 1e4;
|
|
21
|
+
const MAX_FORM_INDEX = 1e4;
|
|
22
|
+
function isFormContentType(contentType) {
|
|
23
|
+
const mediaType = contentType?.split(";", 1)[0]?.trim().toLowerCase();
|
|
24
|
+
return mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* `objectToFormData` writes nested fields as `a[b]`, array items as `a[0]`,
|
|
28
|
+
* and file lists as `a[]`. Split one of those keys into path segments.
|
|
29
|
+
* A key that is not entirely bracket-encoded stays a single literal segment.
|
|
30
|
+
*/
|
|
31
|
+
function formKeySegments(key) {
|
|
32
|
+
const bracket = key.indexOf("[");
|
|
33
|
+
if (bracket <= 0 || !key.endsWith("]")) return [key];
|
|
34
|
+
const segments = [key.slice(0, bracket)];
|
|
35
|
+
const rest = key.slice(bracket);
|
|
36
|
+
const pattern = /\[([^[\]]*)\]/g;
|
|
37
|
+
let consumed = 0;
|
|
38
|
+
let match;
|
|
39
|
+
while ((match = pattern.exec(rest)) !== null) {
|
|
40
|
+
if (match.index !== consumed) return [key];
|
|
41
|
+
segments.push(match[1] ?? "");
|
|
42
|
+
consumed = pattern.lastIndex;
|
|
43
|
+
if (segments.length > MAX_FORM_DEPTH) throw new Error("Form field is nested too deeply");
|
|
44
|
+
}
|
|
45
|
+
if (consumed !== rest.length) return [key];
|
|
46
|
+
return segments;
|
|
47
|
+
}
|
|
48
|
+
function arrayIndex(segment) {
|
|
49
|
+
if (segment !== "0" && !/^[1-9]\d*$/.test(segment)) return null;
|
|
50
|
+
if (segment.length > 5) throw new Error("Form field index is out of range");
|
|
51
|
+
const index = Number(segment);
|
|
52
|
+
if (index > MAX_FORM_INDEX) throw new Error("Form field index is out of range");
|
|
53
|
+
return index;
|
|
54
|
+
}
|
|
55
|
+
function isContainerRecord(value) {
|
|
56
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Blob);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Rebuild the object `objectToFormData` flattened. Numeric segments and `[]`
|
|
60
|
+
* become arrays. Scalars are left as the client encoded them.
|
|
61
|
+
*/
|
|
62
|
+
function formRecordToObject(record) {
|
|
63
|
+
const root = {};
|
|
64
|
+
let nodes = 0;
|
|
65
|
+
const reserveNodes = (count) => {
|
|
66
|
+
nodes += count;
|
|
67
|
+
if (nodes > MAX_FORM_NODES) throw new Error("Form field has too many nested values");
|
|
68
|
+
};
|
|
69
|
+
const createContainer = (asArray) => {
|
|
70
|
+
reserveNodes(1);
|
|
71
|
+
return asArray ? [] : {};
|
|
72
|
+
};
|
|
73
|
+
const read = (parent, segment) => {
|
|
74
|
+
if (Array.isArray(parent)) return segment === "" ? void 0 : parent[Number(segment)];
|
|
75
|
+
return Object.hasOwn(parent, segment) ? parent[segment] : void 0;
|
|
76
|
+
};
|
|
77
|
+
const write = (parent, segment, value) => {
|
|
78
|
+
if (Array.isArray(parent)) {
|
|
79
|
+
const index = segment === "" ? parent.length : arrayIndex(segment);
|
|
80
|
+
if (index === null) throw new Error("Form field shape is inconsistent");
|
|
81
|
+
reserveNodes(Math.max(0, index + 1 - parent.length));
|
|
82
|
+
parent[index] = value;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
Object.defineProperty(parent, segment, {
|
|
86
|
+
value,
|
|
87
|
+
writable: true,
|
|
88
|
+
enumerable: true,
|
|
89
|
+
configurable: true
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
const assign = (segments, value) => {
|
|
93
|
+
let parent = root;
|
|
94
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
95
|
+
const segment = segments[i];
|
|
96
|
+
const next = segments[i + 1];
|
|
97
|
+
const nextIsArray = next === "" || arrayIndex(next) !== null;
|
|
98
|
+
const child = read(parent, segment);
|
|
99
|
+
const childIsContainer = nextIsArray ? Array.isArray(child) : isContainerRecord(child);
|
|
100
|
+
const container = childIsContainer ? child : createContainer(nextIsArray);
|
|
101
|
+
if (!childIsContainer) write(parent, segment, container);
|
|
102
|
+
parent = container;
|
|
103
|
+
}
|
|
104
|
+
write(parent, segments[segments.length - 1], value);
|
|
105
|
+
};
|
|
106
|
+
for (const [key, raw] of Object.entries(record)) {
|
|
107
|
+
const segments = formKeySegments(key);
|
|
108
|
+
const values = Array.isArray(raw) ? raw : [raw];
|
|
109
|
+
for (const value of values) assign(segments, value);
|
|
110
|
+
}
|
|
111
|
+
return root;
|
|
112
|
+
}
|
|
113
|
+
async function readBody(c) {
|
|
114
|
+
if (!isFormContentType(c.req.header("content-type"))) return c.req.json();
|
|
115
|
+
return formRecordToObject(await c.req.parseBody());
|
|
116
|
+
}
|
|
117
|
+
async function runValidation(validators, c) {
|
|
118
|
+
const input = {};
|
|
119
|
+
const allIssues = [];
|
|
120
|
+
if (validators.params) {
|
|
121
|
+
const raw = c.req.param();
|
|
122
|
+
const result = await validateSlot(validators.params, raw);
|
|
123
|
+
if (result.ok) input.params = result.value;
|
|
124
|
+
else allIssues.push({
|
|
125
|
+
slot: "params",
|
|
126
|
+
issues: flattenIssues(result.issues)
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (validators.query) {
|
|
130
|
+
const raw = Object.fromEntries(Object.entries(c.req.queries()).map(([key, values]) => [key, values.length === 1 ? values[0] : values]));
|
|
131
|
+
const result = await validateSlot(validators.query, raw);
|
|
132
|
+
if (result.ok) input.query = result.value;
|
|
133
|
+
else allIssues.push({
|
|
134
|
+
slot: "query",
|
|
135
|
+
issues: flattenIssues(result.issues)
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (validators.body) {
|
|
139
|
+
let raw;
|
|
140
|
+
const formBody = isFormContentType(c.req.header("content-type"));
|
|
141
|
+
try {
|
|
142
|
+
raw = await readBody(c);
|
|
143
|
+
} catch {
|
|
144
|
+
return {
|
|
145
|
+
ok: false,
|
|
146
|
+
response: Response.json({ error: formBody ? "Invalid form body" : "Invalid JSON body" }, { status: 400 })
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const result = await validateSlot(validators.body, raw);
|
|
150
|
+
if (result.ok) input.body = result.value;
|
|
151
|
+
else allIssues.push({
|
|
152
|
+
slot: "body",
|
|
153
|
+
issues: flattenIssues(result.issues)
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (allIssues.length > 0) return {
|
|
157
|
+
ok: false,
|
|
158
|
+
response: Response.json({
|
|
159
|
+
error: "Validation failed",
|
|
160
|
+
issues: allIssues
|
|
161
|
+
}, { status: 400 })
|
|
162
|
+
};
|
|
163
|
+
return {
|
|
164
|
+
ok: true,
|
|
165
|
+
input
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
export { runValidation as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as join } from "./dist-DMYe8CZJ.mjs";
|
|
2
|
-
import { l as bindingNamesForField, p as findBindingNameOwner } from "./wrangler-
|
|
2
|
+
import { l as bindingNamesForField, p as findBindingNameOwner } from "./wrangler-k40T7XTQ.mjs";
|
|
3
3
|
// src/shared/untrusted-env.ts
|
|
4
4
|
/** Authentication inputs that Wrangler may consume from the environment. */
|
|
5
5
|
const WRANGLER_AUTH_CREDENTIAL_ENV_VARS = [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { b as readRootWranglerConfig } from "./wrangler-k40T7XTQ.mjs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as join, c as resolve, n as dirname, o as normalize, t as basename } from "./dist-DMYe8CZJ.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { a as persistCloudflareConfig, i as materializeCloudflareConfig, r as ignoreMaterializedCloudflareConfig } from "./cloudflare-config-DtOGAbeB.mjs";
|
|
3
|
+
import { o as TYPED_CONFIG_FILE, s as loadTypedVoidConfigFile } from "./project-paths-G0yut6Zz.mjs";
|
|
4
|
+
import { h as validateConfig, p as readConfig } from "./config-5oSQhZNj.mjs";
|
|
5
5
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { parseSync } from "vite";
|
|
7
7
|
import { appendSqliteClassMigration, isRecord } from "@void/deploy-core";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { a as join, l as toSlash, n as dirname, r as extname } from "./dist-DMYe8CZJ.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
5
|
-
import { t as MagicString } from "./dist-B6eN80gc.mjs";
|
|
6
|
-
import { c as voidDbBundlerPlugin, r as cloudflareQueueName, t as generateQueueResolverSource } from "./dispatch-BNLB5_Gm.mjs";
|
|
2
|
+
import { l as getDatabaseDialect, p as readConfig } from "./config-5oSQhZNj.mjs";
|
|
3
|
+
import { c as voidDbBundlerPlugin, r as cloudflareQueueName, t as generateQueueResolverSource } from "./dispatch-pYaww76u.mjs";
|
|
4
|
+
import { n as readProjectPaths } from "./project-paths-G0yut6Zz.mjs";
|
|
7
5
|
import { t as WORKER_CONDITIONS } from "./worker-conditions-CBZ0RYsZ.mjs";
|
|
6
|
+
import { t as MagicString } from "./dist-B6eN80gc.mjs";
|
|
7
|
+
import { n as isIdentifier, r as isLiteral } from "./ast-Cv0JwXqb.mjs";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
9
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
10
10
|
import { build, parseSync } from "vite";
|
|
@@ -127,10 +127,13 @@ async function generateWrapper(workerDir, workerMain, root, features) {
|
|
|
127
127
|
config,
|
|
128
128
|
sqlDriver: (dialect, entry) => bundleWorkerSqlDriver(dialect, entry, join(tmpDir, "sql-driver"))
|
|
129
129
|
})],
|
|
130
|
-
resolve: {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
resolve: {
|
|
131
|
+
conditions: [...WORKER_CONDITIONS, "production"],
|
|
132
|
+
alias: [{
|
|
133
|
+
find: /^void$/,
|
|
134
|
+
replacement: fileURLToPath(import.meta.resolve("void/handler"))
|
|
135
|
+
}]
|
|
136
|
+
},
|
|
134
137
|
build: {
|
|
135
138
|
outDir,
|
|
136
139
|
emptyOutDir: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as StandardSchemaV1 } from "./standard-schema-CuDawHOC.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { a as CloudEnv } from "./handler-
|
|
2
|
+
import { i as AuthUser } from "./auth-CZrthGxs.mjs";
|
|
3
|
+
import { a as CloudEnv } from "./handler-DjqciiDc.mjs";
|
|
4
4
|
import { WebSocketRouteMap } from "void/routes";
|
|
5
5
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
6
|
type ParamsRecord = Record<string, string>;
|
package/docs/guide/ai.md
CHANGED
|
@@ -28,6 +28,8 @@ account shown by `void cloudflare status`, or set `CLOUDFLARE_API_TOKEN`.
|
|
|
28
28
|
|
|
29
29
|
For a team platform, use `void connect <platform-url>` and link your project.
|
|
30
30
|
Development requests use that platform's account and usage limits.
|
|
31
|
+
If the platform reports that AI is disabled, ask your administrator to enable it.
|
|
32
|
+
This also applies to model listing, Markdown conversion, and provider-native requests.
|
|
31
33
|
|
|
32
34
|
## Basic Usage
|
|
33
35
|
|
package/docs/guide/auth.md
CHANGED
|
@@ -118,9 +118,71 @@ import { getSession, getUser, requireAuth } from 'void/auth';
|
|
|
118
118
|
- `getUser()` returns the current `AuthUser | null`
|
|
119
119
|
- `getSession()` returns `{ user, session } | null`
|
|
120
120
|
- `requireAuth(c)` returns the authenticated user or throws `401`
|
|
121
|
+
- [`getAuth(c)`](../reference/api/auth.md#getauth-c) returns the request's Better Auth instance, with plugin APIs inferred from `auth.ts`, for use with Better Auth helpers.
|
|
121
122
|
|
|
122
123
|
Import `AuthUser` and `AuthSession` from `void/auth` for type annotations. They include the fields your Better Auth plugins and `user.additionalFields` add, such as `role` from `admin()`. See their fields in the [API reference](../reference/api/auth.md#authuser).
|
|
123
124
|
|
|
125
|
+
## Querying Authentication Tables
|
|
126
|
+
|
|
127
|
+
When authentication is enabled, Void generates the Better Auth Drizzle schema in `.void/better-auth-schema.ts`.
|
|
128
|
+
The generated file exports the core authentication tables:
|
|
129
|
+
|
|
130
|
+
- `userTable`
|
|
131
|
+
- `sessionTable`
|
|
132
|
+
- `accountTable`
|
|
133
|
+
- `verificationTable`
|
|
134
|
+
|
|
135
|
+
Configured Better Auth plugins may also contribute additional tables.
|
|
136
|
+
|
|
137
|
+
The generated file path and core table export names are documented integration points. You can import these exports directly rather than recreating the tables in your application.
|
|
138
|
+
|
|
139
|
+
To import these tables into your application, add a TypeScript path alias to your root `tsconfig.json`:
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"compilerOptions": {
|
|
144
|
+
"paths": {
|
|
145
|
+
"@auth-schema": ["./.void/better-auth-schema.ts"]
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
If your `tsconfig.json` already has a `paths` mapping, add `@auth-schema` to the existing mapping rather than replacing it.
|
|
152
|
+
|
|
153
|
+
If your project extends `.void/tsconfig.json` and defines its own `paths`, make sure to retain any mappings from the generated configuration that your project uses, such as `@schema`.
|
|
154
|
+
|
|
155
|
+
You can now import and query authentication tables:
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
import { userTable } from '@auth-schema';
|
|
159
|
+
import { db, desc } from 'void/db';
|
|
160
|
+
|
|
161
|
+
export function listUsers() {
|
|
162
|
+
return db.select().from(userTable).orderBy(desc(userTable.createdAt));
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
You can also reference authentication tables when defining your own Drizzle tables:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
import { userTable } from '@auth-schema';
|
|
170
|
+
import { sqliteTable, text } from 'void/schema-d1';
|
|
171
|
+
|
|
172
|
+
export const postTable = sqliteTable('post', {
|
|
173
|
+
id: text('id').primaryKey(),
|
|
174
|
+
userId: text('user_id')
|
|
175
|
+
.notNull()
|
|
176
|
+
.references(() => userTable.id, { onDelete: 'cascade' }),
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
This example assumes the default text ID strategy. If you configure `advanced.database.generateId: 'serial'`, use an integer foreign-key column to match the generated user ID.
|
|
181
|
+
|
|
182
|
+
The example above uses SQLite/D1. For PostgreSQL and MySQL, use the corresponding schema modules: `void/schema-pg` and `void/schema-mysql`.
|
|
183
|
+
|
|
184
|
+
The generated schema is managed by Void. Do not edit `.void/better-auth-schema.ts` manually, as Void may regenerate it during its build or preparation process.
|
|
185
|
+
|
|
124
186
|
## Behavior
|
|
125
187
|
|
|
126
188
|
Auth sessions use the same database as your app. Void creates `BETTER_AUTH_SECRET` on deploy if it is missing and reuses it on later deploys.
|
package/docs/guide/database.md
CHANGED
|
@@ -385,6 +385,39 @@ npm install arktype
|
|
|
385
385
|
|
|
386
386
|
See the [CLI reference](../reference/cli/database.md#database) for connection setup, SQL execution, Studio, exports, and other commands.
|
|
387
387
|
|
|
388
|
+
## Adopt an existing Drizzle PostgreSQL database {#adopt-existing-drizzle}
|
|
389
|
+
|
|
390
|
+
You can keep a PostgreSQL database that Drizzle has already migrated. Void tracks applied files separately, so record the existing history before the first Void deployment.
|
|
391
|
+
|
|
392
|
+
1. Back up the database and pause deployments. Try the procedure on a restored copy first.
|
|
393
|
+
2. Set `database: 'pg'` in `void.config.ts`. Keep your existing schema, SQL filenames, and `db/migrations/meta/` directory. Do not regenerate or rename migrations during adoption.
|
|
394
|
+
3. Check the database's Drizzle history against `meta/_journal.json` and your SQL files. Match each applied row's `created_at` to the journal entry's `when`, and its `hash` to the SHA-256 of the corresponding SQL file. Drizzle normally stores this history in `drizzle.__drizzle_migrations`; use your configured schema and table if different. If a file cannot be verified, resolve the discrepancy before continuing.
|
|
395
|
+
|
|
396
|
+
```sql
|
|
397
|
+
SELECT hash, created_at FROM drizzle.__drizzle_migrations ORDER BY created_at;
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
4. Save the following as `adopt-void.sql`, replacing the example filenames with **only the migrations verified as already applied to this database**, including `.sql`. Leave new, unapplied files out of the list.
|
|
401
|
+
|
|
402
|
+
```sql [adopt-void.sql]
|
|
403
|
+
BEGIN;
|
|
404
|
+
CREATE TABLE IF NOT EXISTS _void_migrations (
|
|
405
|
+
name TEXT PRIMARY KEY,
|
|
406
|
+
applied_at TEXT NOT NULL
|
|
407
|
+
);
|
|
408
|
+
INSERT INTO _void_migrations (name, applied_at)
|
|
409
|
+
VALUES
|
|
410
|
+
('0000_create_users.sql', CURRENT_TIMESTAMP::text),
|
|
411
|
+
('0001_add_email.sql', CURRENT_TIMESTAMP::text)
|
|
412
|
+
ON CONFLICT (name) DO NOTHING;
|
|
413
|
+
COMMIT;
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
5. Run the file against the existing database with your PostgreSQL client, stopping on errors. Use the same database and PostgreSQL search path that Void will use. This records the verified filenames without executing their SQL or changing Drizzle's history.
|
|
417
|
+
6. Configure Void's connection to that database and run `void db status`. Verify that only new migrations are pending, then deploy. For direct Cloudflare deployments, provide that database's `DATABASE_URL` in the shell or CI environment running `void deploy`.
|
|
418
|
+
|
|
419
|
+
Repeat the verification and adoption separately for each database. An entry in one environment's history does not prove that another environment has applied it. Leave Drizzle's history table intact, and use Void for subsequent migrations.
|
|
420
|
+
|
|
388
421
|
## Hand-written migrations {#hand-written-migrations}
|
|
389
422
|
|
|
390
423
|
Deploy compares your Drizzle schema with the snapshots in `db/migrations/meta/`. If you have SQL migrations without this metadata, running `void db generate` would create another migration for the same tables.
|
package/docs/guide/deployment.md
CHANGED
|
@@ -35,6 +35,14 @@ void db generate
|
|
|
35
35
|
|
|
36
36
|
Review and commit the SQL, then deploy again. Rollback does not reverse database migrations. See [Database](./database.md) for the local workflow.
|
|
37
37
|
|
|
38
|
+
When migrations run in a separate release step, or a preview shares an existing database, deploy code without applying application or authentication SQL migrations:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
void deploy --skip-migrations
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This works with both deployment destinations. Ensure the app supports the database's current schema. Migration files and schema checks still apply, and the next normal deploy applies any pending migrations. See [the deploy options](../reference/cli/deploy.md#void-deploy) and [`void db migrate`](../reference/cli/database.md#void-db-migrate) for supported ways to apply migrations separately.
|
|
45
|
+
|
|
38
46
|
For D1 on your own Cloudflare account, deploy saves a restore point before applying migrations and prints a [`void db restore`](../reference/cli/database.md#void-db-restore) command. Use it to recover from a bad migration, then fix the migration before deploying again. A restore discards writes made after that point; check that your deployed code works with the restored schema. See the command reference for the recovery steps and retention limits.
|
|
39
47
|
|
|
40
48
|
### Environment variables
|
|
@@ -45,4 +45,6 @@ During local development, with `void deploy --platform cloudflare`, and on [othe
|
|
|
45
45
|
|
|
46
46
|
## Framework `_headers` files
|
|
47
47
|
|
|
48
|
-
Void reads `_headers` files produced by supported frameworks. Your `routing.headers` rules run afterward, so they can override framework defaults.
|
|
48
|
+
On a Void platform, Void reads `_headers` files produced by supported frameworks. Your `routing.headers` rules run afterward, so they can override framework defaults.
|
|
49
|
+
|
|
50
|
+
For native Cloudflare framework deployments, put a `_headers` file in your framework's public asset directory to configure static asset responses. Void includes the built file when it uploads a Worker version, including deployments that keep existing Worker secrets. These rules do not apply to responses generated by a Worker.
|
|
@@ -22,18 +22,21 @@ Pages without dynamic params do not need `getPrerenderPaths()`.
|
|
|
22
22
|
|
|
23
23
|
## Dynamic pages (with params)
|
|
24
24
|
|
|
25
|
-
For pages with URL params, also export `getPrerenderPaths()` to specify which param combinations to prerender
|
|
25
|
+
For pages with URL params, also export `getPrerenderPaths()` to specify which param combinations to prerender. Annotate the return type with [`PageParams`](../../reference/api/types.md#route-types) for that page's URL pattern, such as `/blog/:slug` for `pages/blog/[slug].server.ts`. TypeScript then requires each object to include those params, so a missing or misspelled key is a type error. Void does not infer this type from the filename.
|
|
26
26
|
|
|
27
27
|
```ts
|
|
28
28
|
// pages/blog/[slug].server.ts
|
|
29
|
+
import type { PageParams } from 'void/routes';
|
|
30
|
+
|
|
29
31
|
export const prerender = true;
|
|
30
32
|
|
|
31
|
-
export async function getPrerenderPaths() {
|
|
32
|
-
// Return param objects matching the URL pattern
|
|
33
|
+
export async function getPrerenderPaths(): Promise<PageParams<'/blog/:slug'>[]> {
|
|
33
34
|
return [{ slug: 'hello-world' }, { slug: 'getting-started' }];
|
|
34
35
|
}
|
|
35
36
|
```
|
|
36
37
|
|
|
38
|
+
Each object must include every param in the page path. Values can be strings or numbers, and Void URL-encodes them. A single-segment param such as `[slug]` cannot contain `/`. For nested paths, use a catch-all page such as `pages/docs/[...slug]` and return `{ slug: 'guides/intro' }`. If an entry is invalid, `void deploy` fails. The error names the server file and the entry index.
|
|
39
|
+
|
|
37
40
|
## Custom SSR
|
|
38
41
|
|
|
39
42
|
In custom SSR mode (`src/main.ssr.ts`), export `getPrerenderPaths()` at the top level. Since there's no file-based routing, return full path strings:
|
|
@@ -42,11 +45,13 @@ In custom SSR mode (`src/main.ssr.ts`), export `getPrerenderPaths()` at the top
|
|
|
42
45
|
// src/main.ssr.ts
|
|
43
46
|
export const prerender = true;
|
|
44
47
|
|
|
45
|
-
export async function getPrerenderPaths() {
|
|
48
|
+
export async function getPrerenderPaths(): Promise<string[]> {
|
|
46
49
|
return ['/', '/about', '/blog/hello-world'];
|
|
47
50
|
}
|
|
48
51
|
```
|
|
49
52
|
|
|
53
|
+
Annotate this return type as an array of path strings. Use `PageParams` on file-based pages, where the function returns param objects.
|
|
54
|
+
|
|
50
55
|
## Relationship to revalidation
|
|
51
56
|
|
|
52
57
|
Setting `routing.isr: false` in `void.config.ts` disables ISR and this edge-prerendering behavior, including per-page exports. It does not disable build-time HTML generation with `output: "static"`.
|
|
@@ -23,6 +23,7 @@ Define URL redirects in [`void.config.ts`](../../reference/config) using the `ro
|
|
|
23
23
|
- **Destinations** can be strings (default `302`) or objects with `to` and optional `status`. Supported statuses: `301`, `302`, `303`, `307`, `308`.
|
|
24
24
|
- `:splat` in the destination is replaced with the portion of the path matched by `*` in the source pattern.
|
|
25
25
|
- Destination query strings are merged into the `Location` header (the destination's parameters take precedence on per-key conflict). To drop the incoming query, write an explicit reset like `?`.
|
|
26
|
+
- `c.redirect()` in a handler, loader, or middleware sends that location unchanged and does not append the request query. A named action still drops its action key when the browser follows with GET, and keeps the page's other parameters. See [`c.redirect()`](../../reference/api/rewrites.md#c-rewrite-destination).
|
|
26
27
|
- When multiple rules match, the **first match wins**. Put specific patterns before catch-all patterns.
|
|
27
28
|
- Redirects are evaluated **before** the request reaches the worker, so they short-circuit static asset serving, ISR, and SSR.
|
|
28
29
|
|
|
@@ -119,6 +119,7 @@ Purge the destination pathname with `revalidate({ paths })`. Purging `/en/docs/f
|
|
|
119
119
|
You can purge ISR cache entries programmatically from a route handler:
|
|
120
120
|
|
|
121
121
|
```ts
|
|
122
|
+
import { defineHandler } from 'void';
|
|
122
123
|
import { revalidate } from 'void/isr';
|
|
123
124
|
|
|
124
125
|
export const POST = defineHandler(async (c) => {
|
|
@@ -133,3 +134,5 @@ export const POST = defineHandler(async (c) => {
|
|
|
133
134
|
return c.json({ ok: true });
|
|
134
135
|
});
|
|
135
136
|
```
|
|
137
|
+
|
|
138
|
+
With [`routing.typedRoutes`](../../reference/config.md#routing-typedroutes) on, each path must match one of your routes. Cast a path that TypeScript can't check, such as one from a webhook payload, with `as RouteUrl` from `void/routes`. The cast turns the check off for that path.
|
|
@@ -33,7 +33,7 @@ Supported meta-frameworks use their own asset directories automatically.
|
|
|
33
33
|
|
|
34
34
|
### Native Cloudflare deployments
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
For apps that use Void routing, `void deploy --platform cloudflare` gives generated JavaScript bundles with content fingerprints immutable caching. Framework integrations use their asset configuration and `_headers` file. Files copied from `public/` and custom build outputs with stable filenames keep normal revalidation, even when they live in the assets directory. CSS and other assets keep Cloudflare's default or your configured `Cache-Control`.
|
|
37
37
|
|
|
38
38
|
Use [Custom Headers](./headers) to choose a cache policy for other files. Apply immutable caching only to URLs that change whenever their content changes.
|
|
39
39
|
|
package/docs/guide/live.md
CHANGED
|
@@ -77,6 +77,8 @@ stream.close();
|
|
|
77
77
|
|
|
78
78
|
Subscription IDs are scoped to a connection. Reusing an ID replaces its subscription. After reconnecting, the helper restores active subscriptions and sends their latest `eventId` as `lastEventId`.
|
|
79
79
|
|
|
80
|
+
With [`routing.typedRoutes`](../reference/config.md#routing-typedroutes), the URL must match one of your routes or be an `http://` or `https://` URL. Cast a `string` that TypeScript can't check with `as RouteUrl` from `void/routes`. The cast turns off the check for that URL.
|
|
81
|
+
|
|
80
82
|
## Publish
|
|
81
83
|
|
|
82
84
|
Publish from any server-side code that has a Void runtime env:
|
|
@@ -24,10 +24,10 @@ export const action = defineHandler.withValidator({
|
|
|
24
24
|
});
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
| Action returns
|
|
28
|
-
|
|
|
29
|
-
| Nothing (void)
|
|
30
|
-
| `c.redirect(
|
|
27
|
+
| Action returns | Behavior |
|
|
28
|
+
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
29
|
+
| Nothing (void) | Re-runs the loader, page re-renders with fresh props. |
|
|
30
|
+
| `c.redirect(url)` | Navigates to another page. With [`routing.typedRoutes`](../type-safety.md#checked-url-strings), the location is checked the same way as a link. Cast a string TypeScript cannot check with `as Href`. |
|
|
31
31
|
|
|
32
32
|
Middleware does not run again after the action. To change [shared data](./layouts.md#shared-data), update it in the action or redirect.
|
|
33
33
|
|
|
@@ -173,7 +173,7 @@ For dynamic routes, pass `params` in the options:
|
|
|
173
173
|
|
|
174
174
|
```ts
|
|
175
175
|
// pages/users/[id].server.ts has an action
|
|
176
|
-
const form = useForm('/users
|
|
176
|
+
const form = useForm('/users/[id]', { name: '' }, { params: { id: '42' } });
|
|
177
177
|
<Form form={form} method="put">{/* submits to /users/42 */}</Form>
|
|
178
178
|
```
|
|
179
179
|
|
|
@@ -209,7 +209,7 @@ Actions and forms keep the current scroll position when updating the page in pla
|
|
|
209
209
|
Pass `preserveScroll: false` to reset scroll after an in-place update, or `true` to keep it even after a redirect:
|
|
210
210
|
|
|
211
211
|
```ts
|
|
212
|
-
await action('/users
|
|
212
|
+
await action('/users/[id]?update', {
|
|
213
213
|
params: { id: '42' },
|
|
214
214
|
data: { name: 'Alice' },
|
|
215
215
|
preserveScroll: false,
|
|
@@ -227,19 +227,22 @@ When a page needs multiple mutations, such as updating and deleting a user on th
|
|
|
227
227
|
import { users, updateUserSchema } from '@schema';
|
|
228
228
|
import { defineHandler } from 'void';
|
|
229
229
|
import { db, eq } from 'void/db';
|
|
230
|
+
import type { PageParams } from 'void/routes';
|
|
230
231
|
|
|
231
232
|
export const actions = {
|
|
232
233
|
update: defineHandler.withValidator({
|
|
233
234
|
body: updateUserSchema,
|
|
234
235
|
})(async (c, { body }) => {
|
|
236
|
+
const { id } = c.req.param() as PageParams<'/users/[id]'>;
|
|
235
237
|
await db
|
|
236
238
|
.update(users)
|
|
237
239
|
.set(body)
|
|
238
|
-
.where(eq(users.id, Number(
|
|
240
|
+
.where(eq(users.id, Number(id)));
|
|
239
241
|
}),
|
|
240
242
|
|
|
241
243
|
delete: defineHandler(async (c) => {
|
|
242
|
-
|
|
244
|
+
const { id } = c.req.param() as PageParams<'/users/[id]'>;
|
|
245
|
+
await db.delete(users).where(eq(users.id, Number(id)));
|
|
243
246
|
}),
|
|
244
247
|
};
|
|
245
248
|
```
|
|
@@ -266,7 +269,7 @@ export const actions = {
|
|
|
266
269
|
When a page exports named actions, append `?actionName` to the URL:
|
|
267
270
|
|
|
268
271
|
```ts
|
|
269
|
-
const form = useForm('/users
|
|
272
|
+
const form = useForm('/users/[id]?update', { name: '' }, { params: { id } });
|
|
270
273
|
<Form form={form} method="put">{/* submits to /users/42?update */}</Form>
|
|
271
274
|
```
|
|
272
275
|
|
|
@@ -279,7 +282,7 @@ Use `action()` for a button or other mutation that does not need form state. It
|
|
|
279
282
|
```ts
|
|
280
283
|
import { action } from '@void/react'; // or "@void/vue", "@void/svelte", "@void/solid"
|
|
281
284
|
|
|
282
|
-
const result = await action('/users
|
|
285
|
+
const result = await action('/users/[id]?delete', {
|
|
283
286
|
params: { id: '42' },
|
|
284
287
|
method: 'DELETE',
|
|
285
288
|
});
|
|
@@ -300,6 +303,20 @@ Expected errors such as `400`, `404`, `409`, `422`, and `429` stay with the form
|
|
|
300
303
|
|
|
301
304
|
Authentication errors (`401`, `403`), server errors (`500`, `502`), and unexpected failures are thrown. Handle them with your framework's error boundary or error handling.
|
|
302
305
|
|
|
306
|
+
Use `isVoidActionError()` to tell a failed action apart from other errors. It's `true` for a `VoidActionError` at any status, and narrows the error so you can read `status` and `message`. `isCallSiteActionError()` is `true` only for the expected errors that `action()` returns.
|
|
307
|
+
|
|
308
|
+
```ts
|
|
309
|
+
import { isVoidActionError } from '@void/react'; // or "@void/vue", "@void/svelte", "@void/solid"
|
|
310
|
+
|
|
311
|
+
function describeError(error: unknown) {
|
|
312
|
+
if (isVoidActionError(error)) {
|
|
313
|
+
if (error.status === 401) return 'Please sign in again.';
|
|
314
|
+
if (error.status === 403) return error.message;
|
|
315
|
+
}
|
|
316
|
+
return 'Something went wrong.';
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
303
320
|
Actions can throw `ValidationError` for custom validation logic:
|
|
304
321
|
|
|
305
322
|
```ts
|
|
@@ -426,6 +443,8 @@ export const action = defineHandler(async (c) => {
|
|
|
426
443
|
});
|
|
427
444
|
```
|
|
428
445
|
|
|
446
|
+
`withValidator({ body })` accepts the same upload. Nested names such as `profile[name]`, `tags[0]`, and `tags[]` are objects and arrays again. A multipart schema has to coerce the rest: booleans arrive as `'1'` or `'0'`, numbers and dates as strings, and `null` as `''`.
|
|
447
|
+
|
|
429
448
|
Pick the storage key on the server and allow only the file types you expect. See [Serving Files](../storage.md#serving-files) to send them back safely.
|
|
430
449
|
|
|
431
450
|
## Choosing a Primitive
|
|
@@ -13,13 +13,15 @@ Export a `head()` function from your `.server.ts` file. It receives the Hono con
|
|
|
13
13
|
```ts
|
|
14
14
|
// pages/posts/[slug].server.ts
|
|
15
15
|
import { defineHandler, defineHead } from 'void';
|
|
16
|
+
import type { PageParams } from 'void/routes';
|
|
16
17
|
|
|
17
18
|
export interface Props {
|
|
18
19
|
post: { title: string; excerpt: string; slug: string };
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export const loader = defineHandler<Props>(async (c) => {
|
|
22
|
-
const
|
|
23
|
+
const { slug } = c.req.param() as PageParams<'/posts/[slug]'>;
|
|
24
|
+
const post = await getPost(slug);
|
|
23
25
|
return { post };
|
|
24
26
|
});
|
|
25
27
|
|
|
@@ -344,7 +344,7 @@ export default function PostForm() {
|
|
|
344
344
|
|
|
345
345
|
:::
|
|
346
346
|
|
|
347
|
-
`useIslandForm` provides the same form state as [`useForm`](./actions-and-forms#useform). Pass the action URL to `post`, `put`, `patch`, or `delete` to submit.
|
|
347
|
+
`useIslandForm` provides the same form state as [`useForm`](./actions-and-forms#useform). Pass the action URL to `post`, `put`, `patch`, or `delete` to submit. With [`routing.typedRoutes`](../type-safety.md#checked-url-strings), that URL is a [`RouteUrl`](../../reference/api/types.md#route-types). Cast a path built at runtime with `as RouteUrl`.
|
|
348
348
|
|
|
349
349
|
Successful submissions reload the page; redirects navigate to their destination. A `422` response populates `errors` from `{ errors: { field: "message" } }`. Submit helpers return `Promise<void>`.
|
|
350
350
|
|
|
@@ -26,6 +26,8 @@ export const loader = defineHandler(async (c) => {
|
|
|
26
26
|
|
|
27
27
|
`InferProps` infers the loader’s return type, so page props stay in sync with the data it returns.
|
|
28
28
|
|
|
29
|
+
Void preserves `Date`, `Map`, `Set`, `bigint`, `RegExp`, `URL`, `undefined`, and repeated or cyclic references in page props and shared data. These values keep their types during server rendering, hydration, navigation, and deferred loading. Return data directly from your loader; explicitly returning `Response.json()` uses ordinary JSON conversion instead. Functions and custom class instances cannot be sent as page data.
|
|
30
|
+
|
|
29
31
|
## Using the Data in Page Components
|
|
30
32
|
|
|
31
33
|
The page component receives the loader's result as props. Export the inferred type from the server file so the component stays in sync:
|
|
@@ -136,13 +136,13 @@ Welcome to Void. Here's an interactive demo:
|
|
|
136
136
|
<Counter />
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
- **`<script>` block:** extracted before markdown compilation. Island imports use `with { island: "..." }` syntax (see [islands](./islands)). Any other code in the block becomes a [client script](#client-scripts) that runs in the browser.
|
|
139
|
+
- **`<script>` block:** extracted before markdown compilation. Island imports use `with { island: "..." }` syntax (see [islands](./islands)). The component file uses your framework's extension (`.vue`, `.tsx`, or `.svelte`). Any other code in the block becomes a [client script](#client-scripts) that runs in the browser.
|
|
140
140
|
- **Frontmatter:** YAML metadata between `---` fences. Layouts and islands can read it through [`useFrontmatter()`](#frontmatter-access).
|
|
141
141
|
- **Body:** standard markdown plus GFM. Uppercase tags such as `<Counter />` reference imported components and render as islands.
|
|
142
142
|
|
|
143
143
|
## Client Scripts
|
|
144
144
|
|
|
145
|
-
Use the `<script>` block for island imports and JavaScript that runs when the page loads:
|
|
145
|
+
Use the `<script>` block for island imports and JavaScript that runs when the page loads. Import the component with your framework's extension (`.vue`, `.tsx`, or `.svelte`):
|
|
146
146
|
|
|
147
147
|
```md
|
|
148
148
|
<script>
|