@haddowg/json-api-client 1.0.0 → 1.1.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 CHANGED
@@ -289,6 +289,10 @@ const client = createClient({ baseUrl: 'https://music.example', transport })
289
289
 
290
290
  Retries are deliberately out of scope here — the transport (or the TanStack layer) owns them.
291
291
 
292
+ `req.signal` is set when the caller passed a `signal` to a read (`client.albums.list({ signal })`
293
+ or `$next({ signal })`). Forward it to your HTTP library so the request can be cancelled; the
294
+ default `fetch` transport passes it to `fetch`.
295
+
292
296
  ## Opt-in validation
293
297
 
294
298
  The core runtime trusts the wire (you own both ends; the envelope is invariant) and only runs the
package/dist/ajv.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Validator, n as SchemaMap } from "./validate-BmyPbJCK.cjs";
1
+ import { a as Validator, n as SchemaMap } from "./validate-CfrCMZkA.cjs";
2
2
  import { ValidateFunction } from "ajv";
3
3
 
4
4
  //#region src/ajv.d.ts
package/dist/ajv.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Validator, n as SchemaMap } from "./validate-BmyPbJCK.mjs";
1
+ import { a as Validator, n as SchemaMap } from "./validate-CfrCMZkA.mjs";
2
2
  import { ValidateFunction } from "ajv";
3
3
 
4
4
  //#region src/ajv.d.ts
package/dist/index.cjs CHANGED
@@ -395,10 +395,13 @@ function attachPage(arr, kind, meta, links, ctx, linkage) {
395
395
  };
396
396
  if (meta !== void 0) page.meta = meta;
397
397
  defineGetter(arr, "$page", () => page);
398
- define(arr, "$next", () => navigateLink(page.links.next, ctx, linkage, kind));
399
- define(arr, "$prev", () => navigateLink(page.links.prev, ctx, linkage, kind));
398
+ define(arr, "$next", (options) => navigateLink(page.links.next, ctx, linkage, kind, options?.signal));
399
+ define(arr, "$prev", (options) => navigateLink(page.links.prev, ctx, linkage, kind, options?.signal));
400
400
  }
401
- const navigateLink = (link, ctx, linkage, paginator) => link === void 0 ? Promise.resolve(void 0) : ctx.navigate(link, linkage, paginator);
401
+ const navigateLink = (link, ctx, linkage, paginator, signal) => {
402
+ if (link === void 0) return Promise.resolve(void 0);
403
+ return signal === void 0 ? ctx.navigate(link, linkage, paginator) : ctx.navigate(link, linkage, paginator, signal);
404
+ };
402
405
  /** Extract the navigation links (a link may be a string or a `{href}` object). */
403
406
  function pageLinks(links) {
404
407
  const out = {};
@@ -531,6 +534,7 @@ async function execute(ctx, req) {
531
534
  url,
532
535
  headers
533
536
  };
537
+ if (req.signal !== void 0) transportReq.signal = req.signal;
534
538
  if (req.body !== void 0) {
535
539
  headers["Content-Type"] = req.contentType ?? negotiated;
536
540
  transportReq.body = req.raw && typeof req.body === "string" ? req.body : JSON.stringify(req.body);
@@ -928,6 +932,7 @@ const fetchTransport = async (req) => {
928
932
  headers: req.headers
929
933
  };
930
934
  if (req.body !== void 0) init.body = req.body;
935
+ if (req.signal !== void 0) init.signal = req.signal;
931
936
  const res = await fetch(req.url, init);
932
937
  const headers = {};
933
938
  res.headers.forEach((value, key) => {
@@ -959,8 +964,10 @@ async function run(ctx, type, operation, vars, query, linkage = false, relationF
959
964
  path: fill(template, vars)
960
965
  };
961
966
  if (query !== void 0) {
962
- req.query = query;
963
- negotiateProfiles(ctx, type, query, req, relationForCount);
967
+ const { signal, ...params } = query;
968
+ req.query = params;
969
+ if (signal !== void 0) req.signal = signal;
970
+ negotiateProfiles(ctx, type, params, req, relationForCount);
964
971
  }
965
972
  const doc = await execute(ctx.request, req);
966
973
  const primaryType = operation === "fetchMany" ? type : void 0;
@@ -1195,10 +1202,11 @@ function createClient(descriptor, options) {
1195
1202
  descriptor,
1196
1203
  materialise: {
1197
1204
  descriptor,
1198
- navigate: async (url, linkage = false, paginator) => {
1205
+ navigate: async (url, linkage = false, paginator, signal) => {
1199
1206
  const doc = await execute(request, {
1200
1207
  method: "GET",
1201
- path: url
1208
+ path: url,
1209
+ ...signal !== void 0 ? { signal } : {}
1202
1210
  });
1203
1211
  return doc === void 0 ? void 0 : materialise(doc, ctx.materialise, linkage, void 0, paginator);
1204
1212
  },
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as SortQuery, A as DefaultActionTypes, At as RelationView, B as IncludePath, Bt as AtomicDescriptor, C as fetchTransport, Ct as mediaType, D as Collection, Dt as EdgeEnvelope, E as Client, Et as Edge, F as FieldsMap, Ft as ActionDescriptor, G as ReadResult, Gt as RelationDescriptor, H as LinkageRef, Ht as ClientIdPolicy, I as FilterKey, It as ActionInput, J as RelationshipAccessor, K as RelationName, Kt as RelationMutations, L as FilterQuery, Lt as ActionOutput, M as DefaultWriteAttributes, Mt as ResourceLinks, N as EdgeMembers, Nt as materialise, O as CountToken, Ot as MaterialiseContext, P as FieldSelectionMap, Pt as relatedPaginatorKind, Q as SingleReadQuery, R as HydratedMember, Rt as ActionScope, S as TransportResponse, St as ResourceIdentifier, T as AtomicResultOf, Tt as DocumentEnvelope, U as MemberName, Ut as CountableDescriptor, V as IncludedRelations, Vt as Cardinality, W as PivotInput, Wt as PaginatorKind, X as ResourceHandle, Y as ResourceAccessors, Z as ResourceObjectView, _ as HANDLE_RESERVED, _t as ATOMIC_EXT, a as Validator, at as WriteOptions, b as JsonApiTransport, bt as LocalIdentifier, c as resolveValidator, ct as AtomicDeleteHandle, d as JsonApiContext, dt as AtomicRef, et as SortToken, f as JsonApiRequest, ft as AtomicResult, g as ClientOptions, gt as runAtomic, h as serializeQuery, ht as AtomicUpdateInput, i as ValidationOption, it as UpdateInput, j as DefaultAttributes, jt as ResourceEnvelope, k as CreateInput, kt as Page, l as validateDocument, lt as AtomicHandle, m as execute, mt as AtomicUpdateHandle, n as SchemaMap, nt as TypeName, o as WireResource, ot as AtomicCreateHandle, p as ReadQuery, pt as AtomicResults, q as RelationReadQuery, qt as ResourceDescriptor, r as ValidationConfig, rt as TypedReadQuery, s as assertJsonApiDocument, st as AtomicCreateInput, t as ResolvedValidator, tt as TypeAccessor, u as Document, ut as AtomicRecorder, v as HeadersInit, vt as ATOMIC_MEDIA_TYPE, w as ActionsAccessor, wt as ArrayEnvelope, x as TransportRequest, xt as MediaTypeParams, y as createClient, yt as JSON_API_MEDIA_TYPE, z as IdentifierMember, zt as ApiDescriptor } from "./validate-BmyPbJCK.cjs";
1
+ import { $ as SortQuery, A as DefaultActionTypes, At as Page, B as IncludePath, Bt as ApiDescriptor, C as fetchTransport, Ct as mediaType, D as Collection, Dt as EdgeEnvelope, E as Client, Et as Edge, F as FieldsMap, Ft as relatedPaginatorKind, G as ReadResult, Gt as PaginatorKind, H as LinkageRef, Ht as Cardinality, I as FilterKey, It as ActionDescriptor, J as RelationshipAccessor, Jt as ResourceDescriptor, K as RelationName, Kt as RelationDescriptor, L as FilterQuery, Lt as ActionInput, M as DefaultWriteAttributes, Mt as ResourceEnvelope, N as EdgeMembers, Nt as ResourceLinks, O as CountToken, Ot as MaterialiseContext, P as FieldSelectionMap, Pt as materialise, Q as SingleReadQuery, R as HydratedMember, Rt as ActionOutput, S as TransportResponse, St as ResourceIdentifier, T as AtomicResultOf, Tt as DocumentEnvelope, U as MemberName, Ut as ClientIdPolicy, V as IncludedRelations, Vt as AtomicDescriptor, W as PivotInput, Wt as CountableDescriptor, X as ResourceHandle, Y as ResourceAccessors, Z as ResourceObjectView, _ as HANDLE_RESERVED, _t as ATOMIC_EXT, a as Validator, at as WriteOptions, b as JsonApiTransport, bt as LocalIdentifier, c as resolveValidator, ct as AtomicDeleteHandle, d as JsonApiContext, dt as AtomicRef, et as SortToken, f as JsonApiRequest, ft as AtomicResult, g as ClientOptions, gt as runAtomic, h as serializeQuery, ht as AtomicUpdateInput, i as ValidationOption, it as UpdateInput, j as DefaultAttributes, jt as RelationView, k as CreateInput, kt as NavigateOptions, l as validateDocument, lt as AtomicHandle, m as execute, mt as AtomicUpdateHandle, n as SchemaMap, nt as TypeName, o as WireResource, ot as AtomicCreateHandle, p as ReadQuery, pt as AtomicResults, q as RelationReadQuery, qt as RelationMutations, r as ValidationConfig, rt as TypedReadQuery, s as assertJsonApiDocument, st as AtomicCreateInput, t as ResolvedValidator, tt as TypeAccessor, u as Document, ut as AtomicRecorder, v as HeadersInit, vt as ATOMIC_MEDIA_TYPE, w as ActionsAccessor, wt as ArrayEnvelope, x as TransportRequest, xt as MediaTypeParams, y as createClient, yt as JSON_API_MEDIA_TYPE, z as IdentifierMember, zt as ActionScope } from "./validate-CfrCMZkA.cjs";
2
2
 
3
3
  //#region src/errors.d.ts
4
4
  /** A single JSON:API error object (spec: error objects). */
@@ -194,5 +194,5 @@ declare function withRemappedRelationshipPaths(error: JsonApiError, rel: string,
194
194
  */
195
195
  declare function withRemappedAtomicPaths(error: JsonApiError, descriptor: ApiDescriptor, typeForOp: (opIndex: number) => string | undefined): JsonApiError;
196
196
  //#endregion
197
- export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, ActionDescriptor, ActionInput, ActionOutput, ActionScope, ActionsAccessor, ApiDescriptor, ArrayEnvelope, AtomicCreateHandle, AtomicCreateInput, AtomicDeleteHandle, AtomicDescriptor, AtomicHandle, AtomicRecorder, AtomicRef, AtomicResult, AtomicResultOf, AtomicResults, AtomicUpdateHandle, AtomicUpdateInput, Cardinality, Client, ClientIdPolicy, ClientOptions, Collection, CountToken, CountableDescriptor, CreateInput, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, FieldSelectionMap, FieldsMap, FilterKey, FilterQuery, HANDLE_RESERVED, HeadersInit, HydratedMember, IdentifierMember, IncludePath, IncludedRelations, JSON_API_MEDIA_TYPE, JsonApiContext, JsonApiError, JsonApiErrorObject, JsonApiRequest, JsonApiTransport, LinkageRef, LocalIdentifier, MaterialiseContext, MediaTypeParams, MemberName, Page, PaginatorKind, PivotInput, ReadQuery, ReadResult, RelationDescriptor, RelationMutations, RelationName, RelationReadQuery, RelationView, RelationshipAccessor, RelationshipDocument, ResolvedValidator, ResourceAccessors, ResourceDescriptor, ResourceEnvelope, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceObjectView, SchemaMap, SingleReadQuery, SortQuery, SortToken, StructuralGuardError, ToDocumentOptions, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedReadQuery, UpdateInput, ValidationConfig, ValidationOption, Validator, WireResource, WriteDocument, WriteOptions, assertJsonApiDocument, createClient, execute, fetchTransport, materialise, mediaType, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
197
+ export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, ActionDescriptor, ActionInput, ActionOutput, ActionScope, ActionsAccessor, ApiDescriptor, ArrayEnvelope, AtomicCreateHandle, AtomicCreateInput, AtomicDeleteHandle, AtomicDescriptor, AtomicHandle, AtomicRecorder, AtomicRef, AtomicResult, AtomicResultOf, AtomicResults, AtomicUpdateHandle, AtomicUpdateInput, Cardinality, Client, ClientIdPolicy, ClientOptions, Collection, CountToken, CountableDescriptor, CreateInput, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, FieldSelectionMap, FieldsMap, FilterKey, FilterQuery, HANDLE_RESERVED, HeadersInit, HydratedMember, IdentifierMember, IncludePath, IncludedRelations, JSON_API_MEDIA_TYPE, JsonApiContext, JsonApiError, JsonApiErrorObject, JsonApiRequest, JsonApiTransport, LinkageRef, LocalIdentifier, MaterialiseContext, MediaTypeParams, MemberName, NavigateOptions, Page, PaginatorKind, PivotInput, ReadQuery, ReadResult, RelationDescriptor, RelationMutations, RelationName, RelationReadQuery, RelationView, RelationshipAccessor, RelationshipDocument, ResolvedValidator, ResourceAccessors, ResourceDescriptor, ResourceEnvelope, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceObjectView, SchemaMap, SingleReadQuery, SortQuery, SortToken, StructuralGuardError, ToDocumentOptions, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedReadQuery, UpdateInput, ValidationConfig, ValidationOption, Validator, WireResource, WriteDocument, WriteOptions, assertJsonApiDocument, createClient, execute, fetchTransport, materialise, mediaType, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
198
198
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as SortQuery, A as DefaultActionTypes, At as RelationView, B as IncludePath, Bt as AtomicDescriptor, C as fetchTransport, Ct as mediaType, D as Collection, Dt as EdgeEnvelope, E as Client, Et as Edge, F as FieldsMap, Ft as ActionDescriptor, G as ReadResult, Gt as RelationDescriptor, H as LinkageRef, Ht as ClientIdPolicy, I as FilterKey, It as ActionInput, J as RelationshipAccessor, K as RelationName, Kt as RelationMutations, L as FilterQuery, Lt as ActionOutput, M as DefaultWriteAttributes, Mt as ResourceLinks, N as EdgeMembers, Nt as materialise, O as CountToken, Ot as MaterialiseContext, P as FieldSelectionMap, Pt as relatedPaginatorKind, Q as SingleReadQuery, R as HydratedMember, Rt as ActionScope, S as TransportResponse, St as ResourceIdentifier, T as AtomicResultOf, Tt as DocumentEnvelope, U as MemberName, Ut as CountableDescriptor, V as IncludedRelations, Vt as Cardinality, W as PivotInput, Wt as PaginatorKind, X as ResourceHandle, Y as ResourceAccessors, Z as ResourceObjectView, _ as HANDLE_RESERVED, _t as ATOMIC_EXT, a as Validator, at as WriteOptions, b as JsonApiTransport, bt as LocalIdentifier, c as resolveValidator, ct as AtomicDeleteHandle, d as JsonApiContext, dt as AtomicRef, et as SortToken, f as JsonApiRequest, ft as AtomicResult, g as ClientOptions, gt as runAtomic, h as serializeQuery, ht as AtomicUpdateInput, i as ValidationOption, it as UpdateInput, j as DefaultAttributes, jt as ResourceEnvelope, k as CreateInput, kt as Page, l as validateDocument, lt as AtomicHandle, m as execute, mt as AtomicUpdateHandle, n as SchemaMap, nt as TypeName, o as WireResource, ot as AtomicCreateHandle, p as ReadQuery, pt as AtomicResults, q as RelationReadQuery, qt as ResourceDescriptor, r as ValidationConfig, rt as TypedReadQuery, s as assertJsonApiDocument, st as AtomicCreateInput, t as ResolvedValidator, tt as TypeAccessor, u as Document, ut as AtomicRecorder, v as HeadersInit, vt as ATOMIC_MEDIA_TYPE, w as ActionsAccessor, wt as ArrayEnvelope, x as TransportRequest, xt as MediaTypeParams, y as createClient, yt as JSON_API_MEDIA_TYPE, z as IdentifierMember, zt as ApiDescriptor } from "./validate-BmyPbJCK.mjs";
1
+ import { $ as SortQuery, A as DefaultActionTypes, At as Page, B as IncludePath, Bt as ApiDescriptor, C as fetchTransport, Ct as mediaType, D as Collection, Dt as EdgeEnvelope, E as Client, Et as Edge, F as FieldsMap, Ft as relatedPaginatorKind, G as ReadResult, Gt as PaginatorKind, H as LinkageRef, Ht as Cardinality, I as FilterKey, It as ActionDescriptor, J as RelationshipAccessor, Jt as ResourceDescriptor, K as RelationName, Kt as RelationDescriptor, L as FilterQuery, Lt as ActionInput, M as DefaultWriteAttributes, Mt as ResourceEnvelope, N as EdgeMembers, Nt as ResourceLinks, O as CountToken, Ot as MaterialiseContext, P as FieldSelectionMap, Pt as materialise, Q as SingleReadQuery, R as HydratedMember, Rt as ActionOutput, S as TransportResponse, St as ResourceIdentifier, T as AtomicResultOf, Tt as DocumentEnvelope, U as MemberName, Ut as ClientIdPolicy, V as IncludedRelations, Vt as AtomicDescriptor, W as PivotInput, Wt as CountableDescriptor, X as ResourceHandle, Y as ResourceAccessors, Z as ResourceObjectView, _ as HANDLE_RESERVED, _t as ATOMIC_EXT, a as Validator, at as WriteOptions, b as JsonApiTransport, bt as LocalIdentifier, c as resolveValidator, ct as AtomicDeleteHandle, d as JsonApiContext, dt as AtomicRef, et as SortToken, f as JsonApiRequest, ft as AtomicResult, g as ClientOptions, gt as runAtomic, h as serializeQuery, ht as AtomicUpdateInput, i as ValidationOption, it as UpdateInput, j as DefaultAttributes, jt as RelationView, k as CreateInput, kt as NavigateOptions, l as validateDocument, lt as AtomicHandle, m as execute, mt as AtomicUpdateHandle, n as SchemaMap, nt as TypeName, o as WireResource, ot as AtomicCreateHandle, p as ReadQuery, pt as AtomicResults, q as RelationReadQuery, qt as RelationMutations, r as ValidationConfig, rt as TypedReadQuery, s as assertJsonApiDocument, st as AtomicCreateInput, t as ResolvedValidator, tt as TypeAccessor, u as Document, ut as AtomicRecorder, v as HeadersInit, vt as ATOMIC_MEDIA_TYPE, w as ActionsAccessor, wt as ArrayEnvelope, x as TransportRequest, xt as MediaTypeParams, y as createClient, yt as JSON_API_MEDIA_TYPE, z as IdentifierMember, zt as ActionScope } from "./validate-CfrCMZkA.mjs";
2
2
 
3
3
  //#region src/errors.d.ts
4
4
  /** A single JSON:API error object (spec: error objects). */
@@ -194,5 +194,5 @@ declare function withRemappedRelationshipPaths(error: JsonApiError, rel: string,
194
194
  */
195
195
  declare function withRemappedAtomicPaths(error: JsonApiError, descriptor: ApiDescriptor, typeForOp: (opIndex: number) => string | undefined): JsonApiError;
196
196
  //#endregion
197
- export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, ActionDescriptor, ActionInput, ActionOutput, ActionScope, ActionsAccessor, ApiDescriptor, ArrayEnvelope, AtomicCreateHandle, AtomicCreateInput, AtomicDeleteHandle, AtomicDescriptor, AtomicHandle, AtomicRecorder, AtomicRef, AtomicResult, AtomicResultOf, AtomicResults, AtomicUpdateHandle, AtomicUpdateInput, Cardinality, Client, ClientIdPolicy, ClientOptions, Collection, CountToken, CountableDescriptor, CreateInput, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, FieldSelectionMap, FieldsMap, FilterKey, FilterQuery, HANDLE_RESERVED, HeadersInit, HydratedMember, IdentifierMember, IncludePath, IncludedRelations, JSON_API_MEDIA_TYPE, JsonApiContext, JsonApiError, JsonApiErrorObject, JsonApiRequest, JsonApiTransport, LinkageRef, LocalIdentifier, MaterialiseContext, MediaTypeParams, MemberName, Page, PaginatorKind, PivotInput, ReadQuery, ReadResult, RelationDescriptor, RelationMutations, RelationName, RelationReadQuery, RelationView, RelationshipAccessor, RelationshipDocument, ResolvedValidator, ResourceAccessors, ResourceDescriptor, ResourceEnvelope, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceObjectView, SchemaMap, SingleReadQuery, SortQuery, SortToken, StructuralGuardError, ToDocumentOptions, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedReadQuery, UpdateInput, ValidationConfig, ValidationOption, Validator, WireResource, WriteDocument, WriteOptions, assertJsonApiDocument, createClient, execute, fetchTransport, materialise, mediaType, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
197
+ export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, ActionDescriptor, ActionInput, ActionOutput, ActionScope, ActionsAccessor, ApiDescriptor, ArrayEnvelope, AtomicCreateHandle, AtomicCreateInput, AtomicDeleteHandle, AtomicDescriptor, AtomicHandle, AtomicRecorder, AtomicRef, AtomicResult, AtomicResultOf, AtomicResults, AtomicUpdateHandle, AtomicUpdateInput, Cardinality, Client, ClientIdPolicy, ClientOptions, Collection, CountToken, CountableDescriptor, CreateInput, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, FieldSelectionMap, FieldsMap, FilterKey, FilterQuery, HANDLE_RESERVED, HeadersInit, HydratedMember, IdentifierMember, IncludePath, IncludedRelations, JSON_API_MEDIA_TYPE, JsonApiContext, JsonApiError, JsonApiErrorObject, JsonApiRequest, JsonApiTransport, LinkageRef, LocalIdentifier, MaterialiseContext, MediaTypeParams, MemberName, NavigateOptions, Page, PaginatorKind, PivotInput, ReadQuery, ReadResult, RelationDescriptor, RelationMutations, RelationName, RelationReadQuery, RelationView, RelationshipAccessor, RelationshipDocument, ResolvedValidator, ResourceAccessors, ResourceDescriptor, ResourceEnvelope, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceObjectView, SchemaMap, SingleReadQuery, SortQuery, SortToken, StructuralGuardError, ToDocumentOptions, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedReadQuery, UpdateInput, ValidationConfig, ValidationOption, Validator, WireResource, WriteDocument, WriteOptions, assertJsonApiDocument, createClient, execute, fetchTransport, materialise, mediaType, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
198
198
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -394,10 +394,13 @@ function attachPage(arr, kind, meta, links, ctx, linkage) {
394
394
  };
395
395
  if (meta !== void 0) page.meta = meta;
396
396
  defineGetter(arr, "$page", () => page);
397
- define(arr, "$next", () => navigateLink(page.links.next, ctx, linkage, kind));
398
- define(arr, "$prev", () => navigateLink(page.links.prev, ctx, linkage, kind));
397
+ define(arr, "$next", (options) => navigateLink(page.links.next, ctx, linkage, kind, options?.signal));
398
+ define(arr, "$prev", (options) => navigateLink(page.links.prev, ctx, linkage, kind, options?.signal));
399
399
  }
400
- const navigateLink = (link, ctx, linkage, paginator) => link === void 0 ? Promise.resolve(void 0) : ctx.navigate(link, linkage, paginator);
400
+ const navigateLink = (link, ctx, linkage, paginator, signal) => {
401
+ if (link === void 0) return Promise.resolve(void 0);
402
+ return signal === void 0 ? ctx.navigate(link, linkage, paginator) : ctx.navigate(link, linkage, paginator, signal);
403
+ };
401
404
  /** Extract the navigation links (a link may be a string or a `{href}` object). */
402
405
  function pageLinks(links) {
403
406
  const out = {};
@@ -530,6 +533,7 @@ async function execute(ctx, req) {
530
533
  url,
531
534
  headers
532
535
  };
536
+ if (req.signal !== void 0) transportReq.signal = req.signal;
533
537
  if (req.body !== void 0) {
534
538
  headers["Content-Type"] = req.contentType ?? negotiated;
535
539
  transportReq.body = req.raw && typeof req.body === "string" ? req.body : JSON.stringify(req.body);
@@ -927,6 +931,7 @@ const fetchTransport = async (req) => {
927
931
  headers: req.headers
928
932
  };
929
933
  if (req.body !== void 0) init.body = req.body;
934
+ if (req.signal !== void 0) init.signal = req.signal;
930
935
  const res = await fetch(req.url, init);
931
936
  const headers = {};
932
937
  res.headers.forEach((value, key) => {
@@ -958,8 +963,10 @@ async function run(ctx, type, operation, vars, query, linkage = false, relationF
958
963
  path: fill(template, vars)
959
964
  };
960
965
  if (query !== void 0) {
961
- req.query = query;
962
- negotiateProfiles(ctx, type, query, req, relationForCount);
966
+ const { signal, ...params } = query;
967
+ req.query = params;
968
+ if (signal !== void 0) req.signal = signal;
969
+ negotiateProfiles(ctx, type, params, req, relationForCount);
963
970
  }
964
971
  const doc = await execute(ctx.request, req);
965
972
  const primaryType = operation === "fetchMany" ? type : void 0;
@@ -1194,10 +1201,11 @@ function createClient(descriptor, options) {
1194
1201
  descriptor,
1195
1202
  materialise: {
1196
1203
  descriptor,
1197
- navigate: async (url, linkage = false, paginator) => {
1204
+ navigate: async (url, linkage = false, paginator, signal) => {
1198
1205
  const doc = await execute(request, {
1199
1206
  method: "GET",
1200
- path: url
1207
+ path: url,
1208
+ ...signal !== void 0 ? { signal } : {}
1201
1209
  });
1202
1210
  return doc === void 0 ? void 0 : materialise(doc, ctx.materialise, linkage, void 0, paginator);
1203
1211
  },