@haddowg/json-api-client 1.30.0 → 1.32.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/dist/ajv.cjs +1 -1
- package/dist/ajv.d.cts +1 -1
- package/dist/ajv.d.mts +1 -1
- package/dist/ajv.mjs +1 -1
- package/dist/index.cjs +338 -28
- package/dist/index.d.cts +109 -7
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +109 -7
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +330 -29
- package/dist/index.mjs.map +1 -1
- package/dist/{validate-B2Dtn9dI.cjs → validate-B9cyfO3p.cjs} +20 -4
- package/dist/{validate-CtXB1MGk.mjs → validate-BuPAPJMi.mjs} +16 -6
- package/dist/validate-BuPAPJMi.mjs.map +1 -0
- package/dist/{validate-ugcQVpb0.d.mts → validate-DyNfTJ52.d.cts} +334 -50
- package/dist/validate-DyNfTJ52.d.cts.map +1 -0
- package/dist/{validate-ugcQVpb0.d.cts → validate-DyNfTJ52.d.mts} +334 -50
- package/dist/validate-DyNfTJ52.d.mts.map +1 -0
- package/package.json +1 -1
- package/dist/validate-CtXB1MGk.mjs.map +0 -1
- package/dist/validate-ugcQVpb0.d.cts.map +0 -1
- package/dist/validate-ugcQVpb0.d.mts.map +0 -1
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
//#region src/error-shared.ts
|
|
2
|
+
/** An error object's first non-empty `detail` or `title`, then its `code` when `withCode` is set. */
|
|
3
|
+
function errorText(error, withCode = false) {
|
|
4
|
+
return [
|
|
5
|
+
error?.detail,
|
|
6
|
+
error?.title,
|
|
7
|
+
withCode ? error?.code : void 0
|
|
8
|
+
].find((s) => s !== void 0 && s !== "");
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
1
11
|
//#region src/errors.ts
|
|
2
12
|
/**
|
|
3
13
|
* Thrown by the always-on light structural guards when a parsed response is not a
|
|
@@ -14,14 +24,14 @@ var StructuralGuardError = class extends Error {
|
|
|
14
24
|
};
|
|
15
25
|
/**
|
|
16
26
|
* The default {@link JsonApiError} message: the generic status line, then the first error object's
|
|
17
|
-
* `
|
|
18
|
-
* objects.
|
|
27
|
+
* `detail` (else its `title`) when it has one, then `" (and N more)"` for the further error
|
|
28
|
+
* objects.
|
|
19
29
|
*/
|
|
20
30
|
function describeErrors(status, errors) {
|
|
21
31
|
let message = `JSON:API request failed with status ${status}`;
|
|
22
32
|
const first = errors[0];
|
|
23
|
-
const words = first
|
|
24
|
-
if (
|
|
33
|
+
const words = errorText(first);
|
|
34
|
+
if (words !== void 0) message += `: ${words}`;
|
|
25
35
|
if (errors.length > 1) message += ` (and ${errors.length - 1} more)`;
|
|
26
36
|
return message;
|
|
27
37
|
}
|
|
@@ -444,6 +454,12 @@ Object.defineProperty(exports, "assertJsonApiDocument", {
|
|
|
444
454
|
return assertJsonApiDocument;
|
|
445
455
|
}
|
|
446
456
|
});
|
|
457
|
+
Object.defineProperty(exports, "errorText", {
|
|
458
|
+
enumerable: true,
|
|
459
|
+
get: function() {
|
|
460
|
+
return errorText;
|
|
461
|
+
}
|
|
462
|
+
});
|
|
447
463
|
Object.defineProperty(exports, "fieldsOfUrl", {
|
|
448
464
|
enumerable: true,
|
|
449
465
|
get: function() {
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
//#region src/error-shared.ts
|
|
2
|
+
/** An error object's first non-empty `detail` or `title`, then its `code` when `withCode` is set. */
|
|
3
|
+
function errorText(error, withCode = false) {
|
|
4
|
+
return [
|
|
5
|
+
error?.detail,
|
|
6
|
+
error?.title,
|
|
7
|
+
withCode ? error?.code : void 0
|
|
8
|
+
].find((s) => s !== void 0 && s !== "");
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
1
11
|
//#region src/errors.ts
|
|
2
12
|
/**
|
|
3
13
|
* Thrown by the always-on light structural guards when a parsed response is not a
|
|
@@ -14,14 +24,14 @@ var StructuralGuardError = class extends Error {
|
|
|
14
24
|
};
|
|
15
25
|
/**
|
|
16
26
|
* The default {@link JsonApiError} message: the generic status line, then the first error object's
|
|
17
|
-
* `
|
|
18
|
-
* objects.
|
|
27
|
+
* `detail` (else its `title`) when it has one, then `" (and N more)"` for the further error
|
|
28
|
+
* objects.
|
|
19
29
|
*/
|
|
20
30
|
function describeErrors(status, errors) {
|
|
21
31
|
let message = `JSON:API request failed with status ${status}`;
|
|
22
32
|
const first = errors[0];
|
|
23
|
-
const words = first
|
|
24
|
-
if (
|
|
33
|
+
const words = errorText(first);
|
|
34
|
+
if (words !== void 0) message += `: ${words}`;
|
|
25
35
|
if (errors.length > 1) message += ` (and ${errors.length - 1} more)`;
|
|
26
36
|
return message;
|
|
27
37
|
}
|
|
@@ -426,6 +436,6 @@ function validateResourceMember(member, validator, fields) {
|
|
|
426
436
|
}
|
|
427
437
|
}
|
|
428
438
|
//#endregion
|
|
429
|
-
export { validateDocument as a, JsonApiError as c, hasErrorCode as d, sparseSchemas as i, StructuralGuardError as l, resolveValidator as n, fieldsOfUrl as o, sparseSchema as r, nestedFieldset as s, assertJsonApiDocument as t, findError as u };
|
|
439
|
+
export { validateDocument as a, JsonApiError as c, hasErrorCode as d, errorText as f, sparseSchemas as i, StructuralGuardError as l, resolveValidator as n, fieldsOfUrl as o, sparseSchema as r, nestedFieldset as s, assertJsonApiDocument as t, findError as u };
|
|
430
440
|
|
|
431
|
-
//# sourceMappingURL=validate-
|
|
441
|
+
//# sourceMappingURL=validate-BuPAPJMi.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-BuPAPJMi.mjs","names":[],"sources":["../src/error-shared.ts","../src/errors.ts","../src/nested-fieldset.ts","../src/validate.ts"],"sourcesContent":["import type { JsonApiError, JsonApiErrorObject } from './errors'\n\n/** The {@link JsonApiError} members of `E`, read without distributing over a union such as a query's error. */\nexport type JsonApiErrorOf<E> = Extract<NonNullable<E>, JsonApiError<string>>\n\n/** The codes `E`'s {@link JsonApiError} carries, else `Fallback`. */\nexport type CodesOf<E, Fallback extends string = string> = [JsonApiErrorOf<E>] extends [never]\n ? Fallback\n : JsonApiErrorOf<E> extends JsonApiError<infer C>\n ? C\n : Fallback\n\n/** An error object's first non-empty `detail` or `title`, then its `code` when `withCode` is set. */\nexport function errorText(\n error: JsonApiErrorObject | undefined,\n withCode = false,\n): string | undefined {\n return [error?.detail, error?.title, withCode ? error?.code : undefined].find(\n (s) => s !== undefined && s !== '',\n )\n}\n","import { type CodesOf, errorText, type JsonApiErrorOf } from './error-shared'\n\n/**\n * A single JSON:API error object (spec: error objects).\n *\n * `C` is the server's documented error-code union (a generated client's `ErrorCode`). `code` is\n * typed `C | (string & {})`: editors suggest the documented codes, yet any other string still\n * fits, because the catalogue is open and a server may send a code it never documented.\n */\nexport interface JsonApiErrorObject<C extends string = string> {\n id?: string\n status?: string\n code?: C | (string & {})\n title?: string\n detail?: string\n source?: { pointer?: string; parameter?: string; header?: string }\n meta?: Record<string, unknown>\n /**\n * The user-facing input path, remapped from `source.pointer` for write errors\n * (e.g. `/data/attributes/title` -> `title`). Populated by the runtime, which\n * built the envelope and therefore knows the inverse mapping. See docs/errors.md.\n */\n path?: string\n /**\n * The zero-based index of the failing operation within an atomic batch, parsed from a\n * `source.pointer` carrying an `/atomic:operations/{n}` prefix. Populated only for atomic\n * errors; `path` then holds the flat path within that operation's input.\n */\n opIndex?: number\n}\n\n/**\n * Thrown by the always-on light structural guards when a parsed response is not a\n * JSON:API document, or a `data`/`included` member is not a resource object carrying `type`+`id`.\n * Distinct from {@link JsonApiError} (a non-2xx server response): this signals the wire shape the\n * runtime relies on was violated, not an application error the server reported. The opt-in\n * per-field validator throws its engine's own error type, never this one.\n */\nexport class StructuralGuardError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'StructuralGuardError'\n }\n}\n\n/**\n * The default {@link JsonApiError} message: the generic status line, then the first error object's\n * `detail` (else its `title`) when it has one, then `\" (and N more)\"` for the further error\n * objects.\n */\nfunction describeErrors(status: number, errors: readonly JsonApiErrorObject[]): string {\n let message = `JSON:API request failed with status ${status}`\n const first = errors[0]\n const words = errorText(first)\n if (words !== undefined) {\n message += `: ${words}`\n }\n if (errors.length > 1) {\n message += ` (and ${errors.length - 1} more)`\n }\n return message\n}\n\n/**\n * Thrown for any non-2xx JSON:API response. Carries the parsed error document plus\n * expressive status matchers and pointer-grouping helpers.\n *\n * `C` types each error object's `code` (see {@link JsonApiErrorObject}). It is a compile-time\n * hint only: the runtime never checks a code against it.\n */\nexport class JsonApiError<C extends string = string> extends Error {\n readonly status: number\n readonly errors: JsonApiErrorObject<C>[]\n\n constructor(status: number, errors: JsonApiErrorObject<C>[], message?: string) {\n super(message ?? describeErrors(status, errors))\n this.name = 'JsonApiError'\n this.status = status\n this.errors = errors\n }\n\n hasStatus(status: number): boolean {\n return this.status === status\n }\n\n is4xx(): boolean {\n return this.status >= 400 && this.status < 500\n }\n\n is5xx(): boolean {\n return this.status >= 500 && this.status < 600\n }\n\n isBadRequest(): boolean {\n return this.status === 400\n }\n\n isUnauthorized(): boolean {\n return this.status === 401\n }\n\n isForbidden(): boolean {\n return this.status === 403\n }\n\n isNotFound(): boolean {\n return this.status === 404\n }\n\n isNotAcceptable(): boolean {\n return this.status === 406\n }\n\n isConflict(): boolean {\n return this.status === 409\n }\n\n isUnsupportedMediaType(): boolean {\n return this.status === 415\n }\n\n isUnprocessable(): boolean {\n return this.status === 422\n }\n\n /** Alias of {@link isUnprocessable} — the JSON:API validation status. */\n isValidationError(): boolean {\n return this.status === 422\n }\n\n isRateLimited(): boolean {\n return this.status === 429\n }\n\n /**\n * Group errors by user-facing input path (falls back to the raw pointer, then the\n * query parameter). The payoff for form/validation UX — 422 `source.pointer`s are\n * remapped to the flat shape the caller actually supplied.\n */\n byPath(): Record<string, JsonApiErrorObject<C>[]> {\n const out: Record<string, JsonApiErrorObject<C>[]> = {}\n for (const e of this.errors) {\n const key = e.path ?? e.source?.pointer ?? e.source?.parameter ?? '_'\n ;(out[key] ??= []).push(e)\n }\n return out\n }\n}\n\n/**\n * True when `err` is a {@link JsonApiError} and any of its error objects carries `code`. Takes\n * any string, so it also matches codes the server never documented. A generated client exports a\n * `hasErrorCode` bound to its server's `ErrorCode` union, which rejects a misspelt code at\n * compile time; reach for this one only to match an undocumented code.\n */\nexport function hasErrorCode(err: unknown, code: string): err is JsonApiError {\n return err instanceof JsonApiError && err.errors.some((e) => e.code === code)\n}\n\n/**\n * The codes `hasErrorCode` and `findError` take for an error typed `E`: the codes of the\n * {@link JsonApiError} it holds, such as a query's `error` typed by the operation that raised it,\n * else `C`, every code the server documents.\n */\nexport type ErrorCodesFor<E, C extends string> = string extends CodesOf<E, C> ? C : CodesOf<E, C>\n\n/**\n * {@link hasErrorCode} restricted to one server's documented codes, or to the codes `err`'s type\n * carries. A generated client binds it:\n * `export const hasErrorCode = hasErrorCodeRuntime as ErrorCodeGuard<ErrorCode>`. The cast is\n * needed because `JsonApiError<string>` doesn't assign to `JsonApiError<ErrorCode>`.\n */\nexport type ErrorCodeGuard<C extends string> = <E>(\n err: E,\n code: ErrorCodesFor<E, C>,\n) => err is E & GuardedError<E, ErrorCodesFor<E, C>>\n\n/** What a matched guard narrows `E` to: its {@link JsonApiError} members, or one carrying `K`. */\ntype GuardedError<E, K extends string> = [JsonApiErrorOf<E>] extends [never]\n ? JsonApiError<K>\n : JsonApiErrorOf<E>\n\n/**\n * An error object carrying the documented code `K`, its `meta` typed when the server declares\n * one for the code. `M` is a generated client's `ErrorMetaByCode`; a code it does not list\n * keeps the untyped `meta`.\n */\nexport type CodedErrorObject<K extends string, M = {}> = JsonApiErrorObject<K> & {\n code: K\n} & (K extends keyof M ? { meta: M[K] } : {})\n\n/**\n * The first error object in `err` carrying `code`, or `undefined` when `err` is not a\n * {@link JsonApiError} or none of its errors carries it. Takes any string; a generated client\n * exports a `findError` bound to its documented codes and their `meta`, which types the result.\n */\nexport function findError(err: unknown, code: string): JsonApiErrorObject | undefined {\n return err instanceof JsonApiError ? err.errors.find((e) => e.code === code) : undefined\n}\n\n/**\n * {@link findError} restricted to one server's documented codes and their declared `meta`, or to\n * the codes `err`'s type carries. A generated client binds it:\n * `export const findError = findErrorRuntime as ErrorFinder<ErrorCode, ErrorMetaByCode>`.\n */\nexport type ErrorFinder<C extends string, M = {}> = <E, K extends ErrorCodesFor<E, C>>(\n err: E,\n code: K,\n) => CodedErrorObject<K, M> | undefined\n","/**\n * The keys a sparse fieldset selected of each attribute it narrowed, under the Nested Fieldsets\n * profile (https://haddowg.github.io/json-api/profiles/nested-fieldsets/): attribute name -> the\n * paths `fields[type]=<attribute>.<path>` named, in request order, each once. A path into a nested\n * object, such as `geo.lat`, names one key per level, and a path through a list names its items\n * `*`, such as `*.sku`. An attribute the fieldset also lists whole\n * is left out, and so is a path whose key the fieldset also lists whole, since the server renders\n * those whole. A path ending in `*` names the list itself, so `lines.*` lists `lines` whole and\n * `shipping.parcels.*` selects `parcels` whole. Empty when nothing was narrowed.\n */\nexport type NestedFieldset = Readonly<Record<string, readonly string[]>>\n\nconst NONE: NestedFieldset = Object.freeze({})\n\n/**\n * The {@link NestedFieldset} of one type's `fields[type]` members. The path is everything after the\n * first full stop, as the server reads it, and a member with an empty key at any level selects\n * nothing.\n */\nexport function nestedFieldset(listed: readonly string[] | undefined): NestedFieldset {\n if (listed === undefined) {\n return NONE\n }\n const members = listed.map(listItself)\n const whole = new Set(members.filter((member) => !member.includes('.')))\n const out: Record<string, string[]> = {}\n for (const member of members) {\n const dot = member.indexOf('.')\n if (dot <= 0) {\n continue\n }\n const attribute = member.slice(0, dot)\n if (whole.has(attribute)) {\n continue\n }\n const path = member.slice(dot + 1)\n if (path.split('.').includes('')) {\n continue\n }\n const paths = (out[attribute] ??= [])\n if (!paths.includes(path)) {\n paths.push(path)\n }\n }\n for (const [attribute, paths] of Object.entries(out)) {\n out[attribute] = paths.filter(\n (path) => !paths.some((other) => other !== path && path.startsWith(`${other}.`)),\n )\n }\n return Object.keys(out).length === 0 ? NONE : out\n}\n\n/** A member ending in `.*` with the wildcard dropped, since it names the list itself. */\nfunction listItself(member: string): string {\n let out = member\n while (out.endsWith('.*')) {\n out = out.slice(0, -2)\n }\n return out\n}\n\n/**\n * The `fields[type]` members a request URL carries, by type, for a link the client follows as\n * given, such as a `next` page, whose query it didn't build.\n */\nexport function fieldsOfUrl(url: string): Record<string, string[]> | undefined {\n let params: URLSearchParams\n try {\n params = new URL(url, 'http://link.invalid').searchParams\n } catch {\n return undefined\n }\n let out: Record<string, string[]> | undefined\n params.forEach((value, name) => {\n const type = /^fields\\[(.+)\\]$/.exec(name)?.[1]\n if (type !== undefined) {\n ;(out ??= {})[type] = value === '' ? [] : value.split(',')\n }\n })\n return out\n}\n","import { StructuralGuardError } from './errors'\nimport { nestedFieldset } from './nested-fieldset'\nimport type { Document } from './request'\n\n/**\n * A wire resource as it appears in a document's `data`/`included` — a JSON:API resource\n * object (or bare identifier). The structural guards assert `type` (and, where required,\n * `id`); the opt-in validator sees the whole object to check the rest against its schema.\n */\nexport interface WireResource {\n type: string\n id?: string\n [key: string]: unknown\n}\n\n/**\n * What the request a resource answered tells a validator. `fields` is the sparse fieldset the\n * request sent for the resource's type, `fields[type]`, absent when it sent none.\n */\nexport interface ValidationContext {\n readonly fields?: readonly string[]\n}\n\n/**\n * The opt-in per-resource validator: validate one wire `resource` against its JSON `schema`\n * (the bundle's per-type resource-object schema). The engine is the user's — throw (or\n * aggregate-then-throw) on an invalid resource; return for a valid one. With the bare-function\n * seam form there is no per-type schema, so `schema` is `undefined` and the function owns the\n * whole decision. With the schema-driven form, `schema` is already relaxed for the request's\n * sparse fieldset (see {@link sparseSchema}). `context` carries that fieldset either way, so a\n * bare validator can relax its own schema.\n */\nexport type Validator = (\n resource: WireResource,\n schema: unknown,\n context?: ValidationContext,\n) => void\n\n/** A per-type JSON Schema map (the codegen-emitted `schemas` constant), keyed by JSON:API type. */\nexport type SchemaMap = Readonly<Record<string, unknown>>\n\n/**\n * The schema-driven validation seam: a per-type `schemas` map plus a `validator` engine. Each\n * wire resource is validated against `schemas[resource.type]`; a type with no schema is skipped.\n */\nexport interface ValidationConfig {\n schemas: SchemaMap\n validator: Validator\n}\n\n/**\n * The `validate?` option on {@link ClientOptions}: either the schema-driven {@link ValidationConfig}\n * (the common case — the codegen-emitted `schemas` map + an engine adapter) or a bare\n * {@link Validator} that owns schema lookup itself (it is called per resource with `schema` =\n * `undefined`). Absent => no per-field validation (zero overhead, no engine dependency).\n */\nexport type ValidationOption = ValidationConfig | Validator\n\n/**\n * A normalised validator: resolve a resource's schema (or `undefined`) and validate it. `fields`\n * is the request's sparse fieldset for the resource's type, when it sent one.\n */\nexport interface ResolvedValidator {\n validate(resource: WireResource, fields?: readonly string[]): void\n}\n\n/** Whether a `validate` option is the schema-driven config (vs a bare validator function). */\nfunction isConfig(option: ValidationOption): option is ValidationConfig {\n return typeof option === 'object' && option !== null && !Array.isArray(option)\n}\n\n/**\n * Normalise the `validate?` option to a single per-resource validator. The config form looks the\n * schema up by `resource.type` and skips a type with no schema (the seam stays graceful for a\n * partially-covered bundle); the bare-function form calls the validator with `schema = undefined`,\n * delegating the whole decision to the caller. Returns `undefined` when validation is off.\n */\nexport function resolveValidator(\n option: ValidationOption | undefined,\n): ResolvedValidator | undefined {\n if (option === undefined) {\n return undefined\n }\n if (isConfig(option)) {\n const { schemas, validator } = option\n const sparse = sparseSchemas()\n return {\n validate(resource, fields) {\n const schema = schemas[resource.type]\n // A type the bundle does not cover is skipped, not failed — partial coverage is allowed.\n if (schema === undefined) {\n return\n }\n if (fields === undefined) {\n validator(resource, schema)\n } else {\n validator(resource, sparse(schema, fields), { fields })\n }\n },\n }\n }\n return {\n validate(resource, fields) {\n if (fields === undefined) {\n option(resource, undefined)\n } else {\n option(resource, undefined, { fields })\n }\n },\n }\n}\n\n/**\n * A cache of {@link sparseSchema} results, by schema and fieldset, so each pair is relaxed once.\n * A schema with no fieldset comes back as it is.\n */\nexport function sparseSchemas(): (\n schema: unknown,\n fields: readonly string[] | undefined,\n) => unknown {\n const cache = new WeakMap<object, Map<string, unknown>>()\n return (schema, fields) => {\n if (fields === undefined || !isObject(schema)) {\n return schema\n }\n let bySet = cache.get(schema)\n if (bySet === undefined) {\n bySet = new Map()\n cache.set(schema, bySet)\n }\n const key = fields.join(',')\n if (!bySet.has(key)) {\n bySet.set(key, sparseSchema(schema, fields))\n }\n return bySet.get(key)\n }\n}\n\n/**\n * The members one object level of a sparse fieldset selects: `keep`, the keys it renders, and\n * `children`, the keys it narrows further, a list's items under `*`.\n */\ninterface Narrowing {\n keep: ReadonlySet<string>\n children: ReadonlyMap<string, Narrowing>\n}\n\n/** The {@link Narrowing} of key paths relative to one level, such as `b`, `c.d` or `*.sku`. */\nfunction narrowingOf(paths: readonly string[]): Narrowing {\n const keep = new Set<string>()\n const whole = new Set<string>()\n const deeper = new Map<string, string[]>()\n for (const path of paths) {\n const dot = path.indexOf('.')\n const head = dot < 0 ? path : path.slice(0, dot)\n keep.add(head)\n if (dot < 0) {\n whole.add(head)\n } else {\n const rest = deeper.get(head) ?? []\n rest.push(path.slice(dot + 1))\n deeper.set(head, rest)\n }\n }\n const children = new Map<string, Narrowing>()\n for (const [head, rest] of deeper) {\n if (!whole.has(head)) {\n children.set(head, narrowingOf(rest))\n }\n }\n return { keep, children }\n}\n\n/**\n * One {@link Narrowing} for a schema several keys share, such as a map's `additionalProperties`:\n * a key stays required only when every sharer renders it, and a key one sharer narrows is narrowed.\n */\nfunction merged(narrowings: readonly Narrowing[]): Narrowing {\n if (narrowings.length === 1) {\n return narrowings[0]!\n }\n const keep = new Set(\n [...narrowings[0]!.keep].filter((key) => narrowings.every((n) => n.keep.has(key))),\n )\n const grouped = new Map<string, Narrowing[]>()\n for (const narrowing of narrowings) {\n for (const [key, child] of narrowing.children) {\n grouped.set(key, [...(grouped.get(key) ?? []), child])\n }\n }\n const children = new Map<string, Narrowing>()\n for (const [key, group] of grouped) {\n children.set(key, merged(group))\n }\n return { keep, children }\n}\n\n/** The schema a local `$ref` such as `#/$defs/Address` points at within `root`. */\nfunction resolveRef(root: Record<string, unknown>, ref: string): unknown {\n if (!ref.startsWith('#')) {\n return undefined\n }\n let node: unknown = root\n for (const raw of ref.slice(1).split('/').slice(1)) {\n const segment = decodeURIComponent(raw).replace(/~1/g, '/').replace(/~0/g, '~')\n node = isObject(node) ? node[segment] : undefined\n }\n return node\n}\n\n/** `schema` with `narrowing` applied: its `required` cut to what the level renders, its narrowed keys relaxed in turn. */\nfunction narrowed(\n root: Record<string, unknown>,\n schema: unknown,\n narrowing: Narrowing,\n depth = 0,\n): unknown {\n if (!isObject(schema) || depth > 64) {\n return schema\n }\n if (typeof schema['$ref'] === 'string') {\n const { $ref: ref, ...siblings } = schema\n const target = resolveRef(root, ref as string)\n if (isObject(target)) {\n return narrowed(root, { ...target, ...siblings }, narrowing, depth + 1)\n }\n }\n const out: Record<string, unknown> = { ...schema }\n // The member naming a union's variant renders whatever the selection, so it stays required and\n // its `const` still tells the narrowed variants apart.\n const discriminator = isObject(out['discriminator']) ? out['discriminator']['propertyName'] : null\n const branchNarrowing =\n typeof discriminator === 'string'\n ? { keep: new Set([...narrowing.keep, discriminator]), children: narrowing.children }\n : narrowing\n for (const key of ['anyOf', 'oneOf', 'allOf'] as const) {\n const branches = out[key]\n if (Array.isArray(branches)) {\n out[key] = branches.map((branch) => narrowed(root, branch, branchNarrowing, depth + 1))\n }\n }\n // Without a discriminator, narrowed variants can no longer be told apart by their required\n // members, so a value may match more than one of them.\n if (Array.isArray(out['oneOf']) && typeof discriminator !== 'string') {\n const { oneOf, ...rest } = out\n return out['anyOf'] === undefined\n ? narrowedLevel(root, { ...rest, anyOf: oneOf }, narrowing, depth)\n : narrowedLevel(\n root,\n { ...rest, allOf: [...((rest['allOf'] as unknown[]) ?? []), { anyOf: oneOf }] },\n narrowing,\n depth,\n )\n }\n return narrowedLevel(root, out, narrowing, depth)\n}\n\n/** The rest of {@link narrowed}: one level's own `required` and keys. */\nfunction narrowedLevel(\n root: Record<string, unknown>,\n out: Record<string, unknown>,\n narrowing: Narrowing,\n depth: number,\n): unknown {\n const required = out['required']\n if (Array.isArray(required)) {\n out['required'] = required.filter((key) => typeof key === 'string' && narrowing.keep.has(key))\n }\n const properties = isObject(out['properties']) ? { ...out['properties'] } : undefined\n const patterns = isObject(out['patternProperties']) ? out['patternProperties'] : undefined\n const shared = new Map<string, Narrowing[]>()\n const share = (target: string, child: Narrowing): void => {\n shared.set(target, [...(shared.get(target) ?? []), child])\n }\n for (const [key, child] of narrowing.children) {\n if (key === '*') {\n if (isObject(out['items'])) {\n out['items'] = narrowed(root, out['items'], child, depth + 1)\n }\n continue\n }\n if (properties !== undefined && key in properties) {\n properties[key] = narrowed(root, properties[key], child, depth + 1)\n continue\n }\n const matching = Object.keys(patterns ?? {}).filter((pattern) => matches(pattern, key))\n if (matching.length > 0) {\n matching.forEach((pattern) => share(`pattern:${pattern}`, child))\n } else if (isObject(out['additionalProperties'])) {\n share('additional', child)\n }\n }\n if (properties !== undefined) {\n out['properties'] = properties\n }\n if (patterns !== undefined) {\n const next = { ...patterns }\n for (const pattern of Object.keys(patterns)) {\n const group = shared.get(`pattern:${pattern}`)\n if (group !== undefined) {\n next[pattern] = narrowed(root, patterns[pattern], merged(group), depth + 1)\n }\n }\n out['patternProperties'] = next\n }\n const additional = shared.get('additional')\n if (additional !== undefined) {\n out['additionalProperties'] = narrowed(\n root,\n out['additionalProperties'],\n merged(additional),\n depth + 1,\n )\n }\n return out\n}\n\n/** Whether a `patternProperties` pattern matches `key`; an unreadable pattern matches nothing. */\nfunction matches(pattern: string, key: string): boolean {\n try {\n return new RegExp(pattern, 'u').test(key)\n } catch {\n return false\n }\n}\n\n/**\n * A resource object schema relaxed for a response to a request whose sparse fieldset for the type\n * named `members`. An attribute or relation the fieldset leaves out is no longer required, and an\n * attribute it narrows to some of its keys, such as `address.city`, `location.geo.lat` or\n * `lines.*.sku`, requires only the keys selected at each level along those paths. A member the\n * fieldset also lists whole is left as declared, as the server renders it whole. Everything else\n * in the schema is kept, so a selected value is still checked, but for its `$id`: the copy is a\n * schema of its own.\n */\nexport function sparseSchema(schema: unknown, members: readonly string[]): unknown {\n if (!isObject(schema)) {\n return schema\n }\n const selection = nestedFieldset(members)\n const selected = new Set([\n // `lines.*` names the list itself, as `lines` does.\n ...members\n .map((member) => member.replace(/(?:\\.\\*)+$/, ''))\n .filter((member) => member !== '' && !member.includes('.')),\n ...Object.keys(selection),\n ])\n const children = new Map<string, Narrowing>()\n for (const [attribute, paths] of Object.entries(selection)) {\n children.set(attribute, narrowingOf(paths))\n }\n // The resource object keeps its own required members, but `attributes` and `relationships`\n // may be left out when the fieldset empties them.\n const required = Array.isArray(schema['required']) ? (schema['required'] as unknown[]) : []\n const out = narrowed(schema, schema, {\n keep: new Set(\n required.filter(\n (key): key is string =>\n typeof key === 'string' && key !== 'attributes' && key !== 'relationships',\n ),\n ),\n children: new Map([\n ['attributes', { keep: selected, children }],\n ['relationships', { keep: selected, children: new Map() }],\n ]),\n }) as Record<string, unknown>\n // An engine keying schemas by `$id` can then hold the copy beside the whole schema.\n delete out['$id']\n return out\n}\n\nconst isObject = (v: unknown): v is Record<string, unknown> =>\n typeof v === 'object' && v !== null && !Array.isArray(v)\n\n/**\n * The light structural guards every parsed response passes through (ADR 0004): assert the body\n * is a JSON:API document and that each `data`/`included` member carries a string `type` (and,\n * for a full resource, an `id`). This is the always-on, engine-free floor — it never duplicates\n * the opt-in per-field validation; it only proves the envelope invariant the runtime relies on.\n *\n * A primary-`data` resource and every `included` resource must carry `type`+`id`. A relationship\n * endpoint's primary data is pure resource-identifier linkage, which also carries `type`+`id`, so\n * the same guard holds; `linkage` is accepted for symmetry with the materialiser but the assertion\n * is identical (an identifier is `type`+`id`). `data: null` (an empty to-one) and a missing\n * `data` (a meta-only document) are valid and pass.\n */\nexport function assertJsonApiDocument(body: unknown): asserts body is Document {\n if (!isObject(body)) {\n throw new StructuralGuardError('Response body is not a JSON:API document (expected an object)')\n }\n // A JSON:API document must carry at least one of `data`, `errors`, or `meta`. An error\n // document never reaches here (a non-2xx throws a JsonApiError upstream), so the guard\n // requires a `data` or `meta` top-level member.\n if (!('data' in body) && !('meta' in body)) {\n throw new StructuralGuardError(\n 'Response body is not a JSON:API document (missing top-level \"data\" or \"meta\")',\n )\n }\n const data = body['data']\n if (Array.isArray(data)) {\n data.forEach((member, i) => assertResource(member, `data[${i}]`))\n } else if (data !== null && data !== undefined) {\n assertResource(data, 'data')\n }\n const included = body['included']\n if (included !== undefined) {\n if (!Array.isArray(included)) {\n throw new StructuralGuardError('Response \"included\" is not an array')\n }\n included.forEach((member, i) => assertResource(member, `included[${i}]`))\n }\n}\n\n/** Assert a single member is a resource object/identifier carrying string `type` + `id`. */\nfunction assertResource(member: unknown, at: string): void {\n if (!isObject(member)) {\n throw new StructuralGuardError(`${at} is not a JSON:API resource object`)\n }\n if (typeof member['type'] !== 'string') {\n throw new StructuralGuardError(`${at} is missing a string \"type\"`)\n }\n if (typeof member['id'] !== 'string') {\n throw new StructuralGuardError(`${at} (type \"${member['type']}\") is missing a string \"id\"`)\n }\n}\n\n/**\n * Run the opt-in validator over every wire resource in a document's `data` + `included`, each\n * against its per-type schema. Called only when a validator is configured (off by default). The\n * structural guards have already proven each member carries `type`+`id`, so the cast is sound.\n */\nexport function validateDocument(\n body: Document,\n validator: ResolvedValidator,\n fields?: Readonly<Record<string, readonly string[]>>,\n): void {\n const data = body.data\n if (Array.isArray(data)) {\n for (const member of data) {\n validateResourceMember(member, validator, fields)\n }\n } else if (data !== null && data !== undefined) {\n validateResourceMember(data, validator, fields)\n }\n if (body.included !== undefined) {\n // `included` always holds full resource objects.\n for (const member of body.included) {\n const resource = member as WireResource\n validator.validate(resource, fields?.[resource.type])\n }\n }\n}\n\n/**\n * Validate a `data` member, but only when it is a full RESOURCE OBJECT. A relationship-linkage\n * endpoint's `data` is bare resource IDENTIFIERS (`type`+`id`[+`meta`], no `attributes`/\n * `relationships`); the per-type schema describes the resource object, so running it over an\n * identifier would spuriously fail. The structural guard already covered the identifier shape.\n */\nfunction validateResourceMember(\n member: unknown,\n validator: ResolvedValidator,\n fields: Readonly<Record<string, readonly string[]>> | undefined,\n): void {\n if (isObject(member) && ('attributes' in member || 'relationships' in member)) {\n const resource = member as WireResource\n validator.validate(resource, fields?.[resource.type])\n }\n}\n"],"mappings":";;AAaA,SAAgB,UACd,OACA,WAAW,OACS;CACpB,OAAO;EAAC,OAAO;EAAQ,OAAO;EAAO,WAAW,OAAO,OAAO,KAAA;CAAS,CAAC,CAAC,MACtE,MAAM,MAAM,KAAA,KAAa,MAAM,EAClC;AACF;;;;;;;;;;ACkBA,IAAa,uBAAb,cAA0C,MAAM;CAC9C,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;;;;;;AAOA,SAAS,eAAe,QAAgB,QAA+C;CACrF,IAAI,UAAU,uCAAuC;CACrD,MAAM,QAAQ,OAAO;CACrB,MAAM,QAAQ,UAAU,KAAK;CAC7B,IAAI,UAAU,KAAA,GACZ,WAAW,KAAK;CAElB,IAAI,OAAO,SAAS,GAClB,WAAW,SAAS,OAAO,SAAS,EAAE;CAExC,OAAO;AACT;;;;;;;;AASA,IAAa,eAAb,cAA6D,MAAM;CACjE;CACA;CAEA,YAAY,QAAgB,QAAiC,SAAkB;EAC7E,MAAM,WAAW,eAAe,QAAQ,MAAM,CAAC;EAC/C,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,SAAS;CAChB;CAEA,UAAU,QAAyB;EACjC,OAAO,KAAK,WAAW;CACzB;CAEA,QAAiB;EACf,OAAO,KAAK,UAAU,OAAO,KAAK,SAAS;CAC7C;CAEA,QAAiB;EACf,OAAO,KAAK,UAAU,OAAO,KAAK,SAAS;CAC7C;CAEA,eAAwB;EACtB,OAAO,KAAK,WAAW;CACzB;CAEA,iBAA0B;EACxB,OAAO,KAAK,WAAW;CACzB;CAEA,cAAuB;EACrB,OAAO,KAAK,WAAW;CACzB;CAEA,aAAsB;EACpB,OAAO,KAAK,W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