@softistx/alxia-react-router 0.0.0-stage → 0.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lists/connection-page.ts", "../src/lists/nodes-of.ts", "../src/lists/or-failed.ts", "../src/lists/use-paged-rows.ts", "../src/lists/use-same-route-loading.ts", "../src/lists/use-search-change.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/** What `fetchPage` answers: the rows it read and the connection they came from. */\nexport type ConnectionSlice<Row> = {\n\trows: readonly Row[];\n\tconnection: {\n\t\ttotalCount: number;\n\t\tpageInfo: { hasNextPage: boolean; endCursor?: string | null };\n\t};\n};\n\n/** Reads at most `first` rows after the cursor `after` (`null` for the start). */\nexport type FetchConnectionPage<Row> = (\n\tfirst: number,\n\tafter: string | null,\n) => Promise<ConnectionSlice<Row>>;\n\n/** The options of {@link connectionPage}. */\nexport type ConnectionPageOptions = {\n\t/** The API's cap on `first`; no call asks for more. Default `100`. */\n\tmaxFirst?: number;\n};\n\n/** One numbered page of a cursor-paged connection. */\nexport type ConnectionPage<Row> = {\n\t/** The rows of `page` alone, at most `pageSize`. */\n\trows: Row[];\n\t/** The connection's `totalCount`, from its last answer. */\n\ttotal: number;\n\t/** The page served: the one wanted, or the last when it was past it. */\n\tpage: number;\n\t/**\n\t * `ceil(total / pageSize)`, at least `1`; counted from the rows read when\n\t * the connection ended before `totalCount` said it would.\n\t */\n\tpageCount: number;\n\t/** How many rows come before `page`: `(page - 1) * pageSize`. */\n\tskip: number;\n};\n\n/** The default cap on `first`. */\nexport const DEFAULT_MAX_FIRST = 100;\n\nfunction positiveInteger(name: string, value: number): void {\n\tif (!Number.isInteger(value) || value < 1)\n\t\tthrow new RangeError(\n\t\t\t`connectionPage(): ${name} must be an integer of at least 1; got ${value}`,\n\t\t);\n}\n\n/**\n * Serves numbered pages (`?page=3`) over a connection paged by cursor\n * (`first`/`after`, `pageInfo.endCursor`, `totalCount`): calls\n * `fetchPage(first, after)` from the start, following `endCursor`, until\n * `wanted` is filled or the connection ends, never asking more than\n * `maxFirst` rows at once. A `wanted` page past the last one gives the last\n * page; when the connection ends before `totalCount` says it should, the\n * last page is counted from the rows read. `fetchPage`'s errors pass through.\n *\n * Throws a `RangeError` when `wanted`, `pageSize` or `maxFirst` is not an\n * integer of at least 1.\n */\nexport async function connectionPage<Row>(\n\twanted: number,\n\tpageSize: number,\n\tfetchPage: FetchConnectionPage<Row>,\n\toptions: ConnectionPageOptions = {},\n): Promise<ConnectionPage<Row>> {\n\tconst maxFirst = options.maxFirst ?? DEFAULT_MAX_FIRST;\n\tpositiveInteger('wanted', wanted);\n\tpositiveInteger('pageSize', pageSize);\n\tpositiveInteger('maxFirst', maxFirst);\n\n\tlet end = wanted * pageSize;\n\tconst rows: Row[] = [];\n\tlet after: string | null = null;\n\tlet total = 0;\n\tfor (;;) {\n\t\tconst result: ConnectionSlice<Row> = await fetchPage(\n\t\t\tMath.min(maxFirst, end - rows.length),\n\t\t\tafter,\n\t\t);\n\t\trows.push(...result.rows);\n\t\tconst count = result.connection.totalCount;\n\t\ttotal = Number.isFinite(count) && count >= 0 ? count : rows.length;\n\t\t// a page past the last: read no further than the last page\n\t\tend = Math.min(end, Math.max(Math.ceil(total / pageSize), 1) * pageSize);\n\t\tconst next: string | null = result.connection.pageInfo.endCursor ?? null;\n\t\tif (\n\t\t\trows.length >= end ||\n\t\t\t!result.connection.pageInfo.hasNextPage ||\n\t\t\t!next ||\n\t\t\tnext === after ||\n\t\t\tresult.rows.length === 0\n\t\t)\n\t\t\tbreak;\n\t\tafter = next;\n\t}\n\n\t// a walk that ended before the page was filled read every row there is,\n\t// so the pages are counted from those rows, whatever totalCount claimed\n\tconst known = rows.length < end ? rows.length : total;\n\tconst pageCount = Math.max(Math.ceil(known / pageSize), 1);\n\tconst page = Math.min(wanted, pageCount);\n\tconst skip = (page - 1) * pageSize;\n\treturn {\n\t\trows: rows.slice(skip, skip + pageSize),\n\t\ttotal,\n\t\tpage,\n\t\tpageCount,\n\t\tskip,\n\t};\n}\n",
|
|
6
|
+
"/**\n * A connection as {@link nodesOf} reads it: its `edges`, each with a `node`.\n * Relay's other fields (`cursor`, `pageInfo`, `totalCount`) are accepted and\n * ignored, so an inline literal that carries them type-checks.\n */\nexport type EdgesConnection<Node> = {\n\treadonly edges?:\n\t\t| readonly (\n\t\t\t\t| { readonly node?: Node | null; readonly cursor?: unknown }\n\t\t\t\t| null\n\t\t\t\t| undefined\n\t\t )[]\n\t\t| null;\n\treadonly pageInfo?: unknown;\n\treadonly totalCount?: unknown;\n};\n\n/**\n * The nodes of a GraphQL connection (`edges { node }`), in its order: `[]`\n * for a `null` or `undefined` connection (a refused or missing read) and for\n * a `null` or missing `edges`; a `null` edge or node is skipped. Always a new\n * array, so the caller may change it.\n */\nexport function nodesOf<Node>(\n\tconnection: EdgesConnection<Node> | null | undefined,\n): Node[] {\n\tconst nodes: Node[] = [];\n\tfor (const edge of connection?.edges ?? []) {\n\t\tconst node = edge?.node;\n\t\tif (node !== null && node !== undefined) nodes.push(node);\n\t}\n\treturn nodes;\n}\n",
|
|
7
|
+
"/** What a loader answers for a failed cursor page: no rows, so `usePagedRows` sets `error`. */\nexport const FAILED = Object.freeze({ failed: true as const });\n\n/** The type of {@link FAILED}. */\nexport type FailedPage = typeof FAILED;\n\n/** Whether a loader answer is {@link FAILED}. */\nexport function isFailedPage(value: unknown): value is FailedPage {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t(value as { failed?: unknown }).failed === true\n\t);\n}\n\n/**\n * The loader half of `usePagedRows`. Runs `run` and returns its answer.\n *\n * - With no `after` (the first page), an error is rethrown, so the route's\n * `ErrorBoundary` shows.\n * - With an `after` (a \"load more\"), any error becomes {@link FAILED}, so the\n * rows stay on screen with a retry, except a 3xx `Response` (a redirect),\n * which is rethrown.\n */\nexport async function orFailed<T>(\n\tafter: string | null | undefined,\n\trun: () => Promise<T> | T,\n): Promise<T | FailedPage> {\n\tif (!after) return await run();\n\ttry {\n\t\treturn await run();\n\t} catch (error) {\n\t\tif (error instanceof Response && error.status >= 300 && error.status < 400)\n\t\t\tthrow error;\n\t\treturn FAILED;\n\t}\n}\n",
|
|
8
|
+
"import { useCallback, useEffect, useRef, useState } from 'react';\nimport { useFetcher, useLocation } from 'react-router';\n\nexport interface PagedRowsOptions<Page> {\n\t/** The search parameter that carries the cursor (default `after`). */\n\treadonly cursorParam?: string;\n\t/** The cursor of the page after this one, `null` at the end (default `page.next`). */\n\treadonly nextOf?: (page: Page) => string | null;\n}\n\nexport interface PagedRows<Row> {\n\t/** The first page's rows, then the rows of each page loaded after it. */\n\treadonly rows: readonly Row[];\n\t/** The cursor of the next page, `null` when there is none. */\n\treadonly next: string | null;\n\t/** A page is being fetched. */\n\treadonly loading: boolean;\n\t/**\n\t * The last `loadMore` ended with nothing usable (the route answered something\n\t * that is not a page). The rows stay; call `loadMore` again to retry. The\n\t * next `loadMore` clears it.\n\t */\n\treadonly error: boolean;\n\t/** Fetches the page after the last one; nothing when there is none or one is on its way. */\n\treadonly loadMore: () => void;\n}\n\n/** The default cursor parameter, shared with `useSearchChange`'s default `resetKeys`. */\nexport const DEFAULT_CURSOR_PARAM = 'after';\n\ninterface Loaded<Page, Row> {\n\treadonly first: Page;\n\treadonly extra: readonly Row[];\n\treadonly next: string | null;\n\treadonly error: boolean;\n}\n\ntype NextOf<Page> = (page: Page) => string | null;\n\n/** The state for a first page: nothing loaded after it yet. */\nfunction restart<Page, Row>(\n\tfirst: Page,\n\tnextOf: NextOf<Page>,\n): Loaded<Page, Row> {\n\treturn { first, extra: [], next: nextOf(first) ?? null, error: false };\n}\n\n/**\n * The rows and cursor of `value` when it is a page (an object whose rows are\n * an array and whose cursor is a string or `null`), else `undefined`.\n */\nfunction readPage<Page, Row>(\n\tvalue: unknown,\n\trowsOf: (page: Page) => readonly Row[],\n\tnextOf: NextOf<Page>,\n): { rows: readonly Row[]; next: string | null } | undefined {\n\tif (typeof value !== 'object' || value === null) return undefined;\n\ttry {\n\t\tconst rows = rowsOf(value as Page);\n\t\tconst next = nextOf(value as Page);\n\t\tif (!Array.isArray(rows)) return undefined;\n\t\tif (next !== null && typeof next !== 'string') return undefined;\n\t\treturn { rows, next };\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** The state after an answer: its rows appended, or `error` when it was not a page. */\nfunction settle<Page, Row>(\n\tprevious: Loaded<Page, Row>,\n\tfirst: Page,\n\tmore: { rows: readonly Row[]; next: string | null } | undefined,\n\tnextOf: NextOf<Page>,\n): Loaded<Page, Row> {\n\tconst base =\n\t\tprevious.first === first ? previous : restart<Page, Row>(first, nextOf);\n\tif (more === undefined) return { ...base, error: true };\n\treturn {\n\t\t...base,\n\t\textra: [...base.extra, ...more.rows],\n\t\tnext: more.next,\n\t\terror: false,\n\t};\n}\n\n/**\n * Appends the pages a \"load more\" asks of the route the page is on. The\n * route's loader answers `?<cursorParam>=<next>` with the next page, through\n * `useFetcher`, so the address bar and the page's own data stay as they are.\n *\n * - It starts over whenever `firstPage` is another object (a new search, a\n * revalidation): the rows are the new first page's alone, in that very\n * render. A page still on its way for the old one is dropped.\n * - A failed load keeps the rows and sets `error`. A thrown loader error goes\n * to the route's `ErrorBoundary` as React Router always does; `error` covers\n * an answer that is not a page, such as `data({ message }, { status: 503 })`\n * or `null`.\n * - Data of the fetcher that is not a page (no rows, or no cursor) is ignored.\n */\nexport function usePagedRows<Page, Row>(\n\tfirstPage: Page,\n\trowsOf: (page: Page) => readonly Row[],\n\toptions: PagedRowsOptions<Page> = {},\n): PagedRows<Row> {\n\tconst cursorParam = options.cursorParam ?? DEFAULT_CURSOR_PARAM;\n\tconst nextOf: NextOf<Page> =\n\t\toptions.nextOf ??\n\t\t((page) => (page as { next?: string | null }).next as string | null);\n\tconst fetcher = useFetcher();\n\tconst { pathname, search } = useLocation();\n\tconst [loaded, setLoaded] = useState(() =>\n\t\trestart<Page, Row>(firstPage, nextOf),\n\t);\n\t// What was asked, and for which first page, so an answer that comes after a restart is dropped.\n\tconst asked = useRef<{ first: Page; seen: unknown; started: boolean } | null>(\n\t\tnull,\n\t);\n\tconst current =\n\t\tloaded.first === firstPage ? loaded : restart<Page, Row>(firstPage, nextOf);\n\n\t// Deliberate deps: rowsOf and nextOf are usually inline functions, new on\n\t// every render, and are read at the time of the answer; the effect must run\n\t// on the fetcher's settling, not on each render.\n\tuseEffect(() => {\n\t\tconst request = asked.current;\n\t\tif (request === null) return;\n\t\tif (fetcher.state !== 'idle') {\n\t\t\trequest.started = true;\n\t\t\treturn;\n\t\t}\n\t\t// Idle: the answer is in when the fetcher was seen busy, or when its data\n\t\t// is no longer the one it had at the call (an answer within one batch).\n\t\tif (!request.started && fetcher.data === request.seen) return;\n\t\tasked.current = null;\n\t\tif (request.first !== firstPage) return;\n\t\tconst more =\n\t\t\tfetcher.data === request.seen\n\t\t\t\t? undefined\n\t\t\t\t: readPage(fetcher.data, rowsOf, nextOf);\n\t\tsetLoaded((previous) => settle(previous, firstPage, more, nextOf));\n\t}, [fetcher.state, fetcher.data, firstPage]);\n\n\tconst next = current.next;\n\tconst busy = fetcher.state !== 'idle';\n\tconst { load } = fetcher;\n\tconst loadMore = useCallback(() => {\n\t\tif (next === null || busy) return;\n\t\tconst params = new URLSearchParams(search);\n\t\tparams.set(cursorParam, next);\n\t\tasked.current = { first: firstPage, seen: fetcher.data, started: false };\n\t\tsetLoaded({ ...current, error: false });\n\t\tvoid load(`${pathname}?${params}`);\n\t}, [\n\t\tnext,\n\t\tbusy,\n\t\tsearch,\n\t\tcursorParam,\n\t\tfirstPage,\n\t\tfetcher.data,\n\t\tcurrent,\n\t\tpathname,\n\t\tload,\n\t]);\n\n\treturn {\n\t\trows: [...rowsOf(firstPage), ...current.extra],\n\t\tnext,\n\t\tloading: busy,\n\t\terror: current.error,\n\t\tloadMore,\n\t};\n}\n",
|
|
9
|
+
"import { useLocation, useNavigation } from 'react-router';\n\n/**\n * `true` while a navigation is loading and goes to the pathname the page is\n * on: another search of this list, not another page. It stays `false` for a\n * navigation elsewhere (and when idle), so a list can show its skeleton\n * without flashing on a click that leaves it.\n */\nexport function useSameRouteLoading(): boolean {\n\tconst navigation = useNavigation();\n\tconst { pathname } = useLocation();\n\treturn (\n\t\tnavigation.state === 'loading' && navigation.location.pathname === pathname\n\t);\n}\n",
|
|
10
|
+
"import { useCallback } from 'react';\nimport { useSearchParams } from 'react-router';\nimport { DEFAULT_CURSOR_PARAM } from './use-paged-rows';\n\nexport interface SearchChangeOptions {\n\t/**\n\t * The parameters dropped by every change, because they only mean something\n\t * for the search they were read from (default `['after']`, a cursor).\n\t */\n\treadonly resetKeys?: readonly string[];\n}\n\nconst RESET_KEYS: readonly string[] = [DEFAULT_CURSOR_PARAM];\n\n/** What `change` takes: a record of changes, a whole search, or an updater. */\nexport type SearchChange =\n\t| Record<string, string | null | undefined>\n\t| URLSearchParams\n\t| ((prev: URLSearchParams) => URLSearchParams);\n\n/**\n * Returns `(changes) => void`. With a record it sets the parameters it is\n * given a value for, deletes the ones given `null` or `undefined` (an empty\n * string is a value, so it is set), and deletes `resetKeys` in the same step.\n * With a `URLSearchParams` it replaces the whole search by it, and with an\n * updater `(prev) => URLSearchParams` by what the updater returns; both are\n * the caller's whole search, so `resetKeys` does not apply. Every form\n * replaces the history entry and keeps the scroll position.\n */\nexport function useSearchChange(\n\toptions: SearchChangeOptions = {},\n): (changes: SearchChange) => void {\n\tconst [, setSearchParams] = useSearchParams();\n\tconst resetKeys = options.resetKeys ?? RESET_KEYS;\n\tconst joined = resetKeys.join('\\u0000');\n\treturn useCallback(\n\t\t(changes) => {\n\t\t\tconst navigation = { replace: true, preventScrollReset: true };\n\t\t\tif (typeof changes === 'function') {\n\t\t\t\tsetSearchParams(\n\t\t\t\t\t(current) => changes(new URLSearchParams(current)),\n\t\t\t\t\tnavigation,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (changes instanceof URLSearchParams) {\n\t\t\t\tsetSearchParams(new URLSearchParams(changes), navigation);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetSearchParams((current) => {\n\t\t\t\tconst next = new URLSearchParams(current);\n\t\t\t\tfor (const [key, value] of Object.entries(changes)) {\n\t\t\t\t\tif (value === null || value === undefined) next.delete(key);\n\t\t\t\t\telse next.set(key, value);\n\t\t\t\t}\n\t\t\t\tfor (const key of joined === '' ? [] : joined.split('\\u0000'))\n\t\t\t\t\tnext.delete(key);\n\t\t\t\treturn next;\n\t\t\t}, navigation);\n\t\t},\n\t\t[setSearchParams, joined],\n\t);\n}\n"
|
|
11
|
+
],
|
|
12
|
+
"mappings": ";AAuCO,IAAM,oBAAoB;AAEjC,SAAS,eAAe,CAAC,MAAc,OAAqB;AAAA,EAC3D,IAAI,CAAC,OAAO,UAAU,KAAK,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D,IAAI,OAAO,YAAY,YAAY;AAAA,MAClC,gBACC,CAAC,YAAY,QAAQ,IAAI,gBAAgB,OAAO,CAAC,GACjD,UACD;AAAA,MACA;AAAA,IACD;AAAA,IACA,IAAI,mBAAmB,iBAAiB;AAAA,MACvC,gBAAgB,IAAI,gBAAgB,OAAO,GAAG,UAAU;AAAA,MACxD;AAAA,IACD;AAAA,IACA,gBAAgB,CAAC,YAAY;AAAA,MAC5B,MAAM,OAAO,IAAI,gBAAgB,OAAO;AAAA,MACxC,YAAY,KAAK,UAAU,OAAO,QAAQ,OAAO,GAAG;AAAA,QACnD,IAAI,UAAU,QAAQ,UAAU;AAAA,UAAW,KAAK,OAAO,GAAG;AAAA,QAC1D;AAAA,UAAK,KAAK,IAAI,KAAK,KAAK;AAAA,MACzB;AAAA,MACA,WAAW,OAAO,WAAW,KAAK,CAAC,IAAI,OAAO,MAAM,MAAQ;AAAA,QAC3D,KAAK,OAAO,GAAG;AAAA,MAChB,OAAO;AAAA,OACL,UAAU;AAAA,KAEd,CAAC,iBAAiB,MAAM,CACzB;AAAA;",
|
|
13
|
+
"debugId": "E1991386278F332764756E2164756E21",
|
|
14
|
+
"names": []
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"newest-first.d.ts","sourceRoot":"","sources":["../../src/lists/newest-first.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,wBAAgB,WAAW,CAAC,CAAC,SAAS;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EAC1D,KAAK,EAAE,SAAS,CAAC,EAAE,GACjB,CAAC,EAAE,CAIL"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A connection as {@link nodesOf} reads it: its `edges`, each with a `node`.
|
|
3
|
+
* Relay's other fields (`cursor`, `pageInfo`, `totalCount`) are accepted and
|
|
4
|
+
* ignored, so an inline literal that carries them type-checks.
|
|
5
|
+
*/
|
|
6
|
+
export type EdgesConnection<Node> = {
|
|
7
|
+
readonly edges?: readonly ({
|
|
8
|
+
readonly node?: Node | null;
|
|
9
|
+
readonly cursor?: unknown;
|
|
10
|
+
} | null | undefined)[] | null;
|
|
11
|
+
readonly pageInfo?: unknown;
|
|
12
|
+
readonly totalCount?: unknown;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The nodes of a GraphQL connection (`edges { node }`), in its order: `[]`
|
|
16
|
+
* for a `null` or `undefined` connection (a refused or missing read) and for
|
|
17
|
+
* a `null` or missing `edges`; a `null` edge or node is skipped. Always a new
|
|
18
|
+
* array, so the caller may change it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function nodesOf<Node>(connection: EdgesConnection<Node> | null | undefined): Node[];
|
|
21
|
+
//# sourceMappingURL=nodes-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes-of.d.ts","sourceRoot":"","sources":["../../src/lists/nodes-of.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,eAAe,CAAC,IAAI,IAAI;IACnC,QAAQ,CAAC,KAAK,CAAC,EACZ,SAAS,CACP;QAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAC1D,IAAI,GACJ,SAAS,CACV,EAAE,GACH,IAAI,CAAC;IACR,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAC3B,UAAU,EAAE,eAAe,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GAClD,IAAI,EAAE,CAOR"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** What a loader answers for a failed cursor page: no rows, so `usePagedRows` sets `error`. */
|
|
2
|
+
export declare const FAILED: Readonly<{
|
|
3
|
+
failed: true;
|
|
4
|
+
}>;
|
|
5
|
+
/** The type of {@link FAILED}. */
|
|
6
|
+
export type FailedPage = typeof FAILED;
|
|
7
|
+
/** Whether a loader answer is {@link FAILED}. */
|
|
8
|
+
export declare function isFailedPage(value: unknown): value is FailedPage;
|
|
9
|
+
/**
|
|
10
|
+
* The loader half of `usePagedRows`. Runs `run` and returns its answer.
|
|
11
|
+
*
|
|
12
|
+
* - With no `after` (the first page), an error is rethrown, so the route's
|
|
13
|
+
* `ErrorBoundary` shows.
|
|
14
|
+
* - With an `after` (a "load more"), any error becomes {@link FAILED}, so the
|
|
15
|
+
* rows stay on screen with a retry, except a 3xx `Response` (a redirect),
|
|
16
|
+
* which is rethrown.
|
|
17
|
+
*/
|
|
18
|
+
export declare function orFailed<T>(after: string | null | undefined, run: () => Promise<T> | T): Promise<T | FailedPage>;
|
|
19
|
+
//# sourceMappingURL=or-failed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"or-failed.d.ts","sourceRoot":"","sources":["../../src/lists/or-failed.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,eAAO,MAAM,MAAM;;EAA2C,CAAC;AAE/D,kCAAkC;AAClC,MAAM,MAAM,UAAU,GAAG,OAAO,MAAM,CAAC;AAEvC,iDAAiD;AACjD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAMhE;AAED;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAC/B,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GACvB,OAAO,CAAC,CAAC,GAAG,UAAU,CAAC,CASzB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface PagedRowsOptions<Page> {
|
|
2
|
+
/** The search parameter that carries the cursor (default `after`). */
|
|
3
|
+
readonly cursorParam?: string;
|
|
4
|
+
/** The cursor of the page after this one, `null` at the end (default `page.next`). */
|
|
5
|
+
readonly nextOf?: (page: Page) => string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface PagedRows<Row> {
|
|
8
|
+
/** The first page's rows, then the rows of each page loaded after it. */
|
|
9
|
+
readonly rows: readonly Row[];
|
|
10
|
+
/** The cursor of the next page, `null` when there is none. */
|
|
11
|
+
readonly next: string | null;
|
|
12
|
+
/** A page is being fetched. */
|
|
13
|
+
readonly loading: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The last `loadMore` ended with nothing usable (the route answered something
|
|
16
|
+
* that is not a page). The rows stay; call `loadMore` again to retry. The
|
|
17
|
+
* next `loadMore` clears it.
|
|
18
|
+
*/
|
|
19
|
+
readonly error: boolean;
|
|
20
|
+
/** Fetches the page after the last one; nothing when there is none or one is on its way. */
|
|
21
|
+
readonly loadMore: () => void;
|
|
22
|
+
}
|
|
23
|
+
/** The default cursor parameter, shared with `useSearchChange`'s default `resetKeys`. */
|
|
24
|
+
export declare const DEFAULT_CURSOR_PARAM = "after";
|
|
25
|
+
/**
|
|
26
|
+
* Appends the pages a "load more" asks of the route the page is on. The
|
|
27
|
+
* route's loader answers `?<cursorParam>=<next>` with the next page, through
|
|
28
|
+
* `useFetcher`, so the address bar and the page's own data stay as they are.
|
|
29
|
+
*
|
|
30
|
+
* - It starts over whenever `firstPage` is another object (a new search, a
|
|
31
|
+
* revalidation): the rows are the new first page's alone, in that very
|
|
32
|
+
* render. A page still on its way for the old one is dropped.
|
|
33
|
+
* - A failed load keeps the rows and sets `error`. A thrown loader error goes
|
|
34
|
+
* to the route's `ErrorBoundary` as React Router always does; `error` covers
|
|
35
|
+
* an answer that is not a page, such as `data({ message }, { status: 503 })`
|
|
36
|
+
* or `null`.
|
|
37
|
+
* - Data of the fetcher that is not a page (no rows, or no cursor) is ignored.
|
|
38
|
+
*/
|
|
39
|
+
export declare function usePagedRows<Page, Row>(firstPage: Page, rowsOf: (page: Page) => readonly Row[], options?: PagedRowsOptions<Page>): PagedRows<Row>;
|
|
40
|
+
//# sourceMappingURL=use-paged-rows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-paged-rows.d.ts","sourceRoot":"","sources":["../../src/lists/use-paged-rows.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB,CAAC,IAAI;IACrC,sEAAsE;IACtE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,sFAAsF;IACtF,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,GAAG,IAAI,CAAC;CAChD;AAED,MAAM,WAAW,SAAS,CAAC,GAAG;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,CAAC;IAC9B,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,4FAA4F;IAC5F,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,yFAAyF;AACzF,eAAO,MAAM,oBAAoB,UAAU,CAAC;AA0D5C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,GAAG,EACrC,SAAS,EAAE,IAAI,EACf,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,SAAS,GAAG,EAAE,EACtC,OAAO,GAAE,gBAAgB,CAAC,IAAI,CAAM,GAClC,SAAS,CAAC,GAAG,CAAC,CAoEhB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `true` while a navigation is loading and goes to the pathname the page is
|
|
3
|
+
* on: another search of this list, not another page. It stays `false` for a
|
|
4
|
+
* navigation elsewhere (and when idle), so a list can show its skeleton
|
|
5
|
+
* without flashing on a click that leaves it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useSameRouteLoading(): boolean;
|
|
8
|
+
//# sourceMappingURL=use-same-route-loading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-same-route-loading.d.ts","sourceRoot":"","sources":["../../src/lists/use-same-route-loading.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAM7C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface SearchChangeOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The parameters dropped by every change, because they only mean something
|
|
4
|
+
* for the search they were read from (default `['after']`, a cursor).
|
|
5
|
+
*/
|
|
6
|
+
readonly resetKeys?: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
/** What `change` takes: a record of changes, a whole search, or an updater. */
|
|
9
|
+
export type SearchChange = Record<string, string | null | undefined> | URLSearchParams | ((prev: URLSearchParams) => URLSearchParams);
|
|
10
|
+
/**
|
|
11
|
+
* Returns `(changes) => void`. With a record it sets the parameters it is
|
|
12
|
+
* given a value for, deletes the ones given `null` or `undefined` (an empty
|
|
13
|
+
* string is a value, so it is set), and deletes `resetKeys` in the same step.
|
|
14
|
+
* With a `URLSearchParams` it replaces the whole search by it, and with an
|
|
15
|
+
* updater `(prev) => URLSearchParams` by what the updater returns; both are
|
|
16
|
+
* the caller's whole search, so `resetKeys` does not apply. Every form
|
|
17
|
+
* replaces the history entry and keeps the scroll position.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useSearchChange(options?: SearchChangeOptions): (changes: SearchChange) => void;
|
|
20
|
+
//# sourceMappingURL=use-search-change.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-search-change.d.ts","sourceRoot":"","sources":["../../src/lists/use-search-change.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,mBAAmB;IACnC;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC;AAID,+EAA+E;AAC/E,MAAM,MAAM,YAAY,GACrB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GACzC,eAAe,GACf,CAAC,CAAC,IAAI,EAAE,eAAe,KAAK,eAAe,CAAC,CAAC;AAEhD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC9B,OAAO,GAAE,mBAAwB,GAC/B,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CA+BjC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@softistx/alxia-react-router/mcp`: the API's MCP and OAuth endpoints served on
|
|
3
|
+
* the app's own origin, relayed to the API. Imports `@softistx/alxia-proxy` and
|
|
4
|
+
* `@softistx/alxia` (`MCP_RELAY_PATHS`).
|
|
5
|
+
*/
|
|
6
|
+
export { CONSENT_COOKIE, CONSENT_COOKIE_PLAIN, CONSENT_PATH, CONSENT_REQUEST_HEADER, } from '../oauth/binding';
|
|
7
|
+
export { type McpRelayOptions, mcpRelay } from './mcp-relay';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,sBAAsB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CONSENT_PATH2,
|
|
3
|
+
CONSENT_COOKIE2,
|
|
4
|
+
CONSENT_COOKIE_PLAIN2,
|
|
5
|
+
CONSENT_REQUEST_HEADER2,
|
|
6
|
+
consentRequestOf2,
|
|
7
|
+
consentBindingCookie2
|
|
8
|
+
} from "../chunks/index-j4ktpcke.js";
|
|
9
|
+
// src/mcp/mcp-relay.ts
|
|
10
|
+
import {
|
|
11
|
+
MCP_RELAY_PATHS,
|
|
12
|
+
originalUrl
|
|
13
|
+
} from "@softistx/alxia";
|
|
14
|
+
|
|
15
|
+
// src/mcp/relay.ts
|
|
16
|
+
import { proxy } from "@softistx/alxia-proxy";
|
|
17
|
+
function relayMiddleware(options) {
|
|
18
|
+
const { header, value } = options.secret;
|
|
19
|
+
const byPath = new Map;
|
|
20
|
+
for (const route of options.routes) {
|
|
21
|
+
const forward = proxy(options.api, {
|
|
22
|
+
timeout: options.timeout,
|
|
23
|
+
bodyLimit: route.bodyLimit,
|
|
24
|
+
headers: {
|
|
25
|
+
request: (headers, ctx) => {
|
|
26
|
+
headers.delete("cookie");
|
|
27
|
+
if (ctx.ip === undefined || ctx.ip === "") {
|
|
28
|
+
headers.delete("x-forwarded-for");
|
|
29
|
+
} else
|
|
30
|
+
headers.set("x-forwarded-for", ctx.ip);
|
|
31
|
+
headers.delete("forwarded");
|
|
32
|
+
headers.delete("x-real-ip");
|
|
33
|
+
headers.set(header, value);
|
|
34
|
+
options.request?.(headers, ctx);
|
|
35
|
+
},
|
|
36
|
+
response: (headers, ctx) => {
|
|
37
|
+
headers.delete("set-cookie");
|
|
38
|
+
options.response?.(headers, ctx);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
byPath.set(route.path, forward);
|
|
43
|
+
}
|
|
44
|
+
return (ctx, next) => {
|
|
45
|
+
const forward = byPath.get(ctx.url.pathname);
|
|
46
|
+
return forward === undefined ? next() : forward(ctx, next);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/mcp/mcp-relay.ts
|
|
51
|
+
var MCP_BODY_LIMIT = 256 * 1024;
|
|
52
|
+
var OAUTH_BODY_LIMIT = 64 * 1024;
|
|
53
|
+
var TIMEOUT = 60000;
|
|
54
|
+
function mcpRelay(options) {
|
|
55
|
+
const timeout = options.timeout ?? TIMEOUT;
|
|
56
|
+
const consent = options.consent === false ? undefined : options.consent ?? {};
|
|
57
|
+
const path = consent?.path ?? CONSENT_PATH2;
|
|
58
|
+
if (!path.startsWith("/")) {
|
|
59
|
+
throw new TypeError(`mcpRelay: consent.path must start with "/", got "${path}"`);
|
|
60
|
+
}
|
|
61
|
+
const origin = consent?.origin;
|
|
62
|
+
if (origin !== undefined && !(URL.canParse(origin) && /^https?:$/.test(new URL(origin).protocol))) {
|
|
63
|
+
throw new TypeError(`mcpRelay: consent.origin must be an http(s) origin, got "${origin}"`);
|
|
64
|
+
}
|
|
65
|
+
const middleware = relayMiddleware({
|
|
66
|
+
api: options.api,
|
|
67
|
+
secret: options.secret,
|
|
68
|
+
timeout,
|
|
69
|
+
routes: MCP_RELAY_PATHS.map((path) => ({
|
|
70
|
+
path,
|
|
71
|
+
bodyLimit: path === "/mcp" ? MCP_BODY_LIMIT : OAUTH_BODY_LIMIT
|
|
72
|
+
})),
|
|
73
|
+
response: (headers) => {
|
|
74
|
+
headers.set("content-security-policy", "default-src 'none'; frame-ancestors 'none'");
|
|
75
|
+
headers.set("x-content-type-options", "nosniff");
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const binding = consent === undefined ? undefined : async (ctx, next) => {
|
|
79
|
+
const response = await middleware(ctx, next);
|
|
80
|
+
if (ctx.url.pathname !== "/oauth/authorize")
|
|
81
|
+
return response;
|
|
82
|
+
const app = origin ?? originalUrl(ctx).origin;
|
|
83
|
+
const id = consentRequestOf2(response, app, path);
|
|
84
|
+
if (id === undefined)
|
|
85
|
+
return response;
|
|
86
|
+
const headers = new Headers(response.headers);
|
|
87
|
+
headers.append("set-cookie", consentBindingCookie2(id, new URL(app).protocol === "https:"));
|
|
88
|
+
return new Response(response.body, {
|
|
89
|
+
status: response.status,
|
|
90
|
+
statusText: response.statusText,
|
|
91
|
+
headers
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
return (app) => app.use(binding ?? middleware);
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
CONSENT_COOKIE2 as CONSENT_COOKIE,
|
|
98
|
+
CONSENT_COOKIE_PLAIN2 as CONSENT_COOKIE_PLAIN,
|
|
99
|
+
CONSENT_PATH2 as CONSENT_PATH,
|
|
100
|
+
CONSENT_REQUEST_HEADER2 as CONSENT_REQUEST_HEADER,
|
|
101
|
+
mcpRelay
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
//# debugId=2E220AC1652370D164756E2164756E21
|
|
105
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/mcp/mcp-relay.ts", "../src/mcp/relay.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import {\n\ttype Alxia,\n\ttype Empty,\n\tMCP_RELAY_PATHS,\n\toriginalUrl,\n} from '@softistx/alxia';\nimport {\n\tCONSENT_PATH,\n\tconsentBindingCookie,\n\tconsentRequestOf,\n} from '../oauth/binding';\nimport { relayMiddleware } from './relay';\n\n/** The most bytes of a request body on `/mcp`. */\nconst MCP_BODY_LIMIT = 256 * 1024;\n/** The most bytes of a request body on the OAuth endpoints. */\nconst OAUTH_BODY_LIMIT = 64 * 1024;\n/** Milliseconds the API has to send its response's headers. */\nconst TIMEOUT = 60_000;\n\nexport interface McpRelayOptions {\n\t/** The API's origin, an absolute `http://` or `https://` URL. */\n\treadonly api: string | URL;\n\t/**\n\t * The header the API checks to trust the forwarded client address and to\n\t * accept the relayed paths (`requireProxySecret` of `@softistx/alxia`), and\n\t * its secret. Set on every relayed request, over any value the client\n\t * sent.\n\t */\n\treadonly secret: { readonly header: string; readonly value: string };\n\t/** Milliseconds the API has to send its response's headers: 60 000 by default; past it, a 504. */\n\treadonly timeout?: number;\n\t/**\n\t * Binds a pending consent request to the browser that opened it: when\n\t * `/oauth/authorize` is answered with a redirect to this app's own consent\n\t * page, the answer also sets an httpOnly, `SameSite=Lax` cookie naming the\n\t * request, which `oauthConsent` reads. On by default; `false` turns it off.\n\t */\n\treadonly consent?:\n\t\t| false\n\t\t| {\n\t\t\t\t/** The consent page's path: `/oauth/consent` by default. */\n\t\t\t\treadonly path?: `/${string}`;\n\t\t\t\t/**\n\t\t\t\t * The app's public origin (`https://app.example`). Default: the\n\t\t\t\t * origin of the request, which is wrong behind a proxy that\n\t\t\t\t * ends TLS; give it then. Decides `Secure` and the `__Host-` name.\n\t\t\t\t */\n\t\t\t\treadonly origin?: string;\n\t\t };\n}\n\n/**\n * A `beforeAll` plugin relaying `MCP_RELAY_PATHS` of `@softistx/alxia` (`/mcp`,\n * `/oauth/authorize`, `/oauth/token`, `/oauth/register`, `/oauth/revoke`,\n * `/.well-known/oauth-authorization-server` and\n * `/.well-known/oauth-protected-resource/mcp`) to the API, which accepts them\n * from the relay alone with `requireProxySecret({ paths: MCP_RELAY_PATHS })`.\n * `/oauth/consent` and every other path fall through to the app.\n *\n * Authorization, Origin, the method and the body go unchanged; the Cookie\n * never goes, and no session Bearer is added. `X-Forwarded-For` is the\n * client address the app resolved, never appended to a client's copy.\n * Bodies over 256 KiB on `/mcp` and 64 KiB on `/oauth/*` are refused with a\n * 413. The response keeps its status, its streamed body, `WWW-Authenticate`\n * and `Retry-After`; its `Set-Cookie` is dropped and a restrictive\n * `Content-Security-Policy` and `X-Content-Type-Options: nosniff` are set.\n *\n * ```ts\n * createServer({\n * beforeAll: (app) =>\n * app.plugin(mcpRelay({ api: env.API_ORIGIN, secret: { header: 'x-proxy-secret', value: env.API_PROXY_SECRET } })),\n * });\n * ```\n */\nexport function mcpRelay(options: McpRelayOptions) {\n\tconst timeout = options.timeout ?? TIMEOUT;\n\tconst consent =\n\t\toptions.consent === false ? undefined : (options.consent ?? {});\n\tconst path = consent?.path ?? CONSENT_PATH;\n\tif (!path.startsWith('/')) {\n\t\tthrow new TypeError(\n\t\t\t`mcpRelay: consent.path must start with \"/\", got \"${path}\"`,\n\t\t);\n\t}\n\tconst origin = consent?.origin;\n\tif (\n\t\torigin !== undefined &&\n\t\t!(URL.canParse(origin) && /^https?:$/.test(new URL(origin).protocol))\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`mcpRelay: consent.origin must be an http(s) origin, got \"${origin}\"`,\n\t\t);\n\t}\n\tconst middleware = relayMiddleware({\n\t\tapi: options.api,\n\t\tsecret: options.secret,\n\t\ttimeout,\n\t\troutes: MCP_RELAY_PATHS.map((path) => ({\n\t\t\tpath,\n\t\t\tbodyLimit: path === '/mcp' ? MCP_BODY_LIMIT : OAUTH_BODY_LIMIT,\n\t\t})),\n\t\tresponse: (headers) => {\n\t\t\theaders.set(\n\t\t\t\t'content-security-policy',\n\t\t\t\t\"default-src 'none'; frame-ancestors 'none'\",\n\t\t\t);\n\t\t\theaders.set('x-content-type-options', 'nosniff');\n\t\t},\n\t});\n\t// Around the relay: its `Set-Cookie` removal has run by the time this adds\n\t// the app's own cookie.\n\tconst binding: typeof middleware | undefined =\n\t\tconsent === undefined\n\t\t\t? undefined\n\t\t\t: ((async (ctx, next) => {\n\t\t\t\t\tconst response = (await middleware(ctx, next)) as Response;\n\t\t\t\t\tif (ctx.url.pathname !== '/oauth/authorize') return response;\n\t\t\t\t\tconst app = origin ?? originalUrl(ctx).origin;\n\t\t\t\t\tconst id = consentRequestOf(response, app, path);\n\t\t\t\t\tif (id === undefined) return response;\n\t\t\t\t\tconst headers = new Headers(response.headers);\n\t\t\t\t\theaders.append(\n\t\t\t\t\t\t'set-cookie',\n\t\t\t\t\t\tconsentBindingCookie(id, new URL(app).protocol === 'https:'),\n\t\t\t\t\t);\n\t\t\t\t\treturn new Response(response.body, {\n\t\t\t\t\t\tstatus: response.status,\n\t\t\t\t\t\tstatusText: response.statusText,\n\t\t\t\t\t\theaders,\n\t\t\t\t\t});\n\t\t\t\t}) as typeof middleware);\n\treturn <App extends Alxia<Empty, ''>>(app: App): App =>\n\t\tapp.use(binding ?? middleware) as unknown as App;\n}\n",
|
|
6
|
+
"/**\n * The forwarding core of a BFF relay: exact paths of the app's own origin\n * sent to the API with `@softistx/alxia-proxy`, the client's cookies never sent, the\n * client address and the shared secret set rather than appended. Internal:\n * `/mcp` is its first user and a media relay can share it, passing the\n * `request` edit that adds what it needs (a session Bearer), which this\n * core never adds.\n */\nimport type { Middleware } from '@softistx/alxia';\nimport { type ProxyContext, proxy } from '@softistx/alxia-proxy';\n\n/** The most bytes a body may hold on a relayed path, 413 above. */\nexport interface RelayRoute {\n\treadonly path: `/${string}`;\n\treadonly bodyLimit: number;\n}\n\nexport interface RelayOptions {\n\t/** The API's origin, an absolute `http://` or `https://` URL. */\n\treadonly api: string | URL;\n\t/** The paths relayed, each with its body limit. Any other path falls through. */\n\treadonly routes: readonly RelayRoute[];\n\t/** The header the API checks, and its value: set on every relayed request, over any client copy. */\n\treadonly secret: { readonly header: string; readonly value: string };\n\t/** Milliseconds the API has to send its response's headers. */\n\treadonly timeout: number;\n\t/** Edits the headers the API receives, after the core's own (cookie removed, address and secret set). */\n\treadonly request?: (headers: Headers, ctx: ProxyContext) => void;\n\t/** Edits the headers the client receives. */\n\treadonly response?: (headers: Headers, ctx: ProxyContext) => void;\n}\n\n/**\n * A middleware relaying the paths of `options.routes`, exactly, whatever\n * the method, and calling `next` for every other request.\n */\nexport function relayMiddleware(options: RelayOptions): Middleware {\n\tconst { header, value } = options.secret;\n\tconst byPath = new Map<string, Middleware>();\n\tfor (const route of options.routes) {\n\t\tconst forward = proxy(options.api, {\n\t\t\ttimeout: options.timeout,\n\t\t\tbodyLimit: route.bodyLimit,\n\t\t\theaders: {\n\t\t\t\trequest: (headers, ctx) => {\n\t\t\t\t\theaders.delete('cookie');\n\t\t\t\t\t// The proxy appends to X-Forwarded-For; the API keys its limits on\n\t\t\t\t\t// the left-most entry, which the client would then choose.\n\t\t\t\t\tif (ctx.ip === undefined || ctx.ip === '') {\n\t\t\t\t\t\theaders.delete('x-forwarded-for');\n\t\t\t\t\t} else headers.set('x-forwarded-for', ctx.ip);\n\t\t\t\t\t// Other client-address headers a client could choose.\n\t\t\t\t\theaders.delete('forwarded');\n\t\t\t\t\theaders.delete('x-real-ip');\n\t\t\t\t\theaders.set(header, value);\n\t\t\t\t\toptions.request?.(headers, ctx);\n\t\t\t\t},\n\t\t\t\tresponse: (headers, ctx) => {\n\t\t\t\t\theaders.delete('set-cookie');\n\t\t\t\t\toptions.response?.(headers, ctx);\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\tbyPath.set(route.path, forward as unknown as Middleware);\n\t}\n\treturn ((ctx, next) => {\n\t\tconst forward = byPath.get(ctx.url.pathname);\n\t\treturn forward === undefined ? next() : forward(ctx, next);\n\t}) as Middleware;\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";;;;;;;;;AAAA;AAAA;AAAA;AAAA;;;ACSA;AA2BO,SAAS,eAAe,CAAC,SAAmC;AAAA,EAClE,QAAQ,QAAQ,UAAU,QAAQ;AAAA,EAClC,MAAM,SAAS,IAAI;AAAA,EACnB,WAAW,SAAS,QAAQ,QAAQ;AAAA,IACnC,MAAM,UAAU,MAAM,QAAQ,KAAK;AAAA,MAClC,SAAS,QAAQ;AAAA,MACjB,WAAW,MAAM;AAAA,MACjB,SAAS;AAAA,QACR,SAAS,CAAC,SAAS,QAAQ;AAAA,UAC1B,QAAQ,OAAO,QAAQ;AAAA,UAGvB,IAAI,IAAI,OAAO,aAAa,IAAI,OAAO,IAAI;AAAA,YAC1C,QAAQ,OAAO,iBAAiB;AAAA,UACjC,EAAE;AAAA,YAAK,QAAQ,IAAI,mBAAmB,IAAI,EAAE;AAAA,UAE5C,QAAQ,OAAO,WAAW;AAAA,UAC1B,QAAQ,OAAO,WAAW;AAAA,UAC1B,QAAQ,IAAI,QAAQ,KAAK;AAAA,UACzB,QAAQ,UAAU,SAAS,GAAG;AAAA;AAAA,QAE/B,UAAU,CAAC,SAAS,QAAQ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M,UACL,YAAY,YACT,YACE,OAAO,KAAK,SAAS;AAAA,IACvB,MAAM,WAAY,MAAM,WAAW,KAAK,IAAI;AAAA,IAC5C,IAAI,IAAI,IAAI,aAAa;AAAA,MAAoB,OAAO;AAAA,IACpD,MAAM,MAAM,UAAU,YAAY,GAAG,EAAE;AAAA,IACvC,MAAM,KAAK,kBAAiB,UAAU,KAAK,IAAI;AAAA,IAC/C,IAAI,OAAO;AAAA,MAAW,OAAO;AAAA,IAC7B,MAAM,UAAU,IAAI,QAAQ,SAAS,OAAO;AAAA,IAC5C,QAAQ,OACP,cACA,sBAAqB,IAAI,IAAI,IAAI,GAAG,EAAE,aAAa,QAAQ,CAC5D;AAAA,IACA,OAAO,IAAI,SAAS,SAAS,MAAM;AAAA,MAClC,QAAQ,SAAS;AAAA,MACjB,YAAY,SAAS;AAAA,MACrB;AAAA,IACD,CAAC;AAAA;AAAA,EAEL,OAAO,CAA+B,QACrC,IAAI,IAAI,WAAW,UAAU;AAAA;",
|
|
9
|
+
"debugId": "2E220AC1652370D164756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type Alxia, type Empty } from '@softistx/alxia';
|
|
2
|
+
export interface McpRelayOptions {
|
|
3
|
+
/** The API's origin, an absolute `http://` or `https://` URL. */
|
|
4
|
+
readonly api: string | URL;
|
|
5
|
+
/**
|
|
6
|
+
* The header the API checks to trust the forwarded client address and to
|
|
7
|
+
* accept the relayed paths (`requireProxySecret` of `@softistx/alxia`), and
|
|
8
|
+
* its secret. Set on every relayed request, over any value the client
|
|
9
|
+
* sent.
|
|
10
|
+
*/
|
|
11
|
+
readonly secret: {
|
|
12
|
+
readonly header: string;
|
|
13
|
+
readonly value: string;
|
|
14
|
+
};
|
|
15
|
+
/** Milliseconds the API has to send its response's headers: 60 000 by default; past it, a 504. */
|
|
16
|
+
readonly timeout?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Binds a pending consent request to the browser that opened it: when
|
|
19
|
+
* `/oauth/authorize` is answered with a redirect to this app's own consent
|
|
20
|
+
* page, the answer also sets an httpOnly, `SameSite=Lax` cookie naming the
|
|
21
|
+
* request, which `oauthConsent` reads. On by default; `false` turns it off.
|
|
22
|
+
*/
|
|
23
|
+
readonly consent?: false | {
|
|
24
|
+
/** The consent page's path: `/oauth/consent` by default. */
|
|
25
|
+
readonly path?: `/${string}`;
|
|
26
|
+
/**
|
|
27
|
+
* The app's public origin (`https://app.example`). Default: the
|
|
28
|
+
* origin of the request, which is wrong behind a proxy that
|
|
29
|
+
* ends TLS; give it then. Decides `Secure` and the `__Host-` name.
|
|
30
|
+
*/
|
|
31
|
+
readonly origin?: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A `beforeAll` plugin relaying `MCP_RELAY_PATHS` of `@softistx/alxia` (`/mcp`,
|
|
36
|
+
* `/oauth/authorize`, `/oauth/token`, `/oauth/register`, `/oauth/revoke`,
|
|
37
|
+
* `/.well-known/oauth-authorization-server` and
|
|
38
|
+
* `/.well-known/oauth-protected-resource/mcp`) to the API, which accepts them
|
|
39
|
+
* from the relay alone with `requireProxySecret({ paths: MCP_RELAY_PATHS })`.
|
|
40
|
+
* `/oauth/consent` and every other path fall through to the app.
|
|
41
|
+
*
|
|
42
|
+
* Authorization, Origin, the method and the body go unchanged; the Cookie
|
|
43
|
+
* never goes, and no session Bearer is added. `X-Forwarded-For` is the
|
|
44
|
+
* client address the app resolved, never appended to a client's copy.
|
|
45
|
+
* Bodies over 256 KiB on `/mcp` and 64 KiB on `/oauth/*` are refused with a
|
|
46
|
+
* 413. The response keeps its status, its streamed body, `WWW-Authenticate`
|
|
47
|
+
* and `Retry-After`; its `Set-Cookie` is dropped and a restrictive
|
|
48
|
+
* `Content-Security-Policy` and `X-Content-Type-Options: nosniff` are set.
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* createServer({
|
|
52
|
+
* beforeAll: (app) =>
|
|
53
|
+
* app.plugin(mcpRelay({ api: env.API_ORIGIN, secret: { header: 'x-proxy-secret', value: env.API_PROXY_SECRET } })),
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function mcpRelay(options: McpRelayOptions): <App extends Alxia<Empty, "">>(app: App) => App;
|
|
58
|
+
//# sourceMappingURL=mcp-relay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-relay.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-relay.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,KAAK,EACV,KAAK,KAAK,EAGV,MAAM,iBAAiB,CAAC;AAezB,MAAM,WAAW,eAAe;IAC/B,iEAAiE;IACjE,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACrE,kGAAkG;IAClG,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EACd,KAAK,GACL;QACA,4DAA4D;QAC5D,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;QAC7B;;;;WAIG;QACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;CACL;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,IAyDxC,GAAG,SAAS,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,KAAK,GAAG,KAAG,GAAG,CAEpD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The forwarding core of a BFF relay: exact paths of the app's own origin
|
|
3
|
+
* sent to the API with `@softistx/alxia-proxy`, the client's cookies never sent, the
|
|
4
|
+
* client address and the shared secret set rather than appended. Internal:
|
|
5
|
+
* `/mcp` is its first user and a media relay can share it, passing the
|
|
6
|
+
* `request` edit that adds what it needs (a session Bearer), which this
|
|
7
|
+
* core never adds.
|
|
8
|
+
*/
|
|
9
|
+
import type { Middleware } from '@softistx/alxia';
|
|
10
|
+
import { type ProxyContext } from '@softistx/alxia-proxy';
|
|
11
|
+
/** The most bytes a body may hold on a relayed path, 413 above. */
|
|
12
|
+
export interface RelayRoute {
|
|
13
|
+
readonly path: `/${string}`;
|
|
14
|
+
readonly bodyLimit: number;
|
|
15
|
+
}
|
|
16
|
+
export interface RelayOptions {
|
|
17
|
+
/** The API's origin, an absolute `http://` or `https://` URL. */
|
|
18
|
+
readonly api: string | URL;
|
|
19
|
+
/** The paths relayed, each with its body limit. Any other path falls through. */
|
|
20
|
+
readonly routes: readonly RelayRoute[];
|
|
21
|
+
/** The header the API checks, and its value: set on every relayed request, over any client copy. */
|
|
22
|
+
readonly secret: {
|
|
23
|
+
readonly header: string;
|
|
24
|
+
readonly value: string;
|
|
25
|
+
};
|
|
26
|
+
/** Milliseconds the API has to send its response's headers. */
|
|
27
|
+
readonly timeout: number;
|
|
28
|
+
/** Edits the headers the API receives, after the core's own (cookie removed, address and secret set). */
|
|
29
|
+
readonly request?: (headers: Headers, ctx: ProxyContext) => void;
|
|
30
|
+
/** Edits the headers the client receives. */
|
|
31
|
+
readonly response?: (headers: Headers, ctx: ProxyContext) => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A middleware relaying the paths of `options.routes`, exactly, whatever
|
|
35
|
+
* the method, and calling `next` for every other request.
|
|
36
|
+
*/
|
|
37
|
+
export declare function relayMiddleware(options: RelayOptions): Middleware;
|
|
38
|
+
//# sourceMappingURL=relay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/mcp/relay.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,KAAK,YAAY,EAAS,MAAM,uBAAuB,CAAC;AAEjE,mEAAmE;AACnE,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,IAAI,EAAE,IAAI,MAAM,EAAE,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,YAAY;IAC5B,iEAAiE;IACjE,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAC3B,iFAAiF;IACjF,QAAQ,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;IACvC,oGAAoG;IACpG,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACrE,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yGAAyG;IACzG,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;IACjE,6CAA6C;IAC7C,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;CAClE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,UAAU,CAiCjE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Why an upload failed, from the status the app's media route answered. */
|
|
2
|
+
export type MediaUploadReason = 'unauthenticated' | 'forbidden' | 'length_required' | 'too_large' | 'type_refused' | 'rate_limited' | 'unavailable' | 'timeout' | 'failed' | 'network' | 'invalid_response' | 'aborted';
|
|
3
|
+
/** The reason a refusal status stands for. */
|
|
4
|
+
export declare const reasonOf: (status: number) => MediaUploadReason;
|
|
5
|
+
/**
|
|
6
|
+
* What `uploadMedia` rejects with. `status` is the HTTP status, `0` when there
|
|
7
|
+
* was none (`network`, `aborted`); `code` is the `error` of the JSON refusal
|
|
8
|
+
* when the answer had one, and `body` the whole JSON refusal (`{ error,
|
|
9
|
+
* reason, ... }`, any shape the route's `onRefusal` gave it), `undefined` when
|
|
10
|
+
* the answer was no JSON object. `retryAfter` is the wait in seconds the answer's
|
|
11
|
+
* `Retry-After` header states (a 429 or 503 usually sends it), `undefined`
|
|
12
|
+
* when the header is absent or invalid.
|
|
13
|
+
*/
|
|
14
|
+
export declare class MediaUploadError extends Error {
|
|
15
|
+
readonly reason: MediaUploadReason;
|
|
16
|
+
readonly status: number;
|
|
17
|
+
readonly code?: string | undefined;
|
|
18
|
+
readonly retryAfter?: number | undefined;
|
|
19
|
+
readonly body?: Record<string, unknown> | undefined;
|
|
20
|
+
readonly name = "MediaUploadError";
|
|
21
|
+
constructor(reason: MediaUploadReason, status: number, code?: string | undefined, retryAfter?: number | undefined, body?: Record<string, unknown> | undefined);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The seconds a `Retry-After` header value asks to wait: whole seconds, or an
|
|
25
|
+
* HTTP date (the seconds left until it, `0` once past). `undefined` when the
|
|
26
|
+
* value is absent or neither.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseRetryAfter(value: string | null | undefined, now?: number): number | undefined;
|
|
29
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/media/client/error.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,MAAM,iBAAiB,GAC1B,iBAAiB,GACjB,WAAW,GACX,iBAAiB,GACjB,WAAW,GACX,cAAc,GACd,cAAc,GACd,aAAa,GACb,SAAS,GACT,QAAQ,GACR,SAAS,GACT,kBAAkB,GAClB,SAAS,CAAC;AAcb,8CAA8C;AAC9C,eAAO,MAAM,QAAQ,GAAI,QAAQ,MAAM,KAAG,iBACZ,CAAC;AAE/B;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IAGzC,QAAQ,CAAC,MAAM,EAAE,iBAAiB;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IANxC,SAAkB,IAAI,sBAAsB;gBAElC,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,YAAA,EACb,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAIxC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,GAAG,GAAE,MAAmB,GACtB,MAAM,GAAG,SAAS,CAQpB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@softistx/alxia-react-router/media/client`: the page's side of `/media`, a browser
|
|
3
|
+
* upload with progress, abort and typed refusals. It imports nothing and uses
|
|
4
|
+
* only browser APIs (`XMLHttpRequest`), so it is safe in the client bundle.
|
|
5
|
+
*/
|
|
6
|
+
export { MediaUploadError, type MediaUploadReason, reasonOf } from './error';
|
|
7
|
+
export { type MediaUploadResult, type UploadMediaOptions, uploadMedia, } from './upload';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/media/client/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,WAAW,GACX,MAAM,UAAU,CAAC"}
|