@warp-drive/core 5.8.0-beta.0 → 5.8.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.
- package/README.md +23 -36
- package/declarations/build-config.d.ts +18 -1
- package/declarations/configure.d.ts +1 -1
- package/declarations/graph/-private/-edge-definition.d.ts +12 -2
- package/declarations/index.d.ts +90 -8
- package/declarations/reactive/-private/default-mode.d.ts +1 -1
- package/declarations/reactive/-private/document.d.ts +58 -46
- package/declarations/reactive/-private/fields/extension.d.ts +1 -1
- package/declarations/reactive/-private/fields/managed-array.d.ts +2 -2
- package/declarations/reactive/-private/fields/managed-object.d.ts +1 -1
- package/declarations/reactive/-private/record.d.ts +10 -1
- package/declarations/reactive/-private/schema.d.ts +77 -4
- package/declarations/reactive/-private.d.ts +1 -0
- package/declarations/reactive.d.ts +13 -8
- package/declarations/request/-private/types.d.ts +1 -1
- package/declarations/request.d.ts +47 -0
- package/declarations/signals/-leaked.d.ts +2 -0
- package/declarations/signals/-private.d.ts +6 -0
- package/declarations/{store/-private/new-core-tmp → signals}/promise-state.d.ts +2 -1
- package/declarations/{store/-private/new-core-tmp → signals}/request-state.d.ts +6 -6
- package/declarations/{store/-private/new-core-tmp → signals}/request-subscription.d.ts +4 -4
- package/declarations/store/-private/cache-handler/types.d.ts +2 -16
- package/declarations/store/-private/caches/instance-cache.d.ts +5 -6
- package/declarations/store/-private/default-cache-policy.d.ts +147 -129
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +1 -1
- package/declarations/store/-private/managers/cache-key-manager.d.ts +26 -8
- package/declarations/store/-private/managers/cache-manager.d.ts +7 -18
- package/declarations/store/-private/managers/notification-manager.d.ts +1 -1
- package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +1 -1
- package/declarations/store/-private/record-arrays/resource-array.d.ts +1 -1
- package/declarations/store/-private/store-service.d.ts +43 -64
- package/declarations/store/-private.d.ts +0 -6
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +1 -1
- package/declarations/store/deprecated/-private.d.ts +2 -2
- package/declarations/store/deprecated/store.d.ts +33 -32
- package/declarations/store.d.ts +1 -0
- package/declarations/types/cache.d.ts +8 -6
- package/declarations/types/record.d.ts +132 -0
- package/declarations/types/request.d.ts +26 -14
- package/declarations/types/schema/fields.d.ts +37 -13
- package/declarations/{store/-types/q → types/schema}/schema-service.d.ts +15 -13
- package/declarations/types/spec/document.d.ts +34 -0
- package/declarations/types/symbols.d.ts +2 -2
- package/declarations/types.d.ts +1 -1
- package/dist/build-config.js +1 -1
- package/dist/configure-DPUFCemT.js +1940 -0
- package/dist/configure.js +2 -1
- package/dist/default-cache-policy-D7_u4YRH.js +572 -0
- package/dist/{context-C_7OLieY.js → future-BKkJJkj7.js} +174 -174
- package/dist/graph/-private.js +16 -6
- package/dist/{request-state-C955e0AL.js → index-CQP2NSqg.js} +8830 -9427
- package/dist/index.js +6 -382
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +4 -903
- package/dist/request.js +49 -1
- package/dist/signals/-leaked.js +1 -0
- package/dist/store/-private.js +1 -2
- package/dist/store.js +1 -533
- package/dist/symbols-3C1OkYtZ.js +39 -0
- package/dist/types/-private.js +1 -1
- package/dist/types/record.js +127 -0
- package/dist/types/request.js +14 -12
- package/dist/types/runtime.js +1 -1
- package/dist/types/schema/fields.js +14 -0
- package/dist/types/schema/schema-service.js +0 -0
- package/dist/types/symbols.js +2 -2
- package/dist/unpkg/dev/-leaked-Co0EI6Go.js +1939 -0
- package/dist/unpkg/dev/build-config/babel-macros.js +1 -0
- package/dist/unpkg/dev/build-config/canary-features.js +1 -0
- package/dist/unpkg/dev/build-config/debugging.js +1 -0
- package/dist/unpkg/dev/build-config/deprecations.js +1 -0
- package/dist/unpkg/dev/build-config/env.js +1 -0
- package/dist/unpkg/dev/build-config/macros.js +1 -0
- package/dist/unpkg/dev/build-config.js +1 -0
- package/dist/unpkg/dev/configure.js +1 -0
- package/dist/unpkg/dev/future-DFfOzSoe.js +672 -0
- package/dist/unpkg/dev/graph/-private.js +3132 -0
- package/dist/unpkg/dev/index-BzcBOnw9.js +9392 -0
- package/dist/unpkg/dev/index.js +6 -0
- package/dist/unpkg/dev/reactive/-private.js +1 -0
- package/dist/unpkg/dev/reactive.js +3 -0
- package/dist/unpkg/dev/request.js +49 -0
- package/dist/unpkg/dev/runtime-E1M51_-O.js +135 -0
- package/dist/unpkg/dev/signals/-leaked.js +1 -0
- package/dist/unpkg/dev/store/-private.js +55 -0
- package/dist/unpkg/dev/store.js +558 -0
- package/dist/unpkg/dev/types/-private.js +69 -0
- package/dist/unpkg/dev/types/cache/aliases.js +0 -0
- package/dist/unpkg/dev/types/cache/change.js +0 -0
- package/dist/unpkg/dev/types/cache/mutations.js +0 -0
- package/dist/unpkg/dev/types/cache/operations.js +0 -0
- package/dist/unpkg/dev/types/cache/relationship.js +0 -0
- package/dist/unpkg/dev/types/cache.js +0 -0
- package/dist/unpkg/dev/types/graph.js +0 -0
- package/dist/unpkg/dev/types/identifier.js +61 -0
- package/dist/unpkg/dev/types/json/raw.js +0 -0
- package/dist/unpkg/dev/types/params.js +0 -0
- package/dist/unpkg/dev/types/record.js +191 -0
- package/dist/unpkg/dev/types/request.js +77 -0
- package/dist/unpkg/dev/types/runtime.js +34 -0
- package/dist/unpkg/dev/types/schema/concepts.js +0 -0
- package/dist/unpkg/dev/types/schema/fields.js +505 -0
- package/dist/unpkg/dev/types/schema/fields.type-test.js +0 -0
- package/dist/unpkg/dev/types/schema/schema-service.js +0 -0
- package/dist/unpkg/dev/types/spec/document.js +0 -0
- package/dist/unpkg/dev/types/spec/error.js +0 -0
- package/dist/unpkg/dev/types/spec/json-api-raw.js +0 -0
- package/dist/unpkg/dev/types/symbols.js +84 -0
- package/dist/unpkg/dev/types/utils.js +0 -0
- package/dist/unpkg/dev/types.js +0 -0
- package/dist/unpkg/dev/utils/string.js +91 -0
- package/dist/unpkg/dev-deprecated/-leaked-DjMeRqdU.js +1939 -0
- package/dist/unpkg/dev-deprecated/-private-3C1OkYtZ.js +39 -0
- package/dist/unpkg/dev-deprecated/build-config/babel-macros.js +1 -0
- package/dist/unpkg/dev-deprecated/build-config/canary-features.js +1 -0
- package/dist/unpkg/dev-deprecated/build-config/debugging.js +1 -0
- package/dist/unpkg/dev-deprecated/build-config/deprecations.js +1 -0
- package/dist/unpkg/dev-deprecated/build-config/env.js +1 -0
- package/dist/unpkg/dev-deprecated/build-config/macros.js +1 -0
- package/dist/unpkg/dev-deprecated/build-config.js +1 -0
- package/dist/unpkg/dev-deprecated/configure.js +1 -0
- package/dist/unpkg/dev-deprecated/future-DFfOzSoe.js +672 -0
- package/dist/unpkg/dev-deprecated/graph/-private.js +3327 -0
- package/dist/unpkg/dev-deprecated/index-6TnTv-WG.js +10007 -0
- package/dist/unpkg/dev-deprecated/index.js +5 -0
- package/dist/unpkg/dev-deprecated/reactive/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/reactive.js +3 -0
- package/dist/unpkg/dev-deprecated/request.js +49 -0
- package/dist/unpkg/dev-deprecated/runtime-DAu5b0IR.js +135 -0
- package/dist/unpkg/dev-deprecated/signals/-leaked.js +1 -0
- package/dist/unpkg/dev-deprecated/store/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/store.js +558 -0
- package/dist/unpkg/dev-deprecated/types/-private.js +69 -0
- package/dist/unpkg/dev-deprecated/types/cache/aliases.js +0 -0
- package/dist/unpkg/dev-deprecated/types/cache/change.js +0 -0
- package/dist/unpkg/dev-deprecated/types/cache/mutations.js +0 -0
- package/dist/unpkg/dev-deprecated/types/cache/operations.js +0 -0
- package/dist/unpkg/dev-deprecated/types/cache/relationship.js +0 -0
- package/dist/unpkg/dev-deprecated/types/cache.js +0 -0
- package/dist/unpkg/dev-deprecated/types/graph.js +0 -0
- package/dist/unpkg/dev-deprecated/types/identifier.js +61 -0
- package/dist/unpkg/dev-deprecated/types/json/raw.js +0 -0
- package/dist/unpkg/dev-deprecated/types/params.js +0 -0
- package/dist/unpkg/dev-deprecated/types/record.js +191 -0
- package/dist/unpkg/dev-deprecated/types/request.js +77 -0
- package/dist/unpkg/dev-deprecated/types/runtime.js +34 -0
- package/dist/unpkg/dev-deprecated/types/schema/concepts.js +0 -0
- package/dist/unpkg/dev-deprecated/types/schema/fields.js +505 -0
- package/dist/unpkg/dev-deprecated/types/schema/fields.type-test.js +0 -0
- package/dist/unpkg/dev-deprecated/types/schema/schema-service.js +0 -0
- package/dist/unpkg/dev-deprecated/types/spec/document.js +0 -0
- package/dist/unpkg/dev-deprecated/types/spec/error.js +0 -0
- package/dist/unpkg/dev-deprecated/types/spec/json-api-raw.js +0 -0
- package/dist/unpkg/dev-deprecated/types/symbols.js +84 -0
- package/dist/unpkg/dev-deprecated/types/utils.js +0 -0
- package/dist/unpkg/dev-deprecated/types.js +0 -0
- package/dist/unpkg/dev-deprecated/utils/string.js +91 -0
- package/dist/unpkg/prod/-leaked-DUONXQDB.js +1676 -0
- package/dist/unpkg/prod/-private-sql1_mdx.js +39 -0
- package/dist/unpkg/prod/build-config/babel-macros.js +1 -0
- package/dist/unpkg/prod/build-config/canary-features.js +1 -0
- package/dist/unpkg/prod/build-config/debugging.js +1 -0
- package/dist/unpkg/prod/build-config/deprecations.js +1 -0
- package/dist/unpkg/prod/build-config/env.js +1 -0
- package/dist/unpkg/prod/build-config/macros.js +1 -0
- package/dist/unpkg/prod/build-config.js +1 -0
- package/dist/unpkg/prod/configure.js +2 -0
- package/dist/unpkg/prod/graph/-private.js +2235 -0
- package/dist/unpkg/prod/handler-EU_8ncB2.js +1619 -0
- package/dist/unpkg/prod/index.js +483 -0
- package/dist/unpkg/prod/promise-cache-DIT8Ypjq.js +19 -0
- package/dist/unpkg/prod/reactive/-private.js +1 -0
- package/dist/unpkg/prod/reactive.js +30 -0
- package/dist/unpkg/prod/request-BrJSCG6r.js +421 -0
- package/dist/unpkg/prod/request.js +2 -0
- package/dist/unpkg/prod/schema-BSkHyoWz.js +5219 -0
- package/dist/unpkg/prod/signals/-leaked.js +1 -0
- package/dist/unpkg/prod/store/-private.js +126 -0
- package/dist/unpkg/prod/store.js +437 -0
- package/dist/unpkg/prod/types/-private.js +49 -0
- package/dist/unpkg/prod/types/cache/aliases.js +0 -0
- package/dist/unpkg/prod/types/cache/change.js +0 -0
- package/dist/unpkg/prod/types/cache/mutations.js +0 -0
- package/dist/unpkg/prod/types/cache/operations.js +0 -0
- package/dist/unpkg/prod/types/cache/relationship.js +0 -0
- package/dist/unpkg/prod/types/cache.js +0 -0
- package/dist/unpkg/prod/types/graph.js +0 -0
- package/dist/unpkg/prod/types/identifier.js +61 -0
- package/dist/unpkg/prod/types/json/raw.js +0 -0
- package/dist/unpkg/prod/types/params.js +0 -0
- package/dist/unpkg/prod/types/record.js +191 -0
- package/dist/unpkg/prod/types/request.js +77 -0
- package/dist/unpkg/prod/types/runtime.js +34 -0
- package/dist/unpkg/prod/types/schema/concepts.js +0 -0
- package/dist/unpkg/prod/types/schema/fields.js +505 -0
- package/dist/unpkg/prod/types/schema/fields.type-test.js +0 -0
- package/dist/unpkg/prod/types/schema/schema-service.js +0 -0
- package/dist/unpkg/prod/types/spec/document.js +0 -0
- package/dist/unpkg/prod/types/spec/error.js +0 -0
- package/dist/unpkg/prod/types/spec/json-api-raw.js +0 -0
- package/dist/unpkg/prod/types/symbols.js +84 -0
- package/dist/unpkg/prod/types/utils.js +0 -0
- package/dist/unpkg/prod/types.js +0 -0
- package/dist/unpkg/prod/utils/string.js +72 -0
- package/dist/unpkg/prod-deprecated/-leaked-DRNv9VIX.js +1676 -0
- package/dist/unpkg/prod-deprecated/-private-3C1OkYtZ.js +39 -0
- package/dist/unpkg/prod-deprecated/build-config/babel-macros.js +1 -0
- package/dist/unpkg/prod-deprecated/build-config/canary-features.js +1 -0
- package/dist/unpkg/prod-deprecated/build-config/debugging.js +1 -0
- package/dist/unpkg/prod-deprecated/build-config/deprecations.js +1 -0
- package/dist/unpkg/prod-deprecated/build-config/env.js +1 -0
- package/dist/unpkg/prod-deprecated/build-config/macros.js +1 -0
- package/dist/unpkg/prod-deprecated/build-config.js +1 -0
- package/dist/unpkg/prod-deprecated/configure.js +2 -0
- package/dist/unpkg/prod-deprecated/graph/-private.js +2408 -0
- package/dist/unpkg/prod-deprecated/handler-CCIu4sQ3.js +334 -0
- package/dist/unpkg/prod-deprecated/hooks-Dv4Np0MY.js +26 -0
- package/dist/unpkg/prod-deprecated/index.js +483 -0
- package/dist/unpkg/prod-deprecated/promise-cache-DIT8Ypjq.js +19 -0
- package/dist/unpkg/prod-deprecated/reactive/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/reactive.js +5 -0
- package/dist/unpkg/prod-deprecated/request-BrJSCG6r.js +421 -0
- package/dist/unpkg/prod-deprecated/request.js +2 -0
- package/dist/unpkg/prod-deprecated/schema-CJcjHv0E.js +6939 -0
- package/dist/unpkg/prod-deprecated/signals/-leaked.js +1 -0
- package/dist/unpkg/prod-deprecated/store/-private.js +88 -0
- package/dist/unpkg/prod-deprecated/store.js +437 -0
- package/dist/unpkg/prod-deprecated/types/-private.js +49 -0
- package/dist/unpkg/prod-deprecated/types/cache/aliases.js +0 -0
- package/dist/unpkg/prod-deprecated/types/cache/change.js +0 -0
- package/dist/unpkg/prod-deprecated/types/cache/mutations.js +0 -0
- package/dist/unpkg/prod-deprecated/types/cache/operations.js +0 -0
- package/dist/unpkg/prod-deprecated/types/cache/relationship.js +0 -0
- package/dist/unpkg/prod-deprecated/types/cache.js +0 -0
- package/dist/unpkg/prod-deprecated/types/graph.js +0 -0
- package/dist/unpkg/prod-deprecated/types/identifier.js +61 -0
- package/dist/unpkg/prod-deprecated/types/json/raw.js +0 -0
- package/dist/unpkg/prod-deprecated/types/params.js +0 -0
- package/dist/unpkg/prod-deprecated/types/record.js +191 -0
- package/dist/unpkg/prod-deprecated/types/request.js +77 -0
- package/dist/unpkg/prod-deprecated/types/runtime.js +34 -0
- package/dist/unpkg/prod-deprecated/types/schema/concepts.js +0 -0
- package/dist/unpkg/prod-deprecated/types/schema/fields.js +505 -0
- package/dist/unpkg/prod-deprecated/types/schema/fields.type-test.js +0 -0
- package/dist/unpkg/prod-deprecated/types/schema/schema-service.js +0 -0
- package/dist/unpkg/prod-deprecated/types/spec/document.js +0 -0
- package/dist/unpkg/prod-deprecated/types/spec/error.js +0 -0
- package/dist/unpkg/prod-deprecated/types/spec/json-api-raw.js +0 -0
- package/dist/unpkg/prod-deprecated/types/symbols.js +84 -0
- package/dist/unpkg/prod-deprecated/types/utils.js +0 -0
- package/dist/unpkg/prod-deprecated/types.js +0 -0
- package/dist/unpkg/prod-deprecated/utils/string.js +72 -0
- package/logos/README.md +2 -2
- package/logos/logo-yellow-slab.svg +1 -0
- package/logos/word-mark-black.svg +1 -0
- package/logos/word-mark-white.svg +1 -0
- package/package.json +12 -4
- package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +0 -24
- package/dist/configure-C3x8YXzL.js +0 -181
- package/logos/NCC-1701-a-blue.svg +0 -4
- package/logos/NCC-1701-a-gold.svg +0 -4
- package/logos/NCC-1701-a-gold_100.svg +0 -1
- package/logos/NCC-1701-a-gold_base-64.txt +0 -1
- package/logos/NCC-1701-a.svg +0 -4
- package/logos/docs-badge.svg +0 -2
- package/logos/ember-data-logo-dark.svg +0 -12
- package/logos/ember-data-logo-light.svg +0 -12
- package/logos/social1.png +0 -0
- package/logos/social2.png +0 -0
- package/logos/warp-drive-logo-dark.svg +0 -4
- package/logos/warp-drive-logo-gold.svg +0 -4
- /package/declarations/{store/-private/new-core-tmp → signals}/reactivity/configure.d.ts +0 -0
- /package/declarations/{store/-private/new-core-tmp → signals}/reactivity/internal.d.ts +0 -0
- /package/declarations/{store/-private/new-core-tmp → signals}/reactivity/signal.d.ts +0 -0
- /package/dist/{symbols-sql1_mdx.js → unpkg/dev/-private-sql1_mdx.js} +0 -0
|
@@ -1,5 +1,52 @@
|
|
|
1
|
+
import type { ReactiveDataDocument } from "./reactive.js";
|
|
2
|
+
import type { RequestInfo } from "./types/request.js";
|
|
3
|
+
import type { RequestSignature } from "./types/symbols.js";
|
|
1
4
|
export { createDeferred } from "./request/-private/future.js";
|
|
2
5
|
export type { Future, Handler, CacheHandler, NextFn, Deferred, ManagedRequestPriority } from "./request/-private/types.js";
|
|
3
6
|
export { setPromiseResult, getPromiseResult } from "./request/-private/promise-cache.js";
|
|
4
7
|
export type { Awaitable } from "./request/-private/promise-cache.js";
|
|
5
8
|
export type { Context } from "./request/-private/context.js";
|
|
9
|
+
/**
|
|
10
|
+
* Brands the supplied object with the supplied response type.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import type { ReactiveDataDocument } from '@warp-drive/core/reactive';
|
|
14
|
+
* import { withResponseType } from '@warp-drive/core/request';
|
|
15
|
+
* import type { User } from '#/data/user.ts'
|
|
16
|
+
*
|
|
17
|
+
* const result = await store.request(
|
|
18
|
+
* withResponseType<ReactiveDataDocument<User>>({ url: '/users/1' })
|
|
19
|
+
* );
|
|
20
|
+
*
|
|
21
|
+
* result.content.data; // will have type User
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
export declare function withResponseType<T>(obj: RequestInfo): RequestInfo<T> & {
|
|
26
|
+
[RequestSignature]: T;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Brands the supplied object with the supplied response type
|
|
30
|
+
* wrapped in {@link ReactiveDataDocument}. This is a convenience for
|
|
31
|
+
* the common case of using {@link withResponseType} with `ReactiveDataDocument`.
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { withReactiveResponse } from '@warp-drive/core/request';
|
|
35
|
+
* import type { User } from '#/data/user.ts'
|
|
36
|
+
*
|
|
37
|
+
* const result = await store.request(
|
|
38
|
+
* withReactiveResponse<User>({ url: '/users/1' })
|
|
39
|
+
* );
|
|
40
|
+
*
|
|
41
|
+
* result.content.data; // will have type User
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export declare function withReactiveResponse<T>(obj: RequestInfo): RequestInfo<ReactiveDataDocument<T>> & {
|
|
47
|
+
[RequestSignature]: ReactiveDataDocument<T>;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated use {@link withResponseType} instead
|
|
51
|
+
*/
|
|
52
|
+
export declare const withBrand: typeof withResponseType;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { defineNonEnumerableSignal, defineGate, defineSignal, entangleSignal, signal, waitFor, gate, DISPOSE, memoized, notifyInternalSignal, peekInternalSignal, withSignalStore } from "./-private.js";
|
|
2
|
+
export type { AutorefreshBehaviorCombos, SubscriptionArgs, ContentFeatures, RecoveryFeatures, RequestArgs } from "./-private.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DISPOSE, createRequestSubscription, type RequestArgs, type SubscriptionArgs, type RequestComponentArgs, type RequestSubscription, type ContentFeatures, type RecoveryFeatures, type AutorefreshBehaviorCombos, type AutorefreshBehaviorType } from "./request-subscription.js";
|
|
2
|
+
export { getRequestState, type RequestLoadingState, type RequestState } from "./request-state.js";
|
|
3
|
+
export { getPromiseState, type PromiseState, type ResolvedPromise, type RejectedPromise, type PendingPromise } from "./promise-state.js";
|
|
4
|
+
export { setupSignals, type HooksOptions, type SignalHooks, waitFor, willSyncFlushWatchers } from "./reactivity/configure.js";
|
|
5
|
+
export { signal, memoized, gate, entangleSignal, entangleInitiallyStaleSignal, defineSignal, defineGate, defineNonEnumerableSignal, createSignalDescriptor } from "./reactivity/signal.js";
|
|
6
|
+
export { type SignalStore, ARRAY_SIGNAL, OBJECT_SIGNAL, Signals, type WarpDriveSignal, peekInternalSignal, createInternalMemo, withSignalStore, notifyInternalSignal, consumeInternalSignal, getOrCreateInternalSignal, createInternalSignal } from "./reactivity/internal.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Awaitable } from "
|
|
1
|
+
import type { Awaitable } from "../request.js";
|
|
2
2
|
/**
|
|
3
3
|
* The state of a promise in the "pending"
|
|
4
4
|
* state. This is the default initial state.
|
|
@@ -256,6 +256,7 @@ export declare function createPromiseState<
|
|
|
256
256
|
*
|
|
257
257
|
* If looking to use in a template, consider also the `<Await />` component.
|
|
258
258
|
*
|
|
259
|
+
* See also {@link PromiseState}
|
|
259
260
|
*/
|
|
260
261
|
export declare function getPromiseState<
|
|
261
262
|
T = unknown,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Future } from "
|
|
2
|
-
import type { ImmutableRequestInfo, ResponseInfo, StructuredErrorDocument } from "
|
|
1
|
+
import type { Future } from "../request.js";
|
|
2
|
+
import type { ImmutableRequestInfo, ResponseInfo, StructuredErrorDocument } from "../types/request.js";
|
|
3
3
|
import type { PendingPromise, RejectedPromise, ResolvedPromise } from "./promise-state.js";
|
|
4
4
|
/**
|
|
5
5
|
* Lazily consumes the stream of a request, providing a number of
|
|
@@ -308,14 +308,14 @@ export interface PrivateRequestState {
|
|
|
308
308
|
* - {@link CancelledRequest}
|
|
309
309
|
*
|
|
310
310
|
*/
|
|
311
|
-
export type
|
|
311
|
+
export type RequestState<
|
|
312
312
|
RT = unknown,
|
|
313
313
|
E extends StructuredErrorDocument = StructuredErrorDocument
|
|
314
314
|
> = PendingRequest | ResolvedRequest<RT> | RejectedRequest<RT, E> | CancelledRequest<RT, E>;
|
|
315
315
|
export declare function createRequestState<
|
|
316
316
|
RT,
|
|
317
317
|
E
|
|
318
|
-
>(future: Future<RT>): Readonly<
|
|
318
|
+
>(future: Future<RT>): Readonly<RequestState<RT, StructuredErrorDocument<E>>>;
|
|
319
319
|
/**
|
|
320
320
|
* `getRequestState` can be used in both JavaScript and Template contexts.
|
|
321
321
|
*
|
|
@@ -362,11 +362,11 @@ export declare function createRequestState<
|
|
|
362
362
|
* ```
|
|
363
363
|
*
|
|
364
364
|
* If looking to use in a template, consider also the `<Request />` component
|
|
365
|
-
* which offers a
|
|
365
|
+
* which offers a number of additional capabilities for requests *beyond* what
|
|
366
366
|
* `RequestState` provides.
|
|
367
367
|
*
|
|
368
368
|
*/
|
|
369
369
|
export declare function getRequestState<
|
|
370
370
|
RT,
|
|
371
371
|
E
|
|
372
|
-
>(future: Future<RT>): Readonly<
|
|
372
|
+
>(future: Future<RT>): Readonly<RequestState<RT, StructuredErrorDocument<E>>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { RequestManager, Store, StoreRequestInput } from "
|
|
2
|
-
import type { Future } from "
|
|
3
|
-
import type { StructuredErrorDocument } from "
|
|
4
|
-
import type { RequestState } from "
|
|
1
|
+
import type { RequestManager, Store, StoreRequestInput } from "../index.js";
|
|
2
|
+
import type { Future } from "../request.js";
|
|
3
|
+
import type { StructuredErrorDocument } from "../types/request.js";
|
|
4
|
+
import type { RequestState } from "./request-state.js";
|
|
5
5
|
export declare const DISPOSE: "(symbol) dispose";
|
|
6
6
|
export type AutorefreshBehaviorType = "online" | "interval" | "invalid";
|
|
7
7
|
export type AutorefreshBehaviorCombos = boolean | AutorefreshBehaviorType | `${AutorefreshBehaviorType},${AutorefreshBehaviorType}` | `${AutorefreshBehaviorType},${AutorefreshBehaviorType},${AutorefreshBehaviorType}`;
|
|
@@ -12,7 +12,6 @@ import type { Store } from "../store-service.js";
|
|
|
12
12
|
* Implementing this service allows you to programatically define
|
|
13
13
|
* when a request should be considered expired.
|
|
14
14
|
*
|
|
15
|
-
* @class (Interface) CachePolicy
|
|
16
15
|
* @public
|
|
17
16
|
*/
|
|
18
17
|
export interface CachePolicy {
|
|
@@ -27,9 +26,7 @@ export interface CachePolicy {
|
|
|
27
26
|
* and the cache will be updated before returning the response.
|
|
28
27
|
*
|
|
29
28
|
* @public
|
|
30
|
-
* @
|
|
31
|
-
* @param {Store} store
|
|
32
|
-
* @return {Boolean} true if the request is considered hard expired
|
|
29
|
+
* @return true if the request is considered hard expired
|
|
33
30
|
*/
|
|
34
31
|
isHardExpired(identifier: RequestKey, store: Store): boolean;
|
|
35
32
|
/**
|
|
@@ -42,9 +39,7 @@ export interface CachePolicy {
|
|
|
42
39
|
* request is made to update the cache via the configured request handlers.
|
|
43
40
|
*
|
|
44
41
|
* @public
|
|
45
|
-
* @
|
|
46
|
-
* @param {Store} store
|
|
47
|
-
* @return {Boolean} true if the request is considered soft expired
|
|
42
|
+
* @return true if the request is considered soft expired
|
|
48
43
|
*/
|
|
49
44
|
isSoftExpired(identifier: RequestKey, store: Store): boolean;
|
|
50
45
|
/**
|
|
@@ -54,10 +49,6 @@ export interface CachePolicy {
|
|
|
54
49
|
* Note, this is invoked regardless of whether the request has a cache-key.
|
|
55
50
|
*
|
|
56
51
|
* @public
|
|
57
|
-
* @param {ImmutableRequestInfo} request
|
|
58
|
-
* @param {RequestKey | null} identifier
|
|
59
|
-
* @param {Store} store
|
|
60
|
-
* @return {void}
|
|
61
52
|
*/
|
|
62
53
|
willRequest?(request: ImmutableRequestInfo, identifier: RequestKey | null, store: Store): void;
|
|
63
54
|
/**
|
|
@@ -88,11 +79,6 @@ export interface CachePolicy {
|
|
|
88
79
|
*
|
|
89
80
|
*
|
|
90
81
|
* @public
|
|
91
|
-
* @param {ImmutableRequestInfo} request
|
|
92
|
-
* @param {ImmutableResponse} response
|
|
93
|
-
* @param {RequestKey | null} identifier
|
|
94
|
-
* @param {Store} store
|
|
95
|
-
* @return {void}
|
|
96
82
|
*/
|
|
97
83
|
didRequest?(request: ImmutableRequestInfo, response: Response | ResponseInfo | null, identifier: RequestKey | null, store: Store): void;
|
|
98
84
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactiveDocument } from "../../../reactive/-private/document.js";
|
|
1
|
+
import { type ReactiveDocument } from "../../../reactive/-private/document.js";
|
|
2
2
|
import type { Cache } from "../../../types/cache.js";
|
|
3
3
|
import type { RequestKey, ResourceKey } from "../../../types/identifier.js";
|
|
4
4
|
import type { TypedRecordInstance, TypeFromInstance } from "../../../types/record.js";
|
|
@@ -6,13 +6,13 @@ import type { OpaqueRecordInstance } from "../../-types/q/record-instance.js";
|
|
|
6
6
|
import { CacheCapabilitiesManager } from "../managers/cache-capabilities-manager.js";
|
|
7
7
|
import type { CacheManager } from "../managers/cache-manager.js";
|
|
8
8
|
import type { CreateRecordProperties, Store } from "../store-service.js";
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function peekResourceKey(record: OpaqueRecordInstance): ResourceKey | undefined;
|
|
10
10
|
/**
|
|
11
|
-
Retrieves the unique referentially-stable
|
|
11
|
+
Retrieves the unique referentially-stable {@link ResourceKey}
|
|
12
12
|
assigned to the given record instance.
|
|
13
13
|
|
|
14
14
|
```js
|
|
15
|
-
import { recordIdentifierFor } from "@
|
|
15
|
+
import { recordIdentifierFor } from "@warp-drive/core";
|
|
16
16
|
// ... gain access to a record, for instance with peekRecord or findRecord
|
|
17
17
|
const record = store.peekRecord("user", "1");
|
|
18
18
|
// get the identifier for the record (see docs for ResourceKey)
|
|
@@ -22,8 +22,7 @@ const { id, type, lid } = identifier;
|
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
@public
|
|
25
|
-
@param
|
|
26
|
-
@return {ResourceKey}
|
|
25
|
+
@param record a record instance previously obstained from the store.
|
|
27
26
|
*/
|
|
28
27
|
export declare function recordIdentifierFor<T extends TypedRecordInstance>(record: T): ResourceKey<TypeFromInstance<T>>;
|
|
29
28
|
export declare function recordIdentifierFor(record: OpaqueRecordInstance): ResourceKey;
|
|
@@ -2,6 +2,7 @@ import type { Cache } from "@warp-drive/core/types/cache";
|
|
|
2
2
|
import type { RequestKey, ResourceKey } from "@warp-drive/core/types/identifier";
|
|
3
3
|
import type { ImmutableRequestInfo, ResponseInfo, StructuredDocument } from "@warp-drive/core/types/request";
|
|
4
4
|
import type { ResourceDocument } from "@warp-drive/core/types/spec/document";
|
|
5
|
+
import type { CachePolicy } from "../-private.js";
|
|
5
6
|
type UnsubscribeToken = object;
|
|
6
7
|
type CacheOperation = "added" | "removed" | "updated" | "state";
|
|
7
8
|
type DocumentCacheOperation = "invalidated" | "added" | "removed" | "updated" | "state";
|
|
@@ -28,6 +29,11 @@ type Store = {
|
|
|
28
29
|
cache: Cache;
|
|
29
30
|
notifications: NotificationManager;
|
|
30
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Interface of a parsed Cache-Control header value.
|
|
34
|
+
*
|
|
35
|
+
* - [MDN Cache-Control Reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control)
|
|
36
|
+
*/
|
|
31
37
|
export interface CacheControlValue {
|
|
32
38
|
immutable?: boolean;
|
|
33
39
|
"max-age"?: number;
|
|
@@ -66,24 +72,83 @@ export interface CacheControlValue {
|
|
|
66
72
|
* }
|
|
67
73
|
* ```
|
|
68
74
|
*
|
|
75
|
+
* See also {@link CacheControlValue} and [Response Directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control#response_directives)
|
|
76
|
+
*
|
|
69
77
|
* @public
|
|
70
|
-
* @param {String} header
|
|
71
|
-
* @return {CacheControlValue}
|
|
72
78
|
*/
|
|
73
79
|
export declare function parseCacheControl(header: string): CacheControlValue;
|
|
74
80
|
/**
|
|
81
|
+
* The constraint options for {@link PolicyConfig.constraints}
|
|
82
|
+
*/
|
|
83
|
+
export interface PolicyConfigConstraints {
|
|
84
|
+
/**
|
|
85
|
+
* Headers that should be checked for expiration.
|
|
86
|
+
*
|
|
87
|
+
*/
|
|
88
|
+
headers?: {
|
|
89
|
+
/**
|
|
90
|
+
* Whether the `Cache-Control` header should be checked for expiration.
|
|
91
|
+
* If `true`, then the `max-age` and `s-maxage` directives are used alongside
|
|
92
|
+
* the `Age` and `Date` headers to determine if the expiration time has passed.
|
|
93
|
+
*
|
|
94
|
+
* Other directives are ignored.
|
|
95
|
+
*
|
|
96
|
+
* 'Cache-Control' will take precedence over 'Expires' if both are present
|
|
97
|
+
* and both configured to be checked.
|
|
98
|
+
*
|
|
99
|
+
*/
|
|
100
|
+
"Cache-Control"?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Whether the `Expires` header should be checked for expiration.
|
|
103
|
+
*
|
|
104
|
+
* If `true`, then the `Expires` header is used to caclulate the expiration time
|
|
105
|
+
* and determine if the expiration time has passed.
|
|
106
|
+
*
|
|
107
|
+
* 'Cache-Control' will take precedence over 'Expires' if both are present.
|
|
108
|
+
*
|
|
109
|
+
*/
|
|
110
|
+
Expires?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Whether the `X-WarpDrive-Expires` header should be checked for expiration.
|
|
113
|
+
*
|
|
114
|
+
* If `true`, then the `X-WarpDrive-Expires` header is used to caclulate the expiration time
|
|
115
|
+
* and determine if the expiration time has passed.
|
|
116
|
+
*
|
|
117
|
+
* This header will take precedence over 'Cache-Control' and 'Expires' if all three are present.
|
|
118
|
+
*
|
|
119
|
+
* The header's value should be a [UTC date string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString).
|
|
120
|
+
*
|
|
121
|
+
*/
|
|
122
|
+
"X-WarpDrive-Expires"?: boolean;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* A function that should be called to determine if the request is expired.
|
|
126
|
+
*
|
|
127
|
+
* If present, this function will be called with the request and should return
|
|
128
|
+
* `true` if the request is expired, `false` if it is not expired, and
|
|
129
|
+
* `null` if the expiration status is unknown.
|
|
130
|
+
*
|
|
131
|
+
* If the function does not return `null`,
|
|
132
|
+
*
|
|
133
|
+
*/
|
|
134
|
+
isExpired?: (request: StructuredDocument<ResourceDocument>) => boolean | null;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
75
137
|
* The configuration options for the {@link DefaultCachePolicy}
|
|
76
138
|
*
|
|
77
|
-
* ```ts
|
|
78
|
-
* import {
|
|
139
|
+
* ```ts [app/services/store.ts]
|
|
140
|
+
* import { Store } from '@warp-drive/core';
|
|
141
|
+
* import { DefaultCachePolicy } from '@warp-drive/core/store'; // [!code focus]
|
|
79
142
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
143
|
+
* export default class AppStore extends Store {
|
|
144
|
+
* lifetimes = new DefaultCachePolicy({ // [!code focus:3]
|
|
145
|
+
* // ... PolicyConfig Settings ... //
|
|
146
|
+
* });
|
|
147
|
+
* }
|
|
83
148
|
* ```
|
|
84
149
|
*
|
|
85
150
|
*/
|
|
86
|
-
export
|
|
151
|
+
export interface PolicyConfig {
|
|
87
152
|
/**
|
|
88
153
|
* the number of milliseconds after which a request is considered
|
|
89
154
|
* stale. If a request is issued again after this time, the request
|
|
@@ -92,10 +157,9 @@ export type PolicyConfig = {
|
|
|
92
157
|
*
|
|
93
158
|
* This is calculated against the `date` header of the response.
|
|
94
159
|
*
|
|
95
|
-
* If your API does not provide a `date` header, the
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* header will be considered stale immediately.
|
|
160
|
+
* If your API does not provide a `date` header, the {@link Fetch} handler
|
|
161
|
+
* will automatically add it to responses if it is not present. Responses
|
|
162
|
+
* without a `date` header will be considered stale immediately.
|
|
99
163
|
*
|
|
100
164
|
*/
|
|
101
165
|
apiCacheSoftExpires: number;
|
|
@@ -107,10 +171,9 @@ export type PolicyConfig = {
|
|
|
107
171
|
*
|
|
108
172
|
* This is calculated against the `date` header of the response.
|
|
109
173
|
*
|
|
110
|
-
* If your API does not provide a `date` header, the
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* header will be considered hard expired immediately.
|
|
174
|
+
* If your API does not provide a `date` header, the {@link Fetch} handler
|
|
175
|
+
* will automatically add it to responses if it is not present. Responses
|
|
176
|
+
* without a `date` header will be considered hard expired immediately.
|
|
114
177
|
*
|
|
115
178
|
*/
|
|
116
179
|
apiCacheHardExpires: number;
|
|
@@ -120,8 +183,8 @@ export type PolicyConfig = {
|
|
|
120
183
|
*
|
|
121
184
|
* This helps reduce flakiness and produce predictably rendered results in test suites.
|
|
122
185
|
*
|
|
123
|
-
* Requests that specifically set
|
|
124
|
-
* still be background reloaded in tests.
|
|
186
|
+
* Requests that specifically set {@link RequestInfo.cacheOptions.backgroundReload | cacheOptions.backgroundReload }
|
|
187
|
+
* will still be background reloaded in tests.
|
|
125
188
|
*
|
|
126
189
|
* This behavior can be opted out of by setting this value to `true`.
|
|
127
190
|
*
|
|
@@ -130,7 +193,7 @@ export type PolicyConfig = {
|
|
|
130
193
|
/**
|
|
131
194
|
* In addition to the simple time-based expiration strategy, CachePolicy
|
|
132
195
|
* supports various common server-supplied expiration strategies via
|
|
133
|
-
* headers, as well as custom expiration strategies via the
|
|
196
|
+
* headers, as well as custom expiration strategies via the {@link PolicyConfigConstraints.isExpired | isExpired}
|
|
134
197
|
* function.
|
|
135
198
|
*
|
|
136
199
|
* Requests will be validated for expiration against these constraints.
|
|
@@ -157,118 +220,82 @@ export type PolicyConfig = {
|
|
|
157
220
|
* - ↳ (if null) Cache-Control header
|
|
158
221
|
* - ↳ (if null) Expires header
|
|
159
222
|
*
|
|
223
|
+
* See {@link PolicyConfigConstraints} for configuration options.
|
|
160
224
|
*/
|
|
161
|
-
constraints?:
|
|
162
|
-
|
|
163
|
-
* Headers that should be checked for expiration.
|
|
164
|
-
*
|
|
165
|
-
*/
|
|
166
|
-
headers?: {
|
|
167
|
-
/**
|
|
168
|
-
* Whether the `Cache-Control` header should be checked for expiration.
|
|
169
|
-
* If `true`, then the `max-age` and `s-maxage` directives are used alongside
|
|
170
|
-
* the `Age` and `Date` headers to determine if the expiration time has passed.
|
|
171
|
-
*
|
|
172
|
-
* Other directives are ignored.
|
|
173
|
-
*
|
|
174
|
-
* 'Cache-Control' will take precedence over 'Expires' if both are present
|
|
175
|
-
* and both configured to be checked.
|
|
176
|
-
*
|
|
177
|
-
*/
|
|
178
|
-
"Cache-Control"?: boolean;
|
|
179
|
-
/**
|
|
180
|
-
* Whether the `Expires` header should be checked for expiration.
|
|
181
|
-
*
|
|
182
|
-
* If `true`, then the `Expires` header is used to caclulate the expiration time
|
|
183
|
-
* and determine if the expiration time has passed.
|
|
184
|
-
*
|
|
185
|
-
* 'Cache-Control' will take precedence over 'Expires' if both are present.
|
|
186
|
-
*
|
|
187
|
-
*/
|
|
188
|
-
Expires?: boolean;
|
|
189
|
-
/**
|
|
190
|
-
* Whether the `X-WarpDrive-Expires` header should be checked for expiration.
|
|
191
|
-
*
|
|
192
|
-
* If `true`, then the `X-WarpDrive-Expires` header is used to caclulate the expiration time
|
|
193
|
-
* and determine if the expiration time has passed.
|
|
194
|
-
*
|
|
195
|
-
* This header will take precedence over 'Cache-Control' and 'Expires' if all three are present.
|
|
196
|
-
*
|
|
197
|
-
* The header's value should be a [UTC date string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString).
|
|
198
|
-
*
|
|
199
|
-
*/
|
|
200
|
-
"X-WarpDrive-Expires"?: boolean;
|
|
201
|
-
};
|
|
202
|
-
/**
|
|
203
|
-
* A function that should be called to determine if the request is expired.
|
|
204
|
-
*
|
|
205
|
-
* If present, this function will be called with the request and should return
|
|
206
|
-
* `true` if the request is expired, `false` if it is not expired, and
|
|
207
|
-
* `null` if the expiration status is unknown.
|
|
208
|
-
*
|
|
209
|
-
* If the function does not return `null`,
|
|
210
|
-
*
|
|
211
|
-
*/
|
|
212
|
-
isExpired?: (request: StructuredDocument<ResourceDocument>) => boolean | null;
|
|
213
|
-
};
|
|
214
|
-
};
|
|
225
|
+
constraints?: PolicyConfigConstraints;
|
|
226
|
+
}
|
|
215
227
|
/**
|
|
216
|
-
* A basic CachePolicy that can be added to the Store service.
|
|
217
|
-
*
|
|
218
|
-
* Determines staleness based on time since the request was last received from the API
|
|
219
|
-
* using the `date` header.
|
|
228
|
+
* A basic {@link CachePolicy} that can be added to the Store service.
|
|
220
229
|
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* In order expiration is determined by:
|
|
230
|
+
* ```ts [app/services/store.ts]
|
|
231
|
+
* import { Store } from '@warp-drive/core';
|
|
232
|
+
* import { DefaultCachePolicy } from '@warp-drive/core/store'; // [!code focus]
|
|
225
233
|
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
234
|
+
* export default class AppStore extends Store {
|
|
235
|
+
* lifetimes = new DefaultCachePolicy({ // [!code focus:5]
|
|
236
|
+
* apiCacheSoftExpires: 30_000,
|
|
237
|
+
* apiCacheHardExpires: 60_000,
|
|
238
|
+
* // ... Other PolicyConfig Settings ... //
|
|
239
|
+
* });
|
|
240
|
+
* }
|
|
241
|
+
* ```
|
|
232
242
|
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
243
|
+
* :::tip 💡 TIP
|
|
244
|
+
* Date headers do not have millisecond precision, so expiration times should
|
|
245
|
+
* generally be larger than 1000ms.
|
|
246
|
+
* :::
|
|
235
247
|
*
|
|
236
|
-
*
|
|
237
|
-
* with the types that should be invalidated, or its request should specify the ResourceKeys
|
|
238
|
-
* of the records that are being created via `records`. Providing both is valid.
|
|
248
|
+
* See also {@link PolicyConfig} for configuration options.
|
|
239
249
|
*
|
|
240
|
-
*
|
|
241
|
-
* > only requests that had specified `cacheOptions.types` and occurred prior to the
|
|
242
|
-
* > createRecord request will be invalidated. This means that a given request should always
|
|
243
|
-
* > specify the types that would invalidate it to opt into this behavior. Abstracting this
|
|
244
|
-
* > behavior via builders is recommended to ensure consistency.
|
|
250
|
+
* ### The Mechanics
|
|
245
251
|
*
|
|
246
|
-
* This
|
|
247
|
-
*
|
|
252
|
+
* This policy determines staleness based on various configurable constraints falling back to a simple
|
|
253
|
+
* check of the time elapsed since the request was last received from the API using the `date` header
|
|
254
|
+
* from the last response.
|
|
248
255
|
*
|
|
249
|
-
*
|
|
256
|
+
* :::tip 💡 TIP
|
|
257
|
+
* The {@link Fetch} handler provided by `@warp-drive/core` will automatically
|
|
250
258
|
* add the `date` header to responses if it is not present.
|
|
259
|
+
* :::
|
|
251
260
|
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
* > generally be larger than 1000ms.
|
|
261
|
+
* - For manual override of reload see {@link CacheOptions.reload | cacheOptions.reload}
|
|
262
|
+
* - For manual override of background reload see {@link CacheOptions.backgroundReload | cacheOptions.backgroundReload}
|
|
255
263
|
*
|
|
256
|
-
*
|
|
264
|
+
* In order expiration is determined by:
|
|
257
265
|
*
|
|
258
|
-
* ```
|
|
259
|
-
*
|
|
260
|
-
*
|
|
266
|
+
* ```md
|
|
267
|
+
* Is explicitly invalidated by `cacheOptions.reload`
|
|
268
|
+
* ↳ (if falsey) if the request has been explicitly invalidated
|
|
269
|
+
* since the last request (see Automatic Invalidation below)
|
|
270
|
+
* ↳ (if false) (If Active) isExpired function
|
|
271
|
+
* ↳ (if null) (If Active) X-WarpDrive-Expires header
|
|
272
|
+
* ↳ (if null) (If Active) Cache-Control header
|
|
273
|
+
* ↳ (if null) (If Active) Expires header
|
|
274
|
+
* ↳ (if null) Date header + apiCacheHardExpires < current time
|
|
261
275
|
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
* });
|
|
267
|
-
* }
|
|
276
|
+
* -- <if above is false, a background request is issued if> --
|
|
277
|
+
*
|
|
278
|
+
* ↳ is invalidated by `cacheOptions.backgroundReload`
|
|
279
|
+
* ↳ (if falsey) Date header + apiCacheSoftExpires < current time
|
|
268
280
|
* ```
|
|
269
281
|
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
282
|
+
* ### Automatic Invalidation / Entanglement
|
|
283
|
+
*
|
|
284
|
+
* It also invalidates any request with an {@link RequestInfo.op | OpCode} of `"query"`
|
|
285
|
+
* for which {@link CacheOptions.types | cacheOptions.types} was provided
|
|
286
|
+
* when a request with an `OpCode` of `"createRecord"` is successful and also includes
|
|
287
|
+
* a matching type in its own `cacheOptions.types` array.
|
|
288
|
+
|
|
289
|
+
* :::tip 💡 TIP
|
|
290
|
+
* Abstracting this behavior via builders is recommended to ensure consistency.
|
|
291
|
+
* :::
|
|
292
|
+
*
|
|
293
|
+
* ### Testing
|
|
294
|
+
*
|
|
295
|
+
* In Testing environments:
|
|
296
|
+
*
|
|
297
|
+
* - `apiCacheSoftExpires` will always be `false`
|
|
298
|
+
* - `apiCacheHardExpires` will use the `apiCacheSoftExpires` value.
|
|
272
299
|
*
|
|
273
300
|
* This helps reduce flakiness and produce predictably rendered results in test suites.
|
|
274
301
|
*
|
|
@@ -280,16 +307,7 @@ export type PolicyConfig = {
|
|
|
280
307
|
*
|
|
281
308
|
* @public
|
|
282
309
|
*/
|
|
283
|
-
export declare class DefaultCachePolicy {
|
|
284
|
-
config: PolicyConfig;
|
|
285
|
-
_stores: WeakMap<Store, {
|
|
286
|
-
invalidated: Set<RequestKey>;
|
|
287
|
-
types: Map<string, Set<RequestKey>>;
|
|
288
|
-
}>;
|
|
289
|
-
_getStore(store: Store): {
|
|
290
|
-
invalidated: Set<RequestKey>;
|
|
291
|
-
types: Map<string, Set<RequestKey>>;
|
|
292
|
-
};
|
|
310
|
+
export declare class DefaultCachePolicy implements CachePolicy {
|
|
293
311
|
constructor(config: PolicyConfig);
|
|
294
312
|
/**
|
|
295
313
|
* Invalidate a request by its CacheKey for the given store instance.
|
|
@@ -314,7 +332,7 @@ export declare class DefaultCachePolicy {
|
|
|
314
332
|
* of the store.
|
|
315
333
|
*
|
|
316
334
|
* This invalidation is done automatically when using this service
|
|
317
|
-
* for both the CacheHandler and the LegacyNetworkHandler.
|
|
335
|
+
* for both the {@link CacheHandler} and the [NetworkHandler](/api/@warp-drive/legacy/compat/variables/LegacyNetworkHandler).
|
|
318
336
|
*
|
|
319
337
|
* ```ts
|
|
320
338
|
* store.lifetimes.invalidateRequestsForType(store, 'person');
|
|
@@ -328,7 +346,7 @@ export declare class DefaultCachePolicy {
|
|
|
328
346
|
* This is invoked by the CacheHandler for both foreground and background requests
|
|
329
347
|
* once the cache has been updated.
|
|
330
348
|
*
|
|
331
|
-
* Note, this is invoked by the CacheHandler regardless of whether
|
|
349
|
+
* Note, this is invoked by the {@link CacheHandler} regardless of whether
|
|
332
350
|
* the request has a cache-key.
|
|
333
351
|
*
|
|
334
352
|
* This method should not be invoked directly by consumers.
|
|
@@ -340,7 +358,7 @@ export declare class DefaultCachePolicy {
|
|
|
340
358
|
* Invoked to determine if the request may be fulfilled from cache
|
|
341
359
|
* if possible.
|
|
342
360
|
*
|
|
343
|
-
* Note, this is only invoked by the CacheHandler if the request has
|
|
361
|
+
* Note, this is only invoked by the {@link CacheHandler} if the request has
|
|
344
362
|
* a cache-key.
|
|
345
363
|
*
|
|
346
364
|
* If no cache entry is found or the entry is hard expired,
|
|
@@ -355,7 +373,7 @@ export declare class DefaultCachePolicy {
|
|
|
355
373
|
* Invoked if `isHardExpired` is false to determine if the request
|
|
356
374
|
* should be update behind the scenes if cache data is already available.
|
|
357
375
|
*
|
|
358
|
-
* Note, this is only invoked by the CacheHandler if the request has
|
|
376
|
+
* Note, this is only invoked by the {@link CacheHandler} if the request has
|
|
359
377
|
* a cache-key.
|
|
360
378
|
*
|
|
361
379
|
* If true, the request will be fulfilled from cache while a backgrounded
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RequestKey, ResourceKey } from "../../../types/identifier.js";
|
|
2
|
+
import type { SchemaService } from "../../../types/schema/schema-service.js";
|
|
2
3
|
import type { CacheCapabilitiesManager as StoreWrapper } from "../../-types/q/cache-capabilities-manager.js";
|
|
3
|
-
import type { SchemaService } from "../../-types/q/schema-service.js";
|
|
4
4
|
import type { PrivateStore, Store } from "../store-service.js";
|
|
5
5
|
import type { CacheKeyManager } from "./cache-key-manager.js";
|
|
6
6
|
import type { NotificationType } from "./notification-manager.js";
|