@warp-drive/core 5.8.0-alpha.3 → 5.8.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.
- package/README.md +1 -1
- package/declarations/reactive/-private/schema.d.ts +76 -3
- package/declarations/store/-private/caches/instance-cache.d.ts +2 -3
- package/declarations/store/-private/default-cache-policy.d.ts +76 -59
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +1 -1
- package/declarations/store/-private/store-service.d.ts +41 -62
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +1 -1
- package/declarations/store/deprecated/store.d.ts +32 -31
- package/declarations/{store/-types/q → types/schema}/schema-service.d.ts +11 -9
- package/declarations/types.d.ts +1 -1
- package/dist/{request-state-CUuZzgvE.js → index-MiSBsI57.js} +4497 -3402
- package/dist/index.js +4 -381
- package/dist/reactive.js +4 -743
- package/dist/store/-private.js +1 -1
- package/dist/store.js +84 -47
- package/dist/types/-private.js +1 -1
- package/dist/types/schema/schema-service.js +0 -0
- package/package.json +3 -3
package/dist/store/-private.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { C as CacheHandler, D as DISPOSE, R as RecordArrayManager, E as Signals, S as Store, k as StoreMap, _ as _clearCaches, n as _deprecatingNormalize, h as assertPrivateCapabilities, d as assertPrivateStore, b as coerceId, c as constructResource, J as consumeInternalSignal, G as createInternalMemo, l as createLegacyManyArray, q as createRequestSubscription, A as defineGate, B as defineNonEnumerableSignal, z as defineSignal, e as ensureStringId, y as entangleInitiallyStaleSignal, x as entangleSignal, f as fastPush, w as gate, K as getOrCreateInternalSignal, p as getPromiseState, t as getRequestState, g as isPrivateStore, a as isRequestKey, i as isResourceKey, m as log, o as logGroup, v as memoized, I as notifyInternalSignal, F as peekInternalSignal, r as recordIdentifierFor, j as setRecordIdentifier, u as signal, s as storeFor, H as withSignalStore } from "../
|
|
1
|
+
export { C as CacheHandler, D as DISPOSE, R as RecordArrayManager, E as Signals, S as Store, k as StoreMap, _ as _clearCaches, n as _deprecatingNormalize, h as assertPrivateCapabilities, d as assertPrivateStore, b as coerceId, c as constructResource, J as consumeInternalSignal, G as createInternalMemo, l as createLegacyManyArray, q as createRequestSubscription, A as defineGate, B as defineNonEnumerableSignal, z as defineSignal, e as ensureStringId, y as entangleInitiallyStaleSignal, x as entangleSignal, f as fastPush, w as gate, K as getOrCreateInternalSignal, p as getPromiseState, t as getRequestState, g as isPrivateStore, a as isRequestKey, i as isResourceKey, m as log, o as logGroup, v as memoized, I as notifyInternalSignal, F as peekInternalSignal, r as recordIdentifierFor, j as setRecordIdentifier, u as signal, s as storeFor, H as withSignalStore } from "../index-MiSBsI57.js";
|
|
2
2
|
export { A as ARRAY_SIGNAL, O as OBJECT_SIGNAL, w as waitFor } from "../configure-C3x8YXzL.js";
|
package/dist/store.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { deprecate } from '@ember/debug';
|
|
2
2
|
import { LRUCache } from './utils/string.js';
|
|
3
3
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Interface of a parsed Cache-Control header value.
|
|
7
|
+
*
|
|
8
|
+
* - [MDN Cache-Control Reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control)
|
|
9
|
+
*/
|
|
4
10
|
const NUMERIC_KEYS = new Set(['max-age', 's-maxage', 'stale-if-error', 'stale-while-revalidate']);
|
|
5
11
|
|
|
6
12
|
/**
|
|
@@ -25,6 +31,8 @@ const NUMERIC_KEYS = new Set(['max-age', 's-maxage', 'stale-if-error', 'stale-wh
|
|
|
25
31
|
* }
|
|
26
32
|
* ```
|
|
27
33
|
*
|
|
34
|
+
* See also {@link CacheControlValue} and [Response Directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control#response_directives)
|
|
35
|
+
*
|
|
28
36
|
* @public
|
|
29
37
|
* @param {String} header
|
|
30
38
|
* @return {CacheControlValue}
|
|
@@ -231,73 +239,91 @@ function isExpired(cacheKey, request, config) {
|
|
|
231
239
|
/**
|
|
232
240
|
* The configuration options for the {@link DefaultCachePolicy}
|
|
233
241
|
*
|
|
234
|
-
* ```ts
|
|
235
|
-
* import {
|
|
242
|
+
* ```ts [app/services/store.ts]
|
|
243
|
+
* import { Store } from '@warp-drive/core';
|
|
244
|
+
* import { DefaultCachePolicy } from '@warp-drive/core/store'; // [!code focus]
|
|
236
245
|
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
246
|
+
* export default class AppStore extends Store {
|
|
247
|
+
* lifetimes = new DefaultCachePolicy({ // [!code focus:3]
|
|
248
|
+
* // ... PolicyConfig Settings ... //
|
|
249
|
+
* });
|
|
250
|
+
* }
|
|
240
251
|
* ```
|
|
241
252
|
*
|
|
242
253
|
*/
|
|
243
254
|
|
|
244
255
|
/**
|
|
245
|
-
* A basic CachePolicy that can be added to the Store service.
|
|
246
|
-
*
|
|
247
|
-
* Determines staleness based on time since the request was last received from the API
|
|
248
|
-
* using the `date` header.
|
|
256
|
+
* A basic {@link CachePolicy} that can be added to the Store service.
|
|
249
257
|
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* In order expiration is determined by:
|
|
258
|
+
* ```ts [app/services/store.ts]
|
|
259
|
+
* import { Store } from '@warp-drive/core';
|
|
260
|
+
* import { DefaultCachePolicy } from '@warp-drive/core/store'; // [!code focus]
|
|
254
261
|
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
262
|
+
* export default class AppStore extends Store {
|
|
263
|
+
* lifetimes = new DefaultCachePolicy({ // [!code focus:5]
|
|
264
|
+
* apiCacheSoftExpires: 30_000,
|
|
265
|
+
* apiCacheHardExpires: 60_000,
|
|
266
|
+
* // ... Other PolicyConfig Settings ... //
|
|
267
|
+
* });
|
|
268
|
+
* }
|
|
269
|
+
* ```
|
|
261
270
|
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
271
|
+
* :::tip 💡 TIP
|
|
272
|
+
* Date headers do not have millisecond precision, so expiration times should
|
|
273
|
+
* generally be larger than 1000ms.
|
|
274
|
+
* :::
|
|
264
275
|
*
|
|
265
|
-
*
|
|
266
|
-
* with the types that should be invalidated, or its request should specify the ResourceKeys
|
|
267
|
-
* of the records that are being created via `records`. Providing both is valid.
|
|
276
|
+
* See also {@link PolicyConfig} for configuration options.
|
|
268
277
|
*
|
|
269
|
-
*
|
|
270
|
-
* > only requests that had specified `cacheOptions.types` and occurred prior to the
|
|
271
|
-
* > createRecord request will be invalidated. This means that a given request should always
|
|
272
|
-
* > specify the types that would invalidate it to opt into this behavior. Abstracting this
|
|
273
|
-
* > behavior via builders is recommended to ensure consistency.
|
|
278
|
+
* ### The Mechanics
|
|
274
279
|
*
|
|
275
|
-
* This
|
|
276
|
-
*
|
|
280
|
+
* This policy determines staleness based on various configurable constraints falling back to a simple
|
|
281
|
+
* check of the time elapsed since the request was last received from the API using the `date` header
|
|
282
|
+
* from the last response.
|
|
277
283
|
*
|
|
278
|
-
*
|
|
284
|
+
* :::tip 💡 TIP
|
|
285
|
+
* The {@link Fetch} handler provided by `@warp-drive/core` will automatically
|
|
279
286
|
* add the `date` header to responses if it is not present.
|
|
287
|
+
* :::
|
|
280
288
|
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
* > generally be larger than 1000ms.
|
|
289
|
+
* - For manual override of reload see {@link RequestInfo.cacheOptions.reload | cacheOptions.reload}
|
|
290
|
+
* - For manual override of background reload see {@link RequestInfo.cacheOptions.backgroundReload | cacheOptions.backgroundReload}
|
|
284
291
|
*
|
|
285
|
-
*
|
|
292
|
+
* In order expiration is determined by:
|
|
286
293
|
*
|
|
287
|
-
* ```
|
|
288
|
-
*
|
|
289
|
-
*
|
|
294
|
+
* ```md
|
|
295
|
+
* Is explicitly invalidated by `cacheOptions.reload`
|
|
296
|
+
* ↳ (if falsey) if the request has been explicitly invalidated
|
|
297
|
+
* since the last request (see Automatic Invalidation below)
|
|
298
|
+
* ↳ (if false) (If Active) isExpired function
|
|
299
|
+
* ↳ (if null) (If Active) X-WarpDrive-Expires header
|
|
300
|
+
* ↳ (if null) (If Active) Cache-Control header
|
|
301
|
+
* ↳ (if null) (If Active) Expires header
|
|
302
|
+
* ↳ (if null) Date header + apiCacheHardExpires < current time
|
|
290
303
|
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
* });
|
|
296
|
-
* }
|
|
304
|
+
* -- <if above is false, a background request is issued if> --
|
|
305
|
+
*
|
|
306
|
+
* ↳ is invalidated by `cacheOptions.backgroundReload`
|
|
307
|
+
* ↳ (if falsey) Date header + apiCacheSoftExpires < current time
|
|
297
308
|
* ```
|
|
298
309
|
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
310
|
+
* ### Automatic Invalidation / Entanglement
|
|
311
|
+
*
|
|
312
|
+
* It also invalidates any request with an {@link RequestInfo.op | OpCode} of `"query"`
|
|
313
|
+
* for which {@link RequestInfo.cacheOptions.types | cacheOptions.types} was provided
|
|
314
|
+
* when a request with an `OpCode` of `"createRecord"` is successful and also includes
|
|
315
|
+
* a matching type in its own `cacheOptions.types` array.
|
|
316
|
+
|
|
317
|
+
* :::tip 💡 TIP
|
|
318
|
+
* Abstracting this behavior via builders is recommended to ensure consistency.
|
|
319
|
+
* :::
|
|
320
|
+
*
|
|
321
|
+
* ### Testing
|
|
322
|
+
*
|
|
323
|
+
* In Testing environments:
|
|
324
|
+
*
|
|
325
|
+
* - `apiCacheSoftExpires` will always be `false`
|
|
326
|
+
* - `apiCacheHardExpires` will use the `apiCacheSoftExpires` value.
|
|
301
327
|
*
|
|
302
328
|
* This helps reduce flakiness and produce predictably rendered results in test suites.
|
|
303
329
|
*
|
|
@@ -310,6 +336,17 @@ function isExpired(cacheKey, request, config) {
|
|
|
310
336
|
* @public
|
|
311
337
|
*/
|
|
312
338
|
class DefaultCachePolicy {
|
|
339
|
+
/**
|
|
340
|
+
* @internal
|
|
341
|
+
*/
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* @internal
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* @internal
|
|
349
|
+
*/
|
|
313
350
|
_getStore(store) {
|
|
314
351
|
let set = this._stores.get(store);
|
|
315
352
|
if (!set) {
|
package/dist/types/-private.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
2
2
|
const name = "@warp-drive/core";
|
|
3
|
-
const version = "5.8.0-alpha.
|
|
3
|
+
const version = "5.8.0-alpha.5";
|
|
4
4
|
|
|
5
5
|
// in testing mode, we utilize globals to ensure only one copy exists of
|
|
6
6
|
// these maps, due to bugs in ember-auto-import
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warp-drive/core",
|
|
3
|
-
"version": "5.8.0-alpha.
|
|
3
|
+
"version": "5.8.0-alpha.5",
|
|
4
4
|
"description": "Core package for WarpDrive | All the Universal Basics",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@embroider/macros": "^1.18.1",
|
|
40
|
-
"@warp-drive/build-config": "5.8.0-alpha.
|
|
40
|
+
"@warp-drive/build-config": "5.8.0-alpha.5"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/core": "^7.28.3",
|
|
44
44
|
"@babel/plugin-transform-typescript": "^7.28.0",
|
|
45
45
|
"@babel/preset-typescript": "^7.27.1",
|
|
46
|
-
"@warp-drive/internal-config": "5.8.0-alpha.
|
|
46
|
+
"@warp-drive/internal-config": "5.8.0-alpha.5",
|
|
47
47
|
"decorator-transforms": "^2.3.0",
|
|
48
48
|
"ember-source": "~6.6.0",
|
|
49
49
|
"expect-type": "^1.2.2",
|