@softistx/alxia-react-router 0.0.0-stage → 0.83.1
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/LICENSE +21 -0
- package/README.md +2085 -2
- package/dist/api-keys/api-keys.d.ts +93 -0
- package/dist/api-keys/api-keys.d.ts.map +1 -0
- package/dist/api-keys/index.d.ts +9 -0
- package/dist/api-keys/index.d.ts.map +1 -0
- package/dist/api-keys/index.js +66 -0
- package/dist/api-keys/index.js.map +10 -0
- package/dist/assets.d.ts +14 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/chunks/index-0786n4qe.js +25 -0
- package/dist/chunks/index-0786n4qe.js.map +10 -0
- package/dist/chunks/index-1nw5yeek.js +169 -0
- package/dist/chunks/index-1nw5yeek.js.map +11 -0
- package/dist/chunks/index-59vhfj6n.js +10 -0
- package/dist/chunks/index-59vhfj6n.js.map +10 -0
- package/dist/chunks/index-5gqcpyyg.js +34 -0
- package/dist/chunks/index-5gqcpyyg.js.map +10 -0
- package/dist/chunks/index-6jf7zpxz.js +119 -0
- package/dist/chunks/index-6jf7zpxz.js.map +11 -0
- package/dist/chunks/index-8as4j8m3.js +340 -0
- package/dist/chunks/index-8as4j8m3.js.map +16 -0
- package/dist/chunks/index-9xv2a8et.js +108 -0
- package/dist/chunks/index-9xv2a8et.js.map +11 -0
- package/dist/chunks/index-ajtvyq35.js +16 -0
- package/dist/chunks/index-ajtvyq35.js.map +10 -0
- package/dist/chunks/index-c55hxgr5.js +124 -0
- package/dist/chunks/index-c55hxgr5.js.map +14 -0
- package/dist/chunks/index-d42p3mdp.js +19 -0
- package/dist/chunks/index-d42p3mdp.js.map +10 -0
- package/dist/chunks/index-gac44rs5.js +42 -0
- package/dist/chunks/index-gac44rs5.js.map +11 -0
- package/dist/chunks/index-j4ktpcke.js +62 -0
- package/dist/chunks/index-j4ktpcke.js.map +10 -0
- package/dist/chunks/index-mscfme4r.js +12 -0
- package/dist/chunks/index-mscfme4r.js.map +10 -0
- package/dist/chunks/index-pghmb2dm.js +30 -0
- package/dist/chunks/index-pghmb2dm.js.map +10 -0
- package/dist/chunks/index-rfr02vg4.js +40 -0
- package/dist/chunks/index-rfr02vg4.js.map +10 -0
- package/dist/chunks/index-sfhshxqz.js +31 -0
- package/dist/chunks/index-sfhshxqz.js.map +10 -0
- package/dist/chunks/index-skwypsjz.js +357 -0
- package/dist/chunks/index-skwypsjz.js.map +12 -0
- package/dist/chunks/index-sxh06ged.js +118 -0
- package/dist/chunks/index-sxh06ged.js.map +11 -0
- package/dist/chunks/index-t2ph23wk.js +96 -0
- package/dist/chunks/index-t2ph23wk.js.map +13 -0
- package/dist/chunks/index-thyabr5n.js +19 -0
- package/dist/chunks/index-thyabr5n.js.map +10 -0
- package/dist/chunks/index-tx36swjx.js +134 -0
- package/dist/chunks/index-tx36swjx.js.map +11 -0
- package/dist/chunks/index-v2z5k640.js +54 -0
- package/dist/chunks/index-v2z5k640.js.map +11 -0
- package/dist/chunks/index-vr82typq.js +23 -0
- package/dist/chunks/index-vr82typq.js.map +11 -0
- package/dist/chunks/index-whj6h5eg.js +9 -0
- package/dist/chunks/index-whj6h5eg.js.map +10 -0
- package/dist/chunks/index-wyypkfdv.js +130 -0
- package/dist/chunks/index-wyypkfdv.js.map +13 -0
- package/dist/chunks/index-xd5aqy3g.js +90 -0
- package/dist/chunks/index-xd5aqy3g.js.map +10 -0
- package/dist/chunks/index-zdbqzcjp.js +97 -0
- package/dist/chunks/index-zdbqzcjp.js.map +12 -0
- package/dist/chunks/index-zyg8amjc.js +23 -0
- package/dist/chunks/index-zyg8amjc.js.map +10 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +215 -0
- package/dist/cli/index.js.map +13 -0
- package/dist/cli/main.d.ts +13 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/reveal.d.ts +18 -0
- package/dist/cli/reveal.d.ts.map +1 -0
- package/dist/cli/template.d.ts +8 -0
- package/dist/cli/template.d.ts.map +1 -0
- package/dist/context.d.ts +104 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/document/index.d.ts +11 -0
- package/dist/document/index.d.ts.map +1 -0
- package/dist/document/index.js +19 -0
- package/dist/document/index.js.map +9 -0
- package/dist/document/inline-script.d.ts +27 -0
- package/dist/document/inline-script.d.ts.map +1 -0
- package/dist/document/language-store.d.ts +8 -0
- package/dist/document/language-store.d.ts.map +1 -0
- package/dist/document/nonce.d.ts +34 -0
- package/dist/document/nonce.d.ts.map +1 -0
- package/dist/document/page-language.d.ts +39 -0
- package/dist/document/page-language.d.ts.map +1 -0
- package/dist/document/text-direction.d.ts +10 -0
- package/dist/document/text-direction.d.ts.map +1 -0
- package/dist/entry/abort.d.ts +21 -0
- package/dist/entry/abort.d.ts.map +1 -0
- package/dist/entry/create-entry.d.ts +41 -0
- package/dist/entry/create-entry.d.ts.map +1 -0
- package/dist/entry/index.d.ts +8 -0
- package/dist/entry/index.d.ts.map +1 -0
- package/dist/entry/index.js +154 -0
- package/dist/entry/index.js.map +13 -0
- package/dist/entry/root-data.d.ts +27 -0
- package/dist/entry/root-data.d.ts.map +1 -0
- package/dist/entry/whole-page.d.ts +10 -0
- package/dist/entry/whole-page.d.ts.map +1 -0
- package/dist/errors/api-error.d.ts +117 -0
- package/dist/errors/api-error.d.ts.map +1 -0
- package/dist/errors/api-errors.d.ts +122 -0
- package/dist/errors/api-errors.d.ts.map +1 -0
- package/dist/errors/call-failure.d.ts +45 -0
- package/dist/errors/call-failure.d.ts.map +1 -0
- package/dist/errors/catalogue-check.d.ts +24 -0
- package/dist/errors/catalogue-check.d.ts.map +1 -0
- package/dist/errors/catalogue-read.d.ts +33 -0
- package/dist/errors/catalogue-read.d.ts.map +1 -0
- package/dist/errors/catalogue.d.ts +59 -0
- package/dist/errors/catalogue.d.ts.map +1 -0
- package/dist/errors/code-resolver.d.ts +44 -0
- package/dist/errors/code-resolver.d.ts.map +1 -0
- package/dist/errors/cross-site.d.ts +8 -0
- package/dist/errors/cross-site.d.ts.map +1 -0
- package/dist/errors/describe-refusal.d.ts +6 -0
- package/dist/errors/describe-refusal.d.ts.map +1 -0
- package/dist/errors/describe.d.ts +3 -0
- package/dist/errors/describe.d.ts.map +1 -0
- package/dist/errors/fetcher-result.d.ts +33 -0
- package/dist/errors/fetcher-result.d.ts.map +1 -0
- package/dist/errors/field-placement.d.ts +12 -0
- package/dist/errors/field-placement.d.ts.map +1 -0
- package/dist/errors/form-errors.d.ts +8 -0
- package/dist/errors/form-errors.d.ts.map +1 -0
- package/dist/errors/form-refusal.d.ts +25 -0
- package/dist/errors/form-refusal.d.ts.map +1 -0
- package/dist/errors/index.d.ts +21 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +588 -0
- package/dist/errors/index.js.map +26 -0
- package/dist/errors/json-actions.d.ts +38 -0
- package/dist/errors/json-actions.d.ts.map +1 -0
- package/dist/errors/log.d.ts +8 -0
- package/dist/errors/log.d.ts.map +1 -0
- package/dist/errors/message-values.d.ts +11 -0
- package/dist/errors/message-values.d.ts.map +1 -0
- package/dist/errors/messages.d.ts +63 -0
- package/dist/errors/messages.d.ts.map +1 -0
- package/dist/errors/page-path.d.ts +9 -0
- package/dist/errors/page-path.d.ts.map +1 -0
- package/dist/errors/problem-error.d.ts +50 -0
- package/dist/errors/problem-error.d.ts.map +1 -0
- package/dist/errors/provider.d.ts +20 -0
- package/dist/errors/provider.d.ts.map +1 -0
- package/dist/errors/request-id.d.ts +5 -0
- package/dist/errors/request-id.d.ts.map +1 -0
- package/dist/errors/route-error.d.ts +33 -0
- package/dist/errors/route-error.d.ts.map +1 -0
- package/dist/errors/route-refusal.d.ts +20 -0
- package/dist/errors/route-refusal.d.ts.map +1 -0
- package/dist/errors/same-site.d.ts +49 -0
- package/dist/errors/same-site.d.ts.map +1 -0
- package/dist/errors/section-action.d.ts +46 -0
- package/dist/errors/section-action.d.ts.map +1 -0
- package/dist/errors/standard-schema.d.ts +34 -0
- package/dist/errors/standard-schema.d.ts.map +1 -0
- package/dist/errors/submit-form.d.ts +16 -0
- package/dist/errors/submit-form.d.ts.map +1 -0
- package/dist/errors/upstream-headers.d.ts +18 -0
- package/dist/errors/upstream-headers.d.ts.map +1 -0
- package/dist/errors/use-json-fetcher.d.ts +18 -0
- package/dist/errors/use-json-fetcher.d.ts.map +1 -0
- package/dist/fetcher/auth-refusal.d.ts +29 -0
- package/dist/fetcher/auth-refusal.d.ts.map +1 -0
- package/dist/fetcher/index.d.ts +20 -0
- package/dist/fetcher/index.d.ts.map +1 -0
- package/dist/fetcher/index.js +392 -0
- package/dist/fetcher/index.js.map +21 -0
- package/dist/fetcher/section-form.d.ts +24 -0
- package/dist/fetcher/section-form.d.ts.map +1 -0
- package/dist/fetcher/section-reload.d.ts +17 -0
- package/dist/fetcher/section-reload.d.ts.map +1 -0
- package/dist/fetcher/section-save.d.ts +29 -0
- package/dist/fetcher/section-save.d.ts.map +1 -0
- package/dist/fetcher/use-debounced-fetcher.d.ts +57 -0
- package/dist/fetcher/use-debounced-fetcher.d.ts.map +1 -0
- package/dist/fetcher/use-fetcher-answer.d.ts +16 -0
- package/dist/fetcher/use-fetcher-answer.d.ts.map +1 -0
- package/dist/fetcher/use-fetcher-done.d.ts +15 -0
- package/dist/fetcher/use-fetcher-done.d.ts.map +1 -0
- package/dist/fetcher/use-fetcher-promise.d.ts +48 -0
- package/dist/fetcher/use-fetcher-promise.d.ts.map +1 -0
- package/dist/fetcher/use-form-refusal.d.ts +20 -0
- package/dist/fetcher/use-form-refusal.d.ts.map +1 -0
- package/dist/fetcher/use-revalidate-on-focus.d.ts +20 -0
- package/dist/fetcher/use-revalidate-on-focus.d.ts.map +1 -0
- package/dist/fetcher/use-row-save.d.ts +32 -0
- package/dist/fetcher/use-row-save.d.ts.map +1 -0
- package/dist/fetcher/use-section-save.d.ts +46 -0
- package/dist/fetcher/use-section-save.d.ts.map +1 -0
- package/dist/fetcher/use-visible-interval.d.ts +24 -0
- package/dist/fetcher/use-visible-interval.d.ts.map +1 -0
- package/dist/fetcher/use-visible-revalidation.d.ts +10 -0
- package/dist/fetcher/use-visible-revalidation.d.ts.map +1 -0
- package/dist/health.d.ts +21 -0
- package/dist/health.d.ts.map +1 -0
- package/dist/help/check/check.d.ts +35 -0
- package/dist/help/check/check.d.ts.map +1 -0
- package/dist/help/check/index.d.ts +8 -0
- package/dist/help/check/index.d.ts.map +1 -0
- package/dist/help/check/index.js +17 -0
- package/dist/help/check/index.js.map +9 -0
- package/dist/help/check/routes.d.ts +22 -0
- package/dist/help/check/routes.d.ts.map +1 -0
- package/dist/help/guide.d.ts +33 -0
- package/dist/help/guide.d.ts.map +1 -0
- package/dist/help/index.d.ts +16 -0
- package/dist/help/index.d.ts.map +1 -0
- package/dist/help/index.js +192 -0
- package/dist/help/index.js.map +14 -0
- package/dist/help/load.d.ts +39 -0
- package/dist/help/load.d.ts.map +1 -0
- package/dist/help/panel.d.ts +69 -0
- package/dist/help/panel.d.ts.map +1 -0
- package/dist/help/parse-flow.d.ts +27 -0
- package/dist/help/parse-flow.d.ts.map +1 -0
- package/dist/help/react.d.ts +12 -0
- package/dist/help/react.d.ts.map +1 -0
- package/dist/help/resolve.d.ts +24 -0
- package/dist/help/resolve.d.ts.map +1 -0
- package/dist/help/types.d.ts +50 -0
- package/dist/help/types.d.ts.map +1 -0
- package/dist/help/yaml.d.ts +18 -0
- package/dist/help/yaml.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +197 -0
- package/dist/index.js.map +14 -0
- package/dist/link/index.d.ts +7 -0
- package/dist/link/index.d.ts.map +1 -0
- package/dist/link/index.js +16 -0
- package/dist/link/index.js.map +10 -0
- package/dist/link/router-link.d.ts +27 -0
- package/dist/link/router-link.d.ts.map +1 -0
- package/dist/lists/connection-page.d.ts +50 -0
- package/dist/lists/connection-page.d.ts.map +1 -0
- package/dist/lists/index.d.ts +13 -0
- package/dist/lists/index.d.ts.map +1 -0
- package/dist/lists/index.js +205 -0
- package/dist/lists/index.js.map +15 -0
- package/dist/lists/newest-first.d.ts +5 -0
- package/dist/lists/newest-first.d.ts.map +1 -0
- package/dist/lists/nodes-of.d.ts +21 -0
- package/dist/lists/nodes-of.d.ts.map +1 -0
- package/dist/lists/or-failed.d.ts +19 -0
- package/dist/lists/or-failed.d.ts.map +1 -0
- package/dist/lists/use-paged-rows.d.ts +40 -0
- package/dist/lists/use-paged-rows.d.ts.map +1 -0
- package/dist/lists/use-same-route-loading.d.ts +8 -0
- package/dist/lists/use-same-route-loading.d.ts.map +1 -0
- package/dist/lists/use-search-change.d.ts +20 -0
- package/dist/lists/use-search-change.d.ts.map +1 -0
- package/dist/mcp/index.d.ts +8 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +105 -0
- package/dist/mcp/index.js.map +11 -0
- package/dist/mcp/mcp-relay.d.ts +58 -0
- package/dist/mcp/mcp-relay.d.ts.map +1 -0
- package/dist/mcp/relay.d.ts +38 -0
- package/dist/mcp/relay.d.ts.map +1 -0
- package/dist/media/client/error.d.ts +29 -0
- package/dist/media/client/error.d.ts.map +1 -0
- package/dist/media/client/index.d.ts +8 -0
- package/dist/media/client/index.d.ts.map +1 -0
- package/dist/media/client/index.js +133 -0
- package/dist/media/client/index.js.map +11 -0
- package/dist/media/client/upload.d.ts +32 -0
- package/dist/media/client/upload.d.ts.map +1 -0
- package/dist/media/forward.d.ts +14 -0
- package/dist/media/forward.d.ts.map +1 -0
- package/dist/media/headers.d.ts +11 -0
- package/dist/media/headers.d.ts.map +1 -0
- package/dist/media/index.d.ts +9 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/index.js +396 -0
- package/dist/media/index.js.map +16 -0
- package/dist/media/options.d.ts +114 -0
- package/dist/media/options.d.ts.map +1 -0
- package/dist/media/path.d.ts +12 -0
- package/dist/media/path.d.ts.map +1 -0
- package/dist/media/read.d.ts +11 -0
- package/dist/media/read.d.ts.map +1 -0
- package/dist/media/refusal.d.ts +11 -0
- package/dist/media/refusal.d.ts.map +1 -0
- package/dist/media/respond.d.ts +8 -0
- package/dist/media/respond.d.ts.map +1 -0
- package/dist/media/write.d.ts +13 -0
- package/dist/media/write.d.ts.map +1 -0
- package/dist/navigation/index.d.ts +9 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/index.js +48 -0
- package/dist/navigation/index.js.map +11 -0
- package/dist/navigation/use-focus-on-navigate.d.ts +16 -0
- package/dist/navigation/use-focus-on-navigate.d.ts.map +1 -0
- package/dist/navigation/use-route-transition.d.ts +19 -0
- package/dist/navigation/use-route-transition.d.ts.map +1 -0
- package/dist/nonce.d.ts +16 -0
- package/dist/nonce.d.ts.map +1 -0
- package/dist/oauth/answer.d.ts +33 -0
- package/dist/oauth/answer.d.ts.map +1 -0
- package/dist/oauth/binding.d.ts +43 -0
- package/dist/oauth/binding.d.ts.map +1 -0
- package/dist/oauth/consent.d.ts +134 -0
- package/dist/oauth/consent.d.ts.map +1 -0
- package/dist/oauth/grants.d.ts +88 -0
- package/dist/oauth/grants.d.ts.map +1 -0
- package/dist/oauth/index.d.ts +16 -0
- package/dist/oauth/index.d.ts.map +1 -0
- package/dist/oauth/index.js +207 -0
- package/dist/oauth/index.js.map +12 -0
- package/dist/oauth/model.d.ts +13 -0
- package/dist/oauth/model.d.ts.map +1 -0
- package/dist/oauth/react/index.d.ts +7 -0
- package/dist/oauth/react/index.d.ts.map +1 -0
- package/dist/oauth/react/index.js +99 -0
- package/dist/oauth/react/index.js.map +10 -0
- package/dist/oauth/react/use-consent.d.ts +52 -0
- package/dist/oauth/react/use-consent.d.ts.map +1 -0
- package/dist/oidc/dpop.d.ts +80 -0
- package/dist/oidc/dpop.d.ts.map +1 -0
- package/dist/oidc/errors.d.ts +16 -0
- package/dist/oidc/errors.d.ts.map +1 -0
- package/dist/oidc/flow.d.ts +59 -0
- package/dist/oidc/flow.d.ts.map +1 -0
- package/dist/oidc/index.d.ts +11 -0
- package/dist/oidc/index.d.ts.map +1 -0
- package/dist/oidc/index.js +742 -0
- package/dist/oidc/index.js.map +15 -0
- package/dist/oidc/oidc.d.ts +132 -0
- package/dist/oidc/oidc.d.ts.map +1 -0
- package/dist/oidc/revoke.d.ts +28 -0
- package/dist/oidc/revoke.d.ts.map +1 -0
- package/dist/oidc/seal.d.ts +20 -0
- package/dist/oidc/seal.d.ts.map +1 -0
- package/dist/pwa/build/build-worker.d.ts +41 -0
- package/dist/pwa/build/build-worker.d.ts.map +1 -0
- package/dist/pwa/build/index.d.ts +9 -0
- package/dist/pwa/build/index.d.ts.map +1 -0
- package/dist/pwa/build/index.js +9 -0
- package/dist/pwa/build/index.js.map +9 -0
- package/dist/pwa/build/precache.d.ts +17 -0
- package/dist/pwa/build/precache.d.ts.map +1 -0
- package/dist/pwa/index.d.ts +16 -0
- package/dist/pwa/index.d.ts.map +1 -0
- package/dist/pwa/index.js +110 -0
- package/dist/pwa/index.js.map +12 -0
- package/dist/pwa/model/caching.d.ts +46 -0
- package/dist/pwa/model/caching.d.ts.map +1 -0
- package/dist/pwa/model/clear-app-caches.d.ts +9 -0
- package/dist/pwa/model/clear-app-caches.d.ts.map +1 -0
- package/dist/pwa/model/font-precache.d.ts +15 -0
- package/dist/pwa/model/font-precache.d.ts.map +1 -0
- package/dist/pwa/model/manifest.d.ts +80 -0
- package/dist/pwa/model/manifest.d.ts.map +1 -0
- package/dist/pwa/model/precache-list.d.ts +40 -0
- package/dist/pwa/model/precache-list.d.ts.map +1 -0
- package/dist/pwa/model/registration.d.ts +39 -0
- package/dist/pwa/model/registration.d.ts.map +1 -0
- package/dist/pwa/model/start-service-worker.d.ts +24 -0
- package/dist/pwa/model/start-service-worker.d.ts.map +1 -0
- package/dist/pwa/model/storable.d.ts +8 -0
- package/dist/pwa/model/storable.d.ts.map +1 -0
- package/dist/pwa/model/theme-color.d.ts +20 -0
- package/dist/pwa/model/theme-color.d.ts.map +1 -0
- package/dist/pwa/model/update-notice.d.ts +38 -0
- package/dist/pwa/model/update-notice.d.ts.map +1 -0
- package/dist/pwa/model/worker-contract.d.ts +61 -0
- package/dist/pwa/model/worker-contract.d.ts.map +1 -0
- package/dist/pwa/react/index.d.ts +9 -0
- package/dist/pwa/react/index.d.ts.map +1 -0
- package/dist/pwa/react/index.js +75 -0
- package/dist/pwa/react/index.js.map +13 -0
- package/dist/pwa/react/use-online.d.ts +6 -0
- package/dist/pwa/react/use-online.d.ts.map +1 -0
- package/dist/pwa/react/use-service-worker.d.ts +33 -0
- package/dist/pwa/react/use-service-worker.d.ts.map +1 -0
- package/dist/pwa/react/use-update-notice.d.ts +14 -0
- package/dist/pwa/react/use-update-notice.d.ts.map +1 -0
- package/dist/pwa/server/index.d.ts +7 -0
- package/dist/pwa/server/index.d.ts.map +1 -0
- package/dist/pwa/server/index.js +18 -0
- package/dist/pwa/server/index.js.map +10 -0
- package/dist/pwa/server/no-cache.d.ts +22 -0
- package/dist/pwa/server/no-cache.d.ts.map +1 -0
- package/dist/pwa/worker/index.d.ts +9 -0
- package/dist/pwa/worker/index.d.ts.map +1 -0
- package/dist/pwa/worker/index.js +144 -0
- package/dist/pwa/worker/index.js.map +12 -0
- package/dist/pwa/worker/injected.d.ts +15 -0
- package/dist/pwa/worker/injected.d.ts.map +1 -0
- package/dist/pwa/worker/plan.d.ts +65 -0
- package/dist/pwa/worker/plan.d.ts.map +1 -0
- package/dist/pwa/worker/scope.d.ts +18 -0
- package/dist/pwa/worker/scope.d.ts.map +1 -0
- package/dist/pwa/worker/start-worker.d.ts +17 -0
- package/dist/pwa/worker/start-worker.d.ts.map +1 -0
- package/dist/react-router.d.ts +68 -0
- package/dist/react-router.d.ts.map +1 -0
- package/dist/server.d.ts +127 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/session/codes.d.ts +9 -0
- package/dist/session/codes.d.ts.map +1 -0
- package/dist/session/cookies.d.ts +128 -0
- package/dist/session/cookies.d.ts.map +1 -0
- package/dist/session/flow-types.d.ts +235 -0
- package/dist/session/flow-types.d.ts.map +1 -0
- package/dist/session/guard.d.ts +10 -0
- package/dist/session/guard.d.ts.map +1 -0
- package/dist/session/index.d.ts +22 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +1090 -0
- package/dist/session/index.js.map +27 -0
- package/dist/session/land.d.ts +28 -0
- package/dist/session/land.d.ts.map +1 -0
- package/dist/session/link-json.d.ts +22 -0
- package/dist/session/link-json.d.ts.map +1 -0
- package/dist/session/link-land.d.ts +20 -0
- package/dist/session/link-land.d.ts.map +1 -0
- package/dist/session/link-token.d.ts +24 -0
- package/dist/session/link-token.d.ts.map +1 -0
- package/dist/session/link-types.d.ts +142 -0
- package/dist/session/link-types.d.ts.map +1 -0
- package/dist/session/links.d.ts +14 -0
- package/dist/session/links.d.ts.map +1 -0
- package/dist/session/model/index.d.ts +8 -0
- package/dist/session/model/index.d.ts.map +1 -0
- package/dist/session/model/index.js +35 -0
- package/dist/session/model/index.js.map +9 -0
- package/dist/session/model/link-post.d.ts +35 -0
- package/dist/session/model/link-post.d.ts.map +1 -0
- package/dist/session/model/paths.d.ts +24 -0
- package/dist/session/model/paths.d.ts.map +1 -0
- package/dist/session/model/safe-next.d.ts +15 -0
- package/dist/session/model/safe-next.d.ts.map +1 -0
- package/dist/session/model/second-factor.d.ts +16 -0
- package/dist/session/model/second-factor.d.ts.map +1 -0
- package/dist/session/model/site-path.d.ts +10 -0
- package/dist/session/model/site-path.d.ts.map +1 -0
- package/dist/session/model/step-up-answers.d.ts +45 -0
- package/dist/session/model/step-up-answers.d.ts.map +1 -0
- package/dist/session/model/step-up-props.d.ts +22 -0
- package/dist/session/model/step-up-props.d.ts.map +1 -0
- package/dist/session/model/step-up.d.ts +48 -0
- package/dist/session/model/step-up.d.ts.map +1 -0
- package/dist/session/react/index.d.ts +13 -0
- package/dist/session/react/index.d.ts.map +1 -0
- package/dist/session/react/index.js +196 -0
- package/dist/session/react/index.js.map +14 -0
- package/dist/session/react/step-up/answers.d.ts +9 -0
- package/dist/session/react/step-up/answers.d.ts.map +1 -0
- package/dist/session/react/step-up/dialog-props.d.ts +27 -0
- package/dist/session/react/step-up/dialog-props.d.ts.map +1 -0
- package/dist/session/react/step-up/index.d.ts +7 -0
- package/dist/session/react/step-up/index.d.ts.map +1 -0
- package/dist/session/react/step-up/pending-runs.d.ts +21 -0
- package/dist/session/react/step-up/pending-runs.d.ts.map +1 -0
- package/dist/session/react/step-up/phase.d.ts +8 -0
- package/dist/session/react/step-up/phase.d.ts.map +1 -0
- package/dist/session/react/step-up/use-step-up-replay.d.ts +59 -0
- package/dist/session/react/step-up/use-step-up-replay.d.ts.map +1 -0
- package/dist/session/react/step-up/use-step-up-runner.d.ts +70 -0
- package/dist/session/react/step-up/use-step-up-runner.d.ts.map +1 -0
- package/dist/session/react/step-up/use-step-up.d.ts +51 -0
- package/dist/session/react/step-up/use-step-up.d.ts.map +1 -0
- package/dist/session/react/use-code-field.d.ts +37 -0
- package/dist/session/react/use-code-field.d.ts.map +1 -0
- package/dist/session/react/use-link-fragment.d.ts +22 -0
- package/dist/session/react/use-link-fragment.d.ts.map +1 -0
- package/dist/session/react/use-link-param.d.ts +26 -0
- package/dist/session/react/use-link-param.d.ts.map +1 -0
- package/dist/session/react/use-link-post.d.ts +39 -0
- package/dist/session/react/use-link-post.d.ts.map +1 -0
- package/dist/session/react/use-sign-out.d.ts +46 -0
- package/dist/session/react/use-sign-out.d.ts.map +1 -0
- package/dist/session/second-factor.d.ts +22 -0
- package/dist/session/second-factor.d.ts.map +1 -0
- package/dist/session/serialize.d.ts +42 -0
- package/dist/session/serialize.d.ts.map +1 -0
- package/dist/session/sign-in.d.ts +19 -0
- package/dist/session/sign-in.d.ts.map +1 -0
- package/dist/session/signed.d.ts +44 -0
- package/dist/session/signed.d.ts.map +1 -0
- package/dist/session/social-flow.d.ts +22 -0
- package/dist/session/social-flow.d.ts.map +1 -0
- package/dist/session/social-land.d.ts +31 -0
- package/dist/session/social-land.d.ts.map +1 -0
- package/dist/session/social-types.d.ts +136 -0
- package/dist/session/social-types.d.ts.map +1 -0
- package/dist/session/social.d.ts +32 -0
- package/dist/session/social.d.ts.map +1 -0
- package/dist/session/step-up-codes.d.ts +9 -0
- package/dist/session/step-up-codes.d.ts.map +1 -0
- package/dist/session/step-up-signed-out.d.ts +21 -0
- package/dist/session/step-up-signed-out.d.ts.map +1 -0
- package/dist/session/step-up-types.d.ts +127 -0
- package/dist/session/step-up-types.d.ts.map +1 -0
- package/dist/session/step-up.d.ts +17 -0
- package/dist/session/step-up.d.ts.map +1 -0
- package/dist/session/step.d.ts +22 -0
- package/dist/session/step.d.ts.map +1 -0
- package/dist/session/throttle.d.ts +73 -0
- package/dist/session/throttle.d.ts.map +1 -0
- package/dist/session/timed-wait.d.ts +4 -0
- package/dist/session/timed-wait.d.ts.map +1 -0
- package/dist/session/viewer.d.ts +34 -0
- package/dist/session/viewer.d.ts.map +1 -0
- package/dist/subscription/documents.d.ts +3 -0
- package/dist/subscription/documents.d.ts.map +1 -0
- package/dist/subscription/index.d.ts +7 -0
- package/dist/subscription/index.d.ts.map +1 -0
- package/dist/subscription/index.js +359 -0
- package/dist/subscription/index.js.map +14 -0
- package/dist/subscription/proxy.d.ts +54 -0
- package/dist/subscription/proxy.d.ts.map +1 -0
- package/dist/subscription/react/backoff.d.ts +8 -0
- package/dist/subscription/react/backoff.d.ts.map +1 -0
- package/dist/subscription/react/classify.d.ts +15 -0
- package/dist/subscription/react/classify.d.ts.map +1 -0
- package/dist/subscription/react/controller.d.ts +40 -0
- package/dist/subscription/react/controller.d.ts.map +1 -0
- package/dist/subscription/react/fake-timers.d.ts +8 -0
- package/dist/subscription/react/fake-timers.d.ts.map +1 -0
- package/dist/subscription/react/index.d.ts +15 -0
- package/dist/subscription/react/index.d.ts.map +1 -0
- package/dist/subscription/react/index.js +227 -0
- package/dist/subscription/react/index.js.map +17 -0
- package/dist/subscription/react/reconnect.d.ts +9 -0
- package/dist/subscription/react/reconnect.d.ts.map +1 -0
- package/dist/subscription/react/scheduler.d.ts +13 -0
- package/dist/subscription/react/scheduler.d.ts.map +1 -0
- package/dist/subscription/react/timers.d.ts +7 -0
- package/dist/subscription/react/timers.d.ts.map +1 -0
- package/dist/subscription/react/use-live-subscription.d.ts +36 -0
- package/dist/subscription/react/use-live-subscription.d.ts.map +1 -0
- package/dist/subscription/react/versions.d.ts +6 -0
- package/dist/subscription/react/versions.d.ts.map +1 -0
- package/dist/subscription/read.d.ts +17 -0
- package/dist/subscription/read.d.ts.map +1 -0
- package/dist/subscription/refusal.d.ts +11 -0
- package/dist/subscription/refusal.d.ts.map +1 -0
- package/dist/subscription/relay.d.ts +16 -0
- package/dist/subscription/relay.d.ts.map +1 -0
- package/dist/vite/bun.d.ts +21 -0
- package/dist/vite/bun.d.ts.map +1 -0
- package/dist/vite/bundle.d.ts +33 -0
- package/dist/vite/bundle.d.ts.map +1 -0
- package/dist/vite/compress.d.ts +18 -0
- package/dist/vite/compress.d.ts.map +1 -0
- package/dist/vite/config.d.ts +33 -0
- package/dist/vite/config.d.ts.map +1 -0
- package/dist/vite/dev.d.ts +28 -0
- package/dist/vite/dev.d.ts.map +1 -0
- package/dist/vite/entry.d.ts +20 -0
- package/dist/vite/entry.d.ts.map +1 -0
- package/dist/vite/hosts.d.ts +16 -0
- package/dist/vite/hosts.d.ts.map +1 -0
- package/dist/vite/index.d.ts +68 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +635 -0
- package/dist/vite/index.js.map +22 -0
- package/dist/vite/inline.d.ts +18 -0
- package/dist/vite/inline.d.ts.map +1 -0
- package/dist/vite/node.d.ts +16 -0
- package/dist/vite/node.d.ts.map +1 -0
- package/dist/vite/preview.d.ts +8 -0
- package/dist/vite/preview.d.ts.map +1 -0
- package/dist/vite/runtime.d.ts +8 -0
- package/dist/vite/runtime.d.ts.map +1 -0
- package/dist/vite/socket.d.ts +75 -0
- package/dist/vite/socket.d.ts.map +1 -0
- package/dist/vite/worker.d.ts +16 -0
- package/dist/vite/worker.d.ts.map +1 -0
- package/dist/with-alxia.d.ts +36 -0
- package/dist/with-alxia.d.ts.map +1 -0
- package/docs/README.md +42 -0
- package/docs/guide/api-keys.md +216 -0
- package/docs/guide/beside-the-pages.md +201 -0
- package/docs/guide/csp-nonce.md +166 -0
- package/docs/guide/customising-the-server.md +324 -0
- package/docs/guide/deploying.md +102 -0
- package/docs/guide/document.md +334 -0
- package/docs/guide/errors.md +1147 -0
- package/docs/guide/fetcher.md +355 -0
- package/docs/guide/getting-started.md +112 -0
- package/docs/guide/help.md +325 -0
- package/docs/guide/how-it-works.md +274 -0
- package/docs/guide/link.md +32 -0
- package/docs/guide/lists.md +225 -0
- package/docs/guide/mcp.md +173 -0
- package/docs/guide/media.md +273 -0
- package/docs/guide/navigation.md +52 -0
- package/docs/guide/oauth.md +342 -0
- package/docs/guide/oidc.md +262 -0
- package/docs/guide/openapi.md +51 -0
- package/docs/guide/pwa.md +670 -0
- package/docs/guide/session.md +2105 -0
- package/docs/guide/subscriptions.md +211 -0
- package/docs/guide/testing.md +42 -0
- package/docs/guide/typing-the-loaders.md +311 -0
- package/docs/guide.md +82 -0
- package/docs/roadmap.md +474 -0
- package/docs/troubleshooting.md +3837 -0
- package/package.json +301 -5
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/errors/code-resolver.ts", "../src/errors/describe-refusal.ts", "../src/errors/field-placement.ts", "../src/errors/form-refusal.ts", "../src/errors/submit-form.ts", "../src/errors/describe.ts", "../src/errors/api-errors.ts", "../src/errors/log.ts", "../src/errors/call-failure.ts", "../src/errors/catalogue-check.ts", "../src/errors/catalogue-read.ts", "../src/errors/catalogue.ts", "../src/errors/json-actions.ts", "../src/errors/message-values.ts", "../src/errors/messages.ts", "../src/errors/provider.ts", "../src/errors/section-action.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { ApiMessages } from './messages';\n\n/** The part of a zod issue a code reads, by shape (`@nxgt/material-core`'s `CodeIssue`). */\nexport type CodeIssueLike = {\n\treadonly code: string;\n\t/** A custom issue's params: `.refine(…, { params: { code } })`. */\n\treadonly params?: Record<string, unknown> | undefined;\n\treadonly input?: unknown;\n\treadonly origin?: string | undefined;\n\treadonly minimum?: unknown;\n\treadonly maximum?: unknown;\n\treadonly expected?: unknown;\n\treadonly message?: string | undefined;\n};\n\n/** An API error code (`<module>.errors.<slug>`, the module in kebab-case or camelCase), as opposed to a GraphQL one (`BAD_USER_INPUT`). */\nexport const API_CODE = /^[a-z][a-zA-Z0-9-]*\\.errors\\.[a-z0-9-]+$/;\n\nexport interface ApiCodeResolverOptions<L extends string> {\n\t/**\n\t * The app's translator, for every key that is not an API code. Method\n\t * syntax: the app's own `Translate<LocaleKey>` is accepted.\n\t */\n\ttranslate(\n\t\tkey: string,\n\t\tcontext?: Readonly<Record<string, unknown>>,\n\t\tlanguage?: L | (() => L),\n\t): string;\n\t/** The page's language, when a call names none. */\n\tlanguage(): L;\n\t/** Which code an issue carries; the issue's `params.code` by default. */\n\tcodeOf?(issue: CodeIssueLike): string | undefined;\n\t/** Whether a key is an API code; `<module>.errors.<slug>` by default. */\n\tisApiCode?(key: string): boolean;\n}\n\n/** What `@nxgt/material`'s `useCodeResolver(schema, resolver)` takes. */\nexport interface ApiCodeResolver<L extends string> {\n\ttranslate: (\n\t\tkey: string,\n\t\tcontext?: Readonly<Record<string, unknown>>,\n\t\tlanguage?: L | (() => L),\n\t) => string;\n\tcodeOf: (issue: CodeIssueLike) => string | undefined;\n}\n\nfunction paramsCode(issue: CodeIssueLike) {\n\tconst code = (issue.params as { code?: unknown } | undefined)?.code;\n\treturn typeof code === 'string' ? code : undefined;\n}\n\n/**\n * The words of what a form's checks ask for: a refinement carrying an API\n * code in `params.code` reads exactly as the API words it (from the\n * catalogue `messages` holds), any other key takes the app's translator, and\n * a code the catalogue lacks comes back as it is, so the form library words\n * the issue with its own locale instead. Both functions are stable: a\n * resolver is made once per schema and language, so build this once, at\n * module scope.\n */\nexport function apiCodeResolver<L extends string>(\n\tmessages: ApiMessages<L>,\n\toptions: ApiCodeResolverOptions<L>,\n): ApiCodeResolver<L> {\n\tconst isApiCode = (key: string) =>\n\t\toptions.isApiCode ? options.isApiCode(key) : API_CODE.test(key);\n\treturn {\n\t\ttranslate(key, context, provideLanguage) {\n\t\t\tif (!isApiCode(key))\n\t\t\t\treturn options.translate(key, context, provideLanguage);\n\t\t\tconst language =\n\t\t\t\ttypeof provideLanguage === 'function'\n\t\t\t\t\t? provideLanguage()\n\t\t\t\t\t: (provideLanguage ?? options.language());\n\t\t\treturn messages.apiMessage(key, context, language) ?? key;\n\t\t},\n\t\tcodeOf(issue) {\n\t\t\treturn options.codeOf ? options.codeOf(issue) : paramsCode(issue);\n\t\t},\n\t};\n}\n",
|
|
6
|
+
"import { isApiErrorLike } from './api-error';\nimport type { ApiErrors } from './api-errors';\n\n/** The API's refusal of `error`, or `undefined` when it is not one. */\nexport function refusalOf<L extends string>(\n\terrors: Pick<ApiErrors<L>, 'apiErrorMessage' | 'unavailableMessage'>,\n\terror: unknown,\n\tlanguage: L,\n): ReturnType<ApiErrors<L>['apiRefusal']> {\n\tif (isApiErrorLike(error)) {\n\t\treturn {\n\t\t\tmessage: errors.apiErrorMessage(error, language),\n\t\t\tstatus: error.status,\n\t\t};\n\t}\n\tif (error instanceof Response && error.status === 503) {\n\t\treturn { message: errors.unavailableMessage(language), status: 503 };\n\t}\n\treturn undefined;\n}\n\n/** The worded message of each field an API error names, by field path. */\nexport function fieldErrorsOf<L extends string>(\n\terrors: Pick<ApiErrors<L>, 'apiErrorMessage' | 'translateCode'>,\n\terror: Parameters<ApiErrors<L>['fieldErrors']>[0],\n\tlanguage: L,\n): ReturnType<ApiErrors<L>['fieldErrors']> {\n\tconst extensions = error.errors[0]?.extensions;\n\tconst fields = Array.isArray(extensions?.fields) ? extensions.fields : [];\n\tif (!fields.length && extensions?.field) {\n\t\treturn { [extensions.field]: errors.apiErrorMessage(error, language) };\n\t}\n\treturn Object.fromEntries(\n\t\tfields.map(({ path, code, message, params }) => [\n\t\t\tpath,\n\t\t\terrors.translateCode(code, message, language, params),\n\t\t]),\n\t);\n}\n",
|
|
7
|
+
"import type { ApiErrorLike } from './api-error';\nimport type { ApiErrors } from './api-errors';\n\n/**\n * The field messages of a refusal placed under the form fields `fieldOf`\n * names for their input paths: `byField`, and the messages of the paths it\n * names no field for (`unplaced`).\n */\nexport function placeFieldErrors<L extends string>(\n\terrors: Pick<ApiErrors<L>, 'fieldErrors'>,\n\terror: ApiErrorLike,\n\tlanguage: L,\n\tfieldOf: (path: string) => string | undefined,\n): { byField: Record<string, string>; unplaced: string[] } {\n\tconst byField: Record<string, string> = {};\n\tconst unplaced: string[] = [];\n\tfor (const [path, message] of Object.entries(\n\t\terrors.fieldErrors(error, language),\n\t)) {\n\t\tconst field = fieldOf(path);\n\t\tif (field) byField[field] = message;\n\t\telse unplaced.push(message);\n\t}\n\treturn { byField, unplaced };\n}\n",
|
|
8
|
+
"import { isApiErrorLike } from './api-error';\nimport type { ApiErrors } from './api-errors';\nimport { fetcherRefusal } from './fetcher-result';\nimport { placeFieldErrors } from './field-placement';\nimport type { RouteErrorOptions } from './route-error';\n\n/** What `apiErrors.formRefusal` answers: a form's refusal, for a fetcher's action. */\nexport interface FormRefusal {\n\t/**\n\t * The message for the form as a whole: empty when every field issue found\n\t * its form field, else the refusal's message followed by the messages of\n\t * the issues that found none (as `submitForm`'s `formError`).\n\t */\n\terror: string;\n\t/** Messages by form field, already translated. */\n\tfieldErrors: Record<string, string>;\n\t/** The refusal's HTTP status. */\n\tstatus: number;\n}\n\n/**\n * A fetcher form's refusal (`fetcherRefusal`) with each field issue placed\n * under the form field `fieldOf` names for its input path. `error` is empty\n * when every issue found its field, else the refusal's message with the\n * messages of the unplaced issues. An unreachable API gives the unavailable\n * message with no field errors, as `fetcherRefusal` does; a 401 or any other\n * failure is thrown for the error page.\n */\nexport function formRefusal<L extends string>(\n\terrors: Pick<ApiErrors<L>, 'apiRefusal' | 'fieldErrors'>,\n\terror: unknown,\n\tlanguage: L,\n\tfieldOf: (path: string) => string | undefined,\n\troute?: RouteErrorOptions,\n): FormRefusal {\n\tconst { message, status } = fetcherRefusal(errors, error, language, route);\n\tif (!isApiErrorLike(error))\n\t\treturn { error: message, fieldErrors: {}, status };\n\tconst { byField, unplaced } = placeFieldErrors(\n\t\terrors,\n\t\terror,\n\t\tlanguage,\n\t\tfieldOf,\n\t);\n\treturn {\n\t\terror:\n\t\t\tObject.keys(byField).length && !unplaced.length\n\t\t\t\t? ''\n\t\t\t\t: [message, ...unplaced].join(' '),\n\t\tfieldErrors: byField,\n\t\tstatus,\n\t};\n}\n",
|
|
9
|
+
"import { data } from 'react-router';\nimport { isApiErrorLike } from './api-error';\nimport type { ApiErrors } from './api-errors';\nimport { placeFieldErrors } from './field-placement';\nimport type { FormErrors } from './form-errors';\nimport { type RouteErrorOptions, routeError } from './route-error';\n\n/**\n * Runs a form's mutation. An `ApiError` becomes the form's errors: each\n * refused field (`extensions.fields`, or the one `extensions.field` names)\n * under the form field `fieldOf` names (else on the form), and any other\n * code as the form's message. A 404 about none of the form's fields (the\n * record itself is gone), a 401 and other failures go to the error page.\n */\nexport async function submitForm<L extends string, T>(\n\terrors: Pick<ApiErrors<L>, 'apiErrorMessage' | 'fieldErrors'>,\n\tlanguage: L,\n\trun: () => Promise<T>,\n\tfieldOf: (path: string) => string | undefined,\n\troute?: RouteErrorOptions,\n): Promise<{ ok: true; value: T } | ReturnType<typeof data<FormErrors>>> {\n\ttry {\n\t\treturn { ok: true, value: await run() };\n\t} catch (error) {\n\t\tif (!isApiErrorLike(error) || error.status === 401) {\n\t\t\tthrow routeError(error, route);\n\t\t}\n\t\tconst field = error.errors[0]?.extensions?.field;\n\t\tif (error.status === 404 && !(field && fieldOf(field))) {\n\t\t\tthrow routeError(error, route);\n\t\t}\n\t\tconst { byField, unplaced } = placeFieldErrors(\n\t\t\terrors,\n\t\t\terror,\n\t\t\tlanguage,\n\t\t\tfieldOf,\n\t\t);\n\t\tconst formError =\n\t\t\tObject.keys(byField).length && !unplaced.length\n\t\t\t\t? undefined\n\t\t\t\t: [errors.apiErrorMessage(error, language), ...unplaced].join(' ');\n\t\treturn data({ fieldErrors: byField, formError }, { status: error.status });\n\t}\n}\n",
|
|
10
|
+
"import { valuesOf } from './api-error';\nimport type { ApiErrors, ApiErrorsOptions } from './api-errors';\nimport { API_CODE } from './code-resolver';\nimport { fieldErrorsOf, refusalOf } from './describe-refusal';\nimport { fetcherRefusal, fetcherResult } from './fetcher-result';\nimport { formRefusal } from './form-refusal';\nimport { submitForm } from './submit-form';\n\nexport function describeApiErrors<L extends string>({\n\tmessages,\n\tunavailable,\n\trefused,\n\treword,\n\tbyCode = {},\n\tisApiCode = (code) => API_CODE.test(code),\n}: ApiErrorsOptions<L>): ApiErrors<L> {\n\tconst translateCode: ApiErrors<L>['translateCode'] = (\n\t\tcode,\n\t\tfallback,\n\t\tlanguage,\n\t\tvalues,\n\t) => {\n\t\tif (!code) return fallback;\n\t\treturn messages.apiMessage(code, values, language) ?? fallback;\n\t};\n\n\tconst apiErrorMessage: ApiErrors<L>['apiErrorMessage'] = (\n\t\terror,\n\t\tlanguage,\n\t) => {\n\t\tconst code = error.code;\n\t\tif (refused && (!code || !isApiCode(code))) return refused(language);\n\t\tconst own = code && Object.hasOwn(byCode, code) ? byCode[code] : undefined;\n\t\tconst values = valuesOf(error.errors[0]?.extensions);\n\t\tconst text = own\n\t\t\t? own(error, language)\n\t\t\t: translateCode(code, error.message, language, values);\n\t\tif (!reword || !code) return text;\n\t\treturn (\n\t\t\treword(text, error, { code, values: values ?? {}, language }) ?? text\n\t\t);\n\t};\n\n\tconst unavailableMessage = (language: L) => unavailable(language);\n\n\tconst apiRefusal: ApiErrors<L>['apiRefusal'] = (error, language) =>\n\t\trefusalOf({ apiErrorMessage, unavailableMessage }, error, language);\n\n\tconst fieldErrors: ApiErrors<L>['fieldErrors'] = (error, language) =>\n\t\tfieldErrorsOf({ apiErrorMessage, translateCode }, error, language);\n\n\tconst parts = { apiRefusal, apiErrorMessage, fieldErrors };\n\n\treturn {\n\t\ttranslateCode,\n\t\tapiErrorMessage,\n\t\tunavailableMessage,\n\t\tfieldErrors,\n\t\tapiRefusal,\n\t\tfetcherRefusal: (error, language, route) =>\n\t\t\tfetcherRefusal(parts, error, language, route),\n\t\tformRefusal: (error, language, fieldOf, route) =>\n\t\t\tformRefusal(parts, error, language, fieldOf, route),\n\t\tfetcherResult: (language, about, run, options) =>\n\t\t\tfetcherResult(parts, language, about, run, options),\n\t\tsubmitForm: (language, run, fieldOf, route) =>\n\t\t\tsubmitForm(parts, language, run, fieldOf, route),\n\t};\n}\n",
|
|
11
|
+
"import type { data } from 'react-router';\nimport type { ApiErrorLike } from './api-error';\nimport { describeApiErrors } from './describe';\nimport type { FetcherResultOptions } from './fetcher-result';\nimport type { FormErrors } from './form-errors';\nimport type { FormRefusal } from './form-refusal';\nimport type { ApiMessages } from './messages';\nimport type { RouteErrorOptions } from './route-error';\n\n/** A refused call, as a page says it: the message, and the HTTP status to answer. */\nexport type ApiRefusal = { message: string; status: number };\n\nexport interface ApiErrorsOptions<L extends string> {\n\t/** The catalogue the API's codes are worded from. */\n\tmessages: ApiMessages<L>;\n\t/**\n\t * The app's own word for an API it cannot reach (a 503 `Response`): not\n\t * an API error, so never one of the catalogue's codes.\n\t */\n\tunavailable(language: L): string;\n\t/**\n\t * The app's generic refusal, said for an error with no API code (a raw\n\t * `BAD_USER_INPUT` before the API's validation layer), never the raw\n\t * message. Without it, such an error says the message the API sent.\n\t */\n\trefused?(language: L): string;\n\t/**\n\t * An app's own wording for given codes, such as the API's request limits\n\t * (depth, cost, introspection), whose params differ and name no field.\n\t * Checked after `refused`, before the catalogue.\n\t */\n\tbyCode?: Readonly<\n\t\tRecord<string, (error: ApiErrorLike, language: L) => string>\n\t>;\n\t/**\n\t * Words a whole family of codes once, after the text is worded. It runs\n\t * on the final text `apiErrorMessage` (so `apiRefusal`, `fetcherResult`,\n\t * `fetcherRefusal`, `submitForm` and a single `extensions.field`) says\n\t * for an error with a code, whichever produced it: the catalogue, the\n\t * API's own message, or `byCode`. It does not run on `refused`'s text, on\n\t * `unavailable`'s (a network failure), on `translateCode` nor on the\n\t * entries of `extensions.fields`. `values` are the merged values the\n\t * catalogue formats with (`extensions` and `extensions.params`, params\n\t * winning). Return the text to show, or `undefined` to keep `text`.\n\t */\n\treword?(\n\t\ttext: string,\n\t\terror: ApiErrorLike,\n\t\tcontext: {\n\t\t\tcode: string;\n\t\t\tvalues: Readonly<Record<string, unknown>>;\n\t\t\tlanguage: L;\n\t\t},\n\t): string | undefined;\n\t/** Whether a code is an API code; `<module>.errors.<slug>` by default. */\n\tisApiCode?(code: string): boolean;\n}\n\n/** What a page says of an API's refusals, in a language. */\nexport interface ApiErrors<L extends string> {\n\t/**\n\t * The catalogue's text of an API code in `language`, else `fallback` (the\n\t * message the API already worded). `values` are the message's arguments\n\t * (`extensions.params`).\n\t */\n\ttranslateCode(\n\t\tcode: string | undefined,\n\t\tfallback: string,\n\t\tlanguage: L,\n\t\tvalues?: Readonly<Record<string, unknown>>,\n\t): string;\n\t/**\n\t * What to show for an API error: `refused` for an error with no API code,\n\t * when given; else `byCode`'s wording of its code; else the catalogue's\n\t * text; else the message the API already worded.\n\t */\n\tapiErrorMessage(error: ApiErrorLike, language: L): string;\n\t/**\n\t * The message of each refused field, by input path, ready for a form: the\n\t * entries of `extensions.fields`, else the one field `extensions.field`\n\t * names, with the error's own message. Empty for neither.\n\t */\n\tfieldErrors(error: ApiErrorLike, language: L): Record<string, string>;\n\t/** `unavailable`, in `language`. */\n\tunavailableMessage(language: L): string;\n\t/**\n\t * What a failed call says to the user: an API refusal's message and its\n\t * status, or an API it cannot reach (a 503 `Response`: the unavailable\n\t * word). Undefined for anything else, which the caller rethrows.\n\t */\n\tapiRefusal(error: unknown, language: L): ApiRefusal | undefined;\n\t/**\n\t * A fetcher's refusal: `apiRefusal`'s, so the page stays where it was. A\n\t * 401 (the session caller redirects first) or any other failure is\n\t * thrown, through `routeError`, for the error page.\n\t */\n\tfetcherRefusal(\n\t\terror: unknown,\n\t\tlanguage: L,\n\t\troute?: RouteErrorOptions,\n\t): ApiRefusal;\n\t/**\n\t * A fetcher form's refusal (`fetcherRefusal`) with its field issues under\n\t * the form field `fieldOf` names for each input path: `{ error,\n\t * fieldErrors, status }`, `error` empty when every issue found its field.\n\t */\n\tformRefusal(\n\t\terror: unknown,\n\t\tlanguage: L,\n\t\tfieldOf: (path: string) => string | undefined,\n\t\troute?: RouteErrorOptions,\n\t): FormRefusal;\n\t/**\n\t * Runs the mutation of an action a fetcher posted to: `{ ok: true }` with\n\t * `about` and the mutation's value, or `{ ok: false, error }` with `about`\n\t * and the refusal's message, answered with its HTTP status. `options.reword`\n\t * words the refusal of this call from the caught API error (`undefined`\n\t * keeps the worded message); it is not called for an unreachable API.\n\t */\n\tfetcherResult<\n\t\tAbout extends object,\n\t\tValue extends object = Record<never, never>,\n\t>(\n\t\tlanguage: L,\n\t\tabout: About,\n\t\trun: () => Promise<Value>,\n\t\toptions?: FetcherResultOptions,\n\t): Promise<\n\t\t| ({ ok: true } & About & Value)\n\t\t| ReturnType<typeof data<{ ok: false; error: string } & About>>\n\t>;\n\t/**\n\t * Runs a form's mutation: `{ ok: true, value }`, or the form's errors\n\t * (`fieldErrors` under the form field `fieldOf` names an input path by,\n\t * and a `formError` for the rest) with the refusal's status. A 404 about\n\t * none of the form's fields, a 401 and other failures are thrown for the\n\t * error page, through `routeError` (with `route`).\n\t */\n\tsubmitForm<T>(\n\t\tlanguage: L,\n\t\trun: () => Promise<T>,\n\t\tfieldOf: (path: string) => string | undefined,\n\t\troute?: RouteErrorOptions,\n\t): Promise<{ ok: true; value: T } | ReturnType<typeof data<FormErrors>>>;\n}\n\n/**\n * The wording of an API's refusals for the languages `L`, from the\n * catalogue `messages` holds. Make one per app, beside its `createApiMessages`.\n */\nexport function createApiErrors<L extends string>(\n\toptions: ApiErrorsOptions<L>,\n): ApiErrors<L> {\n\treturn describeApiErrors(options);\n}\n",
|
|
12
|
+
"/** The methods of a `console` a report goes through. */\nexport type LogMethod = 'warn' | 'error';\n\n/**\n * A log whose methods can throw without breaking what reports through\n * them: a broken app log must not turn a handled failure into a rejection.\n */\nexport function quietLog<M extends LogMethod>(\n\tlog: Pick<Console, M>,\n\tmethods: readonly M[],\n): Pick<Console, M> {\n\tconst quiet = {} as Pick<Console, M>;\n\tfor (const method of methods) {\n\t\tquiet[method] = ((...args: unknown[]) => {\n\t\t\ttry {\n\t\t\t\t(log[method] as (...args: unknown[]) => void)(...args);\n\t\t\t} catch {\n\t\t\t\t// Swallowed on purpose: see above.\n\t\t\t}\n\t\t}) as Pick<Console, M>[M];\n\t}\n\treturn quiet;\n}\n",
|
|
13
|
+
"import { isApiErrorLike, isStatusError, isUnavailableError } from './api-error';\nimport { quietLog } from './log';\nimport { isProblemErrorLike } from './problem-error';\nimport { REQUEST_ID_HEADER } from './request-id';\n\n/** The statuses an API's gateway or auth layer may answer without a GraphQL body. */\nconst PASSED_THROUGH: ReadonlySet<number> = new Set([401, 403, 404]);\n\n/** The statuses a `Response` cannot carry a body with. */\nconst NO_BODY: ReadonlySet<number> = new Set([101, 204, 205, 304]);\n\nexport interface CallFailureOptions {\n\t/** What a log line names the API by, such as `my-api https://api.example.com/graphql`. */\n\tapi: string;\n\t/** The operation's name, for the log (`operationName(document)`). */\n\toperation?: string;\n\t/** The `x-request-id` the API answered, when it did (`requestIdOf(response)`). */\n\trequestId?: string;\n\t/** The incoming request's signal: an aborted call is answered 503. */\n\tsignal?: AbortSignal;\n\t/** The statuses without a GraphQL body that become a `Response` of their own; 401, 403 and 404 by default. */\n\tpassedThrough?: ReadonlySet<number>;\n\t/** Where the lines go; `console` by default. */\n\tlog?: Pick<Console, 'warn' | 'error'>;\n}\n\n/**\n * What a call became once it failed, for a loader or an action to throw: the\n * `ApiError` or `ProblemError` as it is (carrying `requestId`), a `Response` of the API's own\n * status for a 401, 403 or 404 without a GraphQL body, a 503 `Response` (with no body; the reason is in the log) for an\n * unreachable, slow, garbled or aborted API, and any other error as it is.\n * Every case it recognises is logged with the request id, when the API gave one, and never\n * the headers, the variables nor a token; the id rides on the `ApiError` as\n * `requestId` and on a `Response` as `x-request-id`, where `routeError` reads\n * it.\n *\n * It recognises `@nxgt/graphql-client`'s errors by their `name`, never with\n * `instanceof`, so it needs no import of the client and holds across two\n * copies of it.\n */\nexport function apiCallFailure(\n\terror: unknown,\n\t{\n\t\tapi,\n\t\toperation = 'operation',\n\t\trequestId,\n\t\tsignal,\n\t\tpassedThrough = PASSED_THROUGH,\n\t\tlog: appLog = console,\n\t}: CallFailureOptions,\n): unknown {\n\tconst log = quietLog(appLog, ['warn', 'error']);\n\tconst call = `${api}: ${operation}${requestId ? ` (request ${requestId})` : ''}`;\n\tconst headers: Record<string, string> = requestId\n\t\t? { [REQUEST_ID_HEADER]: requestId }\n\t\t: {};\n\tconst unavailable = (reason: string, cause?: unknown): Response => {\n\t\tlog.error(`${call} ${reason}`, cause ?? '');\n\t\treturn new Response(null, { status: 503, headers });\n\t};\n\tif (isApiErrorLike(error)) {\n\t\t// The client's `ApiError.requestId` is writable, though the structural type marks it readonly.\n\t\tif (requestId) (error as { requestId?: string }).requestId = requestId;\n\t\tconst line = `${call} answered ${error.status}${error.code ? ` ${error.code}` : ''}`;\n\t\tif (error.status >= 500) log.error(line);\n\t\telse log.warn(line);\n\t\treturn error;\n\t}\n\tif (isProblemErrorLike(error)) {\n\t\tif (requestId) error.requestId = requestId;\n\t\tconst line = `${call} answered ${error.status}`;\n\t\tif (error.status >= 500) log.error(line);\n\t\telse log.warn(line);\n\t\treturn error;\n\t}\n\tif (isStatusError(error)) {\n\t\tif (passedThrough.has(error.status)) {\n\t\t\tlog.warn(`${call} answered ${error.status}`);\n\t\t\tconst statusText =\n\t\t\t\ttypeof error.statusText === 'string' ? error.statusText : '';\n\t\t\tif (NO_BODY.has(error.status)) {\n\t\t\t\treturn new Response(null, {\n\t\t\t\t\tstatus: error.status,\n\t\t\t\t\tstatusText,\n\t\t\t\t\theaders,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn new Response(statusText, {\n\t\t\t\tstatus: error.status,\n\t\t\t\tstatusText,\n\t\t\t\theaders,\n\t\t\t});\n\t\t}\n\t\treturn unavailable(`answered ${error.status} without GraphQL`, error.body);\n\t}\n\tif (isUnavailableError(error)) return unavailable(error.reason, error.cause);\n\tif (signal?.aborted) return unavailable('aborted', error);\n\treturn error;\n}\n\n/** A document, as far as `operationName` reads it: `graphql`'s `DocumentNode` fits. */\nexport interface DocumentLike {\n\treadonly definitions: readonly {\n\t\treadonly kind: string;\n\t\treadonly operation?: string | undefined;\n\t\treadonly name?: { readonly value: string } | undefined;\n\t}[];\n}\n\n/**\n * The name of the operation a document holds, for a log line: its name, else\n * its kind (`query`, `mutation`, `subscription`), else `operation`.\n */\nexport function operationName(document: DocumentLike): string {\n\tfor (const definition of document.definitions) {\n\t\tif (definition.kind === 'OperationDefinition') {\n\t\t\treturn definition.name?.value ?? definition.operation ?? 'operation';\n\t\t}\n\t}\n\treturn 'operation';\n}\n",
|
|
14
|
+
"import type { Held } from './catalogue-read';\n\n/** What the TTL check needs: the reader's state and the app's own calls. */\nexport interface CheckContext<L extends string> {\n\treader: {\n\t\theld: Map<L, Held>;\n\t\tload(language: L, now: number): Promise<void>;\n\t};\n\tversions(): Promise<Partial<Record<L, string>>>;\n\tttl(): number;\n\tretryMs: number;\n\tlog: Pick<Console, 'error'>;\n}\n\n/**\n * Asks the versions in one call and reads again the messages of each\n * language that moved. An API that cannot be reached keeps the messages\n * held (stale, still worded) and is asked again after `retryMs`.\n */\nexport async function checkVersions<L extends string>(\n\t{ reader, versions, ttl, retryMs, log }: CheckContext<L>,\n\tnow: number,\n) {\n\ttry {\n\t\tconst latest = await versions();\n\t\tfor (const [language, entry] of [...reader.held]) {\n\t\t\tif (latest[language] !== entry.version) {\n\t\t\t\tawait reader.load(language, now);\n\t\t\t} else {\n\t\t\t\tentry.checkedAt = now;\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tlog.error(\n\t\t\t'alxia-react-router: the error catalogue was not checked, keeping what is held',\n\t\t\terror,\n\t\t);\n\t\tfor (const entry of reader.held.values()) {\n\t\t\tentry.checkedAt = now - ttl() + retryMs;\n\t\t}\n\t}\n}\n\n/**\n * The TTL, whose getter is the app's: one that throws, or that is not a\n * finite number of at least 0, is logged and `fallback` is used.\n */\nexport function safeTtl(\n\tttlMs: number | (() => number),\n\tfallback: number,\n\tlog: Pick<Console, 'error'>,\n) {\n\treturn () => {\n\t\ttry {\n\t\t\tconst ttl = typeof ttlMs === 'function' ? ttlMs() : ttlMs;\n\t\t\tif (typeof ttl === 'number' && Number.isFinite(ttl) && ttl >= 0) {\n\t\t\t\treturn ttl;\n\t\t\t}\n\t\t\tlog.error('alxia-react-router: ttlMs is not a duration, using retryMs');\n\t\t} catch (error) {\n\t\t\tlog.error('alxia-react-router: ttlMs threw, using retryMs', error);\n\t\t}\n\t\treturn fallback;\n\t};\n}\n",
|
|
15
|
+
"import type { ApiMessages, CatalogueMessage } from './messages';\n\n/** What the API answers for one language: its version and every message. */\nexport type CatalogueReply = {\n\tversion: string;\n\tmessages: ReadonlyArray<CatalogueMessage & { readonly code: string }>;\n};\n\n/** A language's catalogue as held, and when its version was last confirmed. */\nexport type Held = { version: string; checkedAt: number };\n\nexport interface CatalogueReaderOptions<L extends string> {\n\tmessages: ApiMessages<L>;\n\tread(language: L): Promise<CatalogueReply>;\n\tretryMs: number;\n\tfirstReadWaitMs: number;\n\tlog: Pick<Console, 'error'>;\n}\n\n/**\n * Waits for the read, until `firstReadWaitMs` after it started (not after\n * this request came: a hung API holds a request at most that long in\n * all); the read goes on either way.\n */\nasync function boundedWait(\n\tpending: { read: Promise<void>; started: number },\n\tfirstReadWaitMs: number,\n) {\n\tconst left = firstReadWaitMs - (performance.now() - pending.started);\n\tif (left <= 0) return;\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tconst limit = new Promise<void>((resolve) => {\n\t\ttimer = setTimeout(resolve, left);\n\t});\n\tawait Promise.race([pending.read, limit]);\n\tclearTimeout(timer);\n}\n\n/**\n * The reading half of the catalogue: the first read of each language (one in\n * flight, a bounded wait, a retry delay after a failure) and the version\n * each one holds. `createErrorCatalogue` adds the TTL check on top.\n */\nexport function createCatalogueReader<L extends string>({\n\tmessages,\n\tread,\n\tretryMs,\n\tfirstReadWaitMs,\n\tlog,\n}: CatalogueReaderOptions<L>) {\n\tconst held = new Map<L, Held>();\n\tconst loading = new Map<L, { read: Promise<void>; started: number }>();\n\tconst failedAt = new Map<L, number>();\n\n\t/** Reads one language's messages and holds them. */\n\tasync function load(language: L, now: number) {\n\t\tconst reply = await read(language);\n\t\tconst entries: Record<string, CatalogueMessage> = Object.create(null);\n\t\tfor (const { code, message, params } of reply.messages) {\n\t\t\tentries[code] = { message, params };\n\t\t}\n\t\tmessages.set(language, entries);\n\t\theld.set(language, { version: reply.version, checkedAt: now });\n\t}\n\n\t/** The first read of a language, once however many pages ask at the same time. */\n\tfunction loadOnce(language: L, now: number) {\n\t\tlet pending = loading.get(language);\n\t\tif (!pending) {\n\t\t\tconst started = performance.now();\n\t\t\tconst reading = load(language, now)\n\t\t\t\t.then(() => {\n\t\t\t\t\tfailedAt.delete(language);\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\t// When it failed, not when it started: a read that hung for\n\t\t\t\t\t// the wait is not retried at once by the next request.\n\t\t\t\t\tfailedAt.set(language, now + (performance.now() - started));\n\t\t\t\t\tlog.error(\n\t\t\t\t\t\t`alxia-react-router: the error catalogue (${language}) was not read`,\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tloading.delete(language);\n\t\t\t\t});\n\t\t\tpending = { read: reading, started };\n\t\t\tloading.set(language, pending);\n\t\t}\n\t\treturn pending;\n\t}\n\n\treturn {\n\t\theld,\n\t\tload,\n\t\t/** Reads a language that is not held yet, unless a failure is still fresh. */\n\t\tasync first(language: L, now: number) {\n\t\t\tconst failed = failedAt.get(language);\n\t\t\tif (failed === undefined || now - failed >= retryMs) {\n\t\t\t\tawait boundedWait(loadOnce(language, now), firstReadWaitMs);\n\t\t\t}\n\t\t},\n\t\treset() {\n\t\t\theld.clear();\n\t\t\tloading.clear();\n\t\t\tfailedAt.clear();\n\t\t},\n\t};\n}\n",
|
|
16
|
+
"import { checkVersions, safeTtl } from './catalogue-check';\nimport { type CatalogueReply, createCatalogueReader } from './catalogue-read';\nimport { quietLog } from './log';\nimport type { ApiMessages, CatalogueMessages } from './messages';\n\nexport type { CatalogueReply } from './catalogue-read';\n\nexport interface ErrorCatalogueOptions<L extends string> {\n\t/** The store the page words refusals from (`createApiMessages`). */\n\tmessages: ApiMessages<L>;\n\t/** The languages to hold, each read once and kept fresh. */\n\tlanguages: readonly L[];\n\t/** Reads one language's catalogue from the API. */\n\tread(language: L): Promise<CatalogueReply>;\n\t/** Asks the API for the version of every language, in one call. */\n\tversions(): Promise<Partial<Record<L, string>>>;\n\t/** How long a held catalogue is served before its version is checked. */\n\tttlMs: number | (() => number);\n\t/** How soon a check or a first read that failed is tried again. Default 5000. */\n\tretryMs?: number;\n\t/**\n\t * How long a request waits for a language's first read; past it the\n\t * request goes on and the read carries on in the background. Default 1500.\n\t */\n\tfirstReadWaitMs?: number;\n\t/** The codes the browser words itself (`clientMessages`). */\n\tclientCodes: readonly string[];\n\t/** Where failures are reported. Default `console`. */\n\tlog?: Pick<Console, 'error'>;\n}\n\n/** The API's error catalogue, kept fresh for the server. */\nexport interface ErrorCatalogue<L extends string> {\n\t/**\n\t * The catalogue of `language`, ready to word a refusal. Only a language\n\t * with no catalogue yet is awaited, for at most `firstReadWaitMs`. A held\n\t * one is served as it is, and once older than the TTL its version is\n\t * checked in the background, one check at a time.\n\t */\n\tfresh(language: L, now?: number): Promise<void>;\n\t/** Every language, fresh: what the root middleware awaits. */\n\tfreshAll(now?: number): Promise<void>;\n\t/** At startup: reads every language without holding the boot back. */\n\twarm(): void;\n\t/** The messages the browser words itself, by language, for the root's loader. */\n\tclientMessages(): Record<L, CatalogueMessages>;\n\t/**\n\t * Forgets everything held and in flight. For use between tests, with\n\t * nothing in flight: a read or check still running when it is called\n\t * finishes and holds its result again.\n\t */\n\treset(): void;\n\t/** The version held for a language, if any. */\n\theldVersion(language: L): string | undefined;\n\t/** Waits for the check in flight, if any (tests). */\n\tsettled(): Promise<void>;\n}\n\n/** The messages the browser words itself, by language. */\nfunction clientMessages<L extends string>(\n\tmessages: ApiMessages<L>,\n\tlanguages: readonly L[],\n\tclientCodes: readonly string[],\n) {\n\tconst byLanguage = {} as Record<L, CatalogueMessages>;\n\tfor (const language of languages) {\n\t\tconst entries: Record<string, CatalogueMessages[string]> =\n\t\t\tObject.create(null);\n\t\tfor (const code of clientCodes) {\n\t\t\tconst entry = messages.messageOf(language, code);\n\t\t\tif (entry) entries[code] = entry;\n\t\t}\n\t\tbyLanguage[language] = entries;\n\t}\n\treturn byLanguage;\n}\n\n/**\n * Keeps the API's error catalogue in `messages`: read on first use, checked\n * against the API's versions once per TTL, and re-read only for the\n * languages whose version moved. It is an instance, not module state.\n */\nexport function createErrorCatalogue<L extends string>({\n\tmessages,\n\tlanguages,\n\tread,\n\tversions,\n\tttlMs,\n\tretryMs = 5_000,\n\tfirstReadWaitMs = 1_500,\n\tclientCodes,\n\tlog: appLog = console,\n}: ErrorCatalogueOptions<L>): ErrorCatalogue<L> {\n\tif (languages.length === 0) {\n\t\tthrow new TypeError('createErrorCatalogue(): needs at least one language.');\n\t}\n\tconst log = quietLog(appLog, ['error']);\n\tconst ttl = safeTtl(ttlMs, retryMs, log);\n\tconst reader = createCatalogueReader({\n\t\tmessages,\n\t\tread,\n\t\tretryMs,\n\t\tfirstReadWaitMs,\n\t\tlog,\n\t});\n\tconst context = { reader, versions, ttl, retryMs, log };\n\tlet checking: Promise<void> | undefined;\n\n\tasync function fresh(language: L, now: number = Date.now()) {\n\t\tconst entry = reader.held.get(language);\n\t\tif (!entry) return reader.first(language, now);\n\t\tif (now - entry.checkedAt >= ttl() && !checking) {\n\t\t\tchecking = checkVersions(context, now)\n\t\t\t\t.finally(() => {\n\t\t\t\t\tchecking = undefined;\n\t\t\t\t})\n\t\t\t\t.catch(() => {});\n\t\t}\n\t}\n\n\tconst freshAll = async (now: number = Date.now()) => {\n\t\tawait Promise.all(languages.map((language) => fresh(language, now)));\n\t};\n\n\treturn {\n\t\tfresh,\n\t\tfreshAll,\n\t\twarm() {\n\t\t\tfreshAll().catch((error) => {\n\t\t\t\tlog.error(\n\t\t\t\t\t'alxia-react-router: the error catalogue was not warmed',\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t});\n\t\t},\n\t\tclientMessages: () => clientMessages(messages, languages, clientCodes),\n\t\treset() {\n\t\t\treader.reset();\n\t\t\tchecking = undefined;\n\t\t\tmessages.clear();\n\t\t},\n\t\theldVersion: (language) => reader.held.get(language)?.version,\n\t\tsettled: () => checking ?? Promise.resolve(),\n\t};\n}\n",
|
|
17
|
+
"import { data, redirect } from 'react-router';\nimport { nextOf } from './page-path';\nimport { rememberSiteCheck, siteCheck } from './same-site';\nimport type { InferOutput, StandardSchemaV1 } from './standard-schema';\n\nexport interface JsonActionsOptions {\n\t/**\n\t * The origin a request must come from, such as `https://app.example.com`:\n\t * required behind a TLS-terminating proxy, where the request's own URL\n\t * says `http:`. A getter is read at each request. Else the request's own\n\t * origin.\n\t */\n\torigin?: string | (() => string | undefined);\n}\n\n/** The actions' JSON helpers, bound to one app's origin. */\nexport interface JsonActions {\n\t/**\n\t * The JSON body an action was posted, refused unless it comes from this\n\t * site: 403 for another origin or a cross-site fetch, 415 for a body that\n\t * is not `application/json`, 400 for malformed JSON.\n\t */\n\treadJson(request: Request): Promise<unknown>;\n\t/**\n\t * For the actions a form posts to: a native post (before hydration) goes\n\t * back to its page, which then posts JSON. A JSON post goes on.\n\t */\n\trequireJsonPost(request: Request): void;\n\t/**\n\t * The `input` of the JSON body `{ input }`, checked against a Standard\n\t * Schema (Zod 4, Valibot, ArkType), whose validation may be async. A\n\t * refused input is a 400.\n\t */\n\treadInput<S extends StandardSchemaV1>(\n\t\trequest: Request,\n\t\tschema: S,\n\t): Promise<InferOutput<S>>;\n}\n\n/**\n * Every action takes JSON: a cross-site page can only post a form or\n * `text/plain` without a preflight, so requiring `application/json` and a\n * same-origin `Origin` (or `Sec-Fetch-Site`) stops CSRF before the session\n * cookie's `SameSite` is even consulted.\n */\nexport function jsonActions(options: JsonActionsOptions = {}): JsonActions {\n\tconst crossSite = siteCheck(options.origin);\n\tconst isJson = (request: Request) =>\n\t\trequest.headers.get('content-type')?.startsWith('application/json');\n\n\tasync function readJson(request: Request): Promise<unknown> {\n\t\tcrossSite(request);\n\t\tif (!isJson(request)) {\n\t\t\tthrow data('Expected a JSON body', { status: 415 });\n\t\t}\n\t\treturn request.json().catch(() => {\n\t\t\tthrow data('Malformed JSON body', { status: 400 });\n\t\t});\n\t}\n\n\tconst actions: JsonActions = {\n\t\treadJson,\n\t\trequireJsonPost(request) {\n\t\t\tif (!isJson(request)) throw redirect(nextOf(request.url));\n\t\t},\n\t\tasync readInput(request, schema) {\n\t\t\tconst body = (await readJson(request)) as { input?: unknown } | null;\n\t\t\tconst result = await schema['~standard'].validate(body?.input);\n\t\t\tif (result.issues) {\n\t\t\t\tthrow data('The form sent an input the API would refuse', {\n\t\t\t\t\tstatus: 400,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn result.value as InferOutput<typeof schema>;\n\t\t},\n\t};\n\trememberSiteCheck(actions, crossSite);\n\treturn actions;\n}\n",
|
|
18
|
+
"import type { CatalogueMessage } from './messages';\n\n/** The values a formatter takes: what ICU arguments can be. */\nexport type MessageValues = Readonly<\n\tRecord<string, string | number | boolean | object>\n>;\n\nconst DAY = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\n\n/** A local `Date` built from the calendar parts of a `YYYY-MM-DD`: no time-zone shift. */\nfunction dayOf(value: string): Date | undefined {\n\tconst parts = DAY.exec(value);\n\tif (!parts) return undefined;\n\treturn new Date(Number(parts[1]), Number(parts[2]) - 1, Number(parts[3]));\n}\n\n/**\n * The values as the message formats them: a `YYYY-MM-DD` the message names\n * as a date becomes a local `Date` (by calendar parts, so the day is the\n * same in every time zone), a count or number given as a numeric string a\n * number. Everything else passes as it is.\n */\nexport function valuesFor(\n\tparams: CatalogueMessage['params'],\n\tvalues: Readonly<Record<string, unknown>>,\n): MessageValues {\n\tconst worded: Record<string, unknown> = { ...values };\n\tfor (const { name, kind } of params) {\n\t\tconst value = values[name];\n\t\tif (typeof value !== 'string') continue;\n\t\tif (kind === 'DATE') {\n\t\t\tconst day = dayOf(value);\n\t\t\tif (day) worded[name] = day;\n\t\t} else if (\n\t\t\t(kind === 'NUMBER' || kind === 'PLURAL') &&\n\t\t\tvalue.trim() !== '' &&\n\t\t\t!Number.isNaN(Number(value))\n\t\t) {\n\t\t\tworded[name] = Number(value);\n\t\t}\n\t}\n\treturn worded as MessageValues;\n}\n",
|
|
19
|
+
"import { type MessageValues, valuesFor } from './message-values';\n\nexport type { MessageValues } from './message-values';\n\n/** How a message uses an argument (the API's `ErrorParamKind`). */\nexport type ParamKind = 'TEXT' | 'NUMBER' | 'DATE' | 'PLURAL' | 'SELECT';\n\n/**\n * One text of the API's error catalogue: the uninterpolated ICU message and\n * the arguments it names, which say what to supply as a date or a number\n * without parsing the message.\n */\nexport type CatalogueMessage = {\n\tmessage: string;\n\tparams: ReadonlyArray<{ name: string; kind: ParamKind }>;\n};\n\n/** A language's messages by API code (`<module>.errors.<slug>`). */\nexport type CatalogueMessages = Readonly<Record<string, CatalogueMessage>>;\n\n/**\n * Formats an ICU message for a language: plurals, numbers and dates of that\n * language. `@nxgt/material`'s `formatMessage` is one, as it is. It reports\n * a message it could not format (a missing value, a stray brace) to\n * `onError` instead of throwing.\n */\nexport type MessageFormat<L extends string> = (\n\tmessage: string,\n\tlanguage: L,\n\tvalues: MessageValues,\n\toptions: { onError(error: unknown): void },\n) => string;\n\nexport interface ApiMessagesOptions<L extends string> {\n\t/** The app's ICU formatter: the same engine as its translator, so both word alike. */\n\tformat: MessageFormat<L>;\n}\n\n/** The catalogue the page words refusals with, by language. */\nexport interface ApiMessages<L extends string> {\n\t/** Replaces a language's messages (a server's whole catalogue). */\n\tset(language: L, messages: CatalogueMessages): void;\n\t/** Adds messages to a language's (a browser's, from the root's data). */\n\tadd(language: L, messages: CatalogueMessages): void;\n\t/** Forgets every message (tests). */\n\tclear(): void;\n\t/** The message the catalogue holds for a code in a language, if any. */\n\tmessageOf(language: L, code: string): CatalogueMessage | undefined;\n\t/**\n\t * A message formatted for `language` with `values`. Undefined when it\n\t * cannot be formatted with those values (a missing argument, a day it\n\t * cannot read) or does not parse.\n\t */\n\tformat(\n\t\tentry: CatalogueMessage,\n\t\tvalues: Readonly<Record<string, unknown>> | undefined,\n\t\tlanguage: L,\n\t): string | undefined;\n\t/**\n\t * The catalogue's text of an API code in `language`, with `values`\n\t * (`extensions.params`) filled in. Undefined when the catalogue has no\n\t * such code or the message cannot be formatted, so the caller falls back\n\t * to the message the API already worded.\n\t */\n\tapiMessage(\n\t\tcode: string,\n\t\tvalues: Readonly<Record<string, unknown>> | undefined,\n\t\tlanguage: L,\n\t): string | undefined;\n}\n\n/**\n * A catalogue store for the languages `L`. It is an instance, not module\n * state: two copies of the package never split it, and a spec makes its own.\n * Make one per app, in a module of its own, and share it with\n * `apiCodeResolver` and `ApiMessagesProvider`.\n */\nexport function createApiMessages<L extends string>({\n\tformat,\n}: ApiMessagesOptions<L>): ApiMessages<L> {\n\tconst catalogues = new Map<L, Map<string, CatalogueMessage>>();\n\n\tconst messageOf = (language: L, code: string) =>\n\t\tcatalogues.get(language)?.get(code);\n\n\tfunction formatEntry(\n\t\tentry: CatalogueMessage,\n\t\tvalues: Readonly<Record<string, unknown>> | undefined,\n\t\tlanguage: L,\n\t) {\n\t\tconst worded = valuesFor(entry.params, values ?? {});\n\t\t// A message that did not format is reported here, not logged: the\n\t\t// caller falls back.\n\t\tlet failed = false;\n\t\ttry {\n\t\t\tconst text = format(entry.message, language, worded, {\n\t\t\t\tonError: () => {\n\t\t\t\t\tfailed = true;\n\t\t\t\t},\n\t\t\t});\n\t\t\treturn failed ? undefined : text;\n\t\t} catch {\n\t\t\t// An app's formatter that throws is a message that did not format.\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\treturn {\n\t\tset(language, messages) {\n\t\t\tcatalogues.set(language, new Map(Object.entries(messages)));\n\t\t},\n\t\tadd(language, messages) {\n\t\t\tconst held = catalogues.get(language) ?? new Map();\n\t\t\tfor (const [code, message] of Object.entries(messages)) {\n\t\t\t\theld.set(code, message);\n\t\t\t}\n\t\t\tcatalogues.set(language, held);\n\t\t},\n\t\tclear() {\n\t\t\tcatalogues.clear();\n\t\t},\n\t\tmessageOf,\n\t\tformat: formatEntry,\n\t\tapiMessage(code, values, language) {\n\t\t\tconst entry = messageOf(language, code);\n\t\t\treturn entry ? formatEntry(entry, values, language) : undefined;\n\t\t},\n\t};\n}\n",
|
|
20
|
+
"import type { ReactNode } from 'react';\nimport type { ApiMessages, CatalogueMessages } from './messages';\n\nexport interface ApiMessagesProviderProps<L extends string> {\n\t/** The store `apiCodeResolver` reads. */\n\tmessages: ApiMessages<L>;\n\t/** The messages the root's data carries, by language. */\n\tvalue: Readonly<Record<L, CatalogueMessages>> | undefined;\n\tchildren: ReactNode;\n}\n\n/**\n * Fills the browser's catalogue with the messages the root's data carries\n * (the few its forms word), before the children render: `apiCodeResolver`\n * reads them synchronously. A server render writes nothing: the server's\n * store holds the whole, fresher catalogue, and a render's data may be older\n * than it. It is a plain function (no JSX, no React runtime): use it as\n * `ApiMessagesProvider({ messages, value, children })` from a component, or\n * as an element's type.\n */\nexport function ApiMessagesProvider<L extends string>({\n\tmessages,\n\tvalue,\n\tchildren,\n}: ApiMessagesProviderProps<L>): ReactNode {\n\tconst inBrowser =\n\t\ttypeof (globalThis as { document?: unknown }).document !== 'undefined';\n\tif (value && inBrowser) {\n\t\tfor (const [language, held] of Object.entries<CatalogueMessages>(value)) {\n\t\t\tmessages.add(language as L, held);\n\t\t}\n\t}\n\treturn children;\n}\n",
|
|
21
|
+
"import { data } from 'react-router';\nimport type { ApiErrors } from './api-errors';\nimport { formRefusal } from './form-refusal';\n\n/**\n * What a record route's action answers to one posted section (`intent`):\n * done, or refused with the form's message, the messages by form field, and\n * whether someone changed the record since it was read. Built by\n * `sectionAction`, read by `useSectionSave` and `useRowSave`\n * (`@softistx/alxia-react-router/fetcher`).\n */\nexport type SectionResult =\n\t| { ok: true; intent: string }\n\t| {\n\t\t\tok: false;\n\t\t\tintent: string;\n\t\t\t/** The message for the form as a whole; empty when every issue found its field. */\n\t\t\terror: string;\n\t\t\t/** Messages by form field, already translated. */\n\t\t\tfieldErrors: Record<string, string>;\n\t\t\t/** Whether the API refused because the record changed since it was read. */\n\t\t\tstale: boolean;\n\t };\n\n/** What `sectionAction` takes besides the write. */\nexport interface SectionActionOptions {\n\t/** The form field an input path of the API's refusal belongs under, or `undefined` for none. */\n\tfieldOf: (path: string) => string | undefined;\n\t/** Whether the failure is the API's version conflict (the app's own check of its error). */\n\tisStale: (error: unknown) => boolean;\n}\n\n/**\n * Runs one section's write for a route's action: `{ ok: true, intent }`, or\n * the refusal `useSectionSave` shows (the API's field issues under the form\n * fields `fieldOf` names, a version conflict flagged by `isStale`), answered\n * with the refusal's status. A 401 and any other failure are thrown for the\n * error page, as `formRefusal` does.\n */\nexport async function sectionAction<L extends string>(\n\terrors: Pick<ApiErrors<L>, 'apiRefusal' | 'fieldErrors'>,\n\tlanguage: L,\n\tintent: string,\n\trun: () => Promise<unknown>,\n\t{ fieldOf, isStale }: SectionActionOptions,\n) {\n\ttry {\n\t\tawait run();\n\t\treturn { ok: true, intent } satisfies SectionResult;\n\t} catch (error) {\n\t\tconst { status, ...refusal } = formR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AI,SAAS,WAAW;AAAA,IACvB,YAAY,UAAU,SAAS,OAAO,QAA2B,KAAK,GAAG;AAAA,MACxE,SAAS,IAAI,UAAe,IAAI;AAAA,IACjC;AAAA,EACD;AAAA,EACA,OAAO;AAAA;;AChCR,iBAAS;AAuCF,eAAe,aAA+B,CACpD,QACA,UACA,QACA,OACE,SAAS,WACV;AAAA,EACD,IAAI;AAAA,IACH,MAAM,IAAI;AAAA,IACV,OAAO,EAAE,IAAI,MAAM,OAAO;AAAA,IACzB,OAAO,OAAO;AAAA,IACf,QAAQ,WAAW,YAAY,YAC9B,QACA,OACA,UACA,OACD;AAAA,IACA,OAAO,MACN;AAAA,MACC,IAAI;AAAA,MACJ;AAAA,MACA,OAAO,QAAQ,KAAK;AAAA,SACjB;AAAA,IACJ,GACA,EAAE,OAAO,CACV;AAAA;AAAA;",
|
|
24
|
+
"debugId": "29CC739BED3AAC8864756E2164756E21",
|
|
25
|
+
"names": []
|
|
26
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { InferOutput, StandardSchemaV1 } from './standard-schema';
|
|
2
|
+
export interface JsonActionsOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The origin a request must come from, such as `https://app.example.com`:
|
|
5
|
+
* required behind a TLS-terminating proxy, where the request's own URL
|
|
6
|
+
* says `http:`. A getter is read at each request. Else the request's own
|
|
7
|
+
* origin.
|
|
8
|
+
*/
|
|
9
|
+
origin?: string | (() => string | undefined);
|
|
10
|
+
}
|
|
11
|
+
/** The actions' JSON helpers, bound to one app's origin. */
|
|
12
|
+
export interface JsonActions {
|
|
13
|
+
/**
|
|
14
|
+
* The JSON body an action was posted, refused unless it comes from this
|
|
15
|
+
* site: 403 for another origin or a cross-site fetch, 415 for a body that
|
|
16
|
+
* is not `application/json`, 400 for malformed JSON.
|
|
17
|
+
*/
|
|
18
|
+
readJson(request: Request): Promise<unknown>;
|
|
19
|
+
/**
|
|
20
|
+
* For the actions a form posts to: a native post (before hydration) goes
|
|
21
|
+
* back to its page, which then posts JSON. A JSON post goes on.
|
|
22
|
+
*/
|
|
23
|
+
requireJsonPost(request: Request): void;
|
|
24
|
+
/**
|
|
25
|
+
* The `input` of the JSON body `{ input }`, checked against a Standard
|
|
26
|
+
* Schema (Zod 4, Valibot, ArkType), whose validation may be async. A
|
|
27
|
+
* refused input is a 400.
|
|
28
|
+
*/
|
|
29
|
+
readInput<S extends StandardSchemaV1>(request: Request, schema: S): Promise<InferOutput<S>>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Every action takes JSON: a cross-site page can only post a form or
|
|
33
|
+
* `text/plain` without a preflight, so requiring `application/json` and a
|
|
34
|
+
* same-origin `Origin` (or `Sec-Fetch-Site`) stops CSRF before the session
|
|
35
|
+
* cookie's `SameSite` is even consulted.
|
|
36
|
+
*/
|
|
37
|
+
export declare function jsonActions(options?: JsonActionsOptions): JsonActions;
|
|
38
|
+
//# sourceMappingURL=json-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-actions.d.ts","sourceRoot":"","sources":["../../src/errors/json-actions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC;CAC7C;AAED,4DAA4D;AAC5D,MAAM,WAAW,WAAW;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7C;;;OAGG;IACH,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxC;;;;OAIG;IACH,SAAS,CAAC,CAAC,SAAS,gBAAgB,EACnC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,CAAC,GACP,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,WAAW,CAiCzE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The methods of a `console` a report goes through. */
|
|
2
|
+
export type LogMethod = 'warn' | 'error';
|
|
3
|
+
/**
|
|
4
|
+
* A log whose methods can throw without breaking what reports through
|
|
5
|
+
* them: a broken app log must not turn a handled failure into a rejection.
|
|
6
|
+
*/
|
|
7
|
+
export declare function quietLog<M extends LogMethod>(log: Pick<Console, M>, methods: readonly M[]): Pick<Console, M>;
|
|
8
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/errors/log.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAEzC;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,SAAS,EAC3C,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,EACrB,OAAO,EAAE,SAAS,CAAC,EAAE,GACnB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAYlB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CatalogueMessage } from './messages';
|
|
2
|
+
/** The values a formatter takes: what ICU arguments can be. */
|
|
3
|
+
export type MessageValues = Readonly<Record<string, string | number | boolean | object>>;
|
|
4
|
+
/**
|
|
5
|
+
* The values as the message formats them: a `YYYY-MM-DD` the message names
|
|
6
|
+
* as a date becomes a local `Date` (by calendar parts, so the day is the
|
|
7
|
+
* same in every time zone), a count or number given as a numeric string a
|
|
8
|
+
* number. Everything else passes as it is.
|
|
9
|
+
*/
|
|
10
|
+
export declare function valuesFor(params: CatalogueMessage['params'], values: Readonly<Record<string, unknown>>): MessageValues;
|
|
11
|
+
//# sourceMappingURL=message-values.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-values.d.ts","sourceRoot":"","sources":["../../src/errors/message-values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,+DAA+D;AAC/D,MAAM,MAAM,aAAa,GAAG,QAAQ,CACnC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC,CAClD,CAAC;AAWF;;;;;GAKG;AACH,wBAAgB,SAAS,CACxB,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACvC,aAAa,CAiBf"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type MessageValues } from './message-values';
|
|
2
|
+
export type { MessageValues } from './message-values';
|
|
3
|
+
/** How a message uses an argument (the API's `ErrorParamKind`). */
|
|
4
|
+
export type ParamKind = 'TEXT' | 'NUMBER' | 'DATE' | 'PLURAL' | 'SELECT';
|
|
5
|
+
/**
|
|
6
|
+
* One text of the API's error catalogue: the uninterpolated ICU message and
|
|
7
|
+
* the arguments it names, which say what to supply as a date or a number
|
|
8
|
+
* without parsing the message.
|
|
9
|
+
*/
|
|
10
|
+
export type CatalogueMessage = {
|
|
11
|
+
message: string;
|
|
12
|
+
params: ReadonlyArray<{
|
|
13
|
+
name: string;
|
|
14
|
+
kind: ParamKind;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
/** A language's messages by API code (`<module>.errors.<slug>`). */
|
|
18
|
+
export type CatalogueMessages = Readonly<Record<string, CatalogueMessage>>;
|
|
19
|
+
/**
|
|
20
|
+
* Formats an ICU message for a language: plurals, numbers and dates of that
|
|
21
|
+
* language. `@nxgt/material`'s `formatMessage` is one, as it is. It reports
|
|
22
|
+
* a message it could not format (a missing value, a stray brace) to
|
|
23
|
+
* `onError` instead of throwing.
|
|
24
|
+
*/
|
|
25
|
+
export type MessageFormat<L extends string> = (message: string, language: L, values: MessageValues, options: {
|
|
26
|
+
onError(error: unknown): void;
|
|
27
|
+
}) => string;
|
|
28
|
+
export interface ApiMessagesOptions<L extends string> {
|
|
29
|
+
/** The app's ICU formatter: the same engine as its translator, so both word alike. */
|
|
30
|
+
format: MessageFormat<L>;
|
|
31
|
+
}
|
|
32
|
+
/** The catalogue the page words refusals with, by language. */
|
|
33
|
+
export interface ApiMessages<L extends string> {
|
|
34
|
+
/** Replaces a language's messages (a server's whole catalogue). */
|
|
35
|
+
set(language: L, messages: CatalogueMessages): void;
|
|
36
|
+
/** Adds messages to a language's (a browser's, from the root's data). */
|
|
37
|
+
add(language: L, messages: CatalogueMessages): void;
|
|
38
|
+
/** Forgets every message (tests). */
|
|
39
|
+
clear(): void;
|
|
40
|
+
/** The message the catalogue holds for a code in a language, if any. */
|
|
41
|
+
messageOf(language: L, code: string): CatalogueMessage | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* A message formatted for `language` with `values`. Undefined when it
|
|
44
|
+
* cannot be formatted with those values (a missing argument, a day it
|
|
45
|
+
* cannot read) or does not parse.
|
|
46
|
+
*/
|
|
47
|
+
format(entry: CatalogueMessage, values: Readonly<Record<string, unknown>> | undefined, language: L): string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* The catalogue's text of an API code in `language`, with `values`
|
|
50
|
+
* (`extensions.params`) filled in. Undefined when the catalogue has no
|
|
51
|
+
* such code or the message cannot be formatted, so the caller falls back
|
|
52
|
+
* to the message the API already worded.
|
|
53
|
+
*/
|
|
54
|
+
apiMessage(code: string, values: Readonly<Record<string, unknown>> | undefined, language: L): string | undefined;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A catalogue store for the languages `L`. It is an instance, not module
|
|
58
|
+
* state: two copies of the package never split it, and a spec makes its own.
|
|
59
|
+
* Make one per app, in a module of its own, and share it with
|
|
60
|
+
* `apiCodeResolver` and `ApiMessagesProvider`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function createApiMessages<L extends string>({ format, }: ApiMessagesOptions<L>): ApiMessages<L>;
|
|
63
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/errors/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,kBAAkB,CAAC;AAEjE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,mEAAmE;AACnE,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEzE;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;CACzD,CAAC;AAEF,oEAAoE;AACpE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,IAAI,CAC7C,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,CAAC,EACX,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE;IAAE,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,KACtC,MAAM,CAAC;AAEZ,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,MAAM;IACnD,sFAAsF;IACtF,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;CACzB;AAED,+DAA+D;AAC/D,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,MAAM;IAC5C,mEAAmE;IACnE,GAAG,CAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpD,yEAAyE;IACzE,GAAG,CAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpD,qCAAqC;IACrC,KAAK,IAAI,IAAI,CAAC;IACd,wEAAwE;IACxE,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC;IACnE;;;;OAIG;IACH,MAAM,CACL,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,EACrD,QAAQ,EAAE,CAAC,GACT,MAAM,GAAG,SAAS,CAAC;IACtB;;;;;OAKG;IACH,UAAU,CACT,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,EACrD,QAAQ,EAAE,CAAC,GACT,MAAM,GAAG,SAAS,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,EACnD,MAAM,GACN,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAiDxC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The page a request is for, as `next` carries it back after sign-in: its
|
|
3
|
+
* path and search, without React Router's single-fetch details. A client
|
|
4
|
+
* navigation's `request.url` is `/todos/demo/list.data?q=a&_routes=…`
|
|
5
|
+
* (`/_.data` for `/`, `?index` for an index action), as the server
|
|
6
|
+
* runtime's own `normalizeUrl` strips them.
|
|
7
|
+
*/
|
|
8
|
+
export declare function nextOf(url: string): string;
|
|
9
|
+
//# sourceMappingURL=page-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-path.d.ts","sourceRoot":"","sources":["../../src/errors/page-path.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAgB1C"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** A reply of a REST/OpenAPI client, as far as `problemError` reads it: `{ status, data }`. */
|
|
2
|
+
export interface ProblemReply {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
/** The parsed body; a problem document (RFC 9457) when the API refused. */
|
|
5
|
+
readonly data?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface ProblemErrorOptions {
|
|
8
|
+
/** The `x-request-id` the API answered (`requestIdOf(response)`). */
|
|
9
|
+
requestId?: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
/** A refusal read from a REST API's RFC 9457 problem reply. */
|
|
12
|
+
export interface ProblemErrorLike extends Error {
|
|
13
|
+
/** The HTTP status of the reply. */
|
|
14
|
+
readonly status: number;
|
|
15
|
+
/** The problem's `title`, else `Error <status>`. */
|
|
16
|
+
readonly title: string;
|
|
17
|
+
/** The problem's `detail`, when it has one. */
|
|
18
|
+
readonly detail?: string | undefined;
|
|
19
|
+
/** The problem's `type` URI, when it has one. */
|
|
20
|
+
readonly type?: string | undefined;
|
|
21
|
+
/** The problem's `instance` URI, when it has one. */
|
|
22
|
+
readonly instance?: string | undefined;
|
|
23
|
+
/** The id the API logged the request under, when the caller kept it. */
|
|
24
|
+
requestId?: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The error of an RFC 9457 problem reply. Its `message` is the problem's
|
|
28
|
+
* `detail`, else its `title`, else `Error <status>`.
|
|
29
|
+
*/
|
|
30
|
+
export declare class ProblemError extends Error implements ProblemErrorLike {
|
|
31
|
+
readonly name = "ProblemError";
|
|
32
|
+
readonly status: number;
|
|
33
|
+
readonly title: string;
|
|
34
|
+
readonly detail: string | undefined;
|
|
35
|
+
readonly type: string | undefined;
|
|
36
|
+
readonly instance: string | undefined;
|
|
37
|
+
requestId: string | undefined;
|
|
38
|
+
constructor(reply: ProblemReply, { requestId }?: ProblemErrorOptions);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Turns a REST/OpenAPI client's `{ status, data }` reply into a
|
|
42
|
+
* `ProblemError`; a body that is not a problem document gives `Error <status>`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function problemError(reply: ProblemReply, options?: ProblemErrorOptions): ProblemError;
|
|
45
|
+
/**
|
|
46
|
+
* Whether `error` is a `ProblemError`, told by its name and a numeric
|
|
47
|
+
* `status`, never `instanceof`, so it holds across two copies of the package.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isProblemErrorLike(error: unknown): error is ProblemErrorLike;
|
|
50
|
+
//# sourceMappingURL=problem-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"problem-error.d.ts","sourceRoot":"","sources":["../../src/errors/problem-error.ts"],"names":[],"mappings":"AAEA,+FAA+F;AAC/F,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IACnC,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,+DAA+D;AAC/D,MAAM,WAAW,gBAAiB,SAAQ,KAAK;IAC9C,oCAAoC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,iDAAiD;IACjD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAKD;;;GAGG;AACH,qBAAa,YAAa,SAAQ,KAAM,YAAW,gBAAgB;IAClE,SAAkB,IAAI,kBAAkB;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;gBAElB,KAAK,EAAE,YAAY,EAAE,EAAE,SAAS,EAAE,GAAE,mBAAwB;CAoBxE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC3B,KAAK,EAAE,YAAY,EACnB,OAAO,CAAC,EAAE,mBAAmB,GAC3B,YAAY,CAEd;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAK5E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ApiMessages, CatalogueMessages } from './messages';
|
|
3
|
+
export interface ApiMessagesProviderProps<L extends string> {
|
|
4
|
+
/** The store `apiCodeResolver` reads. */
|
|
5
|
+
messages: ApiMessages<L>;
|
|
6
|
+
/** The messages the root's data carries, by language. */
|
|
7
|
+
value: Readonly<Record<L, CatalogueMessages>> | undefined;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Fills the browser's catalogue with the messages the root's data carries
|
|
12
|
+
* (the few its forms word), before the children render: `apiCodeResolver`
|
|
13
|
+
* reads them synchronously. A server render writes nothing: the server's
|
|
14
|
+
* store holds the whole, fresher catalogue, and a render's data may be older
|
|
15
|
+
* than it. It is a plain function (no JSX, no React runtime): use it as
|
|
16
|
+
* `ApiMessagesProvider({ messages, value, children })` from a component, or
|
|
17
|
+
* as an element's type.
|
|
18
|
+
*/
|
|
19
|
+
export declare function ApiMessagesProvider<L extends string>({ messages, value, children, }: ApiMessagesProviderProps<L>): ReactNode;
|
|
20
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/errors/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEjE,MAAM,WAAW,wBAAwB,CAAC,CAAC,SAAS,MAAM;IACzD,yCAAyC;IACzC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACzB,yDAAyD;IACzD,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,GAAG,SAAS,CAAC;IAC1D,QAAQ,EAAE,SAAS,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAAE,EACrD,QAAQ,EACR,KAAK,EACL,QAAQ,GACR,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAAG,SAAS,CASzC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The header an API echoes on every response: the id its logs carry. */
|
|
2
|
+
export declare const REQUEST_ID_HEADER = "x-request-id";
|
|
3
|
+
/** The request id a response carries, if the API sent one. */
|
|
4
|
+
export declare function requestIdOf(response: Response): string | undefined;
|
|
5
|
+
//# sourceMappingURL=request-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-id.d.ts","sourceRoot":"","sources":["../../src/errors/request-id.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD,8DAA8D;AAC9D,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAElE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a route error of the API carries to the error page: the API's code
|
|
3
|
+
* and message when it gave a code, and the `X-Request-Id` of the call as the
|
|
4
|
+
* support reference (`errorRequestId`).
|
|
5
|
+
*/
|
|
6
|
+
export type RouteErrorData = {
|
|
7
|
+
code?: string | undefined;
|
|
8
|
+
message?: string | undefined;
|
|
9
|
+
requestId?: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
export interface RouteErrorOptions {
|
|
12
|
+
/** The statuses that become a route error of their own; 401, 403, 404 and 503 by default. */
|
|
13
|
+
statuses?: ReadonlySet<number>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* What a loader throws for an error from the API: an `ApiError` whose
|
|
17
|
+
* status is routed (401, 403, 404 or 503) becomes a route error response of
|
|
18
|
+
* that status, which the root `ErrorBoundary` renders as its page, with the
|
|
19
|
+
* call's request id when the API gave one. A thrown routed `Response` that
|
|
20
|
+
* carries a request id becomes one too (a bare `Response` hands the browser
|
|
21
|
+
* its body only). Any other `ApiError` that has a request id becomes a 500
|
|
22
|
+
* with just that id, so the generic error page can show it. A `ProblemError`
|
|
23
|
+
* (`problemError`, a REST API's RFC 9457 reply) is treated alike, its message
|
|
24
|
+
* being the problem's detail or title. Anything else
|
|
25
|
+
* is returned as it is.
|
|
26
|
+
*/
|
|
27
|
+
export declare function routeError(error: unknown, { statuses }?: RouteErrorOptions): unknown;
|
|
28
|
+
/**
|
|
29
|
+
* The support reference an error page shows: the API's `X-Request-Id` a
|
|
30
|
+
* route error carries (`routeError`), if it carries one.
|
|
31
|
+
*/
|
|
32
|
+
export declare function errorRequestId(error: unknown): string | undefined;
|
|
33
|
+
//# sourceMappingURL=route-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-error.d.ts","sourceRoot":"","sources":["../../src/errors/route-error.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEF,MAAM,WAAW,iBAAiB;IACjC,6FAA6F;IAC7F,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACzB,KAAK,EAAE,OAAO,EACd,EAAE,QAAiB,EAAE,GAAE,iBAAsB,GAC3C,OAAO,CAgCT;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAMjE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** A React Router `data(body, { status })` value, as a route throws it. */
|
|
2
|
+
export type DataRefusal = {
|
|
3
|
+
type: 'DataWithResponseInit';
|
|
4
|
+
data: unknown;
|
|
5
|
+
init: {
|
|
6
|
+
status: number;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
/** What `isRouteRefusal` narrows to: a thrown `data()` with a status, or a thrown `Response`. */
|
|
10
|
+
export type RouteRefusal = DataRefusal | Response;
|
|
11
|
+
/**
|
|
12
|
+
* Whether a caught value is a route refusal: a React Router `data(body, {
|
|
13
|
+
* status })` value (what `oauthConsent`'s action throws) or a thrown
|
|
14
|
+
* `Response`. Read its status with `routeRefusalStatus`. A plain `Error`, a
|
|
15
|
+
* non-object, or a `data()` with no status is not one.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isRouteRefusal(value: unknown): value is RouteRefusal;
|
|
18
|
+
/** The status of a route refusal, or `undefined` for any other value. */
|
|
19
|
+
export declare function routeRefusalStatus(value: unknown): number | undefined;
|
|
20
|
+
//# sourceMappingURL=route-refusal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-refusal.d.ts","sourceRoot":"","sources":["../../src/errors/route-refusal.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,MAAM,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,sBAAsB,CAAC;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACzB,CAAC;AAEF,iGAAiG;AACjG,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;AAElD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAOpE;AAED,yEAAyE;AACzE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAGrE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { JsonActions } from './json-actions';
|
|
2
|
+
/** Refuses a request from another site with a 403; reads headers only. */
|
|
3
|
+
export type SiteCheck = (request: Request) => void;
|
|
4
|
+
/**
|
|
5
|
+
* The same-site rule of `readJson`: an `Origin` that is not the app's own, or
|
|
6
|
+
* a `Sec-Fetch-Site` that is neither `same-origin` nor `none`, is a 403.
|
|
7
|
+
* `origin` is the app's configured origin (or a getter), else the request's.
|
|
8
|
+
*/
|
|
9
|
+
export declare function siteCheck(origin?: string | (() => string | undefined) | undefined): SiteCheck;
|
|
10
|
+
/**
|
|
11
|
+
* Where a `jsonActions` instance keeps its site check: an enumerable property
|
|
12
|
+
* under a registered symbol, so it survives `{ ...json }` and a second copy of
|
|
13
|
+
* the package. Not public.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SITE_CHECK: unique symbol;
|
|
16
|
+
/** Puts the check on a `jsonActions` instance. */
|
|
17
|
+
export declare function rememberSiteCheck(actions: object, check: SiteCheck): void;
|
|
18
|
+
/** Whether `actions` carries a site check, as every `jsonActions()` instance does. */
|
|
19
|
+
export declare const hasSiteCheck: (actions: object) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Refuses a cross-site request with the rule of the `jsonActions` instance
|
|
22
|
+
* (its configured origin, read at each request); an object without a check
|
|
23
|
+
* gets the request's own origin. It reads headers only, never the body.
|
|
24
|
+
*/
|
|
25
|
+
export declare function refuseCrossSite(actions: object, request: Request): void;
|
|
26
|
+
/** Options of {@link requireSameSite}. */
|
|
27
|
+
export interface SameSiteOptions {
|
|
28
|
+
/**
|
|
29
|
+
* The origin a request must come from, such as `https://app.example.com`:
|
|
30
|
+
* required behind a TLS-terminating proxy, where the request's own URL
|
|
31
|
+
* says `http:`. A getter is read at each request. Else the request's own
|
|
32
|
+
* origin, which is right for a host that serves several tenants.
|
|
33
|
+
*/
|
|
34
|
+
origin?: string | (() => string | undefined);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The same-site guard for any POST, a native form or JSON: throws a 403
|
|
38
|
+
* `Cross-site request refused` for an `Origin` that is not the app's own
|
|
39
|
+
* (`Origin: null` and a foreign origin included) and for a `Sec-Fetch-Site`
|
|
40
|
+
* that is neither `same-origin` nor `none`. A request with no `Origin` and no
|
|
41
|
+
* `Sec-Fetch-Site` (a non-browser client, an old browser) goes on, as it does
|
|
42
|
+
* for `readJson`: CSRF is a browser attack, and a browser sends one of them.
|
|
43
|
+
* It reads headers only, never the body, so the form can still be read after.
|
|
44
|
+
*
|
|
45
|
+
* Pass a `jsonActions()` instance to apply its configured origin, or
|
|
46
|
+
* `{ origin }`; else the request's own origin is the reference.
|
|
47
|
+
*/
|
|
48
|
+
export declare function requireSameSite(request: Request, from?: JsonActions | SameSiteOptions): void;
|
|
49
|
+
//# sourceMappingURL=same-site.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"same-site.d.ts","sourceRoot":"","sources":["../../src/errors/same-site.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,0EAA0E;AAC1E,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,SAAS,CACxB,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,GACtD,SAAS,CAOX;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,eAEtB,CAAC;AAEF,kDAAkD;AAClD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAMzE;AAED,sFAAsF;AACtF,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,OACwB,CAAC;AAExE;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAGvE;AAED,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC/B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC;CAC7C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC9B,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,WAAW,GAAG,eAAe,GAClC,IAAI,CAMN"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ApiErrors } from './api-errors';
|
|
2
|
+
/**
|
|
3
|
+
* What a record route's action answers to one posted section (`intent`):
|
|
4
|
+
* done, or refused with the form's message, the messages by form field, and
|
|
5
|
+
* whether someone changed the record since it was read. Built by
|
|
6
|
+
* `sectionAction`, read by `useSectionSave` and `useRowSave`
|
|
7
|
+
* (`@softistx/alxia-react-router/fetcher`).
|
|
8
|
+
*/
|
|
9
|
+
export type SectionResult = {
|
|
10
|
+
ok: true;
|
|
11
|
+
intent: string;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
intent: string;
|
|
15
|
+
/** The message for the form as a whole; empty when every issue found its field. */
|
|
16
|
+
error: string;
|
|
17
|
+
/** Messages by form field, already translated. */
|
|
18
|
+
fieldErrors: Record<string, string>;
|
|
19
|
+
/** Whether the API refused because the record changed since it was read. */
|
|
20
|
+
stale: boolean;
|
|
21
|
+
};
|
|
22
|
+
/** What `sectionAction` takes besides the write. */
|
|
23
|
+
export interface SectionActionOptions {
|
|
24
|
+
/** The form field an input path of the API's refusal belongs under, or `undefined` for none. */
|
|
25
|
+
fieldOf: (path: string) => string | undefined;
|
|
26
|
+
/** Whether the failure is the API's version conflict (the app's own check of its error). */
|
|
27
|
+
isStale: (error: unknown) => boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Runs one section's write for a route's action: `{ ok: true, intent }`, or
|
|
31
|
+
* the refusal `useSectionSave` shows (the API's field issues under the form
|
|
32
|
+
* fields `fieldOf` names, a version conflict flagged by `isStale`), answered
|
|
33
|
+
* with the refusal's status. A 401 and any other failure are thrown for the
|
|
34
|
+
* error page, as `formRefusal` does.
|
|
35
|
+
*/
|
|
36
|
+
export declare function sectionAction<L extends string>(errors: Pick<ApiErrors<L>, 'apiRefusal' | 'fieldErrors'>, language: L, intent: string, run: () => Promise<unknown>, { fieldOf, isStale }: SectionActionOptions): Promise<import("react-router").UNSAFE_DataWithResponseInit<{
|
|
37
|
+
error: string;
|
|
38
|
+
fieldErrors: Record<string, string>;
|
|
39
|
+
ok: false;
|
|
40
|
+
intent: string;
|
|
41
|
+
stale: boolean;
|
|
42
|
+
}> | {
|
|
43
|
+
ok: true;
|
|
44
|
+
intent: string;
|
|
45
|
+
}>;
|
|
46
|
+
//# sourceMappingURL=section-action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-action.d.ts","sourceRoot":"","sources":["../../src/errors/section-action.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GACtB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC5B;IACA,EAAE,EAAE,KAAK,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,4EAA4E;IAC5E,KAAK,EAAE,OAAO,CAAC;CACd,CAAC;AAEL,oDAAoD;AACpD,MAAM,WAAW,oBAAoB;IACpC,gGAAgG;IAChG,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAC9C,4FAA4F;IAC5F,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;CACrC;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,CAAC,SAAS,MAAM,EACnD,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC,EACxD,QAAQ,EAAE,CAAC,EACX,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EAC3B,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,oBAAoB;;;;;;;;;GAsB1C"}
|