@warp-drive/core 5.6.0-alpha.15 → 5.6.0-alpha.17

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 (286) hide show
  1. package/declarations/build-config/babel-macros.d.ts +1 -2
  2. package/declarations/build-config/canary-features.d.ts +1 -2
  3. package/declarations/build-config/debugging.d.ts +1 -2
  4. package/declarations/build-config/deprecations.d.ts +1 -2
  5. package/declarations/build-config/env.d.ts +1 -2
  6. package/declarations/build-config/macros.d.ts +1 -2
  7. package/declarations/build-config.d.ts +1 -2
  8. package/declarations/configure.d.ts +6 -7
  9. package/declarations/graph/-private/-diff.d.ts +21 -22
  10. package/declarations/graph/-private/-edge-definition.d.ts +134 -135
  11. package/declarations/graph/-private/-state.d.ts +93 -7
  12. package/declarations/graph/-private/-utils.d.ts +18 -13
  13. package/declarations/graph/-private/coerce-id.d.ts +6 -1
  14. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +15 -4
  15. package/declarations/graph/-private/edges/collection.d.ts +35 -36
  16. package/declarations/graph/-private/edges/implicit.d.ts +28 -29
  17. package/declarations/graph/-private/edges/resource.d.ts +19 -20
  18. package/declarations/graph/-private/graph.d.ts +83 -48
  19. package/declarations/graph/-private/normalize-link.d.ts +7 -2
  20. package/declarations/graph/-private/operations/add-to-related-records.d.ts +3 -4
  21. package/declarations/graph/-private/operations/merge-identifier.d.ts +2 -3
  22. package/declarations/graph/-private/operations/remove-from-related-records.d.ts +3 -4
  23. package/declarations/graph/-private/operations/replace-related-record.d.ts +2 -3
  24. package/declarations/graph/-private/operations/replace-related-records.d.ts +58 -4
  25. package/declarations/graph/-private/operations/update-relationship.d.ts +11 -9
  26. package/declarations/graph/-private.d.ts +9 -10
  27. package/declarations/index.d.ts +11 -12
  28. package/declarations/reactive/-private/document.d.ts +143 -144
  29. package/declarations/reactive/-private/fields/compute.d.ts +31 -28
  30. package/declarations/reactive/-private/fields/extension.d.ts +2 -3
  31. package/declarations/reactive/-private/fields/managed-array.d.ts +19 -20
  32. package/declarations/reactive/-private/fields/managed-object.d.ts +16 -16
  33. package/declarations/reactive/-private/fields/many-array-manager.d.ts +15 -16
  34. package/declarations/reactive/-private/hooks.d.ts +3 -4
  35. package/declarations/reactive/-private/record.d.ts +61 -59
  36. package/declarations/reactive/-private/schema.d.ts +242 -224
  37. package/declarations/reactive/-private/symbols.d.ts +26 -1
  38. package/declarations/reactive/-private.d.ts +1 -2
  39. package/declarations/reactive.d.ts +4 -5
  40. package/declarations/request/-private/context.d.ts +34 -35
  41. package/declarations/request/-private/debug.d.ts +2 -3
  42. package/declarations/request/-private/fetch.d.ts +23 -24
  43. package/declarations/request/-private/future.d.ts +3 -4
  44. package/declarations/request/-private/manager.d.ts +159 -157
  45. package/declarations/request/-private/promise-cache.d.ts +21 -13
  46. package/declarations/request/-private/types.d.ts +124 -124
  47. package/declarations/request/-private/utils.d.ts +8 -9
  48. package/declarations/request.d.ts +5 -6
  49. package/declarations/store/-private/cache-handler/handler.d.ts +57 -52
  50. package/declarations/store/-private/cache-handler/types.d.ts +95 -96
  51. package/declarations/store/-private/cache-handler/utils.d.ts +16 -16
  52. package/declarations/store/-private/caches/cache-utils.d.ts +7 -4
  53. package/declarations/store/-private/caches/identifier-cache.d.ts +234 -246
  54. package/declarations/store/-private/caches/instance-cache.d.ts +47 -47
  55. package/declarations/store/-private/caches/resource-utils.d.ts +3 -4
  56. package/declarations/store/-private/debug/utils.d.ts +6 -7
  57. package/declarations/store/-private/default-cache-policy.d.ts +362 -361
  58. package/declarations/store/-private/legacy-model-support/record-reference.d.ts +154 -159
  59. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +14 -14
  60. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +21 -22
  61. package/declarations/store/-private/managers/cache-manager.d.ts +440 -425
  62. package/declarations/store/-private/managers/notification-manager.d.ts +88 -83
  63. package/declarations/store/-private/managers/record-array-manager.d.ts +89 -90
  64. package/declarations/store/-private/network/request-cache.d.ts +86 -83
  65. package/declarations/store/-private/new-core-tmp/promise-state.d.ts +252 -244
  66. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +154 -155
  67. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +148 -149
  68. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +28 -23
  69. package/declarations/store/-private/new-core-tmp/request-state.d.ts +263 -241
  70. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +253 -223
  71. package/declarations/store/-private/record-arrays/identifier-array.d.ts +125 -121
  72. package/declarations/store/-private/record-arrays/many-array.d.ts +180 -184
  73. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +120 -110
  74. package/declarations/store/-private/store-service.d.ts +1594 -1586
  75. package/declarations/store/-private/utils/coerce-id.d.ts +6 -1
  76. package/declarations/store/-private/utils/construct-resource.d.ts +1 -2
  77. package/declarations/store/-private/utils/is-non-empty-string.d.ts +0 -1
  78. package/declarations/store/-private/utils/normalize-model-name.d.ts +0 -1
  79. package/declarations/store/-private/utils/uuid-polyfill.d.ts +0 -1
  80. package/declarations/store/-private.d.ts +31 -28
  81. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +96 -97
  82. package/declarations/store/-types/q/ds-model.d.ts +17 -18
  83. package/declarations/store/-types/q/identifier.d.ts +11 -12
  84. package/declarations/store/-types/q/record-instance.d.ts +16 -17
  85. package/declarations/store/-types/q/schema-service.d.ts +346 -343
  86. package/declarations/store/-types/q/store.d.ts +25 -28
  87. package/declarations/store.d.ts +1 -2
  88. package/declarations/types/-private.d.ts +16 -8
  89. package/declarations/types/cache/aliases.d.ts +11 -1
  90. package/declarations/types/cache/change.d.ts +4 -5
  91. package/declarations/types/cache/mutations.d.ts +51 -28
  92. package/declarations/types/cache/operations.d.ts +60 -47
  93. package/declarations/types/cache/relationship.d.ts +11 -9
  94. package/declarations/types/cache.d.ts +495 -484
  95. package/declarations/types/graph.d.ts +31 -32
  96. package/declarations/types/identifier.d.ts +83 -82
  97. package/declarations/types/json/raw.d.ts +1 -2
  98. package/declarations/types/params.d.ts +4 -5
  99. package/declarations/types/record.d.ts +117 -76
  100. package/declarations/types/request.d.ts +289 -266
  101. package/declarations/types/runtime.d.ts +8 -9
  102. package/declarations/types/schema/concepts.d.ts +19 -13
  103. package/declarations/types/schema/fields.d.ts +1712 -1713
  104. package/declarations/types/schema/fields.type-test.d.ts +0 -1
  105. package/declarations/types/spec/document.d.ts +28 -22
  106. package/declarations/types/spec/error.d.ts +16 -17
  107. package/declarations/types/spec/json-api-raw.d.ts +102 -102
  108. package/declarations/types/symbols.d.ts +74 -75
  109. package/declarations/types/utils.d.ts +5 -5
  110. package/declarations/types.d.ts +10 -11
  111. package/declarations/utils/string.d.ts +43 -40
  112. package/dist/graph/-private.js +1 -1
  113. package/dist/{handler-D1C3Innj.js → handler-C2T-IyJK.js} +1 -1
  114. package/dist/index.js +2 -2
  115. package/dist/reactive/-private.js +1 -1
  116. package/dist/reactive.js +42 -73
  117. package/dist/{request-state-CCOJIj5i.js → request-state-CjLph1LP.js} +275 -261
  118. package/dist/store/-private.js +2 -2
  119. package/dist/{symbols-epHW0Vm9.js → symbols-SIstXMLI.js} +1 -1
  120. package/dist/types/-private.js +1 -1
  121. package/package.json +4 -4
  122. package/declarations/build-config/babel-macros.d.ts.map +0 -1
  123. package/declarations/build-config/canary-features.d.ts.map +0 -1
  124. package/declarations/build-config/debugging.d.ts.map +0 -1
  125. package/declarations/build-config/deprecations.d.ts.map +0 -1
  126. package/declarations/build-config/env.d.ts.map +0 -1
  127. package/declarations/build-config/macros.d.ts.map +0 -1
  128. package/declarations/build-config.d.ts.map +0 -1
  129. package/declarations/configure.d.ts.map +0 -1
  130. package/declarations/graph/-private/-diff.d.ts.map +0 -1
  131. package/declarations/graph/-private/-edge-definition.d.ts.map +0 -1
  132. package/declarations/graph/-private/-state.d.ts.map +0 -1
  133. package/declarations/graph/-private/-utils.d.ts.map +0 -1
  134. package/declarations/graph/-private/coerce-id.d.ts.map +0 -1
  135. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts.map +0 -1
  136. package/declarations/graph/-private/edges/collection.d.ts.map +0 -1
  137. package/declarations/graph/-private/edges/implicit.d.ts.map +0 -1
  138. package/declarations/graph/-private/edges/resource.d.ts.map +0 -1
  139. package/declarations/graph/-private/graph.d.ts.map +0 -1
  140. package/declarations/graph/-private/normalize-link.d.ts.map +0 -1
  141. package/declarations/graph/-private/operations/add-to-related-records.d.ts.map +0 -1
  142. package/declarations/graph/-private/operations/merge-identifier.d.ts.map +0 -1
  143. package/declarations/graph/-private/operations/remove-from-related-records.d.ts.map +0 -1
  144. package/declarations/graph/-private/operations/replace-related-record.d.ts.map +0 -1
  145. package/declarations/graph/-private/operations/replace-related-records.d.ts.map +0 -1
  146. package/declarations/graph/-private/operations/update-relationship.d.ts.map +0 -1
  147. package/declarations/graph/-private.d.ts.map +0 -1
  148. package/declarations/index.d.ts.map +0 -1
  149. package/declarations/reactive/-private/document.d.ts.map +0 -1
  150. package/declarations/reactive/-private/fields/compute.d.ts.map +0 -1
  151. package/declarations/reactive/-private/fields/extension.d.ts.map +0 -1
  152. package/declarations/reactive/-private/fields/managed-array.d.ts.map +0 -1
  153. package/declarations/reactive/-private/fields/managed-object.d.ts.map +0 -1
  154. package/declarations/reactive/-private/fields/many-array-manager.d.ts.map +0 -1
  155. package/declarations/reactive/-private/hooks.d.ts.map +0 -1
  156. package/declarations/reactive/-private/record.d.ts.map +0 -1
  157. package/declarations/reactive/-private/schema.d.ts.map +0 -1
  158. package/declarations/reactive/-private/symbols.d.ts.map +0 -1
  159. package/declarations/reactive/-private.d.ts.map +0 -1
  160. package/declarations/reactive.d.ts.map +0 -1
  161. package/declarations/request/-private/context.d.ts.map +0 -1
  162. package/declarations/request/-private/debug.d.ts.map +0 -1
  163. package/declarations/request/-private/fetch.d.ts.map +0 -1
  164. package/declarations/request/-private/future.d.ts.map +0 -1
  165. package/declarations/request/-private/manager.d.ts.map +0 -1
  166. package/declarations/request/-private/promise-cache.d.ts.map +0 -1
  167. package/declarations/request/-private/types.d.ts.map +0 -1
  168. package/declarations/request/-private/utils.d.ts.map +0 -1
  169. package/declarations/request.d.ts.map +0 -1
  170. package/declarations/store/-private/cache-handler/handler.d.ts.map +0 -1
  171. package/declarations/store/-private/cache-handler/types.d.ts.map +0 -1
  172. package/declarations/store/-private/cache-handler/utils.d.ts.map +0 -1
  173. package/declarations/store/-private/caches/cache-utils.d.ts.map +0 -1
  174. package/declarations/store/-private/caches/identifier-cache.d.ts.map +0 -1
  175. package/declarations/store/-private/caches/instance-cache.d.ts.map +0 -1
  176. package/declarations/store/-private/caches/resource-utils.d.ts.map +0 -1
  177. package/declarations/store/-private/debug/utils.d.ts.map +0 -1
  178. package/declarations/store/-private/default-cache-policy.d.ts.map +0 -1
  179. package/declarations/store/-private/legacy-model-support/record-reference.d.ts.map +0 -1
  180. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts.map +0 -1
  181. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts.map +0 -1
  182. package/declarations/store/-private/managers/cache-manager.d.ts.map +0 -1
  183. package/declarations/store/-private/managers/notification-manager.d.ts.map +0 -1
  184. package/declarations/store/-private/managers/record-array-manager.d.ts.map +0 -1
  185. package/declarations/store/-private/network/request-cache.d.ts.map +0 -1
  186. package/declarations/store/-private/new-core-tmp/promise-state.d.ts.map +0 -1
  187. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts.map +0 -1
  188. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts.map +0 -1
  189. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts.map +0 -1
  190. package/declarations/store/-private/new-core-tmp/request-state.d.ts.map +0 -1
  191. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts.map +0 -1
  192. package/declarations/store/-private/record-arrays/identifier-array.d.ts.map +0 -1
  193. package/declarations/store/-private/record-arrays/many-array.d.ts.map +0 -1
  194. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts.map +0 -1
  195. package/declarations/store/-private/store-service.d.ts.map +0 -1
  196. package/declarations/store/-private/store-service.type-test.d.ts +0 -2
  197. package/declarations/store/-private/store-service.type-test.d.ts.map +0 -1
  198. package/declarations/store/-private/utils/coerce-id.d.ts.map +0 -1
  199. package/declarations/store/-private/utils/construct-resource.d.ts.map +0 -1
  200. package/declarations/store/-private/utils/is-non-empty-string.d.ts.map +0 -1
  201. package/declarations/store/-private/utils/normalize-model-name.d.ts.map +0 -1
  202. package/declarations/store/-private/utils/uuid-polyfill.d.ts.map +0 -1
  203. package/declarations/store/-private.d.ts.map +0 -1
  204. package/declarations/store/-types/q/cache-capabilities-manager.d.ts.map +0 -1
  205. package/declarations/store/-types/q/ds-model.d.ts.map +0 -1
  206. package/declarations/store/-types/q/identifier.d.ts.map +0 -1
  207. package/declarations/store/-types/q/promise-proxies.d.ts +0 -2
  208. package/declarations/store/-types/q/promise-proxies.d.ts.map +0 -1
  209. package/declarations/store/-types/q/record-data-json-api.d.ts +0 -31
  210. package/declarations/store/-types/q/record-data-json-api.d.ts.map +0 -1
  211. package/declarations/store/-types/q/record-instance.d.ts.map +0 -1
  212. package/declarations/store/-types/q/schema-service.d.ts.map +0 -1
  213. package/declarations/store/-types/q/store.d.ts.map +0 -1
  214. package/declarations/store.d.ts.map +0 -1
  215. package/declarations/types/-private.d.ts.map +0 -1
  216. package/declarations/types/cache/aliases.d.ts.map +0 -1
  217. package/declarations/types/cache/change.d.ts.map +0 -1
  218. package/declarations/types/cache/mutations.d.ts.map +0 -1
  219. package/declarations/types/cache/operations.d.ts.map +0 -1
  220. package/declarations/types/cache/relationship.d.ts.map +0 -1
  221. package/declarations/types/cache.d.ts.map +0 -1
  222. package/declarations/types/graph.d.ts.map +0 -1
  223. package/declarations/types/identifier.d.ts.map +0 -1
  224. package/declarations/types/json/raw.d.ts.map +0 -1
  225. package/declarations/types/params.d.ts.map +0 -1
  226. package/declarations/types/record.d.ts.map +0 -1
  227. package/declarations/types/record.type-test.d.ts +0 -2
  228. package/declarations/types/record.type-test.d.ts.map +0 -1
  229. package/declarations/types/request.d.ts.map +0 -1
  230. package/declarations/types/request.type-test.d.ts +0 -2
  231. package/declarations/types/request.type-test.d.ts.map +0 -1
  232. package/declarations/types/runtime.d.ts.map +0 -1
  233. package/declarations/types/schema/concepts.d.ts.map +0 -1
  234. package/declarations/types/schema/fields.d.ts.map +0 -1
  235. package/declarations/types/schema/fields.type-test.d.ts.map +0 -1
  236. package/declarations/types/spec/document.d.ts.map +0 -1
  237. package/declarations/types/spec/error.d.ts.map +0 -1
  238. package/declarations/types/spec/json-api-raw.d.ts.map +0 -1
  239. package/declarations/types/symbols.d.ts.map +0 -1
  240. package/declarations/types/utils.d.ts.map +0 -1
  241. package/declarations/types.d.ts.map +0 -1
  242. package/declarations/utils/string.d.ts.map +0 -1
  243. package/dist/build-config/babel-macros.js.map +0 -1
  244. package/dist/build-config/canary-features.js.map +0 -1
  245. package/dist/build-config/debugging.js.map +0 -1
  246. package/dist/build-config/deprecations.js.map +0 -1
  247. package/dist/build-config/env.js.map +0 -1
  248. package/dist/build-config/macros.js.map +0 -1
  249. package/dist/build-config.js.map +0 -1
  250. package/dist/configure-B48bFHOl.js.map +0 -1
  251. package/dist/configure.js.map +0 -1
  252. package/dist/context-COmAnXUQ.js.map +0 -1
  253. package/dist/graph/-private.js.map +0 -1
  254. package/dist/handler-D1C3Innj.js.map +0 -1
  255. package/dist/index.js.map +0 -1
  256. package/dist/reactive/-private.js.map +0 -1
  257. package/dist/reactive.js.map +0 -1
  258. package/dist/request-state-CCOJIj5i.js.map +0 -1
  259. package/dist/request.js.map +0 -1
  260. package/dist/store/-private.js.map +0 -1
  261. package/dist/store.js.map +0 -1
  262. package/dist/symbols-epHW0Vm9.js.map +0 -1
  263. package/dist/types/-private.js.map +0 -1
  264. package/dist/types/cache/aliases.js.map +0 -1
  265. package/dist/types/cache/change.js.map +0 -1
  266. package/dist/types/cache/mutations.js.map +0 -1
  267. package/dist/types/cache/operations.js.map +0 -1
  268. package/dist/types/cache/relationship.js.map +0 -1
  269. package/dist/types/cache.js.map +0 -1
  270. package/dist/types/graph.js.map +0 -1
  271. package/dist/types/identifier.js.map +0 -1
  272. package/dist/types/json/raw.js.map +0 -1
  273. package/dist/types/params.js.map +0 -1
  274. package/dist/types/record.js.map +0 -1
  275. package/dist/types/request.js.map +0 -1
  276. package/dist/types/runtime.js.map +0 -1
  277. package/dist/types/schema/concepts.js.map +0 -1
  278. package/dist/types/schema/fields.js.map +0 -1
  279. package/dist/types/schema/fields.type-test.js.map +0 -1
  280. package/dist/types/spec/document.js.map +0 -1
  281. package/dist/types/spec/error.js.map +0 -1
  282. package/dist/types/spec/json-api-raw.js.map +0 -1
  283. package/dist/types/symbols.js.map +0 -1
  284. package/dist/types/utils.js.map +0 -1
  285. package/dist/types.js.map +0 -1
  286. package/dist/utils/string.js.map +0 -1
@@ -1,492 +1,503 @@
1
- import type { ResourceBlob } from './cache/aliases.ts';
2
- import type { Change } from './cache/change.ts';
3
- import type { Mutation } from './cache/mutations.ts';
4
- import type { Operation } from './cache/operations.ts';
5
- import type { CollectionRelationship, ResourceRelationship } from './cache/relationship.ts';
6
- import type { StableDocumentIdentifier, StableRecordIdentifier } from './identifier.ts';
7
- import type { Value } from './json/raw.ts';
8
- import type { TypeFromInstanceOrString } from './record.ts';
9
- import type { RequestContext, StructuredDataDocument, StructuredDocument } from './request.ts';
10
- import type { ResourceDocument, SingleResourceDataDocument } from './spec/document.ts';
11
- import type { ApiError } from './spec/error.ts';
1
+ import type { ResourceBlob } from "./cache/aliases.js";
2
+ import type { Change } from "./cache/change.js";
3
+ import type { Mutation } from "./cache/mutations.js";
4
+ import type { Operation } from "./cache/operations.js";
5
+ import type { CollectionRelationship, ResourceRelationship } from "./cache/relationship.js";
6
+ import type { StableDocumentIdentifier, StableRecordIdentifier } from "./identifier.js";
7
+ import type { Value } from "./json/raw.js";
8
+ import type { TypeFromInstanceOrString } from "./record.js";
9
+ import type { RequestContext, StructuredDataDocument, StructuredDocument } from "./request.js";
10
+ import type { ResourceDocument, SingleResourceDataDocument } from "./spec/document.js";
11
+ import type { ApiError } from "./spec/error.js";
12
12
  /**
13
- * A hash of changed attributes with the key being the attribute name and the value being an
14
- * array of `[oldValue, newValue]`.
15
- *
16
- * @internal
17
- */
13
+ * A hash of changed attributes with the key being the attribute name and the value being an
14
+ * array of `[oldValue, newValue]`.
15
+ *
16
+ * @internal
17
+ */
18
18
  export type ChangedAttributesHash = Record<string, [Value | undefined, Value]>;
19
19
  export type RelationshipDiff = {
20
- kind: 'collection';
21
- remoteState: StableRecordIdentifier[];
22
- additions: Set<StableRecordIdentifier>;
23
- removals: Set<StableRecordIdentifier>;
24
- localState: StableRecordIdentifier[];
25
- reordered: boolean;
20
+ kind: "collection";
21
+ remoteState: StableRecordIdentifier[];
22
+ additions: Set<StableRecordIdentifier>;
23
+ removals: Set<StableRecordIdentifier>;
24
+ localState: StableRecordIdentifier[];
25
+ reordered: boolean;
26
26
  } | {
27
- kind: 'resource';
28
- remoteState: StableRecordIdentifier | null;
29
- localState: StableRecordIdentifier | null;
27
+ kind: "resource";
28
+ remoteState: StableRecordIdentifier | null;
29
+ localState: StableRecordIdentifier | null;
30
30
  };
31
31
  /**
32
- * The interface for WarpDrive Caches.
33
- *
34
- * A Cache handles in-memory storage of Document and Resource
35
- * data.
36
- *
37
- * @class (Interface) Cache
38
- * @public
39
- */
32
+ * The interface for WarpDrive Caches.
33
+ *
34
+ * A Cache handles in-memory storage of Document and Resource
35
+ * data.
36
+ *
37
+ * @class (Interface) Cache
38
+ * @public
39
+ */
40
40
  export interface Cache {
41
- /**
42
- * The Cache Version that this implementation implements.
43
- *
44
- * @type {'2'}
45
- * @public
46
- * @property version
47
- */
48
- version: '2';
49
- /**
50
- * Cache the response to a request
51
- *
52
- * Unlike `store.push` which has UPSERT
53
- * semantics, `put` has `replace` semantics similar to
54
- * the `http` method `PUT`
55
- *
56
- * the individually cacheable resource data it may contain
57
- * should upsert, but the document data surrounding it should
58
- * fully replace any existing information
59
- *
60
- * Note that in order to support inserting arbitrary data
61
- * to the cache that did not originate from a request `put`
62
- * should expect to sometimes encounter a document with only
63
- * a `content` member and therefor must not assume the existence
64
- * of `request` and `response` on the document.
65
- *
66
- * @param {StructuredDocument} doc
67
- * @return {ResourceDocument}
68
- * @public
69
- */
70
- put<T>(doc: StructuredDocument<T> | {
71
- content: T;
72
- }): ResourceDocument;
73
- /**
74
- * Update the "remote" or "canonical" (persisted) state of the Cache
75
- * by merging new information into the existing state.
76
- *
77
- * @public
78
- * @param {Operation | Operation[]} op the operation(s) to perform
79
- * @return {void}
80
- */
81
- patch(op: Operation | Operation[]): void;
82
- /**
83
- * Update the "local" or "current" (unpersisted) state of the Cache
84
- *
85
- * @param {Mutation} mutation
86
- * @return {void}
87
- * @public
88
- */
89
- mutate(mutation: Mutation): void;
90
- /**
91
- * Peek resource data from the Cache.
92
- *
93
- * In development, if the return value
94
- * is JSON the return value
95
- * will be deep-cloned and deep-frozen
96
- * to prevent mutation thereby enforcing cache
97
- * Immutability.
98
- *
99
- * This form of peek is useful for implementations
100
- * that want to feed raw-data from cache to the UI
101
- * or which want to interact with a blob of data
102
- * directly from the presentation cache.
103
- *
104
- * An implementation might want to do this because
105
- * de-referencing records which read from their own
106
- * blob is generally safer because the record does
107
- * not require retainining connections to the Store
108
- * and Cache to present data on a per-field basis.
109
- *
110
- * This generally takes the place of `getAttr` as
111
- * an API and may even take the place of `getRelationship`
112
- * depending on implementation specifics, though this
113
- * latter usage is less recommended due to the advantages
114
- * of the Graph handling necessary entanglements and
115
- * notifications for relational data.
116
- *
117
- * @public
118
- * @param {StableRecordIdentifier | StableDocumentIdentifier} identifier
119
- * @return {ResourceDocument | ResourceBlob | null} the known resource data
120
- */
121
- peek<T = unknown>(identifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>): T | null;
122
- peek(identifier: StableDocumentIdentifier): ResourceDocument | null;
123
- /**
124
- * Peek remote resource data from the Cache.
125
- *
126
- * This will give the data provided from the server without any local changes.
127
- *
128
- * In development, if the return value
129
- * is JSON the return value
130
- * will be deep-cloned and deep-frozen
131
- * to prevent mutation thereby enforcing cache
132
- * Immutability.
133
- *
134
- * This form of peek is useful for implementations
135
- * that want to feed raw-data from cache to the UI
136
- * or which want to interact with a blob of data
137
- * directly from the presentation cache.
138
- *
139
- * An implementation might want to do this because
140
- * de-referencing records which read from their own
141
- * blob is generally safer because the record does
142
- * not require retainining connections to the Store
143
- * and Cache to present data on a per-field basis.
144
- *
145
- * This generally takes the place of `getAttr` as
146
- * an API and may even take the place of `getRelationship`
147
- * depending on implementation specifics, though this
148
- * latter usage is less recommended due to the advantages
149
- * of the Graph handling necessary entanglements and
150
- * notifications for relational data.
151
- *
152
- * @public
153
- * @param {StableRecordIdentifier | StableDocumentIdentifier} identifier
154
- * @return {ResourceDocument | ResourceBlob | null} the known resource data
155
- */
156
- peekRemoteState<T = unknown>(identifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>): T | null;
157
- peekRemoteState(identifier: StableDocumentIdentifier): ResourceDocument | null;
158
- /**
159
- * Peek the Cache for the existing request data associated with
160
- * a cacheable request
161
- *
162
- * This is effectively the reverse of `put` for a request in
163
- * that it will return the the request, response, and content
164
- * whereas `peek` will return just the `content`.
165
- *
166
- * @param {StableDocumentIdentifier}
167
- * @return {StructuredDocument<ResourceDocument> | null}
168
- * @public
169
- */
170
- peekRequest(identifier: StableDocumentIdentifier): StructuredDocument<ResourceDocument> | null;
171
- /**
172
- * Push resource data from a remote source into the cache for this identifier
173
- *
174
- * @public
175
- * @param identifier
176
- * @param data
177
- * @param hasRecord
178
- * @return {void | string[]} if `hasRecord` is true then calculated key changes should be returned
179
- */
180
- upsert(identifier: StableRecordIdentifier, data: ResourceBlob, hasRecord: boolean): void | string[];
181
- /**
182
- * Create a fork of the cache from the current state.
183
- *
184
- * Applications should typically not call this method themselves,
185
- * preferring instead to fork at the Store level, which will
186
- * utilize this method to fork the cache.
187
- *
188
- * @public
189
- * @return {Promise<Cache>}
190
- */
191
- fork(): Promise<Cache>;
192
- /**
193
- * Merge a fork back into a parent Cache.
194
- *
195
- * Applications should typically not call this method themselves,
196
- * preferring instead to merge at the Store level, which will
197
- * utilize this method to merge the caches.
198
- *
199
- * @param {Cache} cache
200
- * @public
201
- * @return {Promise<void>}
202
- */
203
- merge(cache: Cache): Promise<void>;
204
- /**
205
- * Generate the list of changes applied to all
206
- * record in the store.
207
- *
208
- * Each individual resource or document that has
209
- * been mutated should be described as an individual
210
- * `Change` entry in the returned array.
211
- *
212
- * A `Change` is described by an object containing up to
213
- * three properties: (1) the `identifier` of the entity that
214
- * changed; (2) the `op` code of that change being one of
215
- * `upsert` or `remove`, and if the op is `upsert` a `patch`
216
- * containing the data to merge into the cache for the given
217
- * entity.
218
- *
219
- * This `patch` is opaque to the Store but should be understood
220
- * by the Cache and may expect to be utilized by an Adapter
221
- * when generating data during a `save` operation.
222
- *
223
- * It is generally recommended that the `patch` contain only
224
- * the updated state, ignoring fields that are unchanged
225
- *
226
- * ```ts
227
- * interface Change {
228
- * identifier: StableRecordIdentifier | StableDocumentIdentifier;
229
- * op: 'upsert' | 'remove';
230
- * patch?: unknown;
231
- * }
232
- * ```
233
- *
234
- * @public
235
- */
236
- diff(): Promise<Change[]>;
237
- /**
238
- * Serialize the entire contents of the Cache into a Stream
239
- * which may be fed back into a new instance of the same Cache
240
- * via `cache.hydrate`.
241
- *
242
- * @return {Promise<ReadableStream>}
243
- * @public
244
- */
245
- dump(): Promise<ReadableStream<unknown>>;
246
- /**
247
- * hydrate a Cache from a Stream with content previously serialized
248
- * from another instance of the same Cache, resolving when hydration
249
- * is complete.
250
- *
251
- * This method should expect to be called both in the context of restoring
252
- * the Cache during application rehydration after SSR **AND** at unknown
253
- * times during the lifetime of an already booted application when it is
254
- * desired to bulk-load additional information into the cache. This latter
255
- * behavior supports optimizing pre/fetching of data for route transitions
256
- * via data-only SSR modes.
257
- *
258
- * @param {ReadableStream} stream
259
- * @return {Promise<void>}
260
- * @public
261
- */
262
- hydrate(stream: ReadableStream<unknown>): Promise<void>;
263
- /**
264
- * [LIFECYCLE] Signal to the cache that a new record has been instantiated on the client
265
- *
266
- * It returns properties from options that should be set on the record during the create
267
- * process. This return value behavior is deprecated.
268
- *
269
- * @public
270
- * @param identifier
271
- * @param createArgs
272
- */
273
- clientDidCreate(identifier: StableRecordIdentifier, createArgs?: Record<string, unknown>): Record<string, unknown>;
274
- /**
275
- * [LIFECYCLE] Signals to the cache that a resource
276
- * will be part of a save transaction.
277
- *
278
- * @public
279
- * @param identifier
280
- */
281
- willCommit(identifier: StableRecordIdentifier, context: RequestContext): void;
282
- /**
283
- * [LIFECYCLE] Signals to the cache that a resource
284
- * was successfully updated as part of a save transaction.
285
- *
286
- * @public
287
- * @param identifier - the primary identifier that was operated on
288
- * @param data - a document in the cache format containing any updated data
289
- * @return {SingleResourceDataDocument}
290
- */
291
- didCommit(identifier: StableRecordIdentifier, result: StructuredDataDocument<unknown>): SingleResourceDataDocument;
292
- /**
293
- * [LIFECYCLE] Signals to the cache that a resource
294
- * was update via a save transaction failed.
295
- *
296
- * @public
297
- * @param identifier
298
- * @param errors
299
- */
300
- commitWasRejected(identifier: StableRecordIdentifier, errors?: ApiError[]): void;
301
- /**
302
- * [LIFECYCLE] Signals to the cache that all data for a resource
303
- * should be cleared.
304
- *
305
- * This method is a candidate to become a mutation
306
- *
307
- * @public
308
- * @param identifier
309
- */
310
- unloadRecord(identifier: StableRecordIdentifier): void;
311
- /**
312
- * Retrieve the data for an attribute from the cache
313
- *
314
- * @public
315
- * @param identifier
316
- * @param field
317
- * @return {unknown}
318
- */
319
- getAttr(identifier: StableRecordIdentifier, field: string | string[]): Value | undefined;
320
- /**
321
- * Retrieve remote state without any local changes for a specific attribute
322
- *
323
- * @public
324
- * @param identifier
325
- * @param field
326
- * @return {unknown}
327
- */
328
- getRemoteAttr(identifier: StableRecordIdentifier, field: string | string[]): Value | undefined;
329
- /**
330
- * Mutate the data for an attribute in the cache
331
- *
332
- * This method is a candidate to become a mutation
333
- *
334
- * @public
335
- * @param identifier
336
- * @param field
337
- * @param value
338
- */
339
- setAttr(identifier: StableRecordIdentifier, field: string | string[], value: Value): void;
340
- /**
341
- * Query the cache for the changed attributes of a resource.
342
- *
343
- * Returns a map of field names to tuples of [old, new] values
344
- *
345
- * ```
346
- * { <field>: [<old>, <new>] }
347
- * ```
348
- *
349
- * @public
350
- * @param identifier
351
- * @return {Record<string, [unknown, unknown]>} `{ <field>: [<old>, <new>] }`
352
- */
353
- changedAttrs(identifier: StableRecordIdentifier): ChangedAttributesHash;
354
- /**
355
- * Query the cache for whether any mutated attributes exist
356
- *
357
- * @public
358
- * @param identifier
359
- * @return {Boolean}
360
- */
361
- hasChangedAttrs(identifier: StableRecordIdentifier): boolean;
362
- /**
363
- * Tell the cache to discard any uncommitted mutations to attributes
364
- *
365
- * This method is a candidate to become a mutation
366
- *
367
- * @public
368
- * @param identifier
369
- * @return {String[]} the names of fields that were restored
370
- */
371
- rollbackAttrs(identifier: StableRecordIdentifier): string[];
372
- /**
373
- * Query the cache for the changes to relationships of a resource.
374
- *
375
- * Returns a map of relationship names to RelationshipDiff objects.
376
- *
377
- * ```ts
378
- * type RelationshipDiff =
379
- | {
380
- kind: 'collection';
381
- remoteState: StableRecordIdentifier[];
382
- additions: Set<StableRecordIdentifier>;
383
- removals: Set<StableRecordIdentifier>;
384
- localState: StableRecordIdentifier[];
385
- reordered: boolean;
386
- }
387
- | {
388
- kind: 'resource';
389
- remoteState: StableRecordIdentifier | null;
390
- localState: StableRecordIdentifier | null;
391
- };
392
- ```
393
- *
394
- * @public
395
- * @param {StableRecordIdentifier} identifier
396
- * @return {Map<string, RelationshipDiff>}
397
- */
398
- changedRelationships(identifier: StableRecordIdentifier): Map<string, RelationshipDiff>;
399
- /**
400
- * Query the cache for whether any mutated attributes exist
401
- *
402
- * @public
403
- * @param {StableRecordIdentifier} identifier
404
- * @return {Boolean}
405
- */
406
- hasChangedRelationships(identifier: StableRecordIdentifier): boolean;
407
- /**
408
- * Tell the cache to discard any uncommitted mutations to relationships.
409
- *
410
- * This will also discard the change on any appropriate inverses.
411
- *
412
- * This method is a candidate to become a mutation
413
- *
414
- * @public
415
- * @param {StableRecordIdentifier} identifier
416
- * @return {String[]} the names of relationships that were restored
417
- */
418
- rollbackRelationships(identifier: StableRecordIdentifier): string[];
419
- /**
420
- * Query the cache for the current state of a relationship property
421
- *
422
- * @public
423
- * @param {StableRecordIdentifier} identifier
424
- * @param {String} field
425
- * @return resource relationship object
426
- */
427
- getRelationship(identifier: StableRecordIdentifier, field: string, isCollection?: boolean): ResourceRelationship | CollectionRelationship;
428
- /**
429
- * Query the cache for the server state of a relationship property without any local changes
430
- *
431
- * @public
432
- * @param {StableRecordIdentifier} identifier
433
- * @param {String} field
434
- * @return resource relationship object
435
- */
436
- getRemoteRelationship(identifier: StableRecordIdentifier, field: string, isCollection?: boolean): ResourceRelationship | CollectionRelationship;
437
- /**
438
- * Update the cache state for the given resource to be marked
439
- * as locally deleted, or remove such a mark.
440
- *
441
- * This method is a candidate to become a mutation
442
- *
443
- * @public
444
- * @param identifier
445
- * @param {Boolean} isDeleted
446
- */
447
- setIsDeleted(identifier: StableRecordIdentifier, isDeleted: boolean): void;
448
- /**
449
- * Query the cache for any validation errors applicable to the given resource.
450
- *
451
- * @public
452
- * @param identifier
453
- * @return {JsonApiError[]}
454
- */
455
- getErrors(identifier: StableRecordIdentifier): ApiError[];
456
- /**
457
- * Query the cache for whether a given resource has any available data
458
- *
459
- * @public
460
- * @param identifier
461
- * @return {Boolean}
462
- */
463
- isEmpty(identifier: StableRecordIdentifier): boolean;
464
- /**
465
- * Query the cache for whether a given resource was created locally and not
466
- * yet persisted.
467
- *
468
- * @public
469
- * @param identifier
470
- * @return {Boolean}
471
- */
472
- isNew(identifier: StableRecordIdentifier): boolean;
473
- /**
474
- * Query the cache for whether a given resource is marked as deleted (but not
475
- * necessarily persisted yet).
476
- *
477
- * @public
478
- * @param identifier
479
- * @return {Boolean}
480
- */
481
- isDeleted(identifier: StableRecordIdentifier): boolean;
482
- /**
483
- * Query the cache for whether a given resource has been deleted and that deletion
484
- * has also been persisted.
485
- *
486
- * @public
487
- * @param identifier
488
- * @return {Boolean}
489
- */
490
- isDeletionCommitted(identifier: StableRecordIdentifier): boolean;
41
+ /**
42
+ * The Cache Version that this implementation implements.
43
+ *
44
+ * @type {'2'}
45
+ * @public
46
+ * @property version
47
+ */
48
+ version: "2";
49
+ // Cache Management
50
+ // ================
51
+ /**
52
+ * Cache the response to a request
53
+ *
54
+ * Unlike `store.push` which has UPSERT
55
+ * semantics, `put` has `replace` semantics similar to
56
+ * the `http` method `PUT`
57
+ *
58
+ * the individually cacheable resource data it may contain
59
+ * should upsert, but the document data surrounding it should
60
+ * fully replace any existing information
61
+ *
62
+ * Note that in order to support inserting arbitrary data
63
+ * to the cache that did not originate from a request `put`
64
+ * should expect to sometimes encounter a document with only
65
+ * a `content` member and therefor must not assume the existence
66
+ * of `request` and `response` on the document.
67
+ *
68
+ * @param {StructuredDocument} doc
69
+ * @return {ResourceDocument}
70
+ * @public
71
+ */
72
+ put<T>(doc: StructuredDocument<T> | {
73
+ content: T;
74
+ }): ResourceDocument;
75
+ /**
76
+ * Update the "remote" or "canonical" (persisted) state of the Cache
77
+ * by merging new information into the existing state.
78
+ *
79
+ * @public
80
+ * @param {Operation | Operation[]} op the operation(s) to perform
81
+ * @return {void}
82
+ */
83
+ patch(op: Operation | Operation[]): void;
84
+ /**
85
+ * Update the "local" or "current" (unpersisted) state of the Cache
86
+ *
87
+ * @param {Mutation} mutation
88
+ * @return {void}
89
+ * @public
90
+ */
91
+ mutate(mutation: Mutation): void;
92
+ /**
93
+ * Peek resource data from the Cache.
94
+ *
95
+ * In development, if the return value
96
+ * is JSON the return value
97
+ * will be deep-cloned and deep-frozen
98
+ * to prevent mutation thereby enforcing cache
99
+ * Immutability.
100
+ *
101
+ * This form of peek is useful for implementations
102
+ * that want to feed raw-data from cache to the UI
103
+ * or which want to interact with a blob of data
104
+ * directly from the presentation cache.
105
+ *
106
+ * An implementation might want to do this because
107
+ * de-referencing records which read from their own
108
+ * blob is generally safer because the record does
109
+ * not require retainining connections to the Store
110
+ * and Cache to present data on a per-field basis.
111
+ *
112
+ * This generally takes the place of `getAttr` as
113
+ * an API and may even take the place of `getRelationship`
114
+ * depending on implementation specifics, though this
115
+ * latter usage is less recommended due to the advantages
116
+ * of the Graph handling necessary entanglements and
117
+ * notifications for relational data.
118
+ *
119
+ * @public
120
+ * @param {StableRecordIdentifier | StableDocumentIdentifier} identifier
121
+ * @return {ResourceDocument | ResourceBlob | null} the known resource data
122
+ */
123
+ peek<T = unknown>(identifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>): T | null;
124
+ peek(identifier: StableDocumentIdentifier): ResourceDocument | null;
125
+ /**
126
+ * Peek remote resource data from the Cache.
127
+ *
128
+ * This will give the data provided from the server without any local changes.
129
+ *
130
+ * In development, if the return value
131
+ * is JSON the return value
132
+ * will be deep-cloned and deep-frozen
133
+ * to prevent mutation thereby enforcing cache
134
+ * Immutability.
135
+ *
136
+ * This form of peek is useful for implementations
137
+ * that want to feed raw-data from cache to the UI
138
+ * or which want to interact with a blob of data
139
+ * directly from the presentation cache.
140
+ *
141
+ * An implementation might want to do this because
142
+ * de-referencing records which read from their own
143
+ * blob is generally safer because the record does
144
+ * not require retainining connections to the Store
145
+ * and Cache to present data on a per-field basis.
146
+ *
147
+ * This generally takes the place of `getAttr` as
148
+ * an API and may even take the place of `getRelationship`
149
+ * depending on implementation specifics, though this
150
+ * latter usage is less recommended due to the advantages
151
+ * of the Graph handling necessary entanglements and
152
+ * notifications for relational data.
153
+ *
154
+ * @public
155
+ * @param {StableRecordIdentifier | StableDocumentIdentifier} identifier
156
+ * @return {ResourceDocument | ResourceBlob | null} the known resource data
157
+ */
158
+ peekRemoteState<T = unknown>(identifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>): T | null;
159
+ peekRemoteState(identifier: StableDocumentIdentifier): ResourceDocument | null;
160
+ /**
161
+ * Peek the Cache for the existing request data associated with
162
+ * a cacheable request
163
+ *
164
+ * This is effectively the reverse of `put` for a request in
165
+ * that it will return the the request, response, and content
166
+ * whereas `peek` will return just the `content`.
167
+ *
168
+ * @param {StableDocumentIdentifier}
169
+ * @return {StructuredDocument<ResourceDocument> | null}
170
+ * @public
171
+ */
172
+ peekRequest(identifier: StableDocumentIdentifier): StructuredDocument<ResourceDocument> | null;
173
+ /**
174
+ * Push resource data from a remote source into the cache for this identifier
175
+ *
176
+ * @public
177
+ * @param identifier
178
+ * @param data
179
+ * @param hasRecord
180
+ * @return {void | string[]} if `hasRecord` is true then calculated key changes should be returned
181
+ */
182
+ upsert(identifier: StableRecordIdentifier, data: ResourceBlob, hasRecord: boolean): void | string[];
183
+ // Cache Forking Support
184
+ // =====================
185
+ /**
186
+ * Create a fork of the cache from the current state.
187
+ *
188
+ * Applications should typically not call this method themselves,
189
+ * preferring instead to fork at the Store level, which will
190
+ * utilize this method to fork the cache.
191
+ *
192
+ * @public
193
+ * @return {Promise<Cache>}
194
+ */
195
+ fork(): Promise<Cache>;
196
+ /**
197
+ * Merge a fork back into a parent Cache.
198
+ *
199
+ * Applications should typically not call this method themselves,
200
+ * preferring instead to merge at the Store level, which will
201
+ * utilize this method to merge the caches.
202
+ *
203
+ * @param {Cache} cache
204
+ * @public
205
+ * @return {Promise<void>}
206
+ */
207
+ merge(cache: Cache): Promise<void>;
208
+ /**
209
+ * Generate the list of changes applied to all
210
+ * record in the store.
211
+ *
212
+ * Each individual resource or document that has
213
+ * been mutated should be described as an individual
214
+ * `Change` entry in the returned array.
215
+ *
216
+ * A `Change` is described by an object containing up to
217
+ * three properties: (1) the `identifier` of the entity that
218
+ * changed; (2) the `op` code of that change being one of
219
+ * `upsert` or `remove`, and if the op is `upsert` a `patch`
220
+ * containing the data to merge into the cache for the given
221
+ * entity.
222
+ *
223
+ * This `patch` is opaque to the Store but should be understood
224
+ * by the Cache and may expect to be utilized by an Adapter
225
+ * when generating data during a `save` operation.
226
+ *
227
+ * It is generally recommended that the `patch` contain only
228
+ * the updated state, ignoring fields that are unchanged
229
+ *
230
+ * ```ts
231
+ * interface Change {
232
+ * identifier: StableRecordIdentifier | StableDocumentIdentifier;
233
+ * op: 'upsert' | 'remove';
234
+ * patch?: unknown;
235
+ * }
236
+ * ```
237
+ *
238
+ * @public
239
+ */
240
+ diff(): Promise<Change[]>;
241
+ // SSR Support
242
+ // ===========
243
+ /**
244
+ * Serialize the entire contents of the Cache into a Stream
245
+ * which may be fed back into a new instance of the same Cache
246
+ * via `cache.hydrate`.
247
+ *
248
+ * @return {Promise<ReadableStream>}
249
+ * @public
250
+ */
251
+ dump(): Promise<ReadableStream<unknown>>;
252
+ /**
253
+ * hydrate a Cache from a Stream with content previously serialized
254
+ * from another instance of the same Cache, resolving when hydration
255
+ * is complete.
256
+ *
257
+ * This method should expect to be called both in the context of restoring
258
+ * the Cache during application rehydration after SSR **AND** at unknown
259
+ * times during the lifetime of an already booted application when it is
260
+ * desired to bulk-load additional information into the cache. This latter
261
+ * behavior supports optimizing pre/fetching of data for route transitions
262
+ * via data-only SSR modes.
263
+ *
264
+ * @param {ReadableStream} stream
265
+ * @return {Promise<void>}
266
+ * @public
267
+ */
268
+ hydrate(stream: ReadableStream<unknown>): Promise<void>;
269
+ // Resource Support
270
+ // ================
271
+ /**
272
+ * [LIFECYCLE] Signal to the cache that a new record has been instantiated on the client
273
+ *
274
+ * It returns properties from options that should be set on the record during the create
275
+ * process. This return value behavior is deprecated.
276
+ *
277
+ * @public
278
+ * @param identifier
279
+ * @param createArgs
280
+ */
281
+ clientDidCreate(identifier: StableRecordIdentifier, createArgs?: Record<string, unknown>): Record<string, unknown>;
282
+ /**
283
+ * [LIFECYCLE] Signals to the cache that a resource
284
+ * will be part of a save transaction.
285
+ *
286
+ * @public
287
+ * @param identifier
288
+ */
289
+ willCommit(identifier: StableRecordIdentifier, context: RequestContext): void;
290
+ /**
291
+ * [LIFECYCLE] Signals to the cache that a resource
292
+ * was successfully updated as part of a save transaction.
293
+ *
294
+ * @public
295
+ * @param identifier - the primary identifier that was operated on
296
+ * @param data - a document in the cache format containing any updated data
297
+ * @return {SingleResourceDataDocument}
298
+ */
299
+ didCommit(identifier: StableRecordIdentifier, result: StructuredDataDocument<unknown>): SingleResourceDataDocument;
300
+ /**
301
+ * [LIFECYCLE] Signals to the cache that a resource
302
+ * was update via a save transaction failed.
303
+ *
304
+ * @public
305
+ * @param identifier
306
+ * @param errors
307
+ */
308
+ commitWasRejected(identifier: StableRecordIdentifier, errors?: ApiError[]): void;
309
+ /**
310
+ * [LIFECYCLE] Signals to the cache that all data for a resource
311
+ * should be cleared.
312
+ *
313
+ * This method is a candidate to become a mutation
314
+ *
315
+ * @public
316
+ * @param identifier
317
+ */
318
+ unloadRecord(identifier: StableRecordIdentifier): void;
319
+ // Granular Resource Data APIs
320
+ // ===========================
321
+ /**
322
+ * Retrieve the data for an attribute from the cache
323
+ *
324
+ * @public
325
+ * @param identifier
326
+ * @param field
327
+ * @return {unknown}
328
+ */
329
+ getAttr(identifier: StableRecordIdentifier, field: string | string[]): Value | undefined;
330
+ /**
331
+ * Retrieve remote state without any local changes for a specific attribute
332
+ *
333
+ * @public
334
+ * @param identifier
335
+ * @param field
336
+ * @return {unknown}
337
+ */
338
+ getRemoteAttr(identifier: StableRecordIdentifier, field: string | string[]): Value | undefined;
339
+ /**
340
+ * Mutate the data for an attribute in the cache
341
+ *
342
+ * This method is a candidate to become a mutation
343
+ *
344
+ * @public
345
+ * @param identifier
346
+ * @param field
347
+ * @param value
348
+ */
349
+ setAttr(identifier: StableRecordIdentifier, field: string | string[], value: Value): void;
350
+ /**
351
+ * Query the cache for the changed attributes of a resource.
352
+ *
353
+ * Returns a map of field names to tuples of [old, new] values
354
+ *
355
+ * ```
356
+ * { <field>: [<old>, <new>] }
357
+ * ```
358
+ *
359
+ * @public
360
+ * @param identifier
361
+ * @return {Record<string, [unknown, unknown]>} `{ <field>: [<old>, <new>] }`
362
+ */
363
+ changedAttrs(identifier: StableRecordIdentifier): ChangedAttributesHash;
364
+ /**
365
+ * Query the cache for whether any mutated attributes exist
366
+ *
367
+ * @public
368
+ * @param identifier
369
+ * @return {Boolean}
370
+ */
371
+ hasChangedAttrs(identifier: StableRecordIdentifier): boolean;
372
+ /**
373
+ * Tell the cache to discard any uncommitted mutations to attributes
374
+ *
375
+ * This method is a candidate to become a mutation
376
+ *
377
+ * @public
378
+ * @param identifier
379
+ * @return {String[]} the names of fields that were restored
380
+ */
381
+ rollbackAttrs(identifier: StableRecordIdentifier): string[];
382
+ /**
383
+ * Query the cache for the changes to relationships of a resource.
384
+ *
385
+ * Returns a map of relationship names to RelationshipDiff objects.
386
+ *
387
+ * ```ts
388
+ * type RelationshipDiff =
389
+ | {
390
+ kind: 'collection';
391
+ remoteState: StableRecordIdentifier[];
392
+ additions: Set<StableRecordIdentifier>;
393
+ removals: Set<StableRecordIdentifier>;
394
+ localState: StableRecordIdentifier[];
395
+ reordered: boolean;
396
+ }
397
+ | {
398
+ kind: 'resource';
399
+ remoteState: StableRecordIdentifier | null;
400
+ localState: StableRecordIdentifier | null;
401
+ };
402
+ ```
403
+ *
404
+ * @public
405
+ * @param {StableRecordIdentifier} identifier
406
+ * @return {Map<string, RelationshipDiff>}
407
+ */
408
+ changedRelationships(identifier: StableRecordIdentifier): Map<string, RelationshipDiff>;
409
+ /**
410
+ * Query the cache for whether any mutated attributes exist
411
+ *
412
+ * @public
413
+ * @param {StableRecordIdentifier} identifier
414
+ * @return {Boolean}
415
+ */
416
+ hasChangedRelationships(identifier: StableRecordIdentifier): boolean;
417
+ /**
418
+ * Tell the cache to discard any uncommitted mutations to relationships.
419
+ *
420
+ * This will also discard the change on any appropriate inverses.
421
+ *
422
+ * This method is a candidate to become a mutation
423
+ *
424
+ * @public
425
+ * @param {StableRecordIdentifier} identifier
426
+ * @return {String[]} the names of relationships that were restored
427
+ */
428
+ rollbackRelationships(identifier: StableRecordIdentifier): string[];
429
+ /**
430
+ * Query the cache for the current state of a relationship property
431
+ *
432
+ * @public
433
+ * @param {StableRecordIdentifier} identifier
434
+ * @param {String} field
435
+ * @return resource relationship object
436
+ */
437
+ getRelationship(identifier: StableRecordIdentifier, field: string, isCollection?: boolean): ResourceRelationship | CollectionRelationship;
438
+ /**
439
+ * Query the cache for the server state of a relationship property without any local changes
440
+ *
441
+ * @public
442
+ * @param {StableRecordIdentifier} identifier
443
+ * @param {String} field
444
+ * @return resource relationship object
445
+ */
446
+ getRemoteRelationship(identifier: StableRecordIdentifier, field: string, isCollection?: boolean): ResourceRelationship | CollectionRelationship;
447
+ // Resource State
448
+ // ===============
449
+ /**
450
+ * Update the cache state for the given resource to be marked
451
+ * as locally deleted, or remove such a mark.
452
+ *
453
+ * This method is a candidate to become a mutation
454
+ *
455
+ * @public
456
+ * @param identifier
457
+ * @param {Boolean} isDeleted
458
+ */
459
+ setIsDeleted(identifier: StableRecordIdentifier, isDeleted: boolean): void;
460
+ /**
461
+ * Query the cache for any validation errors applicable to the given resource.
462
+ *
463
+ * @public
464
+ * @param identifier
465
+ * @return {JsonApiError[]}
466
+ */
467
+ getErrors(identifier: StableRecordIdentifier): ApiError[];
468
+ /**
469
+ * Query the cache for whether a given resource has any available data
470
+ *
471
+ * @public
472
+ * @param identifier
473
+ * @return {Boolean}
474
+ */
475
+ isEmpty(identifier: StableRecordIdentifier): boolean;
476
+ /**
477
+ * Query the cache for whether a given resource was created locally and not
478
+ * yet persisted.
479
+ *
480
+ * @public
481
+ * @param identifier
482
+ * @return {Boolean}
483
+ */
484
+ isNew(identifier: StableRecordIdentifier): boolean;
485
+ /**
486
+ * Query the cache for whether a given resource is marked as deleted (but not
487
+ * necessarily persisted yet).
488
+ *
489
+ * @public
490
+ * @param identifier
491
+ * @return {Boolean}
492
+ */
493
+ isDeleted(identifier: StableRecordIdentifier): boolean;
494
+ /**
495
+ * Query the cache for whether a given resource has been deleted and that deletion
496
+ * has also been persisted.
497
+ *
498
+ * @public
499
+ * @param identifier
500
+ * @return {Boolean}
501
+ */
502
+ isDeletionCommitted(identifier: StableRecordIdentifier): boolean;
491
503
  }
492
- //# sourceMappingURL=cache.d.ts.map