@warp-drive/core 5.7.0-alpha.3 → 5.7.0-alpha.31
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/declarations/graph/-private/-diff.d.ts +7 -20
- package/declarations/graph/-private/-edge-definition.d.ts +3 -12
- package/declarations/graph/-private/-state.d.ts +2 -2
- package/declarations/graph/-private/-utils.d.ts +5 -5
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +3 -3
- package/declarations/graph/-private/edges/collection.d.ts +10 -10
- package/declarations/graph/-private/edges/implicit.d.ts +5 -5
- package/declarations/graph/-private/edges/resource.d.ts +6 -7
- package/declarations/graph/-private/graph.d.ts +17 -15
- package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -4
- package/declarations/graph/-private/operations/update-relationship.d.ts +3 -3
- package/declarations/index.d.ts +1 -1
- package/declarations/reactive/-private/default-mode.d.ts +73 -0
- package/declarations/reactive/-private/document.d.ts +11 -21
- package/declarations/reactive/-private/fields/get-field-key.d.ts +8 -0
- package/declarations/reactive/-private/fields/managed-array.d.ts +7 -10
- package/declarations/reactive/-private/fields/managed-object.d.ts +7 -9
- package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
- package/declarations/reactive/-private/hooks.d.ts +2 -2
- package/declarations/reactive/-private/kind/alias-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/array-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/attribute-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/belongs-to-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/collection-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/derived-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/generic-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/has-many-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/hash-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/identity-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/local-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/object-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/resource-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/schema-array-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/schema-object-field.d.ts +4 -0
- package/declarations/reactive/-private/record.d.ts +44 -33
- package/declarations/reactive/-private/schema.d.ts +16 -72
- package/declarations/reactive/-private/symbols.d.ts +2 -7
- package/declarations/reactive/-private.d.ts +1 -1
- package/declarations/reactive.d.ts +278 -1
- package/declarations/request/-private/context.d.ts +3 -3
- package/declarations/request/-private/fetch.d.ts +2 -0
- package/declarations/request/-private/manager.d.ts +24 -28
- package/declarations/request/-private/types.d.ts +22 -23
- package/declarations/request/-private/utils.d.ts +44 -2
- package/declarations/store/-private/cache-handler/handler.d.ts +2 -8
- package/declarations/store/-private/cache-handler/types.d.ts +10 -10
- package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
- package/declarations/store/-private/caches/instance-cache.d.ts +21 -19
- package/declarations/store/-private/debug/utils.d.ts +1 -0
- package/declarations/store/-private/default-cache-policy.d.ts +25 -38
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +24 -15
- package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +38 -52
- package/declarations/store/-private/managers/cache-manager.d.ts +47 -95
- package/declarations/store/-private/managers/notification-manager.d.ts +30 -42
- package/declarations/store/-private/managers/record-array-manager.d.ts +45 -41
- package/declarations/store/-private/network/request-cache.d.ts +21 -21
- package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +3 -41
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +14 -29
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +24 -3
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +129 -22
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -123
- package/declarations/store/-private/record-arrays/-utils.d.ts +80 -0
- package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +81 -0
- package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +133 -0
- package/declarations/store/-private/record-arrays/legacy-query.d.ts +81 -0
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +1 -124
- package/declarations/store/-private/record-arrays/resource-array.d.ts +75 -0
- package/declarations/store/-private/store-service.d.ts +156 -101
- package/declarations/store/-private.d.ts +12 -9
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
- package/declarations/store/-types/q/identifier.d.ts +9 -6
- package/declarations/store/-types/q/record-instance.d.ts +0 -1
- package/declarations/store/-types/q/schema-service.d.ts +28 -40
- package/declarations/store/-types/q/store.d.ts +6 -7
- package/declarations/store/deprecated/-private.d.ts +12 -23
- package/declarations/store/deprecated/store.d.ts +11 -12
- package/declarations/types/-private.d.ts +1 -1
- package/declarations/types/cache/aliases.d.ts +2 -2
- package/declarations/types/cache/change.d.ts +2 -2
- package/declarations/types/cache/mutations.d.ts +13 -13
- package/declarations/types/cache/operations.d.ts +115 -32
- package/declarations/types/cache/relationship.d.ts +4 -4
- package/declarations/types/cache.d.ts +51 -113
- package/declarations/types/graph.d.ts +12 -12
- package/declarations/types/identifier.d.ts +52 -76
- package/declarations/types/params.d.ts +2 -3
- package/declarations/types/request.d.ts +69 -42
- package/declarations/types/schema/concepts.d.ts +2 -2
- package/declarations/types/schema/fields.d.ts +378 -14
- package/declarations/types/spec/document.d.ts +6 -6
- package/declarations/types/spec/json-api-raw.d.ts +6 -8
- package/declarations/utils/string.d.ts +2 -2
- package/dist/{configure-B48bFHOl.js → configure-C3x8YXzL.js} +5 -5
- package/dist/configure.js +1 -1
- package/dist/{context-COmAnXUQ.js → context-Bh-MA_tH.js} +40 -6
- package/dist/graph/-private.js +137 -144
- package/dist/index.js +25 -14
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +203 -1413
- package/dist/{request-state-CejVJgdj.js → request-state-DGyt5EV8.js} +5674 -2812
- package/dist/request.js +1 -1
- package/dist/store/-private.js +2 -3
- package/dist/store.js +32 -44
- package/dist/{symbols-SIstXMLI.js → symbols-sql1_mdx.js} +3 -8
- package/dist/types/-private.js +1 -1
- package/dist/types/identifier.js +19 -45
- package/dist/types/request.js +45 -3
- package/dist/types/schema/fields.js +23 -2
- package/dist/utils/string.js +2 -2
- package/package.json +10 -10
- package/declarations/reactive/-private/fields/compute.d.ts +0 -43
- package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
- package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
- package/dist/handler-D2jjnIA-.js +0 -339
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RequestKey } from "../../../types/identifier.js";
|
|
2
2
|
import type { ImmutableCreateRequestOptions, ImmutableDeleteRequestOptions, ImmutableRequestInfo, ImmutableUpdateRequestOptions, StructuredDataDocument } from "../../../types/request.js";
|
|
3
3
|
import type { ResourceDataDocument, ResourceErrorDocument } from "../../../types/spec/document.js";
|
|
4
4
|
import type { ApiError } from "../../../types/spec/error.js";
|
|
5
5
|
import type { Store } from "../store-service.js";
|
|
6
6
|
export declare const MUTATION_OPS: Set<string>;
|
|
7
|
-
export declare function calcShouldFetch(store: Store, request: ImmutableRequestInfo, hasCachedValue: boolean, identifier:
|
|
8
|
-
export declare function calcShouldBackgroundFetch(store: Store, request: ImmutableRequestInfo, willFetch: boolean, identifier:
|
|
7
|
+
export declare function calcShouldFetch(store: Store, request: ImmutableRequestInfo, hasCachedValue: boolean, identifier: RequestKey | null): boolean;
|
|
8
|
+
export declare function calcShouldBackgroundFetch(store: Store, request: ImmutableRequestInfo, willFetch: boolean, identifier: RequestKey | null): boolean;
|
|
9
9
|
export declare function isMutation(request: Partial<ImmutableRequestInfo>): request is ImmutableUpdateRequestOptions | ImmutableCreateRequestOptions | ImmutableDeleteRequestOptions;
|
|
10
10
|
export declare function isCacheAffecting<T>(document: StructuredDataDocument<T>): boolean;
|
|
11
11
|
export declare function isAggregateError(error: Error & {
|
|
@@ -21,7 +21,7 @@ export type RobustError = Error & {
|
|
|
21
21
|
// TODO @runspired, consider if we should deep freeze errors (potentially only in debug) vs cloning them
|
|
22
22
|
export declare function cloneError(error: RobustError): RobustError;
|
|
23
23
|
export declare function isErrorDocument(document: ResourceDataDocument | ResourceErrorDocument): document is ResourceErrorDocument;
|
|
24
|
-
export declare function getPriority(identifier:
|
|
24
|
+
export declare function getPriority(identifier: RequestKey | null, deduped: Map<RequestKey, {
|
|
25
25
|
priority: {
|
|
26
26
|
blocking: boolean;
|
|
27
27
|
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { ReactiveDocument } from "../../../reactive/-private/document.js";
|
|
2
2
|
import type { Cache } from "../../../types/cache.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { RequestKey, ResourceKey } from "../../../types/identifier.js";
|
|
4
4
|
import type { TypedRecordInstance, TypeFromInstance } from "../../../types/record.js";
|
|
5
5
|
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 peekRecordIdentifier(record: OpaqueRecordInstance):
|
|
9
|
+
export declare function peekRecordIdentifier(record: OpaqueRecordInstance): ResourceKey | undefined;
|
|
10
10
|
/**
|
|
11
|
-
Retrieves the unique referentially-stable [RecordIdentifier](/ember-data/release/classes/
|
|
11
|
+
Retrieves the unique referentially-stable [RecordIdentifier](/ember-data/release/classes/ResourceKey)
|
|
12
12
|
assigned to the given record instance.
|
|
13
13
|
|
|
14
14
|
```js
|
|
15
15
|
import { recordIdentifierFor } from "@ember-data/store";
|
|
16
16
|
// ... gain access to a record, for instance with peekRecord or findRecord
|
|
17
17
|
const record = store.peekRecord("user", "1");
|
|
18
|
-
// get the identifier for the record (see docs for
|
|
18
|
+
// get the identifier for the record (see docs for ResourceKey)
|
|
19
19
|
const identifier = recordIdentifierFor(record);
|
|
20
20
|
// access the identifier's properties.
|
|
21
21
|
const { id, type, lid } = identifier;
|
|
@@ -23,20 +23,21 @@ const { id, type, lid } = identifier;
|
|
|
23
23
|
|
|
24
24
|
@public
|
|
25
25
|
@param {Object} record a record instance previously obstained from the store.
|
|
26
|
-
@return {
|
|
26
|
+
@return {ResourceKey}
|
|
27
27
|
*/
|
|
28
|
-
export declare function recordIdentifierFor<T extends TypedRecordInstance>(record: T):
|
|
29
|
-
export declare function recordIdentifierFor(record: OpaqueRecordInstance):
|
|
30
|
-
export declare function setRecordIdentifier(record: OpaqueRecordInstance, identifier:
|
|
28
|
+
export declare function recordIdentifierFor<T extends TypedRecordInstance>(record: T): ResourceKey<TypeFromInstance<T>>;
|
|
29
|
+
export declare function recordIdentifierFor(record: OpaqueRecordInstance): ResourceKey;
|
|
30
|
+
export declare function setRecordIdentifier(record: OpaqueRecordInstance, identifier: ResourceKey): void;
|
|
31
|
+
export declare function removeRecordIdentifier(record: OpaqueRecordInstance): void;
|
|
31
32
|
export declare const StoreMap: Map<unknown, Store>;
|
|
32
33
|
/**
|
|
33
34
|
* We may eventually make this public, but its likely better for this to be killed off
|
|
34
|
-
* @
|
|
35
|
+
* @private
|
|
35
36
|
*/
|
|
36
|
-
export declare function storeFor(record: OpaqueRecordInstance): Store |
|
|
37
|
+
export declare function storeFor(record: OpaqueRecordInstance, ignoreMissing: boolean): Store | null;
|
|
37
38
|
export type Caches = {
|
|
38
|
-
record: Map<
|
|
39
|
-
document: Map<
|
|
39
|
+
record: Map<ResourceKey, OpaqueRecordInstance>;
|
|
40
|
+
document: Map<RequestKey, ReactiveDocument<OpaqueRecordInstance | OpaqueRecordInstance[] | null | undefined>>;
|
|
40
41
|
};
|
|
41
42
|
export declare class InstanceCache {
|
|
42
43
|
store: Store;
|
|
@@ -45,14 +46,15 @@ export declare class InstanceCache {
|
|
|
45
46
|
__cacheManager: CacheManager;
|
|
46
47
|
__instances: Caches;
|
|
47
48
|
constructor(store: Store);
|
|
48
|
-
peek(identifier:
|
|
49
|
-
getDocument<T>(identifier:
|
|
50
|
-
getRecord(identifier:
|
|
51
|
-
recordIsLoaded(identifier:
|
|
52
|
-
disconnect(identifier:
|
|
53
|
-
unloadRecord(identifier:
|
|
49
|
+
peek(identifier: ResourceKey): Cache | OpaqueRecordInstance | undefined;
|
|
50
|
+
getDocument<T>(identifier: RequestKey): ReactiveDocument<T>;
|
|
51
|
+
getRecord(identifier: ResourceKey): OpaqueRecordInstance;
|
|
52
|
+
recordIsLoaded(identifier: ResourceKey, filterDeleted?: boolean): boolean;
|
|
53
|
+
disconnect(identifier: ResourceKey): void;
|
|
54
|
+
unloadRecord(identifier: ResourceKey): void;
|
|
54
55
|
clear(type?: string): void;
|
|
55
56
|
// TODO this should move into something coordinating operations
|
|
56
|
-
setRecordId(identifier:
|
|
57
|
+
setRecordId(identifier: ResourceKey, id: string): void;
|
|
57
58
|
}
|
|
59
|
+
export declare function getNewRecord(instances: InstanceCache, identifier: ResourceKey, properties: CreateRecordProperties): OpaqueRecordInstance;
|
|
58
60
|
export declare function _clearCaches(): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare function logGroup(scope: "cache", prefix: string, type: string, lid: string, bucket: string, key: string): void;
|
|
2
2
|
export declare function logGroup(scope: "reactive-ui", prefix: string, type: string, lid: string, bucket: string, key: ""): void;
|
|
3
3
|
export declare function logGroup(scope: "notify", prefix: string, type: string, lid: string, bucket: string, key: string): void;
|
|
4
|
+
export declare function log(scope: "request", prefix: string, type: string, lid: string, bucket: string, key: string): void;
|
|
4
5
|
export declare function log(scope: "cache", prefix: string, type: string, lid: string, bucket: string, key: string): void;
|
|
5
6
|
export declare function log(scope: "reactive-ui", prefix: string, type: string, lid: string, bucket: string, key: ""): void;
|
|
6
7
|
export declare function log(scope: "notify", prefix: string, type: string, lid: string, bucket: string, key: string): void;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import type { Cache } from "@warp-drive/core/types/cache";
|
|
2
|
-
import type {
|
|
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
5
|
type UnsubscribeToken = object;
|
|
6
6
|
type CacheOperation = "added" | "removed" | "updated" | "state";
|
|
7
7
|
type DocumentCacheOperation = "invalidated" | "added" | "removed" | "updated" | "state";
|
|
8
8
|
export interface NotificationCallback {
|
|
9
|
-
(
|
|
10
|
-
(
|
|
9
|
+
(resourceKey: ResourceKey, notificationType: "attributes" | "relationships", key?: string): void;
|
|
10
|
+
(resourceKey: ResourceKey, notificationType: "errors" | "meta" | "identity" | "state"): void;
|
|
11
11
|
}
|
|
12
12
|
interface ResourceOperationCallback {
|
|
13
13
|
// resource updates
|
|
14
|
-
(
|
|
14
|
+
(resourceKey: ResourceKey, notificationType: CacheOperation): void;
|
|
15
15
|
}
|
|
16
16
|
interface DocumentOperationCallback {
|
|
17
17
|
// document updates
|
|
18
|
-
(
|
|
18
|
+
(cacheKey: RequestKey, notificationType: DocumentCacheOperation): void;
|
|
19
19
|
}
|
|
20
20
|
type NotificationManager = {
|
|
21
|
-
subscribe(
|
|
22
|
-
subscribe(
|
|
23
|
-
subscribe(
|
|
24
|
-
notify(
|
|
25
|
-
notify(
|
|
26
|
-
notify(
|
|
27
|
-
notify(
|
|
21
|
+
subscribe(resourceKey: ResourceKey, callback: NotificationCallback): UnsubscribeToken;
|
|
22
|
+
subscribe(cacheKey: "resource", callback: ResourceOperationCallback): UnsubscribeToken;
|
|
23
|
+
subscribe(cacheKey: "document" | RequestKey, callback: DocumentOperationCallback): UnsubscribeToken;
|
|
24
|
+
notify(cacheKey: ResourceKey, value: "attributes" | "relationships", key?: string): boolean;
|
|
25
|
+
notify(cacheKey: ResourceKey, value: "errors" | "meta" | "identity" | "state"): boolean;
|
|
26
|
+
notify(cacheKey: ResourceKey, value: CacheOperation): boolean;
|
|
27
|
+
notify(cacheKey: RequestKey, value: DocumentCacheOperation): boolean;
|
|
28
28
|
};
|
|
29
29
|
type Store = {
|
|
30
30
|
cache: Cache;
|
|
@@ -236,7 +236,7 @@ export type PolicyConfig = {
|
|
|
236
236
|
* request for that type is successful.
|
|
237
237
|
*
|
|
238
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
|
|
239
|
+
* with the types that should be invalidated, or its request should specify the ResourceKeys
|
|
240
240
|
* of the records that are being created via `records`. Providing both is valid.
|
|
241
241
|
*
|
|
242
242
|
* > [!NOTE]
|
|
@@ -285,30 +285,28 @@ export type PolicyConfig = {
|
|
|
285
285
|
export declare class DefaultCachePolicy {
|
|
286
286
|
config: PolicyConfig;
|
|
287
287
|
_stores: WeakMap<Store, {
|
|
288
|
-
invalidated: Set<
|
|
289
|
-
types: Map<string, Set<
|
|
288
|
+
invalidated: Set<RequestKey>;
|
|
289
|
+
types: Map<string, Set<RequestKey>>;
|
|
290
290
|
}>;
|
|
291
291
|
_getStore(store: Store): {
|
|
292
|
-
invalidated: Set<
|
|
293
|
-
types: Map<string, Set<
|
|
292
|
+
invalidated: Set<RequestKey>;
|
|
293
|
+
types: Map<string, Set<RequestKey>>;
|
|
294
294
|
};
|
|
295
295
|
constructor(config: PolicyConfig);
|
|
296
296
|
/**
|
|
297
|
-
* Invalidate a request by its
|
|
297
|
+
* Invalidate a request by its CacheKey for the given store instance.
|
|
298
298
|
*
|
|
299
299
|
* While the store argument may seem redundant, the CachePolicy
|
|
300
300
|
* is designed to be shared across multiple stores / forks
|
|
301
301
|
* of the store.
|
|
302
302
|
*
|
|
303
303
|
* ```ts
|
|
304
|
-
* store.lifetimes.invalidateRequest(store,
|
|
304
|
+
* store.lifetimes.invalidateRequest(store, cacheKey);
|
|
305
305
|
* ```
|
|
306
306
|
*
|
|
307
307
|
* @public
|
|
308
|
-
* @param {StableDocumentIdentifier} identifier
|
|
309
|
-
* @param {Store} store
|
|
310
308
|
*/
|
|
311
|
-
invalidateRequest(
|
|
309
|
+
invalidateRequest(cacheKey: RequestKey, store: Store): void;
|
|
312
310
|
/**
|
|
313
311
|
* Invalidate all requests associated to a specific type
|
|
314
312
|
* for a given store instance.
|
|
@@ -325,8 +323,6 @@ export declare class DefaultCachePolicy {
|
|
|
325
323
|
* ```
|
|
326
324
|
*
|
|
327
325
|
* @public
|
|
328
|
-
* @param {String} type
|
|
329
|
-
* @param {Store} store
|
|
330
326
|
*/
|
|
331
327
|
invalidateRequestsForType(type: string, store: Store): void;
|
|
332
328
|
/**
|
|
@@ -340,13 +336,8 @@ export declare class DefaultCachePolicy {
|
|
|
340
336
|
* This method should not be invoked directly by consumers.
|
|
341
337
|
*
|
|
342
338
|
* @public
|
|
343
|
-
* @param {ImmutableRequestInfo} request
|
|
344
|
-
* @param {ImmutableResponse} response
|
|
345
|
-
* @param {Store} store
|
|
346
|
-
* @param {StableDocumentIdentifier | null} identifier
|
|
347
|
-
* @return {void}
|
|
348
339
|
*/
|
|
349
|
-
didRequest(request: ImmutableRequestInfo, response: Response | ResponseInfo | null,
|
|
340
|
+
didRequest(request: ImmutableRequestInfo, response: Response | ResponseInfo | null, cacheKey: RequestKey | null, store: Store): void;
|
|
350
341
|
/**
|
|
351
342
|
* Invoked to determine if the request may be fulfilled from cache
|
|
352
343
|
* if possible.
|
|
@@ -359,11 +350,9 @@ export declare class DefaultCachePolicy {
|
|
|
359
350
|
* and the cache will be updated before returning the response.
|
|
360
351
|
*
|
|
361
352
|
* @public
|
|
362
|
-
* @
|
|
363
|
-
* @param {Store} store
|
|
364
|
-
* @return {Boolean} true if the request is considered hard expired
|
|
353
|
+
* @return true if the request is considered hard expired
|
|
365
354
|
*/
|
|
366
|
-
isHardExpired(
|
|
355
|
+
isHardExpired(cacheKey: RequestKey, store: Store): boolean;
|
|
367
356
|
/**
|
|
368
357
|
* Invoked if `isHardExpired` is false to determine if the request
|
|
369
358
|
* should be update behind the scenes if cache data is already available.
|
|
@@ -375,10 +364,8 @@ export declare class DefaultCachePolicy {
|
|
|
375
364
|
* request is made to update the cache via the configured request handlers.
|
|
376
365
|
*
|
|
377
366
|
* @public
|
|
378
|
-
* @
|
|
379
|
-
* @param {Store} store
|
|
380
|
-
* @return {Boolean} true if the request is considered soft expired
|
|
367
|
+
* @return true if the request is considered soft expired
|
|
381
368
|
*/
|
|
382
|
-
isSoftExpired(
|
|
369
|
+
isSoftExpired(cacheKey: RequestKey, store: Store): boolean;
|
|
383
370
|
}
|
|
384
371
|
export {};
|
|
@@ -1,25 +1,34 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RequestKey, ResourceKey } from "../../../types/identifier.js";
|
|
2
2
|
import type { CacheCapabilitiesManager as StoreWrapper } from "../../-types/q/cache-capabilities-manager.js";
|
|
3
3
|
import type { SchemaService } from "../../-types/q/schema-service.js";
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
4
|
+
import type { PrivateStore, Store } from "../store-service.js";
|
|
5
|
+
import type { CacheKeyManager } from "./cache-key-manager.js";
|
|
6
6
|
import type { NotificationType } from "./notification-manager.js";
|
|
7
7
|
export interface CacheCapabilitiesManager {
|
|
8
|
+
/** @deprecated - use {@link CacheCapabilitiesManager.schema} */
|
|
8
9
|
getSchemaDefinitionService(): SchemaService;
|
|
9
10
|
}
|
|
10
11
|
export declare class CacheCapabilitiesManager implements StoreWrapper {
|
|
11
|
-
_willNotify: boolean;
|
|
12
|
-
_pendingNotifies: Map<StableRecordIdentifier, Set<string>>;
|
|
13
|
-
_store: Store;
|
|
14
12
|
constructor(_store: Store);
|
|
15
|
-
get
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
notifyChange(identifier:
|
|
19
|
-
notifyChange(identifier:
|
|
20
|
-
notifyChange(identifier:
|
|
13
|
+
get cacheKeyManager(): CacheKeyManager;
|
|
14
|
+
/** @deprecated use {@link CacheCapabilitiesManager.cacheKeyManager} */
|
|
15
|
+
get identifierCache(): CacheKeyManager;
|
|
16
|
+
notifyChange(identifier: ResourceKey, namespace: "added" | "removed", key: null): void;
|
|
17
|
+
notifyChange(identifier: RequestKey, namespace: "added" | "updated" | "removed", key: null): void;
|
|
18
|
+
notifyChange(identifier: ResourceKey, namespace: NotificationType, key: string | null): void;
|
|
21
19
|
get schema(): SchemaService;
|
|
22
|
-
setRecordId(identifier:
|
|
23
|
-
hasRecord(identifier:
|
|
24
|
-
disconnectRecord(identifier:
|
|
20
|
+
setRecordId(identifier: ResourceKey, id: string): void;
|
|
21
|
+
hasRecord(identifier: ResourceKey): boolean;
|
|
22
|
+
disconnectRecord(identifier: ResourceKey): void;
|
|
25
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* This type exists for internal use only for
|
|
26
|
+
* where intimate contracts still exist either for
|
|
27
|
+
* the Test Suite or for Legacy code.
|
|
28
|
+
*
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
export interface PrivateCacheCapabilitiesManager extends CacheCapabilitiesManager {
|
|
32
|
+
_store: PrivateStore;
|
|
33
|
+
}
|
|
34
|
+
export declare function assertPrivateCapabilities(manager: unknown): asserts manager is PrivateCacheCapabilitiesManager;
|
package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts}
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type PersistedResourceKey, type RequestKey, type ResourceKey } from "../../../types/identifier.js";
|
|
2
2
|
import type { ImmutableRequestInfo } from "../../../types/request.js";
|
|
3
3
|
import type { ExistingResourceIdentifierObject, ResourceIdentifierObject } from "../../../types/spec/json-api-raw.js";
|
|
4
4
|
import type { ForgetMethod, GenerationMethod, KeyInfo, KeyInfoMethod, ResetMethod, UpdateMethod } from "../../-types/q/identifier.js";
|
|
5
5
|
type TypeFromIdentifier<T> = T extends {
|
|
6
6
|
type: infer U;
|
|
7
7
|
} ? U : string;
|
|
8
|
-
type NarrowIdentifierIfPossible<T> = T extends ExistingResourceIdentifierObject ?
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
8
|
+
type NarrowIdentifierIfPossible<T> = T extends ExistingResourceIdentifierObject ? PersistedResourceKey<TypeFromIdentifier<T>> : ResourceKey;
|
|
9
|
+
export declare function isResourceKey(identifier: unknown): identifier is ResourceKey;
|
|
10
|
+
export declare function isRequestKey(identifier: unknown): identifier is RequestKey;
|
|
11
11
|
interface KeyOptions {
|
|
12
12
|
lid: IdentifierMap;
|
|
13
13
|
id: IdentifierMap;
|
|
@@ -15,16 +15,16 @@ interface KeyOptions {
|
|
|
15
15
|
type TypeMap = {
|
|
16
16
|
[key: string]: KeyOptions;
|
|
17
17
|
};
|
|
18
|
-
// type IdentifierTypeLookup = { all: Set<
|
|
18
|
+
// type IdentifierTypeLookup = { all: Set<ResourceKey>; id: Map<string, ResourceKey> };
|
|
19
19
|
// type IdentifiersByType = Map<string, IdentifierTypeLookup>;
|
|
20
|
-
type IdentifierMap = Map<string,
|
|
20
|
+
type IdentifierMap = Map<string, ResourceKey>;
|
|
21
21
|
type StableCache = {
|
|
22
22
|
resources: IdentifierMap;
|
|
23
|
-
documents: Map<string,
|
|
23
|
+
documents: Map<string, RequestKey>;
|
|
24
24
|
resourcesByType: TypeMap;
|
|
25
25
|
polymorphicLidBackMap: Map<string, string[]>;
|
|
26
26
|
};
|
|
27
|
-
export type MergeMethod = (targetIdentifier:
|
|
27
|
+
export type MergeMethod = (targetIdentifier: ResourceKey, matchedIdentifier: ResourceKey, resourceData: unknown) => ResourceKey;
|
|
28
28
|
/**
|
|
29
29
|
Configures how unique identifier lid strings are generated by @ember-data/store.
|
|
30
30
|
|
|
@@ -163,10 +163,10 @@ to the application instance, you may not need to implement the `resetMethod`.
|
|
|
163
163
|
export declare function setIdentifierResetMethod(method: ResetMethod | null): void;
|
|
164
164
|
/**
|
|
165
165
|
Configure a callback for when the identifier cache is generating a new
|
|
166
|
-
|
|
166
|
+
ResourceKey for a resource.
|
|
167
167
|
|
|
168
168
|
This method controls the `type` and `id` that will be assigned to the
|
|
169
|
-
`
|
|
169
|
+
`ResourceKey` that is created.
|
|
170
170
|
|
|
171
171
|
This configuration MUST occur prior to the store instance being created.
|
|
172
172
|
|
|
@@ -178,7 +178,7 @@ import { setKeyInfoForResource } from '@warp-drive/core';
|
|
|
178
178
|
*/
|
|
179
179
|
export declare function setKeyInfoForResource(method: KeyInfoMethod | null): void;
|
|
180
180
|
/**
|
|
181
|
-
* Each instance of {@link Store} receives a unique instance of a
|
|
181
|
+
* Each instance of {@link Store} receives a unique instance of a CacheKeyManager.
|
|
182
182
|
*
|
|
183
183
|
* This cache is responsible for assigning or retrieving the unique identify
|
|
184
184
|
* for arbitrary resource data encountered by the store. Data representing
|
|
@@ -190,53 +190,23 @@ export declare function setKeyInfoForResource(method: KeyInfoMethod | null): voi
|
|
|
190
190
|
* @hideconstructor
|
|
191
191
|
* @public
|
|
192
192
|
*/
|
|
193
|
-
export declare class
|
|
194
|
-
/** @internal */
|
|
195
|
-
_cache: StableCache;
|
|
196
|
-
private _generate;
|
|
197
|
-
private _update;
|
|
198
|
-
private _forget;
|
|
199
|
-
private _reset;
|
|
200
|
-
private _merge;
|
|
201
|
-
private _keyInfoForResource;
|
|
202
|
-
private _id;
|
|
193
|
+
export declare class CacheKeyManager {
|
|
203
194
|
constructor();
|
|
204
195
|
/**
|
|
205
|
-
* Internal hook to allow management of merge conflicts with identifiers.
|
|
206
|
-
*
|
|
207
|
-
* we allow late binding of this private internal merge so that
|
|
208
|
-
* the cache can insert itself here to handle elimination of duplicates
|
|
209
|
-
*
|
|
210
|
-
* @private
|
|
211
|
-
*/
|
|
212
|
-
__configureMerge(method: MergeMethod | null): void;
|
|
213
|
-
/** @internal */
|
|
214
|
-
upgradeIdentifier(resource: {
|
|
215
|
-
type: string;
|
|
216
|
-
id: string | null;
|
|
217
|
-
lid?: string;
|
|
218
|
-
}): StableRecordIdentifier;
|
|
219
|
-
/**
|
|
220
|
-
* @private
|
|
221
|
-
*/
|
|
222
|
-
private _getRecordIdentifier;
|
|
223
|
-
private _getRecordIdentifier;
|
|
224
|
-
private _getRecordIdentifier;
|
|
225
|
-
/**
|
|
226
196
|
* allows us to peek without generating when needed
|
|
227
197
|
* useful for the "create" case when we need to see if
|
|
228
198
|
* we are accidentally overwritting something
|
|
229
199
|
*
|
|
230
200
|
* @private
|
|
231
201
|
*/
|
|
232
|
-
peekRecordIdentifier(resource: ResourceIdentifierObject
|
|
202
|
+
peekRecordIdentifier(resource: ResourceIdentifierObject): ResourceKey | undefined;
|
|
233
203
|
/**
|
|
234
204
|
Returns the DocumentIdentifier for the given Request, creates one if it does not yet exist.
|
|
235
205
|
Returns `null` if the request does not have a `cacheKey` or `url`.
|
|
236
206
|
|
|
237
207
|
@public
|
|
238
208
|
*/
|
|
239
|
-
getOrCreateDocumentIdentifier(request: ImmutableRequestInfo):
|
|
209
|
+
getOrCreateDocumentIdentifier(request: ImmutableRequestInfo): RequestKey | null;
|
|
240
210
|
/**
|
|
241
211
|
Returns the Identifier for the given Resource, creates one if it does not yet exist.
|
|
242
212
|
|
|
@@ -263,7 +233,8 @@ export declare class IdentifierCache {
|
|
|
263
233
|
createIdentifierForNewRecord(data: {
|
|
264
234
|
type: string;
|
|
265
235
|
id?: string | null;
|
|
266
|
-
|
|
236
|
+
lid?: string;
|
|
237
|
+
}): ResourceKey;
|
|
267
238
|
/**
|
|
268
239
|
Provides the opportunity to update secondary lookup tables for existing identifiers
|
|
269
240
|
Called after an identifier created with `createIdentifierForNewRecord` has been
|
|
@@ -282,11 +253,8 @@ export declare class IdentifierCache {
|
|
|
282
253
|
|
|
283
254
|
@public
|
|
284
255
|
*/
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
* @private
|
|
288
|
-
*/
|
|
289
|
-
_mergeRecordIdentifiers(keyInfo: KeyInfo, identifier: StableRecordIdentifier, existingIdentifier: StableRecordIdentifier, data: unknown): StableRecordIdentifier;
|
|
256
|
+
// FIXME audit usage
|
|
257
|
+
updateRecordIdentifier(identifierObject: ResourceKey, data: unknown): ResourceKey;
|
|
290
258
|
/**
|
|
291
259
|
Provides the opportunity to eliminate an identifier from secondary lookup tables
|
|
292
260
|
as well as eliminates it from ember-data's own lookup tables and book keeping.
|
|
@@ -297,8 +265,26 @@ export declare class IdentifierCache {
|
|
|
297
265
|
|
|
298
266
|
@public
|
|
299
267
|
*/
|
|
300
|
-
|
|
301
|
-
|
|
268
|
+
// FIXME audit usage
|
|
269
|
+
forgetRecordIdentifier(identifierObject: ResourceKey): void;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* This type exists for internal use only for
|
|
273
|
+
* where intimate contracts still exist either for
|
|
274
|
+
* the Test Suite or for Legacy code.
|
|
275
|
+
*
|
|
276
|
+
* @private
|
|
277
|
+
*/
|
|
278
|
+
export interface PrivateCacheKeyManager extends CacheKeyManager {
|
|
279
|
+
_cache: StableCache;
|
|
280
|
+
/**
|
|
281
|
+
* Internal hook to allow management of merge conflicts with identifiers.
|
|
282
|
+
*
|
|
283
|
+
* we allow late binding of this private internal merge so that
|
|
284
|
+
* the cache can insert itself here to handle elimination of duplicates
|
|
285
|
+
*/
|
|
286
|
+
__configureMerge(method: MergeMethod | null): void;
|
|
287
|
+
_mergeRecordIdentifiers(keyInfo: KeyInfo, identifier: ResourceKey, existingIdentifier: ResourceKey, data: unknown): ResourceKey;
|
|
302
288
|
destroy(): void;
|
|
303
289
|
}
|
|
304
290
|
export {};
|