@haddowg/json-api-client 1.21.0 → 1.22.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
@@ -136,10 +136,12 @@ the same value as `$count`. Both are `undefined` when the server sent no finite
136
136
 
137
137
  ### `relatedQuery` (the Relationship Queries profile)
138
138
 
139
- Where a type's `list` or `get` advertises it, `relatedQuery` filters and sorts a relationship
140
- from the primary read, keyed by include path. Each entry's `filter` and `sort` take what the
141
- relation's own related read takes. The client negotiates the profile in `Accept`, beside the
142
- Countable one when `withCount` is set too.
139
+ Where the server documents it, `relatedQuery` filters and sorts a relationship of the resources
140
+ an operation answers with: `list`, `get`, `create`, `update`, the `.related()` read of a relation
141
+ over one type, and an action answering with a resource. It's keyed by relation name, and each
142
+ entry's `filter` and `sort` take what the relation's own related read takes, with no `sort` on a
143
+ to-one. The client negotiates the profile in `Accept`, beside the Countable one when `withCount`
144
+ is set too.
143
145
 
144
146
  ```ts
145
147
  const runs = await client['campaign-template-runs'].list({
package/dist/ajv.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Validator, n as SchemaMap } from "./validate-DGoH9XA9.cjs";
1
+ import { a as Validator, n as SchemaMap } from "./validate-Rgo7Zm0U.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-DGoH9XA9.mjs";
1
+ import { a as Validator, n as SchemaMap } from "./validate-Rgo7Zm0U.mjs";
2
2
  import { ValidateFunction } from "ajv";
3
3
 
4
4
  //#region src/ajv.d.ts
package/dist/index.cjs CHANGED
@@ -184,7 +184,7 @@ const appendFilterValue = (parts, key, value, list = false) => {
184
184
  * (`filter[title]`, `page[number]`, `fields[albums]`) are kept literal; only values
185
185
  * are percent-encoded. `isListFilter` names the filter keys that take a list, whose array value
186
186
  * goes out as `filter[<key>][]` once per member, and `isRelatedListFilter` does the same for a
187
- * `relatedQuery` entry's filters by include path. Empty/undefined entries are skipped; key order is deterministic
187
+ * `relatedQuery` entry's filters by relation. Empty/undefined entries are skipped; key order is deterministic
188
188
  * (family order, then insertion order within a family) so URLs are stable for caching.
189
189
  */
190
190
  function serializeQuery(query, isListFilter, isRelatedListFilter) {
@@ -194,9 +194,9 @@ function serializeQuery(query, isListFilter, isRelatedListFilter) {
194
194
  if (query.include) append(parts, "include", query.include.join(","));
195
195
  if (query.fields) for (const [type, names] of Object.entries(query.fields)) parts.push(`fields[${type}]=${encodeURIComponent(names.join(","))}`);
196
196
  if (query.withCount && query.withCount.length > 0) append(parts, "withCount", query.withCount.join(","));
197
- for (const [path, entry] of Object.entries(query.relatedQuery ?? {})) {
198
- for (const [key, value] of Object.entries(entry?.filter ?? {})) appendFilterValue(parts, `relatedQuery[${path}][filter][${key}]`, value, isRelatedListFilter?.(path, key) ?? false);
199
- if (entry?.sort !== void 0) append(parts, `relatedQuery[${path}][sort]`, typeof entry.sort === "string" ? entry.sort : entry.sort.join(","));
197
+ for (const [relation, entry] of Object.entries(query.relatedQuery ?? {})) {
198
+ for (const [key, value] of Object.entries(entry?.filter ?? {})) appendFilterValue(parts, `relatedQuery[${relation}][filter][${key}]`, value, isRelatedListFilter?.(relation, key) ?? false);
199
+ if (entry?.sort !== void 0) append(parts, `relatedQuery[${relation}][sort]`, typeof entry.sort === "string" ? entry.sort : entry.sort.join(","));
200
200
  }
201
201
  if (query.page) for (const [key, value] of Object.entries(query.page)) append(parts, `page[${key}]`, Array.isArray(value) ? value.join(",") : value);
202
202
  return parts.join("&");
@@ -1199,6 +1199,15 @@ function parseResults(doc, ctx) {
1199
1199
  });
1200
1200
  }
1201
1201
  //#endregion
1202
+ //#region src/descriptor.ts
1203
+ /**
1204
+ * Whether a relation is polymorphic: flagged {@link RelationDescriptor.polymorphic}, or, when the
1205
+ * flag is absent, listing more than one related type.
1206
+ */
1207
+ function isPolymorphic(relation) {
1208
+ return relation.polymorphic ?? relation.types.length > 1;
1209
+ }
1210
+ //#endregion
1202
1211
  //#region src/filters.ts
1203
1212
  /**
1204
1213
  * Whether a `filter[...]` key takes a list, by the rule the server matches keys with: an exact
@@ -1333,9 +1342,9 @@ async function run(ctx, type, operation, vars, query, linkage = false, relationF
1333
1342
  req.query = params;
1334
1343
  const listFilter = listFilterMatcher(filterSpec(ctx, type, operation, vars["rel"]));
1335
1344
  if (listFilter !== void 0) req.listFilter = listFilter;
1336
- if (params.relatedQuery !== void 0) req.relatedListFilter = relatedListFilter(ctx, type);
1337
1345
  if (signal !== void 0) req.signal = signal;
1338
1346
  negotiateProfiles(ctx, type, params, req, relationForCount, operation);
1347
+ applyRelatedQuery(ctx, renderedType(ctx, type, operation, vars["rel"]), params, req);
1339
1348
  }
1340
1349
  const doc = await execute(ctx.request, req);
1341
1350
  const relation = (operation === "fetchRelated" || operation === "fetchRelationship") && vars["rel"] !== void 0 ? ctx.descriptor[type]?.relations[vars["rel"]] : void 0;
@@ -1357,40 +1366,41 @@ function filterSpec(ctx, type, operation, rel) {
1357
1366
  return types?.length === 1 ? ctx.descriptor[types[0]] : void 0;
1358
1367
  }
1359
1368
  /**
1360
- * Whether a `relatedQuery` entry's filter key takes a list, matched against the vocabulary of the
1361
- * relation its include path ends on, as that relation's related read matches it. A path through a
1362
- * polymorphic relation continues from the first member type declaring the next relation.
1369
+ * The type whose resources an operation answers with, which keys its `relatedQuery`: the type
1370
+ * itself, or a related read's related type when the relation is monomorphic. A relationship read
1371
+ * answers with linkage, so it has none.
1363
1372
  */
1364
- function relatedListFilter(ctx, type) {
1365
- const matchers = /* @__PURE__ */ new Map();
1366
- return (path, key) => {
1367
- if (!matchers.has(path)) matchers.set(path, listFilterMatcher(relatedQuerySpec(ctx, type, path)));
1368
- return matchers.get(path)?.(key) ?? false;
1369
- };
1370
- }
1371
- /** The filter vocabulary of the relation an include path from `type` ends on. */
1372
- function relatedQuerySpec(ctx, type, path) {
1373
- const names = path.split(".");
1374
- let owners = [type];
1375
- for (const [index, name] of names.entries()) {
1376
- const owner = owners.find((t) => ctx.descriptor[t]?.relations[name] !== void 0);
1377
- if (owner === void 0) return;
1378
- if (index === names.length - 1) return filterSpec(ctx, owner, "fetchRelated", name);
1379
- owners = ctx.descriptor[owner].relations[name].types;
1380
- }
1373
+ function renderedType(ctx, type, operation, rel) {
1374
+ if (operation === "fetchRelationship") return;
1375
+ if (operation !== "fetchRelated") return type;
1376
+ const relation = rel === void 0 ? void 0 : ctx.descriptor[type]?.relations[rel];
1377
+ return relation === void 0 || isPolymorphic(relation) ? void 0 : relation.types[0];
1381
1378
  }
1382
- /** Whether a `relatedQuery` carries a filter or sort for any path, so it reaches the wire. */
1379
+ /** Whether a `relatedQuery` carries a filter or sort for any relation, so it reaches the wire. */
1383
1380
  function sendsRelatedQuery(relatedQuery) {
1384
1381
  return Object.values(relatedQuery ?? {}).some((entry) => Object.keys(entry?.filter ?? {}).length > 0 || entry?.sort !== void 0 && entry.sort.length > 0);
1385
1382
  }
1386
1383
  /**
1387
- * Add any profiles a query's parameters require to the request's negotiated `profiles`. A
1388
- * `withCount` read or write needs the Countable profile in `Accept`, else the server rejects it
1389
- * (400) under strict query-param validation. The profile URI is read from the descriptor (never
1384
+ * Prepare a request's `relatedQuery` for resources of type `rendered`: match each entry's list
1385
+ * filters against its relation's related-read vocabulary, and negotiate the type's Relationship
1386
+ * Queries profile, after any Countable one, when the query sends an entry.
1387
+ */
1388
+ function applyRelatedQuery(ctx, rendered, query, req) {
1389
+ if (rendered === void 0 || !sendsRelatedQuery(query.relatedQuery)) return;
1390
+ const matchers = /* @__PURE__ */ new Map();
1391
+ req.relatedListFilter = (rel, key) => {
1392
+ if (!matchers.has(rel)) matchers.set(rel, listFilterMatcher(filterSpec(ctx, rendered, "fetchRelated", rel)));
1393
+ return matchers.get(rel)?.(key) ?? false;
1394
+ };
1395
+ const profile = ctx.descriptor[rendered]?.relatedQuery?.profile;
1396
+ if (profile !== void 0 && !(req.profiles ?? []).includes(profile)) req.profiles = [...req.profiles ?? [], profile];
1397
+ }
1398
+ /**
1399
+ * Add the Countable profile a query's `withCount` requires to the request's negotiated
1400
+ * `profiles`. A `withCount` read or write needs it in `Accept`, else the server rejects it (400)
1401
+ * under strict query-param validation. The profile URI is read from the descriptor (never
1390
1402
  * hardcoded): the relation's `countable` for a related or relationship read, the operation's
1391
1403
  * `resourceCountable` entry for a single-resource read or a write, else the type's `countable`.
1392
- * A `relatedQuery` on a collection or single read likewise adds the type's Relationship Queries
1393
- * profile, after any Countable one.
1394
1404
  */
1395
1405
  function negotiateProfiles(ctx, type, query, req, relationForCount, operation) {
1396
1406
  const profiles = [];
@@ -1399,10 +1409,6 @@ function negotiateProfiles(ctx, type, query, req, relationForCount, operation) {
1399
1409
  const profile = relationForCount !== void 0 ? descriptor?.relations[relationForCount]?.countable?.profile : (isResourceCountOperation(operation) ? descriptor?.resourceCountable?.[operation]?.profile : void 0) ?? descriptor?.countable?.profile;
1400
1410
  if (profile !== void 0) profiles.push(profile);
1401
1411
  }
1402
- if (relationForCount === void 0 && sendsRelatedQuery(query.relatedQuery)) {
1403
- const profile = ctx.descriptor[type]?.relatedQuery?.profile;
1404
- if (profile !== void 0 && !profiles.includes(profile)) profiles.push(profile);
1405
- }
1406
1412
  if (profiles.length > 0) req.profiles = [...req.profiles ?? [], ...profiles];
1407
1413
  }
1408
1414
  /** Whether an operation is one answering with one resource that may take `withCount`. */
@@ -1410,14 +1416,15 @@ function isResourceCountOperation(operation) {
1410
1416
  return operation === "fetchOne" || operation === "create" || operation === "update";
1411
1417
  }
1412
1418
  /**
1413
- * Project a write's opts to the read-query families the response honours: `include`, `fields`
1414
- * and `withCount`.
1419
+ * Project a write's opts to the read-query families the response honours: `include`, `fields`,
1420
+ * `withCount` and `relatedQuery`.
1415
1421
  */
1416
1422
  function writeQuery(opts) {
1417
1423
  if (opts === void 0) return;
1418
1424
  const query = {};
1419
1425
  if (opts.include !== void 0) query.include = [...opts.include];
1420
1426
  if (opts.withCount !== void 0) query.withCount = [...opts.withCount];
1427
+ if (opts.relatedQuery !== void 0) query.relatedQuery = opts.relatedQuery;
1421
1428
  if (opts.fields !== void 0) {
1422
1429
  const fields = {};
1423
1430
  for (const [k, v] of Object.entries(opts.fields)) fields[k] = [...v];
@@ -1460,6 +1467,7 @@ async function runWrite(ctx, spec) {
1460
1467
  if (spec.query !== void 0) {
1461
1468
  req.query = spec.query;
1462
1469
  negotiateProfiles(ctx, spec.type, spec.query, req, void 0, spec.operation);
1470
+ applyRelatedQuery(ctx, spec.type, spec.query, req);
1463
1471
  if (req.profiles !== void 0) req.contentType = JSON_API_MEDIA_TYPE;
1464
1472
  }
1465
1473
  if (spec.wait?.signal !== void 0) req.signal = spec.wait.signal;
@@ -1495,7 +1503,8 @@ async function runWrite(ctx, spec) {
1495
1503
  * `ActionLocation` and never follows it. An action declaring `rawOutput` answers in the media type
1496
1504
  * the caller picks with `options.accept`: JSON:API as above, or a `string`, a `Blob` or
1497
1505
  * `ArrayBuffer`, or parsed JSON by the media type's kind. A collection action that takes filters
1498
- * sends `options.filter` in the query string as a collection read does. A `202` the action
1506
+ * sends `options.filter` in the query string as a collection read does, and an action answering
1507
+ * with a resource sends `options.relatedQuery` as a read does. A `202` the action
1499
1508
  * declares resolves to an `Accepted` job, or with `options.wait` to the value its job URL ends at.
1500
1509
  */
1501
1510
  async function runAction(ctx, action, vars, input, options = {}) {
@@ -1509,6 +1518,13 @@ async function runAction(ctx, action, vars, input, options = {}) {
1509
1518
  const listFilter = listFilterMatcher(action);
1510
1519
  if (listFilter !== void 0) req.listFilter = listFilter;
1511
1520
  }
1521
+ if (options.relatedQuery !== void 0) {
1522
+ req.query = {
1523
+ ...req.query,
1524
+ relatedQuery: options.relatedQuery
1525
+ };
1526
+ applyRelatedQuery(ctx, action.outputType, req.query, req);
1527
+ }
1512
1528
  let remap;
1513
1529
  const media = requestMedia(action, options.contentType);
1514
1530
  if (media !== void 0 && media.kind !== "document") {
@@ -1525,6 +1541,7 @@ async function runAction(ctx, action, vars, input, options = {}) {
1525
1541
  req.contentType = sentContentType(action.contentType ?? "*/*", void 0, req.body);
1526
1542
  req.raw = true;
1527
1543
  }
1544
+ if (req.profiles !== void 0 && req.contentType === void 0) req.contentType = JSON_API_MEDIA_TYPE;
1528
1545
  const raw = responseMedia(action, options.accept);
1529
1546
  try {
1530
1547
  if (raw !== void 0) {
@@ -1830,15 +1847,6 @@ function createClient(descriptor, options) {
1830
1847
  });
1831
1848
  }
1832
1849
  //#endregion
1833
- //#region src/descriptor.ts
1834
- /**
1835
- * Whether a relation is polymorphic: flagged {@link RelationDescriptor.polymorphic}, or, when the
1836
- * flag is absent, listing more than one related type.
1837
- */
1838
- function isPolymorphic(relation) {
1839
- return relation.polymorphic ?? relation.types.length > 1;
1840
- }
1841
- //#endregion
1842
1850
  exports.ATOMIC_EXT = ATOMIC_EXT;
1843
1851
  exports.ATOMIC_MEDIA_TYPE = ATOMIC_MEDIA_TYPE;
1844
1852
  exports.CANONICAL_PAGE_KEYS = CANONICAL_PAGE_KEYS;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as IdentifierMember, $n as ClientIdPolicy, $t as AtomicResults, A as AcceptedOf, An as PageMeta, At as SortToken, B as CountedRelationName, Bn as isAccepted, Bt as WithLinks, C as createClient, Cn as relatedPaginator, Cr as isPolymorphic, Ct as RelationshipAccessor, D as TransportResponse, Dn as Page, Dt as ResourceObjectView, E as TransportRequest, En as ExactPageParams, Et as ResourceHandle, F as BinaryResponseType, Fn as TypedPage, Ft as UpdateInput, G as DefaultWriteAttributes, Gn as ActionInput, Gt as readActionLocation, H as CreateMethod, Hn as AcceptedDescriptor, Ht as WriteResult, I as Client, In as resolvePaginator, It as UpdateMethod, J as FieldSelectionMap, Jn as ActionScope, Jt as AtomicDeleteHandle, K as EdgeMembers, Kn as ActionLocationDescriptor, Kt as AtomicCreateHandle, L as Collection, Ln as Accepted, Lt as WaitOptions, M as ActionsAccessor, Mn as PageParams, Mt as TypeName, N as AtomicResultOf, Nn as PageParamsOf, Nt as TypedReadQuery, O as fetchTransport, On as PageKeys, Ot as SingleReadQuery, P as BinaryBody, Pn as ResolvedPaginator, Pt as TypedRelationReadQuery, Q as HydratedMember, Qn as Cardinality, Qt as AtomicResult, R as CountAccessor, Rn as PollOptions, Rt as WaitValue, S as HeadersInit, Sn as materialise, Sr as StrategyDescriptor, St as RelationSortQuery, T as TransportRawBody, Tn as CANONICAL_PAGE_KEYS, Tt as ResourceCountToken, U as DefaultActionTypes, Un as AcceptedOperation, Ut as ActionLocation, V as CreateInput, Vn as parseRetryAfter, Vt as WriteOptions, W as DefaultAttributes, Wn as ActionDescriptor, Wt as isActionLocation, X as FilterKey, Xn as ApiExamples, Xt as AtomicRecorder, Y as FieldsMap, Yn as ApiDescriptor, Yt as AtomicHandle, Z as FilterQuery, Zn as AtomicDescriptor, Zt as AtomicRef, _ as executeRaw, _n as NavigateOptions, _r as RelationMutations, _t as RelationFilterQuery, a as Validator, an as JSON_API_MEDIA_TYPE, ar as MenuDescriptor, at as ListPageParams, b as ClientOptions, bn as ResourceEnvelope, br as ResourceExamples, bt as RelationPaginator, c as resolveValidator, cn as ResourceIdentifier, cr as PaginatorKind, ct as PivotInput, d as ExecutedResponse, dn as DocumentEnvelope, dr as PivotDescriptor, dt as RelatedIncludedResource, en as AtomicUpdateHandle, er as CountableDescriptor, et as IncludePath, f as JsonApiContext, fn as Edge, fr as RawMediaKind, ft as RelatedIncludedType, g as execute, gn as MaterialiseContext, gr as RelationDescriptor, gt as RelationCollection, h as ReadQuery, hn as LinkObject, hr as RelatedQueryOperation, ht as RelatedQueryParam, i as ValidationOption, in as ATOMIC_MEDIA_TYPE, ir as MediaExamples, it as LinkageRef, j as ActionCallOptions, jn as PageOf, jt as TypeAccessor, k as AcceptedJob, kn as PageLinks, kt as SortQuery, l as validateDocument, ln as mediaType, lr as PaginatorRole, lt as ReadResult, m as RawResponseType, mn as Link, mr as RelatedQueryDescriptor, mt as RelatedQueryEntry, n as SchemaMap, nn as runAtomic, nr as InputMedia, nt as IncludedResource, o as WireResource, on as LocalIdentifier, or as OperationExamples, ot as LooseRelatedQueryEntry, p as JsonApiRequest, pn as EdgeEnvelope, pr as RawOutputMedia, pt as RelatedQuery, q as ErrorCodeOf, qn as ActionOutput, qt as AtomicCreateInput, r as ValidationConfig, rn as ATOMIC_EXT, rr as InputMediaKind, rt as IncludedType, s as assertJsonApiDocument, sn as MediaTypeParams, sr as PaginatorDescriptor, st as MemberName, t as ResolvedValidator, tn as AtomicUpdateInput, tr as FilterFamilyDescriptor, tt as IncludedRelations, u as Document, un as ArrayEnvelope, ur as PaginatorStrategy, ut as ReadableRelationName, v as executeResponse, vn as RelationArrayEnvelope, vr as ResourceCountOperation, vt as RelationName, w as JsonApiTransport, wn as relatedPaginatorKind, wt as ResourceAccessors, x as HANDLE_RESERVED, xn as ResourceLinks, xr as SortFamilyDescriptor, xt as RelationReadQuery, y as serializeQuery, yn as RelationView, yr as ResourceDescriptor, yt as RelationPageParams, z as CountToken, zn as PollTimeoutError, zt as WaitedWriteResult } from "./validate-DGoH9XA9.cjs";
1
+ import { $ as IdentifierMember, $n as ApiDescriptor, $t as AtomicHandle, A as AcceptedOf, An as ExactPageParams, At as ResourceObjectView, B as CountedRelationName, Bn as resolvePaginator, Bt as UpdateMethod, C as createClient, Cn as RelationView, Cr as ResourceDescriptor, Ct as RelationPaginator, D as TransportResponse, Dn as relatedPaginator, Dr as isPolymorphic, Dt as ResourceAccessors, E as TransportRequest, En as materialise, Er as StrategyDescriptor, Et as RelationshipAccessor, F as BinaryResponseType, Fn as PageOf, Ft as TypeName, G as DefaultWriteAttributes, Gn as parseRetryAfter, Gt as WriteOptions, H as CreateMethod, Hn as PollOptions, Ht as WaitValue, I as Client, In as PageParams, It as TypedReadQuery, J as FieldSelectionMap, Jn as ActionDescriptor, Jt as isActionLocation, K as EdgeMembers, Kn as AcceptedDescriptor, Kt as WriteResult, L as Collection, Ln as PageParamsOf, Lt as TypedRelatedReadQuery, M as ActionsAccessor, Mn as PageKeys, Mt as SortQuery, N as AtomicResultOf, Nn as PageLinks, Nt as SortToken, O as fetchTransport, On as relatedPaginatorKind, Ot as ResourceCountToken, P as BinaryBody, Pn as PageMeta, Pt as TypeAccessor, Q as HydratedMember, Qn as ActionScope, Qt as AtomicDeleteHandle, R as CountAccessor, Rn as ResolvedPaginator, Rt as TypedRelationReadQuery, S as HeadersInit, Sn as RelationArrayEnvelope, Sr as ResourceCountOperation, St as RelationPageParams, T as TransportRawBody, Tn as ResourceLinks, Tr as SortFamilyDescriptor, Tt as RelationSortQuery, U as DefaultActionTypes, Un as PollTimeoutError, Ut as WaitedWriteResult, V as CreateInput, Vn as Accepted, Vt as WaitOptions, W as DefaultAttributes, Wn as isAccepted, Wt as WithLinks, X as FilterKey, Xn as ActionLocationDescriptor, Xt as AtomicCreateHandle, Y as FieldsMap, Yn as ActionInput, Yt as readActionLocation, Z as FilterQuery, Zn as ActionOutput, Zt as AtomicCreateInput, _ as executeRaw, _n as EdgeEnvelope, _r as RawOutputMedia, _t as RelatedQueryRelation, a as Validator, an as AtomicUpdateInput, ar as FilterFamilyDescriptor, at as ListPageParams, b as ClientOptions, bn as MaterialiseContext, br as RelationDescriptor, bt as RelationFilterQuery, c as resolveValidator, cn as ATOMIC_MEDIA_TYPE, cr as MediaExamples, ct as MemberName, d as ExecutedResponse, dn as MediaTypeParams, dr as PaginatorDescriptor, dt as ReadableRelationName, en as AtomicRecorder, er as ApiExamples, et as IncludePath, f as JsonApiContext, fn as ResourceIdentifier, fr as PaginatorKind, ft as RelatedIncludedResource, g as execute, gn as Edge, gr as RawMediaKind, gt as RelatedQueryParam, h as ReadQuery, hn as DocumentEnvelope, hr as PivotDescriptor, ht as RelatedQueryEntry, i as ValidationOption, in as AtomicUpdateHandle, ir as CountableDescriptor, it as LinkageRef, j as ActionCallOptions, jn as Page, jt as SingleReadQuery, k as AcceptedJob, kn as CANONICAL_PAGE_KEYS, kt as ResourceHandle, l as validateDocument, ln as JSON_API_MEDIA_TYPE, lr as MenuDescriptor, lt as PivotInput, m as RawResponseType, mn as ArrayEnvelope, mr as PaginatorStrategy, mt as RelatedQuery, n as SchemaMap, nn as AtomicResult, nr as Cardinality, nt as IncludedResource, o as WireResource, on as runAtomic, or as InputMedia, ot as LooseRelatedQuery, p as JsonApiRequest, pn as mediaType, pr as PaginatorRole, pt as RelatedIncludedType, q as ErrorCodeOf, qn as AcceptedOperation, qt as ActionLocation, r as ValidationConfig, rn as AtomicResults, rr as ClientIdPolicy, rt as IncludedType, s as assertJsonApiDocument, sn as ATOMIC_EXT, sr as InputMediaKind, st as LooseRelatedQueryEntry, t as ResolvedValidator, tn as AtomicRef, tr as AtomicDescriptor, tt as IncludedRelations, u as Document, un as LocalIdentifier, ur as OperationExamples, ut as ReadResult, v as executeResponse, vn as Link, vr as RelatedQueryDescriptor, vt as RelatedReadRelatedQuery, w as JsonApiTransport, wn as ResourceEnvelope, wr as ResourceExamples, wt as RelationReadQuery, x as HANDLE_RESERVED, xn as NavigateOptions, xr as RelationMutations, xt as RelationName, y as serializeQuery, yn as LinkObject, yr as RelatedQueryOperation, yt as RelationCollection, z as CountToken, zn as TypedPage, zt as UpdateInput } from "./validate-Rgo7Zm0U.cjs";
2
2
 
3
3
  //#region src/errors.d.ts
4
4
  /**
@@ -253,5 +253,5 @@ declare function withRemappedRelationshipPaths(error: JsonApiError, rel: string,
253
253
  */
254
254
  declare function withRemappedAtomicPaths(error: JsonApiError, descriptor: ApiDescriptor, typeForOp: (opIndex: number) => string | undefined): JsonApiError;
255
255
  //#endregion
256
- export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, type Accepted, AcceptedDescriptor, AcceptedJob, AcceptedOf, AcceptedOperation, 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, CodedErrorObject, Collection, CountAccessor, CountToken, CountableDescriptor, CountedRelationName, CreateInput, CreateMethod, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, ErrorCodeGuard, ErrorCodeOf, ErrorFinder, ExactPageParams, ExecutedResponse, FieldSelectionMap, FieldsMap, FilterFamilyDescriptor, FilterKey, FilterQuery, FilterSpec, 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, LooseRelatedQueryEntry, MaterialiseContext, MediaExamples, MediaTypeParams, MemberName, MenuDescriptor, NavigateOptions, OperationExamples, Page, PageKeys, PageLinks, PageMeta, PageOf, PageParams, PageParamsOf, PaginatorDescriptor, PaginatorKind, PaginatorRole, PaginatorStrategy, PivotDescriptor, PivotInput, type PollOptions, PollTimeoutError, RawMediaKind, RawOutputMedia, RawResponseType, ReadQuery, ReadResult, ReadableRelationName, RelatedIncludedResource, RelatedIncludedType, RelatedQuery, RelatedQueryDescriptor, RelatedQueryEntry, RelatedQueryOperation, RelatedQueryParam, RelationArrayEnvelope, RelationCollection, RelationDescriptor, RelationFilterQuery, RelationMutations, RelationName, RelationPageParams, RelationPaginator, RelationReadQuery, RelationSortQuery, RelationView, RelationshipAccessor, RelationshipDocument, ResolvedPaginator, ResolvedValidator, ResourceAccessors, ResourceCountOperation, ResourceCountToken, ResourceDescriptor, ResourceEnvelope, ResourceExamples, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceObjectView, SchemaMap, SingleReadQuery, SortFamilyDescriptor, SortQuery, SortToken, StrategyDescriptor, StructuralGuardError, ToDocumentOptions, TransportRawBody, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedPage, TypedReadQuery, TypedRelationReadQuery, UpdateInput, UpdateMethod, ValidationConfig, ValidationOption, Validator, WaitOptions, WaitValue, WaitedWriteResult, WireResource, WithLinks, WriteDocument, WriteOptions, WriteResult, assertJsonApiDocument, createClient, execute, executeRaw, executeResponse, fetchTransport, findError, hasErrorCode, isAccepted, isActionLocation, isPolymorphic, listFilterMatcher, materialise, mediaType, parseRetryAfter, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
256
+ export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, type Accepted, AcceptedDescriptor, AcceptedJob, AcceptedOf, AcceptedOperation, 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, CodedErrorObject, Collection, CountAccessor, CountToken, CountableDescriptor, CountedRelationName, CreateInput, CreateMethod, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, ErrorCodeGuard, ErrorCodeOf, ErrorFinder, ExactPageParams, ExecutedResponse, FieldSelectionMap, FieldsMap, FilterFamilyDescriptor, FilterKey, FilterQuery, FilterSpec, 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, LooseRelatedQuery, LooseRelatedQueryEntry, MaterialiseContext, MediaExamples, MediaTypeParams, MemberName, MenuDescriptor, NavigateOptions, OperationExamples, Page, PageKeys, PageLinks, PageMeta, PageOf, PageParams, PageParamsOf, PaginatorDescriptor, PaginatorKind, PaginatorRole, PaginatorStrategy, PivotDescriptor, PivotInput, type PollOptions, PollTimeoutError, RawMediaKind, RawOutputMedia, RawResponseType, ReadQuery, ReadResult, ReadableRelationName, RelatedIncludedResource, RelatedIncludedType, RelatedQuery, RelatedQueryDescriptor, RelatedQueryEntry, RelatedQueryOperation, RelatedQueryParam, RelatedQueryRelation, RelatedReadRelatedQuery, RelationArrayEnvelope, RelationCollection, RelationDescriptor, RelationFilterQuery, RelationMutations, RelationName, RelationPageParams, RelationPaginator, RelationReadQuery, RelationSortQuery, RelationView, RelationshipAccessor, RelationshipDocument, ResolvedPaginator, ResolvedValidator, ResourceAccessors, ResourceCountOperation, ResourceCountToken, ResourceDescriptor, ResourceEnvelope, ResourceExamples, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceObjectView, SchemaMap, SingleReadQuery, SortFamilyDescriptor, SortQuery, SortToken, StrategyDescriptor, StructuralGuardError, ToDocumentOptions, TransportRawBody, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedPage, TypedReadQuery, TypedRelatedReadQuery, TypedRelationReadQuery, UpdateInput, UpdateMethod, ValidationConfig, ValidationOption, Validator, WaitOptions, WaitValue, WaitedWriteResult, WireResource, WithLinks, WriteDocument, WriteOptions, WriteResult, assertJsonApiDocument, createClient, execute, executeRaw, executeResponse, fetchTransport, findError, hasErrorCode, isAccepted, isActionLocation, isPolymorphic, listFilterMatcher, materialise, mediaType, parseRetryAfter, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
257
257
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as IdentifierMember, $n as ClientIdPolicy, $t as AtomicResults, A as AcceptedOf, An as PageMeta, At as SortToken, B as CountedRelationName, Bn as isAccepted, Bt as WithLinks, C as createClient, Cn as relatedPaginator, Cr as isPolymorphic, Ct as RelationshipAccessor, D as TransportResponse, Dn as Page, Dt as ResourceObjectView, E as TransportRequest, En as ExactPageParams, Et as ResourceHandle, F as BinaryResponseType, Fn as TypedPage, Ft as UpdateInput, G as DefaultWriteAttributes, Gn as ActionInput, Gt as readActionLocation, H as CreateMethod, Hn as AcceptedDescriptor, Ht as WriteResult, I as Client, In as resolvePaginator, It as UpdateMethod, J as FieldSelectionMap, Jn as ActionScope, Jt as AtomicDeleteHandle, K as EdgeMembers, Kn as ActionLocationDescriptor, Kt as AtomicCreateHandle, L as Collection, Ln as Accepted, Lt as WaitOptions, M as ActionsAccessor, Mn as PageParams, Mt as TypeName, N as AtomicResultOf, Nn as PageParamsOf, Nt as TypedReadQuery, O as fetchTransport, On as PageKeys, Ot as SingleReadQuery, P as BinaryBody, Pn as ResolvedPaginator, Pt as TypedRelationReadQuery, Q as HydratedMember, Qn as Cardinality, Qt as AtomicResult, R as CountAccessor, Rn as PollOptions, Rt as WaitValue, S as HeadersInit, Sn as materialise, Sr as StrategyDescriptor, St as RelationSortQuery, T as TransportRawBody, Tn as CANONICAL_PAGE_KEYS, Tt as ResourceCountToken, U as DefaultActionTypes, Un as AcceptedOperation, Ut as ActionLocation, V as CreateInput, Vn as parseRetryAfter, Vt as WriteOptions, W as DefaultAttributes, Wn as ActionDescriptor, Wt as isActionLocation, X as FilterKey, Xn as ApiExamples, Xt as AtomicRecorder, Y as FieldsMap, Yn as ApiDescriptor, Yt as AtomicHandle, Z as FilterQuery, Zn as AtomicDescriptor, Zt as AtomicRef, _ as executeRaw, _n as NavigateOptions, _r as RelationMutations, _t as RelationFilterQuery, a as Validator, an as JSON_API_MEDIA_TYPE, ar as MenuDescriptor, at as ListPageParams, b as ClientOptions, bn as ResourceEnvelope, br as ResourceExamples, bt as RelationPaginator, c as resolveValidator, cn as ResourceIdentifier, cr as PaginatorKind, ct as PivotInput, d as ExecutedResponse, dn as DocumentEnvelope, dr as PivotDescriptor, dt as RelatedIncludedResource, en as AtomicUpdateHandle, er as CountableDescriptor, et as IncludePath, f as JsonApiContext, fn as Edge, fr as RawMediaKind, ft as RelatedIncludedType, g as execute, gn as MaterialiseContext, gr as RelationDescriptor, gt as RelationCollection, h as ReadQuery, hn as LinkObject, hr as RelatedQueryOperation, ht as RelatedQueryParam, i as ValidationOption, in as ATOMIC_MEDIA_TYPE, ir as MediaExamples, it as LinkageRef, j as ActionCallOptions, jn as PageOf, jt as TypeAccessor, k as AcceptedJob, kn as PageLinks, kt as SortQuery, l as validateDocument, ln as mediaType, lr as PaginatorRole, lt as ReadResult, m as RawResponseType, mn as Link, mr as RelatedQueryDescriptor, mt as RelatedQueryEntry, n as SchemaMap, nn as runAtomic, nr as InputMedia, nt as IncludedResource, o as WireResource, on as LocalIdentifier, or as OperationExamples, ot as LooseRelatedQueryEntry, p as JsonApiRequest, pn as EdgeEnvelope, pr as RawOutputMedia, pt as RelatedQuery, q as ErrorCodeOf, qn as ActionOutput, qt as AtomicCreateInput, r as ValidationConfig, rn as ATOMIC_EXT, rr as InputMediaKind, rt as IncludedType, s as assertJsonApiDocument, sn as MediaTypeParams, sr as PaginatorDescriptor, st as MemberName, t as ResolvedValidator, tn as AtomicUpdateInput, tr as FilterFamilyDescriptor, tt as IncludedRelations, u as Document, un as ArrayEnvelope, ur as PaginatorStrategy, ut as ReadableRelationName, v as executeResponse, vn as RelationArrayEnvelope, vr as ResourceCountOperation, vt as RelationName, w as JsonApiTransport, wn as relatedPaginatorKind, wt as ResourceAccessors, x as HANDLE_RESERVED, xn as ResourceLinks, xr as SortFamilyDescriptor, xt as RelationReadQuery, y as serializeQuery, yn as RelationView, yr as ResourceDescriptor, yt as RelationPageParams, z as CountToken, zn as PollTimeoutError, zt as WaitedWriteResult } from "./validate-DGoH9XA9.mjs";
1
+ import { $ as IdentifierMember, $n as ApiDescriptor, $t as AtomicHandle, A as AcceptedOf, An as ExactPageParams, At as ResourceObjectView, B as CountedRelationName, Bn as resolvePaginator, Bt as UpdateMethod, C as createClient, Cn as RelationView, Cr as ResourceDescriptor, Ct as RelationPaginator, D as TransportResponse, Dn as relatedPaginator, Dr as isPolymorphic, Dt as ResourceAccessors, E as TransportRequest, En as materialise, Er as StrategyDescriptor, Et as RelationshipAccessor, F as BinaryResponseType, Fn as PageOf, Ft as TypeName, G as DefaultWriteAttributes, Gn as parseRetryAfter, Gt as WriteOptions, H as CreateMethod, Hn as PollOptions, Ht as WaitValue, I as Client, In as PageParams, It as TypedReadQuery, J as FieldSelectionMap, Jn as ActionDescriptor, Jt as isActionLocation, K as EdgeMembers, Kn as AcceptedDescriptor, Kt as WriteResult, L as Collection, Ln as PageParamsOf, Lt as TypedRelatedReadQuery, M as ActionsAccessor, Mn as PageKeys, Mt as SortQuery, N as AtomicResultOf, Nn as PageLinks, Nt as SortToken, O as fetchTransport, On as relatedPaginatorKind, Ot as ResourceCountToken, P as BinaryBody, Pn as PageMeta, Pt as TypeAccessor, Q as HydratedMember, Qn as ActionScope, Qt as AtomicDeleteHandle, R as CountAccessor, Rn as ResolvedPaginator, Rt as TypedRelationReadQuery, S as HeadersInit, Sn as RelationArrayEnvelope, Sr as ResourceCountOperation, St as RelationPageParams, T as TransportRawBody, Tn as ResourceLinks, Tr as SortFamilyDescriptor, Tt as RelationSortQuery, U as DefaultActionTypes, Un as PollTimeoutError, Ut as WaitedWriteResult, V as CreateInput, Vn as Accepted, Vt as WaitOptions, W as DefaultAttributes, Wn as isAccepted, Wt as WithLinks, X as FilterKey, Xn as ActionLocationDescriptor, Xt as AtomicCreateHandle, Y as FieldsMap, Yn as ActionInput, Yt as readActionLocation, Z as FilterQuery, Zn as ActionOutput, Zt as AtomicCreateInput, _ as executeRaw, _n as EdgeEnvelope, _r as RawOutputMedia, _t as RelatedQueryRelation, a as Validator, an as AtomicUpdateInput, ar as FilterFamilyDescriptor, at as ListPageParams, b as ClientOptions, bn as MaterialiseContext, br as RelationDescriptor, bt as RelationFilterQuery, c as resolveValidator, cn as ATOMIC_MEDIA_TYPE, cr as MediaExamples, ct as MemberName, d as ExecutedResponse, dn as MediaTypeParams, dr as PaginatorDescriptor, dt as ReadableRelationName, en as AtomicRecorder, er as ApiExamples, et as IncludePath, f as JsonApiContext, fn as ResourceIdentifier, fr as PaginatorKind, ft as RelatedIncludedResource, g as execute, gn as Edge, gr as RawMediaKind, gt as RelatedQueryParam, h as ReadQuery, hn as DocumentEnvelope, hr as PivotDescriptor, ht as RelatedQueryEntry, i as ValidationOption, in as AtomicUpdateHandle, ir as CountableDescriptor, it as LinkageRef, j as ActionCallOptions, jn as Page, jt as SingleReadQuery, k as AcceptedJob, kn as CANONICAL_PAGE_KEYS, kt as ResourceHandle, l as validateDocument, ln as JSON_API_MEDIA_TYPE, lr as MenuDescriptor, lt as PivotInput, m as RawResponseType, mn as ArrayEnvelope, mr as PaginatorStrategy, mt as RelatedQuery, n as SchemaMap, nn as AtomicResult, nr as Cardinality, nt as IncludedResource, o as WireResource, on as runAtomic, or as InputMedia, ot as LooseRelatedQuery, p as JsonApiRequest, pn as mediaType, pr as PaginatorRole, pt as RelatedIncludedType, q as ErrorCodeOf, qn as AcceptedOperation, qt as ActionLocation, r as ValidationConfig, rn as AtomicResults, rr as ClientIdPolicy, rt as IncludedType, s as assertJsonApiDocument, sn as ATOMIC_EXT, sr as InputMediaKind, st as LooseRelatedQueryEntry, t as ResolvedValidator, tn as AtomicRef, tr as AtomicDescriptor, tt as IncludedRelations, u as Document, un as LocalIdentifier, ur as OperationExamples, ut as ReadResult, v as executeResponse, vn as Link, vr as RelatedQueryDescriptor, vt as RelatedReadRelatedQuery, w as JsonApiTransport, wn as ResourceEnvelope, wr as ResourceExamples, wt as RelationReadQuery, x as HANDLE_RESERVED, xn as NavigateOptions, xr as RelationMutations, xt as RelationName, y as serializeQuery, yn as LinkObject, yr as RelatedQueryOperation, yt as RelationCollection, z as CountToken, zn as TypedPage, zt as UpdateInput } from "./validate-Rgo7Zm0U.mjs";
2
2
 
3
3
  //#region src/errors.d.ts
4
4
  /**
@@ -253,5 +253,5 @@ declare function withRemappedRelationshipPaths(error: JsonApiError, rel: string,
253
253
  */
254
254
  declare function withRemappedAtomicPaths(error: JsonApiError, descriptor: ApiDescriptor, typeForOp: (opIndex: number) => string | undefined): JsonApiError;
255
255
  //#endregion
256
- export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, type Accepted, AcceptedDescriptor, AcceptedJob, AcceptedOf, AcceptedOperation, 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, CodedErrorObject, Collection, CountAccessor, CountToken, CountableDescriptor, CountedRelationName, CreateInput, CreateMethod, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, ErrorCodeGuard, ErrorCodeOf, ErrorFinder, ExactPageParams, ExecutedResponse, FieldSelectionMap, FieldsMap, FilterFamilyDescriptor, FilterKey, FilterQuery, FilterSpec, 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, LooseRelatedQueryEntry, MaterialiseContext, MediaExamples, MediaTypeParams, MemberName, MenuDescriptor, NavigateOptions, OperationExamples, Page, PageKeys, PageLinks, PageMeta, PageOf, PageParams, PageParamsOf, PaginatorDescriptor, PaginatorKind, PaginatorRole, PaginatorStrategy, PivotDescriptor, PivotInput, type PollOptions, PollTimeoutError, RawMediaKind, RawOutputMedia, RawResponseType, ReadQuery, ReadResult, ReadableRelationName, RelatedIncludedResource, RelatedIncludedType, RelatedQuery, RelatedQueryDescriptor, RelatedQueryEntry, RelatedQueryOperation, RelatedQueryParam, RelationArrayEnvelope, RelationCollection, RelationDescriptor, RelationFilterQuery, RelationMutations, RelationName, RelationPageParams, RelationPaginator, RelationReadQuery, RelationSortQuery, RelationView, RelationshipAccessor, RelationshipDocument, ResolvedPaginator, ResolvedValidator, ResourceAccessors, ResourceCountOperation, ResourceCountToken, ResourceDescriptor, ResourceEnvelope, ResourceExamples, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceObjectView, SchemaMap, SingleReadQuery, SortFamilyDescriptor, SortQuery, SortToken, StrategyDescriptor, StructuralGuardError, ToDocumentOptions, TransportRawBody, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedPage, TypedReadQuery, TypedRelationReadQuery, UpdateInput, UpdateMethod, ValidationConfig, ValidationOption, Validator, WaitOptions, WaitValue, WaitedWriteResult, WireResource, WithLinks, WriteDocument, WriteOptions, WriteResult, assertJsonApiDocument, createClient, execute, executeRaw, executeResponse, fetchTransport, findError, hasErrorCode, isAccepted, isActionLocation, isPolymorphic, listFilterMatcher, materialise, mediaType, parseRetryAfter, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
256
+ export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, type Accepted, AcceptedDescriptor, AcceptedJob, AcceptedOf, AcceptedOperation, 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, CodedErrorObject, Collection, CountAccessor, CountToken, CountableDescriptor, CountedRelationName, CreateInput, CreateMethod, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, ErrorCodeGuard, ErrorCodeOf, ErrorFinder, ExactPageParams, ExecutedResponse, FieldSelectionMap, FieldsMap, FilterFamilyDescriptor, FilterKey, FilterQuery, FilterSpec, 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, LooseRelatedQuery, LooseRelatedQueryEntry, MaterialiseContext, MediaExamples, MediaTypeParams, MemberName, MenuDescriptor, NavigateOptions, OperationExamples, Page, PageKeys, PageLinks, PageMeta, PageOf, PageParams, PageParamsOf, PaginatorDescriptor, PaginatorKind, PaginatorRole, PaginatorStrategy, PivotDescriptor, PivotInput, type PollOptions, PollTimeoutError, RawMediaKind, RawOutputMedia, RawResponseType, ReadQuery, ReadResult, ReadableRelationName, RelatedIncludedResource, RelatedIncludedType, RelatedQuery, RelatedQueryDescriptor, RelatedQueryEntry, RelatedQueryOperation, RelatedQueryParam, RelatedQueryRelation, RelatedReadRelatedQuery, RelationArrayEnvelope, RelationCollection, RelationDescriptor, RelationFilterQuery, RelationMutations, RelationName, RelationPageParams, RelationPaginator, RelationReadQuery, RelationSortQuery, RelationView, RelationshipAccessor, RelationshipDocument, ResolvedPaginator, ResolvedValidator, ResourceAccessors, ResourceCountOperation, ResourceCountToken, ResourceDescriptor, ResourceEnvelope, ResourceExamples, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceObjectView, SchemaMap, SingleReadQuery, SortFamilyDescriptor, SortQuery, SortToken, StrategyDescriptor, StructuralGuardError, ToDocumentOptions, TransportRawBody, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedPage, TypedReadQuery, TypedRelatedReadQuery, TypedRelationReadQuery, UpdateInput, UpdateMethod, ValidationConfig, ValidationOption, Validator, WaitOptions, WaitValue, WaitedWriteResult, WireResource, WithLinks, WriteDocument, WriteOptions, WriteResult, assertJsonApiDocument, createClient, execute, executeRaw, executeResponse, fetchTransport, findError, hasErrorCode, isAccepted, isActionLocation, isPolymorphic, listFilterMatcher, materialise, mediaType, parseRetryAfter, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
257
257
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -183,7 +183,7 @@ const appendFilterValue = (parts, key, value, list = false) => {
183
183
  * (`filter[title]`, `page[number]`, `fields[albums]`) are kept literal; only values
184
184
  * are percent-encoded. `isListFilter` names the filter keys that take a list, whose array value
185
185
  * goes out as `filter[<key>][]` once per member, and `isRelatedListFilter` does the same for a
186
- * `relatedQuery` entry's filters by include path. Empty/undefined entries are skipped; key order is deterministic
186
+ * `relatedQuery` entry's filters by relation. Empty/undefined entries are skipped; key order is deterministic
187
187
  * (family order, then insertion order within a family) so URLs are stable for caching.
188
188
  */
189
189
  function serializeQuery(query, isListFilter, isRelatedListFilter) {
@@ -193,9 +193,9 @@ function serializeQuery(query, isListFilter, isRelatedListFilter) {
193
193
  if (query.include) append(parts, "include", query.include.join(","));
194
194
  if (query.fields) for (const [type, names] of Object.entries(query.fields)) parts.push(`fields[${type}]=${encodeURIComponent(names.join(","))}`);
195
195
  if (query.withCount && query.withCount.length > 0) append(parts, "withCount", query.withCount.join(","));
196
- for (const [path, entry] of Object.entries(query.relatedQuery ?? {})) {
197
- for (const [key, value] of Object.entries(entry?.filter ?? {})) appendFilterValue(parts, `relatedQuery[${path}][filter][${key}]`, value, isRelatedListFilter?.(path, key) ?? false);
198
- if (entry?.sort !== void 0) append(parts, `relatedQuery[${path}][sort]`, typeof entry.sort === "string" ? entry.sort : entry.sort.join(","));
196
+ for (const [relation, entry] of Object.entries(query.relatedQuery ?? {})) {
197
+ for (const [key, value] of Object.entries(entry?.filter ?? {})) appendFilterValue(parts, `relatedQuery[${relation}][filter][${key}]`, value, isRelatedListFilter?.(relation, key) ?? false);
198
+ if (entry?.sort !== void 0) append(parts, `relatedQuery[${relation}][sort]`, typeof entry.sort === "string" ? entry.sort : entry.sort.join(","));
199
199
  }
200
200
  if (query.page) for (const [key, value] of Object.entries(query.page)) append(parts, `page[${key}]`, Array.isArray(value) ? value.join(",") : value);
201
201
  return parts.join("&");
@@ -1198,6 +1198,15 @@ function parseResults(doc, ctx) {
1198
1198
  });
1199
1199
  }
1200
1200
  //#endregion
1201
+ //#region src/descriptor.ts
1202
+ /**
1203
+ * Whether a relation is polymorphic: flagged {@link RelationDescriptor.polymorphic}, or, when the
1204
+ * flag is absent, listing more than one related type.
1205
+ */
1206
+ function isPolymorphic(relation) {
1207
+ return relation.polymorphic ?? relation.types.length > 1;
1208
+ }
1209
+ //#endregion
1201
1210
  //#region src/filters.ts
1202
1211
  /**
1203
1212
  * Whether a `filter[...]` key takes a list, by the rule the server matches keys with: an exact
@@ -1332,9 +1341,9 @@ async function run(ctx, type, operation, vars, query, linkage = false, relationF
1332
1341
  req.query = params;
1333
1342
  const listFilter = listFilterMatcher(filterSpec(ctx, type, operation, vars["rel"]));
1334
1343
  if (listFilter !== void 0) req.listFilter = listFilter;
1335
- if (params.relatedQuery !== void 0) req.relatedListFilter = relatedListFilter(ctx, type);
1336
1344
  if (signal !== void 0) req.signal = signal;
1337
1345
  negotiateProfiles(ctx, type, params, req, relationForCount, operation);
1346
+ applyRelatedQuery(ctx, renderedType(ctx, type, operation, vars["rel"]), params, req);
1338
1347
  }
1339
1348
  const doc = await execute(ctx.request, req);
1340
1349
  const relation = (operation === "fetchRelated" || operation === "fetchRelationship") && vars["rel"] !== void 0 ? ctx.descriptor[type]?.relations[vars["rel"]] : void 0;
@@ -1356,40 +1365,41 @@ function filterSpec(ctx, type, operation, rel) {
1356
1365
  return types?.length === 1 ? ctx.descriptor[types[0]] : void 0;
1357
1366
  }
1358
1367
  /**
1359
- * Whether a `relatedQuery` entry's filter key takes a list, matched against the vocabulary of the
1360
- * relation its include path ends on, as that relation's related read matches it. A path through a
1361
- * polymorphic relation continues from the first member type declaring the next relation.
1368
+ * The type whose resources an operation answers with, which keys its `relatedQuery`: the type
1369
+ * itself, or a related read's related type when the relation is monomorphic. A relationship read
1370
+ * answers with linkage, so it has none.
1362
1371
  */
1363
- function relatedListFilter(ctx, type) {
1364
- const matchers = /* @__PURE__ */ new Map();
1365
- return (path, key) => {
1366
- if (!matchers.has(path)) matchers.set(path, listFilterMatcher(relatedQuerySpec(ctx, type, path)));
1367
- return matchers.get(path)?.(key) ?? false;
1368
- };
1369
- }
1370
- /** The filter vocabulary of the relation an include path from `type` ends on. */
1371
- function relatedQuerySpec(ctx, type, path) {
1372
- const names = path.split(".");
1373
- let owners = [type];
1374
- for (const [index, name] of names.entries()) {
1375
- const owner = owners.find((t) => ctx.descriptor[t]?.relations[name] !== void 0);
1376
- if (owner === void 0) return;
1377
- if (index === names.length - 1) return filterSpec(ctx, owner, "fetchRelated", name);
1378
- owners = ctx.descriptor[owner].relations[name].types;
1379
- }
1372
+ function renderedType(ctx, type, operation, rel) {
1373
+ if (operation === "fetchRelationship") return;
1374
+ if (operation !== "fetchRelated") return type;
1375
+ const relation = rel === void 0 ? void 0 : ctx.descriptor[type]?.relations[rel];
1376
+ return relation === void 0 || isPolymorphic(relation) ? void 0 : relation.types[0];
1380
1377
  }
1381
- /** Whether a `relatedQuery` carries a filter or sort for any path, so it reaches the wire. */
1378
+ /** Whether a `relatedQuery` carries a filter or sort for any relation, so it reaches the wire. */
1382
1379
  function sendsRelatedQuery(relatedQuery) {
1383
1380
  return Object.values(relatedQuery ?? {}).some((entry) => Object.keys(entry?.filter ?? {}).length > 0 || entry?.sort !== void 0 && entry.sort.length > 0);
1384
1381
  }
1385
1382
  /**
1386
- * Add any profiles a query's parameters require to the request's negotiated `profiles`. A
1387
- * `withCount` read or write needs the Countable profile in `Accept`, else the server rejects it
1388
- * (400) under strict query-param validation. The profile URI is read from the descriptor (never
1383
+ * Prepare a request's `relatedQuery` for resources of type `rendered`: match each entry's list
1384
+ * filters against its relation's related-read vocabulary, and negotiate the type's Relationship
1385
+ * Queries profile, after any Countable one, when the query sends an entry.
1386
+ */
1387
+ function applyRelatedQuery(ctx, rendered, query, req) {
1388
+ if (rendered === void 0 || !sendsRelatedQuery(query.relatedQuery)) return;
1389
+ const matchers = /* @__PURE__ */ new Map();
1390
+ req.relatedListFilter = (rel, key) => {
1391
+ if (!matchers.has(rel)) matchers.set(rel, listFilterMatcher(filterSpec(ctx, rendered, "fetchRelated", rel)));
1392
+ return matchers.get(rel)?.(key) ?? false;
1393
+ };
1394
+ const profile = ctx.descriptor[rendered]?.relatedQuery?.profile;
1395
+ if (profile !== void 0 && !(req.profiles ?? []).includes(profile)) req.profiles = [...req.profiles ?? [], profile];
1396
+ }
1397
+ /**
1398
+ * Add the Countable profile a query's `withCount` requires to the request's negotiated
1399
+ * `profiles`. A `withCount` read or write needs it in `Accept`, else the server rejects it (400)
1400
+ * under strict query-param validation. The profile URI is read from the descriptor (never
1389
1401
  * hardcoded): the relation's `countable` for a related or relationship read, the operation's
1390
1402
  * `resourceCountable` entry for a single-resource read or a write, else the type's `countable`.
1391
- * A `relatedQuery` on a collection or single read likewise adds the type's Relationship Queries
1392
- * profile, after any Countable one.
1393
1403
  */
1394
1404
  function negotiateProfiles(ctx, type, query, req, relationForCount, operation) {
1395
1405
  const profiles = [];
@@ -1398,10 +1408,6 @@ function negotiateProfiles(ctx, type, query, req, relationForCount, operation) {
1398
1408
  const profile = relationForCount !== void 0 ? descriptor?.relations[relationForCount]?.countable?.profile : (isResourceCountOperation(operation) ? descriptor?.resourceCountable?.[operation]?.profile : void 0) ?? descriptor?.countable?.profile;
1399
1409
  if (profile !== void 0) profiles.push(profile);
1400
1410
  }
1401
- if (relationForCount === void 0 && sendsRelatedQuery(query.relatedQuery)) {
1402
- const profile = ctx.descriptor[type]?.relatedQuery?.profile;
1403
- if (profile !== void 0 && !profiles.includes(profile)) profiles.push(profile);
1404
- }
1405
1411
  if (profiles.length > 0) req.profiles = [...req.profiles ?? [], ...profiles];
1406
1412
  }
1407
1413
  /** Whether an operation is one answering with one resource that may take `withCount`. */
@@ -1409,14 +1415,15 @@ function isResourceCountOperation(operation) {
1409
1415
  return operation === "fetchOne" || operation === "create" || operation === "update";
1410
1416
  }
1411
1417
  /**
1412
- * Project a write's opts to the read-query families the response honours: `include`, `fields`
1413
- * and `withCount`.
1418
+ * Project a write's opts to the read-query families the response honours: `include`, `fields`,
1419
+ * `withCount` and `relatedQuery`.
1414
1420
  */
1415
1421
  function writeQuery(opts) {
1416
1422
  if (opts === void 0) return;
1417
1423
  const query = {};
1418
1424
  if (opts.include !== void 0) query.include = [...opts.include];
1419
1425
  if (opts.withCount !== void 0) query.withCount = [...opts.withCount];
1426
+ if (opts.relatedQuery !== void 0) query.relatedQuery = opts.relatedQuery;
1420
1427
  if (opts.fields !== void 0) {
1421
1428
  const fields = {};
1422
1429
  for (const [k, v] of Object.entries(opts.fields)) fields[k] = [...v];
@@ -1459,6 +1466,7 @@ async function runWrite(ctx, spec) {
1459
1466
  if (spec.query !== void 0) {
1460
1467
  req.query = spec.query;
1461
1468
  negotiateProfiles(ctx, spec.type, spec.query, req, void 0, spec.operation);
1469
+ applyRelatedQuery(ctx, spec.type, spec.query, req);
1462
1470
  if (req.profiles !== void 0) req.contentType = JSON_API_MEDIA_TYPE;
1463
1471
  }
1464
1472
  if (spec.wait?.signal !== void 0) req.signal = spec.wait.signal;
@@ -1494,7 +1502,8 @@ async function runWrite(ctx, spec) {
1494
1502
  * `ActionLocation` and never follows it. An action declaring `rawOutput` answers in the media type
1495
1503
  * the caller picks with `options.accept`: JSON:API as above, or a `string`, a `Blob` or
1496
1504
  * `ArrayBuffer`, or parsed JSON by the media type's kind. A collection action that takes filters
1497
- * sends `options.filter` in the query string as a collection read does. A `202` the action
1505
+ * sends `options.filter` in the query string as a collection read does, and an action answering
1506
+ * with a resource sends `options.relatedQuery` as a read does. A `202` the action
1498
1507
  * declares resolves to an `Accepted` job, or with `options.wait` to the value its job URL ends at.
1499
1508
  */
1500
1509
  async function runAction(ctx, action, vars, input, options = {}) {
@@ -1508,6 +1517,13 @@ async function runAction(ctx, action, vars, input, options = {}) {
1508
1517
  const listFilter = listFilterMatcher(action);
1509
1518
  if (listFilter !== void 0) req.listFilter = listFilter;
1510
1519
  }
1520
+ if (options.relatedQuery !== void 0) {
1521
+ req.query = {
1522
+ ...req.query,
1523
+ relatedQuery: options.relatedQuery
1524
+ };
1525
+ applyRelatedQuery(ctx, action.outputType, req.query, req);
1526
+ }
1511
1527
  let remap;
1512
1528
  const media = requestMedia(action, options.contentType);
1513
1529
  if (media !== void 0 && media.kind !== "document") {
@@ -1524,6 +1540,7 @@ async function runAction(ctx, action, vars, input, options = {}) {
1524
1540
  req.contentType = sentContentType(action.contentType ?? "*/*", void 0, req.body);
1525
1541
  req.raw = true;
1526
1542
  }
1543
+ if (req.profiles !== void 0 && req.contentType === void 0) req.contentType = JSON_API_MEDIA_TYPE;
1527
1544
  const raw = responseMedia(action, options.accept);
1528
1545
  try {
1529
1546
  if (raw !== void 0) {
@@ -1829,15 +1846,6 @@ function createClient(descriptor, options) {
1829
1846
  });
1830
1847
  }
1831
1848
  //#endregion
1832
- //#region src/descriptor.ts
1833
- /**
1834
- * Whether a relation is polymorphic: flagged {@link RelationDescriptor.polymorphic}, or, when the
1835
- * flag is absent, listing more than one related type.
1836
- */
1837
- function isPolymorphic(relation) {
1838
- return relation.polymorphic ?? relation.types.length > 1;
1839
- }
1840
- //#endregion
1841
1849
  export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, CANONICAL_PAGE_KEYS, HANDLE_RESERVED, JSON_API_MEDIA_TYPE, JsonApiError, PollTimeoutError, StructuralGuardError, assertJsonApiDocument, createClient, execute, executeRaw, executeResponse, fetchTransport, findError, hasErrorCode, isAccepted, isActionLocation, isPolymorphic, listFilterMatcher, materialise, mediaType, parseRetryAfter, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
1842
1850
 
1843
1851
  //# sourceMappingURL=index.mjs.map