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

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 +7 -8
  2. package/declarations/index.d.ts +3 -14
  3. package/declarations/index.d.ts.map +1 -0
  4. package/declarations/request/-private/context.d.ts +35 -34
  5. package/declarations/request/-private/context.d.ts.map +1 -0
  6. package/declarations/request/-private/debug.d.ts +3 -2
  7. package/declarations/request/-private/debug.d.ts.map +1 -0
  8. package/declarations/request/-private/fetch.d.ts +36 -24
  9. package/declarations/request/-private/fetch.d.ts.map +1 -0
  10. package/declarations/request/-private/future.d.ts +4 -3
  11. package/declarations/request/-private/future.d.ts.map +1 -0
  12. package/declarations/request/-private/manager.d.ts +132 -159
  13. package/declarations/request/-private/manager.d.ts.map +1 -0
  14. package/declarations/request/-private/promise-cache.d.ts +13 -21
  15. package/declarations/request/-private/promise-cache.d.ts.map +1 -0
  16. package/declarations/request/-private/types.d.ts +123 -124
  17. package/declarations/request/-private/types.d.ts.map +1 -0
  18. package/declarations/request/-private/utils.d.ts +9 -8
  19. package/declarations/request/-private/utils.d.ts.map +1 -0
  20. package/declarations/request.d.ts +433 -5
  21. package/declarations/request.d.ts.map +1 -0
  22. package/declarations/types/-private.d.ts +8 -16
  23. package/declarations/types/-private.d.ts.map +1 -0
  24. package/declarations/types/cache/aliases.d.ts +1 -11
  25. package/declarations/types/cache/aliases.d.ts.map +1 -0
  26. package/declarations/types/cache/change.d.ts +5 -4
  27. package/declarations/types/cache/change.d.ts.map +1 -0
  28. package/declarations/types/cache/mutations.d.ts +28 -51
  29. package/declarations/types/cache/mutations.d.ts.map +1 -0
  30. package/declarations/types/cache/operations.d.ts +47 -60
  31. package/declarations/types/cache/operations.d.ts.map +1 -0
  32. package/declarations/types/cache/relationship.d.ts +9 -11
  33. package/declarations/types/cache/relationship.d.ts.map +1 -0
  34. package/declarations/types/cache.d.ts +484 -495
  35. package/declarations/types/cache.d.ts.map +1 -0
  36. package/declarations/types/graph.d.ts +40 -31
  37. package/declarations/types/graph.d.ts.map +1 -0
  38. package/declarations/types/identifier.d.ts +82 -83
  39. package/declarations/types/identifier.d.ts.map +1 -0
  40. package/declarations/types/json/raw.d.ts +2 -1
  41. package/declarations/types/json/raw.d.ts.map +1 -0
  42. package/declarations/types/params.d.ts +5 -4
  43. package/declarations/types/params.d.ts.map +1 -0
  44. package/declarations/types/record.d.ts +76 -117
  45. package/declarations/types/record.d.ts.map +1 -0
  46. package/declarations/types/record.type-test.d.ts +2 -0
  47. package/declarations/types/record.type-test.d.ts.map +1 -0
  48. package/declarations/types/request.d.ts +266 -289
  49. package/declarations/types/request.d.ts.map +1 -0
  50. package/declarations/types/request.type-test.d.ts +2 -0
  51. package/declarations/types/request.type-test.d.ts.map +1 -0
  52. package/declarations/types/runtime.d.ts +9 -8
  53. package/declarations/types/runtime.d.ts.map +1 -0
  54. package/declarations/types/schema/concepts.d.ts +13 -19
  55. package/declarations/types/schema/concepts.d.ts.map +1 -0
  56. package/declarations/types/schema/fields.d.ts +1741 -1712
  57. package/declarations/types/schema/fields.d.ts.map +1 -0
  58. package/declarations/types/schema/fields.type-test.d.ts +1 -0
  59. package/declarations/types/schema/fields.type-test.d.ts.map +1 -0
  60. package/declarations/types/spec/document.d.ts +22 -28
  61. package/declarations/types/spec/document.d.ts.map +1 -0
  62. package/declarations/types/spec/error.d.ts +17 -16
  63. package/declarations/types/spec/error.d.ts.map +1 -0
  64. package/declarations/types/spec/json-api-raw.d.ts +102 -102
  65. package/declarations/types/spec/json-api-raw.d.ts.map +1 -0
  66. package/declarations/types/symbols.d.ts +75 -74
  67. package/declarations/types/symbols.d.ts.map +1 -0
  68. package/declarations/types/utils.d.ts +5 -5
  69. package/declarations/types/utils.d.ts.map +1 -0
  70. package/declarations/types.d.ts +7 -10
  71. package/declarations/types.d.ts.map +1 -0
  72. package/dist/{context-COmAnXUQ.js → context-DE5sFezZ.js} +2 -2
  73. package/dist/context-DE5sFezZ.js.map +1 -0
  74. package/dist/index.js +104 -37
  75. package/dist/index.js.map +1 -0
  76. package/dist/request.js +1 -1
  77. package/dist/request.js.map +1 -0
  78. package/dist/types/-private.js +3 -3
  79. package/dist/types/-private.js.map +1 -0
  80. package/dist/types/cache/aliases.js.map +1 -0
  81. package/dist/types/cache/change.js.map +1 -0
  82. package/dist/types/cache/mutations.js.map +1 -0
  83. package/dist/types/cache/operations.js.map +1 -0
  84. package/dist/types/cache/relationship.js.map +1 -0
  85. package/dist/types/cache.js.map +1 -0
  86. package/dist/types/graph.js.map +1 -0
  87. package/dist/types/identifier.js.map +1 -0
  88. package/dist/types/json/raw.js.map +1 -0
  89. package/dist/types/params.js.map +1 -0
  90. package/dist/types/record.js +1 -1
  91. package/dist/types/record.js.map +1 -0
  92. package/dist/types/request.js +2 -2
  93. package/dist/types/request.js.map +1 -0
  94. package/dist/types/runtime.js +1 -1
  95. package/dist/types/runtime.js.map +1 -0
  96. package/dist/types/schema/concepts.js.map +1 -0
  97. package/dist/types/schema/fields.js +41 -8
  98. package/dist/types/schema/fields.js.map +1 -0
  99. package/dist/types/schema/fields.type-test.js.map +1 -0
  100. package/dist/types/spec/document.js.map +1 -0
  101. package/dist/types/spec/error.js.map +1 -0
  102. package/dist/types/spec/json-api-raw.js.map +1 -0
  103. package/dist/types/symbols.js +3 -3
  104. package/dist/types/symbols.js.map +1 -0
  105. package/dist/types/utils.js.map +1 -0
  106. package/dist/types.js.map +1 -0
  107. package/package.json +8 -11
  108. package/cjs-dist/addon-shim.cjs +0 -1
  109. package/cjs-dist/cjs-set-config.cjs +0 -1
  110. package/declarations/build-config/babel-macros.d.ts +0 -1
  111. package/declarations/build-config/canary-features.d.ts +0 -1
  112. package/declarations/build-config/debugging.d.ts +0 -1
  113. package/declarations/build-config/deprecations.d.ts +0 -1
  114. package/declarations/build-config/env.d.ts +0 -1
  115. package/declarations/build-config/macros.d.ts +0 -1
  116. package/declarations/build-config.d.ts +0 -1
  117. package/declarations/configure.d.ts +0 -7
  118. package/declarations/graph/-private/-diff.d.ts +0 -32
  119. package/declarations/graph/-private/-edge-definition.d.ts +0 -148
  120. package/declarations/graph/-private/-state.d.ts +0 -96
  121. package/declarations/graph/-private/-utils.d.ts +0 -31
  122. package/declarations/graph/-private/coerce-id.d.ts +0 -10
  123. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +0 -18
  124. package/declarations/graph/-private/edges/collection.d.ts +0 -39
  125. package/declarations/graph/-private/edges/implicit.d.ts +0 -43
  126. package/declarations/graph/-private/edges/resource.d.ts +0 -24
  127. package/declarations/graph/-private/graph.d.ts +0 -90
  128. package/declarations/graph/-private/normalize-link.d.ts +0 -8
  129. package/declarations/graph/-private/operations/add-to-related-records.d.ts +0 -4
  130. package/declarations/graph/-private/operations/merge-identifier.d.ts +0 -3
  131. package/declarations/graph/-private/operations/remove-from-related-records.d.ts +0 -4
  132. package/declarations/graph/-private/operations/replace-related-record.d.ts +0 -3
  133. package/declarations/graph/-private/operations/replace-related-records.d.ts +0 -62
  134. package/declarations/graph/-private/operations/update-relationship.d.ts +0 -13
  135. package/declarations/graph/-private.d.ts +0 -13
  136. package/declarations/reactive/-private/document.d.ts +0 -146
  137. package/declarations/reactive/-private/fields/compute.d.ts +0 -43
  138. package/declarations/reactive/-private/fields/extension.d.ts +0 -8
  139. package/declarations/reactive/-private/fields/managed-array.d.ts +0 -22
  140. package/declarations/reactive/-private/fields/managed-object.d.ts +0 -21
  141. package/declarations/reactive/-private/fields/many-array-manager.d.ts +0 -19
  142. package/declarations/reactive/-private/hooks.d.ts +0 -5
  143. package/declarations/reactive/-private/record.d.ts +0 -64
  144. package/declarations/reactive/-private/schema.d.ts +0 -271
  145. package/declarations/reactive/-private/symbols.d.ts +0 -36
  146. package/declarations/reactive/-private.d.ts +0 -1
  147. package/declarations/reactive.d.ts +0 -4
  148. package/declarations/store/-private/cache-handler/handler.d.ts +0 -62
  149. package/declarations/store/-private/cache-handler/types.d.ts +0 -98
  150. package/declarations/store/-private/cache-handler/utils.d.ts +0 -32
  151. package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
  152. package/declarations/store/-private/caches/identifier-cache.d.ts +0 -304
  153. package/declarations/store/-private/caches/instance-cache.d.ts +0 -65
  154. package/declarations/store/-private/caches/resource-utils.d.ts +0 -9
  155. package/declarations/store/-private/debug/utils.d.ts +0 -6
  156. package/declarations/store/-private/default-cache-policy.d.ts +0 -384
  157. package/declarations/store/-private/legacy-model-support/record-reference.d.ts +0 -159
  158. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +0 -17
  159. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +0 -25
  160. package/declarations/store/-private/managers/cache-manager.d.ts +0 -443
  161. package/declarations/store/-private/managers/notification-manager.d.ts +0 -98
  162. package/declarations/store/-private/managers/record-array-manager.d.ts +0 -97
  163. package/declarations/store/-private/network/request-cache.d.ts +0 -107
  164. package/declarations/store/-private/new-core-tmp/promise-state.d.ts +0 -263
  165. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +0 -176
  166. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +0 -169
  167. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +0 -35
  168. package/declarations/store/-private/new-core-tmp/request-state.d.ts +0 -277
  169. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +0 -261
  170. package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
  171. package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
  172. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +0 -126
  173. package/declarations/store/-private/store-service.d.ts +0 -1605
  174. package/declarations/store/-private/utils/coerce-id.d.ts +0 -10
  175. package/declarations/store/-private/utils/construct-resource.d.ts +0 -6
  176. package/declarations/store/-private/utils/is-non-empty-string.d.ts +0 -1
  177. package/declarations/store/-private/utils/normalize-model-name.d.ts +0 -1
  178. package/declarations/store/-private/utils/uuid-polyfill.d.ts +0 -1
  179. package/declarations/store/-private.d.ts +0 -31
  180. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +0 -99
  181. package/declarations/store/-types/q/ds-model.d.ts +0 -21
  182. package/declarations/store/-types/q/identifier.d.ts +0 -20
  183. package/declarations/store/-types/q/record-instance.d.ts +0 -23
  184. package/declarations/store/-types/q/schema-service.d.ts +0 -354
  185. package/declarations/store/-types/q/store.d.ts +0 -32
  186. package/declarations/store.d.ts +0 -1
  187. package/declarations/utils/string.d.ts +0 -48
  188. package/dist/build-config/babel-macros.js +0 -1
  189. package/dist/build-config/canary-features.js +0 -1
  190. package/dist/build-config/debugging.js +0 -1
  191. package/dist/build-config/deprecations.js +0 -1
  192. package/dist/build-config/env.js +0 -1
  193. package/dist/build-config/macros.js +0 -1
  194. package/dist/build-config.js +0 -1
  195. package/dist/configure-B48bFHOl.js +0 -181
  196. package/dist/configure.js +0 -1
  197. package/dist/graph/-private.js +0 -3372
  198. package/dist/handler-C2T-IyJK.js +0 -339
  199. package/dist/reactive/-private.js +0 -1
  200. package/dist/reactive.js +0 -1988
  201. package/dist/request-state-CjLph1LP.js +0 -8139
  202. package/dist/store/-private.js +0 -3
  203. package/dist/store.js +0 -545
  204. package/dist/symbols-SIstXMLI.js +0 -44
  205. package/dist/utils/string.js +0 -92
  206. package/logos/NCC-1701-a-blue.svg +0 -4
  207. package/logos/NCC-1701-a-gold.svg +0 -4
  208. package/logos/NCC-1701-a-gold_100.svg +0 -1
  209. package/logos/NCC-1701-a-gold_base-64.txt +0 -1
  210. package/logos/NCC-1701-a.svg +0 -4
  211. package/logos/README.md +0 -4
  212. package/logos/docs-badge.svg +0 -2
  213. package/logos/ember-data-logo-dark.svg +0 -12
  214. package/logos/ember-data-logo-light.svg +0 -12
  215. package/logos/github-header.svg +0 -444
  216. package/logos/social1.png +0 -0
  217. package/logos/social2.png +0 -0
  218. package/logos/warp-drive-logo-dark.svg +0 -4
  219. package/logos/warp-drive-logo-gold.svg +0 -4
@@ -1,384 +0,0 @@
1
- import type { Cache } from "@warp-drive/core/types/cache";
2
- import type { StableDocumentIdentifier, StableRecordIdentifier } from "@warp-drive/core/types/identifier";
3
- import type { ImmutableRequestInfo, ResponseInfo, StructuredDocument } from "@warp-drive/core/types/request";
4
- import type { ResourceDocument } from "@warp-drive/core/types/spec/document";
5
- type UnsubscribeToken = object;
6
- type CacheOperation = "added" | "removed" | "updated" | "state";
7
- type DocumentCacheOperation = "invalidated" | "added" | "removed" | "updated" | "state";
8
- export interface NotificationCallback {
9
- (identifier: StableRecordIdentifier, notificationType: "attributes" | "relationships", key?: string): void;
10
- (identifier: StableRecordIdentifier, notificationType: "errors" | "meta" | "identity" | "state"): void;
11
- }
12
- interface ResourceOperationCallback {
13
- // resource updates
14
- (identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
15
- }
16
- interface DocumentOperationCallback {
17
- // document updates
18
- (identifier: StableDocumentIdentifier, notificationType: DocumentCacheOperation): void;
19
- }
20
- type NotificationManager = {
21
- subscribe(identifier: StableRecordIdentifier, callback: NotificationCallback): UnsubscribeToken;
22
- subscribe(identifier: "resource", callback: ResourceOperationCallback): UnsubscribeToken;
23
- subscribe(identifier: "document" | StableDocumentIdentifier, callback: DocumentOperationCallback): UnsubscribeToken;
24
- notify(identifier: StableRecordIdentifier, value: "attributes" | "relationships", key?: string): boolean;
25
- notify(identifier: StableRecordIdentifier, value: "errors" | "meta" | "identity" | "state"): boolean;
26
- notify(identifier: StableRecordIdentifier, value: CacheOperation): boolean;
27
- notify(identifier: StableDocumentIdentifier, value: DocumentCacheOperation): boolean;
28
- };
29
- type Store = {
30
- cache: Cache;
31
- notifications: NotificationManager;
32
- };
33
- export interface CacheControlValue {
34
- immutable?: boolean;
35
- "max-age"?: number;
36
- "must-revalidate"?: boolean;
37
- "must-understand"?: boolean;
38
- "no-cache"?: boolean;
39
- "no-store"?: boolean;
40
- "no-transform"?: boolean;
41
- "only-if-cached"?: boolean;
42
- private?: boolean;
43
- "proxy-revalidate"?: boolean;
44
- public?: boolean;
45
- "s-maxage"?: number;
46
- "stale-if-error"?: number;
47
- "stale-while-revalidate"?: number;
48
- }
49
- /**
50
- * Parses a string Cache-Control header value into an object with the following structure:
51
- *
52
- * ```ts
53
- * interface CacheControlValue {
54
- * immutable?: boolean;
55
- * 'max-age'?: number;
56
- * 'must-revalidate'?: boolean;
57
- * 'must-understand'?: boolean;
58
- * 'no-cache'?: boolean;
59
- * 'no-store'?: boolean;
60
- * 'no-transform'?: boolean;
61
- * 'only-if-cached'?: boolean;
62
- * private?: boolean;
63
- * 'proxy-revalidate'?: boolean;
64
- * public?: boolean;
65
- * 's-maxage'?: number;
66
- * 'stale-if-error'?: number;
67
- * 'stale-while-revalidate'?: number;
68
- * }
69
- * ```
70
- *
71
- * @public
72
- * @param {String} header
73
- * @return {CacheControlValue}
74
- */
75
- export declare function parseCacheControl(header: string): CacheControlValue;
76
- /**
77
- * The configuration options for the {@link DefaultCachePolicy}
78
- *
79
- * ```ts
80
- * import { DefaultCachePolicy } from '@warp-drive/core/store';
81
- *
82
- * new DefaultCachePolicy({
83
- * // ... PolicyConfig Settings ... //
84
- * });
85
- * ```
86
- *
87
- */
88
- export type PolicyConfig = {
89
- /**
90
- * the number of milliseconds after which a request is considered
91
- * stale. If a request is issued again after this time, the request
92
- * will respond from cache immediately while a background request
93
- * is made to update the cache.
94
- *
95
- * This is calculated against the `date` header of the response.
96
- *
97
- * If your API does not provide a `date` header, the `Fetch` handler
98
- * provided by `@warp-drive/core` will automatically add
99
- * it to responses if it is not present. Responses without a `date`
100
- * header will be considered stale immediately.
101
- *
102
- */
103
- apiCacheSoftExpires: number;
104
- /**
105
- * the number of milliseconds after which a request is considered
106
- * expired and should be re-fetched. If a request is issued again
107
- * after this time, the request will disregard the cache and
108
- * wait for a fresh response from the API.
109
- *
110
- * This is calculated against the `date` header of the response.
111
- *
112
- * If your API does not provide a `date` header, the `Fetch` handler
113
- * provided by `@warp-drive/core` will automatically add
114
- * it to responses if it is not present. Responses without a `date`
115
- * header will be considered hard expired immediately.
116
- *
117
- */
118
- apiCacheHardExpires: number;
119
- /**
120
- * In Testing environments, the `apiCacheSoftExpires` will always be `false`
121
- * and `apiCacheHardExpires` will use the `apiCacheSoftExpires` value.
122
- *
123
- * This helps reduce flakiness and produce predictably rendered results in test suites.
124
- *
125
- * Requests that specifically set `cacheOptions.backgroundReload = true` will
126
- * still be background reloaded in tests.
127
- *
128
- * This behavior can be opted out of by setting this value to `true`.
129
- *
130
- */
131
- disableTestOptimization?: boolean;
132
- /**
133
- * In addition to the simple time-based expiration strategy, CachePolicy
134
- * supports various common server-supplied expiration strategies via
135
- * headers, as well as custom expiration strategies via the `isExpired`
136
- * function.
137
- *
138
- * Requests will be validated for expiration against these constraints.
139
- * If any of these constraints are not met, the request will be considered
140
- * expired. If all constraints are met, the request will be considered
141
- * valid and the time based expiration strategy will NOT be used.
142
- *
143
- * Meeting a constraint means BOTH that the properties the constraint
144
- * requires are present AND that the expiration time indicated by those
145
- * properties has not been exceeded.
146
- *
147
- * In other words, if the properties for a constraint are not present,
148
- * this does not count either as meeting or as not meeting the constraint,
149
- * the constraint simply does not apply.
150
- *
151
- * The `isExpired` function is called with the request and should return
152
- * `true` if the request is expired, `false` if it is not expired, and
153
- * `null` if the expiration status is unknown.
154
- *
155
- * In order constraints are checked:
156
- *
157
- * - isExpired function
158
- * - ↳ (if null) X-WarpDrive-Expires header
159
- * - ↳ (if null) Cache-Control header
160
- * - ↳ (if null) Expires header
161
- *
162
- */
163
- constraints?: {
164
- /**
165
- * Headers that should be checked for expiration.
166
- *
167
- */
168
- headers?: {
169
- /**
170
- * Whether the `Cache-Control` header should be checked for expiration.
171
- * If `true`, then the `max-age` and `s-maxage` directives are used alongside
172
- * the `Age` and `Date` headers to determine if the expiration time has passed.
173
- *
174
- * Other directives are ignored.
175
- *
176
- * 'Cache-Control' will take precedence over 'Expires' if both are present
177
- * and both configured to be checked.
178
- *
179
- */
180
- "Cache-Control"?: boolean;
181
- /**
182
- * Whether the `Expires` header should be checked for expiration.
183
- *
184
- * If `true`, then the `Expires` header is used to caclulate the expiration time
185
- * and determine if the expiration time has passed.
186
- *
187
- * 'Cache-Control' will take precedence over 'Expires' if both are present.
188
- *
189
- */
190
- Expires?: boolean;
191
- /**
192
- * Whether the `X-WarpDrive-Expires` header should be checked for expiration.
193
- *
194
- * If `true`, then the `X-WarpDrive-Expires` header is used to caclulate the expiration time
195
- * and determine if the expiration time has passed.
196
- *
197
- * This header will take precedence over 'Cache-Control' and 'Expires' if all three are present.
198
- *
199
- * The header's value should be a [UTC date string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString).
200
- *
201
- */
202
- "X-WarpDrive-Expires"?: boolean;
203
- };
204
- /**
205
- * A function that should be called to determine if the request is expired.
206
- *
207
- * If present, this function will be called with the request and should return
208
- * `true` if the request is expired, `false` if it is not expired, and
209
- * `null` if the expiration status is unknown.
210
- *
211
- * If the function does not return `null`,
212
- *
213
- */
214
- isExpired?: (request: StructuredDocument<ResourceDocument>) => boolean | null;
215
- };
216
- };
217
- /**
218
- * A basic CachePolicy that can be added to the Store service.
219
- *
220
- * Determines staleness based on time since the request was last received from the API
221
- * using the `date` header.
222
- *
223
- * Determines expiration based on configured constraints as well as a time based
224
- * expiration strategy based on the `date` header.
225
- *
226
- * In order expiration is determined by:
227
- *
228
- * - Is explicitly invalidated
229
- * - ↳ (if null) isExpired function \<IF Constraint Active>
230
- * - ↳ (if null) X-WarpDrive-Expires header \<IF Constraint Active>
231
- * - ↳ (if null) Cache-Control header \<IF Constraint Active>
232
- * - ↳ (if null) Expires header \<IF Constraint Active>
233
- * - ↳ (if null) Date header + apiCacheHardExpires \< current time
234
- *
235
- * Invalidates any request for which `cacheOptions.types` was provided when a createRecord
236
- * request for that type is successful.
237
- *
238
- * For this to work, the `createRecord` request must include the `cacheOptions.types` array
239
- * with the types that should be invalidated, or its request should specify the identifiers
240
- * of the records that are being created via `records`. Providing both is valid.
241
- *
242
- * > [!NOTE]
243
- * > only requests that had specified `cacheOptions.types` and occurred prior to the
244
- * > createRecord request will be invalidated. This means that a given request should always
245
- * > specify the types that would invalidate it to opt into this behavior. Abstracting this
246
- * > behavior via builders is recommended to ensure consistency.
247
- *
248
- * This allows the Store's CacheHandler to determine if a request is expired and
249
- * should be refetched upon next request.
250
- *
251
- * The `Fetch` handler provided by `@warp-drive/core` will automatically
252
- * add the `date` header to responses if it is not present.
253
- *
254
- * > [!NOTE]
255
- * > Date headers do not have millisecond precision, so expiration times should
256
- * > generally be larger than 1000ms.
257
- *
258
- * Usage:
259
- *
260
- * ```ts
261
- * import { Store } from '@warp-drive/core';
262
- * import { DefaultCachePolicy } from '@warp-drive/core/store';
263
- *
264
- * export class AppStore extends Store {
265
- * lifetimes = new DefaultCachePolicy({
266
- * apiCacheSoftExpires: 30_000,
267
- * apiCacheHardExpires: 60_000
268
- * });
269
- * }
270
- * ```
271
- *
272
- * In Testing environments, the `apiCacheSoftExpires` will always be `false`
273
- * and `apiCacheHardExpires` will use the `apiCacheSoftExpires` value.
274
- *
275
- * This helps reduce flakiness and produce predictably rendered results in test suites.
276
- *
277
- * Requests that specifically set `cacheOptions.backgroundReload = true` will
278
- * still be background reloaded in tests.
279
- *
280
- * This behavior can be opted out of by setting `disableTestOptimization = true`
281
- * in the policy config.
282
- *
283
- * @public
284
- */
285
- export declare class DefaultCachePolicy {
286
- config: PolicyConfig;
287
- _stores: WeakMap<Store, {
288
- invalidated: Set<StableDocumentIdentifier>;
289
- types: Map<string, Set<StableDocumentIdentifier>>;
290
- }>;
291
- _getStore(store: Store): {
292
- invalidated: Set<StableDocumentIdentifier>;
293
- types: Map<string, Set<StableDocumentIdentifier>>;
294
- };
295
- constructor(config: PolicyConfig);
296
- /**
297
- * Invalidate a request by its identifier for a given store instance.
298
- *
299
- * While the store argument may seem redundant, the CachePolicy
300
- * is designed to be shared across multiple stores / forks
301
- * of the store.
302
- *
303
- * ```ts
304
- * store.lifetimes.invalidateRequest(store, identifier);
305
- * ```
306
- *
307
- * @public
308
- * @param {StableDocumentIdentifier} identifier
309
- * @param {Store} store
310
- */
311
- invalidateRequest(identifier: StableDocumentIdentifier, store: Store): void;
312
- /**
313
- * Invalidate all requests associated to a specific type
314
- * for a given store instance.
315
- *
316
- * While the store argument may seem redundant, the CachePolicy
317
- * is designed to be shared across multiple stores / forks
318
- * of the store.
319
- *
320
- * This invalidation is done automatically when using this service
321
- * for both the CacheHandler and the LegacyNetworkHandler.
322
- *
323
- * ```ts
324
- * store.lifetimes.invalidateRequestsForType(store, 'person');
325
- * ```
326
- *
327
- * @public
328
- * @param {String} type
329
- * @param {Store} store
330
- */
331
- invalidateRequestsForType(type: string, store: Store): void;
332
- /**
333
- * Invoked when a request has been fulfilled from the configured request handlers.
334
- * This is invoked by the CacheHandler for both foreground and background requests
335
- * once the cache has been updated.
336
- *
337
- * Note, this is invoked by the CacheHandler regardless of whether
338
- * the request has a cache-key.
339
- *
340
- * This method should not be invoked directly by consumers.
341
- *
342
- * @public
343
- * @param {ImmutableRequestInfo} request
344
- * @param {ImmutableResponse} response
345
- * @param {Store} store
346
- * @param {StableDocumentIdentifier | null} identifier
347
- * @return {void}
348
- */
349
- didRequest(request: ImmutableRequestInfo, response: Response | ResponseInfo | null, identifier: StableDocumentIdentifier | null, store: Store): void;
350
- /**
351
- * Invoked to determine if the request may be fulfilled from cache
352
- * if possible.
353
- *
354
- * Note, this is only invoked by the CacheHandler if the request has
355
- * a cache-key.
356
- *
357
- * If no cache entry is found or the entry is hard expired,
358
- * the request will be fulfilled from the configured request handlers
359
- * and the cache will be updated before returning the response.
360
- *
361
- * @public
362
- * @param {StableDocumentIdentifier} identifier
363
- * @param {Store} store
364
- * @return {Boolean} true if the request is considered hard expired
365
- */
366
- isHardExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
367
- /**
368
- * Invoked if `isHardExpired` is false to determine if the request
369
- * should be update behind the scenes if cache data is already available.
370
- *
371
- * Note, this is only invoked by the CacheHandler if the request has
372
- * a cache-key.
373
- *
374
- * If true, the request will be fulfilled from cache while a backgrounded
375
- * request is made to update the cache via the configured request handlers.
376
- *
377
- * @public
378
- * @param {StableDocumentIdentifier} identifier
379
- * @param {Store} store
380
- * @return {Boolean} true if the request is considered soft expired
381
- */
382
- isSoftExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
383
- }
384
- export {};
@@ -1,159 +0,0 @@
1
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
2
- import type { SingleResourceDocument } from "../../../types/spec/json-api-raw.js";
3
- import type { OpaqueRecordInstance } from "../../-types/q/record-instance.js";
4
- import type { Store } from "../store-service.js";
5
- /**
6
- A `RecordReference` is a low-level API that allows users and
7
- addon authors to perform meta-operations on a record.
8
-
9
- @hideconstructor
10
- @public
11
- */
12
- export default class RecordReference {
13
- private store;
14
- // unsubscribe token given to us by the notification manager
15
- private ___token;
16
- private ___identifier;
17
- private _ref;
18
- constructor(store: Store, identifier: StableRecordIdentifier);
19
- /** @internal */
20
- destroy(): void;
21
- get type(): string;
22
- /**
23
- The `id` of the record that this reference refers to.
24
-
25
- Together, the `type` and `id` properties form a composite key for
26
- the identity map.
27
-
28
- Example
29
-
30
- ```javascript
31
- let userRef = store.getReference('user', 1);
32
-
33
- userRef.id(); // '1'
34
- ```
35
-
36
- @public
37
- */
38
- id(): string | null;
39
- /**
40
- The `identifier` of the record that this reference refers to.
41
-
42
- Together, the `type` and `id` properties form a composite key for
43
- the identity map.
44
-
45
- Example
46
-
47
- ```javascript
48
- let userRef = store.getReference('user', 1);
49
-
50
- userRef.identifier(); // '1'
51
- ```
52
-
53
- @public
54
- */
55
- identifier(): StableRecordIdentifier;
56
- /**
57
- How the reference will be looked up when it is loaded. Currently
58
- this always returns `identity` to signify that a record will be
59
- loaded by its `type` and `id`.
60
-
61
- Example
62
-
63
- ```javascript
64
- const userRef = store.getReference('user', 1);
65
-
66
- userRef.remoteType(); // 'identity'
67
- ```
68
-
69
- @public
70
- */
71
- remoteType(): "identity";
72
- /**
73
- This API allows you to provide a reference with new data. The
74
- simplest usage of this API is similar to `store.push`: you provide a
75
- normalized hash of data and the object represented by the reference
76
- will update.
77
-
78
- If you pass a promise to `push`, Ember Data will not ask the adapter
79
- for the data if another attempt to fetch it is made in the
80
- interim. When the promise resolves, the underlying object is updated
81
- with the new data, and the promise returned by *this function* is resolved
82
- with that object.
83
-
84
- For example, `recordReference.push(promise)` will be resolved with a
85
- record.
86
-
87
- Example
88
-
89
- ```javascript
90
- let userRef = store.getReference('user', 1);
91
-
92
- // provide data for reference
93
- userRef.push({
94
- data: {
95
- id: "1",
96
- type: "user",
97
- attributes: {
98
- username: "@user"
99
- }
100
- }
101
- }).then(function(user) {
102
- userRef.value() === user;
103
- });
104
- ```
105
-
106
- @public
107
- @param objectOrPromise a JSON:API ResourceDocument or a promise resolving to one
108
- @return a promise for the value (record or relationship)
109
- */
110
- push(objectOrPromise: SingleResourceDocument | Promise<SingleResourceDocument>): Promise<OpaqueRecordInstance>;
111
- /**
112
- If the entity referred to by the reference is already loaded, it is
113
- present as `reference.value`. Otherwise the value returned by this function
114
- is `null`.
115
-
116
- Example
117
-
118
- ```javascript
119
- let userRef = store.getReference('user', 1);
120
-
121
- userRef.value(); // user
122
- ```
123
-
124
- @public
125
- */
126
- value(): OpaqueRecordInstance | null;
127
- /**
128
- Triggers a fetch for the backing entity based on its `remoteType`
129
- (see `remoteType` definitions per reference type).
130
-
131
- Example
132
-
133
- ```javascript
134
- let userRef = store.getReference('user', 1);
135
-
136
- // load user (via store.find)
137
- userRef.load().then(...)
138
- ```
139
-
140
- @public
141
- */
142
- load(): Promise<OpaqueRecordInstance>;
143
- /**
144
- Reloads the record if it is already loaded. If the record is not
145
- loaded it will load the record via `store.findRecord`
146
-
147
- Example
148
-
149
- ```javascript
150
- let userRef = store.getReference('user', 1);
151
-
152
- // or trigger a reload
153
- userRef.reload().then(...)
154
- ```
155
-
156
- @public
157
- */
158
- reload(): Promise<OpaqueRecordInstance>;
159
- }
@@ -1,17 +0,0 @@
1
- import type { TypedRecordInstance, TypeFromInstance } from "../../../types/record.js";
2
- import type { LegacyAttributeField, LegacyRelationshipField } from "../../../types/schema/fields.js";
3
- import type { KeyOrString, ModelSchema } from "../../-types/q/ds-model.js";
4
- import type { Store } from "../store-service.js";
5
- export declare function getShimClass<T>(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string): ShimModelClass<T>;
6
- // Mimics the static apis of @ember-data/model
7
- export default class ShimModelClass<T = unknown> implements ModelSchema<T> {
8
- private __store;
9
- modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
10
- constructor(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string);
11
- get fields(): Map<KeyOrString<T>, "attribute" | "belongsTo" | "hasMany">;
12
- get attributes(): Map<KeyOrString<T>, LegacyAttributeField>;
13
- get relationshipsByName(): Map<KeyOrString<T>, LegacyRelationshipField>;
14
- eachAttribute<K extends KeyOrString<T>>(callback: (key: K, attribute: LegacyAttributeField) => void, binding?: T): void;
15
- eachRelationship<K extends KeyOrString<T>>(callback: (key: K, relationship: LegacyRelationshipField) => void, binding?: T): void;
16
- eachTransformedAttribute<K extends KeyOrString<T>>(callback: (key: K, type: string | null) => void, binding?: T): void;
17
- }
@@ -1,25 +0,0 @@
1
- import type { StableDocumentIdentifier, StableRecordIdentifier } from "../../../types/identifier.js";
2
- import type { CacheCapabilitiesManager as StoreWrapper } from "../../-types/q/cache-capabilities-manager.js";
3
- import type { SchemaService } from "../../-types/q/schema-service.js";
4
- import type { IdentifierCache } from "../caches/identifier-cache.js";
5
- import type { Store } from "../store-service.js";
6
- import type { NotificationType } from "./notification-manager.js";
7
- export interface CacheCapabilitiesManager {
8
- getSchemaDefinitionService(): SchemaService;
9
- }
10
- export declare class CacheCapabilitiesManager implements StoreWrapper {
11
- _willNotify: boolean;
12
- _pendingNotifies: Map<StableRecordIdentifier, Set<string>>;
13
- _store: Store;
14
- constructor(_store: Store);
15
- get identifierCache(): IdentifierCache;
16
- _scheduleNotification(identifier: StableRecordIdentifier, key: string): void;
17
- _flushNotifications(): void;
18
- notifyChange(identifier: StableRecordIdentifier, namespace: "added" | "removed", key: null): void;
19
- notifyChange(identifier: StableDocumentIdentifier, namespace: "added" | "updated" | "removed", key: null): void;
20
- notifyChange(identifier: StableRecordIdentifier, namespace: NotificationType, key: string | null): void;
21
- get schema(): SchemaService;
22
- setRecordId(identifier: StableRecordIdentifier, id: string): void;
23
- hasRecord(identifier: StableRecordIdentifier): boolean;
24
- disconnectRecord(identifier: StableRecordIdentifier): void;
25
- }