@haddowg/json-api-client 1.9.0 → 1.10.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 +9 -8
- package/dist/ajv.d.cts +1 -1
- package/dist/ajv.d.mts +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{validate-CvUPfKwB.d.cts → validate-BLXEfy75.d.cts} +60 -23
- package/dist/validate-BLXEfy75.d.cts.map +1 -0
- package/dist/{validate-CvUPfKwB.d.mts → validate-BLXEfy75.d.mts} +60 -23
- package/dist/validate-BLXEfy75.d.mts.map +1 -0
- package/package.json +3 -3
- package/dist/validate-CvUPfKwB.d.cts.map +0 -1
- package/dist/validate-CvUPfKwB.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -39,13 +39,14 @@ const client = createClient({
|
|
|
39
39
|
|
|
40
40
|
`ClientOptions`:
|
|
41
41
|
|
|
42
|
-
| Option
|
|
43
|
-
|
|
|
44
|
-
| `baseUrl`
|
|
45
|
-
| `transport`
|
|
46
|
-
| `headers`
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
42
|
+
| Option | Type | Notes |
|
|
43
|
+
| ----------------------- | ------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
44
|
+
| `baseUrl` | `string` | Base URL the generated path templates resolve against. |
|
|
45
|
+
| `transport` | `(req) => Promise<res>` | The transport seam; defaults to a `fetch` adapter. |
|
|
46
|
+
| `headers` | `() => HeadersInit \| Promise<HeadersInit>` | Per-request header provider (bearer auth, etc.). |
|
|
47
|
+
| `allowCrossOriginLinks` | `boolean` | Follow a `$next()`/`$prev()` link to another origin, sent without `headers`. Off by default. |
|
|
48
|
+
| `atomic` | `AtomicDescriptor \| null` | Atomic endpoint; the generated `createClient` threads it in. |
|
|
49
|
+
| `validate` | `ValidationOption` | Opt-in per-field validation seam (off by default). |
|
|
49
50
|
|
|
50
51
|
## Reads
|
|
51
52
|
|
|
@@ -65,7 +66,7 @@ const albums = await client.albums.list({
|
|
|
65
66
|
|
|
66
67
|
albums[0]!.title // string
|
|
67
68
|
albums[0]!.artist?.name // hydrated artist resource (its attributes are typed)
|
|
68
|
-
albums.$page.kind // 'page'
|
|
69
|
+
albums.$page.kind // 'page' (typed from the descriptor's paginator)
|
|
69
70
|
albums.$meta?.['page'] // raw top-level meta
|
|
70
71
|
```
|
|
71
72
|
|
package/dist/ajv.d.cts
CHANGED
package/dist/ajv.d.mts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/errors.ts
|
|
3
3
|
/**
|
|
4
|
-
* Thrown by the always-on light structural guards
|
|
4
|
+
* Thrown by the always-on light structural guards when a parsed response is not a
|
|
5
5
|
* JSON:API document, or a `data`/`included` member is not a resource object carrying `type`+`id`.
|
|
6
6
|
* Distinct from {@link JsonApiError} (a non-2xx server response): this signals the wire shape the
|
|
7
7
|
* runtime relies on was violated, not an application error the server reported. The opt-in
|
|
@@ -231,7 +231,7 @@ const defineGetter = (target, key, get) => {
|
|
|
231
231
|
});
|
|
232
232
|
};
|
|
233
233
|
/**
|
|
234
|
-
* Materialise a JSON:API document into a hydrated graph (ADR 0002
|
|
234
|
+
* Materialise a JSON:API document into a hydrated graph (ADR 0002):
|
|
235
235
|
*
|
|
236
236
|
* - single resource -> a flattened resource object (own enumerable type/id/attributes/
|
|
237
237
|
* relations + non-enumerable `$`-accessors);
|
|
@@ -357,7 +357,7 @@ function attachResourceEnvelope(node, raw, env, rels) {
|
|
|
357
357
|
* edge-local `$edge`/`$pivot`. Identity is by `type:id`, never reference.
|
|
358
358
|
*
|
|
359
359
|
* `relationEdge` (set for a to-one) carries the relationship object's self/related links and
|
|
360
|
-
* meta, which ride the value's `$edge`
|
|
360
|
+
* meta, which ride the value's `$edge` (docs/materialisation.md).
|
|
361
361
|
*/
|
|
362
362
|
function buildEdgeView(node, member, relationEdge) {
|
|
363
363
|
const view = {};
|
|
@@ -576,7 +576,7 @@ const isPlainObject$1 = (value) => typeof value === "object" && value !== null &
|
|
|
576
576
|
* value — a `Range`/`DateRange` deepObject (`{ min, max }`) — and recurses into nested bracketed
|
|
577
577
|
* keys (`filter[k][min]=`), matching the server's deepObject wire shape; an array joins with `,`;
|
|
578
578
|
* a scalar is appended directly. Without the object branch a `{ min, max }` value would reach the
|
|
579
|
-
* wire as `filter[k]=[object Object]` and be silently ignored by the server
|
|
579
|
+
* wire as `filter[k]=[object Object]` and be silently ignored by the server.
|
|
580
580
|
*/
|
|
581
581
|
const appendFilterValue = (parts, key, value) => {
|
|
582
582
|
if (isPlainObject$1(value)) {
|
|
@@ -793,7 +793,7 @@ const describe = (value) => value === null ? "null" : Array.isArray(value) ? "an
|
|
|
793
793
|
* - `/data/relationships/orderedTracks/data/0/meta/pivot/position` -> `orderedTracks[0].$pivot.position`
|
|
794
794
|
*
|
|
795
795
|
* Pivot values nest under a member's `meta.pivot` (symmetric with reads — see
|
|
796
|
-
* `JsonPointerBuilder::forLinkageMeta`
|
|
796
|
+
* `JsonPointerBuilder::forLinkageMeta`), so a `meta/pivot/<field>` tail on
|
|
797
797
|
* a member of a pivot-bearing to-many is surfaced as `.$pivot.<field>`.
|
|
798
798
|
*
|
|
799
799
|
* A query-side pointer is left untouched (those are already user-facing — see
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as MemberName, $t as ResourceLinks, A as BinaryBody, An as OperationExamples, At as AtomicRef, B as ErrorCodeOf, Bn as ResourceDescriptor, Bt as MediaTypeParams, C as TransportRawBody, Cn as Cardinality, Ct as isActionLocation, D as ActionCallOptions, Dn as InputMediaKind, Dt as AtomicDeleteHandle, E as fetchTransport, En as InputMedia, Et as AtomicCreateInput, F as CreateInput, Fn as PivotDescriptor, Ft as runAtomic, G as HydratedMember, Gt as Edge, H as FieldsMap, Hn as StrategyDescriptor, Ht as mediaType, I as DefaultActionTypes, In as RawMediaKind, It as ATOMIC_EXT, J as IncludedRelations, Jt as LinkObject, K as IdentifierMember, Kt as EdgeEnvelope, L as DefaultAttributes, Ln as RawOutputMedia, Lt as ATOMIC_MEDIA_TYPE, M as Client, Mn as PaginatorKind, Mt as AtomicResults, N as Collection, Nn as PaginatorRole, Nt as AtomicUpdateHandle, O as ActionsAccessor, On as MediaExamples, Ot as AtomicHandle, P as CountToken, Pn as PaginatorStrategy, Pt as AtomicUpdateInput, Q as ListPageParams, Qt as ResourceEnvelope, R as DefaultWriteAttributes, Rn as RelationDescriptor, Rt as JSON_API_MEDIA_TYPE, S as JsonApiTransport, Sn as AtomicDescriptor, St as ActionLocation, T as TransportResponse, Tn as CountableDescriptor, Tt as AtomicCreateHandle, U as FilterKey, Un as isPolymorphic, Ut as ArrayEnvelope, V as FieldSelectionMap, Vn as ResourceExamples, Vt as ResourceIdentifier, W as FilterQuery, Wt as DocumentEnvelope, X as IncludedType, Xt as NavigateOptions, Y as IncludedResource, Yt as MaterialiseContext, Z as LinkageRef, Zt as RelationView, _ as serializeQuery, _n as ActionLocationDescriptor, _t as TypeName, a as Validator, an as Page, at as RelationName, b as HeadersInit, bn as ApiDescriptor, bt as WithLinks, c as resolveValidator, cn as PageMeta, ct as RelationReadQuery, d as JsonApiContext, dn as PageParamsOf, dt as ResourceHandle, en as materialise, et as PivotInput, f as JsonApiRequest, fn as ResolvedPaginator, ft as ResourceObjectView, g as executeRaw, gn as ActionInput, gt as TypeAccessor, h as execute, hn as ActionDescriptor, ht as SortToken, i as ValidationOption, in as ExactPageParams, it as RelatedIncludedType, j as BinaryResponseType, jn as PaginatorDescriptor, jt as AtomicResult, k as AtomicResultOf, kn as MenuDescriptor, kt as AtomicRecorder, l as validateDocument, ln as PageOf, lt as RelationshipAccessor, m as ReadQuery, mn as resolvePaginator, mt as SortQuery, n as SchemaMap, nn as relatedPaginatorKind, nt as ReadableRelationName, o as WireResource, on as PageKeys, ot as RelationPageParams, p as RawResponseType, pn as TypedPage, pt as SingleReadQuery, q as IncludePath, qt as Link, r as ValidationConfig, rn as CANONICAL_PAGE_KEYS, rt as RelatedIncludedResource, s as assertJsonApiDocument, sn as PageLinks, st as RelationPaginator, t as ResolvedValidator, tn as relatedPaginator, tt as ReadResult, u as Document, un as PageParams, ut as ResourceAccessors, v as ClientOptions, vn as ActionOutput, vt as TypedReadQuery, w as TransportRequest, wn as ClientIdPolicy, wt as readActionLocation, x as createClient, xn as ApiExamples, xt as WriteOptions, y as HANDLE_RESERVED, yn as ActionScope, yt as UpdateInput, z as EdgeMembers, zn as RelationMutations, zt as LocalIdentifier } from "./validate-BLXEfy75.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
4
|
/**
|
|
@@ -23,7 +23,7 @@ interface JsonApiErrorObject<C extends string = string> {
|
|
|
23
23
|
/**
|
|
24
24
|
* The user-facing input path, remapped from `source.pointer` for write errors
|
|
25
25
|
* (e.g. `/data/attributes/title` -> `title`). Populated by the runtime, which
|
|
26
|
-
* built the envelope and therefore knows the inverse mapping. See
|
|
26
|
+
* built the envelope and therefore knows the inverse mapping. See docs/errors.md.
|
|
27
27
|
*/
|
|
28
28
|
path?: string;
|
|
29
29
|
/**
|
|
@@ -34,7 +34,7 @@ interface JsonApiErrorObject<C extends string = string> {
|
|
|
34
34
|
opIndex?: number;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* Thrown by the always-on light structural guards
|
|
37
|
+
* Thrown by the always-on light structural guards when a parsed response is not a
|
|
38
38
|
* JSON:API document, or a `data`/`included` member is not a resource object carrying `type`+`id`.
|
|
39
39
|
* Distinct from {@link JsonApiError} (a non-2xx server response): this signals the wire shape the
|
|
40
40
|
* runtime relies on was violated, not an application error the server reported. The opt-in
|
|
@@ -163,7 +163,7 @@ declare function toRelationshipDocument(refs: unknown, cardinality: 'one' | 'man
|
|
|
163
163
|
* - `/data/relationships/orderedTracks/data/0/meta/pivot/position` -> `orderedTracks[0].$pivot.position`
|
|
164
164
|
*
|
|
165
165
|
* Pivot values nest under a member's `meta.pivot` (symmetric with reads — see
|
|
166
|
-
* `JsonPointerBuilder::forLinkageMeta`
|
|
166
|
+
* `JsonPointerBuilder::forLinkageMeta`), so a `meta/pivot/<field>` tail on
|
|
167
167
|
* a member of a pivot-bearing to-many is surfaced as `.$pivot.<field>`.
|
|
168
168
|
*
|
|
169
169
|
* A query-side pointer is left untouched (those are already user-facing — see
|
|
@@ -216,5 +216,5 @@ declare function withRemappedRelationshipPaths(error: JsonApiError, rel: string,
|
|
|
216
216
|
*/
|
|
217
217
|
declare function withRemappedAtomicPaths(error: JsonApiError, descriptor: ApiDescriptor, typeForOp: (opIndex: number) => string | undefined): JsonApiError;
|
|
218
218
|
//#endregion
|
|
219
|
-
export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, ActionCallOptions, ActionDescriptor, ActionInput, ActionLocation, ActionLocationDescriptor, ActionOutput, ActionScope, ActionsAccessor, ApiDescriptor, ApiExamples, ArrayEnvelope, AtomicCreateHandle, AtomicCreateInput, AtomicDeleteHandle, AtomicDescriptor, AtomicHandle, AtomicRecorder, AtomicRef, AtomicResult, AtomicResultOf, AtomicResults, AtomicUpdateHandle, AtomicUpdateInput, BinaryBody, BinaryResponseType, CANONICAL_PAGE_KEYS, Cardinality, Client, ClientIdPolicy, ClientOptions, Collection, CountToken, CountableDescriptor, CreateInput, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, ErrorCodeGuard, ErrorCodeOf, ExactPageParams, FieldSelectionMap, FieldsMap, FilterKey, FilterQuery, HANDLE_RESERVED, HeadersInit, HydratedMember, IdentifierMember, IncludePath, IncludedRelations, InputMedia, InputMediaKind, JSON_API_MEDIA_TYPE, JsonApiContext, JsonApiError, JsonApiErrorObject, JsonApiRequest, JsonApiTransport, Link, LinkObject, LinkageRef, ListPageParams, LocalIdentifier, MaterialiseContext, MediaExamples, MediaTypeParams, MemberName, MenuDescriptor, NavigateOptions, OperationExamples, Page, PageKeys, PageLinks, PageMeta, PageOf, PageParams, PageParamsOf, PaginatorDescriptor, PaginatorKind, PaginatorRole, PaginatorStrategy, PivotDescriptor, PivotInput, RawMediaKind, RawOutputMedia, RawResponseType, ReadQuery, ReadResult, ReadableRelationName, RelationDescriptor, RelationMutations, RelationName, RelationPageParams, RelationPaginator, RelationReadQuery, RelationView, RelationshipAccessor, RelationshipDocument, ResolvedPaginator, ResolvedValidator, ResourceAccessors, ResourceDescriptor, ResourceEnvelope, ResourceExamples, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceObjectView, SchemaMap, SingleReadQuery, SortQuery, SortToken, StrategyDescriptor, StructuralGuardError, ToDocumentOptions, TransportRawBody, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedPage, TypedReadQuery, UpdateInput, ValidationConfig, ValidationOption, Validator, WireResource, WithLinks, WriteDocument, WriteOptions, assertJsonApiDocument, createClient, execute, executeRaw, fetchTransport, hasErrorCode, isActionLocation, isPolymorphic, materialise, mediaType, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
|
|
219
|
+
export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, ActionCallOptions, ActionDescriptor, ActionInput, ActionLocation, ActionLocationDescriptor, ActionOutput, ActionScope, ActionsAccessor, ApiDescriptor, ApiExamples, ArrayEnvelope, AtomicCreateHandle, AtomicCreateInput, AtomicDeleteHandle, AtomicDescriptor, AtomicHandle, AtomicRecorder, AtomicRef, AtomicResult, AtomicResultOf, AtomicResults, AtomicUpdateHandle, AtomicUpdateInput, BinaryBody, BinaryResponseType, CANONICAL_PAGE_KEYS, Cardinality, Client, ClientIdPolicy, ClientOptions, Collection, CountToken, CountableDescriptor, CreateInput, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, ErrorCodeGuard, ErrorCodeOf, ExactPageParams, FieldSelectionMap, FieldsMap, FilterKey, FilterQuery, HANDLE_RESERVED, HeadersInit, HydratedMember, IdentifierMember, IncludePath, IncludedRelations, IncludedResource, IncludedType, InputMedia, InputMediaKind, JSON_API_MEDIA_TYPE, JsonApiContext, JsonApiError, JsonApiErrorObject, JsonApiRequest, JsonApiTransport, Link, LinkObject, LinkageRef, ListPageParams, LocalIdentifier, MaterialiseContext, MediaExamples, MediaTypeParams, MemberName, MenuDescriptor, NavigateOptions, OperationExamples, Page, PageKeys, PageLinks, PageMeta, PageOf, PageParams, PageParamsOf, PaginatorDescriptor, PaginatorKind, PaginatorRole, PaginatorStrategy, PivotDescriptor, PivotInput, RawMediaKind, RawOutputMedia, RawResponseType, ReadQuery, ReadResult, ReadableRelationName, RelatedIncludedResource, RelatedIncludedType, RelationDescriptor, RelationMutations, RelationName, RelationPageParams, RelationPaginator, RelationReadQuery, RelationView, RelationshipAccessor, RelationshipDocument, ResolvedPaginator, ResolvedValidator, ResourceAccessors, ResourceDescriptor, ResourceEnvelope, ResourceExamples, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceObjectView, SchemaMap, SingleReadQuery, SortQuery, SortToken, StrategyDescriptor, StructuralGuardError, ToDocumentOptions, TransportRawBody, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedPage, TypedReadQuery, UpdateInput, ValidationConfig, ValidationOption, Validator, WireResource, WithLinks, WriteDocument, WriteOptions, assertJsonApiDocument, createClient, execute, executeRaw, fetchTransport, hasErrorCode, isActionLocation, isPolymorphic, materialise, mediaType, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
|
|
220
220
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as MemberName, $t as ResourceLinks, A as BinaryBody, An as OperationExamples, At as AtomicRef, B as ErrorCodeOf, Bn as ResourceDescriptor, Bt as MediaTypeParams, C as TransportRawBody, Cn as Cardinality, Ct as isActionLocation, D as ActionCallOptions, Dn as InputMediaKind, Dt as AtomicDeleteHandle, E as fetchTransport, En as InputMedia, Et as AtomicCreateInput, F as CreateInput, Fn as PivotDescriptor, Ft as runAtomic, G as HydratedMember, Gt as Edge, H as FieldsMap, Hn as StrategyDescriptor, Ht as mediaType, I as DefaultActionTypes, In as RawMediaKind, It as ATOMIC_EXT, J as IncludedRelations, Jt as LinkObject, K as IdentifierMember, Kt as EdgeEnvelope, L as DefaultAttributes, Ln as RawOutputMedia, Lt as ATOMIC_MEDIA_TYPE, M as Client, Mn as PaginatorKind, Mt as AtomicResults, N as Collection, Nn as PaginatorRole, Nt as AtomicUpdateHandle, O as ActionsAccessor, On as MediaExamples, Ot as AtomicHandle, P as CountToken, Pn as PaginatorStrategy, Pt as AtomicUpdateInput, Q as ListPageParams, Qt as ResourceEnvelope, R as DefaultWriteAttributes, Rn as RelationDescriptor, Rt as JSON_API_MEDIA_TYPE, S as JsonApiTransport, Sn as AtomicDescriptor, St as ActionLocation, T as TransportResponse, Tn as CountableDescriptor, Tt as AtomicCreateHandle, U as FilterKey, Un as isPolymorphic, Ut as ArrayEnvelope, V as FieldSelectionMap, Vn as ResourceExamples, Vt as ResourceIdentifier, W as FilterQuery, Wt as DocumentEnvelope, X as IncludedType, Xt as NavigateOptions, Y as IncludedResource, Yt as MaterialiseContext, Z as LinkageRef, Zt as RelationView, _ as serializeQuery, _n as ActionLocationDescriptor, _t as TypeName, a as Validator, an as Page, at as RelationName, b as HeadersInit, bn as ApiDescriptor, bt as WithLinks, c as resolveValidator, cn as PageMeta, ct as RelationReadQuery, d as JsonApiContext, dn as PageParamsOf, dt as ResourceHandle, en as materialise, et as PivotInput, f as JsonApiRequest, fn as ResolvedPaginator, ft as ResourceObjectView, g as executeRaw, gn as ActionInput, gt as TypeAccessor, h as execute, hn as ActionDescriptor, ht as SortToken, i as ValidationOption, in as ExactPageParams, it as RelatedIncludedType, j as BinaryResponseType, jn as PaginatorDescriptor, jt as AtomicResult, k as AtomicResultOf, kn as MenuDescriptor, kt as AtomicRecorder, l as validateDocument, ln as PageOf, lt as RelationshipAccessor, m as ReadQuery, mn as resolvePaginator, mt as SortQuery, n as SchemaMap, nn as relatedPaginatorKind, nt as ReadableRelationName, o as WireResource, on as PageKeys, ot as RelationPageParams, p as RawResponseType, pn as TypedPage, pt as SingleReadQuery, q as IncludePath, qt as Link, r as ValidationConfig, rn as CANONICAL_PAGE_KEYS, rt as RelatedIncludedResource, s as assertJsonApiDocument, sn as PageLinks, st as RelationPaginator, t as ResolvedValidator, tn as relatedPaginator, tt as ReadResult, u as Document, un as PageParams, ut as ResourceAccessors, v as ClientOptions, vn as ActionOutput, vt as TypedReadQuery, w as TransportRequest, wn as ClientIdPolicy, wt as readActionLocation, x as createClient, xn as ApiExamples, xt as WriteOptions, y as HANDLE_RESERVED, yn as ActionScope, yt as UpdateInput, z as EdgeMembers, zn as RelationMutations, zt as LocalIdentifier } from "./validate-BLXEfy75.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
4
|
/**
|
|
@@ -23,7 +23,7 @@ interface JsonApiErrorObject<C extends string = string> {
|
|
|
23
23
|
/**
|
|
24
24
|
* The user-facing input path, remapped from `source.pointer` for write errors
|
|
25
25
|
* (e.g. `/data/attributes/title` -> `title`). Populated by the runtime, which
|
|
26
|
-
* built the envelope and therefore knows the inverse mapping. See
|
|
26
|
+
* built the envelope and therefore knows the inverse mapping. See docs/errors.md.
|
|
27
27
|
*/
|
|
28
28
|
path?: string;
|
|
29
29
|
/**
|
|
@@ -34,7 +34,7 @@ interface JsonApiErrorObject<C extends string = string> {
|
|
|
34
34
|
opIndex?: number;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* Thrown by the always-on light structural guards
|
|
37
|
+
* Thrown by the always-on light structural guards when a parsed response is not a
|
|
38
38
|
* JSON:API document, or a `data`/`included` member is not a resource object carrying `type`+`id`.
|
|
39
39
|
* Distinct from {@link JsonApiError} (a non-2xx server response): this signals the wire shape the
|
|
40
40
|
* runtime relies on was violated, not an application error the server reported. The opt-in
|
|
@@ -163,7 +163,7 @@ declare function toRelationshipDocument(refs: unknown, cardinality: 'one' | 'man
|
|
|
163
163
|
* - `/data/relationships/orderedTracks/data/0/meta/pivot/position` -> `orderedTracks[0].$pivot.position`
|
|
164
164
|
*
|
|
165
165
|
* Pivot values nest under a member's `meta.pivot` (symmetric with reads — see
|
|
166
|
-
* `JsonPointerBuilder::forLinkageMeta`
|
|
166
|
+
* `JsonPointerBuilder::forLinkageMeta`), so a `meta/pivot/<field>` tail on
|
|
167
167
|
* a member of a pivot-bearing to-many is surfaced as `.$pivot.<field>`.
|
|
168
168
|
*
|
|
169
169
|
* A query-side pointer is left untouched (those are already user-facing — see
|
|
@@ -216,5 +216,5 @@ declare function withRemappedRelationshipPaths(error: JsonApiError, rel: string,
|
|
|
216
216
|
*/
|
|
217
217
|
declare function withRemappedAtomicPaths(error: JsonApiError, descriptor: ApiDescriptor, typeForOp: (opIndex: number) => string | undefined): JsonApiError;
|
|
218
218
|
//#endregion
|
|
219
|
-
export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, ActionCallOptions, ActionDescriptor, ActionInput, ActionLocation, ActionLocationDescriptor, ActionOutput, ActionScope, ActionsAccessor, ApiDescriptor, ApiExamples, ArrayEnvelope, AtomicCreateHandle, AtomicCreateInput, AtomicDeleteHandle, AtomicDescriptor, AtomicHandle, AtomicRecorder, AtomicRef, AtomicResult, AtomicResultOf, AtomicResults, AtomicUpdateHandle, AtomicUpdateInput, BinaryBody, BinaryResponseType, CANONICAL_PAGE_KEYS, Cardinality, Client, ClientIdPolicy, ClientOptions, Collection, CountToken, CountableDescriptor, CreateInput, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, ErrorCodeGuard, ErrorCodeOf, ExactPageParams, FieldSelectionMap, FieldsMap, FilterKey, FilterQuery, HANDLE_RESERVED, HeadersInit, HydratedMember, IdentifierMember, IncludePath, IncludedRelations, InputMedia, InputMediaKind, JSON_API_MEDIA_TYPE, JsonApiContext, JsonApiError, JsonApiErrorObject, JsonApiRequest, JsonApiTransport, Link, LinkObject, LinkageRef, ListPageParams, LocalIdentifier, MaterialiseContext, MediaExamples, MediaTypeParams, MemberName, MenuDescriptor, NavigateOptions, OperationExamples, Page, PageKeys, PageLinks, PageMeta, PageOf, PageParams, PageParamsOf, PaginatorDescriptor, PaginatorKind, PaginatorRole, PaginatorStrategy, PivotDescriptor, PivotInput, RawMediaKind, RawOutputMedia, RawResponseType, ReadQuery, ReadResult, ReadableRelationName, RelationDescriptor, RelationMutations, RelationName, RelationPageParams, RelationPaginator, RelationReadQuery, RelationView, RelationshipAccessor, RelationshipDocument, ResolvedPaginator, ResolvedValidator, ResourceAccessors, ResourceDescriptor, ResourceEnvelope, ResourceExamples, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceObjectView, SchemaMap, SingleReadQuery, SortQuery, SortToken, StrategyDescriptor, StructuralGuardError, ToDocumentOptions, TransportRawBody, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedPage, TypedReadQuery, UpdateInput, ValidationConfig, ValidationOption, Validator, WireResource, WithLinks, WriteDocument, WriteOptions, assertJsonApiDocument, createClient, execute, executeRaw, fetchTransport, hasErrorCode, isActionLocation, isPolymorphic, materialise, mediaType, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
|
|
219
|
+
export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, ActionCallOptions, ActionDescriptor, ActionInput, ActionLocation, ActionLocationDescriptor, ActionOutput, ActionScope, ActionsAccessor, ApiDescriptor, ApiExamples, ArrayEnvelope, AtomicCreateHandle, AtomicCreateInput, AtomicDeleteHandle, AtomicDescriptor, AtomicHandle, AtomicRecorder, AtomicRef, AtomicResult, AtomicResultOf, AtomicResults, AtomicUpdateHandle, AtomicUpdateInput, BinaryBody, BinaryResponseType, CANONICAL_PAGE_KEYS, Cardinality, Client, ClientIdPolicy, ClientOptions, Collection, CountToken, CountableDescriptor, CreateInput, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, ErrorCodeGuard, ErrorCodeOf, ExactPageParams, FieldSelectionMap, FieldsMap, FilterKey, FilterQuery, HANDLE_RESERVED, HeadersInit, HydratedMember, IdentifierMember, IncludePath, IncludedRelations, IncludedResource, IncludedType, InputMedia, InputMediaKind, JSON_API_MEDIA_TYPE, JsonApiContext, JsonApiError, JsonApiErrorObject, JsonApiRequest, JsonApiTransport, Link, LinkObject, LinkageRef, ListPageParams, LocalIdentifier, MaterialiseContext, MediaExamples, MediaTypeParams, MemberName, MenuDescriptor, NavigateOptions, OperationExamples, Page, PageKeys, PageLinks, PageMeta, PageOf, PageParams, PageParamsOf, PaginatorDescriptor, PaginatorKind, PaginatorRole, PaginatorStrategy, PivotDescriptor, PivotInput, RawMediaKind, RawOutputMedia, RawResponseType, ReadQuery, ReadResult, ReadableRelationName, RelatedIncludedResource, RelatedIncludedType, RelationDescriptor, RelationMutations, RelationName, RelationPageParams, RelationPaginator, RelationReadQuery, RelationView, RelationshipAccessor, RelationshipDocument, ResolvedPaginator, ResolvedValidator, ResourceAccessors, ResourceDescriptor, ResourceEnvelope, ResourceExamples, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceObjectView, SchemaMap, SingleReadQuery, SortQuery, SortToken, StrategyDescriptor, StructuralGuardError, ToDocumentOptions, TransportRawBody, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedPage, TypedReadQuery, UpdateInput, ValidationConfig, ValidationOption, Validator, WireResource, WithLinks, WriteDocument, WriteOptions, assertJsonApiDocument, createClient, execute, executeRaw, fetchTransport, hasErrorCode, isActionLocation, isPolymorphic, materialise, mediaType, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
|
|
220
220
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/errors.ts
|
|
2
2
|
/**
|
|
3
|
-
* Thrown by the always-on light structural guards
|
|
3
|
+
* Thrown by the always-on light structural guards when a parsed response is not a
|
|
4
4
|
* JSON:API document, or a `data`/`included` member is not a resource object carrying `type`+`id`.
|
|
5
5
|
* Distinct from {@link JsonApiError} (a non-2xx server response): this signals the wire shape the
|
|
6
6
|
* runtime relies on was violated, not an application error the server reported. The opt-in
|
|
@@ -230,7 +230,7 @@ const defineGetter = (target, key, get) => {
|
|
|
230
230
|
});
|
|
231
231
|
};
|
|
232
232
|
/**
|
|
233
|
-
* Materialise a JSON:API document into a hydrated graph (ADR 0002
|
|
233
|
+
* Materialise a JSON:API document into a hydrated graph (ADR 0002):
|
|
234
234
|
*
|
|
235
235
|
* - single resource -> a flattened resource object (own enumerable type/id/attributes/
|
|
236
236
|
* relations + non-enumerable `$`-accessors);
|
|
@@ -356,7 +356,7 @@ function attachResourceEnvelope(node, raw, env, rels) {
|
|
|
356
356
|
* edge-local `$edge`/`$pivot`. Identity is by `type:id`, never reference.
|
|
357
357
|
*
|
|
358
358
|
* `relationEdge` (set for a to-one) carries the relationship object's self/related links and
|
|
359
|
-
* meta, which ride the value's `$edge`
|
|
359
|
+
* meta, which ride the value's `$edge` (docs/materialisation.md).
|
|
360
360
|
*/
|
|
361
361
|
function buildEdgeView(node, member, relationEdge) {
|
|
362
362
|
const view = {};
|
|
@@ -575,7 +575,7 @@ const isPlainObject$1 = (value) => typeof value === "object" && value !== null &
|
|
|
575
575
|
* value — a `Range`/`DateRange` deepObject (`{ min, max }`) — and recurses into nested bracketed
|
|
576
576
|
* keys (`filter[k][min]=`), matching the server's deepObject wire shape; an array joins with `,`;
|
|
577
577
|
* a scalar is appended directly. Without the object branch a `{ min, max }` value would reach the
|
|
578
|
-
* wire as `filter[k]=[object Object]` and be silently ignored by the server
|
|
578
|
+
* wire as `filter[k]=[object Object]` and be silently ignored by the server.
|
|
579
579
|
*/
|
|
580
580
|
const appendFilterValue = (parts, key, value) => {
|
|
581
581
|
if (isPlainObject$1(value)) {
|
|
@@ -792,7 +792,7 @@ const describe = (value) => value === null ? "null" : Array.isArray(value) ? "an
|
|
|
792
792
|
* - `/data/relationships/orderedTracks/data/0/meta/pivot/position` -> `orderedTracks[0].$pivot.position`
|
|
793
793
|
*
|
|
794
794
|
* Pivot values nest under a member's `meta.pivot` (symmetric with reads — see
|
|
795
|
-
* `JsonPointerBuilder::forLinkageMeta`
|
|
795
|
+
* `JsonPointerBuilder::forLinkageMeta`), so a `meta/pivot/<field>` tail on
|
|
796
796
|
* a member of a pivot-bearing to-many is surfaced as `.$pivot.<field>`.
|
|
797
797
|
*
|
|
798
798
|
* A query-side pointer is left untouched (those are already user-facing — see
|