@alxia/react-router 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +301 -13
- package/dist/chunks/index-59vhfj6n.js +10 -0
- package/dist/chunks/index-59vhfj6n.js.map +10 -0
- package/dist/chunks/index-5gqcpyyg.js +34 -0
- package/dist/chunks/index-5gqcpyyg.js.map +10 -0
- package/dist/chunks/{index-zqa30gr7.js → index-9xv2a8et.js} +7 -38
- package/dist/chunks/index-9xv2a8et.js.map +11 -0
- package/dist/chunks/index-mppz0806.js +119 -0
- package/dist/chunks/index-mppz0806.js.map +11 -0
- package/dist/chunks/index-rfr02vg4.js +40 -0
- package/dist/chunks/index-rfr02vg4.js.map +10 -0
- package/dist/chunks/index-zdbqzcjp.js +97 -0
- package/dist/chunks/index-zdbqzcjp.js.map +12 -0
- package/dist/errors/api-error.d.ts +86 -0
- package/dist/errors/api-error.d.ts.map +1 -0
- package/dist/errors/api-errors.d.ts +96 -0
- package/dist/errors/api-errors.d.ts.map +1 -0
- package/dist/errors/call-failure.d.ts +45 -0
- package/dist/errors/call-failure.d.ts.map +1 -0
- package/dist/errors/catalogue-check.d.ts +24 -0
- package/dist/errors/catalogue-check.d.ts.map +1 -0
- package/dist/errors/catalogue-read.d.ts +33 -0
- package/dist/errors/catalogue-read.d.ts.map +1 -0
- package/dist/errors/catalogue.d.ts +59 -0
- package/dist/errors/catalogue.d.ts.map +1 -0
- package/dist/errors/code-resolver.d.ts +44 -0
- package/dist/errors/code-resolver.d.ts.map +1 -0
- package/dist/errors/describe-refusal.d.ts +6 -0
- package/dist/errors/describe-refusal.d.ts.map +1 -0
- package/dist/errors/describe.d.ts +3 -0
- package/dist/errors/describe.d.ts.map +1 -0
- package/dist/errors/fetcher-result.d.ts +21 -0
- package/dist/errors/fetcher-result.d.ts.map +1 -0
- package/dist/errors/form-errors.d.ts +8 -0
- package/dist/errors/form-errors.d.ts.map +1 -0
- package/dist/errors/index.d.ts +15 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +602 -0
- package/dist/errors/index.js.map +29 -0
- package/dist/errors/json-actions.d.ts +38 -0
- package/dist/errors/json-actions.d.ts.map +1 -0
- package/dist/errors/log.d.ts +8 -0
- package/dist/errors/log.d.ts.map +1 -0
- package/dist/errors/message-values.d.ts +11 -0
- package/dist/errors/message-values.d.ts.map +1 -0
- package/dist/errors/messages.d.ts +63 -0
- package/dist/errors/messages.d.ts.map +1 -0
- package/dist/errors/page-path.d.ts +9 -0
- package/dist/errors/page-path.d.ts.map +1 -0
- package/dist/errors/provider.d.ts +20 -0
- package/dist/errors/provider.d.ts.map +1 -0
- package/dist/errors/request-id.d.ts +5 -0
- package/dist/errors/request-id.d.ts.map +1 -0
- package/dist/errors/route-error.d.ts +31 -0
- package/dist/errors/route-error.d.ts.map +1 -0
- package/dist/errors/standard-schema.d.ts +34 -0
- package/dist/errors/standard-schema.d.ts.map +1 -0
- package/dist/errors/submit-form.d.ts +16 -0
- package/dist/errors/submit-form.d.ts.map +1 -0
- package/dist/errors/use-json-fetcher.d.ts +18 -0
- package/dist/errors/use-json-fetcher.d.ts.map +1 -0
- package/dist/pwa/build/build-worker.d.ts +41 -0
- package/dist/pwa/build/build-worker.d.ts.map +1 -0
- package/dist/pwa/build/index.d.ts +9 -0
- package/dist/pwa/build/index.d.ts.map +1 -0
- package/dist/pwa/build/index.js +9 -0
- package/dist/pwa/build/index.js.map +9 -0
- package/dist/pwa/build/precache.d.ts +17 -0
- package/dist/pwa/build/precache.d.ts.map +1 -0
- package/dist/pwa/index.js +34 -134
- package/dist/pwa/index.js.map +4 -8
- package/dist/pwa/react/index.js +1 -1
- package/dist/pwa/worker/index.d.ts +9 -0
- package/dist/pwa/worker/index.d.ts.map +1 -0
- package/dist/pwa/worker/index.js +144 -0
- package/dist/pwa/worker/index.js.map +12 -0
- package/dist/pwa/worker/injected.d.ts +15 -0
- package/dist/pwa/worker/injected.d.ts.map +1 -0
- package/dist/pwa/worker/plan.d.ts +65 -0
- package/dist/pwa/worker/plan.d.ts.map +1 -0
- package/dist/pwa/worker/scope.d.ts +18 -0
- package/dist/pwa/worker/scope.d.ts.map +1 -0
- package/dist/pwa/worker/start-worker.d.ts +17 -0
- package/dist/pwa/worker/start-worker.d.ts.map +1 -0
- package/dist/vite/index.d.ts +10 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +49 -3
- package/dist/vite/index.js.map +6 -5
- package/dist/vite/runtime.d.ts +1 -1
- package/dist/vite/runtime.d.ts.map +1 -1
- package/dist/vite/worker.d.ts +16 -0
- package/dist/vite/worker.d.ts.map +1 -0
- package/docs/README.md +3 -2
- package/docs/guide/errors.md +838 -0
- package/docs/guide/how-it-works.md +7 -1
- package/docs/guide/pwa.md +372 -211
- package/docs/roadmap.md +38 -5
- package/docs/troubleshooting.md +689 -3
- package/package.json +56 -4
- package/dist/chunks/index-zqa30gr7.js.map +0 -12
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ApiMessages, CatalogueMessage } from './messages';
|
|
2
|
+
/** What the API answers for one language: its version and every message. */
|
|
3
|
+
export type CatalogueReply = {
|
|
4
|
+
version: string;
|
|
5
|
+
messages: ReadonlyArray<CatalogueMessage & {
|
|
6
|
+
readonly code: string;
|
|
7
|
+
}>;
|
|
8
|
+
};
|
|
9
|
+
/** A language's catalogue as held, and when its version was last confirmed. */
|
|
10
|
+
export type Held = {
|
|
11
|
+
version: string;
|
|
12
|
+
checkedAt: number;
|
|
13
|
+
};
|
|
14
|
+
export interface CatalogueReaderOptions<L extends string> {
|
|
15
|
+
messages: ApiMessages<L>;
|
|
16
|
+
read(language: L): Promise<CatalogueReply>;
|
|
17
|
+
retryMs: number;
|
|
18
|
+
firstReadWaitMs: number;
|
|
19
|
+
log: Pick<Console, 'error'>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The reading half of the catalogue: the first read of each language (one in
|
|
23
|
+
* flight, a bounded wait, a retry delay after a failure) and the version
|
|
24
|
+
* each one holds. `createErrorCatalogue` adds the TTL check on top.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createCatalogueReader<L extends string>({ messages, read, retryMs, firstReadWaitMs, log, }: CatalogueReaderOptions<L>): {
|
|
27
|
+
held: Map<L, Held>;
|
|
28
|
+
load: (language: L, now: number) => Promise<void>;
|
|
29
|
+
/** Reads a language that is not held yet, unless a failure is still fresh. */
|
|
30
|
+
first(language: L, now: number): Promise<void>;
|
|
31
|
+
reset(): void;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=catalogue-read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogue-read.d.ts","sourceRoot":"","sources":["../../src/errors/catalogue-read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEhE,4EAA4E;AAC5E,MAAM,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,aAAa,CAAC,gBAAgB,GAAG;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACtE,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,IAAI,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1D,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,MAAM;IACvD,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACzB,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;CAC5B;AAqBD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,EAAE,EACvD,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,eAAe,EACf,GAAG,GACH,EAAE,sBAAsB,CAAC,CAAC,CAAC;;qBAMG,CAAC,OAAO,MAAM;IAwC3C,8EAA8E;oBACxD,CAAC,OAAO,MAAM;;EAYrC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type CatalogueReply } from './catalogue-read';
|
|
2
|
+
import type { ApiMessages, CatalogueMessages } from './messages';
|
|
3
|
+
export type { CatalogueReply } from './catalogue-read';
|
|
4
|
+
export interface ErrorCatalogueOptions<L extends string> {
|
|
5
|
+
/** The store the page words refusals from (`createApiMessages`). */
|
|
6
|
+
messages: ApiMessages<L>;
|
|
7
|
+
/** The languages to hold, each read once and kept fresh. */
|
|
8
|
+
languages: readonly L[];
|
|
9
|
+
/** Reads one language's catalogue from the API. */
|
|
10
|
+
read(language: L): Promise<CatalogueReply>;
|
|
11
|
+
/** Asks the API for the version of every language, in one call. */
|
|
12
|
+
versions(): Promise<Partial<Record<L, string>>>;
|
|
13
|
+
/** How long a held catalogue is served before its version is checked. */
|
|
14
|
+
ttlMs: number | (() => number);
|
|
15
|
+
/** How soon a check or a first read that failed is tried again. Default 5000. */
|
|
16
|
+
retryMs?: number;
|
|
17
|
+
/**
|
|
18
|
+
* How long a request waits for a language's first read; past it the
|
|
19
|
+
* request goes on and the read carries on in the background. Default 1500.
|
|
20
|
+
*/
|
|
21
|
+
firstReadWaitMs?: number;
|
|
22
|
+
/** The codes the browser words itself (`clientMessages`). */
|
|
23
|
+
clientCodes: readonly string[];
|
|
24
|
+
/** Where failures are reported. Default `console`. */
|
|
25
|
+
log?: Pick<Console, 'error'>;
|
|
26
|
+
}
|
|
27
|
+
/** The API's error catalogue, kept fresh for the server. */
|
|
28
|
+
export interface ErrorCatalogue<L extends string> {
|
|
29
|
+
/**
|
|
30
|
+
* The catalogue of `language`, ready to word a refusal. Only a language
|
|
31
|
+
* with no catalogue yet is awaited, for at most `firstReadWaitMs`. A held
|
|
32
|
+
* one is served as it is, and once older than the TTL its version is
|
|
33
|
+
* checked in the background, one check at a time.
|
|
34
|
+
*/
|
|
35
|
+
fresh(language: L, now?: number): Promise<void>;
|
|
36
|
+
/** Every language, fresh: what the root middleware awaits. */
|
|
37
|
+
freshAll(now?: number): Promise<void>;
|
|
38
|
+
/** At startup: reads every language without holding the boot back. */
|
|
39
|
+
warm(): void;
|
|
40
|
+
/** The messages the browser words itself, by language, for the root's loader. */
|
|
41
|
+
clientMessages(): Record<L, CatalogueMessages>;
|
|
42
|
+
/**
|
|
43
|
+
* Forgets everything held and in flight. For use between tests, with
|
|
44
|
+
* nothing in flight: a read or check still running when it is called
|
|
45
|
+
* finishes and holds its result again.
|
|
46
|
+
*/
|
|
47
|
+
reset(): void;
|
|
48
|
+
/** The version held for a language, if any. */
|
|
49
|
+
heldVersion(language: L): string | undefined;
|
|
50
|
+
/** Waits for the check in flight, if any (tests). */
|
|
51
|
+
settled(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Keeps the API's error catalogue in `messages`: read on first use, checked
|
|
55
|
+
* against the API's versions once per TTL, and re-read only for the
|
|
56
|
+
* languages whose version moved. It is an instance, not module state.
|
|
57
|
+
*/
|
|
58
|
+
export declare function createErrorCatalogue<L extends string>({ messages, languages, read, versions, ttlMs, retryMs, firstReadWaitMs, clientCodes, log: appLog, }: ErrorCatalogueOptions<L>): ErrorCatalogue<L>;
|
|
59
|
+
//# sourceMappingURL=catalogue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogue.d.ts","sourceRoot":"","sources":["../../src/errors/catalogue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,kBAAkB,CAAC;AAE9E,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEjE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,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7C,qDAAqD;IACrD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAqBD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,EACtD,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,OAAe,EACf,eAAuB,EACvB,WAAW,EACX,GAAG,EAAE,MAAgB,GACrB,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAoD9C"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ApiMessages } from './messages';
|
|
2
|
+
/** The part of a zod issue a code reads, by shape (`@nxgt/material-core`'s `CodeIssue`). */
|
|
3
|
+
export type CodeIssueLike = {
|
|
4
|
+
readonly code: string;
|
|
5
|
+
/** A custom issue's params: `.refine(…, { params: { code } })`. */
|
|
6
|
+
readonly params?: Record<string, unknown> | undefined;
|
|
7
|
+
readonly input?: unknown;
|
|
8
|
+
readonly origin?: string | undefined;
|
|
9
|
+
readonly minimum?: unknown;
|
|
10
|
+
readonly maximum?: unknown;
|
|
11
|
+
readonly expected?: unknown;
|
|
12
|
+
readonly message?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
/** An API error code (`<module>.errors.<slug>`), as opposed to a GraphQL one (`BAD_USER_INPUT`). */
|
|
15
|
+
export declare const API_CODE: RegExp;
|
|
16
|
+
export interface ApiCodeResolverOptions<L extends string> {
|
|
17
|
+
/**
|
|
18
|
+
* The app's translator, for every key that is not an API code. Method
|
|
19
|
+
* syntax: the app's own `Translate<LocaleKey>` is accepted.
|
|
20
|
+
*/
|
|
21
|
+
translate(key: string, context?: Readonly<Record<string, unknown>>, language?: L | (() => L)): string;
|
|
22
|
+
/** The page's language, when a call names none. */
|
|
23
|
+
language(): L;
|
|
24
|
+
/** Which code an issue carries; the issue's `params.code` by default. */
|
|
25
|
+
codeOf?(issue: CodeIssueLike): string | undefined;
|
|
26
|
+
/** Whether a key is an API code; `<module>.errors.<slug>` by default. */
|
|
27
|
+
isApiCode?(key: string): boolean;
|
|
28
|
+
}
|
|
29
|
+
/** What `@nxgt/material`'s `useCodeResolver(schema, resolver)` takes. */
|
|
30
|
+
export interface ApiCodeResolver<L extends string> {
|
|
31
|
+
translate: (key: string, context?: Readonly<Record<string, unknown>>, language?: L | (() => L)) => string;
|
|
32
|
+
codeOf: (issue: CodeIssueLike) => string | undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The words of what a form's checks ask for: a refinement carrying an API
|
|
36
|
+
* code in `params.code` reads exactly as the API words it (from the
|
|
37
|
+
* catalogue `messages` holds), any other key takes the app's translator, and
|
|
38
|
+
* a code the catalogue lacks comes back as it is, so the form library words
|
|
39
|
+
* the issue with its own locale instead. Both functions are stable: a
|
|
40
|
+
* resolver is made once per schema and language, so build this once, at
|
|
41
|
+
* module scope.
|
|
42
|
+
*/
|
|
43
|
+
export declare function apiCodeResolver<L extends string>(messages: ApiMessages<L>, options: ApiCodeResolverOptions<L>): ApiCodeResolver<L>;
|
|
44
|
+
//# sourceMappingURL=code-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-resolver.d.ts","sourceRoot":"","sources":["../../src/errors/code-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,4FAA4F;AAC5F,MAAM,MAAM,aAAa,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACtD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3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@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ApiErrors } from './api-errors';
|
|
2
|
+
/** The API's refusal of `error`, or `undefined` when it is not one. */
|
|
3
|
+
export declare function refusalOf<L extends string>(errors: Pick<ApiErrors<L>, 'apiErrorMessage' | 'unavailableMessage'>, error: unknown, language: L): ReturnType<ApiErrors<L>['apiRefusal']>;
|
|
4
|
+
/** The worded message of each field an API error names, by field path. */
|
|
5
|
+
export declare function fieldErrorsOf<L extends string>(errors: Pick<ApiErrors<L>, 'apiErrorMessage' | 'translateCode'>, error: Parameters<ApiErrors<L>['fieldErrors']>[0], language: L): ReturnType<ApiErrors<L>['fieldErrors']>;
|
|
6
|
+
//# sourceMappingURL=describe-refusal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-refusal.d.ts","sourceRoot":"","sources":["../../src/errors/describe-refusal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,uEAAuE;AACvE,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EACzC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,iBAAiB,GAAG,oBAAoB,CAAC,EACpE,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,CAAC,GACT,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAWxC;AAED,0EAA0E;AAC1E,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAC7C,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAAC,EAC/D,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,EACjD,QAAQ,EAAE,CAAC,GACT,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAYzC"}
|
|
@@ -0,0 +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;AAMhE,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,EACnD,QAAQ,EACR,WAAW,EACX,OAAO,EACP,MAAW,EACX,SAAyC,GACzC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAkDpC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ApiErrors, ApiRefusal } from './api-errors';
|
|
2
|
+
import { type RouteErrorOptions } from './route-error';
|
|
3
|
+
/**
|
|
4
|
+
* A fetcher's refusal: the API's (`apiRefusal`), an unreachable API's too,
|
|
5
|
+
* so the page stays where it was. A 401 (the session caller redirects
|
|
6
|
+
* first) or any other failure is thrown, for the error page.
|
|
7
|
+
*/
|
|
8
|
+
export declare function fetcherRefusal<L extends string>(errors: Pick<ApiErrors<L>, 'apiRefusal'>, error: unknown, language: L, route?: RouteErrorOptions): ApiRefusal;
|
|
9
|
+
/**
|
|
10
|
+
* Runs the mutation of an action a fetcher posted to: `{ ok: true }` with
|
|
11
|
+
* `about` and the mutation's value, or the refusal (`fetcherRefusal`) as a
|
|
12
|
+
* worded `error`, with its HTTP status, for a toast or a form message.
|
|
13
|
+
*/
|
|
14
|
+
export declare function fetcherResult<L extends string, About extends object, Value extends object = Record<never, never>>(errors: Pick<ApiErrors<L>, 'apiRefusal'>, language: L, about: About, run: () => Promise<Value>, route?: RouteErrorOptions): Promise<import("react-router").UNSAFE_DataWithResponseInit<{
|
|
15
|
+
ok: false;
|
|
16
|
+
} & About & {
|
|
17
|
+
error: string;
|
|
18
|
+
}> | ({
|
|
19
|
+
ok: true;
|
|
20
|
+
} & About & Awaited<Value>)>;
|
|
21
|
+
//# sourceMappingURL=fetcher-result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetcher-result.d.ts","sourceRoot":"","sources":["../../src/errors/fetcher-result.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,KAAK,iBAAiB,EAAc,MAAM,eAAe,CAAC;AAEnE;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC9C,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,EACxC,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,CAAC,EACX,KAAK,CAAC,EAAE,iBAAiB,GACvB,UAAU,CAOZ;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAClC,CAAC,SAAS,MAAM,EAChB,KAAK,SAAS,MAAM,EACpB,KAAK,SAAS,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAE3C,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,EACxC,QAAQ,EAAE,CAAC,EACX,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,EACzB,KAAK,CAAC,EAAE,iBAAiB;;;;;;6BAQzB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** What a form action answers when the API refused the input. */
|
|
2
|
+
export type FormErrors = {
|
|
3
|
+
/** Messages by form field, already translated. */
|
|
4
|
+
fieldErrors?: Record<string, string>;
|
|
5
|
+
/** A message for the form as a whole, already translated. */
|
|
6
|
+
formError?: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=form-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-errors.d.ts","sourceRoot":"","sources":["../../src/errors/form-errors.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG;IACxB,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { type ApiErrorEntryLike, type ApiErrorExtensionsLike, type ApiErrorLike, type ApiErrorParamsLike, type ApiFieldErrorLike, isApiErrorLike, waitMinutes, } from './api-error';
|
|
2
|
+
export { type ApiErrors, type ApiErrorsOptions, type ApiRefusal, createApiErrors, } from './api-errors';
|
|
3
|
+
export { apiCallFailure, type CallFailureOptions, type DocumentLike, operationName, } from './call-failure';
|
|
4
|
+
export { type CatalogueReply, createErrorCatalogue, type ErrorCatalogue, type ErrorCatalogueOptions, } from './catalogue';
|
|
5
|
+
export { type ApiCodeResolver, type ApiCodeResolverOptions, apiCodeResolver, type CodeIssueLike, } from './code-resolver';
|
|
6
|
+
export type { FormErrors } from './form-errors';
|
|
7
|
+
export { type JsonActions, type JsonActionsOptions, jsonActions, } from './json-actions';
|
|
8
|
+
export { type ApiMessages, type ApiMessagesOptions, type CatalogueMessage, type CatalogueMessages, createApiMessages, type MessageFormat, type MessageValues, type ParamKind, } from './messages';
|
|
9
|
+
export { nextOf } from './page-path';
|
|
10
|
+
export { ApiMessagesProvider, type ApiMessagesProviderProps, } from './provider';
|
|
11
|
+
export { REQUEST_ID_HEADER, requestIdOf } from './request-id';
|
|
12
|
+
export { errorRequestId, type RouteErrorData, type RouteErrorOptions, routeError, } from './route-error';
|
|
13
|
+
export type { StandardSchemaV1 } from './standard-schema';
|
|
14
|
+
export { type JsonBody, useJsonFetcher } from './use-json-fetcher';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA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