@warp-drive/core 5.7.0-alpha.9 → 5.7.0-beta.0
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 +0 -87
- package/declarations/graph/-private/-utils.d.ts +5 -11
- package/declarations/graph/-private/coerce-id.d.ts +0 -6
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +2 -14
- 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 -51
- package/declarations/graph/-private/normalize-link.d.ts +0 -6
- package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -59
- package/declarations/graph/-private/operations/update-relationship.d.ts +3 -7
- package/declarations/index.d.ts +1 -1
- package/declarations/reactive/-private/default-mode.d.ts +2 -2
- package/declarations/reactive/-private/document.d.ts +11 -27
- package/declarations/reactive/-private/fields/managed-array.d.ts +4 -6
- package/declarations/reactive/-private/fields/managed-object.d.ts +2 -8
- 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/record.d.ts +42 -30
- package/declarations/reactive/-private/schema.d.ts +11 -73
- package/declarations/reactive/-private/symbols.d.ts +2 -33
- package/declarations/reactive/-private.d.ts +1 -1
- package/declarations/reactive.d.ts +277 -1
- package/declarations/request/-private/context.d.ts +3 -5
- package/declarations/request/-private/fetch.d.ts +2 -2
- package/declarations/request/-private/manager.d.ts +24 -28
- package/declarations/request/-private/types.d.ts +22 -24
- 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 -5
- package/declarations/store/-private/caches/instance-cache.d.ts +21 -20
- package/declarations/store/-private/debug/utils.d.ts +1 -0
- package/declarations/store/-private/default-cache-policy.d.ts +25 -40
- 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} +35 -53
- package/declarations/store/-private/managers/cache-manager.d.ts +46 -111
- package/declarations/store/-private/managers/notification-manager.d.ts +30 -45
- package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
- package/declarations/store/-private/network/request-cache.d.ts +21 -25
- 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 +132 -37
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -135
- 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 +67 -0
- package/declarations/store/-private/store-service.d.ts +156 -106
- package/declarations/store/-private/utils/coerce-id.d.ts +0 -6
- package/declarations/store/-private.d.ts +11 -13
- 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 +9 -9
- package/declarations/store/-types/q/store.d.ts +6 -7
- package/declarations/store/deprecated/-private.d.ts +12 -24
- package/declarations/store/deprecated/store.d.ts +11 -16
- package/declarations/types/-private.d.ts +1 -1
- package/declarations/types/cache/aliases.d.ts +0 -11
- package/declarations/types/cache/change.d.ts +2 -2
- package/declarations/types/cache/mutations.d.ts +13 -37
- package/declarations/types/cache/operations.d.ts +115 -32
- package/declarations/types/cache/relationship.d.ts +4 -7
- package/declarations/types/cache.d.ts +51 -125
- package/declarations/types/graph.d.ts +12 -12
- package/declarations/types/identifier.d.ts +52 -78
- package/declarations/types/params.d.ts +2 -3
- package/declarations/types/request.d.ts +66 -42
- package/declarations/types/schema/concepts.d.ts +2 -2
- package/declarations/types/schema/fields.d.ts +30 -3
- package/declarations/types/spec/document.d.ts +6 -10
- package/declarations/types/spec/json-api-raw.d.ts +6 -9
- package/declarations/types.d.ts +0 -1
- package/declarations/utils/string.d.ts +2 -3
- package/dist/{configure-B48bFHOl.js → configure-C3x8YXzL.js} +5 -5
- package/dist/configure.js +1 -1
- package/dist/{context-COmAnXUQ.js → context-C_7OLieY.js} +48 -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 +144 -1926
- package/dist/{request-state-CeN66aML.js → request-state-C955e0AL.js} +5968 -3033
- 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 +6 -0
- package/dist/utils/string.js +2 -2
- package/package.json +11 -11
- 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-SdXlte1w.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 & {
|
|
@@ -18,10 +18,9 @@ export type RobustError = Error & {
|
|
|
18
18
|
errors?: ApiError[];
|
|
19
19
|
content?: unknown;
|
|
20
20
|
};
|
|
21
|
-
// TODO @runspired, consider if we should deep freeze errors (potentially only in debug) vs cloning them
|
|
22
21
|
export declare function cloneError(error: RobustError): RobustError;
|
|
23
22
|
export declare function isErrorDocument(document: ResourceDataDocument | ResourceErrorDocument): document is ResourceErrorDocument;
|
|
24
|
-
export declare function getPriority(identifier:
|
|
23
|
+
export declare function getPriority(identifier: RequestKey | null, deduped: Map<RequestKey, {
|
|
25
24
|
priority: {
|
|
26
25
|
blocking: boolean;
|
|
27
26
|
};
|
|
@@ -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,14 @@ 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
|
-
setRecordId(identifier: StableRecordIdentifier, id: string): void;
|
|
56
|
+
setRecordId(identifier: ResourceKey, id: string): void;
|
|
57
57
|
}
|
|
58
|
+
export declare function getNewRecord(instances: InstanceCache, identifier: ResourceKey, properties: CreateRecordProperties): OpaqueRecordInstance;
|
|
58
59
|
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,28 @@
|
|
|
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
|
-
|
|
14
|
-
(identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
|
|
13
|
+
(resourceKey: ResourceKey, notificationType: CacheOperation): void;
|
|
15
14
|
}
|
|
16
15
|
interface DocumentOperationCallback {
|
|
17
|
-
|
|
18
|
-
(identifier: StableDocumentIdentifier, notificationType: DocumentCacheOperation): void;
|
|
16
|
+
(cacheKey: RequestKey, notificationType: DocumentCacheOperation): void;
|
|
19
17
|
}
|
|
20
18
|
type NotificationManager = {
|
|
21
|
-
subscribe(
|
|
22
|
-
subscribe(
|
|
23
|
-
subscribe(
|
|
24
|
-
notify(
|
|
25
|
-
notify(
|
|
26
|
-
notify(
|
|
27
|
-
notify(
|
|
19
|
+
subscribe(resourceKey: ResourceKey, callback: NotificationCallback): UnsubscribeToken;
|
|
20
|
+
subscribe(cacheKey: "resource", callback: ResourceOperationCallback): UnsubscribeToken;
|
|
21
|
+
subscribe(cacheKey: "document" | RequestKey, callback: DocumentOperationCallback): UnsubscribeToken;
|
|
22
|
+
notify(cacheKey: ResourceKey, value: "attributes" | "relationships", key?: string): boolean;
|
|
23
|
+
notify(cacheKey: ResourceKey, value: "errors" | "meta" | "identity" | "state"): boolean;
|
|
24
|
+
notify(cacheKey: ResourceKey, value: CacheOperation): boolean;
|
|
25
|
+
notify(cacheKey: RequestKey, value: DocumentCacheOperation): boolean;
|
|
28
26
|
};
|
|
29
27
|
type Store = {
|
|
30
28
|
cache: Cache;
|
|
@@ -236,7 +234,7 @@ export type PolicyConfig = {
|
|
|
236
234
|
* request for that type is successful.
|
|
237
235
|
*
|
|
238
236
|
* 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
|
|
237
|
+
* with the types that should be invalidated, or its request should specify the ResourceKeys
|
|
240
238
|
* of the records that are being created via `records`. Providing both is valid.
|
|
241
239
|
*
|
|
242
240
|
* > [!NOTE]
|
|
@@ -285,30 +283,28 @@ export type PolicyConfig = {
|
|
|
285
283
|
export declare class DefaultCachePolicy {
|
|
286
284
|
config: PolicyConfig;
|
|
287
285
|
_stores: WeakMap<Store, {
|
|
288
|
-
invalidated: Set<
|
|
289
|
-
types: Map<string, Set<
|
|
286
|
+
invalidated: Set<RequestKey>;
|
|
287
|
+
types: Map<string, Set<RequestKey>>;
|
|
290
288
|
}>;
|
|
291
289
|
_getStore(store: Store): {
|
|
292
|
-
invalidated: Set<
|
|
293
|
-
types: Map<string, Set<
|
|
290
|
+
invalidated: Set<RequestKey>;
|
|
291
|
+
types: Map<string, Set<RequestKey>>;
|
|
294
292
|
};
|
|
295
293
|
constructor(config: PolicyConfig);
|
|
296
294
|
/**
|
|
297
|
-
* Invalidate a request by its
|
|
295
|
+
* Invalidate a request by its CacheKey for the given store instance.
|
|
298
296
|
*
|
|
299
297
|
* While the store argument may seem redundant, the CachePolicy
|
|
300
298
|
* is designed to be shared across multiple stores / forks
|
|
301
299
|
* of the store.
|
|
302
300
|
*
|
|
303
301
|
* ```ts
|
|
304
|
-
* store.lifetimes.invalidateRequest(store,
|
|
302
|
+
* store.lifetimes.invalidateRequest(store, cacheKey);
|
|
305
303
|
* ```
|
|
306
304
|
*
|
|
307
305
|
* @public
|
|
308
|
-
* @param {StableDocumentIdentifier} identifier
|
|
309
|
-
* @param {Store} store
|
|
310
306
|
*/
|
|
311
|
-
invalidateRequest(
|
|
307
|
+
invalidateRequest(cacheKey: RequestKey, store: Store): void;
|
|
312
308
|
/**
|
|
313
309
|
* Invalidate all requests associated to a specific type
|
|
314
310
|
* for a given store instance.
|
|
@@ -325,8 +321,6 @@ export declare class DefaultCachePolicy {
|
|
|
325
321
|
* ```
|
|
326
322
|
*
|
|
327
323
|
* @public
|
|
328
|
-
* @param {String} type
|
|
329
|
-
* @param {Store} store
|
|
330
324
|
*/
|
|
331
325
|
invalidateRequestsForType(type: string, store: Store): void;
|
|
332
326
|
/**
|
|
@@ -340,13 +334,8 @@ export declare class DefaultCachePolicy {
|
|
|
340
334
|
* This method should not be invoked directly by consumers.
|
|
341
335
|
*
|
|
342
336
|
* @public
|
|
343
|
-
* @param {ImmutableRequestInfo} request
|
|
344
|
-
* @param {ImmutableResponse} response
|
|
345
|
-
* @param {Store} store
|
|
346
|
-
* @param {StableDocumentIdentifier | null} identifier
|
|
347
|
-
* @return {void}
|
|
348
337
|
*/
|
|
349
|
-
didRequest(request: ImmutableRequestInfo, response: Response | ResponseInfo | null,
|
|
338
|
+
didRequest(request: ImmutableRequestInfo, response: Response | ResponseInfo | null, cacheKey: RequestKey | null, store: Store): void;
|
|
350
339
|
/**
|
|
351
340
|
* Invoked to determine if the request may be fulfilled from cache
|
|
352
341
|
* if possible.
|
|
@@ -359,11 +348,9 @@ export declare class DefaultCachePolicy {
|
|
|
359
348
|
* and the cache will be updated before returning the response.
|
|
360
349
|
*
|
|
361
350
|
* @public
|
|
362
|
-
* @
|
|
363
|
-
* @param {Store} store
|
|
364
|
-
* @return {Boolean} true if the request is considered hard expired
|
|
351
|
+
* @return true if the request is considered hard expired
|
|
365
352
|
*/
|
|
366
|
-
isHardExpired(
|
|
353
|
+
isHardExpired(cacheKey: RequestKey, store: Store): boolean;
|
|
367
354
|
/**
|
|
368
355
|
* Invoked if `isHardExpired` is false to determine if the request
|
|
369
356
|
* should be update behind the scenes if cache data is already available.
|
|
@@ -375,10 +362,8 @@ export declare class DefaultCachePolicy {
|
|
|
375
362
|
* request is made to update the cache via the configured request handlers.
|
|
376
363
|
*
|
|
377
364
|
* @public
|
|
378
|
-
* @
|
|
379
|
-
* @param {Store} store
|
|
380
|
-
* @return {Boolean} true if the request is considered soft expired
|
|
365
|
+
* @return true if the request is considered soft expired
|
|
381
366
|
*/
|
|
382
|
-
isSoftExpired(
|
|
367
|
+
isSoftExpired(cacheKey: RequestKey, store: Store): boolean;
|
|
383
368
|
}
|
|
384
369
|
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,14 @@ interface KeyOptions {
|
|
|
15
15
|
type TypeMap = {
|
|
16
16
|
[key: string]: KeyOptions;
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
// type IdentifiersByType = Map<string, IdentifierTypeLookup>;
|
|
20
|
-
type IdentifierMap = Map<string, StableRecordIdentifier>;
|
|
18
|
+
type IdentifierMap = Map<string, ResourceKey>;
|
|
21
19
|
type StableCache = {
|
|
22
20
|
resources: IdentifierMap;
|
|
23
|
-
documents: Map<string,
|
|
21
|
+
documents: Map<string, RequestKey>;
|
|
24
22
|
resourcesByType: TypeMap;
|
|
25
23
|
polymorphicLidBackMap: Map<string, string[]>;
|
|
26
24
|
};
|
|
27
|
-
export type MergeMethod = (targetIdentifier:
|
|
25
|
+
export type MergeMethod = (targetIdentifier: ResourceKey, matchedIdentifier: ResourceKey, resourceData: unknown) => ResourceKey;
|
|
28
26
|
/**
|
|
29
27
|
Configures how unique identifier lid strings are generated by @ember-data/store.
|
|
30
28
|
|
|
@@ -163,10 +161,10 @@ to the application instance, you may not need to implement the `resetMethod`.
|
|
|
163
161
|
export declare function setIdentifierResetMethod(method: ResetMethod | null): void;
|
|
164
162
|
/**
|
|
165
163
|
Configure a callback for when the identifier cache is generating a new
|
|
166
|
-
|
|
164
|
+
ResourceKey for a resource.
|
|
167
165
|
|
|
168
166
|
This method controls the `type` and `id` that will be assigned to the
|
|
169
|
-
`
|
|
167
|
+
`ResourceKey` that is created.
|
|
170
168
|
|
|
171
169
|
This configuration MUST occur prior to the store instance being created.
|
|
172
170
|
|
|
@@ -178,7 +176,7 @@ import { setKeyInfoForResource } from '@warp-drive/core';
|
|
|
178
176
|
*/
|
|
179
177
|
export declare function setKeyInfoForResource(method: KeyInfoMethod | null): void;
|
|
180
178
|
/**
|
|
181
|
-
* Each instance of {@link Store} receives a unique instance of a
|
|
179
|
+
* Each instance of {@link Store} receives a unique instance of a CacheKeyManager.
|
|
182
180
|
*
|
|
183
181
|
* This cache is responsible for assigning or retrieving the unique identify
|
|
184
182
|
* for arbitrary resource data encountered by the store. Data representing
|
|
@@ -190,53 +188,23 @@ export declare function setKeyInfoForResource(method: KeyInfoMethod | null): voi
|
|
|
190
188
|
* @hideconstructor
|
|
191
189
|
* @public
|
|
192
190
|
*/
|
|
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;
|
|
191
|
+
export declare class CacheKeyManager {
|
|
203
192
|
constructor();
|
|
204
193
|
/**
|
|
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
194
|
* allows us to peek without generating when needed
|
|
227
195
|
* useful for the "create" case when we need to see if
|
|
228
196
|
* we are accidentally overwritting something
|
|
229
197
|
*
|
|
230
198
|
* @private
|
|
231
199
|
*/
|
|
232
|
-
peekRecordIdentifier(resource: ResourceIdentifierObject
|
|
200
|
+
peekRecordIdentifier(resource: ResourceIdentifierObject): ResourceKey | undefined;
|
|
233
201
|
/**
|
|
234
202
|
Returns the DocumentIdentifier for the given Request, creates one if it does not yet exist.
|
|
235
203
|
Returns `null` if the request does not have a `cacheKey` or `url`.
|
|
236
204
|
|
|
237
205
|
@public
|
|
238
206
|
*/
|
|
239
|
-
getOrCreateDocumentIdentifier(request: ImmutableRequestInfo):
|
|
207
|
+
getOrCreateDocumentIdentifier(request: ImmutableRequestInfo): RequestKey | null;
|
|
240
208
|
/**
|
|
241
209
|
Returns the Identifier for the given Resource, creates one if it does not yet exist.
|
|
242
210
|
|
|
@@ -263,7 +231,8 @@ export declare class IdentifierCache {
|
|
|
263
231
|
createIdentifierForNewRecord(data: {
|
|
264
232
|
type: string;
|
|
265
233
|
id?: string | null;
|
|
266
|
-
|
|
234
|
+
lid?: string;
|
|
235
|
+
}): ResourceKey;
|
|
267
236
|
/**
|
|
268
237
|
Provides the opportunity to update secondary lookup tables for existing identifiers
|
|
269
238
|
Called after an identifier created with `createIdentifierForNewRecord` has been
|
|
@@ -282,11 +251,7 @@ export declare class IdentifierCache {
|
|
|
282
251
|
|
|
283
252
|
@public
|
|
284
253
|
*/
|
|
285
|
-
updateRecordIdentifier(identifierObject:
|
|
286
|
-
/**
|
|
287
|
-
* @private
|
|
288
|
-
*/
|
|
289
|
-
_mergeRecordIdentifiers(keyInfo: KeyInfo, identifier: StableRecordIdentifier, existingIdentifier: StableRecordIdentifier, data: unknown): StableRecordIdentifier;
|
|
254
|
+
updateRecordIdentifier(identifierObject: ResourceKey, data: unknown): ResourceKey;
|
|
290
255
|
/**
|
|
291
256
|
Provides the opportunity to eliminate an identifier from secondary lookup tables
|
|
292
257
|
as well as eliminates it from ember-data's own lookup tables and book keeping.
|
|
@@ -297,8 +262,25 @@ export declare class IdentifierCache {
|
|
|
297
262
|
|
|
298
263
|
@public
|
|
299
264
|
*/
|
|
300
|
-
forgetRecordIdentifier(identifierObject:
|
|
301
|
-
|
|
265
|
+
forgetRecordIdentifier(identifierObject: ResourceKey): void;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* This type exists for internal use only for
|
|
269
|
+
* where intimate contracts still exist either for
|
|
270
|
+
* the Test Suite or for Legacy code.
|
|
271
|
+
*
|
|
272
|
+
* @private
|
|
273
|
+
*/
|
|
274
|
+
export interface PrivateCacheKeyManager extends CacheKeyManager {
|
|
275
|
+
_cache: StableCache;
|
|
276
|
+
/**
|
|
277
|
+
* Internal hook to allow management of merge conflicts with identifiers.
|
|
278
|
+
*
|
|
279
|
+
* we allow late binding of this private internal merge so that
|
|
280
|
+
* the cache can insert itself here to handle elimination of duplicates
|
|
281
|
+
*/
|
|
282
|
+
__configureMerge(method: MergeMethod | null): void;
|
|
283
|
+
_mergeRecordIdentifiers(keyInfo: KeyInfo, identifier: ResourceKey, existingIdentifier: ResourceKey, data: unknown): ResourceKey;
|
|
302
284
|
destroy(): void;
|
|
303
285
|
}
|
|
304
286
|
export {};
|