@warp-drive/core 5.6.0-alpha.5 → 5.6.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/README.md +8 -7
  2. package/cjs-dist/addon-shim.cjs +1 -0
  3. package/cjs-dist/cjs-set-config.cjs +1 -0
  4. package/declarations/build-config/babel-macros.d.ts +1 -0
  5. package/declarations/build-config/canary-features.d.ts +1 -0
  6. package/declarations/build-config/debugging.d.ts +1 -0
  7. package/declarations/build-config/deprecations.d.ts +1 -0
  8. package/declarations/build-config/env.d.ts +1 -0
  9. package/declarations/build-config/macros.d.ts +1 -0
  10. package/declarations/build-config.d.ts +1 -0
  11. package/declarations/configure.d.ts +7 -0
  12. package/declarations/graph/-private/-diff.d.ts +32 -0
  13. package/declarations/graph/-private/-edge-definition.d.ts +148 -0
  14. package/declarations/graph/-private/-state.d.ts +96 -0
  15. package/declarations/graph/-private/-utils.d.ts +31 -0
  16. package/declarations/graph/-private/coerce-id.d.ts +10 -0
  17. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +18 -0
  18. package/declarations/graph/-private/edges/collection.d.ts +39 -0
  19. package/declarations/graph/-private/edges/implicit.d.ts +43 -0
  20. package/declarations/graph/-private/edges/resource.d.ts +24 -0
  21. package/declarations/graph/-private/graph.d.ts +90 -0
  22. package/declarations/graph/-private/normalize-link.d.ts +8 -0
  23. package/declarations/graph/-private/operations/add-to-related-records.d.ts +4 -0
  24. package/declarations/graph/-private/operations/merge-identifier.d.ts +3 -0
  25. package/declarations/graph/-private/operations/remove-from-related-records.d.ts +4 -0
  26. package/declarations/graph/-private/operations/replace-related-record.d.ts +3 -0
  27. package/declarations/graph/-private/operations/replace-related-records.d.ts +62 -0
  28. package/declarations/graph/-private/operations/update-relationship.d.ts +13 -0
  29. package/declarations/graph/-private.d.ts +13 -0
  30. package/declarations/index.d.ts +14 -3
  31. package/declarations/reactive/-private/document.d.ts +146 -0
  32. package/declarations/reactive/-private/fields/compute.d.ts +43 -0
  33. package/declarations/reactive/-private/fields/extension.d.ts +8 -0
  34. package/declarations/reactive/-private/fields/managed-array.d.ts +22 -0
  35. package/declarations/reactive/-private/fields/managed-object.d.ts +21 -0
  36. package/declarations/reactive/-private/fields/many-array-manager.d.ts +19 -0
  37. package/declarations/reactive/-private/hooks.d.ts +5 -0
  38. package/declarations/reactive/-private/record.d.ts +64 -0
  39. package/declarations/reactive/-private/schema.d.ts +271 -0
  40. package/declarations/reactive/-private/symbols.d.ts +36 -0
  41. package/declarations/reactive/-private.d.ts +1 -0
  42. package/declarations/reactive.d.ts +4 -0
  43. package/declarations/request/-private/context.d.ts +34 -35
  44. package/declarations/request/-private/debug.d.ts +2 -3
  45. package/declarations/request/-private/fetch.d.ts +24 -36
  46. package/declarations/request/-private/future.d.ts +3 -4
  47. package/declarations/request/-private/manager.d.ts +159 -132
  48. package/declarations/request/-private/promise-cache.d.ts +21 -13
  49. package/declarations/request/-private/types.d.ts +124 -123
  50. package/declarations/request/-private/utils.d.ts +8 -9
  51. package/declarations/request.d.ts +5 -433
  52. package/declarations/store/-private/cache-handler/handler.d.ts +62 -0
  53. package/declarations/store/-private/cache-handler/types.d.ts +98 -0
  54. package/declarations/store/-private/cache-handler/utils.d.ts +32 -0
  55. package/declarations/store/-private/caches/cache-utils.d.ts +12 -0
  56. package/declarations/store/-private/caches/identifier-cache.d.ts +304 -0
  57. package/declarations/store/-private/caches/instance-cache.d.ts +65 -0
  58. package/declarations/store/-private/caches/resource-utils.d.ts +9 -0
  59. package/declarations/store/-private/debug/utils.d.ts +6 -0
  60. package/declarations/store/-private/default-cache-policy.d.ts +384 -0
  61. package/declarations/store/-private/legacy-model-support/record-reference.d.ts +159 -0
  62. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +17 -0
  63. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +25 -0
  64. package/declarations/store/-private/managers/cache-manager.d.ts +443 -0
  65. package/declarations/store/-private/managers/notification-manager.d.ts +98 -0
  66. package/declarations/store/-private/managers/record-array-manager.d.ts +97 -0
  67. package/declarations/store/-private/network/request-cache.d.ts +107 -0
  68. package/declarations/store/-private/new-core-tmp/promise-state.d.ts +263 -0
  69. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +176 -0
  70. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +169 -0
  71. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +35 -0
  72. package/declarations/store/-private/new-core-tmp/request-state.d.ts +277 -0
  73. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +261 -0
  74. package/declarations/store/-private/record-arrays/identifier-array.d.ts +147 -0
  75. package/declarations/store/-private/record-arrays/many-array.d.ts +197 -0
  76. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +126 -0
  77. package/declarations/store/-private/store-service.d.ts +1605 -0
  78. package/declarations/store/-private/utils/coerce-id.d.ts +10 -0
  79. package/declarations/store/-private/utils/construct-resource.d.ts +6 -0
  80. package/declarations/store/-private/utils/is-non-empty-string.d.ts +1 -0
  81. package/declarations/store/-private/utils/normalize-model-name.d.ts +1 -0
  82. package/declarations/store/-private/utils/uuid-polyfill.d.ts +1 -0
  83. package/declarations/store/-private.d.ts +31 -0
  84. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +99 -0
  85. package/declarations/store/-types/q/ds-model.d.ts +21 -0
  86. package/declarations/store/-types/q/identifier.d.ts +20 -0
  87. package/declarations/store/-types/q/record-instance.d.ts +23 -0
  88. package/declarations/store/-types/q/schema-service.d.ts +354 -0
  89. package/declarations/store/-types/q/store.d.ts +32 -0
  90. package/declarations/store.d.ts +1 -0
  91. package/declarations/types/-private.d.ts +16 -8
  92. package/declarations/types/cache/aliases.d.ts +11 -1
  93. package/declarations/types/cache/change.d.ts +4 -5
  94. package/declarations/types/cache/mutations.d.ts +51 -28
  95. package/declarations/types/cache/operations.d.ts +60 -47
  96. package/declarations/types/cache/relationship.d.ts +11 -9
  97. package/declarations/types/cache.d.ts +495 -484
  98. package/declarations/types/graph.d.ts +31 -40
  99. package/declarations/types/identifier.d.ts +83 -82
  100. package/declarations/types/json/raw.d.ts +1 -2
  101. package/declarations/types/params.d.ts +4 -5
  102. package/declarations/types/record.d.ts +117 -76
  103. package/declarations/types/request.d.ts +289 -266
  104. package/declarations/types/runtime.d.ts +8 -9
  105. package/declarations/types/schema/concepts.d.ts +19 -13
  106. package/declarations/types/schema/fields.d.ts +1712 -1741
  107. package/declarations/types/schema/fields.type-test.d.ts +0 -1
  108. package/declarations/types/spec/document.d.ts +28 -22
  109. package/declarations/types/spec/error.d.ts +16 -17
  110. package/declarations/types/spec/json-api-raw.d.ts +102 -102
  111. package/declarations/types/symbols.d.ts +74 -75
  112. package/declarations/types/utils.d.ts +5 -5
  113. package/declarations/types.d.ts +10 -7
  114. package/declarations/utils/string.d.ts +48 -0
  115. package/dist/build-config/babel-macros.js +1 -0
  116. package/dist/build-config/canary-features.js +1 -0
  117. package/dist/build-config/debugging.js +1 -0
  118. package/dist/build-config/deprecations.js +1 -0
  119. package/dist/build-config/env.js +1 -0
  120. package/dist/build-config/macros.js +1 -0
  121. package/dist/build-config.js +1 -0
  122. package/dist/configure-B48bFHOl.js +181 -0
  123. package/dist/configure.js +1 -0
  124. package/dist/{context-DE5sFezZ.js → context-COmAnXUQ.js} +2 -2
  125. package/dist/graph/-private.js +3372 -0
  126. package/dist/handler-C2T-IyJK.js +339 -0
  127. package/dist/index.js +37 -104
  128. package/dist/reactive/-private.js +1 -0
  129. package/dist/reactive.js +1988 -0
  130. package/dist/request-state-CjLph1LP.js +8139 -0
  131. package/dist/request.js +1 -1
  132. package/dist/store/-private.js +3 -0
  133. package/dist/store.js +545 -0
  134. package/dist/symbols-SIstXMLI.js +44 -0
  135. package/dist/types/-private.js +3 -3
  136. package/dist/types/record.js +1 -1
  137. package/dist/types/request.js +2 -2
  138. package/dist/types/runtime.js +1 -1
  139. package/dist/types/schema/fields.js +8 -41
  140. package/dist/types/symbols.js +3 -3
  141. package/dist/utils/string.js +92 -0
  142. package/logos/NCC-1701-a-blue.svg +4 -0
  143. package/logos/NCC-1701-a-gold.svg +4 -0
  144. package/logos/NCC-1701-a-gold_100.svg +1 -0
  145. package/logos/NCC-1701-a-gold_base-64.txt +1 -0
  146. package/logos/NCC-1701-a.svg +4 -0
  147. package/logos/README.md +4 -0
  148. package/logos/docs-badge.svg +2 -0
  149. package/logos/ember-data-logo-dark.svg +12 -0
  150. package/logos/ember-data-logo-light.svg +12 -0
  151. package/logos/github-header.svg +444 -0
  152. package/logos/social1.png +0 -0
  153. package/logos/social2.png +0 -0
  154. package/logos/warp-drive-logo-dark.svg +4 -0
  155. package/logos/warp-drive-logo-gold.svg +4 -0
  156. package/package.json +11 -8
  157. package/declarations/index.d.ts.map +0 -1
  158. package/declarations/request/-private/context.d.ts.map +0 -1
  159. package/declarations/request/-private/debug.d.ts.map +0 -1
  160. package/declarations/request/-private/fetch.d.ts.map +0 -1
  161. package/declarations/request/-private/future.d.ts.map +0 -1
  162. package/declarations/request/-private/manager.d.ts.map +0 -1
  163. package/declarations/request/-private/promise-cache.d.ts.map +0 -1
  164. package/declarations/request/-private/types.d.ts.map +0 -1
  165. package/declarations/request/-private/utils.d.ts.map +0 -1
  166. package/declarations/request.d.ts.map +0 -1
  167. package/declarations/types/-private.d.ts.map +0 -1
  168. package/declarations/types/cache/aliases.d.ts.map +0 -1
  169. package/declarations/types/cache/change.d.ts.map +0 -1
  170. package/declarations/types/cache/mutations.d.ts.map +0 -1
  171. package/declarations/types/cache/operations.d.ts.map +0 -1
  172. package/declarations/types/cache/relationship.d.ts.map +0 -1
  173. package/declarations/types/cache.d.ts.map +0 -1
  174. package/declarations/types/graph.d.ts.map +0 -1
  175. package/declarations/types/identifier.d.ts.map +0 -1
  176. package/declarations/types/json/raw.d.ts.map +0 -1
  177. package/declarations/types/params.d.ts.map +0 -1
  178. package/declarations/types/record.d.ts.map +0 -1
  179. package/declarations/types/record.type-test.d.ts +0 -2
  180. package/declarations/types/record.type-test.d.ts.map +0 -1
  181. package/declarations/types/request.d.ts.map +0 -1
  182. package/declarations/types/request.type-test.d.ts +0 -2
  183. package/declarations/types/request.type-test.d.ts.map +0 -1
  184. package/declarations/types/runtime.d.ts.map +0 -1
  185. package/declarations/types/schema/concepts.d.ts.map +0 -1
  186. package/declarations/types/schema/fields.d.ts.map +0 -1
  187. package/declarations/types/schema/fields.type-test.d.ts.map +0 -1
  188. package/declarations/types/spec/document.d.ts.map +0 -1
  189. package/declarations/types/spec/error.d.ts.map +0 -1
  190. package/declarations/types/spec/json-api-raw.d.ts.map +0 -1
  191. package/declarations/types/symbols.d.ts.map +0 -1
  192. package/declarations/types/utils.d.ts.map +0 -1
  193. package/declarations/types.d.ts.map +0 -1
  194. package/dist/context-DE5sFezZ.js.map +0 -1
  195. package/dist/index.js.map +0 -1
  196. package/dist/request.js.map +0 -1
  197. package/dist/types/-private.js.map +0 -1
  198. package/dist/types/cache/aliases.js.map +0 -1
  199. package/dist/types/cache/change.js.map +0 -1
  200. package/dist/types/cache/mutations.js.map +0 -1
  201. package/dist/types/cache/operations.js.map +0 -1
  202. package/dist/types/cache/relationship.js.map +0 -1
  203. package/dist/types/cache.js.map +0 -1
  204. package/dist/types/graph.js.map +0 -1
  205. package/dist/types/identifier.js.map +0 -1
  206. package/dist/types/json/raw.js.map +0 -1
  207. package/dist/types/params.js.map +0 -1
  208. package/dist/types/record.js.map +0 -1
  209. package/dist/types/request.js.map +0 -1
  210. package/dist/types/runtime.js.map +0 -1
  211. package/dist/types/schema/concepts.js.map +0 -1
  212. package/dist/types/schema/fields.js.map +0 -1
  213. package/dist/types/schema/fields.type-test.js.map +0 -1
  214. package/dist/types/spec/document.js.map +0 -1
  215. package/dist/types/spec/error.js.map +0 -1
  216. package/dist/types/spec/json-api-raw.js.map +0 -1
  217. package/dist/types/symbols.js.map +0 -1
  218. package/dist/types/utils.js.map +0 -1
  219. package/dist/types.js.map +0 -1
@@ -0,0 +1,304 @@
1
+ import { type Identifier, type RecordIdentifier, type StableDocumentIdentifier, type StableExistingRecordIdentifier, type StableRecordIdentifier } from "../../../types/identifier.js";
2
+ import type { ImmutableRequestInfo } from "../../../types/request.js";
3
+ import type { ExistingResourceIdentifierObject, ResourceIdentifierObject } from "../../../types/spec/json-api-raw.js";
4
+ import type { ForgetMethod, GenerationMethod, KeyInfo, KeyInfoMethod, ResetMethod, UpdateMethod } from "../../-types/q/identifier.js";
5
+ type TypeFromIdentifier<T> = T extends {
6
+ type: infer U;
7
+ } ? U : string;
8
+ type NarrowIdentifierIfPossible<T> = T extends ExistingResourceIdentifierObject ? StableExistingRecordIdentifier<TypeFromIdentifier<T>> : StableRecordIdentifier;
9
+ export declare function isStableIdentifier(identifier: unknown): identifier is StableRecordIdentifier;
10
+ export declare function isDocumentIdentifier(identifier: unknown): identifier is StableDocumentIdentifier;
11
+ interface KeyOptions {
12
+ lid: IdentifierMap;
13
+ id: IdentifierMap;
14
+ }
15
+ type TypeMap = {
16
+ [key: string]: KeyOptions;
17
+ };
18
+ // type IdentifierTypeLookup = { all: Set<StableRecordIdentifier>; id: Map<string, StableRecordIdentifier> };
19
+ // type IdentifiersByType = Map<string, IdentifierTypeLookup>;
20
+ type IdentifierMap = Map<string, StableRecordIdentifier>;
21
+ type StableCache = {
22
+ resources: IdentifierMap;
23
+ documents: Map<string, StableDocumentIdentifier>;
24
+ resourcesByType: TypeMap;
25
+ polymorphicLidBackMap: Map<string, string[]>;
26
+ };
27
+ export type MergeMethod = (targetIdentifier: StableRecordIdentifier, matchedIdentifier: StableRecordIdentifier, resourceData: unknown) => StableRecordIdentifier;
28
+ /**
29
+ Configures how unique identifier lid strings are generated by @ember-data/store.
30
+
31
+ This configuration MUST occur prior to the store instance being created.
32
+
33
+ Takes a method which can expect to receive various data as its first argument
34
+ and the name of a bucket as its second argument.
35
+
36
+ Currently there are two buckets, 'record' and 'document'.
37
+
38
+ ### Resource (`Record`) Identity
39
+
40
+ If the bucket is `record` the method must return a unique (to at-least
41
+ the given bucket) string identifier for the given data as a string to be
42
+ used as the `lid` of an `Identifier` token.
43
+
44
+ This method will only be called by either `getOrCreateRecordIdentifier` or
45
+ `createIdentifierForNewRecord` when an identifier for the supplied data
46
+ is not already known via `lid` or `type + id` combo and one needs to be
47
+ generated or retrieved from a proprietary cache.
48
+
49
+ `data` will be the same data argument provided to `getOrCreateRecordIdentifier`
50
+ and in the `createIdentifierForNewRecord` case will be an object with
51
+ only `type` as a key.
52
+
53
+ ```ts
54
+ import { setIdentifierGenerationMethod } from '@warp-drive/core';
55
+
56
+ export function initialize(applicationInstance) {
57
+ // note how `count` here is now scoped to the application instance
58
+ // for our generation method by being inside the closure provided
59
+ // by the initialize function
60
+ let count = 0;
61
+
62
+ setIdentifierGenerationMethod((resource, bucket) => {
63
+ return resource.lid || `my-key-${count++}`;
64
+ });
65
+ }
66
+
67
+ export default {
68
+ name: 'configure-ember-data-identifiers',
69
+ initialize
70
+ };
71
+ ```
72
+
73
+ ### Document Identity
74
+
75
+ If the bucket is `document` the method will receive the associated
76
+ immutable `request` passed to `store.request` as its first argument
77
+ and should return a unique string for the given request if the document
78
+ should be cached, and `null` if it should not be cached.
79
+
80
+ Note, the request result will still be passed to the cache via `Cache.put`,
81
+ but caches should take this as a signal that the document should not itself
82
+ be cached, while its contents may still be used to update other cache state.
83
+
84
+ The presence of `cacheOptions.key` on the request will take precedence
85
+ for the document cache key, and this method will not be called if it is
86
+ present.
87
+
88
+ The default method implementation for this bucket is to return `null`
89
+ for all requests whose method is not `GET`, and to return the `url` for
90
+ those where it is.
91
+
92
+ This means that queries via `POST` MUST provide `cacheOptions.key` or
93
+ implement this hook.
94
+
95
+ ⚠️ Caution: Requests that do not have a `method` assigned are assumed to be `GET`
96
+
97
+ @public
98
+ */
99
+ export declare function setIdentifierGenerationMethod(method: GenerationMethod | null): void;
100
+ /**
101
+ Configure a callback for when the identifier cache encounters new resource
102
+ data for an existing resource.
103
+
104
+ This configuration MUST occur prior to the store instance being created.
105
+
106
+ ```js
107
+ import { setIdentifierUpdateMethod } from '@warp-drive/core';
108
+ ```
109
+
110
+ Takes a method which can expect to receive an existing `Identifier` alongside
111
+ some new data to consider as a second argument. This is an opportunity
112
+ for secondary lookup tables and caches associated with the identifier
113
+ to be amended.
114
+
115
+ This method is called everytime `updateRecordIdentifier` is called and
116
+ with the same arguments. It provides the opportunity to update secondary
117
+ lookup tables for existing identifiers.
118
+
119
+ It will always be called after an identifier created with `createIdentifierForNewRecord`
120
+ has been committed, or after an update to the `record` a `RecordIdentifier`
121
+ is assigned to has been committed. Committed here meaning that the server
122
+ has acknowledged the update (for instance after a call to `.save()`)
123
+
124
+ If `id` has not previously existed, it will be assigned to the `Identifier`
125
+ prior to this `UpdateMethod` being called; however, calls to the parent method
126
+ `updateRecordIdentifier` that attempt to change the `id` or calling update
127
+ without providing an `id` when one is missing will throw an error.
128
+
129
+ @public
130
+ */
131
+ export declare function setIdentifierUpdateMethod(method: UpdateMethod | null): void;
132
+ /**
133
+ Configure a callback for when the identifier cache is going to release an identifier.
134
+
135
+ This configuration MUST occur prior to the store instance being created.
136
+
137
+ ```js
138
+ import { setIdentifierForgetMethod } from '@warp-drive/core';
139
+ ```
140
+
141
+ Takes method which can expect to receive an existing `Identifier` that should be eliminated
142
+ from any secondary lookup tables or caches that the user has populated for it.
143
+
144
+ @public
145
+ */
146
+ export declare function setIdentifierForgetMethod(method: ForgetMethod | null): void;
147
+ /**
148
+ Configure a callback for when the identifier cache is being torn down.
149
+
150
+ This configuration MUST occur prior to the store instance being created.
151
+
152
+ ```js
153
+ import { setIdentifierResetMethod } from '@warp-drive/core';
154
+ ```
155
+
156
+ Takes a method which can expect to be called when the parent application is destroyed.
157
+
158
+ If you have properly used a WeakMap to encapsulate the state of your customization
159
+ to the application instance, you may not need to implement the `resetMethod`.
160
+
161
+ @public
162
+ */
163
+ export declare function setIdentifierResetMethod(method: ResetMethod | null): void;
164
+ /**
165
+ Configure a callback for when the identifier cache is generating a new
166
+ StableRecordIdentifier for a resource.
167
+
168
+ This method controls the `type` and `id` that will be assigned to the
169
+ `StableRecordIdentifier` that is created.
170
+
171
+ This configuration MUST occur prior to the store instance being created.
172
+
173
+ ```js
174
+ import { setKeyInfoForResource } from '@warp-drive/core';
175
+ ```
176
+
177
+ @public
178
+ */
179
+ export declare function setKeyInfoForResource(method: KeyInfoMethod | null): void;
180
+ /**
181
+ * Each instance of {@link Store} receives a unique instance of a IdentifierCache.
182
+ *
183
+ * This cache is responsible for assigning or retrieving the unique identify
184
+ * for arbitrary resource data encountered by the store. Data representing
185
+ * a unique resource or record should always be represented by the same
186
+ * identifier.
187
+ *
188
+ * It can be configured by consuming applications.
189
+ *
190
+ * @hideconstructor
191
+ * @public
192
+ */
193
+ export declare class IdentifierCache {
194
+ /** @internal */
195
+ _cache: StableCache;
196
+ private _generate;
197
+ private _update;
198
+ private _forget;
199
+ private _reset;
200
+ private _merge;
201
+ private _keyInfoForResource;
202
+ private _id;
203
+ constructor();
204
+ /**
205
+ * Internal hook to allow management of merge conflicts with identifiers.
206
+ *
207
+ * we allow late binding of this private internal merge so that
208
+ * the cache can insert itself here to handle elimination of duplicates
209
+ *
210
+ * @private
211
+ */
212
+ __configureMerge(method: MergeMethod | null): void;
213
+ /** @internal */
214
+ upgradeIdentifier(resource: {
215
+ type: string;
216
+ id: string | null;
217
+ lid?: string;
218
+ }): StableRecordIdentifier;
219
+ /**
220
+ * @private
221
+ */
222
+ private _getRecordIdentifier;
223
+ private _getRecordIdentifier;
224
+ private _getRecordIdentifier;
225
+ /**
226
+ * allows us to peek without generating when needed
227
+ * useful for the "create" case when we need to see if
228
+ * we are accidentally overwritting something
229
+ *
230
+ * @private
231
+ */
232
+ peekRecordIdentifier(resource: ResourceIdentifierObject | Identifier): StableRecordIdentifier | undefined;
233
+ /**
234
+ Returns the DocumentIdentifier for the given Request, creates one if it does not yet exist.
235
+ Returns `null` if the request does not have a `cacheKey` or `url`.
236
+
237
+ @public
238
+ */
239
+ getOrCreateDocumentIdentifier(request: ImmutableRequestInfo): StableDocumentIdentifier | null;
240
+ /**
241
+ Returns the Identifier for the given Resource, creates one if it does not yet exist.
242
+
243
+ Specifically this means that we:
244
+
245
+ - validate the `id` `type` and `lid` combo against known identifiers
246
+ - return an object with an `lid` that is stable (repeated calls with the same
247
+ `id` + `type` or `lid` will return the same `lid` value)
248
+ - this referential stability of the object itself is guaranteed
249
+
250
+ @public
251
+ */
252
+ getOrCreateRecordIdentifier<T>(resource: T): NarrowIdentifierIfPossible<T>;
253
+ /**
254
+ Returns a new Identifier for the supplied data. Call this method to generate
255
+ an identifier when a new resource is being created local to the client and
256
+ potentially does not have an `id`.
257
+
258
+ Delegates generation to the user supplied `GenerateMethod` if one has been provided
259
+ with the signature `generateMethod({ type }, 'record')`.
260
+
261
+ @public
262
+ */
263
+ createIdentifierForNewRecord(data: {
264
+ type: string;
265
+ id?: string | null;
266
+ }): StableRecordIdentifier;
267
+ /**
268
+ Provides the opportunity to update secondary lookup tables for existing identifiers
269
+ Called after an identifier created with `createIdentifierForNewRecord` has been
270
+ committed.
271
+
272
+ Assigned `id` to an `Identifier` if `id` has not previously existed; however,
273
+ attempting to change the `id` or calling update without providing an `id` when
274
+ one is missing will throw an error.
275
+
276
+ - sets `id` (if `id` was previously `null`)
277
+ - `lid` and `type` MUST NOT be altered post creation
278
+
279
+ If a merge occurs, it is possible the returned identifier does not match the originally
280
+ provided identifier. In this case the abandoned identifier will go through the usual
281
+ `forgetRecordIdentifier` codepaths.
282
+
283
+ @public
284
+ */
285
+ updateRecordIdentifier(identifierObject: RecordIdentifier, data: unknown): StableRecordIdentifier;
286
+ /**
287
+ * @private
288
+ */
289
+ _mergeRecordIdentifiers(keyInfo: KeyInfo, identifier: StableRecordIdentifier, existingIdentifier: StableRecordIdentifier, data: unknown): StableRecordIdentifier;
290
+ /**
291
+ Provides the opportunity to eliminate an identifier from secondary lookup tables
292
+ as well as eliminates it from ember-data's own lookup tables and book keeping.
293
+
294
+ Useful when a record has been deleted and the deletion has been persisted and
295
+ we do not care about the record anymore. Especially useful when an `id` of a
296
+ deleted record might be reused later for a new record.
297
+
298
+ @public
299
+ */
300
+ forgetRecordIdentifier(identifierObject: RecordIdentifier): void;
301
+ /** @internal */
302
+ destroy(): void;
303
+ }
304
+ export {};
@@ -0,0 +1,65 @@
1
+ import { ReactiveDocument } from "../../../reactive/-private/document.js";
2
+ import type { Cache } from "../../../types/cache.js";
3
+ import type { StableDocumentIdentifier, StableRecordIdentifier } from "../../../types/identifier.js";
4
+ import type { Value } from "../../../types/json/raw.js";
5
+ import type { TypedRecordInstance, TypeFromInstance } from "../../../types/record.js";
6
+ import type { OpaqueRecordInstance } from "../../-types/q/record-instance.js";
7
+ import RecordReference from "../legacy-model-support/record-reference.js";
8
+ import { CacheCapabilitiesManager } from "../managers/cache-capabilities-manager.js";
9
+ import type { CacheManager } from "../managers/cache-manager.js";
10
+ import type { CreateRecordProperties, Store } from "../store-service.js";
11
+ export declare function peekRecordIdentifier(record: OpaqueRecordInstance): StableRecordIdentifier | undefined;
12
+ /**
13
+ Retrieves the unique referentially-stable [RecordIdentifier](/ember-data/release/classes/StableRecordIdentifier)
14
+ assigned to the given record instance.
15
+
16
+ ```js
17
+ import { recordIdentifierFor } from "@ember-data/store";
18
+ // ... gain access to a record, for instance with peekRecord or findRecord
19
+ const record = store.peekRecord("user", "1");
20
+ // get the identifier for the record (see docs for StableRecordIdentifier)
21
+ const identifier = recordIdentifierFor(record);
22
+ // access the identifier's properties.
23
+ const { id, type, lid } = identifier;
24
+ ```
25
+
26
+ @public
27
+ @param {Object} record a record instance previously obstained from the store.
28
+ @return {StableRecordIdentifier}
29
+ */
30
+ export declare function recordIdentifierFor<T extends TypedRecordInstance>(record: T): StableRecordIdentifier<TypeFromInstance<T>>;
31
+ export declare function recordIdentifierFor(record: OpaqueRecordInstance): StableRecordIdentifier;
32
+ export declare function setRecordIdentifier(record: OpaqueRecordInstance, identifier: StableRecordIdentifier): void;
33
+ export declare const StoreMap: Map<unknown, Store>;
34
+ /**
35
+ * We may eventually make this public, but its likely better for this to be killed off
36
+ * @internal
37
+ */
38
+ export declare function storeFor(record: OpaqueRecordInstance): Store | undefined;
39
+ type Caches = {
40
+ record: Map<StableRecordIdentifier, OpaqueRecordInstance>;
41
+ reference: WeakMap<StableRecordIdentifier, RecordReference>;
42
+ document: Map<StableDocumentIdentifier, ReactiveDocument<OpaqueRecordInstance | OpaqueRecordInstance[] | null | undefined>>;
43
+ };
44
+ export declare class InstanceCache {
45
+ store: Store;
46
+ cache: Cache;
47
+ _storeWrapper: CacheCapabilitiesManager;
48
+ __cacheManager: CacheManager;
49
+ __instances: Caches;
50
+ constructor(store: Store);
51
+ peek(identifier: StableRecordIdentifier): Cache | OpaqueRecordInstance | undefined;
52
+ getDocument<T>(identifier: StableDocumentIdentifier): ReactiveDocument<T>;
53
+ getRecord(identifier: StableRecordIdentifier, properties?: CreateRecordProperties): OpaqueRecordInstance;
54
+ getReference(identifier: StableRecordIdentifier): RecordReference;
55
+ recordIsLoaded(identifier: StableRecordIdentifier, filterDeleted?: boolean): boolean;
56
+ disconnect(identifier: StableRecordIdentifier): void;
57
+ unloadRecord(identifier: StableRecordIdentifier): void;
58
+ clear(type?: string): void;
59
+ // TODO this should move into something coordinating operations
60
+ setRecordId(identifier: StableRecordIdentifier, id: string): void;
61
+ }
62
+ export declare function resourceIsFullyDeleted(instanceCache: InstanceCache, identifier: StableRecordIdentifier): boolean;
63
+ export declare function preloadData(store: Store, identifier: StableRecordIdentifier, preload: Record<string, Value>): void;
64
+ export declare function _clearCaches(): void;
65
+ export {};
@@ -0,0 +1,9 @@
1
+ export declare function hasLid(resource: unknown): resource is {
2
+ lid: string;
3
+ };
4
+ export declare function hasId(resource: unknown): resource is {
5
+ id: string;
6
+ };
7
+ export declare function hasType(resource: unknown): resource is {
8
+ type: string;
9
+ };
@@ -0,0 +1,6 @@
1
+ export declare function logGroup(scope: "cache", prefix: string, type: string, lid: string, bucket: string, key: string): void;
2
+ export declare function logGroup(scope: "reactive-ui", prefix: string, type: string, lid: string, bucket: string, key: ""): void;
3
+ export declare function logGroup(scope: "notify", prefix: string, type: string, lid: string, bucket: string, key: string): void;
4
+ export declare function log(scope: "cache", prefix: string, type: string, lid: string, bucket: string, key: string): void;
5
+ export declare function log(scope: "reactive-ui", prefix: string, type: string, lid: string, bucket: string, key: ""): void;
6
+ export declare function log(scope: "notify", prefix: string, type: string, lid: string, bucket: string, key: string): void;