@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.
Files changed (609) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2085 -2
  3. package/dist/api-keys/api-keys.d.ts +93 -0
  4. package/dist/api-keys/api-keys.d.ts.map +1 -0
  5. package/dist/api-keys/index.d.ts +9 -0
  6. package/dist/api-keys/index.d.ts.map +1 -0
  7. package/dist/api-keys/index.js +66 -0
  8. package/dist/api-keys/index.js.map +10 -0
  9. package/dist/assets.d.ts +14 -0
  10. package/dist/assets.d.ts.map +1 -0
  11. package/dist/chunks/index-0786n4qe.js +25 -0
  12. package/dist/chunks/index-0786n4qe.js.map +10 -0
  13. package/dist/chunks/index-1nw5yeek.js +169 -0
  14. package/dist/chunks/index-1nw5yeek.js.map +11 -0
  15. package/dist/chunks/index-59vhfj6n.js +10 -0
  16. package/dist/chunks/index-59vhfj6n.js.map +10 -0
  17. package/dist/chunks/index-5gqcpyyg.js +34 -0
  18. package/dist/chunks/index-5gqcpyyg.js.map +10 -0
  19. package/dist/chunks/index-6jf7zpxz.js +119 -0
  20. package/dist/chunks/index-6jf7zpxz.js.map +11 -0
  21. package/dist/chunks/index-8as4j8m3.js +340 -0
  22. package/dist/chunks/index-8as4j8m3.js.map +16 -0
  23. package/dist/chunks/index-9xv2a8et.js +108 -0
  24. package/dist/chunks/index-9xv2a8et.js.map +11 -0
  25. package/dist/chunks/index-ajtvyq35.js +16 -0
  26. package/dist/chunks/index-ajtvyq35.js.map +10 -0
  27. package/dist/chunks/index-c55hxgr5.js +124 -0
  28. package/dist/chunks/index-c55hxgr5.js.map +14 -0
  29. package/dist/chunks/index-d42p3mdp.js +19 -0
  30. package/dist/chunks/index-d42p3mdp.js.map +10 -0
  31. package/dist/chunks/index-gac44rs5.js +42 -0
  32. package/dist/chunks/index-gac44rs5.js.map +11 -0
  33. package/dist/chunks/index-j4ktpcke.js +62 -0
  34. package/dist/chunks/index-j4ktpcke.js.map +10 -0
  35. package/dist/chunks/index-mscfme4r.js +12 -0
  36. package/dist/chunks/index-mscfme4r.js.map +10 -0
  37. package/dist/chunks/index-pghmb2dm.js +30 -0
  38. package/dist/chunks/index-pghmb2dm.js.map +10 -0
  39. package/dist/chunks/index-rfr02vg4.js +40 -0
  40. package/dist/chunks/index-rfr02vg4.js.map +10 -0
  41. package/dist/chunks/index-sfhshxqz.js +31 -0
  42. package/dist/chunks/index-sfhshxqz.js.map +10 -0
  43. package/dist/chunks/index-skwypsjz.js +357 -0
  44. package/dist/chunks/index-skwypsjz.js.map +12 -0
  45. package/dist/chunks/index-sxh06ged.js +118 -0
  46. package/dist/chunks/index-sxh06ged.js.map +11 -0
  47. package/dist/chunks/index-t2ph23wk.js +96 -0
  48. package/dist/chunks/index-t2ph23wk.js.map +13 -0
  49. package/dist/chunks/index-thyabr5n.js +19 -0
  50. package/dist/chunks/index-thyabr5n.js.map +10 -0
  51. package/dist/chunks/index-tx36swjx.js +134 -0
  52. package/dist/chunks/index-tx36swjx.js.map +11 -0
  53. package/dist/chunks/index-v2z5k640.js +54 -0
  54. package/dist/chunks/index-v2z5k640.js.map +11 -0
  55. package/dist/chunks/index-vr82typq.js +23 -0
  56. package/dist/chunks/index-vr82typq.js.map +11 -0
  57. package/dist/chunks/index-whj6h5eg.js +9 -0
  58. package/dist/chunks/index-whj6h5eg.js.map +10 -0
  59. package/dist/chunks/index-wyypkfdv.js +130 -0
  60. package/dist/chunks/index-wyypkfdv.js.map +13 -0
  61. package/dist/chunks/index-xd5aqy3g.js +90 -0
  62. package/dist/chunks/index-xd5aqy3g.js.map +10 -0
  63. package/dist/chunks/index-zdbqzcjp.js +97 -0
  64. package/dist/chunks/index-zdbqzcjp.js.map +12 -0
  65. package/dist/chunks/index-zyg8amjc.js +23 -0
  66. package/dist/chunks/index-zyg8amjc.js.map +10 -0
  67. package/dist/cli/index.d.ts +3 -0
  68. package/dist/cli/index.d.ts.map +1 -0
  69. package/dist/cli/index.js +215 -0
  70. package/dist/cli/index.js.map +13 -0
  71. package/dist/cli/main.d.ts +13 -0
  72. package/dist/cli/main.d.ts.map +1 -0
  73. package/dist/cli/reveal.d.ts +18 -0
  74. package/dist/cli/reveal.d.ts.map +1 -0
  75. package/dist/cli/template.d.ts +8 -0
  76. package/dist/cli/template.d.ts.map +1 -0
  77. package/dist/context.d.ts +104 -0
  78. package/dist/context.d.ts.map +1 -0
  79. package/dist/document/index.d.ts +11 -0
  80. package/dist/document/index.d.ts.map +1 -0
  81. package/dist/document/index.js +19 -0
  82. package/dist/document/index.js.map +9 -0
  83. package/dist/document/inline-script.d.ts +27 -0
  84. package/dist/document/inline-script.d.ts.map +1 -0
  85. package/dist/document/language-store.d.ts +8 -0
  86. package/dist/document/language-store.d.ts.map +1 -0
  87. package/dist/document/nonce.d.ts +34 -0
  88. package/dist/document/nonce.d.ts.map +1 -0
  89. package/dist/document/page-language.d.ts +39 -0
  90. package/dist/document/page-language.d.ts.map +1 -0
  91. package/dist/document/text-direction.d.ts +10 -0
  92. package/dist/document/text-direction.d.ts.map +1 -0
  93. package/dist/entry/abort.d.ts +21 -0
  94. package/dist/entry/abort.d.ts.map +1 -0
  95. package/dist/entry/create-entry.d.ts +41 -0
  96. package/dist/entry/create-entry.d.ts.map +1 -0
  97. package/dist/entry/index.d.ts +8 -0
  98. package/dist/entry/index.d.ts.map +1 -0
  99. package/dist/entry/index.js +154 -0
  100. package/dist/entry/index.js.map +13 -0
  101. package/dist/entry/root-data.d.ts +27 -0
  102. package/dist/entry/root-data.d.ts.map +1 -0
  103. package/dist/entry/whole-page.d.ts +10 -0
  104. package/dist/entry/whole-page.d.ts.map +1 -0
  105. package/dist/errors/api-error.d.ts +117 -0
  106. package/dist/errors/api-error.d.ts.map +1 -0
  107. package/dist/errors/api-errors.d.ts +122 -0
  108. package/dist/errors/api-errors.d.ts.map +1 -0
  109. package/dist/errors/call-failure.d.ts +45 -0
  110. package/dist/errors/call-failure.d.ts.map +1 -0
  111. package/dist/errors/catalogue-check.d.ts +24 -0
  112. package/dist/errors/catalogue-check.d.ts.map +1 -0
  113. package/dist/errors/catalogue-read.d.ts +33 -0
  114. package/dist/errors/catalogue-read.d.ts.map +1 -0
  115. package/dist/errors/catalogue.d.ts +59 -0
  116. package/dist/errors/catalogue.d.ts.map +1 -0
  117. package/dist/errors/code-resolver.d.ts +44 -0
  118. package/dist/errors/code-resolver.d.ts.map +1 -0
  119. package/dist/errors/cross-site.d.ts +8 -0
  120. package/dist/errors/cross-site.d.ts.map +1 -0
  121. package/dist/errors/describe-refusal.d.ts +6 -0
  122. package/dist/errors/describe-refusal.d.ts.map +1 -0
  123. package/dist/errors/describe.d.ts +3 -0
  124. package/dist/errors/describe.d.ts.map +1 -0
  125. package/dist/errors/fetcher-result.d.ts +33 -0
  126. package/dist/errors/fetcher-result.d.ts.map +1 -0
  127. package/dist/errors/field-placement.d.ts +12 -0
  128. package/dist/errors/field-placement.d.ts.map +1 -0
  129. package/dist/errors/form-errors.d.ts +8 -0
  130. package/dist/errors/form-errors.d.ts.map +1 -0
  131. package/dist/errors/form-refusal.d.ts +25 -0
  132. package/dist/errors/form-refusal.d.ts.map +1 -0
  133. package/dist/errors/index.d.ts +21 -0
  134. package/dist/errors/index.d.ts.map +1 -0
  135. package/dist/errors/index.js +588 -0
  136. package/dist/errors/index.js.map +26 -0
  137. package/dist/errors/json-actions.d.ts +38 -0
  138. package/dist/errors/json-actions.d.ts.map +1 -0
  139. package/dist/errors/log.d.ts +8 -0
  140. package/dist/errors/log.d.ts.map +1 -0
  141. package/dist/errors/message-values.d.ts +11 -0
  142. package/dist/errors/message-values.d.ts.map +1 -0
  143. package/dist/errors/messages.d.ts +63 -0
  144. package/dist/errors/messages.d.ts.map +1 -0
  145. package/dist/errors/page-path.d.ts +9 -0
  146. package/dist/errors/page-path.d.ts.map +1 -0
  147. package/dist/errors/problem-error.d.ts +50 -0
  148. package/dist/errors/problem-error.d.ts.map +1 -0
  149. package/dist/errors/provider.d.ts +20 -0
  150. package/dist/errors/provider.d.ts.map +1 -0
  151. package/dist/errors/request-id.d.ts +5 -0
  152. package/dist/errors/request-id.d.ts.map +1 -0
  153. package/dist/errors/route-error.d.ts +33 -0
  154. package/dist/errors/route-error.d.ts.map +1 -0
  155. package/dist/errors/route-refusal.d.ts +20 -0
  156. package/dist/errors/route-refusal.d.ts.map +1 -0
  157. package/dist/errors/same-site.d.ts +49 -0
  158. package/dist/errors/same-site.d.ts.map +1 -0
  159. package/dist/errors/section-action.d.ts +46 -0
  160. package/dist/errors/section-action.d.ts.map +1 -0
  161. package/dist/errors/standard-schema.d.ts +34 -0
  162. package/dist/errors/standard-schema.d.ts.map +1 -0
  163. package/dist/errors/submit-form.d.ts +16 -0
  164. package/dist/errors/submit-form.d.ts.map +1 -0
  165. package/dist/errors/upstream-headers.d.ts +18 -0
  166. package/dist/errors/upstream-headers.d.ts.map +1 -0
  167. package/dist/errors/use-json-fetcher.d.ts +18 -0
  168. package/dist/errors/use-json-fetcher.d.ts.map +1 -0
  169. package/dist/fetcher/auth-refusal.d.ts +29 -0
  170. package/dist/fetcher/auth-refusal.d.ts.map +1 -0
  171. package/dist/fetcher/index.d.ts +20 -0
  172. package/dist/fetcher/index.d.ts.map +1 -0
  173. package/dist/fetcher/index.js +392 -0
  174. package/dist/fetcher/index.js.map +21 -0
  175. package/dist/fetcher/section-form.d.ts +24 -0
  176. package/dist/fetcher/section-form.d.ts.map +1 -0
  177. package/dist/fetcher/section-reload.d.ts +17 -0
  178. package/dist/fetcher/section-reload.d.ts.map +1 -0
  179. package/dist/fetcher/section-save.d.ts +29 -0
  180. package/dist/fetcher/section-save.d.ts.map +1 -0
  181. package/dist/fetcher/use-debounced-fetcher.d.ts +57 -0
  182. package/dist/fetcher/use-debounced-fetcher.d.ts.map +1 -0
  183. package/dist/fetcher/use-fetcher-answer.d.ts +16 -0
  184. package/dist/fetcher/use-fetcher-answer.d.ts.map +1 -0
  185. package/dist/fetcher/use-fetcher-done.d.ts +15 -0
  186. package/dist/fetcher/use-fetcher-done.d.ts.map +1 -0
  187. package/dist/fetcher/use-fetcher-promise.d.ts +48 -0
  188. package/dist/fetcher/use-fetcher-promise.d.ts.map +1 -0
  189. package/dist/fetcher/use-form-refusal.d.ts +20 -0
  190. package/dist/fetcher/use-form-refusal.d.ts.map +1 -0
  191. package/dist/fetcher/use-revalidate-on-focus.d.ts +20 -0
  192. package/dist/fetcher/use-revalidate-on-focus.d.ts.map +1 -0
  193. package/dist/fetcher/use-row-save.d.ts +32 -0
  194. package/dist/fetcher/use-row-save.d.ts.map +1 -0
  195. package/dist/fetcher/use-section-save.d.ts +46 -0
  196. package/dist/fetcher/use-section-save.d.ts.map +1 -0
  197. package/dist/fetcher/use-visible-interval.d.ts +24 -0
  198. package/dist/fetcher/use-visible-interval.d.ts.map +1 -0
  199. package/dist/fetcher/use-visible-revalidation.d.ts +10 -0
  200. package/dist/fetcher/use-visible-revalidation.d.ts.map +1 -0
  201. package/dist/health.d.ts +21 -0
  202. package/dist/health.d.ts.map +1 -0
  203. package/dist/help/check/check.d.ts +35 -0
  204. package/dist/help/check/check.d.ts.map +1 -0
  205. package/dist/help/check/index.d.ts +8 -0
  206. package/dist/help/check/index.d.ts.map +1 -0
  207. package/dist/help/check/index.js +17 -0
  208. package/dist/help/check/index.js.map +9 -0
  209. package/dist/help/check/routes.d.ts +22 -0
  210. package/dist/help/check/routes.d.ts.map +1 -0
  211. package/dist/help/guide.d.ts +33 -0
  212. package/dist/help/guide.d.ts.map +1 -0
  213. package/dist/help/index.d.ts +16 -0
  214. package/dist/help/index.d.ts.map +1 -0
  215. package/dist/help/index.js +192 -0
  216. package/dist/help/index.js.map +14 -0
  217. package/dist/help/load.d.ts +39 -0
  218. package/dist/help/load.d.ts.map +1 -0
  219. package/dist/help/panel.d.ts +69 -0
  220. package/dist/help/panel.d.ts.map +1 -0
  221. package/dist/help/parse-flow.d.ts +27 -0
  222. package/dist/help/parse-flow.d.ts.map +1 -0
  223. package/dist/help/react.d.ts +12 -0
  224. package/dist/help/react.d.ts.map +1 -0
  225. package/dist/help/resolve.d.ts +24 -0
  226. package/dist/help/resolve.d.ts.map +1 -0
  227. package/dist/help/types.d.ts +50 -0
  228. package/dist/help/types.d.ts.map +1 -0
  229. package/dist/help/yaml.d.ts +18 -0
  230. package/dist/help/yaml.d.ts.map +1 -0
  231. package/dist/index.d.ts +7 -0
  232. package/dist/index.d.ts.map +1 -0
  233. package/dist/index.js +197 -0
  234. package/dist/index.js.map +14 -0
  235. package/dist/link/index.d.ts +7 -0
  236. package/dist/link/index.d.ts.map +1 -0
  237. package/dist/link/index.js +16 -0
  238. package/dist/link/index.js.map +10 -0
  239. package/dist/link/router-link.d.ts +27 -0
  240. package/dist/link/router-link.d.ts.map +1 -0
  241. package/dist/lists/connection-page.d.ts +50 -0
  242. package/dist/lists/connection-page.d.ts.map +1 -0
  243. package/dist/lists/index.d.ts +13 -0
  244. package/dist/lists/index.d.ts.map +1 -0
  245. package/dist/lists/index.js +205 -0
  246. package/dist/lists/index.js.map +15 -0
  247. package/dist/lists/newest-first.d.ts +5 -0
  248. package/dist/lists/newest-first.d.ts.map +1 -0
  249. package/dist/lists/nodes-of.d.ts +21 -0
  250. package/dist/lists/nodes-of.d.ts.map +1 -0
  251. package/dist/lists/or-failed.d.ts +19 -0
  252. package/dist/lists/or-failed.d.ts.map +1 -0
  253. package/dist/lists/use-paged-rows.d.ts +40 -0
  254. package/dist/lists/use-paged-rows.d.ts.map +1 -0
  255. package/dist/lists/use-same-route-loading.d.ts +8 -0
  256. package/dist/lists/use-same-route-loading.d.ts.map +1 -0
  257. package/dist/lists/use-search-change.d.ts +20 -0
  258. package/dist/lists/use-search-change.d.ts.map +1 -0
  259. package/dist/mcp/index.d.ts +8 -0
  260. package/dist/mcp/index.d.ts.map +1 -0
  261. package/dist/mcp/index.js +105 -0
  262. package/dist/mcp/index.js.map +11 -0
  263. package/dist/mcp/mcp-relay.d.ts +58 -0
  264. package/dist/mcp/mcp-relay.d.ts.map +1 -0
  265. package/dist/mcp/relay.d.ts +38 -0
  266. package/dist/mcp/relay.d.ts.map +1 -0
  267. package/dist/media/client/error.d.ts +29 -0
  268. package/dist/media/client/error.d.ts.map +1 -0
  269. package/dist/media/client/index.d.ts +8 -0
  270. package/dist/media/client/index.d.ts.map +1 -0
  271. package/dist/media/client/index.js +133 -0
  272. package/dist/media/client/index.js.map +11 -0
  273. package/dist/media/client/upload.d.ts +32 -0
  274. package/dist/media/client/upload.d.ts.map +1 -0
  275. package/dist/media/forward.d.ts +14 -0
  276. package/dist/media/forward.d.ts.map +1 -0
  277. package/dist/media/headers.d.ts +11 -0
  278. package/dist/media/headers.d.ts.map +1 -0
  279. package/dist/media/index.d.ts +9 -0
  280. package/dist/media/index.d.ts.map +1 -0
  281. package/dist/media/index.js +396 -0
  282. package/dist/media/index.js.map +16 -0
  283. package/dist/media/options.d.ts +114 -0
  284. package/dist/media/options.d.ts.map +1 -0
  285. package/dist/media/path.d.ts +12 -0
  286. package/dist/media/path.d.ts.map +1 -0
  287. package/dist/media/read.d.ts +11 -0
  288. package/dist/media/read.d.ts.map +1 -0
  289. package/dist/media/refusal.d.ts +11 -0
  290. package/dist/media/refusal.d.ts.map +1 -0
  291. package/dist/media/respond.d.ts +8 -0
  292. package/dist/media/respond.d.ts.map +1 -0
  293. package/dist/media/write.d.ts +13 -0
  294. package/dist/media/write.d.ts.map +1 -0
  295. package/dist/navigation/index.d.ts +9 -0
  296. package/dist/navigation/index.d.ts.map +1 -0
  297. package/dist/navigation/index.js +48 -0
  298. package/dist/navigation/index.js.map +11 -0
  299. package/dist/navigation/use-focus-on-navigate.d.ts +16 -0
  300. package/dist/navigation/use-focus-on-navigate.d.ts.map +1 -0
  301. package/dist/navigation/use-route-transition.d.ts +19 -0
  302. package/dist/navigation/use-route-transition.d.ts.map +1 -0
  303. package/dist/nonce.d.ts +16 -0
  304. package/dist/nonce.d.ts.map +1 -0
  305. package/dist/oauth/answer.d.ts +33 -0
  306. package/dist/oauth/answer.d.ts.map +1 -0
  307. package/dist/oauth/binding.d.ts +43 -0
  308. package/dist/oauth/binding.d.ts.map +1 -0
  309. package/dist/oauth/consent.d.ts +134 -0
  310. package/dist/oauth/consent.d.ts.map +1 -0
  311. package/dist/oauth/grants.d.ts +88 -0
  312. package/dist/oauth/grants.d.ts.map +1 -0
  313. package/dist/oauth/index.d.ts +16 -0
  314. package/dist/oauth/index.d.ts.map +1 -0
  315. package/dist/oauth/index.js +207 -0
  316. package/dist/oauth/index.js.map +12 -0
  317. package/dist/oauth/model.d.ts +13 -0
  318. package/dist/oauth/model.d.ts.map +1 -0
  319. package/dist/oauth/react/index.d.ts +7 -0
  320. package/dist/oauth/react/index.d.ts.map +1 -0
  321. package/dist/oauth/react/index.js +99 -0
  322. package/dist/oauth/react/index.js.map +10 -0
  323. package/dist/oauth/react/use-consent.d.ts +52 -0
  324. package/dist/oauth/react/use-consent.d.ts.map +1 -0
  325. package/dist/oidc/dpop.d.ts +80 -0
  326. package/dist/oidc/dpop.d.ts.map +1 -0
  327. package/dist/oidc/errors.d.ts +16 -0
  328. package/dist/oidc/errors.d.ts.map +1 -0
  329. package/dist/oidc/flow.d.ts +59 -0
  330. package/dist/oidc/flow.d.ts.map +1 -0
  331. package/dist/oidc/index.d.ts +11 -0
  332. package/dist/oidc/index.d.ts.map +1 -0
  333. package/dist/oidc/index.js +742 -0
  334. package/dist/oidc/index.js.map +15 -0
  335. package/dist/oidc/oidc.d.ts +132 -0
  336. package/dist/oidc/oidc.d.ts.map +1 -0
  337. package/dist/oidc/revoke.d.ts +28 -0
  338. package/dist/oidc/revoke.d.ts.map +1 -0
  339. package/dist/oidc/seal.d.ts +20 -0
  340. package/dist/oidc/seal.d.ts.map +1 -0
  341. package/dist/pwa/build/build-worker.d.ts +41 -0
  342. package/dist/pwa/build/build-worker.d.ts.map +1 -0
  343. package/dist/pwa/build/index.d.ts +9 -0
  344. package/dist/pwa/build/index.d.ts.map +1 -0
  345. package/dist/pwa/build/index.js +9 -0
  346. package/dist/pwa/build/index.js.map +9 -0
  347. package/dist/pwa/build/precache.d.ts +17 -0
  348. package/dist/pwa/build/precache.d.ts.map +1 -0
  349. package/dist/pwa/index.d.ts +16 -0
  350. package/dist/pwa/index.d.ts.map +1 -0
  351. package/dist/pwa/index.js +110 -0
  352. package/dist/pwa/index.js.map +12 -0
  353. package/dist/pwa/model/caching.d.ts +46 -0
  354. package/dist/pwa/model/caching.d.ts.map +1 -0
  355. package/dist/pwa/model/clear-app-caches.d.ts +9 -0
  356. package/dist/pwa/model/clear-app-caches.d.ts.map +1 -0
  357. package/dist/pwa/model/font-precache.d.ts +15 -0
  358. package/dist/pwa/model/font-precache.d.ts.map +1 -0
  359. package/dist/pwa/model/manifest.d.ts +80 -0
  360. package/dist/pwa/model/manifest.d.ts.map +1 -0
  361. package/dist/pwa/model/precache-list.d.ts +40 -0
  362. package/dist/pwa/model/precache-list.d.ts.map +1 -0
  363. package/dist/pwa/model/registration.d.ts +39 -0
  364. package/dist/pwa/model/registration.d.ts.map +1 -0
  365. package/dist/pwa/model/start-service-worker.d.ts +24 -0
  366. package/dist/pwa/model/start-service-worker.d.ts.map +1 -0
  367. package/dist/pwa/model/storable.d.ts +8 -0
  368. package/dist/pwa/model/storable.d.ts.map +1 -0
  369. package/dist/pwa/model/theme-color.d.ts +20 -0
  370. package/dist/pwa/model/theme-color.d.ts.map +1 -0
  371. package/dist/pwa/model/update-notice.d.ts +38 -0
  372. package/dist/pwa/model/update-notice.d.ts.map +1 -0
  373. package/dist/pwa/model/worker-contract.d.ts +61 -0
  374. package/dist/pwa/model/worker-contract.d.ts.map +1 -0
  375. package/dist/pwa/react/index.d.ts +9 -0
  376. package/dist/pwa/react/index.d.ts.map +1 -0
  377. package/dist/pwa/react/index.js +75 -0
  378. package/dist/pwa/react/index.js.map +13 -0
  379. package/dist/pwa/react/use-online.d.ts +6 -0
  380. package/dist/pwa/react/use-online.d.ts.map +1 -0
  381. package/dist/pwa/react/use-service-worker.d.ts +33 -0
  382. package/dist/pwa/react/use-service-worker.d.ts.map +1 -0
  383. package/dist/pwa/react/use-update-notice.d.ts +14 -0
  384. package/dist/pwa/react/use-update-notice.d.ts.map +1 -0
  385. package/dist/pwa/server/index.d.ts +7 -0
  386. package/dist/pwa/server/index.d.ts.map +1 -0
  387. package/dist/pwa/server/index.js +18 -0
  388. package/dist/pwa/server/index.js.map +10 -0
  389. package/dist/pwa/server/no-cache.d.ts +22 -0
  390. package/dist/pwa/server/no-cache.d.ts.map +1 -0
  391. package/dist/pwa/worker/index.d.ts +9 -0
  392. package/dist/pwa/worker/index.d.ts.map +1 -0
  393. package/dist/pwa/worker/index.js +144 -0
  394. package/dist/pwa/worker/index.js.map +12 -0
  395. package/dist/pwa/worker/injected.d.ts +15 -0
  396. package/dist/pwa/worker/injected.d.ts.map +1 -0
  397. package/dist/pwa/worker/plan.d.ts +65 -0
  398. package/dist/pwa/worker/plan.d.ts.map +1 -0
  399. package/dist/pwa/worker/scope.d.ts +18 -0
  400. package/dist/pwa/worker/scope.d.ts.map +1 -0
  401. package/dist/pwa/worker/start-worker.d.ts +17 -0
  402. package/dist/pwa/worker/start-worker.d.ts.map +1 -0
  403. package/dist/react-router.d.ts +68 -0
  404. package/dist/react-router.d.ts.map +1 -0
  405. package/dist/server.d.ts +127 -0
  406. package/dist/server.d.ts.map +1 -0
  407. package/dist/session/codes.d.ts +9 -0
  408. package/dist/session/codes.d.ts.map +1 -0
  409. package/dist/session/cookies.d.ts +128 -0
  410. package/dist/session/cookies.d.ts.map +1 -0
  411. package/dist/session/flow-types.d.ts +235 -0
  412. package/dist/session/flow-types.d.ts.map +1 -0
  413. package/dist/session/guard.d.ts +10 -0
  414. package/dist/session/guard.d.ts.map +1 -0
  415. package/dist/session/index.d.ts +22 -0
  416. package/dist/session/index.d.ts.map +1 -0
  417. package/dist/session/index.js +1090 -0
  418. package/dist/session/index.js.map +27 -0
  419. package/dist/session/land.d.ts +28 -0
  420. package/dist/session/land.d.ts.map +1 -0
  421. package/dist/session/link-json.d.ts +22 -0
  422. package/dist/session/link-json.d.ts.map +1 -0
  423. package/dist/session/link-land.d.ts +20 -0
  424. package/dist/session/link-land.d.ts.map +1 -0
  425. package/dist/session/link-token.d.ts +24 -0
  426. package/dist/session/link-token.d.ts.map +1 -0
  427. package/dist/session/link-types.d.ts +142 -0
  428. package/dist/session/link-types.d.ts.map +1 -0
  429. package/dist/session/links.d.ts +14 -0
  430. package/dist/session/links.d.ts.map +1 -0
  431. package/dist/session/model/index.d.ts +8 -0
  432. package/dist/session/model/index.d.ts.map +1 -0
  433. package/dist/session/model/index.js +35 -0
  434. package/dist/session/model/index.js.map +9 -0
  435. package/dist/session/model/link-post.d.ts +35 -0
  436. package/dist/session/model/link-post.d.ts.map +1 -0
  437. package/dist/session/model/paths.d.ts +24 -0
  438. package/dist/session/model/paths.d.ts.map +1 -0
  439. package/dist/session/model/safe-next.d.ts +15 -0
  440. package/dist/session/model/safe-next.d.ts.map +1 -0
  441. package/dist/session/model/second-factor.d.ts +16 -0
  442. package/dist/session/model/second-factor.d.ts.map +1 -0
  443. package/dist/session/model/site-path.d.ts +10 -0
  444. package/dist/session/model/site-path.d.ts.map +1 -0
  445. package/dist/session/model/step-up-answers.d.ts +45 -0
  446. package/dist/session/model/step-up-answers.d.ts.map +1 -0
  447. package/dist/session/model/step-up-props.d.ts +22 -0
  448. package/dist/session/model/step-up-props.d.ts.map +1 -0
  449. package/dist/session/model/step-up.d.ts +48 -0
  450. package/dist/session/model/step-up.d.ts.map +1 -0
  451. package/dist/session/react/index.d.ts +13 -0
  452. package/dist/session/react/index.d.ts.map +1 -0
  453. package/dist/session/react/index.js +196 -0
  454. package/dist/session/react/index.js.map +14 -0
  455. package/dist/session/react/step-up/answers.d.ts +9 -0
  456. package/dist/session/react/step-up/answers.d.ts.map +1 -0
  457. package/dist/session/react/step-up/dialog-props.d.ts +27 -0
  458. package/dist/session/react/step-up/dialog-props.d.ts.map +1 -0
  459. package/dist/session/react/step-up/index.d.ts +7 -0
  460. package/dist/session/react/step-up/index.d.ts.map +1 -0
  461. package/dist/session/react/step-up/pending-runs.d.ts +21 -0
  462. package/dist/session/react/step-up/pending-runs.d.ts.map +1 -0
  463. package/dist/session/react/step-up/phase.d.ts +8 -0
  464. package/dist/session/react/step-up/phase.d.ts.map +1 -0
  465. package/dist/session/react/step-up/use-step-up-replay.d.ts +59 -0
  466. package/dist/session/react/step-up/use-step-up-replay.d.ts.map +1 -0
  467. package/dist/session/react/step-up/use-step-up-runner.d.ts +70 -0
  468. package/dist/session/react/step-up/use-step-up-runner.d.ts.map +1 -0
  469. package/dist/session/react/step-up/use-step-up.d.ts +51 -0
  470. package/dist/session/react/step-up/use-step-up.d.ts.map +1 -0
  471. package/dist/session/react/use-code-field.d.ts +37 -0
  472. package/dist/session/react/use-code-field.d.ts.map +1 -0
  473. package/dist/session/react/use-link-fragment.d.ts +22 -0
  474. package/dist/session/react/use-link-fragment.d.ts.map +1 -0
  475. package/dist/session/react/use-link-param.d.ts +26 -0
  476. package/dist/session/react/use-link-param.d.ts.map +1 -0
  477. package/dist/session/react/use-link-post.d.ts +39 -0
  478. package/dist/session/react/use-link-post.d.ts.map +1 -0
  479. package/dist/session/react/use-sign-out.d.ts +46 -0
  480. package/dist/session/react/use-sign-out.d.ts.map +1 -0
  481. package/dist/session/second-factor.d.ts +22 -0
  482. package/dist/session/second-factor.d.ts.map +1 -0
  483. package/dist/session/serialize.d.ts +42 -0
  484. package/dist/session/serialize.d.ts.map +1 -0
  485. package/dist/session/sign-in.d.ts +19 -0
  486. package/dist/session/sign-in.d.ts.map +1 -0
  487. package/dist/session/signed.d.ts +44 -0
  488. package/dist/session/signed.d.ts.map +1 -0
  489. package/dist/session/social-flow.d.ts +22 -0
  490. package/dist/session/social-flow.d.ts.map +1 -0
  491. package/dist/session/social-land.d.ts +31 -0
  492. package/dist/session/social-land.d.ts.map +1 -0
  493. package/dist/session/social-types.d.ts +136 -0
  494. package/dist/session/social-types.d.ts.map +1 -0
  495. package/dist/session/social.d.ts +32 -0
  496. package/dist/session/social.d.ts.map +1 -0
  497. package/dist/session/step-up-codes.d.ts +9 -0
  498. package/dist/session/step-up-codes.d.ts.map +1 -0
  499. package/dist/session/step-up-signed-out.d.ts +21 -0
  500. package/dist/session/step-up-signed-out.d.ts.map +1 -0
  501. package/dist/session/step-up-types.d.ts +127 -0
  502. package/dist/session/step-up-types.d.ts.map +1 -0
  503. package/dist/session/step-up.d.ts +17 -0
  504. package/dist/session/step-up.d.ts.map +1 -0
  505. package/dist/session/step.d.ts +22 -0
  506. package/dist/session/step.d.ts.map +1 -0
  507. package/dist/session/throttle.d.ts +73 -0
  508. package/dist/session/throttle.d.ts.map +1 -0
  509. package/dist/session/timed-wait.d.ts +4 -0
  510. package/dist/session/timed-wait.d.ts.map +1 -0
  511. package/dist/session/viewer.d.ts +34 -0
  512. package/dist/session/viewer.d.ts.map +1 -0
  513. package/dist/subscription/documents.d.ts +3 -0
  514. package/dist/subscription/documents.d.ts.map +1 -0
  515. package/dist/subscription/index.d.ts +7 -0
  516. package/dist/subscription/index.d.ts.map +1 -0
  517. package/dist/subscription/index.js +359 -0
  518. package/dist/subscription/index.js.map +14 -0
  519. package/dist/subscription/proxy.d.ts +54 -0
  520. package/dist/subscription/proxy.d.ts.map +1 -0
  521. package/dist/subscription/react/backoff.d.ts +8 -0
  522. package/dist/subscription/react/backoff.d.ts.map +1 -0
  523. package/dist/subscription/react/classify.d.ts +15 -0
  524. package/dist/subscription/react/classify.d.ts.map +1 -0
  525. package/dist/subscription/react/controller.d.ts +40 -0
  526. package/dist/subscription/react/controller.d.ts.map +1 -0
  527. package/dist/subscription/react/fake-timers.d.ts +8 -0
  528. package/dist/subscription/react/fake-timers.d.ts.map +1 -0
  529. package/dist/subscription/react/index.d.ts +15 -0
  530. package/dist/subscription/react/index.d.ts.map +1 -0
  531. package/dist/subscription/react/index.js +227 -0
  532. package/dist/subscription/react/index.js.map +17 -0
  533. package/dist/subscription/react/reconnect.d.ts +9 -0
  534. package/dist/subscription/react/reconnect.d.ts.map +1 -0
  535. package/dist/subscription/react/scheduler.d.ts +13 -0
  536. package/dist/subscription/react/scheduler.d.ts.map +1 -0
  537. package/dist/subscription/react/timers.d.ts +7 -0
  538. package/dist/subscription/react/timers.d.ts.map +1 -0
  539. package/dist/subscription/react/use-live-subscription.d.ts +36 -0
  540. package/dist/subscription/react/use-live-subscription.d.ts.map +1 -0
  541. package/dist/subscription/react/versions.d.ts +6 -0
  542. package/dist/subscription/react/versions.d.ts.map +1 -0
  543. package/dist/subscription/read.d.ts +17 -0
  544. package/dist/subscription/read.d.ts.map +1 -0
  545. package/dist/subscription/refusal.d.ts +11 -0
  546. package/dist/subscription/refusal.d.ts.map +1 -0
  547. package/dist/subscription/relay.d.ts +16 -0
  548. package/dist/subscription/relay.d.ts.map +1 -0
  549. package/dist/vite/bun.d.ts +21 -0
  550. package/dist/vite/bun.d.ts.map +1 -0
  551. package/dist/vite/bundle.d.ts +33 -0
  552. package/dist/vite/bundle.d.ts.map +1 -0
  553. package/dist/vite/compress.d.ts +18 -0
  554. package/dist/vite/compress.d.ts.map +1 -0
  555. package/dist/vite/config.d.ts +33 -0
  556. package/dist/vite/config.d.ts.map +1 -0
  557. package/dist/vite/dev.d.ts +28 -0
  558. package/dist/vite/dev.d.ts.map +1 -0
  559. package/dist/vite/entry.d.ts +20 -0
  560. package/dist/vite/entry.d.ts.map +1 -0
  561. package/dist/vite/hosts.d.ts +16 -0
  562. package/dist/vite/hosts.d.ts.map +1 -0
  563. package/dist/vite/index.d.ts +68 -0
  564. package/dist/vite/index.d.ts.map +1 -0
  565. package/dist/vite/index.js +635 -0
  566. package/dist/vite/index.js.map +22 -0
  567. package/dist/vite/inline.d.ts +18 -0
  568. package/dist/vite/inline.d.ts.map +1 -0
  569. package/dist/vite/node.d.ts +16 -0
  570. package/dist/vite/node.d.ts.map +1 -0
  571. package/dist/vite/preview.d.ts +8 -0
  572. package/dist/vite/preview.d.ts.map +1 -0
  573. package/dist/vite/runtime.d.ts +8 -0
  574. package/dist/vite/runtime.d.ts.map +1 -0
  575. package/dist/vite/socket.d.ts +75 -0
  576. package/dist/vite/socket.d.ts.map +1 -0
  577. package/dist/vite/worker.d.ts +16 -0
  578. package/dist/vite/worker.d.ts.map +1 -0
  579. package/dist/with-alxia.d.ts +36 -0
  580. package/dist/with-alxia.d.ts.map +1 -0
  581. package/docs/README.md +42 -0
  582. package/docs/guide/api-keys.md +216 -0
  583. package/docs/guide/beside-the-pages.md +201 -0
  584. package/docs/guide/csp-nonce.md +166 -0
  585. package/docs/guide/customising-the-server.md +324 -0
  586. package/docs/guide/deploying.md +102 -0
  587. package/docs/guide/document.md +334 -0
  588. package/docs/guide/errors.md +1147 -0
  589. package/docs/guide/fetcher.md +355 -0
  590. package/docs/guide/getting-started.md +112 -0
  591. package/docs/guide/help.md +325 -0
  592. package/docs/guide/how-it-works.md +274 -0
  593. package/docs/guide/link.md +32 -0
  594. package/docs/guide/lists.md +225 -0
  595. package/docs/guide/mcp.md +173 -0
  596. package/docs/guide/media.md +273 -0
  597. package/docs/guide/navigation.md +52 -0
  598. package/docs/guide/oauth.md +342 -0
  599. package/docs/guide/oidc.md +262 -0
  600. package/docs/guide/openapi.md +51 -0
  601. package/docs/guide/pwa.md +670 -0
  602. package/docs/guide/session.md +2105 -0
  603. package/docs/guide/subscriptions.md +211 -0
  604. package/docs/guide/testing.md +42 -0
  605. package/docs/guide/typing-the-loaders.md +311 -0
  606. package/docs/guide.md +82 -0
  607. package/docs/roadmap.md +474 -0
  608. package/docs/troubleshooting.md +3837 -0
  609. package/package.json +301 -5
@@ -0,0 +1,225 @@
1
+ # Lists whose state is the URL
2
+
3
+ A list screen of a BFF keeps its state in the address bar: `?q=ana&status=open`
4
+ for a search and filters, `?after=<cursor>` for the page. The loader reads it;
5
+ the screen changes it. `@softistx/alxia-react-router/lists` holds the three hooks every
6
+ such screen needs, and three loader helpers: `orFailed` for a failed cursor
7
+ page, `connectionPage` for numbered pages over a cursor connection and
8
+ `nodesOf` for a connection's nodes. `react` and `react-router` are its only
9
+ imports, so it adds no peer beyond those, and every hook renders on the
10
+ server.
11
+
12
+ ```tsx
13
+ import {
14
+ usePagedRows,
15
+ useSameRouteLoading,
16
+ useSearchChange,
17
+ } from '@softistx/alxia-react-router/lists';
18
+ ```
19
+
20
+ ## The loader
21
+
22
+ One loader serves the first page and the next ones. It reads the cursor and
23
+ answers `{ items, next }`, `next` being `null` on the last page:
24
+
25
+ ```ts
26
+ export async function loader({ request }: Route.LoaderArgs) {
27
+ const url = new URL(request.url);
28
+ return {
29
+ page: await listUsers({
30
+ q: url.searchParams.get('q') ?? '',
31
+ after: url.searchParams.get('after'),
32
+ }),
33
+ };
34
+ }
35
+ ```
36
+
37
+ ## `useSearchChange`
38
+
39
+ ```tsx
40
+ const change = useSearchChange(); // resetKeys: ['after']
41
+
42
+ <input onChange={(event) => change({ q: event.target.value || null })} />;
43
+ <Select onChange={(status) => change({ status })} />;
44
+ ```
45
+
46
+ `change(changes)` sets each parameter given a string, deletes each given
47
+ `null` or `undefined` (an empty string is a value, so it is kept as `?q=`),
48
+ and deletes `resetKeys` in the same step: a new search makes the old cursor
49
+ meaningless. It navigates with `replace: true` and `preventScrollReset: true`,
50
+ so typing does not fill the history nor jump the page. Pass
51
+ `{ resetKeys: ['after', 'page'] }` to drop more.
52
+
53
+ `change` also takes a whole `URLSearchParams`, which replaces the search, or an
54
+ updater `(prev) => URLSearchParams`, for a filter bar or a server table that
55
+ hands back its next parameters. Both navigate exactly as the record form does
56
+ (`replace: true`, `preventScrollReset: true`), and since they are the whole
57
+ search, `resetKeys` does not apply to them: drop the cursor yourself if the
58
+ new search needs it gone.
59
+
60
+ ```tsx
61
+ <Table onParamsChange={(next: URLSearchParams) => change(next)} />;
62
+ change((prev) => new URLSearchParams([...prev].filter(([key]) => key !== 'status')));
63
+ ```
64
+
65
+ ## `useSameRouteLoading`
66
+
67
+ ```tsx
68
+ const reloading = useSameRouteLoading();
69
+ return reloading ? <Skeleton /> : <Table rows={rows} />;
70
+ ```
71
+
72
+ `true` while a navigation is loading **and** its pathname is the page's own: a
73
+ new search of this list. A click on a link to another page stays `false`, so
74
+ the list does not flash a skeleton on the way out.
75
+
76
+ ## `usePagedRows`
77
+
78
+ ```tsx
79
+ const { rows, next, loading, error, loadMore } = usePagedRows(
80
+ loaderData.page,
81
+ (page) => page.items,
82
+ );
83
+
84
+ <Button disabled={!next || loading} onClick={loadMore}>
85
+ {error ? 'Retry' : 'Load more'}
86
+ </Button>;
87
+ ```
88
+
89
+ | option | default | |
90
+ | --- | --- | --- |
91
+ | `cursorParam` | `'after'` | the search parameter carrying the cursor |
92
+ | `nextOf` | `page.next` | the cursor after a page, `null` at the end |
93
+
94
+ - `loadMore()` asks the **same route** for `?<cursorParam>=<next>`, keeping the
95
+ rest of the search, through `useFetcher`: the address bar and the page's
96
+ data do not change. It does nothing at the end or while a page is on its way.
97
+ - `rows` is the first page's rows followed by every page loaded after it.
98
+ - **It starts over** when `firstPage` is another object, which is what the
99
+ loader gives after a new search or a revalidation. The new first page's rows
100
+ are the ones rendered, with no frame of stale rows, and a page still on its
101
+ way for the old search is dropped.
102
+ - **A failure keeps the rows.** When the route answers something that is not a
103
+ page (`null`, or `data({ message }, { status: 503 })`), `error` is `true` and
104
+ `next` is unchanged, so the same button retries. The next `loadMore` clears
105
+ it. Fetcher data that is not a page (no rows, or a `next` that is neither a string nor `null`) sets `error`, like a failed page.
106
+
107
+ ### Another cursor parameter
108
+
109
+ ```ts
110
+ // the loader answers { items, cursor } for ?q=&page=<cursor>
111
+ const { rows, next, loadMore } = usePagedRows(
112
+ loaderData.page,
113
+ (page) => page.items,
114
+ { cursorParam: 'page', nextOf: (page) => page.cursor },
115
+ );
116
+ const change = useSearchChange({ resetKeys: ['page'] });
117
+ ```
118
+
119
+ `cursorParam` and `useSearchChange`'s `resetKeys` must name the same
120
+ parameter: with the defaults both are `after` (`DEFAULT_CURSOR_PARAM`), and
121
+ with another one a search that keeps the old cursor shows the wrong page.
122
+
123
+ A loader that **throws** on a cursor request is not an `error` here: React
124
+ Router sends a fetcher's thrown error to the route's `ErrorBoundary`. To offer
125
+ a retry instead, wrap the read in `orFailed(after, run)`: it answers
126
+ `FAILED` (`{ failed: true }`, a value that is not a page) for a request that
127
+ has the cursor, rethrows when there is none and rethrows a 3xx `Response`.
128
+
129
+ ```ts
130
+ import { orFailed } from '@softistx/alxia-react-router/lists';
131
+
132
+ export function loader({ request }: Route.LoaderArgs) {
133
+ const url = new URL(request.url);
134
+ return orFailed(url.searchParams.get('after'), async () => ({
135
+ page: await listUsers({
136
+ q: url.searchParams.get('q') ?? '',
137
+ after: url.searchParams.get('after'),
138
+ }),
139
+ }));
140
+ }
141
+ ```
142
+
143
+ `isFailedPage(loaderData)` narrows the answer when a component reads it.
144
+
145
+ ## Numbered pages over a cursor connection: `connectionPage`
146
+
147
+ A table with numbered pages (`?page=3`) over a GraphQL connection paged by
148
+ cursor (`first`/`after`, `pageInfo.endCursor`, `totalCount`) has no cursor for
149
+ page 3: the loader must walk the cursors of pages 1 and 2 itself, keep `first`
150
+ under the API's cap, and fall back to the last page when the address asks for
151
+ one past it. `connectionPage(wanted, pageSize, fetchPage, options?)` does that
152
+ walk on the server:
153
+
154
+ ```ts
155
+ import { connectionPage } from '@softistx/alxia-react-router/lists';
156
+
157
+ export async function loader({ request }: Route.LoaderArgs) {
158
+ const asked = Number(new URL(request.url).searchParams.get('page') ?? 1);
159
+ const wanted = Number.isInteger(asked) && asked >= 1 ? asked : 1;
160
+ const { rows, total, page, pageCount } = await connectionPage(
161
+ wanted,
162
+ 20,
163
+ async (first, after) => {
164
+ const { users } = await api.users({ first, after });
165
+ return { rows: users.nodes, connection: users };
166
+ },
167
+ { maxFirst: 100 },
168
+ );
169
+ return { users: rows, total, page, pageCount };
170
+ }
171
+ ```
172
+
173
+ - `fetchPage(first, after)` reads at most `first` rows after the cursor
174
+ `after` (`null` for the start) and answers `{ rows, connection }`, where
175
+ `connection` carries `totalCount` and `pageInfo: { hasNextPage, endCursor }`.
176
+ - It is called from the start, following `endCursor`, until the wanted page is
177
+ filled or the connection ends. No call asks more than `maxFirst` rows
178
+ (default `100`, `DEFAULT_MAX_FIRST`): page 7 of 50 rows asks `100, 100, 100, 50`.
179
+ - The answer is `{ rows, total, page, pageCount, skip }`: `rows` holds the
180
+ served page's rows alone (at most `pageSize`, the earlier pages are
181
+ dropped), `total` the last `totalCount`, `pageCount` is
182
+ `ceil(total / pageSize)` and at least `1`, `skip` is `(page - 1) * pageSize`.
183
+ - **A page past the last** gives the last page (`page` is then smaller than
184
+ `wanted`), from the rows already read: no second walk. An empty connection
185
+ is page 1 of 1 with no rows. Redirect to `?page=<page>` when the address
186
+ should say so.
187
+ - The walk stops when `hasNextPage` is false, when `endCursor` is missing or
188
+ repeats, or when a call answers no rows, so a connection that misreports
189
+ itself cannot loop. A walk that stopped before the wanted page was filled
190
+ has read every row there is: `pageCount` (and the clamp to the last page)
191
+ then counts those rows, whatever `totalCount` claimed, and `total` falls
192
+ back to them when `totalCount` is not a number.
193
+ - `wanted`, `pageSize` and `maxFirst` must be integers of at least 1, or it
194
+ throws a `RangeError`: validate `?page=` before calling it, as above.
195
+ `fetchPage`'s errors pass through.
196
+
197
+ Each request walks from the start, so page `n` costs about
198
+ `n * pageSize / maxFirst` calls. Keep it for tables a person pages through;
199
+ a long list reads better with `usePagedRows` and a cursor in the address.
200
+
201
+ ## A connection's nodes: `nodesOf`
202
+
203
+ A GraphQL connection in the Relay shape (`edges { node }`) is unwrapped the
204
+ same way in every loader. `nodesOf(connection)` gives its nodes, in the
205
+ connection's order, as a new array:
206
+
207
+ ```ts
208
+ import { nodesOf } from '@softistx/alxia-react-router/lists';
209
+
210
+ export async function loader() {
211
+ const { items } = await api.items({ first: 50 });
212
+ // items: { edges: { node: Item }[] } | null
213
+ return { items: nodesOf(items) }; // Item[]
214
+ }
215
+ ```
216
+
217
+ - A `null` or `undefined` connection, a refused or missing read, gives `[]`,
218
+ and so do a `null` or missing `edges` and an empty one.
219
+ - A `null` edge or a `null` node, which the Relay specification allows when a
220
+ node failed to resolve, is skipped: the array holds nodes alone, and its
221
+ type is the node type without `null`.
222
+ - The node type is inferred from the connection (`EdgesConnection<Node>` is
223
+ the shape it reads), so a generated query type needs no annotation.
224
+ - A connection that also selects `nodes` needs no helper: read
225
+ `connection?.nodes ?? []`.
@@ -0,0 +1,173 @@
1
+ # MCP and OAuth through the BFF
2
+
3
+ An MCP client (an assistant's connector) talks to one origin: your app's. The
4
+ app is a BFF, so it relays the API's MCP server and OAuth endpoints instead of
5
+ exposing the API itself. `@softistx/alxia-react-router/mcp` is that relay.
6
+
7
+ It imports `@softistx/alxia-proxy`, an optional peer of the package that your app
8
+ installs (`bun add @softistx/alxia-proxy`), and `@softistx/alxia` (a required peer) for the
9
+ list of paths it relays, `MCP_RELAY_PATHS`.
10
+
11
+ ## Relay the endpoints
12
+
13
+ `mcpRelay` returns a plugin for `beforeAll`, so it runs before the client's
14
+ files, your middlewares and the pages:
15
+
16
+ ```ts
17
+ // app/server.ts
18
+ import { createServer } from '@softistx/alxia-react-router';
19
+ import { mcpRelay } from '@softistx/alxia-react-router/mcp';
20
+
21
+ export default createServer({
22
+ beforeAll: (app) =>
23
+ app.plugin(
24
+ mcpRelay({
25
+ api: 'https://api.internal:3000',
26
+ secret: { header: 'x-app-proxy-secret', value: process.env.API_PROXY_SECRET ?? '' },
27
+ timeout: 60_000,
28
+ }),
29
+ ),
30
+ });
31
+ ```
32
+
33
+ | option | |
34
+ | --- | --- |
35
+ | `api` | the API's origin, an absolute `http://` or `https://` URL. Anything else throws a `TypeError` when the server is declared |
36
+ | `secret` | `{ header, value }`: the header the API checks to trust the client address you forward, and its value. Set on every relayed request |
37
+ | `timeout` | milliseconds the API has to send its response's headers; 60 000 by default. Past it, a 504. A positive number, else a `TypeError` |
38
+ | `consent` | the [request binding cookie](#bind-a-consent-request-to-the-browser): `{ path?, origin? }`, on by default; `false` turns it off. A `path` not starting with `/` or an `origin` that is not `http(s)://` throws a `TypeError` |
39
+
40
+ ## The paths
41
+
42
+ Exactly `MCP_RELAY_PATHS` of `@softistx/alxia`, whatever the method:
43
+
44
+ - `/mcp`
45
+ - `/.well-known/oauth-authorization-server`
46
+ - `/.well-known/oauth-protected-resource/mcp`
47
+ - `/oauth/authorize`, `/oauth/token`, `/oauth/register`, `/oauth/revoke`
48
+
49
+ The API and your deploy read the same list, so the three never drift apart
50
+ (see the next section).
51
+
52
+ `/oauth/consent` is a page of your app (see [the consent screen](oauth.md)) and
53
+ is **not** relayed. Neither is any other path (`/mcp/`, `/mcp/x`,
54
+ `/oauth/other`): they fall through to your routes.
55
+
56
+ ## Let the API accept them from the relay alone
57
+
58
+ The API serves these paths on its own address too. Make it refuse any request
59
+ that did not come through the relay, with the same secret the relay sets:
60
+
61
+ ```ts
62
+ // the API
63
+ import { alxia, forwardedIp, MCP_RELAY_PATHS, requireProxySecret } from '@softistx/alxia';
64
+
65
+ // unset in development: the API then serves those paths to anyone, as it does without a relay
66
+ const value = process.env.API_PROXY_SECRET;
67
+ const secret = value ? { header: 'x-app-proxy-secret', value } : undefined;
68
+
69
+ const api = alxia({ ip: forwardedIp({ trusted: 1, ...(secret && { secret }) }) });
70
+
71
+ export const app = secret
72
+ ? api.use(requireProxySecret({ paths: MCP_RELAY_PATHS, secret }))
73
+ : api;
74
+ ```
75
+
76
+ A request to one of the paths without the header answers 403
77
+ `{ "error": "proxy_secret_required" }`. Using the same header and value as
78
+ `forwardedIp`'s `secret` means one secret proves the relay for both its
79
+ forwarded address and its paths. See
80
+ [Serving: paths only the relay reaches](https://github.com/softistx/alxia/blob/develop/packages/core/docs/guide/serving.md#paths-only-the-relay-reaches).
81
+
82
+ ## Rate-limit the OAuth endpoints
83
+
84
+ `/oauth/register` and `/oauth/authorize` answer anonymous callers. A reverse
85
+ proxy in front of the app can limit them by path with `OAUTH_LIMITED_PATHS`
86
+ of `@softistx/alxia`, the four OAuth endpoints (`/oauth/consent` is your page and
87
+ is not among them):
88
+
89
+ ```ts
90
+ import { OAUTH_LIMITED_PATHS } from '@softistx/alxia';
91
+
92
+ // one rule per path, in the proxy's own configuration language
93
+ for (const path of OAUTH_LIMITED_PATHS) console.log(`limit ${path}`);
94
+ ```
95
+
96
+ ## What the API receives
97
+
98
+ - `Authorization`, `Origin`, the method, the path, the query and the body, as
99
+ the client sent them.
100
+ - No `Cookie`. The relay never reads your session and **never adds a session
101
+ Bearer**: an MCP client authenticates with its own OAuth token, and a
102
+ browser's session must not stand in for it.
103
+ - `X-Forwarded-For` is the client address the app resolved (`ctx.ip`), set,
104
+ never appended to a copy the client sent: the API keys its rate limits on the
105
+ left-most entry. Behind a proxy, give `createServer({ proxy })` the
106
+ `trustProxy` that tells the app who the client is; without it `ctx.ip` is the
107
+ proxy's address.
108
+ - The `secret` header, over any value the client sent.
109
+ - The body is limited to 256 KiB on `/mcp` and 64 KiB on `/oauth/*`; above, the
110
+ client gets a 413 and the API sees no request.
111
+
112
+ ## What the client receives
113
+
114
+ - The status, the streamed body (an SSE stream arrives event by event),
115
+ `WWW-Authenticate` and `Retry-After`, so a 401 still sends the client to the
116
+ protected-resource metadata and a 429 still tells it how long to wait.
117
+ - `Location` as the API wrote it: it is not rewritten. Give the API your app's
118
+ origin as its public one so its redirects and its metadata are absolute URLs
119
+ on the app.
120
+ - No `Set-Cookie` of the API's. The one cookie the relay sets itself is the [request binding](#bind-a-consent-request-to-the-browser), on `/oauth/authorize`.
121
+ - `Content-Security-Policy: default-src 'none'; frame-ancestors 'none'` and
122
+ `X-Content-Type-Options: nosniff`. They apply to these answers only; your
123
+ pages keep the CSP you set for them.
124
+
125
+ ## Bind a consent request to the browser
126
+
127
+ The API's `/oauth/authorize` answers a redirect to your consent page,
128
+ `/oauth/consent?request_id=…`. Without more, anyone signed in who learns that
129
+ address (a shared link, a log) can read the pending request or approve it for
130
+ their own account. So the relay binds the request to the browser that opened
131
+ it: when the answer redirects to **your own origin and your consent path**, it
132
+ adds an httpOnly, `SameSite=Lax`, `Path=/` cookie naming the request id, for an
133
+ hour. The consent route ([the consent screen](oauth.md#bind-the-request-to-the-browser))
134
+ reads it back.
135
+
136
+ ```ts
137
+ mcpRelay({
138
+ api: 'https://api.internal:3000',
139
+ secret: { header: 'x-app-proxy-secret', value: process.env.API_PROXY_SECRET ?? '' },
140
+ // Behind a proxy that ends TLS, the origin the browser sees:
141
+ consent: { origin: 'https://app.example' },
142
+ });
143
+ ```
144
+
145
+ - Only a 3xx whose `Location` is on the app's origin and on `consent.path`
146
+ (`/oauth/consent` by default) counts. A redirect to another host never does,
147
+ even to a path that looks like `/oauth/consent` there (an error redirect to
148
+ a client's `redirect_uri`). The id must match `[\w-]{1,200}`.
149
+ - `consent.origin` is the app's public origin. By default it is the origin the
150
+ client asked for (`originalUrl`: the scheme and host a `trustProxy` in
151
+ `createServer({ proxy })` reports). Without a trusted proxy in front of a
152
+ TLS-ending one it is `http://`: the cookie is then plain, and an absolute
153
+ `https://` `Location` does not match. Give the public origin there. Its
154
+ protocol decides `Secure` and the name: `__Host-alxia_oauth_request` over
155
+ HTTPS, `alxia_oauth_request` over plain HTTP; `oauthConsent({ origin })` takes the same origin and reads that one name (without it, the name of its own request's scheme), so a cookie planted over HTTP is not read on HTTPS (`CONSENT_COOKIE`,
156
+ `CONSENT_COOKIE_PLAIN`, also exported by `@softistx/alxia-react-router/oauth`).
157
+ - A newer authorize replaces the cookie: one pending consent per browser.
158
+ - `Lax`, not `Strict`: the authorize link comes from the client's site, and a
159
+ `Strict` cookie would not come back on that navigation. The binding cookie
160
+ does not depend on your session cookie. If *your session* cookie is
161
+ `Strict`, a browser arriving cross-site from a web-based client is asked to
162
+ sign in again on the consent page, whatever the binding does.
163
+ - `consent: false` turns it off, for an app that binds some other way.
164
+
165
+ ## Errors
166
+
167
+ | status | when |
168
+ | --- | --- |
169
+ | 413 | the request body is over the path's limit |
170
+ | 502 | the API cannot be reached |
171
+ | 504 | the API sent no response headers within `timeout` |
172
+
173
+ Any other status is the API's own, passed through.
@@ -0,0 +1,273 @@
1
+ # Media through the BFF
2
+
3
+ A browser never talks to the API for a file, nor to the bucket. It asks your
4
+ app, which relays to the API's [`@softistx/alxia-media`](https://github.com/softistx/alxia/blob/develop/packages/media/docs/guide.md)
5
+ routes. `@softistx/alxia-react-router/media` is that relay: one resource route,
6
+ mounted at `/media/*`, for uploads, reads and deletes.
7
+
8
+ It imports nothing (web APIs only), so it adds no peer.
9
+
10
+ ## Mount it
11
+
12
+ ```ts
13
+ // app/routes.ts
14
+ import { index, route, type RouteConfig } from '@react-router/dev/routes';
15
+
16
+ export default [
17
+ index('routes/home.tsx'),
18
+ route('media/*', 'routes/media.ts'),
19
+ ] satisfies RouteConfig;
20
+ ```
21
+
22
+ ```ts
23
+ // app/routes/media.ts
24
+ import { proxyMediaRead, proxyMediaWrite, type MediaProxyOptions } from '@softistx/alxia-react-router/media';
25
+ import type { ActionFunctionArgs, LoaderFunctionArgs } from 'react-router';
26
+
27
+ declare function sessionToken(request: Request): string | null;
28
+
29
+ const options: MediaProxyOptions = {
30
+ api: 'https://api.internal:3000',
31
+ // the kinds the API declares, with the maxBytes of each
32
+ kinds: { 'question-files': { maxBytes: 10 * 1024 * 1024 }, avatars: { maxBytes: 512 * 1024 } },
33
+ getToken: (request) => sessionToken(request),
34
+ headers: { 'x-client': 'web', 'x-proxy-secret': process.env.API_PROXY_SECRET },
35
+ };
36
+
37
+ export const loader = (args: LoaderFunctionArgs) => proxyMediaRead(args, options);
38
+ export const action = (args: ActionFunctionArgs) => proxyMediaWrite(args, options);
39
+ ```
40
+
41
+ `loader` serves `GET` and `HEAD`, `action` serves `PUT` and `DELETE`.
42
+
43
+ | option | |
44
+ | --- | --- |
45
+ | `api` | the API's origin (a path in it is ignored: use `apiPrefix`) |
46
+ | `kinds` | each kind the browser may reach, with its `maxBytes`. Another kind is a 404 |
47
+ | `getToken` | the session's token, from the request. Required for a write (401 without); a read goes on without it, since a public kind needs none |
48
+ | `headers` | extra headers for the API (client name, proxy secret, `X-Forwarded-For`), fixed or built from the request and the route's `context` and `params`. They reach the API only, as written; `Authorization` is replaced by the session's Bearer when there is one |
49
+ | `origin` | the app's own origin for the cross-site check; the request's by default |
50
+ | `prefix` | where the route is mounted on the app, `/media` by default |
51
+ | `apiPrefix` | where `mediaRoutes` is mounted on the API; the same as `prefix` by default |
52
+ | `fetch` | the `fetch` used upstream; the global `fetch` by default |
53
+ | `timeout` | milliseconds the API has to send its response's headers, `60000` by default; past it, a 504 and the upstream request is aborted. `Infinity` sets no deadline; `0`, a negative number, `NaN` or more than `2147483647` is a 500 `proxy_misconfigured`. The timer stops when the headers arrive, so a long download still streams. An upload is answered after its body: raise it for large files |
54
+ | `allowUnsized` | `false` by default: a `PUT` with no `Content-Length` is a 411. `true` lets it go on, the API capping it (and holding it in memory) |
55
+ | `onRefusal` | words every answer of 400 and above, the proxy's and the API's: see [Wording the answers](#wording-the-answers) |
56
+ | `onSuccess` | shapes the API's 2xx JSON answer to a `PUT` or `DELETE` |
57
+ | `forwardQuery` | the query parameters that go to the API: a list of names, or `true`. None by default: see [The query string](#the-query-string) |
58
+ | `requireHeaders` | headers a write must carry, name to exact value; a missing one is a 403 `header_required`: see [Requiring a header](#requiring-a-header) |
59
+
60
+ ## What it does
61
+
62
+ - **Same-site only.** A request with a foreign `Origin` or a `Sec-Fetch-Site`
63
+ other than `same-origin` / `none` is a 403, before the API is called.
64
+ - **The path is checked.** Only `<prefix>/<kind>` (PUT), `<prefix>/<kind>/<key>`
65
+ (GET, HEAD, DELETE) and `<prefix>/<kind>/<key>/<size>` (GET, HEAD) go up: the
66
+ kind must be in `kinds`, the key a UUID, the size a word. Anything else is a
67
+ 404 and the API is not called.
68
+ - **Credentials.** The API receives `Authorization: Bearer <session token>` and
69
+ your `headers`. The browser's `Cookie`, `Authorization` and `X-API-Key` never
70
+ go, and neither does any other header than the ones below.
71
+ - **Reads.** `Range`, `If-None-Match`, `If-Range` and `Accept` go up. The
72
+ status (`200`, `206`, `304`, `404`, `416`, ...) comes back with an allowlist
73
+ of the API's headers: `Content-Type`, `Content-Length`, `Content-Range`,
74
+ `Accept-Ranges`, `ETag`, `Last-Modified`, `Cache-Control`,
75
+ `Content-Disposition`, `X-Content-Type-Options`,
76
+ `Cross-Origin-Resource-Policy`, `Content-Security-Policy`, `Retry-After`
77
+ and `Vary`. Everything else (`Set-Cookie`, `WWW-Authenticate`, `Alt-Svc`,
78
+ `Access-Control-*`, `Server`, `Link`, `Content-Location`) stays behind. The
79
+ body is streamed, never held.
80
+ - **Uploads.** `Content-Type` and `Content-Length` go up with the body, streamed
81
+ both ways. A `PUT` with no `Content-Length` (a chunked body) is a 411
82
+ `length_required`, so the size is checked before a byte is sent; a `File` or
83
+ `Blob` body declares its length. `allowUnsized: true` lets one go on, the API
84
+ capping it, at the price of holding it in memory. A declared length over the
85
+ kind's `maxBytes` is a 413 before the API is called. The API's answer, `{ key,
86
+ contentType, size }` or a 400, 403, 408, 413, 415, 422, 429 or 503, comes
87
+ back unchanged.
88
+ - **A deadline.** The API has `timeout` to send its headers; the same abort
89
+ cuts the upstream request when the client leaves.
90
+ - **Its own refusals** have the API's shape, `{ "error": "<code>" }` plus
91
+ extras (`limit` on a 413), with `Cache-Control: no-store`. They are always
92
+ this JSON, even when the API answers its own refusals as `problem+json`
93
+ (`errorFormat`): a client that reads both reads `error` first. The codes are
94
+ [`@softistx/alxia-media`'s](https://github.com/softistx/alxia/blob/develop/packages/media/README.md#refusals)
95
+ where the API has one (`not_found`, `too_large`, `size_mismatch` for a
96
+ Content-Length that is not a number); these exist only at the proxy:
97
+
98
+ | status | code | when |
99
+ | --- | --- | --- |
100
+ | 401 | `unauthenticated` | a write without a session |
101
+ | 403 | `forbidden` | a cross-site request |
102
+ | 403 | `header_required` | a write lacking a header of `requireHeaders`, or carrying another value |
103
+ | 405 | `method_not_allowed` | the wrong method for the function (`Allow` says which) |
104
+ | 411 | `length_required` | a `PUT` without `Content-Length` |
105
+ | 500 | `proxy_misconfigured` | `headers`, `getToken`, `onRefusal` or `onSuccess` threw, a header is invalid, or `timeout` is not `Infinity` or a number from 1 to 2147483647 |
106
+ | 502 | `unavailable` | the API is unreachable, the request was aborted, or the API redirected |
107
+ | 504 | `unavailable` | the API sent no headers within `timeout` |
108
+
109
+ ## Wording the answers
110
+
111
+ By default the API's body and status pass through and the proxy's refusals are
112
+ `{ "error": "<code>" }`. An app that answers in its own shape sets two hooks,
113
+ both optional, both after the API has answered (or the proxy has refused):
114
+
115
+ ```ts
116
+ import type { MediaProxyOptions } from '@softistx/alxia-react-router/media';
117
+
118
+ declare function messageFor(code: string | undefined, request: Request): string;
119
+
120
+ export const options: Pick<MediaProxyOptions, 'onRefusal' | 'onSuccess'> = {
121
+ // every answer of 400 and above, on reads and writes
122
+ onRefusal: (refusal, request) => ({
123
+ ok: false,
124
+ error: messageFor(refusal.code, request), // e.g. in the viewer's language
125
+ }),
126
+ // the 2xx JSON of a PUT or DELETE
127
+ onSuccess: ({ body }) => ({ ok: true, key: (body as { key: string }).key }),
128
+ };
129
+ ```
130
+
131
+ `refusal` has `status`, `source` (`'proxy'` for the proxy's own codes,
132
+ `'api'` for the API's answer), `code` (the body's `error`, else the `code` of a
133
+ problem or of the first entry of `errors[]`), `body` (the parsed JSON, or
134
+ `undefined` when the API's was not JSON or over 64 KiB) and `headers`. A hook
135
+ returns a `Response` (sent as it is), data (sent as JSON with the same status;
136
+ refusals stay `no-store`) or `undefined` to keep the default. One that throws
137
+ is a 500 `proxy_misconfigured`.
138
+
139
+ Data returned for a 204 or 205 (`@softistx/alxia-media`'s `DELETE` answers 204) is sent
140
+ as a 200 JSON, since those statuses cannot carry a body; a `Response` you
141
+ return is sent as you built it. The hooks read at most 64 KiB of the API's JSON
142
+ body, counted as it streams (a chunked or compressed body has no usable
143
+ `Content-Length`): past that, `body` is `undefined`, and when the hook keeps the
144
+ default the whole answer still goes through, streamed.
145
+
146
+ A read's success is a streamed file and `onSuccess` never touches it. Both
147
+ hooks are off by default, so a route without them answers as before.
148
+
149
+ ## The query string
150
+
151
+ `@softistx/alxia-media`'s own routes read no query parameter, so the proxy forwards none
152
+ by default: whatever a browser appends would otherwise reach the API's
153
+ middlewares (an app-level crop or resize step, say) unasked. `forwardQuery`
154
+ opts in, for writes and for reads alike (a rendition read may need its
155
+ parameters too):
156
+
157
+ ```ts
158
+ const options = { forwardQuery: ['x', 'y', 'size'] }; // PUT /media/avatar?x=10&y=20&size=256
159
+ // forwardQuery: true sends every parameter
160
+ ```
161
+
162
+ Names not listed are dropped; repeated names are kept in order. Prefer the
163
+ list: it keeps a parameter the API did not expect from reaching it.
164
+
165
+ ## Requiring a header
166
+
167
+ Same-site checks pass a request that carries neither `Origin` nor
168
+ `Sec-Fetch-Site` (a script, `curl`). `requireHeaders` adds a check the page's
169
+ own code satisfies and a stray request does not:
170
+
171
+ ```ts
172
+ const options = { requireHeaders: { 'x-example-client': 'example-ui' } };
173
+ ```
174
+
175
+ On `PUT` and `DELETE`, a missing header or a different value (names compared
176
+ without case, values exactly) is a 403 `header_required` before the API is
177
+ called. Reads are not checked. It is a guard against stray writes, not a secret:
178
+ the page sends the value.
179
+
180
+ ## From the page
181
+
182
+ `@softistx/alxia-react-router/media/client` is the page's side. It imports nothing and
183
+ uses only browser APIs, so it is safe in the client bundle (keep the proxy
184
+ functions out of client code: they belong to the resource route).
185
+
186
+ ```tsx
187
+ import { MediaUploadError, uploadMedia } from '@softistx/alxia-react-router/media/client';
188
+
189
+ async function upload(
190
+ file: File,
191
+ onProgress: (percent: number) => void,
192
+ signal: AbortSignal,
193
+ ): Promise<string> {
194
+ try {
195
+ const stored = await uploadMedia('question-files', file, { onProgress, signal });
196
+ return stored.key; // keep the key, not a URL
197
+ } catch (error) {
198
+ if (error instanceof MediaUploadError && error.reason === 'too_large') {
199
+ throw new Error('This file is too large');
200
+ }
201
+ throw error;
202
+ }
203
+ }
204
+
205
+ export const Picture = ({ fileKey }: { fileKey: string }) => (
206
+ <img src={`/media/question-files/${fileKey}`} alt="" />
207
+ );
208
+ ```
209
+
210
+ `upload` has the shape of an upload field's `onUpload(file, onProgress, signal)`.
211
+
212
+ `uploadMedia(kind, file, options)` sends `PUT <basePath>/<kind>` with the raw
213
+ file and its `Content-Type`, on `XMLHttpRequest` since `fetch` cannot report
214
+ upload progress.
215
+
216
+ | option | |
217
+ | --- | --- |
218
+ | `onProgress` | called with 0 to 100 as the body goes up, and with 100 once the file is stored |
219
+ | `signal` | aborts the request; an already aborted signal sends nothing |
220
+ | `basePath` | where the route is mounted, `/media` by default (the proxy's `prefix`) |
221
+ | `timeoutMs` | milliseconds the whole request may take; past it, reason `timeout`. None by default |
222
+ | `headers` | extra request headers, such as the one `requireHeaders` demands |
223
+ | `query` | query parameters added to the URL: `{ fx: 0.4, fy: 0.6 }` sends `PUT /media/<kind>?fx=0.4&fy=0.6`; `undefined` and `null` values are left out. The route passes them on with `forwardQuery` |
224
+
225
+ It resolves `{ key, contentType, size }` and rejects with a `MediaUploadError`:
226
+ `status` is the HTTP status (`0` when there was none), `code` the `error` of the
227
+ JSON refusal when there is one, `body` the whole JSON refusal (`undefined` when
228
+ the answer is no JSON object), `retryAfter` the seconds the answer's
229
+ `Retry-After` header asks to wait (whole seconds or an HTTP date; `undefined`
230
+ when absent or invalid), and `reason` one of:
231
+
232
+ | reason | when |
233
+ | --- | --- |
234
+ | `unauthenticated` | 401 |
235
+ | `forbidden` | 403 (cross-site, or `header_required`) |
236
+ | `length_required` | 411 |
237
+ | `too_large` | 413 |
238
+ | `type_refused` | 415 |
239
+ | `rate_limited` | 429 |
240
+ | `unavailable` | 502 or 503 |
241
+ | `timeout` | 504, or the request timed out |
242
+ | `failed` | any other refusal |
243
+ | `network` | the request got no answer |
244
+ | `invalid_response` | a 2xx whose body is not `{ key, contentType, size }` |
245
+ | `aborted` | the `signal` fired |
246
+
247
+ ```ts
248
+ if (error instanceof MediaUploadError && error.reason === 'rate_limited') {
249
+ const minutes = Math.ceil((error.retryAfter ?? 60) / 60);
250
+ // "Patientez {minutes} minute(s)" in the page's language
251
+ }
252
+ ```
253
+
254
+ The refusal's other fields stay in `body`, to say why a file was refused:
255
+
256
+ ```ts
257
+ if (error instanceof MediaUploadError && error.status === 422) {
258
+ const why = error.body?.reason; // the route's own words, e.g. "image too small"
259
+ }
260
+ ```
261
+
262
+ Word the `reason` in the page's own language; a server-side `onRefusal` does
263
+ not change `reason`, which comes from the status.
264
+
265
+ The path is on your own origin, so `img-src 'self'` is enough in the CSP.
266
+
267
+ ## Caching
268
+
269
+ The API sends `Cache-Control: private, max-age=31536000, immutable` for a
270
+ private file. The proxy passes it through, so **do not** list `/media` in a
271
+ middleware that sets `Cache-Control: no-store` on the app's responses (or
272
+ exempt it): a no-store there would turn off the browser's year-long cache.
273
+ The proxy's own refusals are `no-store`.