@haddowg/json-api-client 1.14.0 → 1.16.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 +1 -1
- package/dist/ajv.d.cts +1 -1
- package/dist/ajv.d.mts +1 -1
- package/dist/index.cjs +59 -8
- package/dist/index.d.cts +17 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +17 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +59 -9
- package/dist/index.mjs.map +1 -1
- package/dist/{validate-DGDixN5N.d.cts → validate-DCMTndv-.d.cts} +171 -36
- package/dist/validate-DCMTndv-.d.cts.map +1 -0
- package/dist/{validate-DGDixN5N.d.mts → validate-DCMTndv-.d.mts} +171 -36
- package/dist/validate-DCMTndv-.d.mts.map +1 -0
- package/package.json +1 -1
- package/dist/validate-DGDixN5N.d.cts.map +0 -1
- package/dist/validate-DGDixN5N.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -209,7 +209,7 @@ off a handle (`.id(id)`). The body shape follows the action's declared `input`
|
|
|
209
209
|
```ts
|
|
210
210
|
// Resource-scoped, document in / document out.
|
|
211
211
|
const reissued = await client.albums.id('1').actions.reissue({
|
|
212
|
-
|
|
212
|
+
releasedAt: '2001-10-01T00:00:00+00:00',
|
|
213
213
|
})
|
|
214
214
|
|
|
215
215
|
// Collection-scoped, no input.
|
package/dist/ajv.d.cts
CHANGED
package/dist/ajv.d.mts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -582,26 +582,32 @@ const isPlainObject$1 = (value) => typeof value === "object" && value !== null &
|
|
|
582
582
|
/**
|
|
583
583
|
* Append a filter value under its (already-bracketed) key. A plain object is a STRUCTURED filter
|
|
584
584
|
* value — a `Range`/`DateRange` deepObject (`{ min, max }`) — and recurses into nested bracketed
|
|
585
|
-
* keys (`filter[k][min]=`), matching the server's deepObject wire shape; an array
|
|
586
|
-
*
|
|
585
|
+
* keys (`filter[k][min]=`), matching the server's deepObject wire shape; an array goes out once per
|
|
586
|
+
* member as `filter[k][]=` for a filter that takes a list, so a member may hold a comma, and joins
|
|
587
|
+
* with `,` otherwise; a scalar is appended directly. Without the object branch a `{ min, max }` value would reach the
|
|
587
588
|
* wire as `filter[k]=[object Object]` and be silently ignored by the server.
|
|
588
589
|
*/
|
|
589
|
-
const appendFilterValue = (parts, key, value) => {
|
|
590
|
+
const appendFilterValue = (parts, key, value, list = false) => {
|
|
590
591
|
if (isPlainObject$1(value)) {
|
|
591
592
|
for (const [subKey, subValue] of Object.entries(value)) appendFilterValue(parts, `${key}[${subKey}]`, subValue);
|
|
592
593
|
return;
|
|
593
594
|
}
|
|
595
|
+
if (list && Array.isArray(value)) {
|
|
596
|
+
for (const member of value) append(parts, `${key}[]`, member);
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
594
599
|
append(parts, key, Array.isArray(value) ? value.join(",") : value);
|
|
595
600
|
};
|
|
596
601
|
/**
|
|
597
602
|
* Serialise a read query to a query string (no leading `?`). Bracketed keys
|
|
598
603
|
* (`filter[title]`, `page[number]`, `fields[albums]`) are kept literal; only values
|
|
599
|
-
* are percent-encoded.
|
|
604
|
+
* are percent-encoded. `isListFilter` names the filter keys that take a list, whose array value
|
|
605
|
+
* goes out as `filter[<key>][]` once per member. Empty/undefined entries are skipped; key order is deterministic
|
|
600
606
|
* (family order, then insertion order within a family) so URLs are stable for caching.
|
|
601
607
|
*/
|
|
602
|
-
function serializeQuery(query) {
|
|
608
|
+
function serializeQuery(query, isListFilter) {
|
|
603
609
|
const parts = [];
|
|
604
|
-
if (query.filter) for (const [key, value] of Object.entries(query.filter)) appendFilterValue(parts, `filter[${key}]`, value);
|
|
610
|
+
if (query.filter) for (const [key, value] of Object.entries(query.filter)) appendFilterValue(parts, `filter[${key}]`, value, isListFilter?.(key) ?? false);
|
|
605
611
|
if (query.sort !== void 0) append(parts, "sort", Array.isArray(query.sort) ? query.sort.join(",") : query.sort);
|
|
606
612
|
if (query.include) append(parts, "include", query.include.join(","));
|
|
607
613
|
if (query.fields) for (const [type, names] of Object.entries(query.fields)) parts.push(`fields[${type}]=${encodeURIComponent(names.join(","))}`);
|
|
@@ -642,7 +648,7 @@ async function send(ctx, req, responseType) {
|
|
|
642
648
|
sendHeaders = link.sameOrigin;
|
|
643
649
|
} else url = isAbsolute(req.path) ? req.path : ctx.baseUrl + req.path;
|
|
644
650
|
if (req.query) {
|
|
645
|
-
const qs = serializeQuery(req.query);
|
|
651
|
+
const qs = serializeQuery(req.query, req.listFilter);
|
|
646
652
|
if (qs) url += (url.includes("?") ? "&" : "?") + qs;
|
|
647
653
|
}
|
|
648
654
|
const negotiated = mediaType({
|
|
@@ -1053,6 +1059,32 @@ function parseResults(doc, ctx) {
|
|
|
1053
1059
|
});
|
|
1054
1060
|
}
|
|
1055
1061
|
//#endregion
|
|
1062
|
+
//#region src/filters.ts
|
|
1063
|
+
/**
|
|
1064
|
+
* Whether a `filter[...]` key takes a list, by the rule the server matches keys with: an exact
|
|
1065
|
+
* key first, then the filter family with the longest prefix whose suffix pattern accepts the rest
|
|
1066
|
+
* of the key. A family never matches its bare prefix. `undefined` when nothing in `spec` takes a
|
|
1067
|
+
* list, so every filter value is sent as before.
|
|
1068
|
+
*/
|
|
1069
|
+
function listFilterMatcher(spec) {
|
|
1070
|
+
const lists = new Set(spec?.listFilters ?? []);
|
|
1071
|
+
const families = (spec?.filterFamilies ?? []).filter((family) => family.list === true);
|
|
1072
|
+
if (lists.size === 0 && families.length === 0) return;
|
|
1073
|
+
const exact = new Set(spec?.filterable ?? []);
|
|
1074
|
+
const byLength = [...spec?.filterFamilies ?? []].sort((a, b) => b.prefix.length - a.prefix.length);
|
|
1075
|
+
return (key) => {
|
|
1076
|
+
if (lists.has(key)) return true;
|
|
1077
|
+
if (exact.has(key)) return false;
|
|
1078
|
+
for (const family of byLength) {
|
|
1079
|
+
const prefix = `${family.prefix}.`;
|
|
1080
|
+
if (!key.startsWith(prefix)) continue;
|
|
1081
|
+
const suffix = key.slice(prefix.length);
|
|
1082
|
+
if (suffix !== "" && new RegExp(`^(?:${family.suffixPattern})$`, "u").test(suffix)) return family.list === true;
|
|
1083
|
+
}
|
|
1084
|
+
return false;
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
//#endregion
|
|
1056
1088
|
//#region src/location.ts
|
|
1057
1089
|
/**
|
|
1058
1090
|
* Whether a value is an {@link ActionLocation}, for an action that answers with either a resource
|
|
@@ -1159,6 +1191,8 @@ async function run(ctx, type, operation, vars, query, linkage = false, relationF
|
|
|
1159
1191
|
if (query !== void 0) {
|
|
1160
1192
|
const { signal, ...params } = query;
|
|
1161
1193
|
req.query = params;
|
|
1194
|
+
const listFilter = listFilterMatcher(filterSpec(ctx, type, operation, vars["rel"]));
|
|
1195
|
+
if (listFilter !== void 0) req.listFilter = listFilter;
|
|
1162
1196
|
if (signal !== void 0) req.signal = signal;
|
|
1163
1197
|
negotiateProfiles(ctx, type, params, req, relationForCount);
|
|
1164
1198
|
}
|
|
@@ -1170,6 +1204,18 @@ async function run(ctx, type, operation, vars, query, linkage = false, relationF
|
|
|
1170
1204
|
return doc === void 0 ? void 0 : materialise(doc, ctx.materialise, linkage, primaryType, paginatorOverride);
|
|
1171
1205
|
}
|
|
1172
1206
|
/**
|
|
1207
|
+
* The filter vocabulary a read's `filter` is matched against: the type's for its collection read.
|
|
1208
|
+
* A related or relationship read takes the relation's own when its descriptor declares one, else
|
|
1209
|
+
* the related type's when the relation has one related type.
|
|
1210
|
+
*/
|
|
1211
|
+
function filterSpec(ctx, type, operation, rel) {
|
|
1212
|
+
if (operation === "fetchMany") return ctx.descriptor[type];
|
|
1213
|
+
const relation = rel === void 0 ? void 0 : ctx.descriptor[type]?.relations[rel];
|
|
1214
|
+
if (relation?.filterable !== void 0 || relation?.filterFamilies !== void 0) return relation;
|
|
1215
|
+
const types = relation?.types;
|
|
1216
|
+
return types?.length === 1 ? ctx.descriptor[types[0]] : void 0;
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1173
1219
|
* Add any profiles a query's parameters require to the request's negotiated `profiles`. A
|
|
1174
1220
|
* `withCount` read needs the type's Countable profile in `Accept` — else the server rejects it
|
|
1175
1221
|
* (400) under strict query-param validation. The profile URI is read from the descriptor's
|
|
@@ -1246,7 +1292,11 @@ async function runAction(ctx, action, vars, input, options = {}) {
|
|
|
1246
1292
|
path: fill(action.path, vars)
|
|
1247
1293
|
};
|
|
1248
1294
|
if (options.signal !== void 0) req.signal = options.signal;
|
|
1249
|
-
if (options.filter !== void 0)
|
|
1295
|
+
if (options.filter !== void 0) {
|
|
1296
|
+
req.query = { filter: options.filter };
|
|
1297
|
+
const listFilter = listFilterMatcher(action);
|
|
1298
|
+
if (listFilter !== void 0) req.listFilter = listFilter;
|
|
1299
|
+
}
|
|
1250
1300
|
let remap;
|
|
1251
1301
|
const media = requestMedia(action, options.contentType);
|
|
1252
1302
|
if (media !== void 0 && media.kind !== "document") {
|
|
@@ -1576,6 +1626,7 @@ exports.findError = findError;
|
|
|
1576
1626
|
exports.hasErrorCode = hasErrorCode;
|
|
1577
1627
|
exports.isActionLocation = isActionLocation;
|
|
1578
1628
|
exports.isPolymorphic = isPolymorphic;
|
|
1629
|
+
exports.listFilterMatcher = listFilterMatcher;
|
|
1579
1630
|
exports.materialise = materialise;
|
|
1580
1631
|
exports.mediaType = mediaType;
|
|
1581
1632
|
exports.readActionLocation = readActionLocation;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as MemberName, $t as
|
|
1
|
+
import { $ as MemberName, $t as NavigateOptions, A as BinaryBody, An as InputMedia, At as AtomicDeleteHandle, B as ErrorCodeOf, Bn as RawMediaKind, Bt as ATOMIC_MEDIA_TYPE, C as TransportRawBody, Cn as ApiDescriptor, Ct as WithLinks, D as ActionCallOptions, Dn as ClientIdPolicy, Dt as readActionLocation, E as fetchTransport, En as Cardinality, Et as isActionLocation, F as CreateInput, Fn as PaginatorDescriptor, Ft as AtomicResults, G as HydratedMember, Gn as ResourceExamples, Gt as mediaType, H as FieldsMap, Hn as RelationDescriptor, Ht as LocalIdentifier, I as DefaultActionTypes, In as PaginatorKind, It as AtomicUpdateHandle, J as IncludedRelations, Jn as isPolymorphic, Jt as Edge, K as IdentifierMember, Kn as SortFamilyDescriptor, Kt as ArrayEnvelope, L as DefaultAttributes, Ln as PaginatorRole, Lt as AtomicUpdateInput, M as Client, Mn as MediaExamples, Mt as AtomicRecorder, N as Collection, Nn as MenuDescriptor, Nt as AtomicRef, O as ActionsAccessor, On as CountableDescriptor, Ot as AtomicCreateHandle, P as CountToken, Pn as OperationExamples, Pt as AtomicResult, Q as ListPageParams, Qt as MaterialiseContext, R as DefaultWriteAttributes, Rn as PaginatorStrategy, Rt as runAtomic, S as JsonApiTransport, Sn as ActionScope, St as UpdateInput, T as TransportResponse, Tn as AtomicDescriptor, Tt as ActionLocation, U as FilterKey, Un as RelationMutations, Ut as MediaTypeParams, V as FieldSelectionMap, Vn as RawOutputMedia, Vt as JSON_API_MEDIA_TYPE, W as FilterQuery, Wn as ResourceDescriptor, Wt as ResourceIdentifier, X as IncludedType, Xt as Link, Y as IncludedResource, Yt as EdgeEnvelope, Z as LinkageRef, Zt as LinkObject, _ as serializeQuery, _n as resolvePaginator, _t as SortToken, a as Validator, an as relatedPaginatorKind, at as RelationFilterQuery, b as HeadersInit, bn as ActionLocationDescriptor, bt as TypedReadQuery, c as resolveValidator, cn as Page, ct as RelationPaginator, d as JsonApiContext, dn as PageMeta, dt as RelationshipAccessor, en as RelationView, et as PivotInput, f as JsonApiRequest, fn as PageOf, ft as ResourceAccessors, g as executeRaw, gn as TypedPage, gt as SortQuery, h as execute, hn as ResolvedPaginator, ht as SingleReadQuery, i as ValidationOption, in as relatedPaginator, it as RelatedIncludedType, j as BinaryResponseType, jn as InputMediaKind, jt as AtomicHandle, k as AtomicResultOf, kn as FilterFamilyDescriptor, kt as AtomicCreateInput, l as validateDocument, ln as PageKeys, lt as RelationReadQuery, m as ReadQuery, mn as PageParamsOf, mt as ResourceObjectView, n as SchemaMap, nn as ResourceLinks, nt as ReadableRelationName, o as WireResource, on as CANONICAL_PAGE_KEYS, ot as RelationName, p as RawResponseType, pn as PageParams, pt as ResourceHandle, q as IncludePath, qn as StrategyDescriptor, qt as DocumentEnvelope, r as ValidationConfig, rn as materialise, rt as RelatedIncludedResource, s as assertJsonApiDocument, sn as ExactPageParams, st as RelationPageParams, t as ResolvedValidator, tn as ResourceEnvelope, tt as ReadResult, u as Document, un as PageLinks, ut as RelationSortQuery, v as ClientOptions, vn as ActionDescriptor, vt as TypeAccessor, w as TransportRequest, wn as ApiExamples, wt as WriteOptions, x as createClient, xn as ActionOutput, xt as TypedRelationReadQuery, y as HANDLE_RESERVED, yn as ActionInput, yt as TypeName, z as EdgeMembers, zn as PivotDescriptor, zt as ATOMIC_EXT } from "./validate-DCMTndv-.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
4
|
/**
|
|
@@ -111,6 +111,21 @@ declare function findError(err: unknown, code: string): JsonApiErrorObject | und
|
|
|
111
111
|
*/
|
|
112
112
|
type ErrorFinder<C extends string, M = {}> = <K extends C>(err: unknown, code: K) => CodedErrorObject<K, M> | undefined;
|
|
113
113
|
//#endregion
|
|
114
|
+
//#region src/filters.d.ts
|
|
115
|
+
/** The filter vocabulary {@link listFilterMatcher} reads: a type's, or a collection action's. */
|
|
116
|
+
interface FilterSpec {
|
|
117
|
+
filterable?: readonly string[];
|
|
118
|
+
listFilters?: readonly string[];
|
|
119
|
+
filterFamilies?: readonly FilterFamilyDescriptor[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Whether a `filter[...]` key takes a list, by the rule the server matches keys with: an exact
|
|
123
|
+
* key first, then the filter family with the longest prefix whose suffix pattern accepts the rest
|
|
124
|
+
* of the key. A family never matches its bare prefix. `undefined` when nothing in `spec` takes a
|
|
125
|
+
* list, so every filter value is sent as before.
|
|
126
|
+
*/
|
|
127
|
+
declare function listFilterMatcher(spec: FilterSpec | undefined): ((key: string) => boolean) | undefined;
|
|
128
|
+
//#endregion
|
|
114
129
|
//#region src/serialize-write.d.ts
|
|
115
130
|
/**
|
|
116
131
|
* A JSON:API resource identifier in a write document: `{ type, id }` or — inside an atomic
|
|
@@ -238,5 +253,5 @@ declare function withRemappedRelationshipPaths(error: JsonApiError, rel: string,
|
|
|
238
253
|
*/
|
|
239
254
|
declare function withRemappedAtomicPaths(error: JsonApiError, descriptor: ApiDescriptor, typeForOp: (opIndex: number) => string | undefined): JsonApiError;
|
|
240
255
|
//#endregion
|
|
241
|
-
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, CodedErrorObject, Collection, CountToken, CountableDescriptor, CreateInput, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, ErrorCodeGuard, ErrorCodeOf, ErrorFinder, 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, SortFamilyDescriptor, 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, findError, hasErrorCode, isActionLocation, isPolymorphic, materialise, mediaType, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
|
|
256
|
+
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, CodedErrorObject, Collection, CountToken, CountableDescriptor, CreateInput, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, ErrorCodeGuard, ErrorCodeOf, ErrorFinder, ExactPageParams, 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, 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, RelationFilterQuery, RelationMutations, RelationName, RelationPageParams, RelationPaginator, RelationReadQuery, RelationSortQuery, RelationView, RelationshipAccessor, RelationshipDocument, ResolvedPaginator, ResolvedValidator, ResourceAccessors, ResourceDescriptor, ResourceEnvelope, ResourceExamples, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceObjectView, SchemaMap, SingleReadQuery, SortFamilyDescriptor, SortQuery, SortToken, StrategyDescriptor, StructuralGuardError, ToDocumentOptions, TransportRawBody, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedPage, TypedReadQuery, TypedRelationReadQuery, UpdateInput, ValidationConfig, ValidationOption, Validator, WireResource, WithLinks, WriteDocument, WriteOptions, assertJsonApiDocument, createClient, execute, executeRaw, fetchTransport, findError, hasErrorCode, isActionLocation, isPolymorphic, listFilterMatcher, materialise, mediaType, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
|
|
242
257
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/errors.ts","../src/serialize-write.ts"],"mappings":";;;;;;AAOA;;;;UAAiB,kBAAA;EACf,EAAA;EACA,MAAA;EACA,IAAA,GAAO,CAAA;EACP,KAAA;EACA,MAAA;EACA,MAAA;IAAW,OAAA;IAAkB,SAAA;IAAoB,MAAA;EAAA;EACjD,IAAA,GAAO,MAAM;EAAN;;;;AAYA;EANP,IAAA;EAgBgC;;;;;EAVhC,OAAA;AAAA;AAW2B;AAa7B;;;;;;AAb6B,cADhB,oBAAA,SAA6B,KAAK;cACjC,OAAA;AAAA;;;;;;;;cAaD,YAAA,oCAAgD,KAAA;EAAA,SAClD,MAAA;EAAA,SACA,MAAA,EAAQ,kBAAA,CAAmB,CAAA;cAExB,MAAA,UAAgB,MAAA,EAAQ,kBAAA,CAAmB,CAAA,KAAM,OAAA;EAO7D,SAAA,CAAU,MAAA;EAIV,KAAA;EAIA,KAAA;EAIA,YAAA;EAIA,cAAA;EAIA,WAAA;EAIA,UAAA;EAIA,eAAA;EAIA,UAAA;EAIA,sBAAA;EAIA,eAAA;EApBA;EAyBA,iBAAA;EAIA,aAAA;EAjBA;;;;;EA0BA,MAAA,IAAU,MAAA,SAAe,kBAAA,CAAmB,CAAA;AAAA;;;;AAAC;AAgB/C;;iBAAgB,YAAA,CAAa,GAAA,WAAc,IAAA,WAAe,GAAA,IAAO,YAAY;;;;;;KASjE,cAAA,sBAAoC,GAAA,WAAc,IAAA,EAAM,CAAA,KAAM,GAAA,IAAO,YAAA,CAAa,CAAA;AATjB;AAS7E;;;;AAT6E,KAgBjE,gBAAA,6BAA6C,kBAAA,CAAmB,CAAA;EAC1E,IAAA,EAAM,CAAA;AAAA,KACH,CAAA,eAAgB,CAAA;EA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AA,EAAY,aAAA,EACZ,IAAA,WACC,YAAA;;;;;;;;iBAWa,6BAAA,CACd,KAAA,EAAO,YAAA,EACP,GAAA,UACA,QAAA,YACC,YAAY;;AFzLqB;AAOpC;;;;;;;iBE+LgB,uBAAA,CACd,KAAA,EAAO,YAAA,EACP,UAAA,EAAY,aAAA,EACZ,SAAA,GAAY,OAAA,kCACX,YAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as MemberName, $t as
|
|
1
|
+
import { $ as MemberName, $t as NavigateOptions, A as BinaryBody, An as InputMedia, At as AtomicDeleteHandle, B as ErrorCodeOf, Bn as RawMediaKind, Bt as ATOMIC_MEDIA_TYPE, C as TransportRawBody, Cn as ApiDescriptor, Ct as WithLinks, D as ActionCallOptions, Dn as ClientIdPolicy, Dt as readActionLocation, E as fetchTransport, En as Cardinality, Et as isActionLocation, F as CreateInput, Fn as PaginatorDescriptor, Ft as AtomicResults, G as HydratedMember, Gn as ResourceExamples, Gt as mediaType, H as FieldsMap, Hn as RelationDescriptor, Ht as LocalIdentifier, I as DefaultActionTypes, In as PaginatorKind, It as AtomicUpdateHandle, J as IncludedRelations, Jn as isPolymorphic, Jt as Edge, K as IdentifierMember, Kn as SortFamilyDescriptor, Kt as ArrayEnvelope, L as DefaultAttributes, Ln as PaginatorRole, Lt as AtomicUpdateInput, M as Client, Mn as MediaExamples, Mt as AtomicRecorder, N as Collection, Nn as MenuDescriptor, Nt as AtomicRef, O as ActionsAccessor, On as CountableDescriptor, Ot as AtomicCreateHandle, P as CountToken, Pn as OperationExamples, Pt as AtomicResult, Q as ListPageParams, Qt as MaterialiseContext, R as DefaultWriteAttributes, Rn as PaginatorStrategy, Rt as runAtomic, S as JsonApiTransport, Sn as ActionScope, St as UpdateInput, T as TransportResponse, Tn as AtomicDescriptor, Tt as ActionLocation, U as FilterKey, Un as RelationMutations, Ut as MediaTypeParams, V as FieldSelectionMap, Vn as RawOutputMedia, Vt as JSON_API_MEDIA_TYPE, W as FilterQuery, Wn as ResourceDescriptor, Wt as ResourceIdentifier, X as IncludedType, Xt as Link, Y as IncludedResource, Yt as EdgeEnvelope, Z as LinkageRef, Zt as LinkObject, _ as serializeQuery, _n as resolvePaginator, _t as SortToken, a as Validator, an as relatedPaginatorKind, at as RelationFilterQuery, b as HeadersInit, bn as ActionLocationDescriptor, bt as TypedReadQuery, c as resolveValidator, cn as Page, ct as RelationPaginator, d as JsonApiContext, dn as PageMeta, dt as RelationshipAccessor, en as RelationView, et as PivotInput, f as JsonApiRequest, fn as PageOf, ft as ResourceAccessors, g as executeRaw, gn as TypedPage, gt as SortQuery, h as execute, hn as ResolvedPaginator, ht as SingleReadQuery, i as ValidationOption, in as relatedPaginator, it as RelatedIncludedType, j as BinaryResponseType, jn as InputMediaKind, jt as AtomicHandle, k as AtomicResultOf, kn as FilterFamilyDescriptor, kt as AtomicCreateInput, l as validateDocument, ln as PageKeys, lt as RelationReadQuery, m as ReadQuery, mn as PageParamsOf, mt as ResourceObjectView, n as SchemaMap, nn as ResourceLinks, nt as ReadableRelationName, o as WireResource, on as CANONICAL_PAGE_KEYS, ot as RelationName, p as RawResponseType, pn as PageParams, pt as ResourceHandle, q as IncludePath, qn as StrategyDescriptor, qt as DocumentEnvelope, r as ValidationConfig, rn as materialise, rt as RelatedIncludedResource, s as assertJsonApiDocument, sn as ExactPageParams, st as RelationPageParams, t as ResolvedValidator, tn as ResourceEnvelope, tt as ReadResult, u as Document, un as PageLinks, ut as RelationSortQuery, v as ClientOptions, vn as ActionDescriptor, vt as TypeAccessor, w as TransportRequest, wn as ApiExamples, wt as WriteOptions, x as createClient, xn as ActionOutput, xt as TypedRelationReadQuery, y as HANDLE_RESERVED, yn as ActionInput, yt as TypeName, z as EdgeMembers, zn as PivotDescriptor, zt as ATOMIC_EXT } from "./validate-DCMTndv-.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
4
|
/**
|
|
@@ -111,6 +111,21 @@ declare function findError(err: unknown, code: string): JsonApiErrorObject | und
|
|
|
111
111
|
*/
|
|
112
112
|
type ErrorFinder<C extends string, M = {}> = <K extends C>(err: unknown, code: K) => CodedErrorObject<K, M> | undefined;
|
|
113
113
|
//#endregion
|
|
114
|
+
//#region src/filters.d.ts
|
|
115
|
+
/** The filter vocabulary {@link listFilterMatcher} reads: a type's, or a collection action's. */
|
|
116
|
+
interface FilterSpec {
|
|
117
|
+
filterable?: readonly string[];
|
|
118
|
+
listFilters?: readonly string[];
|
|
119
|
+
filterFamilies?: readonly FilterFamilyDescriptor[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Whether a `filter[...]` key takes a list, by the rule the server matches keys with: an exact
|
|
123
|
+
* key first, then the filter family with the longest prefix whose suffix pattern accepts the rest
|
|
124
|
+
* of the key. A family never matches its bare prefix. `undefined` when nothing in `spec` takes a
|
|
125
|
+
* list, so every filter value is sent as before.
|
|
126
|
+
*/
|
|
127
|
+
declare function listFilterMatcher(spec: FilterSpec | undefined): ((key: string) => boolean) | undefined;
|
|
128
|
+
//#endregion
|
|
114
129
|
//#region src/serialize-write.d.ts
|
|
115
130
|
/**
|
|
116
131
|
* A JSON:API resource identifier in a write document: `{ type, id }` or — inside an atomic
|
|
@@ -238,5 +253,5 @@ declare function withRemappedRelationshipPaths(error: JsonApiError, rel: string,
|
|
|
238
253
|
*/
|
|
239
254
|
declare function withRemappedAtomicPaths(error: JsonApiError, descriptor: ApiDescriptor, typeForOp: (opIndex: number) => string | undefined): JsonApiError;
|
|
240
255
|
//#endregion
|
|
241
|
-
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, CodedErrorObject, Collection, CountToken, CountableDescriptor, CreateInput, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, ErrorCodeGuard, ErrorCodeOf, ErrorFinder, 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, SortFamilyDescriptor, 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, findError, hasErrorCode, isActionLocation, isPolymorphic, materialise, mediaType, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
|
|
256
|
+
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, CodedErrorObject, Collection, CountToken, CountableDescriptor, CreateInput, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, Document, DocumentEnvelope, Edge, EdgeEnvelope, EdgeMembers, ErrorCodeGuard, ErrorCodeOf, ErrorFinder, ExactPageParams, 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, 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, RelationFilterQuery, RelationMutations, RelationName, RelationPageParams, RelationPaginator, RelationReadQuery, RelationSortQuery, RelationView, RelationshipAccessor, RelationshipDocument, ResolvedPaginator, ResolvedValidator, ResourceAccessors, ResourceDescriptor, ResourceEnvelope, ResourceExamples, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceObjectView, SchemaMap, SingleReadQuery, SortFamilyDescriptor, SortQuery, SortToken, StrategyDescriptor, StructuralGuardError, ToDocumentOptions, TransportRawBody, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedPage, TypedReadQuery, TypedRelationReadQuery, UpdateInput, ValidationConfig, ValidationOption, Validator, WireResource, WithLinks, WriteDocument, WriteOptions, assertJsonApiDocument, createClient, execute, executeRaw, fetchTransport, findError, hasErrorCode, isActionLocation, isPolymorphic, listFilterMatcher, materialise, mediaType, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
|
|
242
257
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/errors.ts","../src/serialize-write.ts"],"mappings":";;;;;;AAOA;;;;UAAiB,kBAAA;EACf,EAAA;EACA,MAAA;EACA,IAAA,GAAO,CAAA;EACP,KAAA;EACA,MAAA;EACA,MAAA;IAAW,OAAA;IAAkB,SAAA;IAAoB,MAAA;EAAA;EACjD,IAAA,GAAO,MAAM;EAAN;;;;AAYA;EANP,IAAA;EAgBgC;;;;;EAVhC,OAAA;AAAA;AAW2B;AAa7B;;;;;;AAb6B,cADhB,oBAAA,SAA6B,KAAK;cACjC,OAAA;AAAA;;;;;;;;cAaD,YAAA,oCAAgD,KAAA;EAAA,SAClD,MAAA;EAAA,SACA,MAAA,EAAQ,kBAAA,CAAmB,CAAA;cAExB,MAAA,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AAA;EACf,IAAA;IACE,IAAA;IACA,EAAA;IACA,UAAA,GAAa,MAAA;IACb,aAAA,GAAgB,MAAA,SAAe,oBAAA;EAAA;AAAA;;UAKlB,iBAAA;EFoEU;;;;;EE9DzB,EAAE;AAAA;;;;;;;;;;;;;;;iBAiBY,UAAA,CACd,UAAA,EAAY,aAAA,EACZ,IAAA,UACA,KAAA,EAAO,MAAA,mBACP,IAAA,GAAO,iBAAA,GACN,aAAA;;;;;;;;;;;;;iBAgDa,sBAAA,CACd,IAAA,WACA,WAAA,mBACC,oBAAoB;;AFXwB;AAgB/C;;;;;;;;;AAA6E;AAS7E;;;;;;iBE6EgB,YAAA,CAAa,UAAA,EAAY,aAAa,EAAE,IAAA,UAAc,OAAA;;;;;;;;;;AF7EyB;AAO/F;;;;;;;iBEsJgB,wBAAA,CAAyB,GAAA,UAAa,QAAA,WAAmB,OAAA;;;;;;;iBAkBzD,iBAAA,CACd,KAAA,EAAO,YAAA,EACP,UAAA,EAAY,aAAA,EACZ,IAAA,WACC,YAAA;;;;;;;;iBAWa,6BAAA,CACd,KAAA,EAAO,YAAA,EACP,GAAA,UACA,QAAA,YACC,YAAY;;AFzLqB;AAOpC;;;;;;;iBE+LgB,uBAAA,CACd,KAAA,EAAO,YAAA,EACP,UAAA,EAAY,aAAA,EACZ,SAAA,GAAY,OAAA,kCACX,YAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -581,26 +581,32 @@ const isPlainObject$1 = (value) => typeof value === "object" && value !== null &
|
|
|
581
581
|
/**
|
|
582
582
|
* Append a filter value under its (already-bracketed) key. A plain object is a STRUCTURED filter
|
|
583
583
|
* value — a `Range`/`DateRange` deepObject (`{ min, max }`) — and recurses into nested bracketed
|
|
584
|
-
* keys (`filter[k][min]=`), matching the server's deepObject wire shape; an array
|
|
585
|
-
*
|
|
584
|
+
* keys (`filter[k][min]=`), matching the server's deepObject wire shape; an array goes out once per
|
|
585
|
+
* member as `filter[k][]=` for a filter that takes a list, so a member may hold a comma, and joins
|
|
586
|
+
* with `,` otherwise; a scalar is appended directly. Without the object branch a `{ min, max }` value would reach the
|
|
586
587
|
* wire as `filter[k]=[object Object]` and be silently ignored by the server.
|
|
587
588
|
*/
|
|
588
|
-
const appendFilterValue = (parts, key, value) => {
|
|
589
|
+
const appendFilterValue = (parts, key, value, list = false) => {
|
|
589
590
|
if (isPlainObject$1(value)) {
|
|
590
591
|
for (const [subKey, subValue] of Object.entries(value)) appendFilterValue(parts, `${key}[${subKey}]`, subValue);
|
|
591
592
|
return;
|
|
592
593
|
}
|
|
594
|
+
if (list && Array.isArray(value)) {
|
|
595
|
+
for (const member of value) append(parts, `${key}[]`, member);
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
593
598
|
append(parts, key, Array.isArray(value) ? value.join(",") : value);
|
|
594
599
|
};
|
|
595
600
|
/**
|
|
596
601
|
* Serialise a read query to a query string (no leading `?`). Bracketed keys
|
|
597
602
|
* (`filter[title]`, `page[number]`, `fields[albums]`) are kept literal; only values
|
|
598
|
-
* are percent-encoded.
|
|
603
|
+
* are percent-encoded. `isListFilter` names the filter keys that take a list, whose array value
|
|
604
|
+
* goes out as `filter[<key>][]` once per member. Empty/undefined entries are skipped; key order is deterministic
|
|
599
605
|
* (family order, then insertion order within a family) so URLs are stable for caching.
|
|
600
606
|
*/
|
|
601
|
-
function serializeQuery(query) {
|
|
607
|
+
function serializeQuery(query, isListFilter) {
|
|
602
608
|
const parts = [];
|
|
603
|
-
if (query.filter) for (const [key, value] of Object.entries(query.filter)) appendFilterValue(parts, `filter[${key}]`, value);
|
|
609
|
+
if (query.filter) for (const [key, value] of Object.entries(query.filter)) appendFilterValue(parts, `filter[${key}]`, value, isListFilter?.(key) ?? false);
|
|
604
610
|
if (query.sort !== void 0) append(parts, "sort", Array.isArray(query.sort) ? query.sort.join(",") : query.sort);
|
|
605
611
|
if (query.include) append(parts, "include", query.include.join(","));
|
|
606
612
|
if (query.fields) for (const [type, names] of Object.entries(query.fields)) parts.push(`fields[${type}]=${encodeURIComponent(names.join(","))}`);
|
|
@@ -641,7 +647,7 @@ async function send(ctx, req, responseType) {
|
|
|
641
647
|
sendHeaders = link.sameOrigin;
|
|
642
648
|
} else url = isAbsolute(req.path) ? req.path : ctx.baseUrl + req.path;
|
|
643
649
|
if (req.query) {
|
|
644
|
-
const qs = serializeQuery(req.query);
|
|
650
|
+
const qs = serializeQuery(req.query, req.listFilter);
|
|
645
651
|
if (qs) url += (url.includes("?") ? "&" : "?") + qs;
|
|
646
652
|
}
|
|
647
653
|
const negotiated = mediaType({
|
|
@@ -1052,6 +1058,32 @@ function parseResults(doc, ctx) {
|
|
|
1052
1058
|
});
|
|
1053
1059
|
}
|
|
1054
1060
|
//#endregion
|
|
1061
|
+
//#region src/filters.ts
|
|
1062
|
+
/**
|
|
1063
|
+
* Whether a `filter[...]` key takes a list, by the rule the server matches keys with: an exact
|
|
1064
|
+
* key first, then the filter family with the longest prefix whose suffix pattern accepts the rest
|
|
1065
|
+
* of the key. A family never matches its bare prefix. `undefined` when nothing in `spec` takes a
|
|
1066
|
+
* list, so every filter value is sent as before.
|
|
1067
|
+
*/
|
|
1068
|
+
function listFilterMatcher(spec) {
|
|
1069
|
+
const lists = new Set(spec?.listFilters ?? []);
|
|
1070
|
+
const families = (spec?.filterFamilies ?? []).filter((family) => family.list === true);
|
|
1071
|
+
if (lists.size === 0 && families.length === 0) return;
|
|
1072
|
+
const exact = new Set(spec?.filterable ?? []);
|
|
1073
|
+
const byLength = [...spec?.filterFamilies ?? []].sort((a, b) => b.prefix.length - a.prefix.length);
|
|
1074
|
+
return (key) => {
|
|
1075
|
+
if (lists.has(key)) return true;
|
|
1076
|
+
if (exact.has(key)) return false;
|
|
1077
|
+
for (const family of byLength) {
|
|
1078
|
+
const prefix = `${family.prefix}.`;
|
|
1079
|
+
if (!key.startsWith(prefix)) continue;
|
|
1080
|
+
const suffix = key.slice(prefix.length);
|
|
1081
|
+
if (suffix !== "" && new RegExp(`^(?:${family.suffixPattern})$`, "u").test(suffix)) return family.list === true;
|
|
1082
|
+
}
|
|
1083
|
+
return false;
|
|
1084
|
+
};
|
|
1085
|
+
}
|
|
1086
|
+
//#endregion
|
|
1055
1087
|
//#region src/location.ts
|
|
1056
1088
|
/**
|
|
1057
1089
|
* Whether a value is an {@link ActionLocation}, for an action that answers with either a resource
|
|
@@ -1158,6 +1190,8 @@ async function run(ctx, type, operation, vars, query, linkage = false, relationF
|
|
|
1158
1190
|
if (query !== void 0) {
|
|
1159
1191
|
const { signal, ...params } = query;
|
|
1160
1192
|
req.query = params;
|
|
1193
|
+
const listFilter = listFilterMatcher(filterSpec(ctx, type, operation, vars["rel"]));
|
|
1194
|
+
if (listFilter !== void 0) req.listFilter = listFilter;
|
|
1161
1195
|
if (signal !== void 0) req.signal = signal;
|
|
1162
1196
|
negotiateProfiles(ctx, type, params, req, relationForCount);
|
|
1163
1197
|
}
|
|
@@ -1169,6 +1203,18 @@ async function run(ctx, type, operation, vars, query, linkage = false, relationF
|
|
|
1169
1203
|
return doc === void 0 ? void 0 : materialise(doc, ctx.materialise, linkage, primaryType, paginatorOverride);
|
|
1170
1204
|
}
|
|
1171
1205
|
/**
|
|
1206
|
+
* The filter vocabulary a read's `filter` is matched against: the type's for its collection read.
|
|
1207
|
+
* A related or relationship read takes the relation's own when its descriptor declares one, else
|
|
1208
|
+
* the related type's when the relation has one related type.
|
|
1209
|
+
*/
|
|
1210
|
+
function filterSpec(ctx, type, operation, rel) {
|
|
1211
|
+
if (operation === "fetchMany") return ctx.descriptor[type];
|
|
1212
|
+
const relation = rel === void 0 ? void 0 : ctx.descriptor[type]?.relations[rel];
|
|
1213
|
+
if (relation?.filterable !== void 0 || relation?.filterFamilies !== void 0) return relation;
|
|
1214
|
+
const types = relation?.types;
|
|
1215
|
+
return types?.length === 1 ? ctx.descriptor[types[0]] : void 0;
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1172
1218
|
* Add any profiles a query's parameters require to the request's negotiated `profiles`. A
|
|
1173
1219
|
* `withCount` read needs the type's Countable profile in `Accept` — else the server rejects it
|
|
1174
1220
|
* (400) under strict query-param validation. The profile URI is read from the descriptor's
|
|
@@ -1245,7 +1291,11 @@ async function runAction(ctx, action, vars, input, options = {}) {
|
|
|
1245
1291
|
path: fill(action.path, vars)
|
|
1246
1292
|
};
|
|
1247
1293
|
if (options.signal !== void 0) req.signal = options.signal;
|
|
1248
|
-
if (options.filter !== void 0)
|
|
1294
|
+
if (options.filter !== void 0) {
|
|
1295
|
+
req.query = { filter: options.filter };
|
|
1296
|
+
const listFilter = listFilterMatcher(action);
|
|
1297
|
+
if (listFilter !== void 0) req.listFilter = listFilter;
|
|
1298
|
+
}
|
|
1249
1299
|
let remap;
|
|
1250
1300
|
const media = requestMedia(action, options.contentType);
|
|
1251
1301
|
if (media !== void 0 && media.kind !== "document") {
|
|
@@ -1559,6 +1609,6 @@ function isPolymorphic(relation) {
|
|
|
1559
1609
|
return relation.polymorphic ?? relation.types.length > 1;
|
|
1560
1610
|
}
|
|
1561
1611
|
//#endregion
|
|
1562
|
-
export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, CANONICAL_PAGE_KEYS, HANDLE_RESERVED, JSON_API_MEDIA_TYPE, JsonApiError, StructuralGuardError, assertJsonApiDocument, createClient, execute, executeRaw, fetchTransport, findError, hasErrorCode, isActionLocation, isPolymorphic, materialise, mediaType, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
|
|
1612
|
+
export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, CANONICAL_PAGE_KEYS, HANDLE_RESERVED, JSON_API_MEDIA_TYPE, JsonApiError, StructuralGuardError, assertJsonApiDocument, createClient, execute, executeRaw, fetchTransport, findError, hasErrorCode, isActionLocation, isPolymorphic, listFilterMatcher, materialise, mediaType, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedPaths, withRemappedRelationshipPaths };
|
|
1563
1613
|
|
|
1564
1614
|
//# sourceMappingURL=index.mjs.map
|