@haddowg/json-api-client 1.28.0 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ajv.cjs +1 -1
- package/dist/ajv.d.cts +1 -1
- package/dist/ajv.d.mts +1 -1
- package/dist/ajv.mjs +1 -1
- package/dist/index.cjs +280 -23
- package/dist/index.d.cts +35 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +35 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +273 -24
- package/dist/index.mjs.map +1 -1
- package/dist/{validate-DMRQn0XN.cjs → validate-B2Dtn9dI.cjs} +14 -1
- package/dist/{validate-BvO7NhkT.mjs → validate-CtXB1MGk.mjs} +15 -2
- package/dist/validate-CtXB1MGk.mjs.map +1 -0
- package/dist/{validate-Dj6pkoNM.d.mts → validate-ugcQVpb0.d.cts} +261 -50
- package/dist/validate-ugcQVpb0.d.cts.map +1 -0
- package/dist/{validate-Dj6pkoNM.d.cts → validate-ugcQVpb0.d.mts} +261 -50
- package/dist/validate-ugcQVpb0.d.mts.map +1 -0
- package/package.json +1 -1
- package/dist/validate-BvO7NhkT.mjs.map +0 -1
- package/dist/validate-Dj6pkoNM.d.cts.map +0 -1
- package/dist/validate-Dj6pkoNM.d.mts.map +0 -1
package/dist/ajv.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_validate = require("./validate-
|
|
2
|
+
const require_validate = require("./validate-B2Dtn9dI.cjs");
|
|
3
3
|
//#region src/ajv.ts
|
|
4
4
|
/**
|
|
5
5
|
* Thrown by the ajv adapter when a wire resource fails its per-type schema. Aggregates every
|
package/dist/ajv.d.cts
CHANGED
package/dist/ajv.d.mts
CHANGED
package/dist/ajv.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,72 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_validate = require("./validate-
|
|
2
|
+
const require_validate = require("./validate-B2Dtn9dI.cjs");
|
|
3
|
+
//#region src/request-stamp.ts
|
|
4
|
+
/**
|
|
5
|
+
* Request stamps: when the request behind a result started, relative to every other request made in
|
|
6
|
+
* this process.
|
|
7
|
+
*
|
|
8
|
+
* The client takes a stamp as each request starts and records it on the top-level value it
|
|
9
|
+
* materialises from the response: a read's resource, collection or linkage (`$next()`/`$prev()`
|
|
10
|
+
* pages included), a write's returned resource, and an atomic batch's results. A cache can then
|
|
11
|
+
* tell which of two results carrying the same resource is the newer, whatever order their
|
|
12
|
+
* responses arrived in.
|
|
13
|
+
*
|
|
14
|
+
* The stamp is a per-process counter rather than `Date.now()`: two requests started in the same
|
|
15
|
+
* millisecond still get distinct, ordered stamps, and a clock change can't reorder them. It means
|
|
16
|
+
* nothing outside the process that issued it, so a value that crossed one (through JSON on a server
|
|
17
|
+
* render, or storage) carries none. Stamps live in a `WeakMap` keyed by the result, so the result
|
|
18
|
+
* keeps its shape and nothing is added to it.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
/** The last stamp handed out; `0` is older than any request (no request is ever stamped `0`). */
|
|
23
|
+
let clock = 0;
|
|
24
|
+
/**
|
|
25
|
+
* A new stamp, later than every stamp handed out before it. The client takes one as each request
|
|
26
|
+
* starts; anything ordering its own events against the client's requests takes them here too.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
function nextRequestStamp() {
|
|
30
|
+
clock += 1;
|
|
31
|
+
return clock;
|
|
32
|
+
}
|
|
33
|
+
const stamps = /* @__PURE__ */ new WeakMap();
|
|
34
|
+
/**
|
|
35
|
+
* Record `stamp` as the start of the request `value` was materialised from, when it is an object.
|
|
36
|
+
* Returns `value`.
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
function stampRequest(value, stamp) {
|
|
40
|
+
if (typeof value === "object" && value !== null) stamps.set(value, stamp);
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
const documentStamps = /* @__PURE__ */ new WeakMap();
|
|
44
|
+
/**
|
|
45
|
+
* Record `stamp` on the response document it was parsed from, so whatever is built from the
|
|
46
|
+
* document can be stamped without the caller carrying the number.
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
function stampDocument(doc, stamp) {
|
|
50
|
+
if (doc !== void 0) documentStamps.set(doc, stamp);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Stamp `value` with the request stamp of `doc`, when `doc` carries one. Returns `value`.
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
function stampFromDocument(doc, value) {
|
|
57
|
+
const stamp = doc === void 0 ? void 0 : documentStamps.get(doc);
|
|
58
|
+
return stamp === void 0 ? value : stampRequest(value, stamp);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The stamp of the request `value` was materialised from: a top-level result the client returned.
|
|
62
|
+
* `undefined` for anything else, such as a plain copy of a result, a nested resource, or data the
|
|
63
|
+
* client never returned.
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
function requestStampOf(value) {
|
|
67
|
+
return typeof value === "object" && value !== null ? stamps.get(value) : void 0;
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
3
70
|
//#region src/types.ts
|
|
4
71
|
/** The JSON:API media type. */
|
|
5
72
|
const JSON_API_MEDIA_TYPE = "application/vnd.api+json";
|
|
@@ -108,7 +175,10 @@ function serializeQuery(query, isListFilter, isRelatedListFilter) {
|
|
|
108
175
|
* parsed error objects (tolerating a non-JSON error body with an empty list).
|
|
109
176
|
*/
|
|
110
177
|
async function execute(ctx, req) {
|
|
111
|
-
|
|
178
|
+
const stamp = nextRequestStamp();
|
|
179
|
+
const doc = parseDocument((await send(ctx, req)).body);
|
|
180
|
+
stampDocument(doc, stamp);
|
|
181
|
+
return doc;
|
|
112
182
|
}
|
|
113
183
|
/**
|
|
114
184
|
* Execute a request as {@link execute} does, keeping the response's status and headers. With
|
|
@@ -116,11 +186,15 @@ async function execute(ctx, req) {
|
|
|
116
186
|
* so the caller can read its `Location`.
|
|
117
187
|
*/
|
|
118
188
|
async function executeResponse(ctx, req, seeOther = false) {
|
|
189
|
+
const stamp = nextRequestStamp();
|
|
119
190
|
const res = await send(ctx, req, void 0, seeOther);
|
|
191
|
+
const document = res.status === 303 ? void 0 : parseDocument(res.body);
|
|
192
|
+
stampDocument(document, stamp);
|
|
120
193
|
return {
|
|
121
194
|
status: res.status,
|
|
122
195
|
headers: res.headers,
|
|
123
|
-
document
|
|
196
|
+
document,
|
|
197
|
+
stamp
|
|
124
198
|
};
|
|
125
199
|
}
|
|
126
200
|
async function executeRaw(ctx, req, as) {
|
|
@@ -366,6 +440,40 @@ function resolvePaginator(paginator, page) {
|
|
|
366
440
|
arm
|
|
367
441
|
};
|
|
368
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* The `page` params for the page after `list`, read from its `next` link, or `undefined` on the
|
|
445
|
+
* last page (or before anything has loaded). Works the same for every strategy, because the
|
|
446
|
+
* server's link already carries the right parameters: counts come back as numbers, cursors as
|
|
447
|
+
* strings, under the wire keys the strategy uses, with the menu arm's `kind` when the link names
|
|
448
|
+
* one. Feed the result back as the `page` of the next read:
|
|
449
|
+
*
|
|
450
|
+
* ```ts
|
|
451
|
+
* const next = nextPageParams(albums)
|
|
452
|
+
* if (next) albums = await client.albums.list({ page: next })
|
|
453
|
+
* ```
|
|
454
|
+
*/
|
|
455
|
+
function nextPageParams(list) {
|
|
456
|
+
return pageParams(list?.$page, list?.$page.links.next);
|
|
457
|
+
}
|
|
458
|
+
/** The `page` params for the page before `list`, from its `prev` link. See {@link nextPageParams}. */
|
|
459
|
+
function prevPageParams(list) {
|
|
460
|
+
return pageParams(list?.$page, list?.$page.links.prev);
|
|
461
|
+
}
|
|
462
|
+
const CURSOR_ROLES = ["after", "before"];
|
|
463
|
+
function pageParams(page, link) {
|
|
464
|
+
if (page === void 0 || link === void 0) return;
|
|
465
|
+
const keys = Object.entries(page.keys);
|
|
466
|
+
const query = link.includes("?") ? link.slice(link.indexOf("?") + 1).split("#")[0] : "";
|
|
467
|
+
const params = {};
|
|
468
|
+
new URLSearchParams(query).forEach((value, name) => {
|
|
469
|
+
const member = /^page\[([^\]]+)\]$/.exec(name)?.[1];
|
|
470
|
+
if (member === void 0) return;
|
|
471
|
+
const role = keys.find(([, key]) => key === member)?.[0];
|
|
472
|
+
const count = Number(value);
|
|
473
|
+
params[member] = role !== void 0 && !CURSOR_ROLES.includes(role) && value !== "" && Number.isFinite(count) ? count : value;
|
|
474
|
+
});
|
|
475
|
+
return params;
|
|
476
|
+
}
|
|
369
477
|
//#endregion
|
|
370
478
|
//#region src/materialise.ts
|
|
371
479
|
const isObject$2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -383,6 +491,59 @@ const defineGetter = (target, key, get) => {
|
|
|
383
491
|
configurable: true
|
|
384
492
|
});
|
|
385
493
|
};
|
|
494
|
+
let overlay;
|
|
495
|
+
/**
|
|
496
|
+
* Install the cache layer's {@link MaterialisedOverlay}, or remove it with `undefined`. One layer is
|
|
497
|
+
* installed at a time; without one, `$optimistic` is `undefined`, `$pending()` is empty and `$count`
|
|
498
|
+
* is the response's count.
|
|
499
|
+
*
|
|
500
|
+
* @internal
|
|
501
|
+
*/
|
|
502
|
+
function setMaterialisedOverlay(next) {
|
|
503
|
+
overlay = next;
|
|
504
|
+
}
|
|
505
|
+
const NO_IDENTIFIERS = Object.freeze([]);
|
|
506
|
+
const NO_CREATES = Object.freeze([]);
|
|
507
|
+
/** The value each per-edge view reads through to. */
|
|
508
|
+
const SOURCES = /* @__PURE__ */ new WeakMap();
|
|
509
|
+
/** The raw (response) count of each node's relations, by node. */
|
|
510
|
+
const RAW_COUNTS = /* @__PURE__ */ new WeakMap();
|
|
511
|
+
/** `target` followed by the values it reads through to, nearest first. */
|
|
512
|
+
function chainOf(target) {
|
|
513
|
+
const chain = [];
|
|
514
|
+
let at = target;
|
|
515
|
+
while (at !== void 0 && !chain.includes(at)) {
|
|
516
|
+
chain.push(at);
|
|
517
|
+
at = SOURCES.get(at);
|
|
518
|
+
}
|
|
519
|
+
return chain;
|
|
520
|
+
}
|
|
521
|
+
/** The raw count of relation `name` the first value in `chain` with one carries. */
|
|
522
|
+
function rawCount(chain, name) {
|
|
523
|
+
for (const value of chain) {
|
|
524
|
+
const count = RAW_COUNTS.get(value);
|
|
525
|
+
if (count !== void 0) return count(name);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
/** {@link rawCount} for the chain starting at `target`, without building the chain. */
|
|
529
|
+
function rawCountOf(target, name) {
|
|
530
|
+
let at = target;
|
|
531
|
+
while (at !== void 0) {
|
|
532
|
+
const count = RAW_COUNTS.get(at);
|
|
533
|
+
if (count !== void 0) return count(name);
|
|
534
|
+
at = SOURCES.get(at);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
/** Define the overlay-backed accessors (`$optimistic`, `$pending`, `$count`) of a resource value. */
|
|
538
|
+
function attachOverlayAccessors(target) {
|
|
539
|
+
defineGetter(target, "$optimistic", () => overlay?.optimistic(chainOf(target)));
|
|
540
|
+
define(target, "$pending", (name) => overlay?.pending(chainOf(target), name) ?? NO_IDENTIFIERS);
|
|
541
|
+
define(target, "$count", (name) => {
|
|
542
|
+
if (overlay === void 0) return rawCountOf(target, name);
|
|
543
|
+
const chain = chainOf(target);
|
|
544
|
+
return overlay.count(chain, name, rawCount(chain, name));
|
|
545
|
+
});
|
|
546
|
+
}
|
|
386
547
|
/** A relationship object's `meta.total` when it is a finite number, else `undefined`. */
|
|
387
548
|
const relationTotal = (rel) => {
|
|
388
549
|
const total = rel?.meta?.["total"];
|
|
@@ -414,6 +575,21 @@ const relationTotal = (rel) => {
|
|
|
414
575
|
* top-level collection read (statically-known); both override the sniff-from-`data[0]` fallback.
|
|
415
576
|
*/
|
|
416
577
|
function materialise(doc, ctx, linkage = false, primaryType, paginatorOverride) {
|
|
578
|
+
const value = materialiseDocument(doc, ctx, linkage, primaryType, paginatorOverride);
|
|
579
|
+
if (typeof value === "object" && value !== null) MATERIALISED.add(value);
|
|
580
|
+
return stampFromDocument(doc, value);
|
|
581
|
+
}
|
|
582
|
+
const MATERIALISED = /* @__PURE__ */ new WeakSet();
|
|
583
|
+
/**
|
|
584
|
+
* Whether `value` is a top-level result `materialise` built: a resource, a collection or a linkage
|
|
585
|
+
* value, including the pages `$next()` and `$prev()` re-materialise. A plain copy of one, such as
|
|
586
|
+
* data that went through `JSON.stringify` on a server and back, has lost its `$`-accessors and
|
|
587
|
+
* answers `false`, which is how a hydrated cache entry is told from a fresh read.
|
|
588
|
+
*/
|
|
589
|
+
function isMaterialised(value) {
|
|
590
|
+
return typeof value === "object" && value !== null && MATERIALISED.has(value);
|
|
591
|
+
}
|
|
592
|
+
function materialiseDocument(doc, ctx, linkage, primaryType, paginatorOverride) {
|
|
417
593
|
require_validate.assertJsonApiDocument(doc);
|
|
418
594
|
if (ctx.validate !== void 0) require_validate.validateDocument(doc, ctx.validate, ctx.fields);
|
|
419
595
|
const env = {};
|
|
@@ -495,7 +671,10 @@ function resolveMember(member, env, index, nodes, ctx, relationEdge) {
|
|
|
495
671
|
if (included) return buildEdgeView(buildNode(included, env, index, nodes, ctx), member, relationEdge);
|
|
496
672
|
return buildIdentifierView(member, relationEdge);
|
|
497
673
|
}
|
|
498
|
-
/**
|
|
674
|
+
/**
|
|
675
|
+
* Attach the resource-level `$`-accessors ($meta/$links/$self/$document/$raw/$nestedFieldset/$rel,
|
|
676
|
+
* and the overlay-backed $count/$optimistic/$pending).
|
|
677
|
+
*/
|
|
499
678
|
function attachResourceEnvelope(node, raw, env, rels, selection) {
|
|
500
679
|
defineGetter(node, "$meta", () => raw.meta);
|
|
501
680
|
defineGetter(node, "$links", () => raw.links);
|
|
@@ -512,7 +691,8 @@ function attachResourceEnvelope(node, raw, env, rels, selection) {
|
|
|
512
691
|
if (rel.meta !== void 0) view.meta = rel.meta;
|
|
513
692
|
return view;
|
|
514
693
|
});
|
|
515
|
-
|
|
694
|
+
RAW_COUNTS.set(node, (name) => Object.hasOwn(rels, name) ? relationTotal(rels[name]) : void 0);
|
|
695
|
+
attachOverlayAccessors(node);
|
|
516
696
|
}
|
|
517
697
|
/**
|
|
518
698
|
* A per-edge VIEW over a node: a distinct wrapper per membership that reads through to the
|
|
@@ -522,22 +702,48 @@ function attachResourceEnvelope(node, raw, env, rels, selection) {
|
|
|
522
702
|
* `relationEdge` (set for a to-one) carries the relationship object's self/related links and
|
|
523
703
|
* meta, which ride the value's `$edge` (docs/materialisation.md).
|
|
524
704
|
*/
|
|
525
|
-
function buildEdgeView(node, member, relationEdge) {
|
|
705
|
+
function buildEdgeView(node, member, relationEdge, pick) {
|
|
526
706
|
const view = {};
|
|
527
|
-
Object.assign(view, node);
|
|
707
|
+
if (pick === void 0) Object.assign(view, node);
|
|
708
|
+
else for (const [k, v] of Object.entries(node)) if (k === "type" || k === "id" || pick(k)) view[k] = v;
|
|
709
|
+
SOURCES.set(view, node);
|
|
528
710
|
for (const k of [
|
|
529
711
|
"$meta",
|
|
530
712
|
"$links",
|
|
531
713
|
"$self",
|
|
532
714
|
"$document",
|
|
533
715
|
"$raw",
|
|
534
|
-
"$nestedFieldset"
|
|
535
|
-
"$rel",
|
|
536
|
-
"$count"
|
|
716
|
+
"$nestedFieldset"
|
|
537
717
|
]) delegate(view, node, k);
|
|
718
|
+
const rel = node.$rel;
|
|
719
|
+
define(view, "$rel", typeof rel === "function" ? rel.bind(node) : () => void 0);
|
|
720
|
+
attachOverlayAccessors(view);
|
|
538
721
|
attachEdgeEnvelope(view, member, false, relationEdge);
|
|
539
722
|
return view;
|
|
540
723
|
}
|
|
724
|
+
/**
|
|
725
|
+
* A per-edge view over `node` for the membership `member` describes, as `materialise` builds one
|
|
726
|
+
* for an included member: it copies `node`'s own enumerable members (those `pick` keeps, when
|
|
727
|
+
* given; `type` and `id` always), reads its resource-level `$`-accessors through to `node`, and
|
|
728
|
+
* owns its `$edge`/`$pivot` from `member.meta`. `node` may be any resource value, a materialised
|
|
729
|
+
* one or a plain object; accessors it lacks read as `undefined`.
|
|
730
|
+
*
|
|
731
|
+
* For a cache layer placing a member in a slot (`@haddowg/json-api-query`'s optimistic drafts).
|
|
732
|
+
*
|
|
733
|
+
* @internal
|
|
734
|
+
*/
|
|
735
|
+
function edgeViewOf(node, member, pick) {
|
|
736
|
+
return buildEdgeView(node, member, void 0, pick);
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* An identifier view for `member`, as `materialise` builds one for a linked member that isn't
|
|
740
|
+
* included: `{ type, id, meta? }` with its `$edge`/`$pivot`.
|
|
741
|
+
*
|
|
742
|
+
* @internal
|
|
743
|
+
*/
|
|
744
|
+
function identifierViewOf(member) {
|
|
745
|
+
return buildIdentifierView(member);
|
|
746
|
+
}
|
|
541
747
|
/** An identifier VIEW for a linked-but-not-included member: a clean `{type,id,meta?}` + edge. */
|
|
542
748
|
function buildIdentifierView(member, relationEdge) {
|
|
543
749
|
const view = {
|
|
@@ -545,6 +751,7 @@ function buildIdentifierView(member, relationEdge) {
|
|
|
545
751
|
id: member.id
|
|
546
752
|
};
|
|
547
753
|
if (member.meta !== void 0) view.meta = member.meta;
|
|
754
|
+
defineGetter(view, "$optimistic", () => overlay?.optimistic([view]));
|
|
548
755
|
attachEdgeEnvelope(view, member, true, relationEdge);
|
|
549
756
|
return view;
|
|
550
757
|
}
|
|
@@ -592,7 +799,9 @@ function augmentArray(members, doc, ctx, linkage, primaryType, paginatorOverride
|
|
|
592
799
|
const arr = [...members];
|
|
593
800
|
const links = doc.links;
|
|
594
801
|
defineGetter(arr, "$links", () => links);
|
|
595
|
-
defineGetter(arr, "$meta", ()
|
|
802
|
+
defineGetter(arr, "$meta", function() {
|
|
803
|
+
return withTotal(doc.meta, this);
|
|
804
|
+
});
|
|
596
805
|
attachPage(arr, paginatorOverride === void 0 ? resolvePaginator(primaryPaginator(doc, ctx, primaryType)) : typeof paginatorOverride === "string" ? resolvePaginator(paginatorOverride) : paginatorOverride, pageMeta(doc.meta), links, ctx, linkage);
|
|
597
806
|
return arr;
|
|
598
807
|
}
|
|
@@ -612,7 +821,10 @@ function augmentRelationArray(members, rel, paginator, ctx, hydrated) {
|
|
|
612
821
|
const links = rel.links;
|
|
613
822
|
defineGetter(arr, "$links", () => links);
|
|
614
823
|
defineGetter(arr, "$meta", () => rel.meta);
|
|
615
|
-
defineGetter(arr, "$count", ()
|
|
824
|
+
defineGetter(arr, "$count", function() {
|
|
825
|
+
const raw = relationTotal(rel);
|
|
826
|
+
return overlay === void 0 ? raw : overlay.count([this], void 0, raw);
|
|
827
|
+
});
|
|
616
828
|
attachPage(arr, paginator, pageMeta(rel.meta), links, ctx, !hydrated, hydrated ? (link) => relatedPageLink(link, links) : void 0);
|
|
617
829
|
return arr;
|
|
618
830
|
}
|
|
@@ -637,7 +849,12 @@ function attachPage(arr, paginator, meta, links, ctx, linkage, follow = (link) =
|
|
|
637
849
|
};
|
|
638
850
|
if (paginator.arm !== void 0) page.arm = paginator.arm;
|
|
639
851
|
if (meta !== void 0) page.meta = meta;
|
|
640
|
-
defineGetter(arr, "$page", ()
|
|
852
|
+
defineGetter(arr, "$page", function() {
|
|
853
|
+
return pageWithTotal(page, this);
|
|
854
|
+
});
|
|
855
|
+
define(arr, "$pending", function() {
|
|
856
|
+
return overlay?.creates?.([this]) ?? NO_CREATES;
|
|
857
|
+
});
|
|
641
858
|
const go = (link, signal) => navigateLink(link === void 0 ? void 0 : follow(link), ctx, linkage, paginator, signal);
|
|
642
859
|
define(arr, "$next", (options) => go(page.links.next, options?.signal));
|
|
643
860
|
define(arr, "$prev", (options) => go(page.links.prev, options?.signal));
|
|
@@ -665,6 +882,37 @@ const linkHref = (link) => {
|
|
|
665
882
|
if (typeof link === "string") return link;
|
|
666
883
|
if (isObject$2(link) && typeof link["href"] === "string") return link["href"];
|
|
667
884
|
};
|
|
885
|
+
/** `meta` with its `total` moved as the overlay reports for `target`, when both say so. */
|
|
886
|
+
function withTotal(meta, target) {
|
|
887
|
+
const raw = meta?.["total"];
|
|
888
|
+
if (overlay?.total === void 0 || typeof raw !== "number" || !Number.isFinite(raw)) return meta;
|
|
889
|
+
const total = overlay.total([target], raw);
|
|
890
|
+
return total === raw ? meta : cachedCopy(meta, total, () => ({
|
|
891
|
+
...meta,
|
|
892
|
+
total
|
|
893
|
+
}));
|
|
894
|
+
}
|
|
895
|
+
/** `page` with its `meta.total` moved as the overlay reports for `target`. */
|
|
896
|
+
function pageWithTotal(page, target) {
|
|
897
|
+
const meta = page.meta === void 0 ? void 0 : withTotal(page.meta, target);
|
|
898
|
+
if (meta === void 0 || meta === page.meta) return page;
|
|
899
|
+
return cachedCopy(page, meta["total"], () => ({
|
|
900
|
+
...page,
|
|
901
|
+
meta
|
|
902
|
+
}));
|
|
903
|
+
}
|
|
904
|
+
/** The copies made of each value per total, so an unchanged total reads back the same object. */
|
|
905
|
+
const COPIES = /* @__PURE__ */ new WeakMap();
|
|
906
|
+
function cachedCopy(value, total, make) {
|
|
907
|
+
const copies = COPIES.get(value) ?? /* @__PURE__ */ new Map();
|
|
908
|
+
COPIES.set(value, copies);
|
|
909
|
+
let copy = copies.get(total);
|
|
910
|
+
if (copy === void 0) {
|
|
911
|
+
copy = make();
|
|
912
|
+
copies.set(total, copy);
|
|
913
|
+
}
|
|
914
|
+
return copy;
|
|
915
|
+
}
|
|
668
916
|
const pageMeta = (meta) => isObject$2(meta?.["page"]) ? meta["page"] : void 0;
|
|
669
917
|
/**
|
|
670
918
|
* The document's paginator (from the primary type's descriptor). Prefers the statically-known
|
|
@@ -1090,15 +1338,16 @@ async function runAtomic(request, materialiseCtx, descriptor, path, build) {
|
|
|
1090
1338
|
ext: [ATOMIC_EXT]
|
|
1091
1339
|
};
|
|
1092
1340
|
let doc;
|
|
1341
|
+
let stamp;
|
|
1093
1342
|
try {
|
|
1094
|
-
doc = await
|
|
1343
|
+
({document: doc, stamp} = await executeResponse(request, req));
|
|
1095
1344
|
} catch (error) {
|
|
1096
1345
|
if (error instanceof require_validate.JsonApiError) throw withRemappedAtomicPaths(error, descriptor, (opIndex) => typeByOp[opIndex], (opIndex) => relationByOp.get(opIndex));
|
|
1097
1346
|
throw error;
|
|
1098
1347
|
}
|
|
1099
|
-
const results = parseResults(doc, materialiseCtx, (opIndex) => relationByOp.has(opIndex));
|
|
1100
|
-
if (!(Array.isArray(returned) && returned.every((h) => h !== null && typeof h === "object" && "opIndex" in h))) return results;
|
|
1101
|
-
return returned.map((handle) => handle.kind === "delete" ? void 0 : results[handle.opIndex]);
|
|
1348
|
+
const results = parseResults(doc, materialiseCtx, (opIndex) => relationByOp.has(opIndex), stamp);
|
|
1349
|
+
if (!(Array.isArray(returned) && returned.every((h) => h !== null && typeof h === "object" && "opIndex" in h))) return stampRequest(results, stamp);
|
|
1350
|
+
return stampRequest(returned.map((handle) => handle.kind === "delete" ? void 0 : results[handle.opIndex]), stamp);
|
|
1102
1351
|
}
|
|
1103
1352
|
/**
|
|
1104
1353
|
* Build the resource `data` for an `add`/`update` op from flat input via {@link toDocument}
|
|
@@ -1138,15 +1387,15 @@ function toRef(ref, what) {
|
|
|
1138
1387
|
}
|
|
1139
1388
|
/**
|
|
1140
1389
|
* Parse `{ "atomic:results": [...] }` positionally, materialising each result's `data`: a
|
|
1141
|
-
* relationship op's as linkage, any other's as a resource
|
|
1142
|
-
* batch) yields `[]`.
|
|
1390
|
+
* relationship op's as linkage, any other's as a resource, each stamped with the batch's request
|
|
1391
|
+
* start. An absent results array (an all-`204` batch) yields `[]`.
|
|
1143
1392
|
*/
|
|
1144
|
-
function parseResults(doc, ctx, isLinkage) {
|
|
1393
|
+
function parseResults(doc, ctx, isLinkage, stamp) {
|
|
1145
1394
|
const results = doc?.["atomic:results"];
|
|
1146
1395
|
if (!Array.isArray(results)) return [];
|
|
1147
1396
|
return results.map((result, opIndex) => {
|
|
1148
1397
|
const entry = isObject(result) ? result : {};
|
|
1149
|
-
const out = { data: entry["data"] === void 0 ? void 0 : materialise({ data: entry["data"] }, ctx, isLinkage(opIndex)) };
|
|
1398
|
+
const out = { data: entry["data"] === void 0 ? void 0 : stampRequest(materialise({ data: entry["data"] }, ctx, isLinkage(opIndex)), stamp) };
|
|
1150
1399
|
if (isObject(entry["meta"])) out.meta = entry["meta"];
|
|
1151
1400
|
return out;
|
|
1152
1401
|
});
|
|
@@ -1438,7 +1687,7 @@ async function runWrite(ctx, spec) {
|
|
|
1438
1687
|
if (error instanceof require_validate.JsonApiError) throw spec.remap(error);
|
|
1439
1688
|
throw error;
|
|
1440
1689
|
}
|
|
1441
|
-
const complete = (doc) => doc === void 0 ? void 0 : spec.metaOnly === true && !("data" in doc) ? doc.meta : materialise(doc, withFields(ctx.materialise, spec.query?.fields), spec.linkage ?? false);
|
|
1690
|
+
const complete = (doc) => stampFromDocument(doc, doc === void 0 ? void 0 : spec.metaOnly === true && !("data" in doc) ? doc.meta : materialise(doc, withFields(ctx.materialise, spec.query?.fields), spec.linkage ?? false));
|
|
1442
1691
|
if (res.status === 202 && spec.accepted !== void 0) return answerAccepted(ctx, spec.accepted, res, complete, spec.wait);
|
|
1443
1692
|
return complete(res.document);
|
|
1444
1693
|
}
|
|
@@ -1519,7 +1768,7 @@ async function runAction(ctx, action, vars, input, options = {}) {
|
|
|
1519
1768
|
return raw.kind === "json" && text !== void 0 ? JSON.parse(text) : text;
|
|
1520
1769
|
}
|
|
1521
1770
|
const res = await executeResponse(ctx.request, req);
|
|
1522
|
-
const complete = (doc) => actionValue(ctx, action, doc);
|
|
1771
|
+
const complete = (doc) => stampFromDocument(doc, actionValue(ctx, action, doc));
|
|
1523
1772
|
if (res.status === 202 && action.accepted !== void 0) {
|
|
1524
1773
|
const wait = waitOptions(options.wait);
|
|
1525
1774
|
const signal = wait?.signal ?? options.signal;
|
|
@@ -1888,30 +2137,38 @@ exports.PollTimeoutError = PollTimeoutError;
|
|
|
1888
2137
|
exports.StructuralGuardError = require_validate.StructuralGuardError;
|
|
1889
2138
|
exports.assertJsonApiDocument = require_validate.assertJsonApiDocument;
|
|
1890
2139
|
exports.createClient = createClient;
|
|
2140
|
+
exports.edgeViewOf = edgeViewOf;
|
|
1891
2141
|
exports.execute = execute;
|
|
1892
2142
|
exports.executeRaw = executeRaw;
|
|
1893
2143
|
exports.executeResponse = executeResponse;
|
|
1894
2144
|
exports.fetchTransport = fetchTransport;
|
|
1895
2145
|
exports.findError = require_validate.findError;
|
|
1896
2146
|
exports.hasErrorCode = require_validate.hasErrorCode;
|
|
2147
|
+
exports.identifierViewOf = identifierViewOf;
|
|
1897
2148
|
exports.isAccepted = isAccepted;
|
|
1898
2149
|
exports.isActionLocation = isActionLocation;
|
|
2150
|
+
exports.isMaterialised = isMaterialised;
|
|
1899
2151
|
exports.isPolymorphic = isPolymorphic;
|
|
1900
2152
|
exports.listFilterMatcher = listFilterMatcher;
|
|
1901
2153
|
exports.loadAll = loadAll;
|
|
1902
2154
|
exports.materialise = materialise;
|
|
1903
2155
|
exports.mediaType = mediaType;
|
|
1904
2156
|
exports.nestedFieldset = require_validate.nestedFieldset;
|
|
2157
|
+
exports.nextPageParams = nextPageParams;
|
|
2158
|
+
exports.nextRequestStamp = nextRequestStamp;
|
|
1905
2159
|
exports.parseRetryAfter = parseRetryAfter;
|
|
2160
|
+
exports.prevPageParams = prevPageParams;
|
|
1906
2161
|
exports.readActionLocation = readActionLocation;
|
|
1907
2162
|
exports.relatedPaginator = relatedPaginator;
|
|
1908
2163
|
exports.relatedPaginatorKind = relatedPaginatorKind;
|
|
1909
2164
|
exports.remapPointer = remapPointer;
|
|
1910
2165
|
exports.remapRelationshipPointer = remapRelationshipPointer;
|
|
2166
|
+
exports.requestStampOf = requestStampOf;
|
|
1911
2167
|
exports.resolvePaginator = resolvePaginator;
|
|
1912
2168
|
exports.resolveValidator = require_validate.resolveValidator;
|
|
1913
2169
|
exports.runAtomic = runAtomic;
|
|
1914
2170
|
exports.serializeQuery = serializeQuery;
|
|
2171
|
+
exports.setMaterialisedOverlay = setMaterialisedOverlay;
|
|
1915
2172
|
exports.sparseSchema = require_validate.sparseSchema;
|
|
1916
2173
|
exports.sparseSchemas = require_validate.sparseSchemas;
|
|
1917
2174
|
exports.toDocument = toDocument;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as DeleteResult, $n as MaterialiseContext, $r as ApiExamples, $t as ResourceAccessors, A as TransportResponse, Ai as StrategyDescriptor, An as readActionLocation, Ar as PageMeta, At as ReadAttributesOf, B as Client, Bn as AtomicRelationshipRecorder, Br as PollOptions, Bt as RelatedReadRelatedQuery, C as ClientOptions, Ci as RelationMutations, Cn as WithLinks, Cr as NestedFieldset, Ct as MutationMetaOf, D as JsonApiTransport, Di as ResourceExamples, Dn as WriteResult, Dr as Page, Dt as OptionsArg, E as createClient, Ei as ResourceDescriptor, En as WritePivotOf, Er as ExactPageParams, Et as OperationMeta, F as ActionCallOptions, Fn as AtomicOperationArgs, Fr as TypedPage, Ft as RelatedMeta, G as CountedRelationName, Gn as runAtomic, Gr as AcceptedOperation, Gt as RelationPaginator, H as CollectionMeta, Hn as AtomicResults, Hr as isAccepted, Ht as RelationFilterQuery, I as ActionsAccessor, In as AtomicRecorder, Ir as nextPageParams, It as RelatedQuery, J as CreateMethod, Jn as Edge, Jr as ActionLocationDescriptor, Jt as RelationSortQuery, K as CreateAttributesOf, Kn as ArrayEnvelope, Kr as ActionDescriptor, Kt as RelationReadQuery, L as AtomicResultOf, Ln as AtomicRef, Lr as prevPageParams, Lt as RelatedQueryEntry, M as AcceptedJob, Mn as AtomicCreateInput, Mr as PageParams, Mt as ReadableRelationName, N as AcceptedMeta, Nn as AtomicDeleteHandle, Nr as PageParamsOf, Nt as RelatedIncludedResource, O as TransportRawBody, Oi as ResourceMetaDescriptor, On as ActionLocation, Or as PageKeys, Ot as PivotFieldsOf, P as AcceptedOf, Pn as AtomicHandle, Pr as ResolvedPaginator, Pt as RelatedIncludedType, Q as DeleteArgs, Qn as LinkObject, Qr as ApiDescriptor, Qt as RequiresRequestMeta, R as BinaryBody, Rn as AtomicRelationshipArgs, Rr as resolvePaginator, Rt as RelatedQueryParam, S as serializeQuery, Si as RelationDescriptor, Sn as WithDocumentMeta, Sr as mediaType, St as MetaOption, T as HeadersInit, Ti as ResourceCountOperation, Tn as WriteOptions, Tr as CANONICAL_PAGE_KEYS, Tt as NestedFieldsetMember, U as CountAccessor, Un as AtomicUpdateHandle, Ur as parseRetryAfter, Ut as RelationName, V as Collection, Vn as AtomicResult, Vr as PollTimeoutError, Vt as RelationCollection, W as CountToken, Wn as AtomicUpdateInput, Wr as AcceptedDescriptor, Wt as RelationPageParams, X as DefaultAttributes, Xn as EdgeMember, Xr as ActionScope, Xt as RelationshipMembers, Y as DefaultActionTypes, Yn as EdgeEnvelope, Yr as ActionOutput, Yt as RelationshipAccessor, Z as DefaultWriteAttributes, Zn as Link, Zr as AdditionalMembersDescriptor, Zt as RequestMetaOf, _ as RawResponseType, _i as PivotDescriptor, _n as UpdateInput, _r as ATOMIC_MEDIA_TYPE, _t as LooseRelatedQuery, a as ValidationOption, ai as DocumentMetaOperation, an as ResourceWriteOperation, ar as RelationArrayEnvelope, at as FilterKey, b as executeRaw, bi as RelatedQueryDescriptor, bn as WaitValue, br as MediaTypeParams, bt as MemberTypeOf, c as assertJsonApiDocument, ci as InputMediaKind, cn as SingletonUpdateInput, cr as ResourceLinks, ct as IdentifierMember, d as sparseSchemas, di as MetaLiteral, dn as TakesVerb, dr as isMaterialised, dt as IncludedResource, ei as AtomicDescriptor, en as ResourceCountToken, er as MaterialisedOverlay, et as DocumentMeta, f as validateDocument, fi as OperationExamples, fn as TypeAccessor, fr as materialise, ft as IncludedType, g as JsonApiRequest, gi as PaginatorStrategy, gn as TypedRelationReadQuery, gr as ATOMIC_EXT, gt as ListPageParams, h as JsonApiContext, hi as PaginatorRole, hn as TypedRelatedReadQuery, hr as setMaterialisedOverlay, ht as ListFilterMember, i as ValidationContext, ii as DocumentMetaDescriptor, in as ResourceWriteMeta, ir as PendingPlacement, it as FieldsMap, j as fetchTransport, ji as isPolymorphic, jn as AtomicCreateHandle, jr as PageOf, jt as ReadResult, k as TransportRequest, ki as SortFamilyDescriptor, kn as isActionLocation, kr as PageLinks, kt as PivotInput, l as resolveValidator, li as MediaExamples, ln as SortQuery, lr as edgeViewOf, lt as IncludePath, m as ExecutedResponse, mi as PaginatorKind, mn as TypedReadQuery, mr as relatedPaginatorKind, mt as LinkageRef, n as SchemaMap, ni as ClientIdPolicy, nn as ResourceMetaOf, nr as PendingCreate, nt as ErrorCodeOf, o as Validator, oi as FilterFamilyDescriptor, on as SingleReadQuery, or as RelationView, ot as FilterQuery, p as Document, pi as PaginatorDescriptor, pn as TypeName, pr as relatedPaginator, pt as IsSingleton, q as CreateInput, qn as DocumentEnvelope, qr as ActionInput, qt as RelationRequestMetaOf, r as ValidationConfig, ri as CountableDescriptor, rn as ResourceObjectView, rr as PendingMember, rt as FieldSelectionMap, s as WireResource, si as InputMedia, sn as SingletonAccessor, sr as ResourceEnvelope, st as HydratedMember, t as ResolvedValidator, ti as Cardinality, tn as ResourceHandle, tr as NavigateOptions, tt as EdgeMembers, u as sparseSchema, ui as MenuDescriptor, un as SortToken, ur as identifierViewOf, ut as IncludedRelations, v as ReadQuery, vi as RawMediaKind, vn as UpdateMethod, vr as JSON_API_MEDIA_TYPE, vt as LooseRelatedQueryEntry, w as HANDLE_RESERVED, wi as RequestMetaOperation, wn as WritableRelationName, wr as nestedFieldset, wt as MutationVerb, x as executeResponse, xi as RelatedQueryOperation, xn as WaitedWriteResult, xr as ResourceIdentifier, xt as MetaObject, y as execute, yi as RawOutputMedia, yn as WaitOptions, yr as LocalIdentifier, yt as MemberName, z as BinaryResponseType, zn as AtomicRelationshipHandle, zr as Accepted, zt as RelatedQueryRelation } from "./validate-ugcQVpb0.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
4
|
/**
|
|
@@ -146,6 +146,39 @@ interface LoadAllOptions {
|
|
|
146
146
|
*/
|
|
147
147
|
declare function loadAll<T>(first: Collection<T> | PromiseLike<Collection<T>>, options?: LoadAllOptions): Promise<T[]>;
|
|
148
148
|
//#endregion
|
|
149
|
+
//#region src/request-stamp.d.ts
|
|
150
|
+
/**
|
|
151
|
+
* Request stamps: when the request behind a result started, relative to every other request made in
|
|
152
|
+
* this process.
|
|
153
|
+
*
|
|
154
|
+
* The client takes a stamp as each request starts and records it on the top-level value it
|
|
155
|
+
* materialises from the response: a read's resource, collection or linkage (`$next()`/`$prev()`
|
|
156
|
+
* pages included), a write's returned resource, and an atomic batch's results. A cache can then
|
|
157
|
+
* tell which of two results carrying the same resource is the newer, whatever order their
|
|
158
|
+
* responses arrived in.
|
|
159
|
+
*
|
|
160
|
+
* The stamp is a per-process counter rather than `Date.now()`: two requests started in the same
|
|
161
|
+
* millisecond still get distinct, ordered stamps, and a clock change can't reorder them. It means
|
|
162
|
+
* nothing outside the process that issued it, so a value that crossed one (through JSON on a server
|
|
163
|
+
* render, or storage) carries none. Stamps live in a `WeakMap` keyed by the result, so the result
|
|
164
|
+
* keeps its shape and nothing is added to it.
|
|
165
|
+
*
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
/**
|
|
169
|
+
* A new stamp, later than every stamp handed out before it. The client takes one as each request
|
|
170
|
+
* starts; anything ordering its own events against the client's requests takes them here too.
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
declare function nextRequestStamp(): number;
|
|
174
|
+
/**
|
|
175
|
+
* The stamp of the request `value` was materialised from: a top-level result the client returned.
|
|
176
|
+
* `undefined` for anything else, such as a plain copy of a result, a nested resource, or data the
|
|
177
|
+
* client never returned.
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
declare function requestStampOf(value: unknown): number | undefined;
|
|
181
|
+
//#endregion
|
|
149
182
|
//#region src/serialize-write.d.ts
|
|
150
183
|
/**
|
|
151
184
|
* A JSON:API resource identifier in a write document: `{ type, id }` or — inside an atomic
|
|
@@ -299,5 +332,5 @@ declare function withRemappedAtomicPaths(error: JsonApiError, descriptor: ApiDes
|
|
|
299
332
|
hasPivot: boolean;
|
|
300
333
|
} | undefined): JsonApiError;
|
|
301
334
|
//#endregion
|
|
302
|
-
export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, type Accepted, AcceptedDescriptor, AcceptedJob, AcceptedMeta, AcceptedOf, AcceptedOperation, ActionCallOptions, ActionDescriptor, ActionInput, ActionLocation, ActionLocationDescriptor, ActionOutput, ActionScope, ActionsAccessor, AdditionalMembersDescriptor, ApiDescriptor, ApiExamples, ArrayEnvelope, AtomicCreateHandle, AtomicCreateInput, AtomicDeleteHandle, AtomicDescriptor, AtomicHandle, AtomicOperationArgs, AtomicRecorder, AtomicRef, AtomicRelationshipArgs, AtomicRelationshipHandle, AtomicRelationshipRecorder, AtomicResult, AtomicResultOf, AtomicResults, AtomicUpdateHandle, AtomicUpdateInput, BinaryBody, BinaryResponseType, CANONICAL_PAGE_KEYS, Cardinality, Client, ClientIdPolicy, ClientOptions, CodedErrorObject, Collection, CollectionMeta, CountAccessor, CountToken, CountableDescriptor, CountedRelationName, CreateInput, CreateMethod, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, DeleteArgs, DeleteResult, Document, DocumentEnvelope, DocumentMeta, DocumentMetaDescriptor, DocumentMetaOperation, 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, IsSingleton, JSON_API_MEDIA_TYPE, JsonApiContext, JsonApiError, JsonApiErrorObject, JsonApiRequest, JsonApiTransport, Link, LinkObject, LinkageRef, ListFilterMember, ListPageParams, LoadAllOptions, LocalIdentifier, LooseRelatedQuery, LooseRelatedQueryEntry, MaterialiseContext, MediaExamples, MediaTypeParams, MemberName, MenuDescriptor, MetaLiteral, MetaObject, MetaOption, MutationMetaOf, MutationVerb, NavigateOptions, type NestedFieldset, NestedFieldsetMember, OperationExamples, OperationMeta, OptionsArg, Page, PageKeys, PageLinks, PageMeta, PageOf, PageParams, PageParamsOf, PaginatorDescriptor, PaginatorKind, PaginatorRole, PaginatorStrategy, PivotDescriptor, PivotInput, type PollOptions, PollTimeoutError, RawMediaKind, RawOutputMedia, RawResponseType, ReadQuery, ReadResult, ReadableRelationName, RelatedIncludedResource, RelatedIncludedType, RelatedMeta, RelatedQuery, RelatedQueryDescriptor, RelatedQueryEntry, RelatedQueryOperation, RelatedQueryParam, RelatedQueryRelation, RelatedReadRelatedQuery, RelationArrayEnvelope, RelationCollection, RelationDescriptor, RelationFilterQuery, RelationMutations, RelationName, RelationPageParams, RelationPaginator, RelationReadQuery, RelationRequestMetaOf, RelationSortQuery, RelationView, RelationshipAccessor, RelationshipDocument, RelationshipMembers, RequestMetaOf, RequestMetaOperation, RequiresRequestMeta, ResolvedPaginator, ResolvedValidator, ResourceAccessors, ResourceCountOperation, ResourceCountToken, ResourceDescriptor, ResourceEnvelope, ResourceExamples, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceMetaDescriptor, ResourceMetaOf, ResourceObjectView, ResourceWriteMeta, ResourceWriteOperation, SchemaMap, SingleReadQuery, SingletonAccessor, SingletonUpdateInput, SortFamilyDescriptor, SortQuery, SortToken, StrategyDescriptor, StructuralGuardError, TakesVerb, ToDocumentOptions, TransportRawBody, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedPage, TypedReadQuery, TypedRelatedReadQuery, TypedRelationReadQuery, UpdateInput, UpdateMethod, ValidationConfig, ValidationContext, ValidationOption, Validator, WaitOptions, WaitValue, WaitedWriteResult, WireResource, WithDocumentMeta, WithLinks, WritableRelationName, WriteDocument, WriteOptions, WriteResult, assertJsonApiDocument, createClient, execute, executeRaw, executeResponse, fetchTransport, findError, hasErrorCode, isAccepted, isActionLocation, isPolymorphic, listFilterMatcher, loadAll, materialise, mediaType, nestedFieldset, parseRetryAfter, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, resolvePaginator, resolveValidator, runAtomic, serializeQuery, sparseSchema, sparseSchemas, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedDocumentMetaPaths, withRemappedPaths, withRemappedRelationshipPaths, withTopLevelMeta };
|
|
335
|
+
export { ATOMIC_EXT, ATOMIC_MEDIA_TYPE, type Accepted, AcceptedDescriptor, AcceptedJob, AcceptedMeta, AcceptedOf, AcceptedOperation, ActionCallOptions, ActionDescriptor, ActionInput, ActionLocation, ActionLocationDescriptor, ActionOutput, ActionScope, ActionsAccessor, AdditionalMembersDescriptor, ApiDescriptor, ApiExamples, ArrayEnvelope, AtomicCreateHandle, AtomicCreateInput, AtomicDeleteHandle, AtomicDescriptor, AtomicHandle, AtomicOperationArgs, AtomicRecorder, AtomicRef, AtomicRelationshipArgs, AtomicRelationshipHandle, AtomicRelationshipRecorder, AtomicResult, AtomicResultOf, AtomicResults, AtomicUpdateHandle, AtomicUpdateInput, BinaryBody, BinaryResponseType, CANONICAL_PAGE_KEYS, Cardinality, Client, ClientIdPolicy, ClientOptions, CodedErrorObject, Collection, CollectionMeta, CountAccessor, CountToken, CountableDescriptor, CountedRelationName, CreateAttributesOf, CreateInput, CreateMethod, DefaultActionTypes, DefaultAttributes, DefaultWriteAttributes, DeleteArgs, DeleteResult, Document, DocumentEnvelope, DocumentMeta, DocumentMetaDescriptor, DocumentMetaOperation, Edge, EdgeEnvelope, EdgeMember, EdgeMembers, ErrorCodeGuard, ErrorCodeOf, ErrorFinder, ExactPageParams, ExecutedResponse, FieldSelectionMap, FieldsMap, FilterFamilyDescriptor, FilterKey, FilterQuery, FilterSpec, HANDLE_RESERVED, HeadersInit, HydratedMember, IdentifierMember, IncludePath, IncludedRelations, IncludedResource, IncludedType, InputMedia, InputMediaKind, IsSingleton, JSON_API_MEDIA_TYPE, JsonApiContext, JsonApiError, JsonApiErrorObject, JsonApiRequest, JsonApiTransport, Link, LinkObject, LinkageRef, ListFilterMember, ListPageParams, LoadAllOptions, LocalIdentifier, LooseRelatedQuery, LooseRelatedQueryEntry, MaterialiseContext, MaterialisedOverlay, MediaExamples, MediaTypeParams, MemberName, MemberTypeOf, MenuDescriptor, MetaLiteral, MetaObject, MetaOption, MutationMetaOf, MutationVerb, NavigateOptions, type NestedFieldset, NestedFieldsetMember, OperationExamples, OperationMeta, OptionsArg, Page, PageKeys, PageLinks, PageMeta, PageOf, PageParams, PageParamsOf, PaginatorDescriptor, PaginatorKind, PaginatorRole, PaginatorStrategy, PendingCreate, PendingMember, PendingPlacement, PivotDescriptor, PivotFieldsOf, PivotInput, type PollOptions, PollTimeoutError, RawMediaKind, RawOutputMedia, RawResponseType, ReadAttributesOf, ReadQuery, ReadResult, ReadableRelationName, RelatedIncludedResource, RelatedIncludedType, RelatedMeta, RelatedQuery, RelatedQueryDescriptor, RelatedQueryEntry, RelatedQueryOperation, RelatedQueryParam, RelatedQueryRelation, RelatedReadRelatedQuery, RelationArrayEnvelope, RelationCollection, RelationDescriptor, RelationFilterQuery, RelationMutations, RelationName, RelationPageParams, RelationPaginator, RelationReadQuery, RelationRequestMetaOf, RelationSortQuery, RelationView, RelationshipAccessor, RelationshipDocument, RelationshipMembers, RequestMetaOf, RequestMetaOperation, RequiresRequestMeta, ResolvedPaginator, ResolvedValidator, ResourceAccessors, ResourceCountOperation, ResourceCountToken, ResourceDescriptor, ResourceEnvelope, ResourceExamples, ResourceHandle, ResourceIdentifier, ResourceLinks, ResourceMetaDescriptor, ResourceMetaOf, ResourceObjectView, ResourceWriteMeta, ResourceWriteOperation, SchemaMap, SingleReadQuery, SingletonAccessor, SingletonUpdateInput, SortFamilyDescriptor, SortQuery, SortToken, StrategyDescriptor, StructuralGuardError, TakesVerb, ToDocumentOptions, TransportRawBody, TransportRequest, TransportResponse, TypeAccessor, TypeName, TypedPage, TypedReadQuery, TypedRelatedReadQuery, TypedRelationReadQuery, UpdateInput, UpdateMethod, ValidationConfig, ValidationContext, ValidationOption, Validator, WaitOptions, WaitValue, WaitedWriteResult, WireResource, WithDocumentMeta, WithLinks, WritableRelationName, WriteDocument, WriteOptions, WritePivotOf, WriteResult, assertJsonApiDocument, createClient, edgeViewOf, execute, executeRaw, executeResponse, fetchTransport, findError, hasErrorCode, identifierViewOf, isAccepted, isActionLocation, isMaterialised, isPolymorphic, listFilterMatcher, loadAll, materialise, mediaType, nestedFieldset, nextPageParams, nextRequestStamp, parseRetryAfter, prevPageParams, readActionLocation, relatedPaginator, relatedPaginatorKind, remapPointer, remapRelationshipPointer, requestStampOf, resolvePaginator, resolveValidator, runAtomic, serializeQuery, setMaterialisedOverlay, sparseSchema, sparseSchemas, toDocument, toRelationshipDocument, validateDocument, withRemappedAtomicPaths, withRemappedDocumentMetaPaths, withRemappedPaths, withRemappedRelationshipPaths, withTopLevelMeta };
|
|
303
336
|
//# 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/filters.ts","../src/load-all.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;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/errors.ts","../src/filters.ts","../src/load-all.ts","../src/request-stamp.ts","../src/serialize-write.ts"],"mappings":"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"}
|