@warp-drive-mirror/json-api 5.6.0-alpha.11

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/LICENSE.md +23 -0
  3. package/README.md +54 -0
  4. package/addon-main.cjs +5 -0
  5. package/declarations/-private/cache.d.ts +514 -0
  6. package/declarations/-private/cache.d.ts.map +1 -0
  7. package/declarations/-private/validate-document-fields.d.ts +4 -0
  8. package/declarations/-private/validate-document-fields.d.ts.map +1 -0
  9. package/declarations/-private/validator/1.1/7.1_top-level-document-members.d.ts +13 -0
  10. package/declarations/-private/validator/1.1/7.1_top-level-document-members.d.ts.map +1 -0
  11. package/declarations/-private/validator/1.1/7.2_resource-objects.d.ts +14 -0
  12. package/declarations/-private/validator/1.1/7.2_resource-objects.d.ts.map +1 -0
  13. package/declarations/-private/validator/1.1/links.d.ts +24 -0
  14. package/declarations/-private/validator/1.1/links.d.ts.map +1 -0
  15. package/declarations/-private/validator/index.d.ts +5 -0
  16. package/declarations/-private/validator/index.d.ts.map +1 -0
  17. package/declarations/-private/validator/utils.d.ts +76 -0
  18. package/declarations/-private/validator/utils.d.ts.map +1 -0
  19. package/declarations/index.d.ts +85 -0
  20. package/declarations/index.d.ts.map +1 -0
  21. package/dist/index.js +3157 -0
  22. package/dist/index.js.map +1 -0
  23. package/logos/NCC-1701-a-blue.svg +4 -0
  24. package/logos/NCC-1701-a-gold.svg +4 -0
  25. package/logos/NCC-1701-a-gold_100.svg +1 -0
  26. package/logos/NCC-1701-a-gold_base-64.txt +1 -0
  27. package/logos/NCC-1701-a.svg +4 -0
  28. package/logos/README.md +4 -0
  29. package/logos/docs-badge.svg +2 -0
  30. package/logos/ember-data-logo-dark.svg +12 -0
  31. package/logos/ember-data-logo-light.svg +12 -0
  32. package/logos/github-header.svg +444 -0
  33. package/logos/social1.png +0 -0
  34. package/logos/social2.png +0 -0
  35. package/logos/warp-drive-logo-dark.svg +4 -0
  36. package/logos/warp-drive-logo-gold.svg +4 -0
  37. package/package.json +71 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ # @warp-drive-mirror/json-api changelog
package/LICENSE.md ADDED
@@ -0,0 +1,23 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017-2025 Ember.js and contributors
4
+ Copyright (c) 2011-2017 Tilde, Inc. and contributors
5
+ Copyright (c) 2011 LivingSocial Inc.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ <h1 align="center">
2
+ <img
3
+ class="project-logo"
4
+ src="./logos/github-header.svg#gh-light-mode-only"
5
+ alt="WarpDrive | Boldly go where no app has gone before"
6
+ title="WarpDrive | Boldly go where no app has gone before"
7
+ />
8
+ <img
9
+ class="project-logo"
10
+ src="./logos/github-header.svg#gh-dark-mode-only"
11
+ alt="WarpDrive | Boldly go where no app has gone before"
12
+ title="WarpDrive | Boldly go where no app has gone before"
13
+ />
14
+ </h1>
15
+
16
+ ![NPM Stable Version](https://img.shields.io/npm/v/ember-data/latest?label=version&style=flat&color=FFC474)
17
+ ![NPM Downloads](https://img.shields.io/npm/dm/ember-data.svg?style=flat&color=FFC474)
18
+ ![License](https://img.shields.io/github/license/emberjs/data.svg?style=flat&color=FFC474)
19
+ [![Docs](./logos/docs-badge.svg)](https://docs.warp-drive.io)
20
+ [![Discord Community Server](https://img.shields.io/badge/Discord-grey?logo=discord&logoColor=FFC474)](https://discord.gg/zT3asNS
21
+ )
22
+
23
+ <br>
24
+
25
+ <p align="center">
26
+ A {JSON:API} Cache Implementation for <em>Warp</em><strong>Drive</strong>.
27
+ </p>
28
+
29
+ <br>
30
+
31
+ ## Installation
32
+
33
+ ```sh
34
+ pnpm add -E @warp-drive-mirror/json-api
35
+ ```
36
+
37
+ <br>
38
+
39
+ ## Documentation
40
+
41
+ *Get Started* → [Guides](https://docs.warp-drive.io)
42
+
43
+
44
+ <br>
45
+
46
+ ## Code of Conduct
47
+
48
+ Refer to the [Code of Conduct](https://github.com/emberjs/data/blob/main/CODE_OF_CONDUCT.md) for community guidelines and inclusivity.
49
+
50
+ <br>
51
+
52
+ ### License
53
+
54
+ This project is licensed under the [MIT License](LICENSE.md).
package/addon-main.cjs ADDED
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const { addonShim } = require('@warp-drive-mirror/core/addon-shim.cjs');
4
+
5
+ module.exports = addonShim(__dirname);
@@ -0,0 +1,514 @@
1
+ import type { Graph } from '@warp-drive-mirror/core/graph/-private';
2
+ import type { CacheCapabilitiesManager } from '@warp-drive-mirror/core/types';
3
+ import type { Cache, ChangedAttributesHash, RelationshipDiff } from '@warp-drive-mirror/core/types/cache';
4
+ import type { Change } from '@warp-drive-mirror/core/types/cache/change';
5
+ import type { Operation } from '@warp-drive-mirror/core/types/cache/operations';
6
+ import type { CollectionRelationship, ResourceRelationship } from '@warp-drive-mirror/core/types/cache/relationship';
7
+ import type { LocalRelationshipOperation } from '@warp-drive-mirror/core/types/graph';
8
+ import type { StableDocumentIdentifier, StableExistingRecordIdentifier, StableRecordIdentifier } from '@warp-drive-mirror/core/types/identifier';
9
+ import type { Value } from '@warp-drive-mirror/core/types/json/raw';
10
+ import type { StructuredDataDocument, StructuredDocument, StructuredErrorDocument } from '@warp-drive-mirror/core/types/request';
11
+ import type { CollectionResourceDataDocument, ResourceDocument, ResourceErrorDocument, ResourceMetaDocument, SingleResourceDataDocument } from '@warp-drive-mirror/core/types/spec/document';
12
+ import type { ApiError } from '@warp-drive-mirror/core/types/spec/error';
13
+ 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
+ /**
33
+ A JSON:API Cache implementation.
34
+
35
+ What cache the store uses is configurable. Using a different
36
+ implementation can be achieved by implementing the store's
37
+ createCache hook.
38
+
39
+ This is the cache implementation used by `ember-data`.
40
+
41
+ ```js
42
+ import Cache from '@ember-data-mirror/json-api';
43
+ import Store from '@ember-data-mirror/store';
44
+
45
+ export default class extends Store {
46
+ createCache(wrapper) {
47
+ return new Cache(wrapper);
48
+ }
49
+ }
50
+ ```
51
+
52
+ @class Cache
53
+ @public
54
+ */
55
+ export declare class JSONAPICache implements Cache {
56
+ /**
57
+ * The Cache Version that this implementation implements.
58
+ *
59
+ * @type {'2'}
60
+ * @public
61
+ * @property version
62
+ */
63
+ version: '2';
64
+ /** @internal */
65
+ _capabilities: CacheCapabilitiesManager;
66
+ /** @internal */
67
+ __cache: Map<StableRecordIdentifier, CachedResource>;
68
+ /** @internal */
69
+ __destroyedCache: Map<StableRecordIdentifier, CachedResource>;
70
+ /** @internal */
71
+ __documents: Map<string, StructuredDocument<ResourceDocument>>;
72
+ /** @internal */
73
+ __graph: Graph;
74
+ constructor(capabilities: CacheCapabilitiesManager);
75
+ /**
76
+ * Cache the response to a request
77
+ *
78
+ * Implements `Cache.put`.
79
+ *
80
+ * Expects a StructuredDocument whose `content` member is a JsonApiDocument.
81
+ *
82
+ * ```js
83
+ * cache.put({
84
+ * request: { url: 'https://api.example.com/v1/user/1' },
85
+ * content: {
86
+ * data: {
87
+ * type: 'user',
88
+ * id: '1',
89
+ * attributes: {
90
+ * name: 'Chris'
91
+ * }
92
+ * }
93
+ * }
94
+ * })
95
+ * ```
96
+ *
97
+ * > **Note**
98
+ * > The nested `content` and `data` members are not a mistake. This is because
99
+ * > there are two separate concepts involved here, the `StructuredDocument` which contains
100
+ * > the context of a given Request that has been issued with the returned contents as its
101
+ * > `content` property, and a `JSON:API Document` which is the json contents returned by
102
+ * > this endpoint and which uses its `data` property to signify which resources are the
103
+ * > primary resources associated with the request.
104
+ *
105
+ * StructuredDocument's with urls will be cached as full documents with
106
+ * associated resource membership order and contents preserved but linked
107
+ * into the cache.
108
+ *
109
+ * @param {StructuredDocument} doc
110
+ * @return {ResourceDocument}
111
+ * @public
112
+ */
113
+ put<T extends SingleResourceDocument>(doc: StructuredDataDocument<T>): SingleResourceDataDocument;
114
+ put<T extends CollectionResourceDocument>(doc: StructuredDataDocument<T>): CollectionResourceDataDocument;
115
+ put<T extends ResourceErrorDocument>(doc: StructuredErrorDocument<T>): ResourceErrorDocument;
116
+ put<T extends ResourceMetaDocument>(doc: StructuredDataDocument<T>): ResourceMetaDocument;
117
+ /** @internal */
118
+ _putDocument<T extends ResourceErrorDocument>(doc: StructuredErrorDocument<T>, data: undefined, included: undefined): ResourceErrorDocument;
119
+ _putDocument<T extends ResourceMetaDocument>(doc: StructuredDataDocument<T>, data: undefined, included: undefined): ResourceMetaDocument;
120
+ _putDocument<T extends SingleResourceDocument>(doc: StructuredDataDocument<T>, data: StableExistingRecordIdentifier | null, included: StableExistingRecordIdentifier[] | undefined): SingleResourceDataDocument;
121
+ _putDocument<T extends CollectionResourceDocument>(doc: StructuredDataDocument<T>, data: StableExistingRecordIdentifier[], included: StableExistingRecordIdentifier[] | undefined): CollectionResourceDataDocument;
122
+ /**
123
+ * Update the "remote" or "canonical" (persisted) state of the Cache
124
+ * by merging new information into the existing state.
125
+ *
126
+ * @public
127
+ * @param {Operation|Operation[]} op the operation or list of operations to perform
128
+ * @return {void}
129
+ */
130
+ patch(op: Operation | Operation[]): void;
131
+ /**
132
+ * Update the "local" or "current" (unpersisted) state of the Cache
133
+ *
134
+ * @param {Mutation} mutation
135
+ * @return {void}
136
+ * @public
137
+ */
138
+ mutate(mutation: LocalRelationshipOperation): void;
139
+ /**
140
+ * Peek resource data from the Cache.
141
+ *
142
+ * In development, if the return value
143
+ * is JSON the return value
144
+ * will be deep-cloned and deep-frozen
145
+ * to prevent mutation thereby enforcing cache
146
+ * Immutability.
147
+ *
148
+ * This form of peek is useful for implementations
149
+ * that want to feed raw-data from cache to the UI
150
+ * or which want to interact with a blob of data
151
+ * directly from the presentation cache.
152
+ *
153
+ * An implementation might want to do this because
154
+ * de-referencing records which read from their own
155
+ * blob is generally safer because the record does
156
+ * not require retainining connections to the Store
157
+ * and Cache to present data on a per-field basis.
158
+ *
159
+ * This generally takes the place of `getAttr` as
160
+ * an API and may even take the place of `getRelationship`
161
+ * depending on implementation specifics, though this
162
+ * latter usage is less recommended due to the advantages
163
+ * of the Graph handling necessary entanglements and
164
+ * notifications for relational data.
165
+ *
166
+ * @public
167
+ * @param {StableRecordIdentifier | StableDocumentIdentifier} identifier
168
+ * @return {ResourceDocument | ResourceObject | null} the known resource data
169
+ */
170
+ peek(identifier: StableRecordIdentifier): ResourceObject | null;
171
+ peek(identifier: StableDocumentIdentifier): ResourceDocument | null;
172
+ peekRemoteState(identifier: StableRecordIdentifier): ResourceObject | null;
173
+ peekRemoteState(identifier: StableDocumentIdentifier): ResourceDocument | null;
174
+ /**
175
+ * Peek the Cache for the existing request data associated with
176
+ * a cacheable request.
177
+ *
178
+ * This is effectively the reverse of `put` for a request in
179
+ * that it will return the the request, response, and content
180
+ * whereas `peek` will return just the `content`.
181
+ *
182
+ * @param {StableDocumentIdentifier}
183
+ * @return {StructuredDocument<ResourceDocument> | null}
184
+ * @public
185
+ */
186
+ peekRequest(identifier: StableDocumentIdentifier): StructuredDocument<ResourceDocument> | null;
187
+ /**
188
+ * Push resource data from a remote source into the cache for this identifier
189
+ *
190
+ * @public
191
+ * @param identifier
192
+ * @param data
193
+ * @param hasRecord
194
+ * @return {void | string[]} if `hasRecord` is true then calculated key changes should be returned
195
+ */
196
+ upsert(identifier: StableRecordIdentifier, data: ExistingResourceObject, calculateChanges?: boolean): void | string[];
197
+ /**
198
+ * Create a fork of the cache from the current state.
199
+ *
200
+ * Applications should typically not call this method themselves,
201
+ * preferring instead to fork at the Store level, which will
202
+ * utilize this method to fork the cache.
203
+ *
204
+ * @internal
205
+ * @return {Promise<Cache>}
206
+ */
207
+ fork(): Promise<Cache>;
208
+ /**
209
+ * Merge a fork back into a parent Cache.
210
+ *
211
+ * Applications should typically not call this method themselves,
212
+ * preferring instead to merge at the Store level, which will
213
+ * utilize this method to merge the caches.
214
+ *
215
+ * @param {Cache} cache
216
+ * @public
217
+ * @return {Promise<void>}
218
+ */
219
+ merge(cache: Cache): Promise<void>;
220
+ /**
221
+ * Generate the list of changes applied to all
222
+ * record in the store.
223
+ *
224
+ * Each individual resource or document that has
225
+ * been mutated should be described as an individual
226
+ * `Change` entry in the returned array.
227
+ *
228
+ * A `Change` is described by an object containing up to
229
+ * three properties: (1) the `identifier` of the entity that
230
+ * changed; (2) the `op` code of that change being one of
231
+ * `upsert` or `remove`, and if the op is `upsert` a `patch`
232
+ * containing the data to merge into the cache for the given
233
+ * entity.
234
+ *
235
+ * This `patch` is opaque to the Store but should be understood
236
+ * by the Cache and may expect to be utilized by an Adapter
237
+ * when generating data during a `save` operation.
238
+ *
239
+ * It is generally recommended that the `patch` contain only
240
+ * the updated state, ignoring fields that are unchanged
241
+ *
242
+ * ```ts
243
+ * interface Change {
244
+ * identifier: StableRecordIdentifier | StableDocumentIdentifier;
245
+ * op: 'upsert' | 'remove';
246
+ * patch?: unknown;
247
+ * }
248
+ * ```
249
+ *
250
+ * @public
251
+ */
252
+ diff(): Promise<Change[]>;
253
+ /**
254
+ * Serialize the entire contents of the Cache into a Stream
255
+ * which may be fed back into a new instance of the same Cache
256
+ * via `cache.hydrate`.
257
+ *
258
+ * @return {Promise<ReadableStream>}
259
+ * @public
260
+ */
261
+ dump(): Promise<ReadableStream<unknown>>;
262
+ /**
263
+ * hydrate a Cache from a Stream with content previously serialized
264
+ * from another instance of the same Cache, resolving when hydration
265
+ * is complete.
266
+ *
267
+ * This method should expect to be called both in the context of restoring
268
+ * the Cache during application rehydration after SSR **AND** at unknown
269
+ * times during the lifetime of an already booted application when it is
270
+ * desired to bulk-load additional information into the cache. This latter
271
+ * behavior supports optimizing pre/fetching of data for route transitions
272
+ * via data-only SSR modes.
273
+ *
274
+ * @param {ReadableStream} stream
275
+ * @return {Promise<void>}
276
+ * @public
277
+ */
278
+ hydrate(stream: ReadableStream<unknown>): Promise<void>;
279
+ /**
280
+ * [LIFECYCLE] Signal to the cache that a new record has been instantiated on the client
281
+ *
282
+ * It returns properties from options that should be set on the record during the create
283
+ * process. This return value behavior is deprecated.
284
+ *
285
+ * @public
286
+ * @param identifier
287
+ * @param createArgs
288
+ */
289
+ clientDidCreate(identifier: StableRecordIdentifier, options?: Record<string, Value>): Record<string, unknown>;
290
+ /**
291
+ * [LIFECYCLE] Signals to the cache that a resource
292
+ * will be part of a save transaction.
293
+ *
294
+ * @public
295
+ * @param identifier
296
+ */
297
+ willCommit(identifier: StableRecordIdentifier): void;
298
+ /**
299
+ * [LIFECYCLE] Signals to the cache that a resource
300
+ * was successfully updated as part of a save transaction.
301
+ *
302
+ * @public
303
+ * @param identifier
304
+ * @param data
305
+ */
306
+ didCommit(committedIdentifier: StableRecordIdentifier, result: StructuredDataDocument<SingleResourceDocument>): SingleResourceDataDocument;
307
+ /**
308
+ * [LIFECYCLE] Signals to the cache that a resource
309
+ * was update via a save transaction failed.
310
+ *
311
+ * @public
312
+ * @param identifier
313
+ * @param errors
314
+ */
315
+ commitWasRejected(identifier: StableRecordIdentifier, errors?: ApiError[]): void;
316
+ /**
317
+ * [LIFECYCLE] Signals to the cache that all data for a resource
318
+ * should be cleared.
319
+ *
320
+ * This method is a candidate to become a mutation
321
+ *
322
+ * @public
323
+ * @param identifier
324
+ */
325
+ unloadRecord(identifier: StableRecordIdentifier): void;
326
+ /**
327
+ * Retrieve the data for an attribute from the cache
328
+ *
329
+ * @public
330
+ * @param identifier
331
+ * @param field
332
+ * @return {unknown}
333
+ */
334
+ getAttr(identifier: StableRecordIdentifier, attr: string | string[]): Value | undefined;
335
+ getRemoteAttr(identifier: StableRecordIdentifier, attr: string | string[]): Value | undefined;
336
+ /**
337
+ * Mutate the data for an attribute in the cache
338
+ *
339
+ * This method is a candidate to become a mutation
340
+ *
341
+ * @public
342
+ * @param identifier
343
+ * @param field
344
+ * @param value
345
+ */
346
+ setAttr(identifier: StableRecordIdentifier, attr: string | string[], value: Value): void;
347
+ /**
348
+ * Query the cache for the changed attributes of a resource.
349
+ *
350
+ * @public
351
+ * @param identifier
352
+ * @return {ChangedAttributesHash} `{ <field>: [<old>, <new>] }`
353
+ */
354
+ changedAttrs(identifier: StableRecordIdentifier): ChangedAttributesHash;
355
+ /**
356
+ * Query the cache for whether any mutated attributes exist
357
+ *
358
+ * @public
359
+ * @param identifier
360
+ * @return {Boolean}
361
+ */
362
+ hasChangedAttrs(identifier: StableRecordIdentifier): boolean;
363
+ /**
364
+ * Tell the cache to discard any uncommitted mutations to attributes
365
+ *
366
+ * This method is a candidate to become a mutation
367
+ *
368
+ * @public
369
+ * @param identifier
370
+ * @return {String[]} the names of fields that were restored
371
+ */
372
+ rollbackAttrs(identifier: StableRecordIdentifier): string[];
373
+ /**
374
+ * Query the cache for the changes to relationships of a resource.
375
+ *
376
+ * Returns a map of relationship names to RelationshipDiff objects.
377
+ *
378
+ * ```ts
379
+ * type RelationshipDiff =
380
+ | {
381
+ kind: 'collection';
382
+ remoteState: StableRecordIdentifier[];
383
+ additions: Set<StableRecordIdentifier>;
384
+ removals: Set<StableRecordIdentifier>;
385
+ localState: StableRecordIdentifier[];
386
+ reordered: boolean;
387
+ }
388
+ | {
389
+ kind: 'resource';
390
+ remoteState: StableRecordIdentifier | null;
391
+ localState: StableRecordIdentifier | null;
392
+ };
393
+ ```
394
+ *
395
+ * @public
396
+ * @param {StableRecordIdentifier} identifier
397
+ * @return {Map<string, RelationshipDiff>}
398
+ */
399
+ changedRelationships(identifier: StableRecordIdentifier): Map<string, RelationshipDiff>;
400
+ /**
401
+ * Query the cache for whether any mutated relationships exist
402
+ *
403
+ * @public
404
+ * @param {StableRecordIdentifier} identifier
405
+ * @return {Boolean}
406
+ */
407
+ hasChangedRelationships(identifier: StableRecordIdentifier): boolean;
408
+ /**
409
+ * Tell the cache to discard any uncommitted mutations to relationships.
410
+ *
411
+ * This will also discard the change on any appropriate inverses.
412
+ *
413
+ * This method is a candidate to become a mutation
414
+ *
415
+ * @public
416
+ * @param {StableRecordIdentifier} identifier
417
+ * @return {String[]} the names of relationships that were restored
418
+ */
419
+ rollbackRelationships(identifier: StableRecordIdentifier): string[];
420
+ /**
421
+ * Query the cache for the current state of a relationship property
422
+ *
423
+ * @public
424
+ * @param identifier
425
+ * @param field
426
+ * @return resource relationship object
427
+ */
428
+ getRelationship(identifier: StableRecordIdentifier, field: string): ResourceRelationship | CollectionRelationship;
429
+ getRemoteRelationship(identifier: StableRecordIdentifier, field: string): ResourceRelationship | CollectionRelationship;
430
+ /**
431
+ * Update the cache state for the given resource to be marked
432
+ * as locally deleted, or remove such a mark.
433
+ *
434
+ * This method is a candidate to become a mutation
435
+ *
436
+ * @public
437
+ * @param identifier
438
+ * @param {Boolean} isDeleted
439
+ */
440
+ setIsDeleted(identifier: StableRecordIdentifier, isDeleted: boolean): void;
441
+ /**
442
+ * Query the cache for any validation errors applicable to the given resource.
443
+ *
444
+ * @public
445
+ * @param identifier
446
+ * @return {JsonApiError[]}
447
+ */
448
+ getErrors(identifier: StableRecordIdentifier): ApiError[];
449
+ /**
450
+ * Query the cache for whether a given resource has any available data
451
+ *
452
+ * @public
453
+ * @param identifier
454
+ * @return {Boolean}
455
+ */
456
+ isEmpty(identifier: StableRecordIdentifier): boolean;
457
+ /**
458
+ * Query the cache for whether a given resource was created locally and not
459
+ * yet persisted.
460
+ *
461
+ * @public
462
+ * @param identifier
463
+ * @return {Boolean}
464
+ */
465
+ isNew(identifier: StableRecordIdentifier): boolean;
466
+ /**
467
+ * Query the cache for whether a given resource is marked as deleted (but not
468
+ * necessarily persisted yet).
469
+ *
470
+ * @public
471
+ * @param identifier
472
+ * @return {Boolean}
473
+ */
474
+ isDeleted(identifier: StableRecordIdentifier): boolean;
475
+ /**
476
+ * Query the cache for whether a given resource has been deleted and that deletion
477
+ * has also been persisted.
478
+ *
479
+ * @public
480
+ * @param identifier
481
+ * @return {Boolean}
482
+ */
483
+ isDeletionCommitted(identifier: StableRecordIdentifier): boolean;
484
+ /**
485
+ * Private method used to populate an entry for the identifier
486
+ *
487
+ * @internal
488
+ * @param {StableRecordIdentifier} identifier
489
+ * @return {CachedResource}
490
+ */
491
+ _createCache(identifier: StableRecordIdentifier): CachedResource;
492
+ /**
493
+ * Peek whether we have cached resource data matching the identifier
494
+ * without asserting if the resource data is missing.
495
+ *
496
+ * @param {StableRecordIdentifier} identifier
497
+ * @param {Boolean} allowDestroyed
498
+ * @internal
499
+ * @return {CachedResource | undefined}
500
+ */
501
+ __safePeek(identifier: StableRecordIdentifier, allowDestroyed: boolean): CachedResource | undefined;
502
+ /**
503
+ * Peek whether we have cached resource data matching the identifier
504
+ * Asserts if the resource data is missing.
505
+ *
506
+ * @param {StableRecordIdentifier} identifier
507
+ * @param {Boolean} allowDestroyed
508
+ * @internal
509
+ * @return {CachedResource}
510
+ */
511
+ __peek(identifier: StableRecordIdentifier, allowDestroyed: boolean): CachedResource;
512
+ }
513
+ export {};
514
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/-private/cache.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAkB,KAAK,EAAyC,MAAM,iCAAiC,CAAC;AAGpH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACnG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,KAAK,EAKV,SAAS,EAQV,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAC9G,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,KAAK,EACV,wBAAwB,EACxB,8BAA8B,EAC9B,sBAAsB,EACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAe,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAEV,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,gCAAgC,CAAC;AAQxC,OAAO,KAAK,EACV,8BAA8B,EAE9B,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,E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IvF;;;;;;OAMG;IACH,uBAAuB,CAAC,UAAU,EAAE,sBAAsB,GAAG,OAAO;IAIpE;;;;;;;;;;OAUG;IACH,qBAAqB,CAAC,UAAU,EAAE,sBAAsB,GAAG,MAAM,EAAE;IASnE;;;;;;;OAOG;IACH,eAAe,CAAC,UAAU,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,GAAG,oBAAoB,GAAG,sBAAsB;IAIjH,qBAAqB,CACnB,UAAU,EAAE,sBAAsB,EAClC,KAAK,EAAE,MAAM,GACZ,oBAAoB,GAAG,sBAAsB;IAOhD;;;;;;;;;OASG;IACH,YAAY,CAAC,UAAU,EAAE,sBAAsB,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI;IAO1E;;;;;;OAMG;IACH,SAAS,CAAC,UAAU,EAAE,sBAAsB,GAAG,QAAQ,EAAE;IAIzD;;;;;;OAMG;IACH,OAAO,CAAC,UAAU,EAAE,sBAAsB,GAAG,OAAO;IAKpD;;;;;;;OAOG;IACH,KAAK,CAAC,UAAU,EAAE,sBAAsB,GAAG,OAAO;IAKlD;;;;;;;OAOG;IACH,SAAS,CAAC,UAAU,EAAE,sBAAsB,GAAG,OAAO;IAKtD;;;;;;;OAOG;IACH,mBAAmB,CAAC,UAAU,EAAE,sBAAsB,GAAG,OAAO;IAKhE;;;;;;OAMG;IACH,YAAY,CAAC,UAAU,EAAE,sBAAsB,GAAG,cAAc;IAOhE;;;;;;;;OAQG;IACH,UAAU,CAAC,UAAU,EAAE,sBAAsB,EAAE,cAAc,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS;IAQnG;;;;;;;;OAQG;IACH,MAAM,CAAC,UAAU,EAAE,sBAAsB,EAAE,cAAc,EAAE,OAAO,GAAG,cAAc;CAQpF"}
@@ -0,0 +1,4 @@
1
+ import type { SchemaService } from '@warp-drive-mirror/core/types';
2
+ import type { CollectionResourceDocument, SingleResourceDocument } from '@warp-drive-mirror/core/types/spec/json-api-raw';
3
+ export declare function validateDocumentFields(schema: SchemaService, jsonApiDoc: SingleResourceDocument | CollectionResourceDocument): void;
4
+ //# sourceMappingURL=validate-document-fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-document-fields.d.ts","sourceRoot":"","sources":["../../src/-private/validate-document-fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,KAAK,EACV,0BAA0B,EAI1B,sBAAsB,EACvB,MAAM,0CAA0C,CAAC;AAElD,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,sBAAsB,GAAG,0BAA0B,QA0BhE"}
@@ -0,0 +1,13 @@
1
+ import type { ResourceDocument } from '@warp-drive-mirror/core/types/spec/document';
2
+ import { type Reporter } from '../utils';
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;
13
+ //# sourceMappingURL=7.1_top-level-document-members.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"7.1_top-level-document-members.d.ts","sourceRoot":"","sources":["../../../../src/-private/validator/1.1/7.1_top-level-document-members.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,OAAO,EAA+B,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAItE;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,gBAAgB,QA8HxF"}
@@ -0,0 +1,14 @@
1
+ import type { ResourceDocument } from '@warp-drive-mirror/core/types/spec/document';
2
+ import { type Reporter } from '../utils';
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;
14
+ //# sourceMappingURL=7.2_resource-objects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"7.2_resource-objects.d.ts","sourceRoot":"","sources":["../../../../src/-private/validator/1.1/7.2_resource-objects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,OAAO,EAOL,KAAK,QAAQ,EACd,MAAM,UAAU,CAAC;AAKlB;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,gBAAgB,QAiDlF"}