@warp-drive-mirror/json-api 5.7.0-alpha.27 → 5.7.0-alpha.29
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/declarations/-private/cache.d.ts +6 -61
- package/declarations/-private/validator/1.1/7.1_top-level-document-members.d.ts +1 -12
- package/declarations/-private/validator/1.1/7.2_resource-objects.d.ts +1 -13
- package/declarations/-private/validator/1.1/links.d.ts +1 -23
- package/dist/index.js +21 -14
- package/package.json +4 -4
|
@@ -1,34 +1,15 @@
|
|
|
1
|
-
import type { Graph } from "@warp-drive-mirror/core/graph/-private";
|
|
2
1
|
import type { CacheCapabilitiesManager } from "@warp-drive-mirror/core/types";
|
|
3
2
|
import type { Cache, ChangedAttributesHash, RelationshipDiff } from "@warp-drive-mirror/core/types/cache";
|
|
4
3
|
import type { Change } from "@warp-drive-mirror/core/types/cache/change";
|
|
5
4
|
import type { Operation } from "@warp-drive-mirror/core/types/cache/operations";
|
|
6
5
|
import type { CollectionRelationship, ResourceRelationship } from "@warp-drive-mirror/core/types/cache/relationship";
|
|
7
6
|
import type { LocalRelationshipOperation } from "@warp-drive-mirror/core/types/graph";
|
|
8
|
-
import type {
|
|
7
|
+
import type { RequestKey, ResourceKey } from "@warp-drive-mirror/core/types/identifier";
|
|
9
8
|
import type { Value } from "@warp-drive-mirror/core/types/json/raw";
|
|
10
9
|
import type { RequestContext, StructuredDataDocument, StructuredDocument, StructuredErrorDocument } from "@warp-drive-mirror/core/types/request";
|
|
11
10
|
import type { CollectionResourceDataDocument, ResourceDocument, ResourceErrorDocument, ResourceMetaDocument, SingleResourceDataDocument } from "@warp-drive-mirror/core/types/spec/document";
|
|
12
11
|
import type { ApiError } from "@warp-drive-mirror/core/types/spec/error";
|
|
13
12
|
import type { CollectionResourceDocument, ExistingResourceObject, ResourceObject, SingleResourceDocument } from "@warp-drive-mirror/core/types/spec/json-api-raw";
|
|
14
|
-
interface CachedResource {
|
|
15
|
-
id: string | null;
|
|
16
|
-
remoteAttrs: Record<string, Value | undefined> | null;
|
|
17
|
-
localAttrs: Record<string, Value | undefined> | null;
|
|
18
|
-
defaultAttrs: Record<string, Value | undefined> | null;
|
|
19
|
-
inflightAttrs: Record<string, Value | undefined> | null;
|
|
20
|
-
changes: Record<string, [Value | undefined, Value]> | null;
|
|
21
|
-
errors: ApiError[] | null;
|
|
22
|
-
isNew: boolean;
|
|
23
|
-
isDeleted: boolean;
|
|
24
|
-
isDeletionCommitted: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* debugging only
|
|
27
|
-
*
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
inflightRelationships?: Record<string, unknown> | null;
|
|
31
|
-
}
|
|
32
13
|
/**
|
|
33
14
|
* ### JSONAPICache
|
|
34
15
|
*
|
|
@@ -128,16 +109,6 @@ export declare class JSONAPICache implements Cache {
|
|
|
128
109
|
* @public
|
|
129
110
|
*/
|
|
130
111
|
version: "2";
|
|
131
|
-
/** @internal */
|
|
132
|
-
_capabilities: CacheCapabilitiesManager;
|
|
133
|
-
/** @internal */
|
|
134
|
-
__cache: Map<ResourceKey, CachedResource>;
|
|
135
|
-
/** @internal */
|
|
136
|
-
__destroyedCache: Map<ResourceKey, CachedResource>;
|
|
137
|
-
/** @internal */
|
|
138
|
-
__documents: Map<string, StructuredDocument<ResourceDocument>>;
|
|
139
|
-
/** @internal */
|
|
140
|
-
__graph: Graph;
|
|
141
112
|
constructor(capabilities: CacheCapabilitiesManager);
|
|
142
113
|
////////// ================ //////////
|
|
143
114
|
////////// Cache Management //////////
|
|
@@ -183,11 +154,6 @@ export declare class JSONAPICache implements Cache {
|
|
|
183
154
|
put<T extends CollectionResourceDocument>(doc: StructuredDataDocument<T>): CollectionResourceDataDocument;
|
|
184
155
|
put<T extends ResourceErrorDocument>(doc: StructuredErrorDocument<T>): ResourceErrorDocument;
|
|
185
156
|
put<T extends ResourceMetaDocument>(doc: StructuredDataDocument<T>): ResourceMetaDocument;
|
|
186
|
-
/** @internal */
|
|
187
|
-
_putDocument<T extends ResourceErrorDocument>(doc: StructuredErrorDocument<T>, data: undefined, included: undefined): ResourceErrorDocument;
|
|
188
|
-
_putDocument<T extends ResourceMetaDocument>(doc: StructuredDataDocument<T>, data: undefined, included: undefined): ResourceMetaDocument;
|
|
189
|
-
_putDocument<T extends SingleResourceDocument>(doc: StructuredDataDocument<T>, data: PersistedResourceKey | null, included: PersistedResourceKey[] | undefined): SingleResourceDataDocument;
|
|
190
|
-
_putDocument<T extends CollectionResourceDocument>(doc: StructuredDataDocument<T>, data: PersistedResourceKey[], included: PersistedResourceKey[] | undefined): CollectionResourceDataDocument;
|
|
191
157
|
/**
|
|
192
158
|
* Update the "remote" or "canonical" (persisted) state of the Cache
|
|
193
159
|
* by merging new information into the existing state.
|
|
@@ -275,7 +241,7 @@ export declare class JSONAPICache implements Cache {
|
|
|
275
241
|
* utilize this method to fork the cache.
|
|
276
242
|
*
|
|
277
243
|
* @category Cache Forking
|
|
278
|
-
* @
|
|
244
|
+
* @private
|
|
279
245
|
*/
|
|
280
246
|
fork(): Promise<Cache>;
|
|
281
247
|
/**
|
|
@@ -286,7 +252,7 @@ export declare class JSONAPICache implements Cache {
|
|
|
286
252
|
* utilize this method to merge the caches.
|
|
287
253
|
*
|
|
288
254
|
* @category Cache Forking
|
|
289
|
-
* @
|
|
255
|
+
* @private
|
|
290
256
|
*/
|
|
291
257
|
merge(_cache: Cache): Promise<void>;
|
|
292
258
|
/**
|
|
@@ -320,7 +286,7 @@ export declare class JSONAPICache implements Cache {
|
|
|
320
286
|
* ```
|
|
321
287
|
*
|
|
322
288
|
* @category Cache Forking
|
|
323
|
-
* @
|
|
289
|
+
* @private
|
|
324
290
|
*/
|
|
325
291
|
diff(): Promise<Change[]>;
|
|
326
292
|
////////// =========== //////////
|
|
@@ -332,7 +298,7 @@ export declare class JSONAPICache implements Cache {
|
|
|
332
298
|
* via `cache.hydrate`.
|
|
333
299
|
*
|
|
334
300
|
* @category SSR Support
|
|
335
|
-
* @
|
|
301
|
+
* @private
|
|
336
302
|
*/
|
|
337
303
|
dump(): Promise<ReadableStream<unknown>>;
|
|
338
304
|
/**
|
|
@@ -348,7 +314,7 @@ export declare class JSONAPICache implements Cache {
|
|
|
348
314
|
* via data-only SSR modes.
|
|
349
315
|
*
|
|
350
316
|
* @category SSR Support
|
|
351
|
-
* @
|
|
317
|
+
* @private
|
|
352
318
|
*/
|
|
353
319
|
hydrate(stream: ReadableStream<unknown>): Promise<void>;
|
|
354
320
|
////////// ================== //////////
|
|
@@ -562,25 +528,4 @@ export declare class JSONAPICache implements Cache {
|
|
|
562
528
|
* @public
|
|
563
529
|
*/
|
|
564
530
|
isDeletionCommitted(identifier: ResourceKey): boolean;
|
|
565
|
-
/**
|
|
566
|
-
* Private method used to populate an entry for the identifier
|
|
567
|
-
*
|
|
568
|
-
* @internal
|
|
569
|
-
*/
|
|
570
|
-
_createCache(identifier: ResourceKey): CachedResource;
|
|
571
|
-
/**
|
|
572
|
-
* Peek whether we have cached resource data matching the identifier
|
|
573
|
-
* without asserting if the resource data is missing.
|
|
574
|
-
*
|
|
575
|
-
* @internal
|
|
576
|
-
*/
|
|
577
|
-
__safePeek(identifier: ResourceKey, allowDestroyed: boolean): CachedResource | undefined;
|
|
578
|
-
/**
|
|
579
|
-
* Peek whether we have cached resource data matching the identifier
|
|
580
|
-
* Asserts if the resource data is missing.
|
|
581
|
-
*
|
|
582
|
-
* @internal
|
|
583
|
-
*/
|
|
584
|
-
__peek(identifier: ResourceKey, allowDestroyed: boolean): CachedResource;
|
|
585
531
|
}
|
|
586
|
-
export {};
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { type Reporter } from "../utils.js";
|
|
3
|
-
/**
|
|
4
|
-
* Reports issues which violate the JSON:API spec for top-level members.
|
|
5
|
-
*
|
|
6
|
-
* Version: 1.1
|
|
7
|
-
* Section: 7.1
|
|
8
|
-
* Link: https://jsonapi.org/format/#document-top-level
|
|
9
|
-
*
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export declare function validateTopLevelDocumentMembers(reporter: Reporter, doc: ResourceDocument): void;
|
|
1
|
+
export {};
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { type Reporter } from "../utils.js";
|
|
3
|
-
/**
|
|
4
|
-
* Validates the resource objects in either the `data` or `included` members of
|
|
5
|
-
* JSON:API document.
|
|
6
|
-
*
|
|
7
|
-
* Version: 1.1
|
|
8
|
-
* Section: 7.2
|
|
9
|
-
* Link: https://jsonapi.org/format/#document-resource-objects
|
|
10
|
-
*
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export declare function validateDocumentResources(reporter: Reporter, doc: ResourceDocument): void;
|
|
1
|
+
export {};
|
|
@@ -1,23 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { CollectionResourceRelationship, ResourceObject, SingleResourceRelationship } from "@warp-drive-mirror/core/types/spec/json-api-raw";
|
|
3
|
-
import { type PathLike, type Reporter } from "../utils.js";
|
|
4
|
-
/**
|
|
5
|
-
* Validates the links object in a top-level JSON API document or resource object
|
|
6
|
-
*
|
|
7
|
-
* Version: 1.1
|
|
8
|
-
*
|
|
9
|
-
* Section: 7.1 Top Level
|
|
10
|
-
* Link: https://jsonapi.org/format/#document-top-level
|
|
11
|
-
*
|
|
12
|
-
* Section: 7.2.3 Resource Objects
|
|
13
|
-
* Link: https://jsonapi.org/format/#document-resource-object-links
|
|
14
|
-
*
|
|
15
|
-
* Section: 7.2.2.2 Resource Relationships
|
|
16
|
-
* Link: https://jsonapi.org/format/#document-resource-object-relationships
|
|
17
|
-
*
|
|
18
|
-
* Section: 7.6 Document Links
|
|
19
|
-
* Link: https://jsonapi.org/format/#document-links
|
|
20
|
-
*
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
export declare function validateLinks(reporter: Reporter, doc: ResourceDocument | ResourceObject | SingleResourceRelationship | CollectionResourceRelationship, type: "collection-document" | "resource-document" | "resource" | "resource-relationship" | "collection-relationship", path?: PathLike): void;
|
|
1
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { graphFor, peekGraph, isBelongsTo } from '@warp-drive-mirror/core/graph/-private';
|
|
2
|
-
import { logGroup, isResourceKey, isRequestKey } from '@warp-drive-mirror/core/store/-private';
|
|
2
|
+
import { logGroup, isResourceKey, assertPrivateCapabilities, isRequestKey } from '@warp-drive-mirror/core/store/-private';
|
|
3
3
|
import Fuse from 'fuse.js';
|
|
4
4
|
import jsonToAst from 'json-to-ast';
|
|
5
5
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
@@ -927,7 +927,6 @@ function validateResourceDocument(reporter, doc) {
|
|
|
927
927
|
function isImplicit(relationship) {
|
|
928
928
|
return relationship.definition.isImplicit;
|
|
929
929
|
}
|
|
930
|
-
function upgradeCapabilities(obj) {}
|
|
931
930
|
const EMPTY_ITERATOR = {
|
|
932
931
|
iterator() {
|
|
933
932
|
return {
|
|
@@ -1201,6 +1200,13 @@ class JSONAPICache {
|
|
|
1201
1200
|
|
|
1202
1201
|
/** @internal */
|
|
1203
1202
|
|
|
1203
|
+
/** @internal */
|
|
1204
|
+
|
|
1205
|
+
/** @internal */
|
|
1206
|
+
|
|
1207
|
+
/** @internal */
|
|
1208
|
+
|
|
1209
|
+
/** @internal */
|
|
1204
1210
|
_putDocument(doc, data, included) {
|
|
1205
1211
|
// @ts-expect-error narrowing within is just horrible in TS :/
|
|
1206
1212
|
const resourceDocument = isErrorDocument(doc) ? fromStructuredError(doc) : fromBaseDocument(doc);
|
|
@@ -1271,7 +1277,7 @@ class JSONAPICache {
|
|
|
1271
1277
|
logGroup('cache', 'patch', '<BATCH>', String(op.length) + ' operations', '', '');
|
|
1272
1278
|
}
|
|
1273
1279
|
}
|
|
1274
|
-
|
|
1280
|
+
assertPrivateCapabilities(this._capabilities);
|
|
1275
1281
|
this._capabilities._store._join(() => {
|
|
1276
1282
|
for (const operation of op) {
|
|
1277
1283
|
patchCache(this, operation);
|
|
@@ -1372,7 +1378,7 @@ class JSONAPICache {
|
|
|
1372
1378
|
}
|
|
1373
1379
|
});
|
|
1374
1380
|
}
|
|
1375
|
-
|
|
1381
|
+
assertPrivateCapabilities(this._capabilities);
|
|
1376
1382
|
const store = this._capabilities._store;
|
|
1377
1383
|
const attrs = getCacheFields(this, identifier);
|
|
1378
1384
|
attrs.forEach((attr, key) => {
|
|
@@ -1430,7 +1436,7 @@ class JSONAPICache {
|
|
|
1430
1436
|
}
|
|
1431
1437
|
});
|
|
1432
1438
|
}
|
|
1433
|
-
|
|
1439
|
+
assertPrivateCapabilities(this._capabilities);
|
|
1434
1440
|
const store = this._capabilities._store;
|
|
1435
1441
|
const attrs = getCacheFields(this, identifier);
|
|
1436
1442
|
attrs.forEach((attr, key) => {
|
|
@@ -1480,7 +1486,7 @@ class JSONAPICache {
|
|
|
1480
1486
|
* @return if `calculateChanges` is true then calculated key changes should be returned
|
|
1481
1487
|
*/
|
|
1482
1488
|
upsert(identifier, data, calculateChanges) {
|
|
1483
|
-
|
|
1489
|
+
assertPrivateCapabilities(this._capabilities);
|
|
1484
1490
|
const store = this._capabilities._store;
|
|
1485
1491
|
if (!store._cbs) {
|
|
1486
1492
|
let result = undefined;
|
|
@@ -1504,7 +1510,7 @@ class JSONAPICache {
|
|
|
1504
1510
|
* utilize this method to fork the cache.
|
|
1505
1511
|
*
|
|
1506
1512
|
* @category Cache Forking
|
|
1507
|
-
* @
|
|
1513
|
+
* @private
|
|
1508
1514
|
*/
|
|
1509
1515
|
fork() {
|
|
1510
1516
|
throw new Error(`Not Implemented`);
|
|
@@ -1518,7 +1524,7 @@ class JSONAPICache {
|
|
|
1518
1524
|
* utilize this method to merge the caches.
|
|
1519
1525
|
*
|
|
1520
1526
|
* @category Cache Forking
|
|
1521
|
-
* @
|
|
1527
|
+
* @private
|
|
1522
1528
|
*/
|
|
1523
1529
|
merge(_cache) {
|
|
1524
1530
|
throw new Error(`Not Implemented`);
|
|
@@ -1555,7 +1561,7 @@ class JSONAPICache {
|
|
|
1555
1561
|
* ```
|
|
1556
1562
|
*
|
|
1557
1563
|
* @category Cache Forking
|
|
1558
|
-
* @
|
|
1564
|
+
* @private
|
|
1559
1565
|
*/
|
|
1560
1566
|
diff() {
|
|
1561
1567
|
throw new Error(`Not Implemented`);
|
|
@@ -1571,7 +1577,7 @@ class JSONAPICache {
|
|
|
1571
1577
|
* via `cache.hydrate`.
|
|
1572
1578
|
*
|
|
1573
1579
|
* @category SSR Support
|
|
1574
|
-
* @
|
|
1580
|
+
* @private
|
|
1575
1581
|
*/
|
|
1576
1582
|
dump() {
|
|
1577
1583
|
throw new Error(`Not Implemented`);
|
|
@@ -1590,7 +1596,7 @@ class JSONAPICache {
|
|
|
1590
1596
|
* via data-only SSR modes.
|
|
1591
1597
|
*
|
|
1592
1598
|
* @category SSR Support
|
|
1593
|
-
* @
|
|
1599
|
+
* @private
|
|
1594
1600
|
*/
|
|
1595
1601
|
hydrate(stream) {
|
|
1596
1602
|
throw new Error('Not Implemented');
|
|
@@ -1994,7 +2000,7 @@ class JSONAPICache {
|
|
|
1994
2000
|
return cached.defaultAttrs[attribute];
|
|
1995
2001
|
} else {
|
|
1996
2002
|
const attrSchema = getCacheFields(this, identifier).get(attribute);
|
|
1997
|
-
|
|
2003
|
+
assertPrivateCapabilities(this._capabilities);
|
|
1998
2004
|
const defaultValue = getDefaultValue(attrSchema, identifier, this._capabilities._store);
|
|
1999
2005
|
if (schemaHasLegacyDefaultValueFn(attrSchema)) {
|
|
2000
2006
|
cached.defaultAttrs = cached.defaultAttrs || Object.create(null);
|
|
@@ -2061,7 +2067,7 @@ class JSONAPICache {
|
|
|
2061
2067
|
return cached.defaultAttrs[attribute];
|
|
2062
2068
|
} else {
|
|
2063
2069
|
const attrSchema = getCacheFields(this, identifier).get(attribute);
|
|
2064
|
-
|
|
2070
|
+
assertPrivateCapabilities(this._capabilities);
|
|
2065
2071
|
const defaultValue = getDefaultValue(attrSchema, identifier, this._capabilities._store);
|
|
2066
2072
|
if (schemaHasLegacyDefaultValueFn(attrSchema)) {
|
|
2067
2073
|
cached.defaultAttrs = cached.defaultAttrs || Object.create(null);
|
|
@@ -2323,7 +2329,7 @@ class JSONAPICache {
|
|
|
2323
2329
|
* @return the names of relationships that were restored
|
|
2324
2330
|
*/
|
|
2325
2331
|
rollbackRelationships(identifier) {
|
|
2326
|
-
|
|
2332
|
+
assertPrivateCapabilities(this._capabilities);
|
|
2327
2333
|
let result;
|
|
2328
2334
|
this._capabilities._store._join(() => {
|
|
2329
2335
|
result = this.__graph.rollback(identifier);
|
|
@@ -2821,6 +2827,7 @@ function recordIsLoaded(cached, filterDeleted = false) {
|
|
|
2821
2827
|
return filterDeleted && cached.isDeletionCommitted ? false : !isEmpty;
|
|
2822
2828
|
}
|
|
2823
2829
|
function _isLoading(peeked, capabilities, identifier) {
|
|
2830
|
+
assertPrivateCapabilities(capabilities);
|
|
2824
2831
|
// TODO refactor things such that the cache is not required to know
|
|
2825
2832
|
// about isLoading
|
|
2826
2833
|
const req = capabilities._store.getRequestStateService();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warp-drive-mirror/json-api",
|
|
3
|
-
"version": "5.7.0-alpha.
|
|
3
|
+
"version": "5.7.0-alpha.29",
|
|
4
4
|
"description": "A {JSON:API} Cache Implementation for WarpDrive",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@warp-drive-mirror/core": "5.7.0-alpha.
|
|
35
|
+
"@warp-drive-mirror/core": "5.7.0-alpha.29"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@embroider/macros": "^1.16.12",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"@babel/plugin-transform-typescript": "^7.27.0",
|
|
45
45
|
"@babel/preset-typescript": "^7.27.0",
|
|
46
46
|
"@types/json-to-ast": "^2.1.4",
|
|
47
|
-
"@warp-drive/internal-config": "5.7.0-alpha.
|
|
48
|
-
"@warp-drive-mirror/core": "5.7.0-alpha.
|
|
47
|
+
"@warp-drive/internal-config": "5.7.0-alpha.29",
|
|
48
|
+
"@warp-drive-mirror/core": "5.7.0-alpha.29",
|
|
49
49
|
"decorator-transforms": "^2.3.0",
|
|
50
50
|
"expect-type": "^1.2.1",
|
|
51
51
|
"typescript": "^5.8.3",
|