@alxia/react-router 0.35.0 → 0.36.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/errors/api-errors.d.ts +7 -0
- package/dist/errors/api-errors.d.ts.map +1 -1
- package/dist/errors/describe.d.ts.map +1 -1
- package/dist/errors/field-placement.d.ts +12 -0
- package/dist/errors/field-placement.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 +1 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +30 -10
- package/dist/errors/index.js.map +8 -6
- package/dist/errors/submit-form.d.ts.map +1 -1
- package/dist/fetcher/index.d.ts +1 -0
- package/dist/fetcher/index.d.ts.map +1 -1
- package/dist/fetcher/index.js +11 -2
- package/dist/fetcher/index.js.map +5 -4
- package/dist/fetcher/use-form-refusal.d.ts +20 -0
- package/dist/fetcher/use-form-refusal.d.ts.map +1 -0
- package/docs/guide/errors.md +47 -1
- package/docs/roadmap.md +1 -1
- package/docs/troubleshooting.md +3 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1322,7 +1322,7 @@ From `@alxia/react-router/errors` (`react-router` is its only package import, an
|
|
|
1322
1322
|
| `CatalogueMessage`, `CatalogueMessages`, `ParamKind`, `MessageFormat`, `MessageValues` | one API message with the kind of each argument (`TEXT`, `NUMBER`, `DATE`, `PLURAL`, `SELECT`), a language's messages by code, and the formatter's type |
|
|
1323
1323
|
| `apiCodeResolver(messages, { translate, language, codeOf?, isApiCode? })`, `ApiCodeResolver`, `ApiCodeResolverOptions`, `CodeIssueLike` | the `{ translate, codeOf }` a form's `useCodeResolver(schema, resolver)` takes: a check's API code is worded as the API words it, any other key by the app's translator; `CodeIssueLike` is the issue a custom `codeOf` receives |
|
|
1324
1324
|
| `ApiMessagesProvider({ messages, value, children })`, `ApiMessagesProviderProps` | `messages` is the store and `value` the root loader's data; fills the store in the browser from the root's data before the children render; a server render writes nothing. A function with no JSX, so no React import |
|
|
1325
|
-
| `createApiErrors({ messages, unavailable, refused?, byCode?, reword?, isApiCode? })`, `ApiErrors`, `ApiErrorsOptions`, `FetcherResultOptions` | what a page says of a refusal, in a language: `apiErrorMessage(error, language)` (the catalogue's text of the code, else the API's message; `refused` replaces it for an error with no API code and `byCode` words given codes, such as a query's limits; `reword(text, error, { code, values, language })` words a family of codes once, on the final text of the catalogue, the API or `byCode`, returning `undefined` to keep it), `fieldErrors(error, language)` by input path, `translateCode(code, fallback, language, values?)`, `unavailableMessage(language)` and `apiRefusal(error, language)`; for an action, `fetcherResult(language, about, run, options?)` (`{ ok: true, …about, …value }`, or `{ ok: false, …about, error }` with the refusal's status; `options` is `FetcherResultOptions`: the `route` options plus `reword(error: ApiErrorLike)`, called for an API's own refusal only: the message of this call, or `undefined` to keep the worded one), `fetcherRefusal(error, language, route?)` (the refusal, or the thrown route error) and `submitForm(language, run, fieldOf, route?)` (`{ ok: true, value }`, or a `FormErrors` with the refusal's status); `route` is the `RouteErrorOptions` of the `routeError` they throw through |
|
|
1325
|
+
| `createApiErrors({ messages, unavailable, refused?, byCode?, reword?, isApiCode? })`, `ApiErrors`, `ApiErrorsOptions`, `FetcherResultOptions` | what a page says of a refusal, in a language: `apiErrorMessage(error, language)` (the catalogue's text of the code, else the API's message; `refused` replaces it for an error with no API code and `byCode` words given codes, such as a query's limits; `reword(text, error, { code, values, language })` words a family of codes once, on the final text of the catalogue, the API or `byCode`, returning `undefined` to keep it), `fieldErrors(error, language)` by input path, `translateCode(code, fallback, language, values?)`, `unavailableMessage(language)` and `apiRefusal(error, language)`; for an action, `fetcherResult(language, about, run, options?)` (`{ ok: true, …about, …value }`, or `{ ok: false, …about, error }` with the refusal's status; `options` is `FetcherResultOptions`: the `route` options plus `reword(error: ApiErrorLike)`, called for an API's own refusal only: the message of this call, or `undefined` to keep the worded one), `fetcherRefusal(error, language, route?)` (the refusal, or the thrown route error) and `submitForm(language, run, fieldOf, route?)` (`{ ok: true, value }`, or a `FormErrors` with the refusal's status); `formRefusal(error, language, fieldOf, route?)` (`{ error, fieldErrors, status }` for a fetcher form: each field issue under the form field `fieldOf` names, `error` empty when every issue found its field); `route` is the `RouteErrorOptions` of the `routeError` they throw through |
|
|
1326
1326
|
| `apiCallFailure(error, { api, operation?, requestId?, signal?, passedThrough?, log? })`, `CallFailureOptions` | what a failed call to the API becomes, for a loader or an action to throw, logged with the request id: an `ApiError` as it is (with `requestId`), a `Response` of its own status for a 401, 403 or 404 without a GraphQL body, a 503 `Response` with no body for an unreachable, slow, garbled or aborted call (the reason is in the log), any other error as it is; the log lines start with `api`, and a `log` that throws never replaces the outcome. It recognises `@nxgt/graphql-client`'s errors by `name`, not `instanceof` |
|
|
1327
1327
|
| `operationName(document)`, `DocumentLike` | the name of the operation a document holds, for the log (else `query`, `mutation` or `subscription`); a structural `{ definitions }`, so `graphql`'s `DocumentNode` fits |
|
|
1328
1328
|
| `createErrorCatalogue({ messages, languages, read, versions, ttlMs, clientCodes, retryMs?, firstReadWaitMs?, log? })`, `ErrorCatalogue`, `ErrorCatalogueOptions`, `CatalogueReply` | keeps the API's error catalogue in the store: `fresh(language, now?)` and `freshAll(now?)` (a cold language is awaited for `firstReadWaitMs`, 1500 by default, and read once however many requests ask; a held one is served, and its version checked in the background once per `ttlMs`, a number or a getter; only a language whose version moved is read again; a failure is retried after `retryMs`, 5000 by default), `warm()` for startup, `clientMessages()` (the `clientCodes` the browser words itself, by language, for the root's loader), and, for tests, `reset()`, `heldVersion(language)`, `settled()` and the `now` parameters. `read` and `versions` are the app's calls to its API |
|
|
@@ -1419,6 +1419,7 @@ From `@alxia/react-router/fetcher` (`react` and `react-router` are its imports;
|
|
|
1419
1419
|
| export | |
|
|
1420
1420
|
| --- | --- |
|
|
1421
1421
|
| `useFetcherAnswer(fetcher, onAnswer?)`, `AnswerSource` | `onAnswer(answer)` once per answer that arrives while the fetcher is idle and differs from the last one seen (the data present at mount counts as seen); the handler is read from a ref; returns the latest answer handed over, `undefined` before the first |
|
|
1422
|
+
| `useFormRefusal(result)`, `FormRefusalResult` | `useFormRefusal(fetcher.data)` returns the `FormErrors` of a fetcher answer that carries `fieldErrors` (`apiErrors.formRefusal`'s), `undefined` for no answer, a done step or a refusal without them; stable for one answer |
|
|
1422
1423
|
| `useDebouncedFetcher(value, to, { delayMs?, minLength?, enabled?, key?, keep? }?)`, `DebouncedFetcher`, `DebouncedFetcherOptions`, `DebouncedFetcherState` | a resource route loaded for what is typed: one `fetcher.load` after `delayMs` (250) without a change and from `minLength` (1) trimmed characters; `to` is a URL or `(value) => url`; returns `{ data, stale, state, retry }`: `data` is the answer for the value as it stands, else the previous one with `stale` set; `state` is `'idle' \| 'waiting' \| 'loading' \| 'done'`; `keep(answer)` filters what may stay as the stale answer; `retry()` (stable) asks again at once |
|
|
1423
1424
|
|
|
1424
1425
|
From `@alxia/react-router/subscription` (no import, no peer):
|
|
@@ -2,6 +2,7 @@ import type { data } from 'react-router';
|
|
|
2
2
|
import type { ApiErrorLike } from './api-error';
|
|
3
3
|
import type { FetcherResultOptions } from './fetcher-result';
|
|
4
4
|
import type { FormErrors } from './form-errors';
|
|
5
|
+
import type { FormRefusal } from './form-refusal';
|
|
5
6
|
import type { ApiMessages } from './messages';
|
|
6
7
|
import type { RouteErrorOptions } from './route-error';
|
|
7
8
|
/** A refused call, as a page says it: the message, and the HTTP status to answer. */
|
|
@@ -82,6 +83,12 @@ export interface ApiErrors<L extends string> {
|
|
|
82
83
|
* thrown, through `routeError`, for the error page.
|
|
83
84
|
*/
|
|
84
85
|
fetcherRefusal(error: unknown, language: L, route?: RouteErrorOptions): ApiRefusal;
|
|
86
|
+
/**
|
|
87
|
+
* A fetcher form's refusal (`fetcherRefusal`) with its field issues under
|
|
88
|
+
* the form field `fieldOf` names for each input path: `{ error,
|
|
89
|
+
* fieldErrors, status }`, `error` empty when every issue found its field.
|
|
90
|
+
*/
|
|
91
|
+
formRefusal(error: unknown, language: L, fieldOf: (path: string) => string | undefined, route?: RouteErrorOptions): FormRefusal;
|
|
85
92
|
/**
|
|
86
93
|
* Runs the mutation of an action a fetcher posted to: `{ ok: true }` with
|
|
87
94
|
* `about` and the mutation's value, or `{ ok: false, error }` with `about`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-errors.d.ts","sourceRoot":"","sources":["../../src/errors/api-errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,qFAAqF;AACrF,MAAM,MAAM,UAAU,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,MAAM;IACjD,qDAAqD;IACrD,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACzB;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC;IACjC;;;;OAIG;IACH,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC;IAC9B;;;;OAIG;IACH,MAAM,CAAC,EAAE,QAAQ,CAChB,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,KAAK,MAAM,CAAC,CAC5D,CAAC;IACF;;;;;;;;;;OAUG;IACH,MAAM,CAAC,CACN,IAAI,EAAE,MAAM,EACZ,KAAK,E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,CAAC,EACX,QAAQ,EAAE,CAAC,EACX,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACrB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EAC7C,KAAK,CAAC,EAAE,iBAAiB,GACvB,OAAO,CAAC;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,KAAK,EAAE,CAAC,CAAA;KAAE,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;CACzE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,EAC/C,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAC1B,SAAS,CAAC,CAAC,CAAC,CAEd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/errors/describe.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/errors/describe.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOhE,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,EACnD,QAAQ,EACR,WAAW,EACX,OAAO,EACP,MAAM,EACN,MAAW,EACX,SAAyC,GACzC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAqDpC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ApiErrorLike } from './api-error';
|
|
2
|
+
import type { ApiErrors } from './api-errors';
|
|
3
|
+
/**
|
|
4
|
+
* The field messages of a refusal placed under the form fields `fieldOf`
|
|
5
|
+
* names for their input paths: `byField`, and the messages of the paths it
|
|
6
|
+
* names no field for (`unplaced`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function placeFieldErrors<L extends string>(errors: Pick<ApiErrors<L>, 'fieldErrors'>, error: ApiErrorLike, language: L, fieldOf: (path: string) => string | undefined): {
|
|
9
|
+
byField: Record<string, string>;
|
|
10
|
+
unplaced: string[];
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=field-placement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-placement.d.ts","sourceRoot":"","sources":["../../src/errors/field-placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAChD,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,EACzC,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAC3C;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAWzD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ApiErrors } from './api-errors';
|
|
2
|
+
import type { RouteErrorOptions } from './route-error';
|
|
3
|
+
/** What `apiErrors.formRefusal` answers: a form's refusal, for a fetcher's action. */
|
|
4
|
+
export interface FormRefusal {
|
|
5
|
+
/**
|
|
6
|
+
* The message for the form as a whole: empty when every field issue found
|
|
7
|
+
* its form field, else the refusal's message followed by the messages of
|
|
8
|
+
* the issues that found none (as `submitForm`'s `formError`).
|
|
9
|
+
*/
|
|
10
|
+
error: string;
|
|
11
|
+
/** Messages by form field, already translated. */
|
|
12
|
+
fieldErrors: Record<string, string>;
|
|
13
|
+
/** The refusal's HTTP status. */
|
|
14
|
+
status: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A fetcher form's refusal (`fetcherRefusal`) with each field issue placed
|
|
18
|
+
* under the form field `fieldOf` names for its input path. `error` is empty
|
|
19
|
+
* when every issue found its field, else the refusal's message with the
|
|
20
|
+
* messages of the unplaced issues. An unreachable API gives the unavailable
|
|
21
|
+
* message with no field errors, as `fetcherRefusal` does; a 401 or any other
|
|
22
|
+
* failure is thrown for the error page.
|
|
23
|
+
*/
|
|
24
|
+
export declare function formRefusal<L extends string>(errors: Pick<ApiErrors<L>, 'apiRefusal' | 'fieldErrors'>, error: unknown, language: L, fieldOf: (path: string) => string | undefined, route?: RouteErrorOptions): FormRefusal;
|
|
25
|
+
//# sourceMappingURL=form-refusal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-refusal.d.ts","sourceRoot":"","sources":["../../src/errors/form-refusal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,sFAAsF;AACtF,MAAM,WAAW,WAAW;IAC3B;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAC3C,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC,EACxD,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EAC7C,KAAK,CAAC,EAAE,iBAAiB,GACvB,WAAW,CAkBb"}
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { type CatalogueReply, createErrorCatalogue, type ErrorCatalogue, type Er
|
|
|
5
5
|
export { type ApiCodeResolver, type ApiCodeResolverOptions, apiCodeResolver, type CodeIssueLike, } from './code-resolver';
|
|
6
6
|
export type { FetcherResultOptions } from './fetcher-result';
|
|
7
7
|
export type { FormErrors } from './form-errors';
|
|
8
|
+
export type { FormRefusal } from './form-refusal';
|
|
8
9
|
export { type JsonActions, type JsonActionsOptions, jsonActions, } from './json-actions';
|
|
9
10
|
export { type ApiMessages, type ApiMessagesOptions, type CatalogueMessage, type CatalogueMessages, createApiMessages, type MessageFormat, type MessageValues, type ParamKind, } from './messages';
|
|
10
11
|
export { nextOf } from './page-path';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,WAAW,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,eAAe,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,aAAa,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,KAAK,cAAc,EACnB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,eAAe,EACf,KAAK,aAAa,GAClB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,WAAW,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,iBAAiB,EACjB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,SAAS,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACN,mBAAmB,EACnB,KAAK,wBAAwB,GAC7B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EACN,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,UAAU,GACV,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,KAAK,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,WAAW,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,eAAe,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,aAAa,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,KAAK,cAAc,EACnB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,eAAe,EACf,KAAK,aAAa,GAClB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,WAAW,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,iBAAiB,EACjB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,SAAS,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACN,mBAAmB,EACnB,KAAK,wBAAwB,GAC7B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EACN,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,UAAU,GACV,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,KAAK,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/errors/index.js
CHANGED
|
@@ -81,6 +81,33 @@ async function fetcherResult(errors, language, about, run, options) {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
// src/errors/field-placement.ts
|
|
85
|
+
function placeFieldErrors(errors, error, language, fieldOf) {
|
|
86
|
+
const byField = {};
|
|
87
|
+
const unplaced = [];
|
|
88
|
+
for (const [path, message] of Object.entries(errors.fieldErrors(error, language))) {
|
|
89
|
+
const field = fieldOf(path);
|
|
90
|
+
if (field)
|
|
91
|
+
byField[field] = message;
|
|
92
|
+
else
|
|
93
|
+
unplaced.push(message);
|
|
94
|
+
}
|
|
95
|
+
return { byField, unplaced };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// src/errors/form-refusal.ts
|
|
99
|
+
function formRefusal(errors, error, language, fieldOf, route) {
|
|
100
|
+
const { message, status } = fetcherRefusal(errors, error, language, route);
|
|
101
|
+
if (!isApiErrorLike2(error))
|
|
102
|
+
return { error: message, fieldErrors: {}, status };
|
|
103
|
+
const { byField, unplaced } = placeFieldErrors(errors, error, language, fieldOf);
|
|
104
|
+
return {
|
|
105
|
+
error: Object.keys(byField).length && !unplaced.length ? "" : [message, ...unplaced].join(" "),
|
|
106
|
+
fieldErrors: byField,
|
|
107
|
+
status
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
84
111
|
// src/errors/submit-form.ts
|
|
85
112
|
import { data as data2 } from "react-router";
|
|
86
113
|
async function submitForm(errors, language, run, fieldOf, route) {
|
|
@@ -94,15 +121,7 @@ async function submitForm(errors, language, run, fieldOf, route) {
|
|
|
94
121
|
if (error.status === 404 && !(field && fieldOf(field))) {
|
|
95
122
|
throw routeError2(error, route);
|
|
96
123
|
}
|
|
97
|
-
const byField =
|
|
98
|
-
const unplaced = [];
|
|
99
|
-
for (const [path, message] of Object.entries(errors.fieldErrors(error, language))) {
|
|
100
|
-
const field = fieldOf(path);
|
|
101
|
-
if (field)
|
|
102
|
-
byField[field] = message;
|
|
103
|
-
else
|
|
104
|
-
unplaced.push(message);
|
|
105
|
-
}
|
|
124
|
+
const { byField, unplaced } = placeFieldErrors(errors, error, language, fieldOf);
|
|
106
125
|
const formError = Object.keys(byField).length && !unplaced.length ? undefined : [errors.apiErrorMessage(error, language), ...unplaced].join(" ");
|
|
107
126
|
return data2({ fieldErrors: byField, formError }, { status: error.status });
|
|
108
127
|
}
|
|
@@ -144,6 +163,7 @@ function describeApiErrors({
|
|
|
144
163
|
fieldErrors,
|
|
145
164
|
apiRefusal,
|
|
146
165
|
fetcherRefusal: (error, language, route) => fetcherRefusal(parts, error, language, route),
|
|
166
|
+
formRefusal: (error, language, fieldOf, route) => formRefusal(parts, error, language, fieldOf, route),
|
|
147
167
|
fetcherResult: (language, about, run, options) => fetcherResult(parts, language, about, run, options),
|
|
148
168
|
submitForm: (language, run, fieldOf, route) => submitForm(parts, language, run, fieldOf, route)
|
|
149
169
|
};
|
|
@@ -542,5 +562,5 @@ export {
|
|
|
542
562
|
waitMinutes2 as waitMinutes
|
|
543
563
|
};
|
|
544
564
|
|
|
545
|
-
//# debugId=
|
|
565
|
+
//# debugId=15421DF8DF81973764756E2164756E21
|
|
546
566
|
//# sourceMappingURL=index.js.map
|
package/dist/errors/index.js.map
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/errors/code-resolver.ts", "../src/errors/describe-refusal.ts", "../src/errors/fetcher-result.ts", "../src/errors/submit-form.ts", "../src/errors/describe.ts", "../src/errors/api-errors.ts", "../src/errors/log.ts", "../src/errors/call-failure.ts", "../src/errors/catalogue-check.ts", "../src/errors/catalogue-read.ts", "../src/errors/catalogue.ts", "../src/errors/json-actions.ts", "../src/errors/message-values.ts", "../src/errors/messages.ts", "../src/errors/provider.ts", "../src/errors/use-json-fetcher.ts"],
|
|
3
|
+
"sources": ["../src/errors/code-resolver.ts", "../src/errors/describe-refusal.ts", "../src/errors/fetcher-result.ts", "../src/errors/field-placement.ts", "../src/errors/form-refusal.ts", "../src/errors/submit-form.ts", "../src/errors/describe.ts", "../src/errors/api-errors.ts", "../src/errors/log.ts", "../src/errors/call-failure.ts", "../src/errors/catalogue-check.ts", "../src/errors/catalogue-read.ts", "../src/errors/catalogue.ts", "../src/errors/json-actions.ts", "../src/errors/message-values.ts", "../src/errors/messages.ts", "../src/errors/provider.ts", "../src/errors/use-json-fetcher.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { ApiMessages } from './messages';\n\n/** The part of a zod issue a code reads, by shape (`@nxgt/material-core`'s `CodeIssue`). */\nexport type CodeIssueLike = {\n\treadonly code: string;\n\t/** A custom issue's params: `.refine(…, { params: { code } })`. */\n\treadonly params?: Record<string, unknown> | undefined;\n\treadonly input?: unknown;\n\treadonly origin?: string | undefined;\n\treadonly minimum?: unknown;\n\treadonly maximum?: unknown;\n\treadonly expected?: unknown;\n\treadonly message?: string | undefined;\n};\n\n/** An API error code (`<module>.errors.<slug>`, the module in kebab-case or camelCase), as opposed to a GraphQL one (`BAD_USER_INPUT`). */\nexport const API_CODE = /^[a-z][a-zA-Z0-9-]*\\.errors\\.[a-z0-9-]+$/;\n\nexport interface ApiCodeResolverOptions<L extends string> {\n\t/**\n\t * The app's translator, for every key that is not an API code. Method\n\t * syntax: the app's own `Translate<LocaleKey>` is accepted.\n\t */\n\ttranslate(\n\t\tkey: string,\n\t\tcontext?: Readonly<Record<string, unknown>>,\n\t\tlanguage?: L | (() => L),\n\t): string;\n\t/** The page's language, when a call names none. */\n\tlanguage(): L;\n\t/** Which code an issue carries; the issue's `params.code` by default. */\n\tcodeOf?(issue: CodeIssueLike): string | undefined;\n\t/** Whether a key is an API code; `<module>.errors.<slug>` by default. */\n\tisApiCode?(key: string): boolean;\n}\n\n/** What `@nxgt/material`'s `useCodeResolver(schema, resolver)` takes. */\nexport interface ApiCodeResolver<L extends string> {\n\ttranslate: (\n\t\tkey: string,\n\t\tcontext?: Readonly<Record<string, unknown>>,\n\t\tlanguage?: L | (() => L),\n\t) => string;\n\tcodeOf: (issue: CodeIssueLike) => string | undefined;\n}\n\nfunction paramsCode(issue: CodeIssueLike) {\n\tconst code = (issue.params as { code?: unknown } | undefined)?.code;\n\treturn typeof code === 'string' ? code : undefined;\n}\n\n/**\n * The words of what a form's checks ask for: a refinement carrying an API\n * code in `params.code` reads exactly as the API words it (from the\n * catalogue `messages` holds), any other key takes the app's translator, and\n * a code the catalogue lacks comes back as it is, so the form library words\n * the issue with its own locale instead. Both functions are stable: a\n * resolver is made once per schema and language, so build this once, at\n * module scope.\n */\nexport function apiCodeResolver<L extends string>(\n\tmessages: ApiMessages<L>,\n\toptions: ApiCodeResolverOptions<L>,\n): ApiCodeResolver<L> {\n\tconst isApiCode = (key: string) =>\n\t\toptions.isApiCode ? options.isApiCode(key) : API_CODE.test(key);\n\treturn {\n\t\ttranslate(key, context, provideLanguage) {\n\t\t\tif (!isApiCode(key))\n\t\t\t\treturn options.translate(key, context, provideLanguage);\n\t\t\tconst language =\n\t\t\t\ttypeof provideLanguage === 'function'\n\t\t\t\t\t? provideLanguage()\n\t\t\t\t\t: (provideLanguage ?? options.language());\n\t\t\treturn messages.apiMessage(key, context, language) ?? key;\n\t\t},\n\t\tcodeOf(issue) {\n\t\t\treturn options.codeOf ? options.codeOf(issue) : paramsCode(issue);\n\t\t},\n\t};\n}\n",
|
|
6
6
|
"import { isApiErrorLike } from './api-error';\nimport type { ApiErrors } from './api-errors';\n\n/** The API's refusal of `error`, or `undefined` when it is not one. */\nexport function refusalOf<L extends string>(\n\terrors: Pick<ApiErrors<L>, 'apiErrorMessage' | 'unavailableMessage'>,\n\terror: unknown,\n\tlanguage: L,\n): ReturnType<ApiErrors<L>['apiRefusal']> {\n\tif (isApiErrorLike(error)) {\n\t\treturn {\n\t\t\tmessage: errors.apiErrorMessage(error, language),\n\t\t\tstatus: error.status,\n\t\t};\n\t}\n\tif (error instanceof Response && error.status === 503) {\n\t\treturn { message: errors.unavailableMessage(language), status: 503 };\n\t}\n\treturn undefined;\n}\n\n/** The worded message of each field an API error names, by field path. */\nexport function fieldErrorsOf<L extends string>(\n\terrors: Pick<ApiErrors<L>, 'apiErrorMessage' | 'translateCode'>,\n\terror: Parameters<ApiErrors<L>['fieldErrors']>[0],\n\tlanguage: L,\n): ReturnType<ApiErrors<L>['fieldErrors']> {\n\tconst extensions = error.errors[0]?.extensions;\n\tconst fields = Array.isArray(extensions?.fields) ? extensions.fields : [];\n\tif (!fields.length && extensions?.field) {\n\t\treturn { [extensions.field]: errors.apiErrorMessage(error, language) };\n\t}\n\treturn Object.fromEntries(\n\t\tfields.map(({ path, code, message, params }) => [\n\t\t\tpath,\n\t\t\terrors.translateCode(code, message, language, params),\n\t\t]),\n\t);\n}\n",
|
|
7
7
|
"import { data } from 'react-router';\nimport { type ApiErrorLike, isApiErrorLike } from './api-error';\nimport type { ApiErrors, ApiRefusal } from './api-errors';\nimport { type RouteErrorOptions, routeError } from './route-error';\n\n/**\n * A fetcher's refusal: the API's (`apiRefusal`), an unreachable API's too,\n * so the page stays where it was. A 401 (the session caller redirects\n * first) or any other failure is thrown, for the error page.\n */\nexport function fetcherRefusal<L extends string>(\n\terrors: Pick<ApiErrors<L>, 'apiRefusal'>,\n\terror: unknown,\n\tlanguage: L,\n\troute?: RouteErrorOptions,\n): ApiRefusal {\n\tconst refusal =\n\t\tisApiErrorLike(error) && error.status === 401\n\t\t\t? undefined\n\t\t\t: errors.apiRefusal(error, language);\n\tif (!refusal) throw routeError(error, route);\n\treturn refusal;\n}\n\n/** What `fetcherResult` takes after `run`: `routeError`'s options, and a rewording. */\nexport interface FetcherResultOptions extends RouteErrorOptions {\n\t/**\n\t * Words the refusal of this call: given the caught API error, the message\n\t * to answer, or `undefined` to keep the worded one. The status is the\n\t * refusal's. Called for an API's own refusal only: not for an API it\n\t * cannot reach or any other failure, nor for what is thrown to the error\n\t * page.\n\t */\n\treword?: (error: ApiErrorLike) => string | undefined;\n}\n\n/**\n * Runs the mutation of an action a fetcher posted to: `{ ok: true }` with\n * `about` and the mutation's value, or the refusal (`fetcherRefusal`) as a\n * worded `error`, with its HTTP status, for a toast or a form message.\n */\nexport async function fetcherResult<\n\tL extends string,\n\tAbout extends object,\n\tValue extends object = Record<never, never>,\n>(\n\terrors: Pick<ApiErrors<L>, 'apiRefusal'>,\n\tlanguage: L,\n\tabout: About,\n\trun: () => Promise<Value>,\n\toptions?: FetcherResultOptions,\n) {\n\ttry {\n\t\treturn { ok: true as const, ...about, ...(await run()) };\n\t} catch (error) {\n\t\tconst { message, status } = fetcherRefusal(\n\t\t\terrors,\n\t\t\terror,\n\t\t\tlanguage,\n\t\t\toptions,\n\t\t);\n\t\treturn data(\n\t\t\t{\n\t\t\t\tok: false as const,\n\t\t\t\t...about,\n\t\t\t\terror:\n\t\t\t\t\t(isApiErrorLike(error) ? options?.reword?.(error) : undefined) ??\n\t\t\t\t\tmessage,\n\t\t\t},\n\t\t\t{ status },\n\t\t);\n\t}\n}\n",
|
|
8
|
-
"import
|
|
9
|
-
"import {
|
|
10
|
-
"import
|
|
8
|
+
"import type { ApiErrorLike } from './api-error';\nimport type { ApiErrors } from './api-errors';\n\n/**\n * The field messages of a refusal placed under the form fields `fieldOf`\n * names for their input paths: `byField`, and the messages of the paths it\n * names no field for (`unplaced`).\n */\nexport function placeFieldErrors<L extends string>(\n\terrors: Pick<ApiErrors<L>, 'fieldErrors'>,\n\terror: ApiErrorLike,\n\tlanguage: L,\n\tfieldOf: (path: string) => string | undefined,\n): { byField: Record<string, string>; unplaced: string[] } {\n\tconst byField: Record<string, string> = {};\n\tconst unplaced: string[] = [];\n\tfor (const [path, message] of Object.entries(\n\t\terrors.fieldErrors(error, language),\n\t)) {\n\t\tconst field = fieldOf(path);\n\t\tif (field) byField[field] = message;\n\t\telse unplaced.push(message);\n\t}\n\treturn { byField, unplaced };\n}\n",
|
|
9
|
+
"import { isApiErrorLike } from './api-error';\nimport type { ApiErrors } from './api-errors';\nimport { fetcherRefusal } from './fetcher-result';\nimport { placeFieldErrors } from './field-placement';\nimport type { RouteErrorOptions } from './route-error';\n\n/** What `apiErrors.formRefusal` answers: a form's refusal, for a fetcher's action. */\nexport interface FormRefusal {\n\t/**\n\t * The message for the form as a whole: empty when every field issue found\n\t * its form field, else the refusal's message followed by the messages of\n\t * the issues that found none (as `submitForm`'s `formError`).\n\t */\n\terror: string;\n\t/** Messages by form field, already translated. */\n\tfieldErrors: Record<string, string>;\n\t/** The refusal's HTTP status. */\n\tstatus: number;\n}\n\n/**\n * A fetcher form's refusal (`fetcherRefusal`) with each field issue placed\n * under the form field `fieldOf` names for its input path. `error` is empty\n * when every issue found its field, else the refusal's message with the\n * messages of the unplaced issues. An unreachable API gives the unavailable\n * message with no field errors, as `fetcherRefusal` does; a 401 or any other\n * failure is thrown for the error page.\n */\nexport function formRefusal<L extends string>(\n\terrors: Pick<ApiErrors<L>, 'apiRefusal' | 'fieldErrors'>,\n\terror: unknown,\n\tlanguage: L,\n\tfieldOf: (path: string) => string | undefined,\n\troute?: RouteErrorOptions,\n): FormRefusal {\n\tconst { message, status } = fetcherRefusal(errors, error, language, route);\n\tif (!isApiErrorLike(error))\n\t\treturn { error: message, fieldErrors: {}, status };\n\tconst { byField, unplaced } = placeFieldErrors(\n\t\terrors,\n\t\terror,\n\t\tlanguage,\n\t\tfieldOf,\n\t);\n\treturn {\n\t\terror:\n\t\t\tObject.keys(byField).length && !unplaced.length\n\t\t\t\t? ''\n\t\t\t\t: [message, ...unplaced].join(' '),\n\t\tfieldErrors: byField,\n\t\tstatus,\n\t};\n}\n",
|
|
10
|
+
"import { data } from 'react-router';\nimport { isApiErrorLike } from './api-error';\nimport type { ApiErrors } from './api-errors';\nimport { placeFieldErrors } from './field-placement';\nimport type { FormErrors } from './form-errors';\nimport { type RouteErrorOptions, routeError } from './route-error';\n\n/**\n * Runs a form's mutation. An `ApiError` becomes the form's errors: each\n * refused field (`extensions.fields`, or the one `extensions.field` names)\n * under the form field `fieldOf` names (else on the form), and any other\n * code as the form's message. A 404 about none of the form's fields (the\n * record itself is gone), a 401 and other failures go to the error page.\n */\nexport async function submitForm<L extends string, T>(\n\terrors: Pick<ApiErrors<L>, 'apiErrorMessage' | 'fieldErrors'>,\n\tlanguage: L,\n\trun: () => Promise<T>,\n\tfieldOf: (path: string) => string | undefined,\n\troute?: RouteErrorOptions,\n): Promise<{ ok: true; value: T } | ReturnType<typeof data<FormErrors>>> {\n\ttry {\n\t\treturn { ok: true, value: await run() };\n\t} catch (error) {\n\t\tif (!isApiErrorLike(error) || error.status === 401) {\n\t\t\tthrow routeError(error, route);\n\t\t}\n\t\tconst field = error.errors[0]?.extensions?.field;\n\t\tif (error.status === 404 && !(field && fieldOf(field))) {\n\t\t\tthrow routeError(error, route);\n\t\t}\n\t\tconst { byField, unplaced } = placeFieldErrors(\n\t\t\terrors,\n\t\t\terror,\n\t\t\tlanguage,\n\t\t\tfieldOf,\n\t\t);\n\t\tconst formError =\n\t\t\tObject.keys(byField).length && !unplaced.length\n\t\t\t\t? undefined\n\t\t\t\t: [errors.apiErrorMessage(error, language), ...unplaced].join(' ');\n\t\treturn data({ fieldErrors: byField, formError }, { status: error.status });\n\t}\n}\n",
|
|
11
|
+
"import { valuesOf } from './api-error';\nimport type { ApiErrors, ApiErrorsOptions } from './api-errors';\nimport { API_CODE } from './code-resolver';\nimport { fieldErrorsOf, refusalOf } from './describe-refusal';\nimport { fetcherRefusal, fetcherResult } from './fetcher-result';\nimport { formRefusal } from './form-refusal';\nimport { submitForm } from './submit-form';\n\nexport function describeApiErrors<L extends string>({\n\tmessages,\n\tunavailable,\n\trefused,\n\treword,\n\tbyCode = {},\n\tisApiCode = (code) => API_CODE.test(code),\n}: ApiErrorsOptions<L>): ApiErrors<L> {\n\tconst translateCode: ApiErrors<L>['translateCode'] = (\n\t\tcode,\n\t\tfallback,\n\t\tlanguage,\n\t\tvalues,\n\t) => {\n\t\tif (!code) return fallback;\n\t\treturn messages.apiMessage(code, values, language) ?? fallback;\n\t};\n\n\tconst apiErrorMessage: ApiErrors<L>['apiErrorMessage'] = (\n\t\terror,\n\t\tlanguage,\n\t) => {\n\t\tconst code = error.code;\n\t\tif (refused && (!code || !isApiCode(code))) return refused(language);\n\t\tconst own = code && Object.hasOwn(byCode, code) ? byCode[code] : undefined;\n\t\tconst values = valuesOf(error.errors[0]?.extensions);\n\t\tconst text = own\n\t\t\t? own(error, language)\n\t\t\t: translateCode(code, error.message, language, values);\n\t\tif (!reword || !code) return text;\n\t\treturn (\n\t\t\treword(text, error, { code, values: values ?? {}, language }) ?? text\n\t\t);\n\t};\n\n\tconst unavailableMessage = (language: L) => unavailable(language);\n\n\tconst apiRefusal: ApiErrors<L>['apiRefusal'] = (error, language) =>\n\t\trefusalOf({ apiErrorMessage, unavailableMessage }, error, language);\n\n\tconst fieldErrors: ApiErrors<L>['fieldErrors'] = (error, language) =>\n\t\tfieldErrorsOf({ apiErrorMessage, translateCode }, error, language);\n\n\tconst parts = { apiRefusal, apiErrorMessage, fieldErrors };\n\n\treturn {\n\t\ttranslateCode,\n\t\tapiErrorMessage,\n\t\tunavailableMessage,\n\t\tfieldErrors,\n\t\tapiRefusal,\n\t\tfetcherRefusal: (error, language, route) =>\n\t\t\tfetcherRefusal(parts, error, language, route),\n\t\tformRefusal: (error, language, fieldOf, route) =>\n\t\t\tformRefusal(parts, error, language, fieldOf, route),\n\t\tfetcherResult: (language, about, run, options) =>\n\t\t\tfetcherResult(parts, language, about, run, options),\n\t\tsubmitForm: (language, run, fieldOf, route) =>\n\t\t\tsubmitForm(parts, language, run, fieldOf, route),\n\t};\n}\n",
|
|
12
|
+
"import type { data } from 'react-router';\nimport type { ApiErrorLike } from './api-error';\nimport { describeApiErrors } from './describe';\nimport type { FetcherResultOptions } from './fetcher-result';\nimport type { FormErrors } from './form-errors';\nimport type { FormRefusal } from './form-refusal';\nimport type { ApiMessages } from './messages';\nimport type { RouteErrorOptions } from './route-error';\n\n/** A refused call, as a page says it: the message, and the HTTP status to answer. */\nexport type ApiRefusal = { message: string; status: number };\n\nexport interface ApiErrorsOptions<L extends string> {\n\t/** The catalogue the API's codes are worded from. */\n\tmessages: ApiMessages<L>;\n\t/**\n\t * The app's own word for an API it cannot reach (a 503 `Response`): not\n\t * an API error, so never one of the catalogue's codes.\n\t */\n\tunavailable(language: L): string;\n\t/**\n\t * The app's generic refusal, said for an error with no API code (a raw\n\t * `BAD_USER_INPUT` before the API's validation layer), never the raw\n\t * message. Without it, such an error says the message the API sent.\n\t */\n\trefused?(language: L): string;\n\t/**\n\t * An app's own wording for given codes, such as the API's request limits\n\t * (depth, cost, introspection), whose params differ and name no field.\n\t * Checked after `refused`, before the catalogue.\n\t */\n\tbyCode?: Readonly<\n\t\tRecord<string, (error: ApiErrorLike, language: L) => string>\n\t>;\n\t/**\n\t * Words a whole family of codes once, after the text is worded. It runs\n\t * on the final text `apiErrorMessage` (so `apiRefusal`, `fetcherResult`,\n\t * `fetcherRefusal`, `submitForm` and a single `extensions.field`) says\n\t * for an error with a code, whichever produced it: the catalogue, the\n\t * API's own message, or `byCode`. It does not run on `refused`'s text, on\n\t * `unavailable`'s (a network failure), on `translateCode` nor on the\n\t * entries of `extensions.fields`. `values` are the merged values the\n\t * catalogue formats with (`extensions` and `extensions.params`, params\n\t * winning). Return the text to show, or `undefined` to keep `text`.\n\t */\n\treword?(\n\t\ttext: string,\n\t\terror: ApiErrorLike,\n\t\tcontext: {\n\t\t\tcode: string;\n\t\t\tvalues: Readonly<Record<string, unknown>>;\n\t\t\tlanguage: L;\n\t\t},\n\t): string | undefined;\n\t/** Whether a code is an API code; `<module>.errors.<slug>` by default. */\n\tisApiCode?(code: string): boolean;\n}\n\n/** What a page says of an API's refusals, in a language. */\nexport interface ApiErrors<L extends string> {\n\t/**\n\t * The catalogue's text of an API code in `language`, else `fallback` (the\n\t * message the API already worded). `values` are the message's arguments\n\t * (`extensions.params`).\n\t */\n\ttranslateCode(\n\t\tcode: string | undefined,\n\t\tfallback: string,\n\t\tlanguage: L,\n\t\tvalues?: Readonly<Record<string, unknown>>,\n\t): string;\n\t/**\n\t * What to show for an API error: `refused` for an error with no API code,\n\t * when given; else `byCode`'s wording of its code; else the catalogue's\n\t * text; else the message the API already worded.\n\t */\n\tapiErrorMessage(error: ApiErrorLike, language: L): string;\n\t/**\n\t * The message of each refused field, by input path, ready for a form: the\n\t * entries of `extensions.fields`, else the one field `extensions.field`\n\t * names, with the error's own message. Empty for neither.\n\t */\n\tfieldErrors(error: ApiErrorLike, language: L): Record<string, string>;\n\t/** `unavailable`, in `language`. */\n\tunavailableMessage(language: L): string;\n\t/**\n\t * What a failed call says to the user: an API refusal's message and its\n\t * status, or an API it cannot reach (a 503 `Response`: the unavailable\n\t * word). Undefined for anything else, which the caller rethrows.\n\t */\n\tapiRefusal(error: unknown, language: L): ApiRefusal | undefined;\n\t/**\n\t * A fetcher's refusal: `apiRefusal`'s, so the page stays where it was. A\n\t * 401 (the session caller redirects first) or any other failure is\n\t * thrown, through `routeError`, for the error page.\n\t */\n\tfetcherRefusal(\n\t\terror: unknown,\n\t\tlanguage: L,\n\t\troute?: RouteErrorOptions,\n\t): ApiRefusal;\n\t/**\n\t * A fetcher form's refusal (`fetcherRefusal`) with its field issues under\n\t * the form field `fieldOf` names for each input path: `{ error,\n\t * fieldErrors, status }`, `error` empty when every issue found its field.\n\t */\n\tformRefusal(\n\t\terror: unknown,\n\t\tlanguage: L,\n\t\tfieldOf: (path: string) => string | undefined,\n\t\troute?: RouteErrorOptions,\n\t): FormRefusal;\n\t/**\n\t * Runs the mutation of an action a fetcher posted to: `{ ok: true }` with\n\t * `about` and the mutation's value, or `{ ok: false, error }` with `about`\n\t * and the refusal's message, answered with its HTTP status. `options.reword`\n\t * words the refusal of this call from the caught API error (`undefined`\n\t * keeps the worded message); it is not called for an unreachable API.\n\t */\n\tfetcherResult<\n\t\tAbout extends object,\n\t\tValue extends object = Record<never, never>,\n\t>(\n\t\tlanguage: L,\n\t\tabout: About,\n\t\trun: () => Promise<Value>,\n\t\toptions?: FetcherResultOptions,\n\t): Promise<\n\t\t| ({ ok: true } & About & Value)\n\t\t| ReturnType<typeof data<{ ok: false; error: string } & About>>\n\t>;\n\t/**\n\t * Runs a form's mutation: `{ ok: true, value }`, or the form's errors\n\t * (`fieldErrors` under the form field `fieldOf` names an input path by,\n\t * and a `formError` for the rest) with the refusal's status. A 404 about\n\t * none of the form's fields, a 401 and other failures are thrown for the\n\t * error page, through `routeError` (with `route`).\n\t */\n\tsubmitForm<T>(\n\t\tlanguage: L,\n\t\trun: () => Promise<T>,\n\t\tfieldOf: (path: string) => string | undefined,\n\t\troute?: RouteErrorOptions,\n\t): Promise<{ ok: true; value: T } | ReturnType<typeof data<FormErrors>>>;\n}\n\n/**\n * The wording of an API's refusals for the languages `L`, from the\n * catalogue `messages` holds. Make one per app, beside its `createApiMessages`.\n */\nexport function createApiErrors<L extends string>(\n\toptions: ApiErrorsOptions<L>,\n): ApiErrors<L> {\n\treturn describeApiErrors(options);\n}\n",
|
|
11
13
|
"/** The methods of a `console` a report goes through. */\nexport type LogMethod = 'warn' | 'error';\n\n/**\n * A log whose methods can throw without breaking what reports through\n * them: a broken app log must not turn a handled failure into a rejection.\n */\nexport function quietLog<M extends LogMethod>(\n\tlog: Pick<Console, M>,\n\tmethods: readonly M[],\n): Pick<Console, M> {\n\tconst quiet = {} as Pick<Console, M>;\n\tfor (const method of methods) {\n\t\tquiet[method] = ((...args: unknown[]) => {\n\t\t\ttry {\n\t\t\t\t(log[method] as (...args: unknown[]) => void)(...args);\n\t\t\t} catch {\n\t\t\t\t// Swallowed on purpose: see above.\n\t\t\t}\n\t\t}) as Pick<Console, M>[M];\n\t}\n\treturn quiet;\n}\n",
|
|
12
14
|
"import { isApiErrorLike, isStatusError, isUnavailableError } from './api-error';\nimport { quietLog } from './log';\nimport { REQUEST_ID_HEADER } from './request-id';\n\n/** The statuses an API's gateway or auth layer may answer without a GraphQL body. */\nconst PASSED_THROUGH: ReadonlySet<number> = new Set([401, 403, 404]);\n\n/** The statuses a `Response` cannot carry a body with. */\nconst NO_BODY: ReadonlySet<number> = new Set([101, 204, 205, 304]);\n\nexport interface CallFailureOptions {\n\t/** What a log line names the API by, such as `my-api https://api.example.com/graphql`. */\n\tapi: string;\n\t/** The operation's name, for the log (`operationName(document)`). */\n\toperation?: string;\n\t/** The `x-request-id` the API answered, when it did (`requestIdOf(response)`). */\n\trequestId?: string;\n\t/** The incoming request's signal: an aborted call is answered 503. */\n\tsignal?: AbortSignal;\n\t/** The statuses without a GraphQL body that become a `Response` of their own; 401, 403 and 404 by default. */\n\tpassedThrough?: ReadonlySet<number>;\n\t/** Where the lines go; `console` by default. */\n\tlog?: Pick<Console, 'warn' | 'error'>;\n}\n\n/**\n * What a call became once it failed, for a loader or an action to throw: the\n * `ApiError` as it is (carrying `requestId`), a `Response` of the API's own\n * status for a 401, 403 or 404 without a GraphQL body, a 503 `Response` (with no body; the reason is in the log) for an\n * unreachable, slow, garbled or aborted API, and any other error as it is.\n * Every case it recognises is logged with the request id, when the API gave one, and never\n * the headers, the variables nor a token; the id rides on the `ApiError` as\n * `requestId` and on a `Response` as `x-request-id`, where `routeError` reads\n * it.\n *\n * It recognises `@nxgt/graphql-client`'s errors by their `name`, never with\n * `instanceof`, so it needs no import of the client and holds across two\n * copies of it.\n */\nexport function apiCallFailure(\n\terror: unknown,\n\t{\n\t\tapi,\n\t\toperation = 'operation',\n\t\trequestId,\n\t\tsignal,\n\t\tpassedThrough = PASSED_THROUGH,\n\t\tlog: appLog = console,\n\t}: CallFailureOptions,\n): unknown {\n\tconst log = quietLog(appLog, ['warn', 'error']);\n\tconst call = `${api}: ${operation}${requestId ? ` (request ${requestId})` : ''}`;\n\tconst headers: Record<string, string> = requestId\n\t\t? { [REQUEST_ID_HEADER]: requestId }\n\t\t: {};\n\tconst unavailable = (reason: string, cause?: unknown): Response => {\n\t\tlog.error(`${call} ${reason}`, cause ?? '');\n\t\treturn new Response(null, { status: 503, headers });\n\t};\n\tif (isApiErrorLike(error)) {\n\t\t// The client's `ApiError.requestId` is writable, though the structural type marks it readonly.\n\t\tif (requestId) (error as { requestId?: string }).requestId = requestId;\n\t\tconst line = `${call} answered ${error.status}${error.code ? ` ${error.code}` : ''}`;\n\t\tif (error.status >= 500) log.error(line);\n\t\telse log.warn(line);\n\t\treturn error;\n\t}\n\tif (isStatusError(error)) {\n\t\tif (passedThrough.has(error.status)) {\n\t\t\tlog.warn(`${call} answered ${error.status}`);\n\t\t\tconst statusText =\n\t\t\t\ttypeof error.statusText === 'string' ? error.statusText : '';\n\t\t\tif (NO_BODY.has(error.status)) {\n\t\t\t\treturn new Response(null, {\n\t\t\t\t\tstatus: error.status,\n\t\t\t\t\tstatusText,\n\t\t\t\t\theaders,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn new Response(statusText, {\n\t\t\t\tstatus: error.status,\n\t\t\t\tstatusText,\n\t\t\t\theaders,\n\t\t\t});\n\t\t}\n\t\treturn unavailable(`answered ${error.status} without GraphQL`, error.body);\n\t}\n\tif (isUnavailableError(error)) return unavailable(error.reason, error.cause);\n\tif (signal?.aborted) return unavailable('aborted', error);\n\treturn error;\n}\n\n/** A document, as far as `operationName` reads it: `graphql`'s `DocumentNode` fits. */\nexport interface DocumentLike {\n\treadonly definitions: readonly {\n\t\treadonly kind: string;\n\t\treadonly operation?: string | undefined;\n\t\treadonly name?: { readonly value: string } | undefined;\n\t}[];\n}\n\n/**\n * The name of the operation a document holds, for a log line: its name, else\n * its kind (`query`, `mutation`, `subscription`), else `operation`.\n */\nexport function operationName(document: DocumentLike): string {\n\tfor (const definition of document.definitions) {\n\t\tif (definition.kind === 'OperationDefinition') {\n\t\t\treturn definition.name?.value ?? definition.operation ?? 'operation';\n\t\t}\n\t}\n\treturn 'operation';\n}\n",
|
|
13
15
|
"import type { Held } from './catalogue-read';\n\n/** What the TTL check needs: the reader's state and the app's own calls. */\nexport interface CheckContext<L extends string> {\n\treader: {\n\t\theld: Map<L, Held>;\n\t\tload(language: L, now: number): Promise<void>;\n\t};\n\tversions(): Promise<Partial<Record<L, string>>>;\n\tttl(): number;\n\tretryMs: number;\n\tlog: Pick<Console, 'error'>;\n}\n\n/**\n * Asks the versions in one call and reads again the messages of each\n * language that moved. An API that cannot be reached keeps the messages\n * held (stale, still worded) and is asked again after `retryMs`.\n */\nexport async function checkVersions<L extends string>(\n\t{ reader, versions, ttl, retryMs, log }: CheckContext<L>,\n\tnow: number,\n) {\n\ttry {\n\t\tconst latest = await versions();\n\t\tfor (const [language, entry] of [...reader.held]) {\n\t\t\tif (latest[language] !== entry.version) {\n\t\t\t\tawait reader.load(language, now);\n\t\t\t} else {\n\t\t\t\tentry.checkedAt = now;\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tlog.error(\n\t\t\t'alxia-react-router: the error catalogue was not checked, keeping what is held',\n\t\t\terror,\n\t\t);\n\t\tfor (const entry of reader.held.values()) {\n\t\t\tentry.checkedAt = now - ttl() + retryMs;\n\t\t}\n\t}\n}\n\n/**\n * The TTL, whose getter is the app's: one that throws, or that is not a\n * finite number of at least 0, is logged and `fallback` is used.\n */\nexport function safeTtl(\n\tttlMs: number | (() => number),\n\tfallback: number,\n\tlog: Pick<Console, 'error'>,\n) {\n\treturn () => {\n\t\ttry {\n\t\t\tconst ttl = typeof ttlMs === 'function' ? ttlMs() : ttlMs;\n\t\t\tif (typeof ttl === 'number' && Number.isFinite(ttl) && ttl >= 0) {\n\t\t\t\treturn ttl;\n\t\t\t}\n\t\t\tlog.error('alxia-react-router: ttlMs is not a duration, using retryMs');\n\t\t} catch (error) {\n\t\t\tlog.error('alxia-react-router: ttlMs threw, using retryMs', error);\n\t\t}\n\t\treturn fallback;\n\t};\n}\n",
|
|
@@ -19,7 +21,7 @@
|
|
|
19
21
|
"import type { ReactNode } from 'react';\nimport type { ApiMessages, CatalogueMessages } from './messages';\n\nexport interface ApiMessagesProviderProps<L extends string> {\n\t/** The store `apiCodeResolver` reads. */\n\tmessages: ApiMessages<L>;\n\t/** The messages the root's data carries, by language. */\n\tvalue: Readonly<Record<L, CatalogueMessages>> | undefined;\n\tchildren: ReactNode;\n}\n\n/**\n * Fills the browser's catalogue with the messages the root's data carries\n * (the few its forms word), before the children render: `apiCodeResolver`\n * reads them synchronously. A server render writes nothing: the server's\n * store holds the whole, fresher catalogue, and a render's data may be older\n * than it. It is a plain function (no JSX, no React runtime): use it as\n * `ApiMessagesProvider({ messages, value, children })` from a component, or\n * as an element's type.\n */\nexport function ApiMessagesProvider<L extends string>({\n\tmessages,\n\tvalue,\n\tchildren,\n}: ApiMessagesProviderProps<L>): ReactNode {\n\tconst inBrowser =\n\t\ttypeof (globalThis as { document?: unknown }).document !== 'undefined';\n\tif (value && inBrowser) {\n\t\tfor (const [language, held] of Object.entries<CatalogueMessages>(value)) {\n\t\t\tmessages.add(language as L, held);\n\t\t}\n\t}\n\treturn children;\n}\n",
|
|
20
22
|
"import { type FetcherWithComponents, useFetcher } from 'react-router';\n\n/** What a fetcher can post as JSON. */\nexport type JsonBody = Parameters<FetcherWithComponents<unknown>['submit']>[0];\n\n/**\n * A fetcher posting JSON to its page's action (which reads it with\n * `readJson`, and answers `fetcherResult` or the like): `post` sends a\n * body, `busy` while it is in flight. `key` shares the fetcher between the\n * form that posts and the component that reads the answer; `action` posts to\n * another route's action instead (a resource route's, such as a\n * `notifications/poll`). `post` takes the target of one call as its second\n * argument (a list's rows each post to their own record's action).\n */\nexport function useJsonFetcher<Action, Body extends JsonBody = JsonBody>(\n\tkey?: string,\n\taction?: string,\n): {\n\tfetcher: ReturnType<typeof useFetcher<Action>>;\n\tpost(body: Body, to?: string): Promise<void>;\n\tbusy: boolean;\n} {\n\tconst fetcher = useFetcher<Action>(key ? { key } : undefined);\n\tconst post = (body: Body, to = action) =>\n\t\tfetcher.submit(body, {\n\t\t\tmethod: 'post',\n\t\t\tencType: 'application/json',\n\t\t\t...(to ? { action: to } : {}),\n\t\t});\n\treturn { fetcher, post, busy: fetcher.state !== 'idle' };\n}\n"
|
|
21
23
|
],
|
|
22
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAgBO,IAAM,WAAW;AA8BxB,SAAS,UAAU,CAAC,OAAsB;AAAA,EACzC,MAAM,OAAQ,MAAM,QAA2C;AAAA,EAC/D,OAAO,OAAO,SAAS,WAAW,OAAO;AAAA;AAYnC,SAAS,eAAiC,CAChD,UACA,SACqB;AAAA,EACrB,MAAM,YAAY,CAAC,QACl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AS;AAAA,EAC5D,MAAM,OAAO,CAAC,MAAY,KAAK,WAC9B,QAAQ,OAAO,MAAM;AAAA,IACpB,QAAQ;AAAA,IACR,SAAS;AAAA,OACL,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;AAAA,EAC5B,CAAC;AAAA,EACF,OAAO,EAAE,SAAS,MAAM,MAAM,QAAQ,UAAU,OAAO;AAAA;",
|
|
25
|
+
"debugId": "15421DF8DF81973764756E2164756E21",
|
|
24
26
|
"names": []
|
|
25
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit-form.d.ts","sourceRoot":"","sources":["../../src/errors/submit-form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"submit-form.d.ts","sourceRoot":"","sources":["../../src/errors/submit-form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,KAAK,iBAAiB,EAAc,MAAM,eAAe,CAAC;AAEnE;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EACnD,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,iBAAiB,GAAG,aAAa,CAAC,EAC7D,QAAQ,EAAE,CAAC,EACX,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACrB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EAC7C,KAAK,CAAC,EAAE,iBAAiB,GACvB,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAuBvE"}
|
package/dist/fetcher/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { type DebouncedFetcher, type DebouncedFetcherOptions, type DebouncedFetcherState, useDebouncedFetcher, } from './use-debounced-fetcher';
|
|
7
7
|
export { type AnswerSource, useFetcherAnswer } from './use-fetcher-answer';
|
|
8
|
+
export { type FormRefusalResult, useFormRefusal } from './use-form-refusal';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fetcher/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,mBAAmB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fetcher/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,mBAAmB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,KAAK,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/fetcher/index.js
CHANGED
|
@@ -92,10 +92,19 @@ function useFetcherAnswer(fetcher, onAnswer) {
|
|
|
92
92
|
}, [answer]);
|
|
93
93
|
return latest;
|
|
94
94
|
}
|
|
95
|
+
// src/fetcher/use-form-refusal.ts
|
|
96
|
+
import { useMemo } from "react";
|
|
97
|
+
function useFormRefusal(result) {
|
|
98
|
+
return useMemo(() => result && !result.ok && result.fieldErrors ? {
|
|
99
|
+
fieldErrors: result.fieldErrors,
|
|
100
|
+
formError: result.error || undefined
|
|
101
|
+
} : undefined, [result]);
|
|
102
|
+
}
|
|
95
103
|
export {
|
|
96
104
|
useDebouncedFetcher,
|
|
97
|
-
useFetcherAnswer
|
|
105
|
+
useFetcherAnswer,
|
|
106
|
+
useFormRefusal
|
|
98
107
|
};
|
|
99
108
|
|
|
100
|
-
//# debugId=
|
|
109
|
+
//# debugId=42D032646A4DF0F764756E2164756E21
|
|
101
110
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/fetcher/use-debounced-fetcher.ts", "../src/fetcher/use-fetcher-answer.ts"],
|
|
3
|
+
"sources": ["../src/fetcher/use-debounced-fetcher.ts", "../src/fetcher/use-fetcher-answer.ts", "../src/fetcher/use-form-refusal.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import {\n\tstartTransition,\n\tuseCallback,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport { useFetcher } from 'react-router';\n\n/** What `useFetcher<Data>` hands back as `data` (`Data` may be `typeof loader`). */\ntype FetcherData<Data> = ReturnType<typeof useFetcher<Data>>['data'];\n\n/** What `useDebouncedFetcher` is doing for the value typed. */\nexport type DebouncedFetcherState =\n\t/** Nothing to ask: disabled, or the value is shorter than `minLength`. */\n\t| 'idle'\n\t/** The value changed and the pause after the last change is running. */\n\t| 'waiting'\n\t/** The resource route is loading. */\n\t| 'loading'\n\t/** The route answered for the value as it stands. */\n\t| 'done';\n\nexport interface DebouncedFetcherOptions<Data = unknown> {\n\t/** Pause after the last change before the route is asked. Default 250. */\n\treadonly delayMs?: number;\n\t/** The trimmed value must have this many characters. Default 1. */\n\treadonly minLength?: number;\n\t/** `false` asks nothing and forgets the previous answer. Default `true`. */\n\treadonly enabled?: boolean;\n\t/** The fetcher's key, to share it with another component. */\n\treadonly key?: string;\n\t/**\n\t * Which answers may be kept as the stale `data` while the next value waits\n\t * or loads. Default: all. An answer it refuses (a failure) is still `data`\n\t * while it is the current one, but is never shown as the previous one: after a refused answer, the stale\n\t * data is the last *kept* answer, not the refused one.\n\t */\n\treadonly keep?: (data: NonNullable<FetcherData<Data>>) => boolean;\n}\n\nexport interface DebouncedFetcher<Data> {\n\t/**\n\t * The route's answer for the value as it stands, else (`stale`) the last\n\t * answer for an earlier value, kept until the new one lands. `undefined`\n\t * before any answer, and again once the hook goes `idle`.\n\t */\n\treadonly data: FetcherData<Data>;\n\t/** `data` answers an earlier value (or none is current yet). */\n\treadonly stale: boolean;\n\treadonly state: DebouncedFetcherState;\n\t/** Asks the route again for the value as it stands, without waiting. */\n\treadonly retry: () => void;\n}\n\n/**\n * A resource route loaded through a fetcher for a value that changes as the\n * user types. After `delayMs` without a change, and from `minLength`\n * characters, it calls `fetcher.load` once (a newer load cancels the\n * previous one). An answer only counts for the value it was asked for: while\n * a newer value waits or loads, `data` is the previous answer with `stale`\n * set, and an answer for an older value is never returned as current.\n * `to` is the route's URL, or a function of the trimmed value that builds it\n * (a string without a function is loaded as it is, the value being only the\n * trigger). A refusal the route answers as data is `data` like any answer.\n */\nexport function useDebouncedFetcher<Data>(\n\tvalue: string,\n\tto: string | ((value: string) => string),\n\toptions: DebouncedFetcherOptions<Data> = {},\n): DebouncedFetcher<Data> {\n\tconst { delayMs = 250, minLength = 1, enabled = true, key, keep } = options;\n\tconst keepRef = useRef(keep);\n\tkeepRef.current = keep;\n\tconst fetcher = useFetcher<Data>(key === undefined ? undefined : { key });\n\tconst load = useRef(fetcher.load);\n\tload.current = fetcher.load;\n\tconst text = value.trim();\n\tconst url =\n\t\tenabled && text.length >= minLength\n\t\t\t? typeof to === 'function'\n\t\t\t\t? to(text)\n\t\t\t\t: to\n\t\t\t: null;\n\t// The URL the fetcher was last told to load.\n\tconst [loaded, setLoaded] = useState<string | null>(null);\n\tconst previous = useRef<FetcherData<Data>>(undefined);\n\t// React Router applies the fetcher's `loading` state in a transition, so\n\t// right after `load()` a render can still show `idle` and the previous\n\t// answer. A load has landed only once the fetcher was seen busy for that very load (the load number is kept, so a busy render of a superseded load does not count), or\n\t// its `load()` promise settled and a transition queued after it committed\n\t// (a fast load whose busy state was never rendered, or a route answering\n\t// the very same object twice). `seq` numbers the loads, so a superseded\n\t// one never counts.\n\tconst seq = useRef(0);\n\tconst [settled, setSettled] = useState(0);\n\tconst busySeq = useRef(0);\n\tuseLayoutEffect(() => {\n\t\tif (fetcher.state !== 'idle') busySeq.current = seq.current;\n\t}, [fetcher.state]);\n\tconst ask = (target: string) => {\n\t\tconst mine = ++seq.current;\n\t\tsetLoaded(target);\n\t\tvoid Promise.resolve(load.current(target)).then(() => {\n\t\t\tif (mine === seq.current) startTransition(() => setSettled(mine));\n\t\t});\n\t};\n\tconst askRef = useRef(ask);\n\taskRef.current = ask;\n\n\tuseEffect(() => {\n\t\tif (url === null) {\n\t\t\tprevious.current = undefined;\n\t\t\tsetLoaded(null);\n\t\t\treturn;\n\t\t}\n\t\tconst timer = setTimeout(() => {\n\t\t\taskRef.current(url);\n\t\t}, delayMs);\n\t\treturn () => clearTimeout(timer);\n\t}, [url, text, delayMs]);\n\n\tconst landed =\n\t\tfetcher.state === 'idle' &&\n\t\t(busySeq.current === seq.current || settled === seq.current);\n\tconst current =\n\t\turl !== null && loaded === url && landed && fetcher.data !== undefined;\n\tconst answer = current ? fetcher.data : undefined;\n\tuseEffect(() => {\n\t\tif (answer === undefined || answer === null) return;\n\t\tif (keepRef.current?.(answer) ?? true) previous.current = answer;\n\t}, [answer]);\n\n\tconst data = current ? answer : url === null ? undefined : previous.current;\n\tlet state: DebouncedFetcherState;\n\tif (url === null) state = 'idle';\n\telse if (loaded !== url) state = 'waiting';\n\telse state = landed ? 'done' : 'loading';\n\n\tconst urlRef = useRef(url);\n\turlRef.current = url;\n\tconst retry = useCallback(() => {\n\t\tconst now = urlRef.current;\n\t\tif (now === null) return;\n\t\taskRef.current(now);\n\t}, []);\n\treturn { data, stale: state !== 'done' && data !== undefined, state, retry };\n}\n",
|
|
6
|
-
"import { useEffect, useRef, useState } from 'react';\n\n/** What the hook reads of a React Router fetcher. */\nexport interface AnswerSource<Data> {\n\treadonly state: string;\n\treadonly data: Data | undefined;\n}\n\n/**\n * The answers a fetcher gives, one at a time. A keyed fetcher outlives its\n * component, so the data it holds when the component mounts is an earlier\n * visit's, not this one's. `onAnswer` is called once for each answer that\n * arrives while the fetcher is idle and is another object than the last one\n * seen (the data present at mount counts as seen). The handler is read from\n * a ref, so a new function each render never re-fires it. Returns the latest\n * answer handed over, `undefined` until one arrives.\n */\nexport function useFetcherAnswer<Data>(\n\tfetcher: AnswerSource<Data>,\n\tonAnswer?: (answer: Data) => void,\n): Data | undefined {\n\tconst seen = useRef(fetcher.data);\n\tconst handler = useRef(onAnswer);\n\thandler.current = onAnswer;\n\tconst [latest, setLatest] = useState<Data | undefined>(undefined);\n\tconst answer = fetcher.state === 'idle' ? fetcher.data : undefined;\n\tuseEffect(() => {\n\t\tif (answer === undefined || answer === null || answer === seen.current) {\n\t\t\treturn;\n\t\t}\n\t\tseen.current = answer;\n\t\tsetLatest(answer);\n\t\thandler.current?.(answer);\n\t}, [answer]);\n\treturn latest;\n}\n"
|
|
6
|
+
"import { useEffect, useRef, useState } from 'react';\n\n/** What the hook reads of a React Router fetcher. */\nexport interface AnswerSource<Data> {\n\treadonly state: string;\n\treadonly data: Data | undefined;\n}\n\n/**\n * The answers a fetcher gives, one at a time. A keyed fetcher outlives its\n * component, so the data it holds when the component mounts is an earlier\n * visit's, not this one's. `onAnswer` is called once for each answer that\n * arrives while the fetcher is idle and is another object than the last one\n * seen (the data present at mount counts as seen). The handler is read from\n * a ref, so a new function each render never re-fires it. Returns the latest\n * answer handed over, `undefined` until one arrives.\n */\nexport function useFetcherAnswer<Data>(\n\tfetcher: AnswerSource<Data>,\n\tonAnswer?: (answer: Data) => void,\n): Data | undefined {\n\tconst seen = useRef(fetcher.data);\n\tconst handler = useRef(onAnswer);\n\thandler.current = onAnswer;\n\tconst [latest, setLatest] = useState<Data | undefined>(undefined);\n\tconst answer = fetcher.state === 'idle' ? fetcher.data : undefined;\n\tuseEffect(() => {\n\t\tif (answer === undefined || answer === null || answer === seen.current) {\n\t\t\treturn;\n\t\t}\n\t\tseen.current = answer;\n\t\tsetLatest(answer);\n\t\thandler.current?.(answer);\n\t}, [answer]);\n\treturn latest;\n}\n",
|
|
7
|
+
"import { useMemo } from 'react';\nimport type { FormErrors } from '../errors/form-errors';\n\n/**\n * What a form's fetcher answers: a done step (`ok: true`), or a refusal\n * (`formRefusal`, or `fetcherResult` with its `error`) that may carry the\n * form's field errors.\n */\nexport type FormRefusalResult =\n\t| { ok: true }\n\t| { ok?: false; fieldErrors?: Record<string, string>; error?: string };\n\n/**\n * The refusal of a form's last answer as its `FormErrors`: `undefined` for\n * no answer, a done step, or a refusal with no `fieldErrors` (a toast's\n * message, not the form's). Stable for one answer.\n */\nexport function useFormRefusal(\n\tresult: FormRefusalResult | undefined,\n): FormErrors | undefined {\n\treturn useMemo(\n\t\t() =>\n\t\t\tresult && !result.ok && result.fieldErrors\n\t\t\t\t? {\n\t\t\t\t\t\tfieldErrors: result.fieldErrors,\n\t\t\t\t\t\tformError: result.error || undefined,\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t[result],\n\t);\n}\n"
|
|
7
8
|
],
|
|
8
|
-
"mappings": ";AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;AA2DO,SAAS,mBAAyB,CACxC,OACA,IACA,UAAyC,CAAC,GACjB;AAAA,EACzB,QAAQ,UAAU,KAAK,YAAY,GAAG,UAAU,MAAM,KAAK,SAAS;AAAA,EACpE,MAAM,UAAU,OAAO,IAAI;AAAA,EAC3B,QAAQ,UAAU;AAAA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U,SAAS,WAAW,OAAO,MAAM;AAAA;;ACnJ5E,sBAAS,sBAAW,qBAAQ;AAiBrB,SAAS,gBAAsB,CACrC,SACA,UACmB;AAAA,EACnB,MAAM,OAAO,QAAO,QAAQ,IAAI;AAAA,EAChC,MAAM,UAAU,QAAO,QAAQ;AAAA,EAC/B,QAAQ,UAAU;AAAA,EAClB,OAAO,QAAQ,aAAa,UAA2B,SAAS;AAAA,EAChE,MAAM,SAAS,QAAQ,UAAU,SAAS,QAAQ,OAAO;AAAA,EACzD,WAAU,MAAM;AAAA,IACf,IAAI,WAAW,aAAa,WAAW,QAAQ,WAAW,KAAK,SAAS;AAAA,MACvE;AAAA,IACD;AAAA,IACA,KAAK,UAAU;AAAA,IACf,UAAU,MAAM;AAAA,IAChB,QAAQ,UAAU,MAAM;AAAA,KACtB,CAAC,MAAM,CAAC;AAAA,EACX,OAAO;AAAA;;AClCR;AAiBO,SAAS,cAAc,CAC7B,QACyB;AAAA,EACzB,OAAO,QACN,MACC,UAAU,CAAC,OAAO,MAAM,OAAO,cAC5B;AAAA,IACA,aAAa,OAAO;AAAA,IACpB,WAAW,OAAO,SAAS;AAAA,EAC5B,IACC,WACJ,CAAC,MAAM,CACR;AAAA;",
|
|
10
|
+
"debugId": "42D032646A4DF0F764756E2164756E21",
|
|
10
11
|
"names": []
|
|
11
12
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FormErrors } from '../errors/form-errors';
|
|
2
|
+
/**
|
|
3
|
+
* What a form's fetcher answers: a done step (`ok: true`), or a refusal
|
|
4
|
+
* (`formRefusal`, or `fetcherResult` with its `error`) that may carry the
|
|
5
|
+
* form's field errors.
|
|
6
|
+
*/
|
|
7
|
+
export type FormRefusalResult = {
|
|
8
|
+
ok: true;
|
|
9
|
+
} | {
|
|
10
|
+
ok?: false;
|
|
11
|
+
fieldErrors?: Record<string, string>;
|
|
12
|
+
error?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The refusal of a form's last answer as its `FormErrors`: `undefined` for
|
|
16
|
+
* no answer, a done step, or a refusal with no `fieldErrors` (a toast's
|
|
17
|
+
* message, not the form's). Stable for one answer.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useFormRefusal(result: FormRefusalResult | undefined): FormErrors | undefined;
|
|
20
|
+
//# sourceMappingURL=use-form-refusal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-form-refusal.d.ts","sourceRoot":"","sources":["../../src/fetcher/use-form-refusal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAC1B;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GACZ;IAAE,EAAE,CAAC,EAAE,KAAK,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE;;;;GAIG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,iBAAiB,GAAG,SAAS,GACnC,UAAU,GAAG,SAAS,CAWxB"}
|
package/docs/guide/errors.md
CHANGED
|
@@ -392,7 +392,7 @@ export const apiErrors = createApiErrors<'en' | 'fr'>({
|
|
|
392
392
|
|
|
393
393
|
`reword` sees the text `apiErrorMessage` returns for an error with a code,
|
|
394
394
|
whichever produced it: the catalogue, the API's own message, or `byCode`; so
|
|
395
|
-
`apiRefusal`, `fetcherResult`, `fetcherRefusal`, `submitForm` and a single
|
|
395
|
+
`apiRefusal`, `fetcherResult`, `fetcherRefusal`, `formRefusal`, `submitForm` and a single
|
|
396
396
|
`extensions.field` are reworded too. It does not see `refused`'s text (an
|
|
397
397
|
error with no API code), `unavailable`'s (a network failure, which is no API
|
|
398
398
|
code), `translateCode`'s, nor the entries of `extensions.fields`, which go
|
|
@@ -589,6 +589,52 @@ export async function action({ request }: Route.ActionArgs) {
|
|
|
589
589
|
}
|
|
590
590
|
```
|
|
591
591
|
|
|
592
|
+
`apiErrors.formRefusal(error, language, fieldOf)` is `fetcherRefusal` for a dialog that
|
|
593
|
+
posts through a fetcher and shows field errors: it answers `{ error,
|
|
594
|
+
fieldErrors, status }`, each refused field under the form field `fieldOf`
|
|
595
|
+
names for its input path. `error` is empty when every field message found its
|
|
596
|
+
field; otherwise it is the refusal's message followed by the messages of the
|
|
597
|
+
issues that map to no field (the `formError` of `submitForm`), and it is the
|
|
598
|
+
refusal's message alone for a refusal that names no field or an API it cannot
|
|
599
|
+
reach.
|
|
600
|
+
On the page, `useFormRefusal(fetcher.data)` (from `@alxia/react-router/fetcher`) returns the `FormErrors` of the
|
|
601
|
+
last answer, or `undefined` for no answer, a done step or a refusal without
|
|
602
|
+
`fieldErrors`.
|
|
603
|
+
|
|
604
|
+
```tsx
|
|
605
|
+
import { useFetcher } from 'react-router';
|
|
606
|
+
import { useFormRefusal } from '@alxia/react-router/fetcher';
|
|
607
|
+
import { apiErrors } from './api-errors';
|
|
608
|
+
import type { Route } from './+types/items';
|
|
609
|
+
|
|
610
|
+
// Your own call to the API, declared here as a stub.
|
|
611
|
+
declare function saveItem(input: unknown): Promise<void>;
|
|
612
|
+
|
|
613
|
+
export async function action({ request }: Route.ActionArgs) {
|
|
614
|
+
try {
|
|
615
|
+
await saveItem(Object.fromEntries(await request.formData()));
|
|
616
|
+
return { ok: true as const };
|
|
617
|
+
} catch (error) {
|
|
618
|
+
// 'input.name' is the form's 'name' field; other paths stay in `error`.
|
|
619
|
+
return apiErrors.formRefusal(error, 'en', (path) =>
|
|
620
|
+
path.startsWith('input.') ? path.slice('input.'.length) : undefined,
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
export function ItemDialog() {
|
|
626
|
+
const fetcher = useFetcher<typeof action>();
|
|
627
|
+
const errors = useFormRefusal(fetcher.data);
|
|
628
|
+
return (
|
|
629
|
+
<fetcher.Form method="post">
|
|
630
|
+
<input name="name" aria-invalid={Boolean(errors?.fieldErrors?.['name'])} />
|
|
631
|
+
{errors?.fieldErrors?.['name']}
|
|
632
|
+
{errors?.formError}
|
|
633
|
+
</fetcher.Form>
|
|
634
|
+
);
|
|
635
|
+
}
|
|
636
|
+
```
|
|
637
|
+
|
|
592
638
|
The helpers route with `routeError`'s defaults (401, 403, 404 and 503). Each
|
|
593
639
|
takes an optional last argument, `route?: RouteErrorOptions`, passed to
|
|
594
640
|
`routeError` for what it throws: `apiErrors.fetcherRefusal(error, 'en', {
|
package/docs/roadmap.md
CHANGED
|
@@ -140,7 +140,7 @@ Nothing planned.
|
|
|
140
140
|
provider (`ApiMessagesProvider`) and the wording of a refusal
|
|
141
141
|
(`createApiErrors`: message, fields and status), the route helpers
|
|
142
142
|
(`routeError`, `errorRequestId`) and the actions' helpers (`fetcherResult`,
|
|
143
|
-
`fetcherRefusal`, `submitForm`), the JSON actions (`jsonActions`:
|
|
143
|
+
`fetcherRefusal`, `formRefusal`, `submitForm`; `useFormRefusal` on `/fetcher`), the JSON actions (`jsonActions`:
|
|
144
144
|
`readJson` with its same-origin CSRF check, `requireJsonPost`, and
|
|
145
145
|
`readInput` over a Standard Schema) with their fetcher hook
|
|
146
146
|
(`useJsonFetcher`), the catalogue's refresh (`createErrorCatalogue`: read
|
package/docs/troubleshooting.md
CHANGED
|
@@ -2647,14 +2647,15 @@ export async function loader() {
|
|
|
2647
2647
|
|
|
2648
2648
|
### An action shows the error page
|
|
2649
2649
|
|
|
2650
|
-
An action that calls `fetcherResult`, `fetcherRefusal` or `submitForm` ends on
|
|
2650
|
+
An action that calls `fetcherResult`, `fetcherRefusal`, `formRefusal` or `submitForm` ends on
|
|
2651
2651
|
the route's error page instead of answering `{ ok: false }` or the form's
|
|
2652
2652
|
errors.
|
|
2653
2653
|
|
|
2654
2654
|
**Why:** by design, these helpers answer only what the page can word. They
|
|
2655
2655
|
throw `routeError(error)` for a 401 (the session code redirects to the sign-in
|
|
2656
2656
|
first), for a failure that is not an API refusal (a network error, a bug of the
|
|
2657
|
-
app's own code), and, for `submitForm`,
|
|
2657
|
+
app's own code), and, for `submitForm` only (not `formRefusal`, which answers a 404 as the
|
|
2658
|
+
form's message), for a 404 that names none of the
|
|
2658
2659
|
form's fields: the record itself is gone, and no field message could say so.
|
|
2659
2660
|
|
|
2660
2661
|
**Fix:** none is needed for a 401 or a real failure: the error page is the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alxia/react-router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.1",
|
|
4
4
|
"description": "alxia as the server of a React Router framework app: server rendering behind the app's hooks, loaders reading its typed context, the client's assets served; the code with no UI an installable app shares (`/pwa`), its hooks (`/pwa/react`), `noCache` for the worker's script (`/pwa/server`), the service worker on Workbox (`/pwa/worker`) and its build (`/pwa/build`), an API's refusals worded for the page (`/errors`), the BFF session: cookies, sign-in, step-up and mail links (`/session`), its page hooks (`/session/react`) and what it shares with the page (`/session/model`), a GraphQL subscription relayed to the browser over SSE (`/subscription`), the page's CSP nonce and inline boot scripts (`/document`) and a streaming `entry.server` (`/entry`)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -141,9 +141,9 @@
|
|
|
141
141
|
]
|
|
142
142
|
},
|
|
143
143
|
"devDependencies": {
|
|
144
|
-
"@alxia/compress": "^0.3.
|
|
145
|
-
"@alxia/core": "^0.
|
|
146
|
-
"@alxia/openapi": "^0.6.
|
|
144
|
+
"@alxia/compress": "^0.3.14",
|
|
145
|
+
"@alxia/core": "^0.19.0",
|
|
146
|
+
"@alxia/openapi": "^0.6.14",
|
|
147
147
|
"@nxgt/graphql-client": "^0.6.0",
|
|
148
148
|
"@nxgt/janus": "^0.29.0",
|
|
149
149
|
"@react-router/dev": "^8.5.0",
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
"zod": "^4.2.0"
|
|
168
168
|
},
|
|
169
169
|
"peerDependencies": {
|
|
170
|
-
"@alxia/core": "^0.
|
|
170
|
+
"@alxia/core": "^0.19.0",
|
|
171
171
|
"isbot": "^5.0.0",
|
|
172
172
|
"react": "^19.0.0",
|
|
173
173
|
"react-dom": "^19.0.0",
|