@warp-drive-mirror/json-api 5.8.0-beta.0 → 5.8.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,51 +1,41 @@
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
- />
1
+ <p align="center">
8
2
  <img
9
3
  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"
4
+ src="./logos/logo-yellow-slab.svg"
5
+ alt="WarpDrive"
6
+ width="180px"
7
+ title="WarpDrive"
13
8
  />
14
- </h1>
9
+ </p>
15
10
 
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
11
+ ![NPM Stable Version](https://img.shields.io/npm/v/ember-data/latest?label=version&style=flat&color=fdb155)
12
+ ![NPM Downloads](https://img.shields.io/npm/dm/ember-data.svg?style=flat&color=fdb155)
13
+ ![License](https://img.shields.io/github/license/warp-drive-data/warp-drive.svg?style=flat&color=fdb155)
14
+ [![EmberJS Discord Community Server](https://img.shields.io/badge/EmberJS-grey?logo=discord&logoColor=fdb155)](https://discord.gg/zT3asNS
15
+ )
16
+ [![WarpDrive Discord Server](https://img.shields.io/badge/WarpDrive-grey?logo=discord&logoColor=fdb155)](https://discord.gg/PHBbnWJx5S
21
17
  )
22
18
 
23
- <br>
24
-
25
- <p align="center">
26
- A {JSON:API} Cache Implementation for <em>Warp</em><strong>Drive</strong>.
27
- </p>
19
+ # @warp-drive-mirror/json-api
28
20
 
29
- <br>
21
+ A {json:api} Cache Implementation for ***Warp*Drive**.
30
22
 
31
- ## Installation
23
+ `{json:api}` excels at simplifying common complex problems around cache consistency and information density, especially in regards to relational or polymorphic data.
32
24
 
33
- ```sh
34
- pnpm add -E @warp-drive-mirror/json-api
35
- ```
25
+ Because most API responses can be quickly transformed into the `{json:api}` format without losing any information, ***Warp*Drive** recommends that most-if-not-all apps should use this Cache implementation.
36
26
 
37
27
  <br>
38
28
 
39
29
  ## Documentation
40
30
 
41
- *Get Started* → [Guides](https://docs.warp-drive.io)
31
+ *Get Started* → [Guides](https://warp-drive.io)
42
32
 
43
33
 
44
34
  <br>
45
35
 
46
36
  ## Code of Conduct
47
37
 
48
- Refer to the [Code of Conduct](https://github.com/emberjs/data/blob/main/CODE_OF_CONDUCT.md) for community guidelines and inclusivity.
38
+ Refer to the [Code of Conduct](https://github.com/warp-drive-data/warp-drive/blob/main/CODE_OF_CONDUCT.md) for community guidelines and inclusivity.
49
39
 
50
40
  <br>
51
41
 
@@ -11,82 +11,12 @@ import type { CollectionResourceDataDocument, ResourceDocument, ResourceErrorDoc
11
11
  import type { ApiError } from "@warp-drive-mirror/core/types/spec/error";
12
12
  import type { CollectionResourceDocument, ExistingResourceObject, ResourceObject, SingleResourceDocument } from "@warp-drive-mirror/core/types/spec/json-api-raw";
13
13
  /**
14
- * ### JSONAPICache
15
- *
16
14
  * ```ts
17
15
  * import { JSONAPICache } from '@warp-drive-mirror/json-api';
18
16
  * ```
19
17
  *
20
- A {@link Cache} implementation tuned for [{json:api}](https://jsonapi.org/)
21
-
22
- This format excels at simiplifying common complex problems around cache
23
- consistency and information density. Because most API responses can be quickly
24
- transformed into {json:api} format without losing any information, WarpDrive
25
- recommends that most apps use this Cache implementation.
26
-
27
- If a cache built to understand another format would do better for your app then
28
- it just needs to follow the same interface.
29
-
30
- Do you really need a cache? Are sunsets beautiful? Caching is what powers features like
31
- immutability, mutation management, and allows ***Warp*Drive** to understand your relational
32
- data.
33
-
34
- Some caches are simple request/response maps. ***Warp*Drive**'s is not. The Cache deeply
35
- understands the structure of your data, ensuring your data remains consistent both within
36
- and across requests.
37
-
38
- ### Installation
39
-
40
- ::: code-group
41
-
42
- ```sh [pnpm]
43
- pnpm add -E @warp-drive-mirror/core@latest @warp-drive-mirror/json-api@latest
44
- ```
45
-
46
- ```sh [npm]
47
- npm add -E @warp-drive-mirror/core@latest @warp-drive-mirror/json-api@latest
48
- ```
49
-
50
- ```sh [yarn]
51
- yarn add -E @warp-drive-mirror/core@latest @warp-drive-mirror/json-api@latest
52
- ```
53
-
54
- ```sh [bun]
55
- bun add --exact @warp-drive-mirror/core@latest @warp-drive-mirror/json-api@latest
56
- ```
57
-
58
- :::
59
-
60
- ### Setup
61
-
62
- ```ts [services/store.ts]
63
- import { Fetch, RequestManager, Store } from '@warp-drive-mirror/core';
64
- import {
65
- registerDerivations,
66
- SchemaService,
67
- } from '@warp-drive-mirror/core/reactive';
68
- import { CacheHandler } from '@warp-drive-mirror/core/store';
69
- import type { CacheCapabilitiesManager } from '@warp-drive-mirror/core/types'; // [!code focus:2]
70
- import { JSONAPICache } from '@warp-drive-mirror/json-api';
71
-
72
- export default class AppStore extends Store {
73
-
74
- requestManager = new RequestManager()
75
- .use([Fetch])
76
- .useCache(CacheHandler);
77
-
78
- createSchemaService() {
79
- const schema = new SchemaService();
80
- registerDerivations(schema);
81
- return schema;
82
- }
83
-
84
- createCache(capabilities: CacheCapabilitiesManager) { // [!code focus:3]
85
- return new JSONAPICache(capabilities);
86
- }
87
- }
88
- ```
89
-
18
+ * A {@link Cache} implementation tuned for [{json:api}](https://jsonapi.org/)
19
+ *
90
20
  * @categoryDescription Cache Management
91
21
  * APIs for primary cache management functionality
92
22
  * @categoryDescription Cache Forking
@@ -99,8 +29,8 @@ return new JSONAPICache(capabilities);
99
29
  * APIs that support granular field level management of resource data
100
30
  * @categoryDescription Resource State
101
31
  * APIs that support managing Resource states
102
-
103
- @public
32
+ *
33
+ * @public
104
34
  */
105
35
  export declare class JSONAPICache implements Cache {
106
36
  /**
@@ -194,6 +124,15 @@ export declare class JSONAPICache implements Cache {
194
124
  * of the Graph handling necessary entanglements and
195
125
  * notifications for relational data.
196
126
  *
127
+ * :::warning
128
+ * It is not recommended to use the return value as
129
+ * a serialized representation of the resource both
130
+ * due to it containing local mutations and because
131
+ * it may contain additional fields not recognized
132
+ * by the {json:api} API implementation such as `lid` and
133
+ * the various internal WarpDrive bookkeeping fields.
134
+ * :::
135
+ *
197
136
  * @category Cache Management
198
137
  * @public
199
138
  */
@@ -325,7 +264,7 @@ export declare class JSONAPICache implements Cache {
325
264
  * @category Resource Lifecycle
326
265
  * @public
327
266
  */
328
- willCommit(identifier: ResourceKey, _context: RequestContext | null): void;
267
+ willCommit(identifier: ResourceKey | ResourceKey[], _context: RequestContext | null): void;
329
268
  /**
330
269
  * [LIFECYCLE] Signals to the cache that a resource
331
270
  * was successfully updated as part of a save transaction.
@@ -333,7 +272,9 @@ export declare class JSONAPICache implements Cache {
333
272
  * @category Resource Lifecycle
334
273
  * @public
335
274
  */
336
- didCommit(committedIdentifier: ResourceKey, result: StructuredDataDocument<SingleResourceDocument> | null): SingleResourceDataDocument;
275
+ didCommit(committedIdentifier: ResourceKey, result: StructuredDataDocument<SingleResourceDataDocument> | null): SingleResourceDataDocument;
276
+ didCommit(committedIdentifier: ResourceKey[], result: StructuredDataDocument<SingleResourceDataDocument> | null): SingleResourceDataDocument;
277
+ didCommit(committedIdentifier: ResourceKey[], result: StructuredDataDocument<CollectionResourceDataDocument> | null): CollectionResourceDataDocument;
337
278
  /**
338
279
  * [LIFECYCLE] Signals to the cache that a resource
339
280
  * was update via a save transaction failed.
@@ -341,7 +282,7 @@ export declare class JSONAPICache implements Cache {
341
282
  * @category Resource Lifecycle
342
283
  * @public
343
284
  */
344
- commitWasRejected(identifier: ResourceKey, errors?: ApiError[]): void;
285
+ commitWasRejected(identifier: ResourceKey | ResourceKey[], errors?: ApiError[]): void;
345
286
  /**
346
287
  * [LIFECYCLE] Signals to the cache that all data for a resource
347
288
  * should be cleared.
@@ -1 +1,5 @@
1
+ /**
2
+ * @module
3
+ * @mergeModuleWith <project>
4
+ */
1
5
  export { JSONAPICache } from "./-private/cache.js";