@timber-js/app 0.2.0-alpha.222 → 0.2.0-alpha.224
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/agent-skill.md +21 -5
- package/dist/_chunks/{actions-vBHr2vqd.js → actions-7dTXYJfu.js} +53 -24
- package/dist/_chunks/actions-7dTXYJfu.js.map +1 -0
- package/dist/_chunks/{als-registry-BZqHCtq-.js → als-registry-DpygwCp0.js} +2 -3
- package/dist/_chunks/{als-registry-BZqHCtq-.js.map → als-registry-DpygwCp0.js.map} +1 -1
- package/dist/_chunks/{als-slots-BEEIPKYm.js → als-slots-kbQrHTzm.js} +2 -3
- package/dist/_chunks/{als-slots-BEEIPKYm.js.map → als-slots-kbQrHTzm.js.map} +1 -1
- package/dist/_chunks/{base-path-DaQrzbez.js → base-path-DDIx0FXe.js} +2 -3
- package/dist/_chunks/{base-path-DaQrzbez.js.map → base-path-DDIx0FXe.js.map} +1 -1
- package/dist/_chunks/{build-manifest-DWppEdLB.js → build-manifest-Y4jl7nwU.js} +2 -3
- package/dist/_chunks/{build-manifest-DWppEdLB.js.map → build-manifest-Y4jl7nwU.js.map} +1 -1
- package/dist/_chunks/{build-output-helper-RV_BRcF1.js → build-output-helper-B7wWGTfR.js} +14 -10
- package/dist/_chunks/build-output-helper-B7wWGTfR.js.map +1 -0
- package/dist/_chunks/{cache-api-DdcDLpBj.js → cache-api-TDZ4hlDc.js} +190 -38
- package/dist/_chunks/cache-api-TDZ4hlDc.js.map +1 -0
- package/dist/_chunks/{canonicalize-BAWkWiKK.js → canonicalize-CqK135BN.js} +29 -4
- package/dist/_chunks/{canonicalize-BAWkWiKK.js.map → canonicalize-CqK135BN.js.map} +1 -1
- package/dist/_chunks/chains-CwOr3Myj.js +1 -0
- package/dist/_chunks/{chains-BchW_AtW.js → chains-Dgm3PrMe.js} +3 -4
- package/dist/_chunks/{chains-BchW_AtW.js.map → chains-Dgm3PrMe.js.map} +1 -1
- package/dist/_chunks/{classify-IqzMpxMs.js → classify--_kINHQV.js} +4 -5
- package/dist/_chunks/{classify-IqzMpxMs.js.map → classify--_kINHQV.js.map} +1 -1
- package/dist/_chunks/{cli-check-DQne_YhU.js → cli-check-Dv3f8d2j.js} +5 -6
- package/dist/_chunks/{cli-check-DQne_YhU.js.map → cli-check-Dv3f8d2j.js.map} +1 -1
- package/dist/_chunks/{cli-context-_mPttGGY.js → cli-context-CbZp32SK.js} +3 -4
- package/dist/_chunks/{cli-context-_mPttGGY.js.map → cli-context-CbZp32SK.js.map} +1 -1
- package/dist/_chunks/cli-context-n5hmkdla.js +1 -0
- package/dist/_chunks/cli-dev-status-prPMLU8G.js +138 -0
- package/dist/_chunks/cli-dev-status-prPMLU8G.js.map +1 -0
- package/dist/_chunks/cli-init-BoXOYYil.js +196 -0
- package/dist/_chunks/cli-init-BoXOYYil.js.map +1 -0
- package/dist/_chunks/{cli-schema-sync-BS-RFGE2.js → cli-schema-sync-DIPurq7X.js} +4 -5
- package/dist/_chunks/{cli-schema-sync-BS-RFGE2.js.map → cli-schema-sync-DIPurq7X.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-v872sHms.js → cli-schema-sync-uq72EZmD.js} +1 -1
- package/dist/_chunks/{client-dep-entries-BJyP9SIu.js → client-dep-entries-CP7AkMCM.js} +4 -5
- package/dist/_chunks/{client-dep-entries-BJyP9SIu.js.map → client-dep-entries-CP7AkMCM.js.map} +1 -1
- package/dist/_chunks/{cloudflare-Byxl8FWP.js → cloudflare-B75X6u4O.js} +10 -13
- package/dist/_chunks/{cloudflare-Byxl8FWP.js.map → cloudflare-B75X6u4O.js.map} +1 -1
- package/dist/_chunks/{codec-registry-oOUxugz3.js → codec-registry-CPc6bjVl.js} +2 -3
- package/dist/_chunks/{codec-registry-oOUxugz3.js.map → codec-registry-CPc6bjVl.js.map} +1 -1
- package/dist/_chunks/{codegen-Bps1sLKJ.js → codegen-B9oWkWGf.js} +5 -8
- package/dist/_chunks/{codegen-Bps1sLKJ.js.map → codegen-B9oWkWGf.js.map} +1 -1
- package/dist/_chunks/{convention-lint-VwzrtjIt.js → convention-lint-hZwz5wd4.js} +8 -11
- package/dist/_chunks/{convention-lint-VwzrtjIt.js.map → convention-lint-hZwz5wd4.js.map} +1 -1
- package/dist/_chunks/dev-discovery-YnabkCKD.js +238 -0
- package/dist/_chunks/dev-discovery-YnabkCKD.js.map +1 -0
- package/dist/_chunks/{dev-server-BNr5drEO.js → dev-server-B7o4As0l.js} +383 -55
- package/dist/_chunks/dev-server-B7o4As0l.js.map +1 -0
- package/dist/_chunks/dev-server-hZzmbMvK.js +1 -0
- package/dist/_chunks/{dev-store-BOa304m_.js → dev-store-BvdqtHvK.js} +82 -38
- package/dist/_chunks/dev-store-BvdqtHvK.js.map +1 -0
- package/dist/_chunks/{dist-DtrJyBbw.js → dist-C1Rjlo6s.js} +3 -5
- package/dist/_chunks/{dist-DtrJyBbw.js.map → dist-C1Rjlo6s.js.map} +1 -1
- package/dist/_chunks/{error-boundary-Bc8QPZuq.js → error-boundary-DRQXGWCp.js} +20 -27
- package/dist/_chunks/{error-boundary-Bc8QPZuq.js.map → error-boundary-DRQXGWCp.js.map} +1 -1
- package/dist/_chunks/{fast-hash-C-tVYrLb.js → fast-hash-DddxkU5Y.js} +2 -3
- package/dist/_chunks/{fast-hash-C-tVYrLb.js.map → fast-hash-DddxkU5Y.js.map} +1 -1
- package/dist/_chunks/{flight-source-node-BdHUOUqg.js → flight-source-node-0Tp6evlz.js} +6 -8
- package/dist/_chunks/flight-source-node-0Tp6evlz.js.map +1 -0
- package/dist/_chunks/{format-BKclgVbk.js → format-DuPOoXUP.js} +2 -3
- package/dist/_chunks/{format-BKclgVbk.js.map → format-DuPOoXUP.js.map} +1 -1
- package/dist/_chunks/{fs-identity-BRKuL215.js → fs-identity-BmQ_Agg-.js} +3 -5
- package/dist/_chunks/{fs-identity-BRKuL215.js.map → fs-identity-BmQ_Agg-.js.map} +1 -1
- package/dist/_chunks/{global-context-B9PFncvb.js → global-context-DbxNWeBP.js} +2 -3
- package/dist/_chunks/{global-context-B9PFncvb.js.map → global-context-DbxNWeBP.js.map} +1 -1
- package/dist/_chunks/{graph-cache-CYiUS2aS.js → graph-cache-B1LAg4t7.js} +5 -89
- package/dist/_chunks/graph-cache-B1LAg4t7.js.map +1 -0
- package/dist/_chunks/{href-validation-BIrxavIy.js → href-validation-CEZy1V-k.js} +4 -7
- package/dist/_chunks/{href-validation-BIrxavIy.js.map → href-validation-CEZy1V-k.js.map} +1 -1
- package/dist/_chunks/{json-lossy-check-C3Sht92C.js → json-lossy-check-DVkLUlfC.js} +3 -4
- package/dist/_chunks/{json-lossy-check-C3Sht92C.js.map → json-lossy-check-DVkLUlfC.js.map} +1 -1
- package/dist/_chunks/{live-graph-DEu_GWbc.js → live-graph-BcVjQ1Te.js} +6 -7
- package/dist/_chunks/{live-graph-DEu_GWbc.js.map → live-graph-BcVjQ1Te.js.map} +1 -1
- package/dist/_chunks/{logger-CI_hThfy.js → logger-CWk44DLp.js} +89 -47
- package/dist/_chunks/logger-CWk44DLp.js.map +1 -0
- package/dist/_chunks/{metadata-routes-B3XJNyIH.js → metadata-routes-BL26HCDd.js} +2 -3
- package/dist/_chunks/{metadata-routes-B3XJNyIH.js.map → metadata-routes-BL26HCDd.js.map} +1 -1
- package/dist/_chunks/{navigation-root-BQfo1-kG.js → navigation-root-M3B2ZrdO.js} +6 -10
- package/dist/_chunks/{navigation-root-BQfo1-kG.js.map → navigation-root-M3B2ZrdO.js.map} +1 -1
- package/dist/_chunks/{node-response-bF0bKoig.js → node-response-B9aviPDa.js} +43 -9
- package/dist/_chunks/node-response-B9aviPDa.js.map +1 -0
- package/dist/_chunks/{param-value-C8TNYchQ.js → param-value-DqlGfF57.js} +2 -3
- package/dist/_chunks/{param-value-C8TNYchQ.js.map → param-value-DqlGfF57.js.map} +1 -1
- package/dist/_chunks/{plugin-context-uDHFqHHJ.js → plugin-context-BfSRKJfz.js} +1 -1
- package/dist/_chunks/{plugin-context-DxMMvjUt.js → plugin-context-FCkaNLUB.js} +4 -6
- package/dist/_chunks/plugin-context-FCkaNLUB.js.map +1 -0
- package/dist/_chunks/{poison-rules-DoEhbqaY.js → poison-rules-Bmz-lCPi.js} +2 -3
- package/dist/_chunks/{poison-rules-DoEhbqaY.js.map → poison-rules-Bmz-lCPi.js.map} +1 -1
- package/dist/_chunks/{poison-scan-DTWIfNgD.js → poison-scan-DJYxZc_7.js} +4 -5
- package/dist/_chunks/{poison-scan-DTWIfNgD.js.map → poison-scan-DJYxZc_7.js.map} +1 -1
- package/dist/_chunks/{purge-store-WZaxu-3m.js → purge-store-8BqLAYZ1.js} +2 -3
- package/dist/_chunks/{purge-store-WZaxu-3m.js.map → purge-store-8BqLAYZ1.js.map} +1 -1
- package/dist/_chunks/{render-timeout-Ln_u7fX-.js → render-timeout-MrrqD1wd.js} +2 -3
- package/dist/_chunks/{render-timeout-Ln_u7fX-.js.map → render-timeout-MrrqD1wd.js.map} +1 -1
- package/dist/_chunks/{resolve-schema-CkAInout.js → resolve-schema-B-aCuTu3.js} +3 -4
- package/dist/_chunks/{resolve-schema-CkAInout.js.map → resolve-schema-B-aCuTu3.js.map} +1 -1
- package/dist/_chunks/{rsc-cache-key-ClUiXQnK.js → rsc-cache-key-D0cb0Gmc.js} +2 -3
- package/dist/_chunks/{rsc-cache-key-ClUiXQnK.js.map → rsc-cache-key-D0cb0Gmc.js.map} +1 -1
- package/dist/_chunks/{rsc-media-type-DDc7duTD.js → rsc-media-type-m8jz9u6_.js} +2 -3
- package/dist/_chunks/{rsc-media-type-DDc7duTD.js.map → rsc-media-type-m8jz9u6_.js.map} +1 -1
- package/dist/_chunks/{rsc-payload-path-dffcs4jp.js → rsc-payload-path-EphpDB-J.js} +2 -3
- package/dist/_chunks/{rsc-payload-path-dffcs4jp.js.map → rsc-payload-path-EphpDB-J.js.map} +1 -1
- package/dist/_chunks/{scan-BoP17W3w.js → scan-CyizcBiX.js} +2 -3
- package/dist/_chunks/{scan-BoP17W3w.js.map → scan-CyizcBiX.js.map} +1 -1
- package/dist/_chunks/{scanner-C8fdKvKG.js → scanner-CJC-ScJU.js} +15 -23
- package/dist/_chunks/{scanner-C8fdKvKG.js.map → scanner-CJC-ScJU.js.map} +1 -1
- package/dist/_chunks/{schema-bridge-DpOmvZlI.js → schema-bridge-DyRs3cqy.js} +2 -3
- package/dist/_chunks/{schema-bridge-DpOmvZlI.js.map → schema-bridge-DyRs3cqy.js.map} +1 -1
- package/dist/_chunks/{segment-classify-C539Pa2O.js → segment-classify-Ho8jXWeC.js} +3 -5
- package/dist/_chunks/{segment-classify-C539Pa2O.js.map → segment-classify-Ho8jXWeC.js.map} +1 -1
- package/dist/_chunks/{segment-context-D3DNxKFq.js → segment-context-CYiGTi3K.js} +4 -6
- package/dist/_chunks/{segment-context-D3DNxKFq.js.map → segment-context-CYiGTi3K.js.map} +1 -1
- package/dist/_chunks/{segment-keys-D5hu1hz4.js → segment-keys-Y60KNc8C.js} +2 -3
- package/dist/_chunks/{segment-keys-D5hu1hz4.js.map → segment-keys-Y60KNc8C.js.map} +1 -1
- package/dist/_chunks/{singleflight-BeVMMKi0.js → singleflight-BChPMjwH.js} +2 -3
- package/dist/_chunks/{singleflight-BeVMMKi0.js.map → singleflight-BChPMjwH.js.map} +1 -1
- package/dist/_chunks/{sizeof-CO3dk0V1.js → sizeof-DG4W40lv.js} +3 -4
- package/dist/_chunks/{sizeof-CO3dk0V1.js.map → sizeof-DG4W40lv.js.map} +1 -1
- package/dist/_chunks/{ssr-data-nA3I70_n.js → ssr-data-9hPtcNOr.js} +3 -4
- package/dist/_chunks/{ssr-data-nA3I70_n.js.map → ssr-data-9hPtcNOr.js.map} +1 -1
- package/dist/_chunks/{state-BhNGPsdi.js → state-B-EBjeER.js} +2 -3
- package/dist/_chunks/{state-BhNGPsdi.js.map → state-B-EBjeER.js.map} +1 -1
- package/dist/_chunks/{status-page-marker-BRX9Ib-d.js → status-page-marker-XIQXlTOb.js} +8 -13
- package/dist/_chunks/{status-page-marker-BRX9Ib-d.js.map → status-page-marker-XIQXlTOb.js.map} +1 -1
- package/dist/_chunks/{tree-match-6yihorhk.js → tree-match-Bqdr9szG.js} +2 -3
- package/dist/_chunks/{tree-match-6yihorhk.js.map → tree-match-Bqdr9szG.js.map} +1 -1
- package/dist/_chunks/{use-query-states-I3JMng6J.js → use-query-states-pkDV-jSg.js} +4 -7
- package/dist/_chunks/{use-query-states-I3JMng6J.js.map → use-query-states-pkDV-jSg.js.map} +1 -1
- package/dist/_chunks/{walkers-BqzxnwGC.js → walkers-DIE203ir.js} +6 -8
- package/dist/_chunks/{walkers-BqzxnwGC.js.map → walkers-DIE203ir.js.map} +1 -1
- package/dist/_chunks/{write-file-atomic-D1qWqHb4.js → write-file-atomic-DW8m_Atv.js} +2 -3
- package/dist/_chunks/{write-file-atomic-D1qWqHb4.js.map → write-file-atomic-DW8m_Atv.js.map} +1 -1
- package/dist/adapters/build-output-helper.d.ts +10 -1
- package/dist/adapters/build-output-helper.d.ts.map +1 -1
- package/dist/adapters/cloudflare-dev.js +2 -3
- package/dist/adapters/cloudflare-kv-cache.js +3 -4
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +1 -1
- package/dist/adapters/nitro-presets.d.ts +6 -0
- package/dist/adapters/nitro-presets.d.ts.map +1 -1
- package/dist/adapters/nitro-preview.d.ts.map +1 -1
- package/dist/adapters/nitro.d.ts.map +1 -1
- package/dist/adapters/nitro.js +94 -57
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/analyze/crawl-entry.js +7 -9
- package/dist/analyze/crawl-entry.js.map +1 -1
- package/dist/analyze/graph-command.d.ts.map +1 -1
- package/dist/analyze/graph-command.js +19 -105
- package/dist/analyze/graph-command.js.map +1 -1
- package/dist/cache/index.js +3 -3
- package/dist/cache/key-discipline.d.ts +61 -0
- package/dist/cache/key-discipline.d.ts.map +1 -0
- package/dist/cache/stores/cloudflare-kv.js +1 -2
- package/dist/cache/stores/memory.js +2 -3
- package/dist/cache/stores/redis.js +1 -2
- package/dist/cache/stores/vercel.js +1 -2
- package/dist/cache/timber-cache.d.ts +5 -1
- package/dist/cache/timber-cache.d.ts.map +1 -1
- package/dist/cdn/cloudflare-purge.js +1 -2
- package/dist/cdn/fastly-purge.js +1 -2
- package/dist/cdn/index.js +2 -3
- package/dist/cdn/workers-cache-purge.js +3 -5
- package/dist/cdn/workers-cache-purge.js.map +1 -1
- package/dist/cli-dev-status.d.ts +75 -0
- package/dist/cli-dev-status.d.ts.map +1 -0
- package/dist/cli-init.d.ts +72 -0
- package/dist/cli-init.d.ts.map +1 -0
- package/dist/cli.d.ts +4 -12
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +27 -54
- package/dist/cli.js.map +1 -1
- package/dist/client/error-boundary.d.ts.map +1 -1
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/index.js +22 -34
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.js +13 -18
- package/dist/client/internal.js.map +1 -1
- package/dist/client/use-cookie.d.ts +18 -5
- package/dist/client/use-cookie.d.ts.map +1 -1
- package/dist/codec.js +2 -3
- package/dist/config-types.d.ts +40 -5
- package/dist/config-types.d.ts.map +1 -1
- package/dist/config-validation.d.ts.map +1 -1
- package/dist/cookies/define-cookie.d.ts.map +1 -1
- package/dist/cookies/index.js +40 -67
- package/dist/cookies/index.js.map +1 -1
- package/dist/cookies/json-cookie.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +698 -237
- package/dist/index.js.map +1 -1
- package/dist/params/index.js +3 -4
- package/dist/plugin-context.d.ts +7 -0
- package/dist/plugin-context.d.ts.map +1 -1
- package/dist/plugins/dev-discovery.d.ts +69 -5
- package/dist/plugins/dev-discovery.d.ts.map +1 -1
- package/dist/plugins/dev-hostname.d.ts +152 -0
- package/dist/plugins/dev-hostname.d.ts.map +1 -0
- package/dist/plugins/dev-server.d.ts +5 -1
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/plugins/dev-store-clear.d.ts +59 -4
- package/dist/plugins/dev-store-clear.d.ts.map +1 -1
- package/dist/plugins/graph-endpoint.d.ts +4 -2
- package/dist/plugins/graph-endpoint.d.ts.map +1 -1
- package/dist/plugins/optimize-package-imports-defaults.d.ts +13 -0
- package/dist/plugins/optimize-package-imports-defaults.d.ts.map +1 -0
- package/dist/plugins/optimize-package-imports.d.ts +113 -0
- package/dist/plugins/optimize-package-imports.d.ts.map +1 -0
- package/dist/plugins/prebuilt.d.ts.map +1 -1
- package/dist/routing/index.js +4 -4
- package/dist/rsc-runtime/rsc.d.ts +2 -1
- package/dist/rsc-runtime/rsc.d.ts.map +1 -1
- package/dist/rsc-runtime/server-references.d.ts +8 -0
- package/dist/rsc-runtime/server-references.d.ts.map +1 -0
- package/dist/search-params/index.js +5 -7
- package/dist/search-params/index.js.map +1 -1
- package/dist/server/access-gate.d.ts +12 -0
- package/dist/server/access-gate.d.ts.map +1 -1
- package/dist/server/canonicalize.d.ts +21 -0
- package/dist/server/canonicalize.d.ts.map +1 -1
- package/dist/server/cookie-context.d.ts +8 -1
- package/dist/server/cookie-context.d.ts.map +1 -1
- package/dist/server/flight-source-node.d.ts.map +1 -1
- package/dist/server/flight-source.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +8 -13
- package/dist/server/index.js.map +1 -1
- package/dist/server/interception-gates.d.ts +49 -0
- package/dist/server/interception-gates.d.ts.map +1 -0
- package/dist/server/internal.js +1061 -943
- package/dist/server/internal.js.map +1 -1
- package/dist/server/logger.d.ts +17 -0
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/param-coercion.d.ts +8 -0
- package/dist/server/param-coercion.d.ts.map +1 -1
- package/dist/server/pipeline-interception.d.ts +34 -4
- package/dist/server/pipeline-interception.d.ts.map +1 -1
- package/dist/server/pipeline-metadata-route.d.ts +24 -0
- package/dist/server/pipeline-metadata-route.d.ts.map +1 -0
- package/dist/server/pipeline-metadata.d.ts +3 -2
- package/dist/server/pipeline-metadata.d.ts.map +1 -1
- package/dist/server/pipeline-phases.d.ts +9 -3
- package/dist/server/pipeline-phases.d.ts.map +1 -1
- package/dist/server/pipeline.d.ts +18 -0
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/prebuilt/dev-store.d.ts +68 -22
- package/dist/server/prebuilt/dev-store.d.ts.map +1 -1
- package/dist/server/prebuilt/overlay.d.ts +8 -0
- package/dist/server/prebuilt/overlay.d.ts.map +1 -1
- package/dist/server/prebuilt-runtime.d.ts.map +1 -1
- package/dist/server/primitives.d.ts +13 -0
- package/dist/server/primitives.d.ts.map +1 -1
- package/dist/server/render-utils.d.ts +21 -0
- package/dist/server/render-utils.d.ts.map +1 -1
- package/dist/server/request-context.d.ts +14 -0
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/route-handler.d.ts +7 -0
- package/dist/server/route-handler.d.ts.map +1 -1
- package/dist/server/route-matcher.d.ts +14 -3
- package/dist/server/route-matcher.d.ts.map +1 -1
- package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/signal-identity.d.ts +6 -0
- package/dist/server/signal-identity.d.ts.map +1 -1
- package/dist/server/traced-access.d.ts +18 -0
- package/dist/server/traced-access.d.ts.map +1 -0
- package/dist/server/tracing.d.ts.map +1 -1
- package/dist/server/types.d.ts +5 -4
- package/dist/server/types.d.ts.map +1 -1
- package/dist/shims/font-google.js +1 -2
- package/dist/shims/font-local.js +1 -2
- package/dist/shims/headers.d.ts +11 -4
- package/dist/shims/headers.d.ts.map +1 -1
- package/docs/api/30-api-server.mdx +3 -1
- package/docs/api/32-api-cache.mdx +1 -1
- package/docs/api/34-api-config.mdx +42 -0
- package/docs/api/36-cli.mdx +72 -6
- package/docs/learn/01-quick-start.mdx +1 -1
- package/docs/learn/06-typed-params.mdx +2 -2
- package/docs/learn/10-caching.mdx +26 -5
- package/llms.txt +1 -1
- package/package.json +12 -12
- package/src/adapters/build-output-helper.ts +26 -4
- package/src/adapters/cloudflare.ts +1 -0
- package/src/adapters/nitro-presets.ts +15 -0
- package/src/adapters/nitro-preview.ts +66 -34
- package/src/adapters/nitro.ts +14 -6
- package/src/analyze/graph-command.ts +25 -133
- package/src/cache/key-discipline.ts +218 -0
- package/src/cache/timber-cache.ts +42 -5
- package/src/cli-dev-status.ts +196 -0
- package/src/cli-init.ts +278 -0
- package/src/cli.ts +33 -79
- package/src/client/error-boundary.tsx +19 -2
- package/src/client/use-cookie.ts +33 -21
- package/src/config-types.ts +40 -5
- package/src/config-validation.ts +37 -0
- package/src/cookies/define-cookie.ts +10 -46
- package/src/cookies/json-cookie.ts +4 -4
- package/src/index.ts +2 -0
- package/src/plugin-context.ts +7 -0
- package/src/plugins/dev-discovery.ts +216 -6
- package/src/plugins/dev-hostname.ts +322 -0
- package/src/plugins/dev-server.ts +96 -37
- package/src/plugins/dev-store-clear.ts +105 -7
- package/src/plugins/graph-endpoint.ts +15 -3
- package/src/plugins/optimize-package-imports-defaults.ts +88 -0
- package/src/plugins/optimize-package-imports.ts +439 -0
- package/src/plugins/prebuilt.ts +9 -0
- package/src/rsc-runtime/rsc.ts +7 -3
- package/src/rsc-runtime/server-references.ts +73 -0
- package/src/rsc-runtime/vendor-types.d.ts +9 -0
- package/src/server/access-gate.tsx +32 -20
- package/src/server/action-handler.ts +40 -34
- package/src/server/canonicalize.ts +27 -0
- package/src/server/cookie-context.ts +11 -3
- package/src/server/flight-source-node.ts +5 -2
- package/src/server/flight-source.ts +4 -3
- package/src/server/index.ts +6 -1
- package/src/server/interception-gates.ts +94 -0
- package/src/server/logger.ts +23 -0
- package/src/server/param-coercion.ts +22 -0
- package/src/server/pipeline-interception.ts +64 -4
- package/src/server/pipeline-metadata-route.ts +242 -0
- package/src/server/pipeline-metadata.ts +7 -5
- package/src/server/pipeline-phases.ts +71 -131
- package/src/server/pipeline.ts +20 -2
- package/src/server/prebuilt/dev-store.ts +113 -34
- package/src/server/prebuilt/overlay.ts +18 -0
- package/src/server/prebuilt-runtime.ts +43 -44
- package/src/server/primitives.ts +14 -0
- package/src/server/render-utils.ts +25 -0
- package/src/server/request-context.ts +27 -3
- package/src/server/route-element-builder.ts +15 -2
- package/src/server/route-handler.ts +3 -2
- package/src/server/route-matcher.ts +48 -33
- package/src/server/rsc-entry/api-handler.ts +2 -33
- package/src/server/rsc-entry/index.ts +8 -3
- package/src/server/rsc-entry/rsc-stream.ts +7 -1
- package/src/server/signal-identity.ts +30 -12
- package/src/server/traced-access.ts +50 -0
- package/src/server/tracing.ts +18 -1
- package/src/server/types.ts +5 -4
- package/src/shims/headers.ts +12 -4
- package/dist/_chunks/actions-vBHr2vqd.js.map +0 -1
- package/dist/_chunks/build-output-helper-RV_BRcF1.js.map +0 -1
- package/dist/_chunks/cache-api-DdcDLpBj.js.map +0 -1
- package/dist/_chunks/chains-B8TCLved.js +0 -1
- package/dist/_chunks/cli-context-BJQB6rtF.js +0 -1
- package/dist/_chunks/dev-server-BNr5drEO.js.map +0 -1
- package/dist/_chunks/dev-server-CUg7Mqh_.js +0 -1
- package/dist/_chunks/dev-store-BOa304m_.js.map +0 -1
- package/dist/_chunks/flight-source-node-BdHUOUqg.js.map +0 -1
- package/dist/_chunks/graph-cache-CYiUS2aS.js.map +0 -1
- package/dist/_chunks/logger-CI_hThfy.js.map +0 -1
- package/dist/_chunks/node-response-bF0bKoig.js.map +0 -1
- package/dist/_chunks/plugin-context-DxMMvjUt.js.map +0 -1
- package/dist/server/prebuilt/key-discipline.d.ts +0 -52
- package/dist/server/prebuilt/key-discipline.d.ts.map +0 -1
- package/src/server/prebuilt/key-discipline.ts +0 -122
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["normalize"],"sources":["../../src/shared/redirect-type.ts","../../src/server/sensitive-fields.ts","../../src/server/action-schema.ts","../../src/server/schema-introspection.ts","../../src/server/action-client.ts"],"sourcesContent":["/**\n * Next.js redirect type discriminator.\n *\n * Provided for API compatibility with libraries that import `RedirectType`\n * from `next/navigation`. In timber, `redirect()` always uses `replace`\n * semantics (no history entry for the redirect itself).\n *\n * Lives in shared/ (isomorphic) so both the server primitives and the\n * client-only next/navigation shim export the same definition without the\n * client shim pulling in server code.\n */\nexport const RedirectType = {\n push: 'push',\n replace: 'replace',\n} as const;\n\nexport type RedirectTypeValue = (typeof RedirectType)[keyof typeof RedirectType];\n","/**\n * Sensitive field stripping — removes password/token/CVV-style fields from\n * the `submittedValues` a `createActionClient` action echoes back to the\n * client for form repopulation.\n *\n * **This is hygiene, not a security boundary.** `submittedValues` only ever\n * returns to the user who typed it, in the response to their own POST:\n *\n * - With JavaScript, it travels in the action's response, a non-cacheable\n * POST fetch. What remains is exposure to devtools, HAR exports and\n * TLS-inspecting proxies.\n * - Without JavaScript, it is rendered into the page's HTML as a field's\n * `defaultValue`: one uncached response, but one that view-source, the\n * back-forward cache and a shared machine can surface. OWASP advises not\n * pre-filling password fields for this reason.\n *\n * The main reason to strip is UX: a password or card field comes back empty\n * after a failed submit, as users expect.\n *\n * What is stripped: a field whose name matches the built-in deny-list (or the\n * configured option), and a field the action's schema marks sensitive with\n * `.meta({ sensitive: true })` (Valibot: `v.metadata({ sensitive: true })`),\n * at its exact path. The schema mark covers names the list misses\n * (`recoveryPhrase`) and always applies, even with the name list turned off.\n *\n * Only `createActionClient` strips, because only it builds `submittedValues`.\n * A raw `'use server'` action owns its return value: whatever it returns is\n * what the client gets, on both paths.\n *\n * See design/08-forms-and-actions.md §\"Sensitive field stripping\"\n * See design/13-security.md §\"Sensitive field stripping\"\n */\n\nimport { isDebug } from './debug.ts';\nimport type { FieldShape } from './schema-introspection.ts';\n\n// ─── Public types ────────────────────────────────────────────────────────\n\n/**\n * How to strip sensitive fields from `submittedValues`, by name.\n *\n * - `true` / `undefined` — use the built-in deny-list (default).\n * - `false` — strip no field by name. Fields the schema marks sensitive are\n * still stripped.\n * - `string[]` — additional field names to strip, merged with the built-in list.\n * - `(name) => boolean` — custom predicate, fully replaces the built-in list.\n * Return `true` to strip, `false` to keep. The `name` argument is the raw\n * (un-normalized) field name as it appeared in the submitted form.\n */\nexport type SensitiveFieldsOption = boolean | readonly string[] | ((name: string) => boolean);\n\n// ─── Built-in deny-list ──────────────────────────────────────────────────\n\n/**\n * Substring patterns matched against the normalized field name.\n * Normalization = lowercase + strip `_` and `-`.\n *\n * Any field whose normalized name *contains* one of these strings is\n * considered sensitive. Entries like `currentPassword`, `passwordConfirmation`,\n * and `user.password` all match via the `password` substring. Every pattern\n * here is long enough not to occur inside an ordinary word.\n */\nconst BUILTIN_SUBSTRING_PATTERNS: readonly string[] = [\n 'password',\n 'passwd',\n 'secret',\n 'apikey',\n 'accesstoken',\n 'refreshtoken',\n 'cardnumber',\n 'cardcvc',\n 'socialsecuritynumber',\n 'mfacode',\n 'twofactorcode',\n 'privatekey',\n];\n\n/**\n * Patterns matched at the start or end of a word of the field name. These are\n * short enough to occur inside ordinary words (`otp` in `footPath` and\n * `notpublic`, `ssn` in `class_number` and `classnumber`), so they must\n * begin or end a word: `otp`, `otpCode`, `otpcode`, `userotp`, `user_ssn`,\n * `SSNLast4`, `newpwd`, `cardcvv`.\n */\nconst BUILTIN_WORD_PATTERNS: readonly string[] = ['pwd', 'cvv', 'cvc', 'ssn', 'otp', 'totp'];\n\n/**\n * Exact matches against the normalized field name. These are field names that\n * are too short or too common to substring-match safely. e.g. `token` alone\n * would match `csrfToken`, which is not sensitive — so `token` is exact-only,\n * while legitimate token fields are covered by `accesstoken` / `refreshtoken`.\n */\nconst BUILTIN_EXACT_PATTERNS: readonly string[] = ['token'];\n\n/**\n * Normalize a field name for deny-list comparison.\n * Lowercases the string and strips `_` and `-` so camelCase, snake_case, and\n * kebab-case variants all compare equal (`api_key` / `apiKey` / `api-key` →\n * `apikey`).\n */\nfunction normalize(name: string): string {\n return name.replace(/[_-]/g, '').toLowerCase();\n}\n\n/**\n * Split a field name into lowercase words at anything that is not a letter\n * and at a lowercase-to-uppercase hump: `user_ssnLast4` → `user`, `ssn`,\n * `last`. An acronym stays joined to what follows it (`OTPcode` →\n * `otpcode`, `SSNLast` → `ssnlast`), which a start-of-word match still finds.\n */\nfunction words(name: string): string[] {\n return name\n .split(/[^A-Za-z]+|(?<=[a-z])(?=[A-Z])/)\n .filter(Boolean)\n .map((w) => w.toLowerCase());\n}\n\n/** Whether a short pattern begins or ends one of the name's words. */\nfunction hasWordPattern(name: string): boolean {\n return words(name).some((word) =>\n BUILTIN_WORD_PATTERNS.some((p) => word.startsWith(p) || word.endsWith(p))\n );\n}\n\n/**\n * Check whether a name matches the built-in deny-list (with optional extras).\n * Extras are merged into the substring pattern list after normalization.\n */\nfunction isBuiltinSensitive(name: string, extras?: readonly string[]): boolean {\n const normalized = normalize(name);\n if (BUILTIN_EXACT_PATTERNS.includes(normalized)) return true;\n for (const pattern of BUILTIN_SUBSTRING_PATTERNS) {\n if (normalized.includes(pattern)) return true;\n }\n if (hasWordPattern(name)) return true;\n if (extras && extras.length > 0) {\n for (const extra of extras) {\n const normExtra = normalize(extra);\n if (normExtra.length === 0) continue;\n if (normalized.includes(normExtra)) return true;\n }\n }\n return false;\n}\n\n// ─── Predicate resolution ────────────────────────────────────────────────\n\n/**\n * A resolved predicate: `null` means \"strip no field by name\" (the option was\n * explicitly `false`). Otherwise a function from raw field name → boolean.\n */\nexport type ResolvedSensitivePredicate = ((name: string) => boolean) | null;\n\n/**\n * Resolve a `SensitiveFieldsOption` into a concrete predicate.\n * Precedence: per-action > global > built-in default.\n *\n * - Per-action `undefined` → fall back to global.\n * - Global `undefined` → use built-in list.\n * - Either level set to `false` → no name matching (returns `null`).\n * - `true` → built-in list.\n * - `string[]` → built-in ∪ extras.\n * - function → custom, replaces the built-in list entirely.\n */\nexport function resolveSensitivePredicate(\n perAction: SensitiveFieldsOption | undefined,\n global: SensitiveFieldsOption | undefined\n): ResolvedSensitivePredicate {\n const chosen = perAction !== undefined ? perAction : global;\n\n if (chosen === false) return null;\n if (chosen === undefined || chosen === true) {\n return (name) => isBuiltinSensitive(name);\n }\n if (typeof chosen === 'function') {\n return chosen;\n }\n // Array of extra names merged with the built-in list.\n const extras = chosen;\n return (name) => isBuiltinSensitive(name, extras);\n}\n\n// ─── Module-level global config ──────────────────────────────────────────\n\nlet globalConfig: SensitiveFieldsOption | undefined;\n\n/**\n * Set the global `forms.stripSensitiveFields` config from `timber.config.ts`.\n * Called once at startup from `rsc-entry`.\n */\nexport function setGlobalSensitiveFieldsConfig(option: SensitiveFieldsOption | undefined): void {\n globalConfig = option;\n}\n\n/** Read the global `forms.stripSensitiveFields` config. */\nexport function getGlobalSensitiveFieldsConfig(): SensitiveFieldsOption | undefined {\n return globalConfig;\n}\n\n// ─── Stripping ───────────────────────────────────────────────────────────\n\n// One warning per field name per process — prevents log spam when a form is\n// submitted many times in dev mode.\nconst warnedFields = new Set<string>();\n\nfunction warnStripped(name: string, markedInSchema: boolean): void {\n if (!isDebug()) return;\n if (warnedFields.has(name)) return;\n warnedFields.add(name);\n console.warn(\n `[timber] stripped sensitive field \"${name}\" from submittedValues. ` +\n (markedInSchema\n ? `The action's schema marks it sensitive; remove the mark to echo it.`\n : `Override via forms.stripSensitiveFields in timber.config.ts.`)\n );\n}\n\n/**\n * Walk an object (recursively) and return a copy without its sensitive\n * fields: every key `predicate` matches, and every field `shape` (the\n * schema's declared shape) marks sensitive. Nested objects like\n * `{ user: { password: '...' } }` are handled — `user.password` is stripped\n * while other `user.*` fields remain.\n *\n * - Arrays are walked element-wise (object entries inside arrays are cleaned).\n * - Non-plain values (strings, numbers, Files, Dates, etc.) are returned as-is.\n * - When a stripped key is encountered, it is omitted from the result entirely\n * — we do NOT set it to an empty string, because that would overwrite a\n * valid `defaultValue` the form author might have set.\n */\nexport function stripSensitiveFields(\n value: Record<string, unknown>,\n predicate: ResolvedSensitivePredicate,\n shape?: FieldShape\n): Record<string, unknown> {\n if (predicate === null && !hasSensitive(shape)) return value;\n return stripFrom(value, predicate, shape) as Record<string, unknown>;\n}\n\nfunction stripFrom(\n value: unknown,\n predicate: ResolvedSensitivePredicate,\n shape: FieldShape | undefined\n): unknown {\n if (value === null || typeof value !== 'object') return value;\n if (value instanceof Blob || value instanceof Date) return value;\n\n if (Array.isArray(value)) {\n return value.map((item) => stripFrom(item, predicate, shape?.item));\n }\n\n // A list `parseFormData` kept as an object (an indexed list with a gap,\n // `keys.0` and `keys.2`): every value is an item.\n const indexed = shape?.item !== undefined && shape.properties === undefined;\n const result: Record<string, unknown> = {};\n for (const [key, nested] of Object.entries(value)) {\n const child = indexed ? shape.item : shape?.properties?.[key];\n if (child?.sensitive || predicate?.(key)) {\n warnStripped(key, child?.sensitive === true);\n continue;\n }\n result[key] = stripFrom(nested, predicate, child);\n }\n return result;\n}\n\n/** Whether `shape` marks any field at or below it sensitive. */\nfunction hasSensitive(shape: FieldShape | undefined): boolean {\n if (!shape) return false;\n if (shape.sensitive) return true;\n if (hasSensitive(shape.item)) return true;\n return Object.values(shape.properties ?? {}).some(hasSensitive);\n}\n\n// ─── Test helpers ────────────────────────────────────────────────────────\n\n/** The built-in patterns, for the docs drift test. */\nexport const __BUILTIN_SENSITIVE_PATTERNS: readonly string[] = [\n ...BUILTIN_SUBSTRING_PATTERNS,\n ...BUILTIN_WORD_PATTERNS,\n ...BUILTIN_EXACT_PATTERNS,\n];\n\n/** Reset the \"warned once\" cache. Exposed for tests. */\nexport function __resetSensitiveFieldsWarnings(): void {\n warnedFields.clear();\n}\n","/**\n * Action input schemas — the Standard Schema protocol (and the legacy\n * `.parse()` interface) as `createActionClient().schema()` accepts them, the\n * input/output types they carry, and running one against an action's input.\n *\n * See design/08-forms-and-actions.md §\"Validation Pattern\"\n */\n\nimport type { ValidationErrors } from './action-types.ts';\n\n// ─── Standard Schema ──────────────────────────────────────────────────────\n\n/**\n * Standard Schema v1 interface (subset).\n * Zod ≥3.24, Valibot ≥1.0, and ArkType all implement this.\n * See https://github.com/standard-schema/standard-schema\n *\n * `types` is the protocol's type-only carrier: a schema's input type (what a\n * caller passes, before coercion) and output type (what validation produces).\n * We use permissive types for issues and paths to accept all compliant\n * libraries without requiring exact structural matches on their shapes.\n */\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n readonly '~standard': {\n readonly validate: (\n value: unknown\n ) => StandardSchemaResult<Output> | Promise<StandardSchemaResult<Output>>;\n readonly types?: { readonly input: Input; readonly output: Output } | undefined;\n };\n}\n\ntype StandardSchemaResult<Output> =\n | { value: Output; issues?: undefined }\n | { value?: undefined; issues: ReadonlyArray<StandardSchemaIssue> };\n\ninterface StandardSchemaIssue {\n message: string;\n path?: ReadonlyArray<PropertyKey | { key: PropertyKey }>;\n}\n\n/** Check if a schema implements the Standard Schema protocol. */\nexport function isStandardSchema(schema: unknown): schema is StandardSchemaV1 {\n return (\n typeof schema === 'object' &&\n schema !== null &&\n '~standard' in schema &&\n typeof (schema as StandardSchemaV1)['~standard'].validate === 'function'\n );\n}\n\n// ─── Schema types ─────────────────────────────────────────────────────────\n\n/**\n * Minimal schema interface — compatible with Zod, Valibot, ArkType, etc.\n *\n * Accepts either:\n * - Standard Schema (preferred): any object with `~standard.validate()`\n * - Legacy parse interface: objects with `.parse()` / `.safeParse()`\n *\n * At runtime, Standard Schema is detected via `~standard` property and\n * takes priority over the legacy interface.\n */\nexport type ActionSchema<T = unknown> = StandardSchemaV1<unknown, T> | LegacyActionSchema<T>;\n\n/** Legacy schema interface with .parse() / .safeParse(). */\ninterface LegacyActionSchema<T = unknown> {\n 'parse'(data: unknown): T;\n 'safeParse'?(data: unknown): { success: true; data: T } | { success: false; error: SchemaError };\n // Exclude Standard Schema objects from matching this interface\n '~standard'?: never;\n}\n\n/** Schema validation error shape (for legacy .safeParse()/.parse() interface). */\nexport interface SchemaError {\n issues?: Array<{ path?: Array<string | number>; message: string }>;\n flatten?(): { fieldErrors: Record<string, string[]> };\n}\n\n/**\n * What a validated action's body receives: the schema's output, after\n * coercion and defaults.\n */\nexport type SchemaOutput<S> = S extends { readonly '~standard': infer Std }\n ? DeclaredType<Std, 'output', ValidatedValue<S>>\n : S extends LegacyActionSchema<infer T>\n ? T\n : never;\n\n/**\n * The value a Standard Schema's `validate` produces on success, for a schema\n * that declares no `types`. Only the success branch has a required `value`.\n */\ntype ValidatedValue<S> = S extends {\n readonly '~standard': { readonly validate: (value: unknown) => infer R };\n}\n ? SuccessValue<Awaited<R>>\n : never;\n\n/** Distributes over the result union, keeping the members with a value. */\ntype SuccessValue<R> = R extends { value: infer O } ? O : never;\n\n/**\n * What a caller passes a validated action: the schema's input, before\n * coercion. A schema that declares no `types` (a hand-written Standard\n * Schema, a legacy `.parse()` schema) has one type for both.\n */\nexport type SchemaInput<S> = S extends { readonly '~standard': infer Std }\n ? DeclaredType<Std, 'input', SchemaOutput<S>>\n : SchemaOutput<S>;\n\n/**\n * `Std.types[K]` when the schema declares `types` (Zod, Valibot, ArkType do),\n * else `Fallback`. Read by key, because `types` is optional in the protocol.\n */\ntype DeclaredType<Std, K extends 'input' | 'output', Fallback> = 'types' extends keyof Std\n ? NonNullable<Std['types' & keyof Std]> extends { readonly [P in K]: infer T }\n ? T\n : Fallback\n : Fallback;\n\n// ─── Validation ───────────────────────────────────────────────────────────\n\n/** The outcome of running an action's schema over its input. */\nexport type SchemaValidation<T> =\n | { ok: true; value: T }\n | { ok: false; validationErrors: ValidationErrors };\n\n/**\n * Validate `input` with `schema`, through Standard Schema when the schema\n * implements it, and through `.safeParse()` / `.parse()` otherwise. Only\n * synchronous Standard Schema validation is supported.\n */\nexport function validateWithSchema<T>(\n schema: ActionSchema<T>,\n input: unknown\n): SchemaValidation<T> {\n if (isStandardSchema(schema)) {\n const result = schema['~standard'].validate(input);\n if (result instanceof Promise) {\n throw new Error(\n '[timber] createActionClient: schema returned a Promise — only sync schemas are supported.'\n );\n }\n if (result.issues) {\n return { ok: false, validationErrors: extractStandardSchemaErrors(result.issues) };\n }\n return { ok: true, value: result.value };\n }\n if (typeof schema.safeParse === 'function') {\n const result = schema.safeParse(input);\n if (!result.success) {\n return { ok: false, validationErrors: extractValidationErrors(result.error) };\n }\n return { ok: true, value: result.data };\n }\n try {\n return { ok: true, value: schema.parse(input) };\n } catch (parseError) {\n return { ok: false, validationErrors: extractValidationErrors(parseError as SchemaError) };\n }\n}\n\n/**\n * Extract validation errors from a schema error.\n * Supports Zod's flatten() and generic issues array.\n */\nfunction extractValidationErrors(error: SchemaError): ValidationErrors {\n // Zod-style flatten\n if (typeof error.flatten === 'function') {\n return error.flatten().fieldErrors;\n }\n\n // Generic issues array\n if (error.issues) {\n const errors: Record<string, string[]> = {};\n for (const issue of error.issues) {\n const path = issue.path?.join('.') ?? '_root';\n (errors[path] ??= []).push(issue.message);\n }\n return errors;\n }\n\n return { _root: ['Validation failed'] };\n}\n\n/**\n * Extract validation errors from Standard Schema issues.\n */\nfunction extractStandardSchemaErrors(issues: ReadonlyArray<StandardSchemaIssue>): ValidationErrors {\n const errors: Record<string, string[]> = {};\n for (const issue of issues) {\n const path =\n issue.path\n ?.map((p) => {\n // Standard Schema path items can be { key: ... } objects or bare PropertyKey values\n if (typeof p === 'object' && p !== null && 'key' in p) return String(p.key);\n return String(p);\n })\n .join('.') ?? '_root';\n (errors[path] ??= []).push(issue.message);\n }\n return Object.keys(errors).length > 0 ? errors : { _root: ['Validation failed'] };\n}\n","/**\n * Schema introspection — the shape of an action's input as its schema\n * declares it: which fields are lists, which may be absent, and which the\n * schema marks sensitive.\n *\n * Standard Schema v1 has no introspection API, so this feature-detects what\n * the libraries expose:\n *\n * - **Zod 4**: its schema tree (`_zod.def`, documented for library authors),\n * with `.meta()` for marks and `_zod.optin` for fields that may be absent.\n * Not Zod's JSON Schema: that describes a `z.preprocess(fn, z.array(…))`\n * field as the inner array, and wrapping a scalar before `fn` runs would\n * hand a comma-splitting preprocessor `['a,b']`. A preprocessed field is\n * its author's to read, so it has no shape here.\n * - **Valibot**: its schema objects (`entries`, `item`, `wrapped`, `options`),\n * with `v.metadata({ sensitive: true })` read from the pipe.\n * - **Standard JSON Schema** (`~standard.jsonSchema.input()`) for any other\n * library that implements it, such as ArkType, whose\n * `.configure({ sensitive: true })` lands in the JSON Schema node.\n *\n * Any other schema (a legacy `.parse()` schema, Zod 3, a hand-written\n * Standard Schema) has no shape: its form input is not normalized and only\n * the name deny-list strips its echo.\n *\n * A union merges its branches: a field is sensitive if any branch marks it,\n * and a list only if every branch declares it one. An intersection merges\n * its parts, which all apply: a list or sensitive if any part says so.\n *\n * `createActionClient` computes the shape once per action and keeps it on the\n * action's closure. It is used twice, by `normalizeListFields` (before\n * validation, and for `submittedValues`) and by `stripSensitiveFields`.\n *\n * See design/08-forms-and-actions.md §\"The Form Model\" and\n * §\"Sensitive field stripping\".\n */\n\nimport { isStandardSchema } from './action-schema.ts';\n\n/** The declared shape of one field (or of the whole input). */\nexport interface FieldShape {\n /** The field holds items of this shape (a list, possibly not in every union branch). */\n item?: FieldShape;\n /** Every declaration of the field is a list: normalize its form value to an array. */\n list?: boolean;\n /** The field is an object; these are its properties' shapes. */\n properties?: Record<string, FieldShape>;\n /** The field may be absent (`.optional()`, a default, a missing union branch). */\n optional?: boolean;\n /** The schema marks the field sensitive (`.meta({ sensitive: true })`). */\n sensitive?: boolean;\n}\n\n/**\n * The shape of `schema`'s input, or `undefined` when the schema library\n * exposes nothing to read it from.\n */\nexport function introspectSchema(schema: unknown): FieldShape | undefined {\n if (!isStandardSchema(schema)) return undefined;\n const standard: Record<string, unknown> = schema['~standard'];\n if (standard.vendor === 'zod' && isRecord(schema) && isRecord(schema._zod)) {\n return fromZod(schema, new Set());\n }\n if (standard.vendor === 'valibot') return fromValibot(schema, new Set());\n\n const jsonSchema = standard.jsonSchema;\n if (!isRecord(jsonSchema) || typeof jsonSchema.input !== 'function') return undefined;\n let root: unknown;\n try {\n root = jsonSchema.input({ target: 'draft-2020-12' });\n } catch {\n return undefined;\n }\n return isRecord(root) ? fromJsonSchema(root, root, new Set()) : undefined;\n}\n\n// ─── Zod 4 ───────────────────────────────────────────────────────────────\n\n/** Zod wrappers whose `innerType` is the field's real type. */\nconst ZOD_WRAPPERS = new Set([\n 'optional',\n 'nullable',\n 'default',\n 'prefault',\n 'nonoptional',\n 'readonly',\n 'catch',\n]);\n\nfunction fromZod(schema: unknown, seen: Set<unknown>): FieldShape | undefined {\n if (!isRecord(schema) || seen.has(schema) || !isRecord(schema._zod)) return undefined;\n const inner = new Set(seen).add(schema);\n const def = schema._zod.def;\n if (!isRecord(def)) return undefined;\n const marks = withMarks(schema._zod.optin === 'optional', zodSensitive(schema));\n\n switch (def.type) {\n case 'object': {\n if (!isRecord(def.shape)) return marks(undefined);\n const properties: Record<string, FieldShape> = {};\n for (const [key, child] of Object.entries(def.shape)) {\n const shape = fromZod(child, inner);\n if (shape) properties[key] = shape;\n }\n return marks({ properties });\n }\n case 'array':\n return marks({ item: fromZod(def.element, inner) ?? {}, list: true });\n case 'union':\n return marks(mergeAll(asList(def.options).map((option) => fromZod(option, inner))));\n case 'intersection':\n return marks(intersectAll([fromZod(def.left, inner), fromZod(def.right, inner)]));\n case 'pipe':\n // `z.preprocess(fn, …)` is a pipe from a transform: its author reads\n // the raw value. Any other pipe takes its input side's shape.\n if (isRecord(def.in) && isRecord(def.in._zod) && isRecord(def.in._zod.def)) {\n if (def.in._zod.def.type === 'transform') return marks(undefined);\n }\n return marks(fromZod(def.in, inner));\n default:\n if (typeof def.type === 'string' && ZOD_WRAPPERS.has(def.type)) {\n return marks(fromZod(def.innerType, inner));\n }\n return marks(undefined);\n }\n}\n\n/** `.meta()` read back: Zod returns the schema's registered metadata. */\nfunction zodSensitive(schema: Record<string, unknown>): boolean {\n if (typeof schema.meta !== 'function') return false;\n try {\n const meta: unknown = schema.meta();\n return isRecord(meta) && meta.sensitive === true;\n } catch {\n return false;\n }\n}\n\n// ─── Valibot ─────────────────────────────────────────────────────────────\n\n/** Valibot wrappers whose `wrapped` schema is the field's real type. */\nconst VALIBOT_WRAPPERS = new Set([\n 'optional',\n 'exact_optional',\n 'nullable',\n 'nullish',\n 'undefinedable',\n 'non_optional',\n 'non_nullable',\n 'non_nullish',\n]);\n\n/** Valibot wrappers that let the field be absent. */\nconst VALIBOT_OPTIONAL = new Set(['optional', 'exact_optional', 'nullish', 'undefinedable']);\n\nconst VALIBOT_OBJECTS = new Set(['object', 'loose_object', 'strict_object', 'object_with_rest']);\n\nfunction fromValibot(schema: unknown, seen: Set<unknown>): FieldShape | undefined {\n if (!isRecord(schema) || seen.has(schema)) return undefined;\n const inner = new Set(seen).add(schema);\n const sensitive =\n Array.isArray(schema.pipe) &&\n schema.pipe.some(\n (action) =>\n isRecord(action) &&\n action.kind === 'metadata' &&\n isRecord(action.metadata) &&\n action.metadata.sensitive === true\n );\n\n const type = schema.type;\n const marks = withMarks(typeof type === 'string' && VALIBOT_OPTIONAL.has(type), sensitive);\n if (typeof type !== 'string') return marks(undefined);\n if (VALIBOT_WRAPPERS.has(type)) return marks(fromValibot(schema.wrapped, inner));\n if (type === 'array') return marks({ item: fromValibot(schema.item, inner) ?? {}, list: true });\n if (type === 'union' || type === 'variant') {\n return marks(mergeAll(asList(schema.options).map((option) => fromValibot(option, inner))));\n }\n if (type === 'intersect') {\n return marks(intersectAll(asList(schema.options).map((option) => fromValibot(option, inner))));\n }\n if (VALIBOT_OBJECTS.has(type) && isRecord(schema.entries)) {\n const properties: Record<string, FieldShape> = {};\n for (const [key, child] of Object.entries(schema.entries)) {\n const shape = fromValibot(child, inner);\n if (shape) properties[key] = shape;\n }\n return marks({ properties });\n }\n return marks(undefined);\n}\n\n// ─── Standard JSON Schema ────────────────────────────────────────────────\n\nfunction fromJsonSchema(\n node: Record<string, unknown>,\n root: Record<string, unknown>,\n refs: Set<string>\n): FieldShape | undefined {\n const marks = withMarks(false, node.sensitive === true);\n const ref = node.$ref;\n if (typeof ref === 'string') {\n // A recursive schema: stop at a ref already being expanded on this path.\n if (refs.has(ref)) return marks(undefined);\n const target = resolveRef(root, ref);\n if (!target) return marks(undefined);\n return marks(fromJsonSchema(target, root, new Set(refs).add(ref)));\n }\n\n const branches = node.anyOf ?? node.oneOf;\n if (Array.isArray(branches)) {\n const shapes = branches\n .filter((b): b is Record<string, unknown> => isRecord(b) && b.type !== 'null')\n .map((b) => fromJsonSchema(b, root, refs));\n return marks(mergeAll(shapes));\n }\n\n if (Array.isArray(node.allOf)) {\n const parts = node.allOf.filter(isRecord).map((part) => fromJsonSchema(part, root, refs));\n return marks(intersectAll(parts));\n }\n\n const types = Array.isArray(node.type) ? node.type : [node.type];\n if (types.includes('array') && isRecord(node.items)) {\n return marks({ item: fromJsonSchema(node.items, root, refs) ?? {}, list: true });\n }\n if (isRecord(node.properties)) {\n const required = new Set(asList(node.required));\n const properties: Record<string, FieldShape> = {};\n for (const [key, child] of Object.entries(node.properties)) {\n const shape = isRecord(child) ? fromJsonSchema(child, root, refs) : undefined;\n if (shape) properties[key] = required.has(key) ? shape : { ...shape, optional: true };\n }\n return marks({ properties });\n }\n return marks(undefined);\n}\n\n/** Resolve a local `#/$defs/...` or `#/definitions/...` reference. */\nfunction resolveRef(\n root: Record<string, unknown>,\n ref: string\n): Record<string, unknown> | undefined {\n if (!ref.startsWith('#/')) return undefined;\n let node: unknown = root;\n for (const segment of ref.slice(2).split('/')) {\n if (!isRecord(node)) return undefined;\n node = node[segment.replaceAll('~1', '/').replaceAll('~0', '~')];\n }\n return isRecord(node) ? node : undefined;\n}\n\n// ─── Unions ──────────────────────────────────────────────────────────────\n\n/**\n * One shape for the branches of a union. A field is sensitive if any branch\n * marks it, a list only if every branch declares it one, and optional if any\n * branch lacks it. A branch with no shape makes nothing a list, but its\n * siblings' marks still apply.\n */\nfunction mergeAll(shapes: (FieldShape | undefined)[]): FieldShape | undefined {\n if (shapes.length === 0) return undefined;\n return shapes.reduce<FieldShape | undefined>(\n (merged, shape, i) => (i === 0 ? (shape ?? {}) : merge(merged ?? {}, shape ?? {})),\n undefined\n );\n}\n\nfunction merge(a: FieldShape, b: FieldShape): FieldShape {\n const out: FieldShape = {};\n if (a.sensitive || b.sensitive) out.sensitive = true;\n if (a.optional || b.optional) out.optional = true;\n if (a.list && b.list) out.list = true;\n if (a.item || b.item) out.item = merge(a.item ?? {}, b.item ?? {});\n if (a.properties || b.properties) {\n const properties: Record<string, FieldShape> = {};\n const keys = new Set([...Object.keys(a.properties ?? {}), ...Object.keys(b.properties ?? {})]);\n for (const key of keys) {\n const left = a.properties?.[key];\n const right = b.properties?.[key];\n // Present in one branch only: absent whenever the other is chosen.\n properties[key] = left && right ? merge(left, right) : { ...(left ?? right), optional: true };\n }\n out.properties = properties;\n }\n return out;\n}\n\n// ─── Intersections ──────────────────────────────────────────────────────\n\n/**\n * One shape for the parts of an intersection, which all apply: a field is a\n * list or sensitive if any part says so, and optional only if every part\n * that declares it lets it be absent.\n */\nfunction intersectAll(shapes: (FieldShape | undefined)[]): FieldShape | undefined {\n const present = shapes.filter((shape): shape is FieldShape => shape !== undefined);\n if (present.length === 0) return undefined;\n return present.reduce(intersect);\n}\n\nfunction intersect(a: FieldShape, b: FieldShape): FieldShape {\n const out: FieldShape = {};\n if (a.sensitive || b.sensitive) out.sensitive = true;\n if (a.optional && b.optional) out.optional = true;\n if (a.list || b.list) out.list = true;\n if (a.item || b.item) out.item = intersect(a.item ?? {}, b.item ?? {});\n if (a.properties || b.properties) {\n const properties: Record<string, FieldShape> = {};\n const keys = new Set([...Object.keys(a.properties ?? {}), ...Object.keys(b.properties ?? {})]);\n for (const key of keys) {\n const left = a.properties?.[key];\n const right = b.properties?.[key];\n properties[key] = left && right ? intersect(left, right) : (left ?? right ?? {});\n }\n out.properties = properties;\n }\n return out;\n}\n\n// ─── List normalization ──────────────────────────────────────────────────\n\n/**\n * Give every field the schema declares as a list the same shape whatever its\n * count. `parseFormData` reads a repeated name as an array, a single value as\n * a scalar, and an absent name not at all; here a scalar becomes `[value]`,\n * and an absent or blank required list becomes `[]` (blanks are dropped from\n * a list, as `parseFormData` drops them from a repeated name). An optional\n * list that was not submitted (or was one blank) is absent, so `.optional()` still means\n * \"not sent\". Lists inside lists and objects are normalized too. An object\n * where a list is declared (an indexed list with a gap) is left for the\n * schema to reject.\n *\n * Returns a copy; the input is not written to.\n */\nexport function normalizeListFields(\n values: Record<string, unknown>,\n shape: FieldShape | undefined\n): Record<string, unknown> {\n if (!shape) return values;\n return normalize(values, shape) as Record<string, unknown>;\n}\n\nfunction normalize(value: unknown, shape: FieldShape): unknown {\n if (shape.list && shape.item) {\n if (value === undefined || value === '') return shape.optional ? undefined : [];\n if (isPlainObject(value)) return value;\n const list = Array.isArray(value) ? value : [value];\n const item = shape.item;\n return list.map((v) => normalize(v, item));\n }\n if (shape.properties && isPlainObject(value)) {\n const out: Record<string, unknown> = { ...value };\n for (const [key, child] of Object.entries(shape.properties)) {\n // Only own keys: `out.constructor` would read Object.prototype's.\n const current = Object.hasOwn(out, key) ? out[key] : undefined;\n if (key === '__proto__') continue;\n const normalized = normalize(current, child);\n if (normalized === undefined) delete out[key];\n else out[key] = normalized;\n }\n return out;\n }\n return value;\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────\n\n/** Apply a node's own marks to the shape read from what it wraps. */\nfunction withMarks(\n optional: boolean,\n sensitive: boolean\n): (shape: FieldShape | undefined) => FieldShape | undefined {\n return (shape) => {\n if (!optional && !sensitive) return shape;\n return {\n ...shape,\n ...(optional ? { optional: true } : {}),\n ...(sensitive ? { sensitive: true } : {}),\n };\n };\n}\n\nfunction asList(value: unknown): unknown[] {\n return Array.isArray(value) ? value : [];\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return isRecord(value) && !Array.isArray(value) && !(value instanceof Blob);\n}\n","/**\n * createActionClient — typed middleware and schema validation for server actions.\n *\n * Inspired by next-safe-action. Provides a builder API:\n * createActionClient({ middleware }) → .schema(z.object(...)) → .action(fn)\n *\n * The resulting action function satisfies both:\n * 1. Direct call: action(input) → Promise<ActionResult>\n * 2. React useActionState: (prevState, formData) => Promise<ActionResult>\n *\n * Types live in `action-types.ts`, schema handling in `action-schema.ts`, and\n * the schema's declared shape (list fields, sensitive fields) in\n * `schema-introspection.ts`.\n *\n * See design/08-forms-and-actions.md §\"Middleware and Server Actions\"\n */\n\nimport { parseFormData } from './form-data.ts';\nimport { formatSize } from '../utils/format.ts';\nimport { isDebug, isDevMode } from './debug.ts';\nimport { isDenySignal, isRedirectSignal } from './signal-identity.ts';\nimport {\n stripSensitiveFields,\n resolveSensitivePredicate,\n getGlobalSensitiveFieldsConfig,\n type SensitiveFieldsOption,\n} from './sensitive-fields.ts';\nimport {\n validateWithSchema,\n type ActionSchema,\n type SchemaInput,\n type SchemaOutput,\n} from './action-schema.ts';\nimport { introspectSchema, normalizeListFields, type FieldShape } from './schema-introspection.ts';\nimport type {\n ActionBuilder,\n ActionContext,\n ActionFn,\n ActionMiddleware,\n ActionResult,\n ActionServerError,\n ValidationErrors,\n} from './action-types.ts';\n\n// ─── ActionError ─────────────────────────────────────────────────────────\n\n/**\n * Typed error class for server actions. Carries a string code and optional data.\n * When thrown from middleware or the action body, the action short-circuits and\n * the client receives `result.serverError`.\n *\n * In production, unexpected errors (non-ActionError) return `{ code: 'INTERNAL_ERROR' }`\n * with no message. In dev, `data.message` is included.\n */\nexport class ActionError<TCode extends string = string> extends Error {\n readonly code: TCode;\n readonly data: Record<string, unknown> | undefined;\n\n constructor(code: TCode, data?: Record<string, unknown>) {\n super(`ActionError: ${code}`);\n this.name = 'ActionError';\n this.code = code;\n this.data = data;\n }\n}\n\n// ─── Config ──────────────────────────────────────────────────────────────\n\ninterface ActionClientConfig<TCtx> {\n middleware?: ActionMiddleware<TCtx> | ActionMiddleware<Record<string, unknown>>[];\n /** Max file size in bytes. Files exceeding this are rejected with validation errors. */\n fileSizeLimit?: number;\n /**\n * Override the sensitive-field name deny-list for this action client.\n * See `SensitiveFieldsOption` in `./sensitive-fields.ts`. Per-client config\n * takes precedence over the global `forms.stripSensitiveFields` option in\n * `timber.config.ts`. Fields the schema marks `.meta({ sensitive: true })`\n * are stripped whatever this says. See design/08-forms-and-actions.md.\n */\n stripSensitiveFields?: SensitiveFieldsOption;\n}\n\n// ─── Implementation ──────────────────────────────────────────────────────\n\n/**\n * Run middleware array or single function. Returns merged context.\n */\nasync function runActionMiddleware<TCtx>(\n middleware: ActionMiddleware<TCtx> | ActionMiddleware<Record<string, unknown>>[] | undefined\n): Promise<TCtx> {\n if (!middleware) {\n return {} as TCtx;\n }\n\n if (Array.isArray(middleware)) {\n let merged = {} as Record<string, unknown>;\n for (const mw of middleware) {\n const result = await mw();\n merged = { ...merged, ...result };\n }\n return merged as TCtx;\n }\n\n return await middleware();\n}\n\n/**\n * Wrap unexpected errors into a safe server error result.\n * ActionError → typed result. Other errors → INTERNAL_ERROR (no leak).\n *\n * `createActionClient` actions only. A raw `'use server'` function that\n * throws is rejected on the client instead (action-handler.ts).\n */\nexport function handleActionError(error: unknown): { serverError: ActionServerError } {\n if (error instanceof ActionError) {\n return {\n serverError: {\n code: error.code,\n ...(error.data ? { data: error.data } : {}),\n },\n };\n }\n\n // In dev, include the message for debugging.\n // Uses isDevMode() — NOT isDebug() — because this data is sent to the\n // browser. TIMBER_DEBUG must never cause error messages to leak to clients.\n // See design/13-security.md principle 4: \"Errors don't leak.\"\n const devMode = isDevMode();\n return {\n serverError: {\n code: 'INTERNAL_ERROR',\n ...(devMode && error instanceof Error ? { data: { message: error.message } } : {}),\n },\n };\n}\n\n/**\n * Create a typed action client with middleware and schema validation.\n *\n * @example\n * ```ts\n * const action = createActionClient({\n * middleware: async () => {\n * const user = await getUser()\n * if (!user) throw new ActionError('UNAUTHORIZED')\n * return { user }\n * },\n * })\n *\n * export const createTodo = action\n * .schema(z.object({ title: z.string().min(1) }))\n * .action(async ({ input, ctx }) => {\n * await db.todos.create({ ...input, userId: ctx.user.id })\n * })\n * ```\n */\nexport function createActionClient<TCtx = Record<string, never>>(\n config: ActionClientConfig<TCtx> = {}\n): ActionBuilder<TCtx> {\n function buildAction<TInput, TOutput, TData>(\n schema: ActionSchema | undefined,\n fn: (ctx: ActionContext<TCtx, TOutput>) => Promise<TData>\n ): ActionFn<TData, TInput> {\n // The schema's declared shape, read once per action on its first call:\n // which fields are lists, and which are marked sensitive.\n let shape: FieldShape | undefined;\n let introspected = false;\n const getShape = (): FieldShape | undefined => {\n if (!introspected) {\n shape = introspectSchema(schema);\n introspected = true;\n }\n return shape;\n };\n\n async function actionHandler(...args: unknown[]): Promise<ActionResult<TData>> {\n // The input is the last argument in every call shape: `(input)`,\n // `(formData)`, `(prevState, payload)` from useActionState's\n // dispatch, `(initialState, formData)` on the no-JS path (Fizz binds\n // the initial state into the form, and decodeAction binds the\n // FormData after it), and `(...bound, prevState, payload)` for an\n // action with bound arguments. Nothing before it is input:\n // `prevState` comes from the client, so it is never read.\n const last = args.at(-1);\n // A form's list fields take the shape the schema declares whatever\n // their count, both for validation and for `submittedValues`.\n const form =\n last instanceof FormData ? normalizeListFields(parseFormData(last), getShape()) : undefined;\n\n // Precedence: per-client (config.stripSensitiveFields) > global\n // (forms.stripSensitiveFields from timber.config.ts) > built-in deny-list.\n const sensitivePredicate = resolveSensitivePredicate(\n config.stripSensitiveFields,\n getGlobalSensitiveFieldsConfig()\n );\n\n // A \"safe-to-echo\" copy of the input. Files are stripped (can't\n // serialize, shouldn't echo back) and sensitive fields (passwords,\n // tokens, CVV, schema-marked fields) are removed before they would\n // land in the RSC payload → client form `defaultValue` → DOM.\n const echo = (value: unknown): Record<string, unknown> | undefined => {\n const withoutFiles = stripFiles(value);\n if (withoutFiles === undefined) return undefined;\n return stripSensitiveFields(withoutFiles, sensitivePredicate, getShape());\n };\n\n try {\n // Run middleware\n const ctx = await runActionMiddleware(config.middleware);\n\n // Without a schema the action receives the FormData itself. Checks\n // and echoes read the parsed form: a FormData has no own entries.\n const rawInput: unknown = schema && form ? form : last;\n const submitted: unknown = form ?? rawInput;\n\n // Validate file sizes before schema validation.\n if (config.fileSizeLimit !== undefined && submitted && typeof submitted === 'object') {\n const fileSizeErrors = validateFileSizes(\n submitted as Record<string, unknown>,\n config.fileSizeLimit\n );\n if (fileSizeErrors) {\n return { validationErrors: fileSizeErrors, submittedValues: echo(submitted) };\n }\n }\n\n let input: unknown = rawInput;\n if (schema) {\n const validation = validateWithSchema(schema, rawInput);\n if (!validation.ok) {\n logValidationFailure(validation.validationErrors);\n return {\n validationErrors: validation.validationErrors,\n submittedValues: echo(submitted),\n };\n }\n input = validation.value;\n }\n\n // Execute the action body. `input` is the schema's output, or the\n // raw input when there is no schema (TOutput is `undefined` then).\n const data = await fn({ ctx, input: input as TOutput });\n return { data };\n } catch (error) {\n // Re-throw redirect/deny signals — these are control flow, not errors.\n // They must propagate to executeAction() which converts them to proper\n // HTTP responses (302 redirect, 4xx deny). Catching them here would\n // wrap them as INTERNAL_ERROR and break redirect()/redirectExternal()/deny().\n if (isRedirectSignal(error) || isDenySignal(error)) {\n throw error;\n }\n // A `serverError` echoes the form like a validation failure does.\n // React resets the form after the action, and a form whose defaults\n // fell back to page data would lose what the user typed (TIM-1573).\n const result = handleActionError(error);\n const submittedValues = form && echo(form);\n return submittedValues ? { ...result, submittedValues } : result;\n }\n }\n\n // One implementation serves every overload of `ActionFn`, which\n // TypeScript cannot check a single function against.\n return actionHandler as ActionFn<TData, TInput>;\n }\n\n return {\n schema<S extends ActionSchema>(schema: S) {\n return {\n action<TData>(\n fn: (ctx: ActionContext<TCtx, SchemaOutput<S>>) => Promise<TData>\n ): ActionFn<TData, SchemaInput<S>> {\n return buildAction(schema, fn);\n },\n };\n },\n action<TData>(\n fn: (ctx: ActionContext<TCtx, undefined>) => Promise<TData>\n ): ActionFn<TData, undefined> {\n return buildAction(undefined, fn);\n },\n };\n}\n\n// ─── Helpers ────────────────────────────────────────────────────────────\n\n/**\n * Log validation failures in dev mode so developers can see what went wrong.\n * In production, validation errors are only returned to the client.\n */\nfunction logValidationFailure(errors: ValidationErrors): void {\n const isDev = isDebug();\n if (!isDev) return;\n\n const fields = Object.entries(errors)\n .map(([field, messages]) => ` ${field}: ${(messages ?? []).join(', ')}`)\n .join('\\n');\n console.warn(`[timber] action schema validation failed:\\n${fields}`);\n}\n\n/**\n * Validate that all File objects in the input are within the size limit.\n * Returns validation errors keyed by field name, or null if all files are ok.\n * Keys are dot paths (`rows.0.file`), the form a field name and a Standard\n * Schema error use, so `errors.field()` finds a file in a list.\n */\nfunction validateFileSizes(input: Record<string, unknown>, limit: number): ValidationErrors | null {\n const limitKb = Math.round(limit / 1024);\n const limitLabel =\n limit >= 1024 * 1024 ? `${Math.round(limit / (1024 * 1024))}MB` : `${limitKb}KB`;\n\n const errors: Record<string, string[]> = {};\n\n function walk(obj: Record<string, unknown>, prefix: string): void {\n for (const [key, value] of Object.entries(obj)) {\n const path = prefix ? `${prefix}.${key}` : key;\n if (value instanceof File && value.size > limit) {\n errors[path] = [\n `File \"${value.name}\" (${formatSize(value.size)}) exceeds the ${limitLabel} limit`,\n ];\n } else if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n const item = value[i];\n const itemPath = `${path}.${i}`;\n if (item instanceof File && item.size > limit) {\n (errors[itemPath] ??= []).push(\n `File \"${item.name}\" (${formatSize(item.size)}) exceeds the ${limitLabel} limit`\n );\n } else if (typeof item === 'object' && item !== null && !(item instanceof File)) {\n walk(item as Record<string, unknown>, itemPath);\n }\n }\n } else if (typeof value === 'object' && value !== null && !(value instanceof File)) {\n walk(value as Record<string, unknown>, path);\n }\n }\n }\n\n walk(input, '');\n return Object.keys(errors).length > 0 ? errors : null;\n}\n\n/**\n * Strip File objects from a value, returning a copy safe for serialization.\n * File objects can't be serialized and shouldn't be echoed back.\n *\n * Mirrors `parseFormData`'s output: objects and arrays at any depth, arrays\n * of arrays included. A File in an array becomes `undefined` rather than\n * being removed, so `rows.2` still names the third element (TIM-1573).\n */\nfunction stripFiles(value: unknown): Record<string, unknown> | undefined {\n if (value === null || typeof value !== 'object' || value instanceof File) return undefined;\n return stripFilesFrom(value) as Record<string, unknown>;\n}\n\nfunction stripFilesFrom(value: unknown): unknown {\n if (value instanceof File) return undefined;\n if (Array.isArray(value)) return value.map(stripFilesFrom);\n if (typeof value !== 'object' || value === null) return value;\n const result: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n if (!(v instanceof File)) result[k] = stripFilesFrom(v);\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAWA,IAAa,eAAe;CAC1B,MAAM;CACN,SAAS;AACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACgDA,IAAM,6BAAgD;CACpD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;AASA,IAAM,wBAA2C;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;AAAM;;;;;;;AAQ3F,IAAM,yBAA4C,CAAC,OAAO;;;;;;;AAQ1D,SAASA,YAAU,MAAsB;CACvC,OAAO,KAAK,QAAQ,SAAS,EAAE,CAAC,CAAC,YAAY;AAC/C;;;;;;;AAQA,SAAS,MAAM,MAAwB;CACrC,OAAO,KACJ,MAAM,gCAAgC,CAAC,CACvC,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,EAAE,YAAY,CAAC;AAC/B;;AAGA,SAAS,eAAe,MAAuB;CAC7C,OAAO,MAAM,IAAI,CAAC,CAAC,MAAM,SACvB,sBAAsB,MAAM,MAAM,KAAK,WAAW,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAC1E;AACF;;;;;AAMA,SAAS,mBAAmB,MAAc,QAAqC;CAC7E,MAAM,aAAaA,YAAU,IAAI;CACjC,IAAI,uBAAuB,SAAS,UAAU,GAAG,OAAO;CACxD,KAAK,MAAM,WAAW,4BACpB,IAAI,WAAW,SAAS,OAAO,GAAG,OAAO;CAE3C,IAAI,eAAe,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KAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,KAAK,GACvC,IAAI,EAAE,aAAa,OAAO,OAAO,KAAK,eAAe,CAAC;CAExD,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["normalize"],"sources":["../../src/shared/redirect-type.ts","../../src/server/sensitive-fields.ts","../../src/server/action-schema.ts","../../src/server/schema-introspection.ts","../../src/server/action-client.ts"],"sourcesContent":["/**\n * Next.js redirect type discriminator.\n *\n * Provided for API compatibility with libraries that import `RedirectType`\n * from `next/navigation`. In timber, `redirect()` always uses `replace`\n * semantics (no history entry for the redirect itself).\n *\n * Lives in shared/ (isomorphic) so both the server primitives and the\n * client-only next/navigation shim export the same definition without the\n * client shim pulling in server code.\n */\nexport const RedirectType = {\n push: 'push',\n replace: 'replace',\n} as const;\n\nexport type RedirectTypeValue = (typeof RedirectType)[keyof typeof RedirectType];\n","/**\n * Sensitive field stripping — removes password/token/CVV-style fields from\n * the `submittedValues` a `createActionClient` action echoes back to the\n * client for form repopulation.\n *\n * **This is hygiene, not a security boundary.** `submittedValues` only ever\n * returns to the user who typed it, in the response to their own POST:\n *\n * - With JavaScript, it travels in the action's response, a non-cacheable\n * POST fetch. What remains is exposure to devtools, HAR exports and\n * TLS-inspecting proxies.\n * - Without JavaScript, it is rendered into the page's HTML as a field's\n * `defaultValue`: one uncached response, but one that view-source, the\n * back-forward cache and a shared machine can surface. OWASP advises not\n * pre-filling password fields for this reason.\n *\n * The main reason to strip is UX: a password or card field comes back empty\n * after a failed submit, as users expect.\n *\n * What is stripped: a field whose name matches the built-in deny-list (or the\n * configured option), and a field the action's schema marks sensitive with\n * `.meta({ sensitive: true })` (Valibot: `v.metadata({ sensitive: true })`),\n * at its exact path. The schema mark covers names the list misses\n * (`recoveryPhrase`) and always applies, even with the name list turned off.\n *\n * Only `createActionClient` strips, because only it builds `submittedValues`.\n * A raw `'use server'` action owns its return value: whatever it returns is\n * what the client gets, on both paths.\n *\n * See design/08-forms-and-actions.md §\"Sensitive field stripping\"\n * See design/13-security.md §\"Sensitive field stripping\"\n */\n\nimport { isDebug } from './debug.ts';\nimport type { FieldShape } from './schema-introspection.ts';\n\n// ─── Public types ────────────────────────────────────────────────────────\n\n/**\n * How to strip sensitive fields from `submittedValues`, by name.\n *\n * - `true` / `undefined` — use the built-in deny-list (default).\n * - `false` — strip no field by name. Fields the schema marks sensitive are\n * still stripped.\n * - `string[]` — additional field names to strip, merged with the built-in list.\n * - `(name) => boolean` — custom predicate, fully replaces the built-in list.\n * Return `true` to strip, `false` to keep. The `name` argument is the raw\n * (un-normalized) field name as it appeared in the submitted form.\n */\nexport type SensitiveFieldsOption = boolean | readonly string[] | ((name: string) => boolean);\n\n// ─── Built-in deny-list ──────────────────────────────────────────────────\n\n/**\n * Substring patterns matched against the normalized field name.\n * Normalization = lowercase + strip `_` and `-`.\n *\n * Any field whose normalized name *contains* one of these strings is\n * considered sensitive. Entries like `currentPassword`, `passwordConfirmation`,\n * and `user.password` all match via the `password` substring. Every pattern\n * here is long enough not to occur inside an ordinary word.\n */\nconst BUILTIN_SUBSTRING_PATTERNS: readonly string[] = [\n 'password',\n 'passwd',\n 'secret',\n 'apikey',\n 'accesstoken',\n 'refreshtoken',\n 'cardnumber',\n 'cardcvc',\n 'socialsecuritynumber',\n 'mfacode',\n 'twofactorcode',\n 'privatekey',\n];\n\n/**\n * Patterns matched at the start or end of a word of the field name. These are\n * short enough to occur inside ordinary words (`otp` in `footPath` and\n * `notpublic`, `ssn` in `class_number` and `classnumber`), so they must\n * begin or end a word: `otp`, `otpCode`, `otpcode`, `userotp`, `user_ssn`,\n * `SSNLast4`, `newpwd`, `cardcvv`.\n */\nconst BUILTIN_WORD_PATTERNS: readonly string[] = ['pwd', 'cvv', 'cvc', 'ssn', 'otp', 'totp'];\n\n/**\n * Exact matches against the normalized field name. These are field names that\n * are too short or too common to substring-match safely. e.g. `token` alone\n * would match `csrfToken`, which is not sensitive — so `token` is exact-only,\n * while legitimate token fields are covered by `accesstoken` / `refreshtoken`.\n */\nconst BUILTIN_EXACT_PATTERNS: readonly string[] = ['token'];\n\n/**\n * Normalize a field name for deny-list comparison.\n * Lowercases the string and strips `_` and `-` so camelCase, snake_case, and\n * kebab-case variants all compare equal (`api_key` / `apiKey` / `api-key` →\n * `apikey`).\n */\nfunction normalize(name: string): string {\n return name.replace(/[_-]/g, '').toLowerCase();\n}\n\n/**\n * Split a field name into lowercase words at anything that is not a letter\n * and at a lowercase-to-uppercase hump: `user_ssnLast4` → `user`, `ssn`,\n * `last`. An acronym stays joined to what follows it (`OTPcode` →\n * `otpcode`, `SSNLast` → `ssnlast`), which a start-of-word match still finds.\n */\nfunction words(name: string): string[] {\n return name\n .split(/[^A-Za-z]+|(?<=[a-z])(?=[A-Z])/)\n .filter(Boolean)\n .map((w) => w.toLowerCase());\n}\n\n/** Whether a short pattern begins or ends one of the name's words. */\nfunction hasWordPattern(name: string): boolean {\n return words(name).some((word) =>\n BUILTIN_WORD_PATTERNS.some((p) => word.startsWith(p) || word.endsWith(p))\n );\n}\n\n/**\n * Check whether a name matches the built-in deny-list (with optional extras).\n * Extras are merged into the substring pattern list after normalization.\n */\nfunction isBuiltinSensitive(name: string, extras?: readonly string[]): boolean {\n const normalized = normalize(name);\n if (BUILTIN_EXACT_PATTERNS.includes(normalized)) return true;\n for (const pattern of BUILTIN_SUBSTRING_PATTERNS) {\n if (normalized.includes(pattern)) return true;\n }\n if (hasWordPattern(name)) return true;\n if (extras && extras.length > 0) {\n for (const extra of extras) {\n const normExtra = normalize(extra);\n if (normExtra.length === 0) continue;\n if (normalized.includes(normExtra)) return true;\n }\n }\n return false;\n}\n\n// ─── Predicate resolution ────────────────────────────────────────────────\n\n/**\n * A resolved predicate: `null` means \"strip no field by name\" (the option was\n * explicitly `false`). Otherwise a function from raw field name → boolean.\n */\nexport type ResolvedSensitivePredicate = ((name: string) => boolean) | null;\n\n/**\n * Resolve a `SensitiveFieldsOption` into a concrete predicate.\n * Precedence: per-action > global > built-in default.\n *\n * - Per-action `undefined` → fall back to global.\n * - Global `undefined` → use built-in list.\n * - Either level set to `false` → no name matching (returns `null`).\n * - `true` → built-in list.\n * - `string[]` → built-in ∪ extras.\n * - function → custom, replaces the built-in list entirely.\n */\nexport function resolveSensitivePredicate(\n perAction: SensitiveFieldsOption | undefined,\n global: SensitiveFieldsOption | undefined\n): ResolvedSensitivePredicate {\n const chosen = perAction !== undefined ? perAction : global;\n\n if (chosen === false) return null;\n if (chosen === undefined || chosen === true) {\n return (name) => isBuiltinSensitive(name);\n }\n if (typeof chosen === 'function') {\n return chosen;\n }\n // Array of extra names merged with the built-in list.\n const extras = chosen;\n return (name) => isBuiltinSensitive(name, extras);\n}\n\n// ─── Module-level global config ──────────────────────────────────────────\n\nlet globalConfig: SensitiveFieldsOption | undefined;\n\n/**\n * Set the global `forms.stripSensitiveFields` config from `timber.config.ts`.\n * Called once at startup from `rsc-entry`.\n */\nexport function setGlobalSensitiveFieldsConfig(option: SensitiveFieldsOption | undefined): void {\n globalConfig = option;\n}\n\n/** Read the global `forms.stripSensitiveFields` config. */\nexport function getGlobalSensitiveFieldsConfig(): SensitiveFieldsOption | undefined {\n return globalConfig;\n}\n\n// ─── Stripping ───────────────────────────────────────────────────────────\n\n// One warning per field name per process — prevents log spam when a form is\n// submitted many times in dev mode.\nconst warnedFields = new Set<string>();\n\nfunction warnStripped(name: string, markedInSchema: boolean): void {\n if (!isDebug()) return;\n if (warnedFields.has(name)) return;\n warnedFields.add(name);\n console.warn(\n `[timber] stripped sensitive field \"${name}\" from submittedValues. ` +\n (markedInSchema\n ? `The action's schema marks it sensitive; remove the mark to echo it.`\n : `Override via forms.stripSensitiveFields in timber.config.ts.`)\n );\n}\n\n/**\n * Walk an object (recursively) and return a copy without its sensitive\n * fields: every key `predicate` matches, and every field `shape` (the\n * schema's declared shape) marks sensitive. Nested objects like\n * `{ user: { password: '...' } }` are handled — `user.password` is stripped\n * while other `user.*` fields remain.\n *\n * - Arrays are walked element-wise (object entries inside arrays are cleaned).\n * - Non-plain values (strings, numbers, Files, Dates, etc.) are returned as-is.\n * - When a stripped key is encountered, it is omitted from the result entirely\n * — we do NOT set it to an empty string, because that would overwrite a\n * valid `defaultValue` the form author might have set.\n */\nexport function stripSensitiveFields(\n value: Record<string, unknown>,\n predicate: ResolvedSensitivePredicate,\n shape?: FieldShape\n): Record<string, unknown> {\n if (predicate === null && !hasSensitive(shape)) return value;\n return stripFrom(value, predicate, shape) as Record<string, unknown>;\n}\n\nfunction stripFrom(\n value: unknown,\n predicate: ResolvedSensitivePredicate,\n shape: FieldShape | undefined\n): unknown {\n if (value === null || typeof value !== 'object') return value;\n if (value instanceof Blob || value instanceof Date) return value;\n\n if (Array.isArray(value)) {\n return value.map((item) => stripFrom(item, predicate, shape?.item));\n }\n\n // A list `parseFormData` kept as an object (an indexed list with a gap,\n // `keys.0` and `keys.2`): every value is an item.\n const indexed = shape?.item !== undefined && shape.properties === undefined;\n const result: Record<string, unknown> = {};\n for (const [key, nested] of Object.entries(value)) {\n const child = indexed ? shape.item : shape?.properties?.[key];\n if (child?.sensitive || predicate?.(key)) {\n warnStripped(key, child?.sensitive === true);\n continue;\n }\n result[key] = stripFrom(nested, predicate, child);\n }\n return result;\n}\n\n/** Whether `shape` marks any field at or below it sensitive. */\nfunction hasSensitive(shape: FieldShape | undefined): boolean {\n if (!shape) return false;\n if (shape.sensitive) return true;\n if (hasSensitive(shape.item)) return true;\n return Object.values(shape.properties ?? {}).some(hasSensitive);\n}\n\n// ─── Test helpers ────────────────────────────────────────────────────────\n\n/** The built-in patterns, for the docs drift test. */\nexport const __BUILTIN_SENSITIVE_PATTERNS: readonly string[] = [\n ...BUILTIN_SUBSTRING_PATTERNS,\n ...BUILTIN_WORD_PATTERNS,\n ...BUILTIN_EXACT_PATTERNS,\n];\n\n/** Reset the \"warned once\" cache. Exposed for tests. */\nexport function __resetSensitiveFieldsWarnings(): void {\n warnedFields.clear();\n}\n","/**\n * Action input schemas — the Standard Schema protocol (and the legacy\n * `.parse()` interface) as `createActionClient().schema()` accepts them, the\n * input/output types they carry, and running one against an action's input.\n *\n * See design/08-forms-and-actions.md §\"Validation Pattern\"\n */\n\nimport type { ValidationErrors } from './action-types.ts';\n\n// ─── Standard Schema ──────────────────────────────────────────────────────\n\n/**\n * Standard Schema v1 interface (subset).\n * Zod ≥3.24, Valibot ≥1.0, and ArkType all implement this.\n * See https://github.com/standard-schema/standard-schema\n *\n * `types` is the protocol's type-only carrier: a schema's input type (what a\n * caller passes, before coercion) and output type (what validation produces).\n * We use permissive types for issues and paths to accept all compliant\n * libraries without requiring exact structural matches on their shapes.\n */\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n readonly '~standard': {\n readonly validate: (\n value: unknown\n ) => StandardSchemaResult<Output> | Promise<StandardSchemaResult<Output>>;\n readonly types?: { readonly input: Input; readonly output: Output } | undefined;\n };\n}\n\ntype StandardSchemaResult<Output> =\n | { value: Output; issues?: undefined }\n | { value?: undefined; issues: ReadonlyArray<StandardSchemaIssue> };\n\ninterface StandardSchemaIssue {\n message: string;\n path?: ReadonlyArray<PropertyKey | { key: PropertyKey }>;\n}\n\n/** Check if a schema implements the Standard Schema protocol. */\nexport function isStandardSchema(schema: unknown): schema is StandardSchemaV1 {\n return (\n typeof schema === 'object' &&\n schema !== null &&\n '~standard' in schema &&\n typeof (schema as StandardSchemaV1)['~standard'].validate === 'function'\n );\n}\n\n// ─── Schema types ─────────────────────────────────────────────────────────\n\n/**\n * Minimal schema interface — compatible with Zod, Valibot, ArkType, etc.\n *\n * Accepts either:\n * - Standard Schema (preferred): any object with `~standard.validate()`\n * - Legacy parse interface: objects with `.parse()` / `.safeParse()`\n *\n * At runtime, Standard Schema is detected via `~standard` property and\n * takes priority over the legacy interface.\n */\nexport type ActionSchema<T = unknown> = StandardSchemaV1<unknown, T> | LegacyActionSchema<T>;\n\n/** Legacy schema interface with .parse() / .safeParse(). */\ninterface LegacyActionSchema<T = unknown> {\n 'parse'(data: unknown): T;\n 'safeParse'?(data: unknown): { success: true; data: T } | { success: false; error: SchemaError };\n // Exclude Standard Schema objects from matching this interface\n '~standard'?: never;\n}\n\n/** Schema validation error shape (for legacy .safeParse()/.parse() interface). */\nexport interface SchemaError {\n issues?: Array<{ path?: Array<string | number>; message: string }>;\n flatten?(): { fieldErrors: Record<string, string[]> };\n}\n\n/**\n * What a validated action's body receives: the schema's output, after\n * coercion and defaults.\n */\nexport type SchemaOutput<S> = S extends { readonly '~standard': infer Std }\n ? DeclaredType<Std, 'output', ValidatedValue<S>>\n : S extends LegacyActionSchema<infer T>\n ? T\n : never;\n\n/**\n * The value a Standard Schema's `validate` produces on success, for a schema\n * that declares no `types`. Only the success branch has a required `value`.\n */\ntype ValidatedValue<S> = S extends {\n readonly '~standard': { readonly validate: (value: unknown) => infer R };\n}\n ? SuccessValue<Awaited<R>>\n : never;\n\n/** Distributes over the result union, keeping the members with a value. */\ntype SuccessValue<R> = R extends { value: infer O } ? O : never;\n\n/**\n * What a caller passes a validated action: the schema's input, before\n * coercion. A schema that declares no `types` (a hand-written Standard\n * Schema, a legacy `.parse()` schema) has one type for both.\n */\nexport type SchemaInput<S> = S extends { readonly '~standard': infer Std }\n ? DeclaredType<Std, 'input', SchemaOutput<S>>\n : SchemaOutput<S>;\n\n/**\n * `Std.types[K]` when the schema declares `types` (Zod, Valibot, ArkType do),\n * else `Fallback`. Read by key, because `types` is optional in the protocol.\n */\ntype DeclaredType<Std, K extends 'input' | 'output', Fallback> = 'types' extends keyof Std\n ? NonNullable<Std['types' & keyof Std]> extends { readonly [P in K]: infer T }\n ? T\n : Fallback\n : Fallback;\n\n// ─── Validation ───────────────────────────────────────────────────────────\n\n/** The outcome of running an action's schema over its input. */\nexport type SchemaValidation<T> =\n | { ok: true; value: T }\n | { ok: false; validationErrors: ValidationErrors };\n\n/**\n * Validate `input` with `schema`, through Standard Schema when the schema\n * implements it, and through `.safeParse()` / `.parse()` otherwise. Only\n * synchronous Standard Schema validation is supported.\n */\nexport function validateWithSchema<T>(\n schema: ActionSchema<T>,\n input: unknown\n): SchemaValidation<T> {\n if (isStandardSchema(schema)) {\n const result = schema['~standard'].validate(input);\n if (result instanceof Promise) {\n throw new Error(\n '[timber] createActionClient: schema returned a Promise — only sync schemas are supported.'\n );\n }\n if (result.issues) {\n return { ok: false, validationErrors: extractStandardSchemaErrors(result.issues) };\n }\n return { ok: true, value: result.value };\n }\n if (typeof schema.safeParse === 'function') {\n const result = schema.safeParse(input);\n if (!result.success) {\n return { ok: false, validationErrors: extractValidationErrors(result.error) };\n }\n return { ok: true, value: result.data };\n }\n try {\n return { ok: true, value: schema.parse(input) };\n } catch (parseError) {\n return { ok: false, validationErrors: extractValidationErrors(parseError as SchemaError) };\n }\n}\n\n/**\n * Extract validation errors from a schema error.\n * Supports Zod's flatten() and generic issues array.\n */\nfunction extractValidationErrors(error: SchemaError): ValidationErrors {\n // Zod-style flatten\n if (typeof error.flatten === 'function') {\n return error.flatten().fieldErrors;\n }\n\n // Generic issues array\n if (error.issues) {\n const errors: Record<string, string[]> = {};\n for (const issue of error.issues) {\n const path = issue.path?.join('.') ?? '_root';\n (errors[path] ??= []).push(issue.message);\n }\n return errors;\n }\n\n return { _root: ['Validation failed'] };\n}\n\n/**\n * Extract validation errors from Standard Schema issues.\n */\nfunction extractStandardSchemaErrors(issues: ReadonlyArray<StandardSchemaIssue>): ValidationErrors {\n const errors: Record<string, string[]> = {};\n for (const issue of issues) {\n const path =\n issue.path\n ?.map((p) => {\n // Standard Schema path items can be { key: ... } objects or bare PropertyKey values\n if (typeof p === 'object' && p !== null && 'key' in p) return String(p.key);\n return String(p);\n })\n .join('.') ?? '_root';\n (errors[path] ??= []).push(issue.message);\n }\n return Object.keys(errors).length > 0 ? errors : { _root: ['Validation failed'] };\n}\n","/**\n * Schema introspection — the shape of an action's input as its schema\n * declares it: which fields are lists, which may be absent, and which the\n * schema marks sensitive.\n *\n * Standard Schema v1 has no introspection API, so this feature-detects what\n * the libraries expose:\n *\n * - **Zod 4**: its schema tree (`_zod.def`, documented for library authors),\n * with `.meta()` for marks and `_zod.optin` for fields that may be absent.\n * Not Zod's JSON Schema: that describes a `z.preprocess(fn, z.array(…))`\n * field as the inner array, and wrapping a scalar before `fn` runs would\n * hand a comma-splitting preprocessor `['a,b']`. A preprocessed field is\n * its author's to read, so it has no shape here.\n * - **Valibot**: its schema objects (`entries`, `item`, `wrapped`, `options`),\n * with `v.metadata({ sensitive: true })` read from the pipe.\n * - **Standard JSON Schema** (`~standard.jsonSchema.input()`) for any other\n * library that implements it, such as ArkType, whose\n * `.configure({ sensitive: true })` lands in the JSON Schema node.\n *\n * Any other schema (a legacy `.parse()` schema, Zod 3, a hand-written\n * Standard Schema) has no shape: its form input is not normalized and only\n * the name deny-list strips its echo.\n *\n * A union merges its branches: a field is sensitive if any branch marks it,\n * and a list only if every branch declares it one. An intersection merges\n * its parts, which all apply: a list or sensitive if any part says so.\n *\n * `createActionClient` computes the shape once per action and keeps it on the\n * action's closure. It is used twice, by `normalizeListFields` (before\n * validation, and for `submittedValues`) and by `stripSensitiveFields`.\n *\n * See design/08-forms-and-actions.md §\"The Form Model\" and\n * §\"Sensitive field stripping\".\n */\n\nimport { isStandardSchema } from './action-schema.ts';\n\n/** The declared shape of one field (or of the whole input). */\nexport interface FieldShape {\n /** The field holds items of this shape (a list, possibly not in every union branch). */\n item?: FieldShape;\n /** Every declaration of the field is a list: normalize its form value to an array. */\n list?: boolean;\n /** The field is an object; these are its properties' shapes. */\n properties?: Record<string, FieldShape>;\n /** The field may be absent (`.optional()`, a default, a missing union branch). */\n optional?: boolean;\n /** The schema marks the field sensitive (`.meta({ sensitive: true })`). */\n sensitive?: boolean;\n}\n\n/**\n * The shape of `schema`'s input, or `undefined` when the schema library\n * exposes nothing to read it from.\n */\nexport function introspectSchema(schema: unknown): FieldShape | undefined {\n if (!isStandardSchema(schema)) return undefined;\n const standard: Record<string, unknown> = schema['~standard'];\n if (standard.vendor === 'zod' && isRecord(schema) && isRecord(schema._zod)) {\n return fromZod(schema, new Set());\n }\n if (standard.vendor === 'valibot') return fromValibot(schema, new Set());\n\n const jsonSchema = standard.jsonSchema;\n if (!isRecord(jsonSchema) || typeof jsonSchema.input !== 'function') return undefined;\n let root: unknown;\n try {\n root = jsonSchema.input({ target: 'draft-2020-12' });\n } catch {\n return undefined;\n }\n return isRecord(root) ? fromJsonSchema(root, root, new Set()) : undefined;\n}\n\n// ─── Zod 4 ───────────────────────────────────────────────────────────────\n\n/** Zod wrappers whose `innerType` is the field's real type. */\nconst ZOD_WRAPPERS = new Set([\n 'optional',\n 'nullable',\n 'default',\n 'prefault',\n 'nonoptional',\n 'readonly',\n 'catch',\n]);\n\nfunction fromZod(schema: unknown, seen: Set<unknown>): FieldShape | undefined {\n if (!isRecord(schema) || seen.has(schema) || !isRecord(schema._zod)) return undefined;\n const inner = new Set(seen).add(schema);\n const def = schema._zod.def;\n if (!isRecord(def)) return undefined;\n const marks = withMarks(schema._zod.optin === 'optional', zodSensitive(schema));\n\n switch (def.type) {\n case 'object': {\n if (!isRecord(def.shape)) return marks(undefined);\n const properties: Record<string, FieldShape> = {};\n for (const [key, child] of Object.entries(def.shape)) {\n const shape = fromZod(child, inner);\n if (shape) properties[key] = shape;\n }\n return marks({ properties });\n }\n case 'array':\n return marks({ item: fromZod(def.element, inner) ?? {}, list: true });\n case 'union':\n return marks(mergeAll(asList(def.options).map((option) => fromZod(option, inner))));\n case 'intersection':\n return marks(intersectAll([fromZod(def.left, inner), fromZod(def.right, inner)]));\n case 'pipe':\n // `z.preprocess(fn, …)` is a pipe from a transform: its author reads\n // the raw value. Any other pipe takes its input side's shape.\n if (isRecord(def.in) && isRecord(def.in._zod) && isRecord(def.in._zod.def)) {\n if (def.in._zod.def.type === 'transform') return marks(undefined);\n }\n return marks(fromZod(def.in, inner));\n default:\n if (typeof def.type === 'string' && ZOD_WRAPPERS.has(def.type)) {\n return marks(fromZod(def.innerType, inner));\n }\n return marks(undefined);\n }\n}\n\n/** `.meta()` read back: Zod returns the schema's registered metadata. */\nfunction zodSensitive(schema: Record<string, unknown>): boolean {\n if (typeof schema.meta !== 'function') return false;\n try {\n const meta: unknown = schema.meta();\n return isRecord(meta) && meta.sensitive === true;\n } catch {\n return false;\n }\n}\n\n// ─── Valibot ─────────────────────────────────────────────────────────────\n\n/** Valibot wrappers whose `wrapped` schema is the field's real type. */\nconst VALIBOT_WRAPPERS = new Set([\n 'optional',\n 'exact_optional',\n 'nullable',\n 'nullish',\n 'undefinedable',\n 'non_optional',\n 'non_nullable',\n 'non_nullish',\n]);\n\n/** Valibot wrappers that let the field be absent. */\nconst VALIBOT_OPTIONAL = new Set(['optional', 'exact_optional', 'nullish', 'undefinedable']);\n\nconst VALIBOT_OBJECTS = new Set(['object', 'loose_object', 'strict_object', 'object_with_rest']);\n\nfunction fromValibot(schema: unknown, seen: Set<unknown>): FieldShape | undefined {\n if (!isRecord(schema) || seen.has(schema)) return undefined;\n const inner = new Set(seen).add(schema);\n const sensitive =\n Array.isArray(schema.pipe) &&\n schema.pipe.some(\n (action) =>\n isRecord(action) &&\n action.kind === 'metadata' &&\n isRecord(action.metadata) &&\n action.metadata.sensitive === true\n );\n\n const type = schema.type;\n const marks = withMarks(typeof type === 'string' && VALIBOT_OPTIONAL.has(type), sensitive);\n if (typeof type !== 'string') return marks(undefined);\n if (VALIBOT_WRAPPERS.has(type)) return marks(fromValibot(schema.wrapped, inner));\n if (type === 'array') return marks({ item: fromValibot(schema.item, inner) ?? {}, list: true });\n if (type === 'union' || type === 'variant') {\n return marks(mergeAll(asList(schema.options).map((option) => fromValibot(option, inner))));\n }\n if (type === 'intersect') {\n return marks(intersectAll(asList(schema.options).map((option) => fromValibot(option, inner))));\n }\n if (VALIBOT_OBJECTS.has(type) && isRecord(schema.entries)) {\n const properties: Record<string, FieldShape> = {};\n for (const [key, child] of Object.entries(schema.entries)) {\n const shape = fromValibot(child, inner);\n if (shape) properties[key] = shape;\n }\n return marks({ properties });\n }\n return marks(undefined);\n}\n\n// ─── Standard JSON Schema ────────────────────────────────────────────────\n\nfunction fromJsonSchema(\n node: Record<string, unknown>,\n root: Record<string, unknown>,\n refs: Set<string>\n): FieldShape | undefined {\n const marks = withMarks(false, node.sensitive === true);\n const ref = node.$ref;\n if (typeof ref === 'string') {\n // A recursive schema: stop at a ref already being expanded on this path.\n if (refs.has(ref)) return marks(undefined);\n const target = resolveRef(root, ref);\n if (!target) return marks(undefined);\n return marks(fromJsonSchema(target, root, new Set(refs).add(ref)));\n }\n\n const branches = node.anyOf ?? node.oneOf;\n if (Array.isArray(branches)) {\n const shapes = branches\n .filter((b): b is Record<string, unknown> => isRecord(b) && b.type !== 'null')\n .map((b) => fromJsonSchema(b, root, refs));\n return marks(mergeAll(shapes));\n }\n\n if (Array.isArray(node.allOf)) {\n const parts = node.allOf.filter(isRecord).map((part) => fromJsonSchema(part, root, refs));\n return marks(intersectAll(parts));\n }\n\n const types = Array.isArray(node.type) ? node.type : [node.type];\n if (types.includes('array') && isRecord(node.items)) {\n return marks({ item: fromJsonSchema(node.items, root, refs) ?? {}, list: true });\n }\n if (isRecord(node.properties)) {\n const required = new Set(asList(node.required));\n const properties: Record<string, FieldShape> = {};\n for (const [key, child] of Object.entries(node.properties)) {\n const shape = isRecord(child) ? fromJsonSchema(child, root, refs) : undefined;\n if (shape) properties[key] = required.has(key) ? shape : { ...shape, optional: true };\n }\n return marks({ properties });\n }\n return marks(undefined);\n}\n\n/** Resolve a local `#/$defs/...` or `#/definitions/...` reference. */\nfunction resolveRef(\n root: Record<string, unknown>,\n ref: string\n): Record<string, unknown> | undefined {\n if (!ref.startsWith('#/')) return undefined;\n let node: unknown = root;\n for (const segment of ref.slice(2).split('/')) {\n if (!isRecord(node)) return undefined;\n node = node[segment.replaceAll('~1', '/').replaceAll('~0', '~')];\n }\n return isRecord(node) ? node : undefined;\n}\n\n// ─── Unions ──────────────────────────────────────────────────────────────\n\n/**\n * One shape for the branches of a union. A field is sensitive if any branch\n * marks it, a list only if every branch declares it one, and optional if any\n * branch lacks it. A branch with no shape makes nothing a list, but its\n * siblings' marks still apply.\n */\nfunction mergeAll(shapes: (FieldShape | undefined)[]): FieldShape | undefined {\n if (shapes.length === 0) return undefined;\n return shapes.reduce<FieldShape | undefined>(\n (merged, shape, i) => (i === 0 ? (shape ?? {}) : merge(merged ?? {}, shape ?? {})),\n undefined\n );\n}\n\nfunction merge(a: FieldShape, b: FieldShape): FieldShape {\n const out: FieldShape = {};\n if (a.sensitive || b.sensitive) out.sensitive = true;\n if (a.optional || b.optional) out.optional = true;\n if (a.list && b.list) out.list = true;\n if (a.item || b.item) out.item = merge(a.item ?? {}, b.item ?? {});\n if (a.properties || b.properties) {\n const properties: Record<string, FieldShape> = {};\n const keys = new Set([...Object.keys(a.properties ?? {}), ...Object.keys(b.properties ?? {})]);\n for (const key of keys) {\n const left = a.properties?.[key];\n const right = b.properties?.[key];\n // Present in one branch only: absent whenever the other is chosen.\n properties[key] = left && right ? merge(left, right) : { ...(left ?? right), optional: true };\n }\n out.properties = properties;\n }\n return out;\n}\n\n// ─── Intersections ──────────────────────────────────────────────────────\n\n/**\n * One shape for the parts of an intersection, which all apply: a field is a\n * list or sensitive if any part says so, and optional only if every part\n * that declares it lets it be absent.\n */\nfunction intersectAll(shapes: (FieldShape | undefined)[]): FieldShape | undefined {\n const present = shapes.filter((shape): shape is FieldShape => shape !== undefined);\n if (present.length === 0) return undefined;\n return present.reduce(intersect);\n}\n\nfunction intersect(a: FieldShape, b: FieldShape): FieldShape {\n const out: FieldShape = {};\n if (a.sensitive || b.sensitive) out.sensitive = true;\n if (a.optional && b.optional) out.optional = true;\n if (a.list || b.list) out.list = true;\n if (a.item || b.item) out.item = intersect(a.item ?? {}, b.item ?? {});\n if (a.properties || b.properties) {\n const properties: Record<string, FieldShape> = {};\n const keys = new Set([...Object.keys(a.properties ?? {}), ...Object.keys(b.properties ?? {})]);\n for (const key of keys) {\n const left = a.properties?.[key];\n const right = b.properties?.[key];\n properties[key] = left && right ? intersect(left, right) : (left ?? right ?? {});\n }\n out.properties = properties;\n }\n return out;\n}\n\n// ─── List normalization ──────────────────────────────────────────────────\n\n/**\n * Give every field the schema declares as a list the same shape whatever its\n * count. `parseFormData` reads a repeated name as an array, a single value as\n * a scalar, and an absent name not at all; here a scalar becomes `[value]`,\n * and an absent or blank required list becomes `[]` (blanks are dropped from\n * a list, as `parseFormData` drops them from a repeated name). An optional\n * list that was not submitted (or was one blank) is absent, so `.optional()` still means\n * \"not sent\". Lists inside lists and objects are normalized too. An object\n * where a list is declared (an indexed list with a gap) is left for the\n * schema to reject.\n *\n * Returns a copy; the input is not written to.\n */\nexport function normalizeListFields(\n values: Record<string, unknown>,\n shape: FieldShape | undefined\n): Record<string, unknown> {\n if (!shape) return values;\n return normalize(values, shape) as Record<string, unknown>;\n}\n\nfunction normalize(value: unknown, shape: FieldShape): unknown {\n if (shape.list && shape.item) {\n if (value === undefined || value === '') return shape.optional ? undefined : [];\n if (isPlainObject(value)) return value;\n const list = Array.isArray(value) ? value : [value];\n const item = shape.item;\n return list.map((v) => normalize(v, item));\n }\n if (shape.properties && isPlainObject(value)) {\n const out: Record<string, unknown> = { ...value };\n for (const [key, child] of Object.entries(shape.properties)) {\n // Only own keys: `out.constructor` would read Object.prototype's.\n const current = Object.hasOwn(out, key) ? out[key] : undefined;\n if (key === '__proto__') continue;\n const normalized = normalize(current, child);\n if (normalized === undefined) delete out[key];\n else out[key] = normalized;\n }\n return out;\n }\n return value;\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────\n\n/** Apply a node's own marks to the shape read from what it wraps. */\nfunction withMarks(\n optional: boolean,\n sensitive: boolean\n): (shape: FieldShape | undefined) => FieldShape | undefined {\n return (shape) => {\n if (!optional && !sensitive) return shape;\n return {\n ...shape,\n ...(optional ? { optional: true } : {}),\n ...(sensitive ? { sensitive: true } : {}),\n };\n };\n}\n\nfunction asList(value: unknown): unknown[] {\n return Array.isArray(value) ? value : [];\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return isRecord(value) && !Array.isArray(value) && !(value instanceof Blob);\n}\n","/**\n * createActionClient — typed middleware and schema validation for server actions.\n *\n * Inspired by next-safe-action. Provides a builder API:\n * createActionClient({ middleware }) → .schema(z.object(...)) → .action(fn)\n *\n * The resulting action function satisfies both:\n * 1. Direct call: action(input) → Promise<ActionResult>\n * 2. React useActionState: (prevState, formData) => Promise<ActionResult>\n *\n * Types live in `action-types.ts`, schema handling in `action-schema.ts`, and\n * the schema's declared shape (list fields, sensitive fields) in\n * `schema-introspection.ts`.\n *\n * See design/08-forms-and-actions.md §\"Middleware and Server Actions\"\n */\n\nimport { parseFormData } from './form-data.ts';\nimport { formatSize } from '../utils/format.ts';\nimport { isDebug, isDevMode } from './debug.ts';\nimport { isDenySignal, isRedirectSignal } from './signal-identity.ts';\nimport {\n stripSensitiveFields,\n resolveSensitivePredicate,\n getGlobalSensitiveFieldsConfig,\n type SensitiveFieldsOption,\n} from './sensitive-fields.ts';\nimport {\n validateWithSchema,\n type ActionSchema,\n type SchemaInput,\n type SchemaOutput,\n} from './action-schema.ts';\nimport { introspectSchema, normalizeListFields, type FieldShape } from './schema-introspection.ts';\nimport type {\n ActionBuilder,\n ActionContext,\n ActionFn,\n ActionMiddleware,\n ActionResult,\n ActionServerError,\n ValidationErrors,\n} from './action-types.ts';\n\n// ─── ActionError ─────────────────────────────────────────────────────────\n\n/**\n * Typed error class for server actions. Carries a string code and optional data.\n * When thrown from middleware or the action body, the action short-circuits and\n * the client receives `result.serverError`.\n *\n * In production, unexpected errors (non-ActionError) return `{ code: 'INTERNAL_ERROR' }`\n * with no message. In dev, `data.message` is included.\n */\nexport class ActionError<TCode extends string = string> extends Error {\n readonly code: TCode;\n readonly data: Record<string, unknown> | undefined;\n\n constructor(code: TCode, data?: Record<string, unknown>) {\n super(`ActionError: ${code}`);\n this.name = 'ActionError';\n this.code = code;\n this.data = data;\n }\n}\n\n// ─── Config ──────────────────────────────────────────────────────────────\n\ninterface ActionClientConfig<TCtx> {\n middleware?: ActionMiddleware<TCtx> | ActionMiddleware<Record<string, unknown>>[];\n /** Max file size in bytes. Files exceeding this are rejected with validation errors. */\n fileSizeLimit?: number;\n /**\n * Override the sensitive-field name deny-list for this action client.\n * See `SensitiveFieldsOption` in `./sensitive-fields.ts`. Per-client config\n * takes precedence over the global `forms.stripSensitiveFields` option in\n * `timber.config.ts`. Fields the schema marks `.meta({ sensitive: true })`\n * are stripped whatever this says. See design/08-forms-and-actions.md.\n */\n stripSensitiveFields?: SensitiveFieldsOption;\n}\n\n// ─── Implementation ──────────────────────────────────────────────────────\n\n/**\n * Run middleware array or single function. Returns merged context.\n */\nasync function runActionMiddleware<TCtx>(\n middleware: ActionMiddleware<TCtx> | ActionMiddleware<Record<string, unknown>>[] | undefined\n): Promise<TCtx> {\n if (!middleware) {\n return {} as TCtx;\n }\n\n if (Array.isArray(middleware)) {\n let merged = {} as Record<string, unknown>;\n for (const mw of middleware) {\n const result = await mw();\n merged = { ...merged, ...result };\n }\n return merged as TCtx;\n }\n\n return await middleware();\n}\n\n/**\n * Wrap unexpected errors into a safe server error result.\n * ActionError → typed result. Other errors → INTERNAL_ERROR (no leak).\n *\n * `createActionClient` actions only. A raw `'use server'` function that\n * throws is rejected on the client instead (action-handler.ts).\n */\nexport function handleActionError(error: unknown): { serverError: ActionServerError } {\n if (error instanceof ActionError) {\n return {\n serverError: {\n code: error.code,\n ...(error.data ? { data: error.data } : {}),\n },\n };\n }\n\n // In dev, include the message for debugging.\n // Uses isDevMode() — NOT isDebug() — because this data is sent to the\n // browser. TIMBER_DEBUG must never cause error messages to leak to clients.\n // See design/13-security.md principle 4: \"Errors don't leak.\"\n const devMode = isDevMode();\n return {\n serverError: {\n code: 'INTERNAL_ERROR',\n ...(devMode && error instanceof Error ? { data: { message: error.message } } : {}),\n },\n };\n}\n\n/**\n * Create a typed action client with middleware and schema validation.\n *\n * @example\n * ```ts\n * const action = createActionClient({\n * middleware: async () => {\n * const user = await getUser()\n * if (!user) throw new ActionError('UNAUTHORIZED')\n * return { user }\n * },\n * })\n *\n * export const createTodo = action\n * .schema(z.object({ title: z.string().min(1) }))\n * .action(async ({ input, ctx }) => {\n * await db.todos.create({ ...input, userId: ctx.user.id })\n * })\n * ```\n */\nexport function createActionClient<TCtx = Record<string, never>>(\n config: ActionClientConfig<TCtx> = {}\n): ActionBuilder<TCtx> {\n function buildAction<TInput, TOutput, TData>(\n schema: ActionSchema | undefined,\n fn: (ctx: ActionContext<TCtx, TOutput>) => Promise<TData>\n ): ActionFn<TData, TInput> {\n // The schema's declared shape, read once per action on its first call:\n // which fields are lists, and which are marked sensitive.\n let shape: FieldShape | undefined;\n let introspected = false;\n const getShape = (): FieldShape | undefined => {\n if (!introspected) {\n shape = introspectSchema(schema);\n introspected = true;\n }\n return shape;\n };\n\n async function actionHandler(...args: unknown[]): Promise<ActionResult<TData>> {\n // The input is the last argument in every call shape: `(input)`,\n // `(formData)`, `(prevState, payload)` from useActionState's\n // dispatch, `(initialState, formData)` on the no-JS path (Fizz binds\n // the initial state into the form, and decodeAction binds the\n // FormData after it), and `(...bound, prevState, payload)` for an\n // action with bound arguments. Nothing before it is input:\n // `prevState` comes from the client, so it is never read.\n const last = args.at(-1);\n // A form's list fields take the shape the schema declares whatever\n // their count, both for validation and for `submittedValues`.\n const form =\n last instanceof FormData ? normalizeListFields(parseFormData(last), getShape()) : undefined;\n\n // Precedence: per-client (config.stripSensitiveFields) > global\n // (forms.stripSensitiveFields from timber.config.ts) > built-in deny-list.\n const sensitivePredicate = resolveSensitivePredicate(\n config.stripSensitiveFields,\n getGlobalSensitiveFieldsConfig()\n );\n\n // A \"safe-to-echo\" copy of the input. Files are stripped (can't\n // serialize, shouldn't echo back) and sensitive fields (passwords,\n // tokens, CVV, schema-marked fields) are removed before they would\n // land in the RSC payload → client form `defaultValue` → DOM.\n const echo = (value: unknown): Record<string, unknown> | undefined => {\n const withoutFiles = stripFiles(value);\n if (withoutFiles === undefined) return undefined;\n return stripSensitiveFields(withoutFiles, sensitivePredicate, getShape());\n };\n\n try {\n // Run middleware\n const ctx = await runActionMiddleware(config.middleware);\n\n // Without a schema the action receives the FormData itself. Checks\n // and echoes read the parsed form: a FormData has no own entries.\n const rawInput: unknown = schema && form ? form : last;\n const submitted: unknown = form ?? rawInput;\n\n // Validate file sizes before schema validation.\n if (config.fileSizeLimit !== undefined && submitted && typeof submitted === 'object') {\n const fileSizeErrors = validateFileSizes(\n submitted as Record<string, unknown>,\n config.fileSizeLimit\n );\n if (fileSizeErrors) {\n return { validationErrors: fileSizeErrors, submittedValues: echo(submitted) };\n }\n }\n\n let input: unknown = rawInput;\n if (schema) {\n const validation = validateWithSchema(schema, rawInput);\n if (!validation.ok) {\n logValidationFailure(validation.validationErrors);\n return {\n validationErrors: validation.validationErrors,\n submittedValues: echo(submitted),\n };\n }\n input = validation.value;\n }\n\n // Execute the action body. `input` is the schema's output, or the\n // raw input when there is no schema (TOutput is `undefined` then).\n const data = await fn({ ctx, input: input as TOutput });\n return { data };\n } catch (error) {\n // Re-throw redirect/deny signals — these are control flow, not errors.\n // They must propagate to executeAction() which converts them to proper\n // HTTP responses (302 redirect, 4xx deny). Catching them here would\n // wrap them as INTERNAL_ERROR and break redirect()/redirectExternal()/deny().\n if (isRedirectSignal(error) || isDenySignal(error)) {\n throw error;\n }\n // A `serverError` echoes the form like a validation failure does.\n // React resets the form after the action, and a form whose defaults\n // fell back to page data would lose what the user typed (TIM-1573).\n const result = handleActionError(error);\n const submittedValues = form && echo(form);\n return submittedValues ? { ...result, submittedValues } : result;\n }\n }\n\n // One implementation serves every overload of `ActionFn`, which\n // TypeScript cannot check a single function against.\n return actionHandler as ActionFn<TData, TInput>;\n }\n\n return {\n schema<S extends ActionSchema>(schema: S) {\n return {\n action<TData>(\n fn: (ctx: ActionContext<TCtx, SchemaOutput<S>>) => Promise<TData>\n ): ActionFn<TData, SchemaInput<S>> {\n return buildAction(schema, fn);\n },\n };\n },\n action<TData>(\n fn: (ctx: ActionContext<TCtx, undefined>) => Promise<TData>\n ): ActionFn<TData, undefined> {\n return buildAction(undefined, fn);\n },\n };\n}\n\n// ─── Helpers ────────────────────────────────────────────────────────────\n\n/**\n * Log validation failures in dev mode so developers can see what went wrong.\n * In production, validation errors are only returned to the client.\n */\nfunction logValidationFailure(errors: ValidationErrors): void {\n const isDev = isDebug();\n if (!isDev) return;\n\n const fields = Object.entries(errors)\n .map(([field, messages]) => ` ${field}: ${(messages ?? []).join(', ')}`)\n .join('\\n');\n console.warn(`[timber] action schema validation failed:\\n${fields}`);\n}\n\n/**\n * Validate that all File objects in the input are within the size limit.\n * Returns validation errors keyed by field name, or null if all files are ok.\n * Keys are dot paths (`rows.0.file`), the form a field name and a Standard\n * Schema error use, so `errors.field()` finds a file in a list.\n */\nfunction validateFileSizes(input: Record<string, unknown>, limit: number): ValidationErrors | null {\n const limitKb = Math.round(limit / 1024);\n const limitLabel =\n limit >= 1024 * 1024 ? `${Math.round(limit / (1024 * 1024))}MB` : `${limitKb}KB`;\n\n const errors: Record<string, string[]> = {};\n\n function walk(obj: Record<string, unknown>, prefix: string): void {\n for (const [key, value] of Object.entries(obj)) {\n const path = prefix ? `${prefix}.${key}` : key;\n if (value instanceof File && value.size > limit) {\n errors[path] = [\n `File \"${value.name}\" (${formatSize(value.size)}) exceeds the ${limitLabel} limit`,\n ];\n } else if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n const item = value[i];\n const itemPath = `${path}.${i}`;\n if (item instanceof File && item.size > limit) {\n (errors[itemPath] ??= []).push(\n `File \"${item.name}\" (${formatSize(item.size)}) exceeds the ${limitLabel} limit`\n );\n } else if (typeof item === 'object' && item !== null && !(item instanceof File)) {\n walk(item as Record<string, unknown>, itemPath);\n }\n }\n } else if (typeof value === 'object' && value !== null && !(value instanceof File)) {\n walk(value as Record<string, unknown>, path);\n }\n }\n }\n\n walk(input, '');\n return Object.keys(errors).length > 0 ? errors : null;\n}\n\n/**\n * Strip File objects from a value, returning a copy safe for serialization.\n * File objects can't be serialized and shouldn't be echoed back.\n *\n * Mirrors `parseFormData`'s output: objects and arrays at any depth, arrays\n * of arrays included. A File in an array becomes `undefined` rather than\n * being removed, so `rows.2` still names the third element (TIM-1573).\n */\nfunction stripFiles(value: unknown): Record<string, unknown> | undefined {\n if (value === null || typeof value !== 'object' || value instanceof File) return undefined;\n return stripFilesFrom(value) as Record<string, unknown>;\n}\n\nfunction stripFilesFrom(value: unknown): unknown {\n if (value instanceof File) return undefined;\n if (Array.isArray(value)) return value.map(stripFilesFrom);\n if (typeof value !== 'object' || value === null) return value;\n const result: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n if (!(v instanceof File)) result[k] = stripFilesFrom(v);\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAWA,IAAa,eAAe;CAC1B,MAAM;CACN,SAAS;AACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACgDA,IAAM,6BAAgD;CACpD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;AASA,IAAM,wBAA2C;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;AAAM;;;;;;;AAQ3F,IAAM,yBAA4C,CAAC,OAAO;;;;;;;AAQ1D,SAASA,YAAU,MAAsB;CACvC,OAAO,KAAK,QAAQ,SAAS,EAAE,CAAC,CAAC,YAAY;AAC/C;;;;;;;AAQA,SAAS,MAAM,MAAwB;CACrC,OAAO,KACJ,MAAM,gCAAgC,CAAC,CACvC,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,EAAE,YAAY,CAAC;AAC/B;;AAGA,SAAS,eAAe,MAAuB;CAC7C,OAAO,MAAM,IAAI,CAAC,CAAC,MAAM,SACvB,sBAAsB,MAAM,MAAM,KAAK,WAAW,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAC1E;AACF;;;;;AAMA,SAAS,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;CAC/C,IAAI,iBAAiB,MAAM,OAAO,KAAA;CAClC,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,IAAI,cAAc;CACzD,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,SAAkC,CAAC;CACzC,KAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,KAAK,GACvC,IAAI,EAAE,aAAa,OAAO,OAAO,KAAK,eAAe,CAAC;CAExD,OAAO;AACT"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The URL's own access gates in an intercepted tree (TIM-1607).
|
|
3
|
+
*
|
|
4
|
+
* An intercepted navigation renders a different route than its URL names —
|
|
5
|
+
* the source route with the target in a slot, or the owner's chain through
|
|
6
|
+
* its intercepting child. The response is still for the URL, so the URL's
|
|
7
|
+
* whole `access.ts` chain gates it, in the one render, as one group of gates
|
|
8
|
+
* at the top of the tree:
|
|
9
|
+
*
|
|
10
|
+
* ```
|
|
11
|
+
* [Gate(/) → Gate(secret) → Gate(secret/[id])] → root layout → … → Gate(feed) → …
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* The whole chain, shared segments included, for two reasons:
|
|
15
|
+
*
|
|
16
|
+
* - **Params.** Each gate must read the URL's params. A shared segment's
|
|
17
|
+
* in-tree gate reads the rendered route's, and in the modal shape those come
|
|
18
|
+
* from re-matching `interceptingPrefix`, a pattern — a shared `[org]` reads
|
|
19
|
+
* the literal `'[org]'`, not `'acme'`.
|
|
20
|
+
* - **Coverage.** Nothing renders outside the top of the tree. Placed any
|
|
21
|
+
* lower, the gates miss whatever an ancestor layout renders beside them —
|
|
22
|
+
* a modal slot is a prop of its owner's layout, and the rendered chain can
|
|
23
|
+
* continue past the owner through a route group the target shares
|
|
24
|
+
* (`app/@modal/(.)secret/[id]` over `app/(main)/page.tsx`).
|
|
25
|
+
*
|
|
26
|
+
* The shared segments' in-tree gates are dropped (`sharedCount`), so each
|
|
27
|
+
* access.ts still runs once, outer → inner: the URL's chain, then the gates
|
|
28
|
+
* only the rendered chain has.
|
|
29
|
+
*
|
|
30
|
+
* Each gate is marked `outsideTree`: the URL's deny pages, and the layouts
|
|
31
|
+
* they render in, are not this tree's, so a deny leaves the SPA for the URL's
|
|
32
|
+
* document instead of being placed here. See `DenySignal._leaveSpa`,
|
|
33
|
+
* design/07-routing.md §"Intercepting Routes".
|
|
34
|
+
*/
|
|
35
|
+
import type React from 'react';
|
|
36
|
+
import type { RouteMatch } from './pipeline.ts';
|
|
37
|
+
export interface InterceptionGates {
|
|
38
|
+
/**
|
|
39
|
+
* How many segments, from the root, the rendered chain shares with the
|
|
40
|
+
* URL's route. Their access.ts runs in the group; the builder gives them no
|
|
41
|
+
* gate of their own.
|
|
42
|
+
*/
|
|
43
|
+
sharedCount: number;
|
|
44
|
+
/** Wrap the whole tree in the URL's gates, outermost first. */
|
|
45
|
+
wrap(element: React.ReactElement, h: (...args: unknown[]) => React.ReactElement): React.ReactElement;
|
|
46
|
+
}
|
|
47
|
+
/** The gates an intercepted match needs, or null when it is not intercepted. */
|
|
48
|
+
export declare function loadInterceptionGates(match: RouteMatch): Promise<InterceptionGates | null>;
|
|
49
|
+
//# sourceMappingURL=interception-gates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interception-gates.d.ts","sourceRoot":"","sources":["../../src/server/interception-gates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAIhD,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,IAAI,CACF,OAAO,EAAE,KAAK,CAAC,YAAY,EAC3B,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,KAAK,CAAC,YAAY,GAC5C,KAAK,CAAC,YAAY,CAAC;CACvB;AAED,gFAAgF;AAChF,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAqChG"}
|