@warp-drive/json-api 5.9.0-beta.0 → 5.9.0-beta.1

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/CHANGELOG.md CHANGED
@@ -1 +1,110 @@
1
1
  # @warp-drive/json-api changelog
2
+
3
+ ## v5.8.0 (2025-10-07)
4
+
5
+ #### :house: Internal
6
+
7
+ * [#10349](https://github.com/warp-drive-data/warp-drive/pull/10349) chore: update all emberjs/data links to warp-drive-data/warp-drive ([@runspired](https://github.com/runspired))
8
+
9
+ #### Committers: (1)
10
+
11
+ Chris Thoburn ([@runspired](https://github.com/runspired))
12
+
13
+ ## v5.7.0 (2025-08-26)
14
+
15
+ #### :memo: Documentation
16
+
17
+ * [#10295](https://github.com/warp-drive-data/warp-drive/pull/10295) Update json-api.org URLs to jsonapi.org ([@Copilot](https://github.com/apps/copilot-swe-agent))
18
+
19
+ #### :house: Internal
20
+
21
+ * [#10130](https://github.com/warp-drive-data/warp-drive/pull/10130) chore: bump pnpm version ([@runspired](https://github.com/runspired))
22
+ * [#10124](https://github.com/warp-drive-data/warp-drive/pull/10124) chore: mark a few types as private ([@runspired](https://github.com/runspired))
23
+
24
+ #### Committers: (2)
25
+
26
+
27
+ Chris Thoburn ([@runspired](https://github.com/runspired))
28
+
29
+ ## v5.6.0 (2025-07-01)
30
+
31
+ #### :memo: Documentation
32
+
33
+ * [#9991](https://github.com/warp-drive-data/warp-drive/pull/9991) chore: improve output of typedoc ([@runspired](https://github.com/runspired))
34
+ * [#9989](https://github.com/warp-drive-data/warp-drive/pull/9989) [BREAKING] docs: integrate API docs to the new docs site ([@runspired](https://github.com/runspired))
35
+ * [#9983](https://github.com/warp-drive-data/warp-drive/pull/9983) feat: revamp guide, make builder typing easier ([@runspired](https://github.com/runspired))
36
+
37
+ #### :rocket: Enhancement
38
+
39
+ * [#10011](https://github.com/warp-drive-data/warp-drive/pull/10011) feat: @warp-drive/core/build-config ([@runspired](https://github.com/runspired))
40
+ * [#10003](https://github.com/warp-drive-data/warp-drive/pull/10003) feat: @warp-drive/json-api ([@runspired](https://github.com/runspired))
41
+
42
+ #### :house: Internal
43
+
44
+ * [#10042](https://github.com/warp-drive-data/warp-drive/pull/10042) chore: upgrade to vite7 ([@runspired](https://github.com/runspired))
45
+ * [#10040](https://github.com/warp-drive-data/warp-drive/pull/10040) chore: isolated declarations ([@runspired](https://github.com/runspired))
46
+ * [#10039](https://github.com/warp-drive-data/warp-drive/pull/10039) chore: bump pnpm ([@runspired](https://github.com/runspired))
47
+
48
+ #### Committers: (1)
49
+
50
+ Chris Thoburn ([@runspired](https://github.com/runspired))
51
+
52
+ ## v5.5.0 (2025-05-08)
53
+
54
+ #### :memo: Documentation
55
+
56
+ * [#9975](https://github.com/warp-drive-data/warp-drive/pull/9975) types: fixup PolarisMode schema types to check better ([@runspired](https://github.com/runspired))
57
+
58
+ #### :rocket: Enhancement
59
+
60
+ * [#9965](https://github.com/warp-drive-data/warp-drive/pull/9965) feat: universal reactivity hooks ([@runspired](https://github.com/runspired))
61
+
62
+ #### :house: Internal
63
+
64
+ * [#9965](https://github.com/warp-drive-data/warp-drive/pull/9965) feat: universal reactivity hooks ([@runspired](https://github.com/runspired))
65
+
66
+ #### Committers: (1)
67
+
68
+ Chris Thoburn ([@runspired](https://github.com/runspired))
69
+
70
+ ## v5.4.0 (2025-04-11)
71
+
72
+ #### :memo: Documentation
73
+
74
+ * [#9472](https://github.com/warp-drive-data/warp-drive/pull/9472) fix: code snippet in json-api/request api docs ([@MehulKChaudhari](https://github.com/MehulKChaudhari))
75
+
76
+ #### :rocket: Enhancement
77
+
78
+ * [#9884](https://github.com/warp-drive-data/warp-drive/pull/9884) feat: cache patch operations for relationships and documents ([@runspired](https://github.com/runspired))
79
+ * [#9896](https://github.com/warp-drive-data/warp-drive/pull/9896) feat: whoa debugging ([@runspired](https://github.com/runspired))
80
+ * [#9769](https://github.com/warp-drive-data/warp-drive/pull/9769) chore: remove restriction on new field kinds being used with legacy mode ([@runspired](https://github.com/runspired))
81
+ * [#9676](https://github.com/warp-drive-data/warp-drive/pull/9676) Feat: hasMany linksMode ([@leoeuclids](https://github.com/leoeuclids))
82
+ * [#9686](https://github.com/warp-drive-data/warp-drive/pull/9686) feat: immutable records should show only remote state, make builder types more useful ([@runspired](https://github.com/runspired))
83
+ * [#9687](https://github.com/warp-drive-data/warp-drive/pull/9687) feat: add patchRecord util to JSON:API ([@runspired](https://github.com/runspired))
84
+ * [#9585](https://github.com/warp-drive-data/warp-drive/pull/9585) chore: stub out linksMode work ([@runspired](https://github.com/runspired))
85
+ * [#9541](https://github.com/warp-drive-data/warp-drive/pull/9541) feat: eslint-plugin-(ember-data|warp-drive) ([@runspired](https://github.com/runspired))
86
+
87
+ #### :bug: Bug Fix
88
+
89
+ * [#9698](https://github.com/warp-drive-data/warp-drive/pull/9698) fix: Don't notify changes for attributes not registered with the schema ([@gitKrystan](https://github.com/gitKrystan))
90
+ * [#9692](https://github.com/warp-drive-data/warp-drive/pull/9692) fix: make serialize utils smarter ([@runspired](https://github.com/runspired))
91
+
92
+ #### :house: Internal
93
+
94
+ * [#9780](https://github.com/warp-drive-data/warp-drive/pull/9780) chore: bump @glimmer/component ([@runspired](https://github.com/runspired))
95
+ * [#9761](https://github.com/warp-drive-data/warp-drive/pull/9761) chore: reduce simple Map/Set ops ([@runspired](https://github.com/runspired))
96
+ * [#9759](https://github.com/warp-drive-data/warp-drive/pull/9759) chore: Improve contributing experience ([@runspired](https://github.com/runspired))
97
+ * [#9752](https://github.com/warp-drive-data/warp-drive/pull/9752) chore: tooling upgrades to support WarpDrive package unification ([@runspired](https://github.com/runspired))
98
+ * [#9705](https://github.com/warp-drive-data/warp-drive/pull/9705) chore: make diagnostic shutdown safer, use bun for holodeck server ([@runspired](https://github.com/runspired))
99
+ * [#9699](https://github.com/warp-drive-data/warp-drive/pull/9699) chore: update to pnpm 10 ([@runspired](https://github.com/runspired))
100
+ * [#9629](https://github.com/warp-drive-data/warp-drive/pull/9629) fix: restore * versions and setup publish to not overwrite them ([@runspired](https://github.com/runspired))
101
+ * [#9620](https://github.com/warp-drive-data/warp-drive/pull/9620) Starwars ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
102
+ * [#9596](https://github.com/warp-drive-data/warp-drive/pull/9596) chore: Remove unused `--report-unused-disable-directives` flag ([@gitKrystan](https://github.com/gitKrystan))
103
+
104
+ #### Committers: (5)
105
+
106
+ Mehul Kiran Chaudhari ([@MehulKChaudhari](https://github.com/MehulKChaudhari))
107
+ Chris Thoburn ([@runspired](https://github.com/runspired))
108
+ Leo Euclides ([@leoeuclids](https://github.com/leoeuclids))
109
+ Krystan HuffMenne ([@gitKrystan](https://github.com/gitKrystan))
110
+ [@NullVoxPopuli](https://github.com/NullVoxPopuli)
package/README.md CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  # @warp-drive/json-api
20
20
 
21
- A {json:api} Cache Implementation for ***Warp*Drive**.
21
+ A [{json:api}](https://jsonapi.org) Cache Implementation for ***Warp*Drive**.
22
22
 
23
23
  `{json:api}` excels at simplifying common complex problems around cache consistency and information density, especially in regards to relational or polymorphic data.
24
24
 
@@ -1,5 +1,515 @@
1
+ import { Graph } from "@warp-drive/core/graph/-private";
2
+ import { CacheCapabilitiesManager } from "@warp-drive/core/types";
3
+ import { Cache, ChangedAttributesHash, RelationshipDiff } from "@warp-drive/core/types/cache";
4
+ import { Change } from "@warp-drive/core/types/cache/change";
5
+ import { Operation } from "@warp-drive/core/types/cache/operations";
6
+ import { CollectionRelationship, ResourceRelationship } from "@warp-drive/core/types/cache/relationship";
7
+ import { LocalRelationshipOperation } from "@warp-drive/core/types/graph";
8
+ import { RequestKey, ResourceKey } from "@warp-drive/core/types/identifier";
9
+ import { Value } from "@warp-drive/core/types/json/raw";
10
+ import { RequestContext, StructuredDataDocument, StructuredDocument, StructuredErrorDocument } from "@warp-drive/core/types/request";
11
+ import { CollectionResourceDataDocument, ResourceDocument, ResourceErrorDocument, ResourceMetaDocument, SingleResourceDataDocument } from "@warp-drive/core/types/spec/document";
12
+ import { ApiError } from "@warp-drive/core/types/spec/error";
13
+ import { CollectionResourceDocument, ExistingResourceObject, ResourceObject, SingleResourceDocument } from "@warp-drive/core/types/spec/json-api-raw";
14
+ //#region src/-private/cache.d.ts
15
+ interface CachedResource {
16
+ id: string | null;
17
+ remoteAttrs: Record<string, Value | undefined> | null;
18
+ localAttrs: Record<string, Value | undefined> | null;
19
+ defaultAttrs: Record<string, Value | undefined> | null;
20
+ inflightAttrs: Record<string, Value | undefined> | null;
21
+ changes: Record<string, [Value | undefined, Value]> | null;
22
+ errors: ApiError[] | null;
23
+ isNew: boolean;
24
+ isDeleted: boolean;
25
+ isDeletionCommitted: boolean;
26
+ /**
27
+ * debugging only
28
+ *
29
+ * @internal
30
+ */
31
+ inflightRelationships?: Record<string, unknown> | null;
32
+ }
1
33
  /**
2
- * @module
3
- * @mergeModuleWith <project>
4
- */
5
- export { JSONAPICache } from "./-private/cache.js";
34
+ * ```ts
35
+ * import { JSONAPICache } from '@warp-drive/json-api';
36
+ * ```
37
+ *
38
+ * A {@link Cache} implementation tuned for [{json:api}](https://jsonapi.org/)
39
+ *
40
+ * @categoryDescription Cache Management
41
+ * APIs for primary cache management functionality
42
+ * @categoryDescription Cache Forking
43
+ * APIs that support Cache Forking
44
+ * @categoryDescription SSR Support
45
+ * APIs that support SSR functionality
46
+ * @categoryDescription Resource Lifecycle
47
+ * APIs that support management of resource data
48
+ * @categoryDescription Resource Data
49
+ * APIs that support granular field level management of resource data
50
+ * @categoryDescription Resource State
51
+ * APIs that support managing Resource states
52
+ *
53
+ * @public
54
+ */
55
+ declare class JSONAPICache implements Cache {
56
+ /**
57
+ * The Cache Version that this implementation implements.
58
+ *
59
+ * @public
60
+ */
61
+ version: "2";
62
+ /** @internal */
63
+ _capabilities: CacheCapabilitiesManager;
64
+ /** @internal */
65
+ __cache: Map<ResourceKey, CachedResource>;
66
+ /** @internal */
67
+ __destroyedCache: Map<ResourceKey, CachedResource>;
68
+ /** @internal */
69
+ __documents: Map<string, StructuredDocument<ResourceDocument>>;
70
+ /** @internal */
71
+ __graph: Graph;
72
+ constructor(capabilities: CacheCapabilitiesManager);
73
+ /**
74
+ * Cache the response to a request
75
+ *
76
+ * Implements `Cache.put`.
77
+ *
78
+ * Expects a StructuredDocument whose `content` member is a JsonApiDocument.
79
+ *
80
+ * ```js
81
+ * cache.put({
82
+ * request: { url: 'https://api.example.com/v1/user/1' },
83
+ * content: {
84
+ * data: {
85
+ * type: 'user',
86
+ * id: '1',
87
+ * attributes: {
88
+ * name: 'Chris'
89
+ * }
90
+ * }
91
+ * }
92
+ * })
93
+ * ```
94
+ *
95
+ * > **Note**
96
+ * > The nested `content` and `data` members are not a mistake. This is because
97
+ * > there are two separate concepts involved here, the `StructuredDocument` which contains
98
+ * > the context of a given Request that has been issued with the returned contents as its
99
+ * > `content` property, and a `JSON:API Document` which is the json contents returned by
100
+ * > this endpoint and which uses its `data` property to signify which resources are the
101
+ * > primary resources associated with the request.
102
+ *
103
+ * StructuredDocument's with urls will be cached as full documents with
104
+ * associated resource membership order and contents preserved but linked
105
+ * into the cache.
106
+ *
107
+ * @category Cache Management
108
+ * @public
109
+ */
110
+ put<T extends SingleResourceDocument>(doc: StructuredDataDocument<T>): SingleResourceDataDocument;
111
+ put<T extends CollectionResourceDocument>(doc: StructuredDataDocument<T>): CollectionResourceDataDocument;
112
+ put<T extends ResourceErrorDocument>(doc: StructuredErrorDocument<T>): ResourceErrorDocument;
113
+ put<T extends ResourceMetaDocument>(doc: StructuredDataDocument<T>): ResourceMetaDocument;
114
+ /** @internal */
115
+ private _putDocument;
116
+ /** @internal */
117
+ private _putDocument;
118
+ /** @internal */
119
+ private _putDocument;
120
+ /** @internal */
121
+ private _putDocument;
122
+ /**
123
+ * Update the "remote" or "canonical" (persisted) state of the Cache
124
+ * by merging new information into the existing state.
125
+ *
126
+ * @category Cache Management
127
+ * @public
128
+ * @param op the operation or list of operations to perform
129
+ */
130
+ patch(op: Operation | Operation[]): void;
131
+ /**
132
+ * Update the "local" or "current" (unpersisted) state of the Cache
133
+ *
134
+ * @category Cache Management
135
+ * @public
136
+ */
137
+ mutate(mutation: LocalRelationshipOperation): void;
138
+ /**
139
+ * Peek resource data from the Cache.
140
+ *
141
+ * In development, if the return value
142
+ * is JSON the return value
143
+ * will be deep-cloned and deep-frozen
144
+ * to prevent mutation thereby enforcing cache
145
+ * Immutability.
146
+ *
147
+ * This form of peek is useful for implementations
148
+ * that want to feed raw-data from cache to the UI
149
+ * or which want to interact with a blob of data
150
+ * directly from the presentation cache.
151
+ *
152
+ * An implementation might want to do this because
153
+ * de-referencing records which read from their own
154
+ * blob is generally safer because the record does
155
+ * not require retainining connections to the Store
156
+ * and Cache to present data on a per-field basis.
157
+ *
158
+ * This generally takes the place of `getAttr` as
159
+ * an API and may even take the place of `getRelationship`
160
+ * depending on implementation specifics, though this
161
+ * latter usage is less recommended due to the advantages
162
+ * of the Graph handling necessary entanglements and
163
+ * notifications for relational data.
164
+ *
165
+ * :::warning
166
+ * It is not recommended to use the return value as
167
+ * a serialized representation of the resource both
168
+ * due to it containing local mutations and because
169
+ * it may contain additional fields not recognized
170
+ * by the {json:api} API implementation such as `lid` and
171
+ * the various internal WarpDrive bookkeeping fields.
172
+ * :::
173
+ *
174
+ * @category Cache Management
175
+ * @public
176
+ */
177
+ peek(identifier: ResourceKey): ResourceObject | null;
178
+ peek(identifier: RequestKey): ResourceDocument | null;
179
+ /**
180
+ * Peek the remote resource data from the Cache.
181
+ *
182
+ * @category Cache Management
183
+ * @public
184
+ */
185
+ peekRemoteState(identifier: ResourceKey): ResourceObject | null;
186
+ peekRemoteState(identifier: RequestKey): ResourceDocument | null;
187
+ /**
188
+ * Peek the Cache for the existing request data associated with
189
+ * a cacheable request.
190
+ *
191
+ * This is effectively the reverse of `put` for a request in
192
+ * that it will return the the request, response, and content
193
+ * whereas `peek` will return just the `content`.
194
+ *
195
+ * @category Cache Management
196
+ * @public
197
+ */
198
+ peekRequest(identifier: RequestKey): StructuredDocument<ResourceDocument> | null;
199
+ /**
200
+ * Push resource data from a remote source into the cache for this identifier
201
+ *
202
+ * @category Cache Management
203
+ * @public
204
+ * @return if `calculateChanges` is true then calculated key changes should be returned
205
+ */
206
+ upsert(identifier: ResourceKey, data: ExistingResourceObject, calculateChanges?: boolean): void | string[];
207
+ /**
208
+ * Create a fork of the cache from the current state.
209
+ *
210
+ * Applications should typically not call this method themselves,
211
+ * preferring instead to fork at the Store level, which will
212
+ * utilize this method to fork the cache.
213
+ *
214
+ * @category Cache Forking
215
+ * @private
216
+ */
217
+ fork(): Promise<Cache>;
218
+ /**
219
+ * Merge a fork back into a parent Cache.
220
+ *
221
+ * Applications should typically not call this method themselves,
222
+ * preferring instead to merge at the Store level, which will
223
+ * utilize this method to merge the caches.
224
+ *
225
+ * @category Cache Forking
226
+ * @private
227
+ */
228
+ merge(_cache: Cache): Promise<void>;
229
+ /**
230
+ * Generate the list of changes applied to all
231
+ * record in the store.
232
+ *
233
+ * Each individual resource or document that has
234
+ * been mutated should be described as an individual
235
+ * `Change` entry in the returned array.
236
+ *
237
+ * A `Change` is described by an object containing up to
238
+ * three properties: (1) the `identifier` of the entity that
239
+ * changed; (2) the `op` code of that change being one of
240
+ * `upsert` or `remove`, and if the op is `upsert` a `patch`
241
+ * containing the data to merge into the cache for the given
242
+ * entity.
243
+ *
244
+ * This `patch` is opaque to the Store but should be understood
245
+ * by the Cache and may expect to be utilized by an Adapter
246
+ * when generating data during a `save` operation.
247
+ *
248
+ * It is generally recommended that the `patch` contain only
249
+ * the updated state, ignoring fields that are unchanged
250
+ *
251
+ * ```ts
252
+ * interface Change {
253
+ * identifier: ResourceKey | RequestKey;
254
+ * op: 'upsert' | 'remove';
255
+ * patch?: unknown;
256
+ * }
257
+ * ```
258
+ *
259
+ * @category Cache Forking
260
+ * @private
261
+ */
262
+ diff(): Promise<Change[]>;
263
+ /**
264
+ * Serialize the entire contents of the Cache into a Stream
265
+ * which may be fed back into a new instance of the same Cache
266
+ * via `cache.hydrate`.
267
+ *
268
+ * @category SSR Support
269
+ * @private
270
+ */
271
+ dump(): Promise<ReadableStream<unknown>>;
272
+ /**
273
+ * hydrate a Cache from a Stream with content previously serialized
274
+ * from another instance of the same Cache, resolving when hydration
275
+ * is complete.
276
+ *
277
+ * This method should expect to be called both in the context of restoring
278
+ * the Cache during application rehydration after SSR **AND** at unknown
279
+ * times during the lifetime of an already booted application when it is
280
+ * desired to bulk-load additional information into the cache. This latter
281
+ * behavior supports optimizing pre/fetching of data for route transitions
282
+ * via data-only SSR modes.
283
+ *
284
+ * @category SSR Support
285
+ * @private
286
+ */
287
+ hydrate(stream: ReadableStream<unknown>): Promise<void>;
288
+ /**
289
+ * [LIFECYCLE] Signal to the cache that a new record has been instantiated on the client
290
+ *
291
+ * It returns properties from options that should be set on the record during the create
292
+ * process. This return value behavior is deprecated.
293
+ *
294
+ * @category Resource Lifecycle
295
+ * @public
296
+ */
297
+ clientDidCreate(identifier: ResourceKey, options?: Record<string, Value>): Record<string, unknown>;
298
+ /**
299
+ * [LIFECYCLE] Signals to the cache that a resource
300
+ * will be part of a save transaction.
301
+ *
302
+ * @category Resource Lifecycle
303
+ * @public
304
+ */
305
+ willCommit(identifier: ResourceKey | ResourceKey[], _context: RequestContext | null): void;
306
+ /**
307
+ * [LIFECYCLE] Signals to the cache that a resource
308
+ * was successfully updated as part of a save transaction.
309
+ *
310
+ * @category Resource Lifecycle
311
+ * @public
312
+ */
313
+ didCommit(committedIdentifier: ResourceKey, result: StructuredDataDocument<SingleResourceDataDocument> | null): SingleResourceDataDocument;
314
+ didCommit(committedIdentifier: ResourceKey[], result: StructuredDataDocument<SingleResourceDataDocument> | null): SingleResourceDataDocument;
315
+ didCommit(committedIdentifier: ResourceKey[], result: StructuredDataDocument<CollectionResourceDataDocument> | null): CollectionResourceDataDocument;
316
+ /**
317
+ * [LIFECYCLE] Signals to the cache that a resource
318
+ * was update via a save transaction failed.
319
+ *
320
+ * @category Resource Lifecycle
321
+ * @public
322
+ */
323
+ commitWasRejected(identifier: ResourceKey | ResourceKey[], errors?: ApiError[]): void;
324
+ /**
325
+ * [LIFECYCLE] Signals to the cache that all data for a resource
326
+ * should be cleared.
327
+ *
328
+ * This method is a candidate to become a mutation
329
+ *
330
+ * @category Resource Lifecycle
331
+ * @public
332
+ */
333
+ unloadRecord(identifier: ResourceKey): void;
334
+ /**
335
+ * Retrieve the data for an attribute from the cache
336
+ * with local mutations applied.
337
+ *
338
+ * @category Resource Data
339
+ * @public
340
+ */
341
+ getAttr(identifier: ResourceKey, attr: string | string[]): Value | undefined;
342
+ /**
343
+ * Retrieve the remote data for an attribute from the cache
344
+ *
345
+ * @category Resource Data
346
+ * @public
347
+ */
348
+ getRemoteAttr(identifier: ResourceKey, attr: string | string[]): Value | undefined;
349
+ /**
350
+ * Mutate the data for an attribute in the cache
351
+ *
352
+ * This method is a candidate to become a mutation
353
+ *
354
+ * @category Resource Data
355
+ * @public
356
+ */
357
+ setAttr(identifier: ResourceKey, attr: string | string[], value: Value): void;
358
+ /**
359
+ * Query the cache for the changed attributes of a resource.
360
+ *
361
+ * @category Resource Data
362
+ * @public
363
+ * @return `{ '<field>': ['<old>', '<new>'] }`
364
+ */
365
+ changedAttrs(identifier: ResourceKey): ChangedAttributesHash;
366
+ /**
367
+ * Query the cache for whether any mutated attributes exist
368
+ *
369
+ * @category Resource Data
370
+ * @public
371
+ */
372
+ hasChangedAttrs(identifier: ResourceKey): boolean;
373
+ /**
374
+ * Tell the cache to discard any uncommitted mutations to attributes
375
+ *
376
+ * This method is a candidate to become a mutation
377
+ *
378
+ * @category Resource Data
379
+ * @public
380
+ * @return the names of fields that were restored
381
+ */
382
+ rollbackAttrs(identifier: ResourceKey): string[];
383
+ /**
384
+ * Query the cache for the changes to relationships of a resource.
385
+ *
386
+ * Returns a map of relationship names to RelationshipDiff objects.
387
+ *
388
+ * ```ts
389
+ * type RelationshipDiff =
390
+ | {
391
+ kind: 'collection';
392
+ remoteState: ResourceKey[];
393
+ additions: Set<ResourceKey>;
394
+ removals: Set<ResourceKey>;
395
+ localState: ResourceKey[];
396
+ reordered: boolean;
397
+ }
398
+ | {
399
+ kind: 'resource';
400
+ remoteState: ResourceKey | null;
401
+ localState: ResourceKey | null;
402
+ };
403
+ ```
404
+ *
405
+ * @category Resource Data
406
+ * @public
407
+ */
408
+ changedRelationships(identifier: ResourceKey): Map<string, RelationshipDiff>;
409
+ /**
410
+ * Query the cache for whether any mutated relationships exist
411
+ *
412
+ * @category Resource Data
413
+ * @public
414
+ */
415
+ hasChangedRelationships(identifier: ResourceKey): boolean;
416
+ /**
417
+ * Tell the cache to discard any uncommitted mutations to relationships.
418
+ *
419
+ * This will also discard the change on any appropriate inverses.
420
+ *
421
+ * This method is a candidate to become a mutation
422
+ *
423
+ * @category Resource Data
424
+ * @public
425
+ * @return the names of relationships that were restored
426
+ */
427
+ rollbackRelationships(identifier: ResourceKey): string[];
428
+ /**
429
+ * Query the cache for the current state of a relationship property
430
+ *
431
+ * @category Resource Data
432
+ * @public
433
+ * @return resource relationship object
434
+ */
435
+ getRelationship(identifier: ResourceKey, field: string): ResourceRelationship | CollectionRelationship;
436
+ /**
437
+ * Query the cache for the remote state of a relationship property
438
+ *
439
+ * @category Resource Data
440
+ * @public
441
+ * @return resource relationship object
442
+ */
443
+ getRemoteRelationship(identifier: ResourceKey, field: string): ResourceRelationship | CollectionRelationship;
444
+ /**
445
+ * Update the cache state for the given resource to be marked
446
+ * as locally deleted, or remove such a mark.
447
+ *
448
+ * This method is a candidate to become a mutation
449
+ *
450
+ * @category Resource State
451
+ * @public
452
+ */
453
+ setIsDeleted(identifier: ResourceKey, isDeleted: boolean): void;
454
+ /**
455
+ * Query the cache for any validation errors applicable to the given resource.
456
+ *
457
+ * @category Resource State
458
+ * @public
459
+ */
460
+ getErrors(identifier: ResourceKey): ApiError[];
461
+ /**
462
+ * Query the cache for whether a given resource has any available data
463
+ *
464
+ * @category Resource State
465
+ * @public
466
+ */
467
+ isEmpty(identifier: ResourceKey): boolean;
468
+ /**
469
+ * Query the cache for whether a given resource was created locally and not
470
+ * yet persisted.
471
+ *
472
+ * @category Resource State
473
+ * @public
474
+ */
475
+ isNew(identifier: ResourceKey): boolean;
476
+ /**
477
+ * Query the cache for whether a given resource is marked as deleted (but not
478
+ * necessarily persisted yet).
479
+ *
480
+ * @category Resource State
481
+ * @public
482
+ */
483
+ isDeleted(identifier: ResourceKey): boolean;
484
+ /**
485
+ * Query the cache for whether a given resource has been deleted and that deletion
486
+ * has also been persisted.
487
+ *
488
+ * @category Resource State
489
+ * @public
490
+ */
491
+ isDeletionCommitted(identifier: ResourceKey): boolean;
492
+ /**
493
+ * Private method used to populate an entry for the identifier
494
+ *
495
+ * @internal
496
+ */
497
+ _createCache(identifier: ResourceKey): CachedResource;
498
+ /**
499
+ * Peek whether we have cached resource data matching the identifier
500
+ * without asserting if the resource data is missing.
501
+ *
502
+ * @internal
503
+ */
504
+ __safePeek(identifier: ResourceKey, allowDestroyed: boolean): CachedResource | undefined;
505
+ /**
506
+ * Peek whether we have cached resource data matching the identifier
507
+ * Asserts if the resource data is missing.
508
+ *
509
+ * @internal
510
+ */
511
+ __peek(identifier: ResourceKey, allowDestroyed: boolean): CachedResource;
512
+ }
513
+ //#endregion
514
+ export { JSONAPICache };
515
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/-private/cache.ts"],"mappings":";;;;;;;;;;;;;;UAkFU;EACR;EACA,aAAa,eAAe;EAC5B,YAAY,eAAe;EAC3B,cAAc,eAAe;EAC7B,eAAe,eAAe;EAC9B,SAAS,gBAAgB,mBAAmB;EAC5C,QAAQ;EACR;EACA;EACA;;;;;;EAOA,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;cAwCb,wBAAwB;;;;;;EAMnC;;EAGA,eAAuB;;EAEvB,SAAiB,IAAI,aAAa;;EAElC,kBAA0B,IAAI,a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