@ember-data/store 5.4.0-alpha.31 → 5.4.0-alpha.33
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/package.json +9 -9
- package/unstable-preview-types/-private/cache-handler.d.ts +101 -99
- package/unstable-preview-types/-private/caches/cache-utils.d.ts +11 -9
- package/unstable-preview-types/-private/caches/identifier-cache.d.ts +181 -179
- package/unstable-preview-types/-private/caches/instance-cache.d.ts +63 -61
- package/unstable-preview-types/-private/caches/resource-utils.d.ts +12 -10
- package/unstable-preview-types/-private/document.d.ts +146 -144
- package/unstable-preview-types/-private/index.d.ts +18 -16
- package/unstable-preview-types/-private/legacy-model-support/record-reference.d.ts +178 -176
- package/unstable-preview-types/-private/legacy-model-support/shim-model-class.d.ts +19 -17
- package/unstable-preview-types/-private/managers/cache-capabilities-manager.d.ts +29 -27
- package/unstable-preview-types/-private/managers/cache-manager.d.ts +442 -440
- package/unstable-preview-types/-private/managers/notification-manager.d.ts +98 -96
- package/unstable-preview-types/-private/managers/record-array-manager.d.ts +97 -95
- package/unstable-preview-types/-private/network/request-cache.d.ts +109 -107
- package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts +134 -132
- package/unstable-preview-types/-private/store-service.d.ts +1503 -1501
- package/unstable-preview-types/-private/utils/coerce-id.d.ts +10 -8
- package/unstable-preview-types/-private/utils/construct-resource.d.ts +10 -8
- package/unstable-preview-types/-private/utils/identifier-debug-consts.d.ts +7 -5
- package/unstable-preview-types/-private/utils/is-non-empty-string.d.ts +4 -2
- package/unstable-preview-types/-private/utils/normalize-model-name.d.ts +4 -2
- package/unstable-preview-types/-private/utils/uuid-polyfill.d.ts +4 -2
- package/unstable-preview-types/-private.d.ts +4 -2
- package/unstable-preview-types/-types/overview.d.ts +21 -19
- package/unstable-preview-types/-types/q/cache-store-wrapper.d.ts +107 -105
- package/unstable-preview-types/-types/q/cache.d.ts +47 -45
- package/unstable-preview-types/-types/q/ds-model.d.ts +15 -13
- package/unstable-preview-types/-types/q/identifier.d.ts +169 -167
- package/unstable-preview-types/-types/q/promise-proxies.d.ts +4 -2
- package/unstable-preview-types/-types/q/record-data-json-api.d.ts +36 -34
- package/unstable-preview-types/-types/q/record-instance.d.ts +29 -27
- package/unstable-preview-types/-types/q/schema-service.d.ts +214 -212
- package/unstable-preview-types/-types/q/store.d.ts +17 -15
- package/unstable-preview-types/index.d.ts +220 -185
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-data/store",
|
|
3
|
-
"version": "5.4.0-alpha.
|
|
3
|
+
"version": "5.4.0-alpha.33",
|
|
4
4
|
"description": "The core of EmberData. Provides the Store service which coordinates the cache with the network and presentation layers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"ember-data-logo-light.svg"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@ember-data/private-build-infra": "5.4.0-alpha.
|
|
25
|
+
"@ember-data/private-build-infra": "5.4.0-alpha.33",
|
|
26
26
|
"@embroider/macros": "^1.13.5",
|
|
27
27
|
"ember-cli-babel": "^8.2.0",
|
|
28
28
|
"pnpm-sync-dependencies-meta-injected": "0.0.10"
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@ember-data/request": "5.4.0-alpha.
|
|
49
|
-
"@ember-data/tracking": "5.4.0-alpha.
|
|
48
|
+
"@ember-data/request": "5.4.0-alpha.33",
|
|
49
|
+
"@ember-data/tracking": "5.4.0-alpha.33",
|
|
50
50
|
"@ember/string": "^3.1.1",
|
|
51
|
-
"@warp-drive/core-types": "0.0.0-alpha.
|
|
51
|
+
"@warp-drive/core-types": "0.0.0-alpha.19"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@babel/cli": "^7.23.9",
|
|
@@ -61,15 +61,15 @@
|
|
|
61
61
|
"@babel/preset-env": "^7.23.9",
|
|
62
62
|
"@babel/preset-typescript": "^7.23.3",
|
|
63
63
|
"@babel/runtime": "^7.23.9",
|
|
64
|
-
"@ember-data/request": "5.4.0-alpha.
|
|
65
|
-
"@ember-data/tracking": "5.4.0-alpha.
|
|
64
|
+
"@ember-data/request": "5.4.0-alpha.33",
|
|
65
|
+
"@ember-data/tracking": "5.4.0-alpha.33",
|
|
66
66
|
"@ember/string": "^3.1.1",
|
|
67
67
|
"@embroider/addon-dev": "^4.1.2",
|
|
68
68
|
"@glimmer/component": "^1.1.2",
|
|
69
69
|
"@rollup/plugin-babel": "^6.0.4",
|
|
70
70
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
71
|
-
"@warp-drive/core-types": "0.0.0-alpha.
|
|
72
|
-
"@warp-drive/internal-config": "5.4.0-alpha.
|
|
71
|
+
"@warp-drive/core-types": "0.0.0-alpha.19",
|
|
72
|
+
"@warp-drive/internal-config": "5.4.0-alpha.33",
|
|
73
73
|
"ember-source": "~5.6.0",
|
|
74
74
|
"rollup": "^4.9.6",
|
|
75
75
|
"typescript": "^5.3.3",
|
|
@@ -1,99 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
export type
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
export
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
1
|
+
declare module '@ember-data/store/-private/cache-handler' {
|
|
2
|
+
import type { Handler } from '@ember-data/request/-private/types';
|
|
3
|
+
import type { StableDocumentIdentifier } from '@warp-drive/core-types/identifier';
|
|
4
|
+
import type { ImmutableRequestInfo, RequestContext, ResponseInfo } from '@warp-drive/core-types/request';
|
|
5
|
+
import { EnableHydration } from '@warp-drive/core-types/request';
|
|
6
|
+
import type { ResourceIdentifierObject } from '@warp-drive/core-types/spec/raw';
|
|
7
|
+
import type Store from '@ember-data/store/-private/store-service';
|
|
8
|
+
/**
|
|
9
|
+
* A service which an application may provide to the store via
|
|
10
|
+
* the store's `lifetimes` property to configure the behavior
|
|
11
|
+
* of the CacheHandler.
|
|
12
|
+
*
|
|
13
|
+
* The default behavior for request lifetimes is to never expire
|
|
14
|
+
* unless manually refreshed via `cacheOptions.reload` or `cacheOptions.backgroundReload`.
|
|
15
|
+
*
|
|
16
|
+
* Implementing this service allows you to programatically define
|
|
17
|
+
* when a request should be considered expired.
|
|
18
|
+
*
|
|
19
|
+
* @class <Interface> LifetimesService
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export interface LifetimesService {
|
|
23
|
+
/**
|
|
24
|
+
* Invoked to determine if the request may be fulfilled from cache
|
|
25
|
+
* if possible.
|
|
26
|
+
*
|
|
27
|
+
* Note, this is only invoked if the request has a cache-key.
|
|
28
|
+
*
|
|
29
|
+
* If no cache entry is found or the entry is hard expired,
|
|
30
|
+
* the request will be fulfilled from the configured request handlers
|
|
31
|
+
* and the cache will be updated before returning the response.
|
|
32
|
+
*
|
|
33
|
+
* @method isHardExpired
|
|
34
|
+
* @public
|
|
35
|
+
* @param {StableDocumentIdentifier} identifier
|
|
36
|
+
* @param {Store} store
|
|
37
|
+
* @return {boolean} true if the request is considered hard expired
|
|
38
|
+
*/
|
|
39
|
+
isHardExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Invoked if `isHardExpired` is false to determine if the request
|
|
42
|
+
* should be update behind the scenes if cache data is already available.
|
|
43
|
+
*
|
|
44
|
+
* Note, this is only invoked if the request has a cache-key.
|
|
45
|
+
*
|
|
46
|
+
* If true, the request will be fulfilled from cache while a backgrounded
|
|
47
|
+
* request is made to update the cache via the configured request handlers.
|
|
48
|
+
*
|
|
49
|
+
* @method isSoftExpired
|
|
50
|
+
* @public
|
|
51
|
+
* @param {StableDocumentIdentifier} identifier
|
|
52
|
+
* @param {Store} store
|
|
53
|
+
* @return {boolean} true if the request is considered soft expired
|
|
54
|
+
*/
|
|
55
|
+
isSoftExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Invoked when a request will be sent to the configured request handlers.
|
|
58
|
+
* This is invoked for both foreground and background requests.
|
|
59
|
+
*
|
|
60
|
+
* Note, this is invoked regardless of whether the request has a cache-key.
|
|
61
|
+
*
|
|
62
|
+
* @method willRequest [Optional]
|
|
63
|
+
* @public
|
|
64
|
+
* @param {ImmutableRequestInfo} request
|
|
65
|
+
* @param {StableDocumentIdentifier | null} identifier
|
|
66
|
+
* @param {Store} store
|
|
67
|
+
* @return {void}
|
|
68
|
+
*/
|
|
69
|
+
willRequest?(request: ImmutableRequestInfo, identifier: StableDocumentIdentifier | null, store: Store): void;
|
|
70
|
+
/**
|
|
71
|
+
* Invoked when a request has been fulfilled from the configured request handlers.
|
|
72
|
+
* This is invoked for both foreground and background requests once the cache has
|
|
73
|
+
* been updated.
|
|
74
|
+
*
|
|
75
|
+
* Note, this is invoked regardless of whether the request has a cache-key.
|
|
76
|
+
*
|
|
77
|
+
* @method didRequest [Optional]
|
|
78
|
+
* @public
|
|
79
|
+
* @param {ImmutableRequestInfo} request
|
|
80
|
+
* @param {ImmutableResponse} response
|
|
81
|
+
* @param {StableDocumentIdentifier | null} identifier
|
|
82
|
+
* @param {Store} store
|
|
83
|
+
* @return {void}
|
|
84
|
+
*/
|
|
85
|
+
didRequest?(request: ImmutableRequestInfo, response: Response | ResponseInfo | null, identifier: StableDocumentIdentifier | null, store: Store): void;
|
|
86
|
+
}
|
|
87
|
+
export type StoreRequestInfo = ImmutableRequestInfo;
|
|
88
|
+
export type LooseStoreRequestInfo = Omit<StoreRequestInfo, 'records' | 'headers'> & {
|
|
89
|
+
records?: ResourceIdentifierObject[];
|
|
90
|
+
headers?: Headers;
|
|
91
|
+
};
|
|
92
|
+
export type StoreRequestInput = StoreRequestInfo | LooseStoreRequestInfo;
|
|
93
|
+
export interface StoreRequestContext extends RequestContext {
|
|
94
|
+
request: StoreRequestInfo & {
|
|
95
|
+
store: Store;
|
|
96
|
+
[EnableHydration]?: boolean;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export declare const CacheHandler: Handler;
|
|
100
|
+
//# sourceMappingURL=cache-handler.d.ts.map
|
|
101
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
export declare
|
|
6
|
-
export declare function
|
|
7
|
-
export
|
|
8
|
-
export default function peekCache(instance:
|
|
9
|
-
|
|
1
|
+
declare module '@ember-data/store/-private/caches/cache-utils' {
|
|
2
|
+
import type { StableRecordIdentifier } from '@warp-drive/core-types/identifier';
|
|
3
|
+
import type { Cache } from '@ember-data/store/-types/q/cache';
|
|
4
|
+
import type { OpaqueRecordInstance } from '@ember-data/store/-types/q/record-instance';
|
|
5
|
+
export declare const CacheForIdentifierCache: Map<unknown, Cache>;
|
|
6
|
+
export declare function setCacheFor(identifier: StableRecordIdentifier | OpaqueRecordInstance, cache: Cache): void;
|
|
7
|
+
export declare function removeRecordDataFor(identifier: StableRecordIdentifier | OpaqueRecordInstance): void;
|
|
8
|
+
export default function peekCache(instance: StableRecordIdentifier): Cache | null;
|
|
9
|
+
export default function peekCache(instance: OpaqueRecordInstance): Cache;
|
|
10
|
+
//# sourceMappingURL=cache-utils.d.ts.map
|
|
11
|
+
}
|
|
@@ -1,180 +1,182 @@
|
|
|
1
|
-
|
|
2
|
-
import type
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
export declare function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export type
|
|
27
|
-
export
|
|
28
|
-
export declare function
|
|
29
|
-
export declare function
|
|
30
|
-
export declare function
|
|
31
|
-
export declare function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
@
|
|
44
|
-
*/
|
|
45
|
-
export declare class IdentifierCache {
|
|
46
|
-
_cache: StableCache;
|
|
47
|
-
_generate: GenerationMethod;
|
|
48
|
-
_update: UpdateMethod;
|
|
49
|
-
_forget: ForgetMethod;
|
|
50
|
-
_reset: ResetMethod;
|
|
51
|
-
_merge: MergeMethod;
|
|
52
|
-
_keyInfoForResource: KeyInfoMethod;
|
|
53
|
-
_isDefaultConfig: boolean;
|
|
54
|
-
_id: number;
|
|
55
|
-
constructor();
|
|
56
|
-
/**
|
|
57
|
-
* Internal hook to allow management of merge conflicts with identifiers.
|
|
58
|
-
*
|
|
59
|
-
* we allow late binding of this private internal merge so that
|
|
60
|
-
* the cache can insert itself here to handle elimination of duplicates
|
|
61
|
-
*
|
|
62
|
-
* @method __configureMerge
|
|
63
|
-
* @private
|
|
64
|
-
*/
|
|
65
|
-
__configureMerge(method: MergeMethod | null): void;
|
|
66
|
-
upgradeIdentifier(resource: {
|
|
67
|
-
type: string;
|
|
68
|
-
id: string | null;
|
|
69
|
-
lid?: string;
|
|
70
|
-
}): StableRecordIdentifier;
|
|
71
|
-
/**
|
|
72
|
-
* @method _getRecordIdentifier
|
|
73
|
-
* @private
|
|
74
|
-
*/
|
|
75
|
-
_getRecordIdentifier(resource: {
|
|
76
|
-
type: string;
|
|
77
|
-
id: string | null;
|
|
78
|
-
lid?: string;
|
|
79
|
-
}, shouldGenerate: 2): StableRecordIdentifier;
|
|
80
|
-
_getRecordIdentifier(resource: unknown, shouldGenerate: 1): StableRecordIdentifier;
|
|
81
|
-
_getRecordIdentifier(resource: unknown, shouldGenerate: 0): StableRecordIdentifier | undefined;
|
|
82
|
-
/**
|
|
83
|
-
* allows us to peek without generating when needed
|
|
84
|
-
* useful for the "create" case when we need to see if
|
|
85
|
-
* we are accidentally overwritting something
|
|
86
|
-
*
|
|
87
|
-
* @method peekRecordIdentifier
|
|
88
|
-
* @param resource
|
|
89
|
-
* @return {StableRecordIdentifier | undefined}
|
|
90
|
-
* @private
|
|
91
|
-
*/
|
|
92
|
-
peekRecordIdentifier(resource: ResourceIdentifierObject | Identifier): StableRecordIdentifier | undefined;
|
|
93
|
-
/**
|
|
94
|
-
Returns the DocumentIdentifier for the given Request, creates one if it does not yet exist.
|
|
95
|
-
Returns `null` if the request does not have a `cacheKey` or `url`.
|
|
96
|
-
|
|
97
|
-
@method getOrCreateDocumentIdentifier
|
|
98
|
-
@param request
|
|
99
|
-
@return {StableDocumentIdentifier | null}
|
|
100
|
-
@public
|
|
101
|
-
*/
|
|
102
|
-
getOrCreateDocumentIdentifier(request: ImmutableRequestInfo): StableDocumentIdentifier | null;
|
|
103
|
-
/**
|
|
104
|
-
Returns the Identifier for the given Resource, creates one if it does not yet exist.
|
|
105
|
-
|
|
106
|
-
Specifically this means that we:
|
|
107
|
-
|
|
108
|
-
- validate the `id` `type` and `lid` combo against known identifiers
|
|
109
|
-
- return an object with an `lid` that is stable (repeated calls with the same
|
|
110
|
-
`id` + `type` or `lid` will return the same `lid` value)
|
|
111
|
-
- this referential stability of the object itself is guaranteed
|
|
112
|
-
|
|
113
|
-
@method getOrCreateRecordIdentifier
|
|
114
|
-
@param resource
|
|
115
|
-
@return {StableRecordIdentifier}
|
|
116
|
-
@public
|
|
117
|
-
*/
|
|
118
|
-
getOrCreateRecordIdentifier(resource: unknown): StableRecordIdentifier;
|
|
119
|
-
/**
|
|
120
|
-
Returns a new Identifier for the supplied data. Call this method to generate
|
|
121
|
-
an identifier when a new resource is being created local to the client and
|
|
122
|
-
potentially does not have an `id`.
|
|
123
|
-
|
|
124
|
-
Delegates generation to the user supplied `GenerateMethod` if one has been provided
|
|
125
|
-
with the signature `generateMethod({ type }, 'record')`.
|
|
126
|
-
|
|
127
|
-
@method createIdentifierForNewRecord
|
|
128
|
-
@param data
|
|
129
|
-
@return {StableRecordIdentifier}
|
|
1
|
+
declare module '@ember-data/store/-private/caches/identifier-cache' {
|
|
2
|
+
import { type Identifier, type RecordIdentifier, type StableDocumentIdentifier, type StableRecordIdentifier } from '@warp-drive/core-types/identifier';
|
|
3
|
+
import type { ImmutableRequestInfo } from '@warp-drive/core-types/request';
|
|
4
|
+
import type { ResourceIdentifierObject } from '@warp-drive/core-types/spec/raw';
|
|
5
|
+
import type { ForgetMethod, GenerationMethod, ResetMethod, UpdateMethod } from '@ember-data/store/-types/q/identifier';
|
|
6
|
+
export declare function isStableIdentifier(identifier: unknown): identifier is StableRecordIdentifier;
|
|
7
|
+
export declare function isDocumentIdentifier(identifier: unknown): identifier is StableDocumentIdentifier;
|
|
8
|
+
interface KeyOptions {
|
|
9
|
+
lid: IdentifierMap;
|
|
10
|
+
id: IdentifierMap;
|
|
11
|
+
}
|
|
12
|
+
type TypeMap = {
|
|
13
|
+
[key: string]: KeyOptions;
|
|
14
|
+
};
|
|
15
|
+
type IdentifierMap = Map<string, StableRecordIdentifier>;
|
|
16
|
+
type KeyInfo = {
|
|
17
|
+
id: string | null;
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
20
|
+
type StableCache = {
|
|
21
|
+
resources: IdentifierMap;
|
|
22
|
+
documents: Map<string, StableDocumentIdentifier>;
|
|
23
|
+
resourcesByType: TypeMap;
|
|
24
|
+
polymorphicLidBackMap: Map<string, string[]>;
|
|
25
|
+
};
|
|
26
|
+
export type KeyInfoMethod = (resource: unknown, known: StableRecordIdentifier | null) => KeyInfo;
|
|
27
|
+
export type MergeMethod = (targetIdentifier: StableRecordIdentifier, matchedIdentifier: StableRecordIdentifier, resourceData: unknown) => StableRecordIdentifier;
|
|
28
|
+
export declare function setIdentifierGenerationMethod(method: GenerationMethod | null): void;
|
|
29
|
+
export declare function setIdentifierUpdateMethod(method: UpdateMethod | null): void;
|
|
30
|
+
export declare function setIdentifierForgetMethod(method: ForgetMethod | null): void;
|
|
31
|
+
export declare function setIdentifierResetMethod(method: ResetMethod | null): void;
|
|
32
|
+
export declare function setKeyInfoForResource(method: KeyInfoMethod | null): void;
|
|
33
|
+
/**
|
|
34
|
+
* Each instance of {Store} receives a unique instance of a IdentifierCache.
|
|
35
|
+
*
|
|
36
|
+
* This cache is responsible for assigning or retrieving the unique identify
|
|
37
|
+
* for arbitrary resource data encountered by the store. Data representing
|
|
38
|
+
* a unique resource or record should always be represented by the same
|
|
39
|
+
* identifier.
|
|
40
|
+
*
|
|
41
|
+
* It can be configured by consuming applications.
|
|
42
|
+
*
|
|
43
|
+
* @class IdentifierCache
|
|
130
44
|
@public
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
45
|
+
*/
|
|
46
|
+
export declare class IdentifierCache {
|
|
47
|
+
_cache: StableCache;
|
|
48
|
+
_generate: GenerationMethod;
|
|
49
|
+
_update: UpdateMethod;
|
|
50
|
+
_forget: ForgetMethod;
|
|
51
|
+
_reset: ResetMethod;
|
|
52
|
+
_merge: MergeMethod;
|
|
53
|
+
_keyInfoForResource: KeyInfoMethod;
|
|
54
|
+
_isDefaultConfig: boolean;
|
|
55
|
+
_id: number;
|
|
56
|
+
constructor();
|
|
57
|
+
/**
|
|
58
|
+
* Internal hook to allow management of merge conflicts with identifiers.
|
|
59
|
+
*
|
|
60
|
+
* we allow late binding of this private internal merge so that
|
|
61
|
+
* the cache can insert itself here to handle elimination of duplicates
|
|
62
|
+
*
|
|
63
|
+
* @method __configureMerge
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
__configureMerge(method: MergeMethod | null): void;
|
|
67
|
+
upgradeIdentifier(resource: {
|
|
68
|
+
type: string;
|
|
69
|
+
id: string | null;
|
|
70
|
+
lid?: string;
|
|
71
|
+
}): StableRecordIdentifier;
|
|
72
|
+
/**
|
|
73
|
+
* @method _getRecordIdentifier
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
_getRecordIdentifier(resource: {
|
|
77
|
+
type: string;
|
|
78
|
+
id: string | null;
|
|
79
|
+
lid?: string;
|
|
80
|
+
}, shouldGenerate: 2): StableRecordIdentifier;
|
|
81
|
+
_getRecordIdentifier(resource: unknown, shouldGenerate: 1): StableRecordIdentifier;
|
|
82
|
+
_getRecordIdentifier(resource: unknown, shouldGenerate: 0): StableRecordIdentifier | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* allows us to peek without generating when needed
|
|
85
|
+
* useful for the "create" case when we need to see if
|
|
86
|
+
* we are accidentally overwritting something
|
|
87
|
+
*
|
|
88
|
+
* @method peekRecordIdentifier
|
|
89
|
+
* @param resource
|
|
90
|
+
* @return {StableRecordIdentifier | undefined}
|
|
91
|
+
* @private
|
|
92
|
+
*/
|
|
93
|
+
peekRecordIdentifier(resource: ResourceIdentifierObject | Identifier): StableRecordIdentifier | undefined;
|
|
94
|
+
/**
|
|
95
|
+
Returns the DocumentIdentifier for the given Request, creates one if it does not yet exist.
|
|
96
|
+
Returns `null` if the request does not have a `cacheKey` or `url`.
|
|
97
|
+
|
|
98
|
+
@method getOrCreateDocumentIdentifier
|
|
99
|
+
@param request
|
|
100
|
+
@return {StableDocumentIdentifier | null}
|
|
101
|
+
@public
|
|
102
|
+
*/
|
|
103
|
+
getOrCreateDocumentIdentifier(request: ImmutableRequestInfo): StableDocumentIdentifier | null;
|
|
104
|
+
/**
|
|
105
|
+
Returns the Identifier for the given Resource, creates one if it does not yet exist.
|
|
106
|
+
|
|
107
|
+
Specifically this means that we:
|
|
108
|
+
|
|
109
|
+
- validate the `id` `type` and `lid` combo against known identifiers
|
|
110
|
+
- return an object with an `lid` that is stable (repeated calls with the same
|
|
111
|
+
`id` + `type` or `lid` will return the same `lid` value)
|
|
112
|
+
- this referential stability of the object itself is guaranteed
|
|
113
|
+
|
|
114
|
+
@method getOrCreateRecordIdentifier
|
|
115
|
+
@param resource
|
|
116
|
+
@return {StableRecordIdentifier}
|
|
117
|
+
@public
|
|
118
|
+
*/
|
|
119
|
+
getOrCreateRecordIdentifier(resource: unknown): StableRecordIdentifier;
|
|
120
|
+
/**
|
|
121
|
+
Returns a new Identifier for the supplied data. Call this method to generate
|
|
122
|
+
an identifier when a new resource is being created local to the client and
|
|
123
|
+
potentially does not have an `id`.
|
|
124
|
+
|
|
125
|
+
Delegates generation to the user supplied `GenerateMethod` if one has been provided
|
|
126
|
+
with the signature `generateMethod({ type }, 'record')`.
|
|
127
|
+
|
|
128
|
+
@method createIdentifierForNewRecord
|
|
129
|
+
@param data
|
|
130
|
+
@return {StableRecordIdentifier}
|
|
131
|
+
@public
|
|
132
|
+
*/
|
|
133
|
+
createIdentifierForNewRecord(data: {
|
|
134
|
+
type: string;
|
|
135
|
+
id?: string | null;
|
|
136
|
+
}): StableRecordIdentifier;
|
|
137
|
+
/**
|
|
138
|
+
Provides the opportunity to update secondary lookup tables for existing identifiers
|
|
139
|
+
Called after an identifier created with `createIdentifierForNewRecord` has been
|
|
140
|
+
committed.
|
|
141
|
+
|
|
142
|
+
Assigned `id` to an `Identifier` if `id` has not previously existed; however,
|
|
143
|
+
attempting to change the `id` or calling update without providing an `id` when
|
|
144
|
+
one is missing will throw an error.
|
|
145
|
+
|
|
146
|
+
- sets `id` (if `id` was previously `null`)
|
|
147
|
+
- `lid` and `type` MUST NOT be altered post creation
|
|
148
|
+
|
|
149
|
+
If a merge occurs, it is possible the returned identifier does not match the originally
|
|
150
|
+
provided identifier. In this case the abandoned identifier will go through the usual
|
|
151
|
+
`forgetRecordIdentifier` codepaths.
|
|
152
|
+
|
|
153
|
+
@method updateRecordIdentifier
|
|
154
|
+
@param identifierObject
|
|
155
|
+
@param data
|
|
156
|
+
@return {StableRecordIdentifier}
|
|
157
|
+
@public
|
|
158
|
+
*/
|
|
159
|
+
updateRecordIdentifier(identifierObject: RecordIdentifier, data: unknown): StableRecordIdentifier;
|
|
160
|
+
/**
|
|
161
|
+
* @method _mergeRecordIdentifiers
|
|
162
|
+
* @private
|
|
163
|
+
*/
|
|
164
|
+
_mergeRecordIdentifiers(keyInfo: KeyInfo, identifier: StableRecordIdentifier, existingIdentifier: StableRecordIdentifier, data: unknown): StableRecordIdentifier;
|
|
165
|
+
/**
|
|
166
|
+
Provides the opportunity to eliminate an identifier from secondary lookup tables
|
|
167
|
+
as well as eliminates it from ember-data's own lookup tables and book keeping.
|
|
168
|
+
|
|
169
|
+
Useful when a record has been deleted and the deletion has been persisted and
|
|
170
|
+
we do not care about the record anymore. Especially useful when an `id` of a
|
|
171
|
+
deleted record might be reused later for a new record.
|
|
172
|
+
|
|
173
|
+
@method forgetRecordIdentifier
|
|
174
|
+
@param identifierObject
|
|
175
|
+
@public
|
|
176
|
+
*/
|
|
177
|
+
forgetRecordIdentifier(identifierObject: RecordIdentifier): void;
|
|
178
|
+
destroy(): void;
|
|
179
|
+
}
|
|
180
|
+
export {};
|
|
181
|
+
//# sourceMappingURL=identifier-cache.d.ts.map
|
|
182
|
+
}
|