@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.
Files changed (35) hide show
  1. package/package.json +9 -9
  2. package/unstable-preview-types/-private/cache-handler.d.ts +101 -99
  3. package/unstable-preview-types/-private/caches/cache-utils.d.ts +11 -9
  4. package/unstable-preview-types/-private/caches/identifier-cache.d.ts +181 -179
  5. package/unstable-preview-types/-private/caches/instance-cache.d.ts +63 -61
  6. package/unstable-preview-types/-private/caches/resource-utils.d.ts +12 -10
  7. package/unstable-preview-types/-private/document.d.ts +146 -144
  8. package/unstable-preview-types/-private/index.d.ts +18 -16
  9. package/unstable-preview-types/-private/legacy-model-support/record-reference.d.ts +178 -176
  10. package/unstable-preview-types/-private/legacy-model-support/shim-model-class.d.ts +19 -17
  11. package/unstable-preview-types/-private/managers/cache-capabilities-manager.d.ts +29 -27
  12. package/unstable-preview-types/-private/managers/cache-manager.d.ts +442 -440
  13. package/unstable-preview-types/-private/managers/notification-manager.d.ts +98 -96
  14. package/unstable-preview-types/-private/managers/record-array-manager.d.ts +97 -95
  15. package/unstable-preview-types/-private/network/request-cache.d.ts +109 -107
  16. package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts +134 -132
  17. package/unstable-preview-types/-private/store-service.d.ts +1503 -1501
  18. package/unstable-preview-types/-private/utils/coerce-id.d.ts +10 -8
  19. package/unstable-preview-types/-private/utils/construct-resource.d.ts +10 -8
  20. package/unstable-preview-types/-private/utils/identifier-debug-consts.d.ts +7 -5
  21. package/unstable-preview-types/-private/utils/is-non-empty-string.d.ts +4 -2
  22. package/unstable-preview-types/-private/utils/normalize-model-name.d.ts +4 -2
  23. package/unstable-preview-types/-private/utils/uuid-polyfill.d.ts +4 -2
  24. package/unstable-preview-types/-private.d.ts +4 -2
  25. package/unstable-preview-types/-types/overview.d.ts +21 -19
  26. package/unstable-preview-types/-types/q/cache-store-wrapper.d.ts +107 -105
  27. package/unstable-preview-types/-types/q/cache.d.ts +47 -45
  28. package/unstable-preview-types/-types/q/ds-model.d.ts +15 -13
  29. package/unstable-preview-types/-types/q/identifier.d.ts +169 -167
  30. package/unstable-preview-types/-types/q/promise-proxies.d.ts +4 -2
  31. package/unstable-preview-types/-types/q/record-data-json-api.d.ts +36 -34
  32. package/unstable-preview-types/-types/q/record-instance.d.ts +29 -27
  33. package/unstable-preview-types/-types/q/schema-service.d.ts +214 -212
  34. package/unstable-preview-types/-types/q/store.d.ts +17 -15
  35. 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.31",
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.31",
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.31",
49
- "@ember-data/tracking": "5.4.0-alpha.31",
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.17"
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.31",
65
- "@ember-data/tracking": "5.4.0-alpha.31",
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.17",
72
- "@warp-drive/internal-config": "5.4.0-alpha.31",
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
- import type { Handler } from '@ember-data/request/-private/types';
2
- import type { StableDocumentIdentifier } from '@warp-drive/core-types/identifier';
3
- import type { ImmutableRequestInfo, RequestContext, ResponseInfo } from '@warp-drive/core-types/request';
4
- import { EnableHydration } from '@warp-drive/core-types/request';
5
- import type { ResourceIdentifierObject } from '@warp-drive/core-types/spec/raw';
6
- import type Store from './store-service';
7
- /**
8
- * A service which an application may provide to the store via
9
- * the store's `lifetimes` property to configure the behavior
10
- * of the CacheHandler.
11
- *
12
- * The default behavior for request lifetimes is to never expire
13
- * unless manually refreshed via `cacheOptions.reload` or `cacheOptions.backgroundReload`.
14
- *
15
- * Implementing this service allows you to programatically define
16
- * when a request should be considered expired.
17
- *
18
- * @class <Interface> LifetimesService
19
- * @public
20
- */
21
- export interface LifetimesService {
22
- /**
23
- * Invoked to determine if the request may be fulfilled from cache
24
- * if possible.
25
- *
26
- * Note, this is only invoked if the request has a cache-key.
27
- *
28
- * If no cache entry is found or the entry is hard expired,
29
- * the request will be fulfilled from the configured request handlers
30
- * and the cache will be updated before returning the response.
31
- *
32
- * @method isHardExpired
33
- * @public
34
- * @param {StableDocumentIdentifier} identifier
35
- * @param {Store} store
36
- * @return {boolean} true if the request is considered hard expired
37
- */
38
- isHardExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
39
- /**
40
- * Invoked if `isHardExpired` is false to determine if the request
41
- * should be update behind the scenes if cache data is already available.
42
- *
43
- * Note, this is only invoked if the request has a cache-key.
44
- *
45
- * If true, the request will be fulfilled from cache while a backgrounded
46
- * request is made to update the cache via the configured request handlers.
47
- *
48
- * @method isSoftExpired
49
- * @public
50
- * @param {StableDocumentIdentifier} identifier
51
- * @param {Store} store
52
- * @return {boolean} true if the request is considered soft expired
53
- */
54
- isSoftExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
55
- /**
56
- * Invoked when a request will be sent to the configured request handlers.
57
- * This is invoked for both foreground and background requests.
58
- *
59
- * Note, this is invoked regardless of whether the request has a cache-key.
60
- *
61
- * @method willRequest [Optional]
62
- * @public
63
- * @param {ImmutableRequestInfo} request
64
- * @param {StableDocumentIdentifier | null} identifier
65
- * @param {Store} store
66
- * @return {void}
67
- */
68
- willRequest?(request: ImmutableRequestInfo, identifier: StableDocumentIdentifier | null, store: Store): void;
69
- /**
70
- * Invoked when a request has been fulfilled from the configured request handlers.
71
- * This is invoked for both foreground and background requests once the cache has
72
- * been updated.
73
- *
74
- * Note, this is invoked regardless of whether the request has a cache-key.
75
- *
76
- * @method didRequest [Optional]
77
- * @public
78
- * @param {ImmutableRequestInfo} request
79
- * @param {ImmutableResponse} response
80
- * @param {StableDocumentIdentifier | null} identifier
81
- * @param {Store} store
82
- * @return {void}
83
- */
84
- didRequest?(request: ImmutableRequestInfo, response: Response | ResponseInfo | null, identifier: StableDocumentIdentifier | null, store: Store): void;
85
- }
86
- export type StoreRequestInfo = ImmutableRequestInfo;
87
- export type LooseStoreRequestInfo = Omit<StoreRequestInfo, 'records' | 'headers'> & {
88
- records?: ResourceIdentifierObject[];
89
- headers?: Headers;
90
- };
91
- export type StoreRequestInput = StoreRequestInfo | LooseStoreRequestInfo;
92
- export interface StoreRequestContext extends RequestContext {
93
- request: StoreRequestInfo & {
94
- store: Store;
95
- [EnableHydration]?: boolean;
96
- };
97
- }
98
- export declare const CacheHandler: Handler;
99
- //# sourceMappingURL=cache-handler.d.ts.map
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
- import type { StableRecordIdentifier } from '@warp-drive/core-types/identifier';
2
- import type { Cache } from '../../-types/q/cache';
3
- import type { OpaqueRecordInstance } from '../../-types/q/record-instance';
4
- export declare const CacheForIdentifierCache: Map<unknown, Cache>;
5
- export declare function setCacheFor(identifier: StableRecordIdentifier | OpaqueRecordInstance, cache: Cache): void;
6
- export declare function removeRecordDataFor(identifier: StableRecordIdentifier | OpaqueRecordInstance): void;
7
- export default function peekCache(instance: StableRecordIdentifier): Cache | null;
8
- export default function peekCache(instance: OpaqueRecordInstance): Cache;
9
- //# sourceMappingURL=cache-utils.d.ts.map
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
- import { type Identifier, type RecordIdentifier, type StableDocumentIdentifier, type StableRecordIdentifier } from '@warp-drive/core-types/identifier';
2
- import type { ImmutableRequestInfo } from '@warp-drive/core-types/request';
3
- import type { ResourceIdentifierObject } from '@warp-drive/core-types/spec/raw';
4
- import type { ForgetMethod, GenerationMethod, ResetMethod, UpdateMethod } from '../../-types/q/identifier';
5
- export declare function isStableIdentifier(identifier: unknown): identifier is StableRecordIdentifier;
6
- export declare function isDocumentIdentifier(identifier: unknown): identifier is StableDocumentIdentifier;
7
- interface KeyOptions {
8
- lid: IdentifierMap;
9
- id: IdentifierMap;
10
- }
11
- type TypeMap = {
12
- [key: string]: KeyOptions;
13
- };
14
- type IdentifierMap = Map<string, StableRecordIdentifier>;
15
- type KeyInfo = {
16
- id: string | null;
17
- type: string;
18
- };
19
- type StableCache = {
20
- resources: IdentifierMap;
21
- documents: Map<string, StableDocumentIdentifier>;
22
- resourcesByType: TypeMap;
23
- polymorphicLidBackMap: Map<string, string[]>;
24
- };
25
- export type KeyInfoMethod = (resource: unknown, known: StableRecordIdentifier | null) => KeyInfo;
26
- export type MergeMethod = (targetIdentifier: StableRecordIdentifier, matchedIdentifier: StableRecordIdentifier, resourceData: unknown) => StableRecordIdentifier;
27
- export declare function setIdentifierGenerationMethod(method: GenerationMethod | null): void;
28
- export declare function setIdentifierUpdateMethod(method: UpdateMethod | null): void;
29
- export declare function setIdentifierForgetMethod(method: ForgetMethod | null): void;
30
- export declare function setIdentifierResetMethod(method: ResetMethod | null): void;
31
- export declare function setKeyInfoForResource(method: KeyInfoMethod | null): void;
32
- /**
33
- * Each instance of {Store} receives a unique instance of a IdentifierCache.
34
- *
35
- * This cache is responsible for assigning or retrieving the unique identify
36
- * for arbitrary resource data encountered by the store. Data representing
37
- * a unique resource or record should always be represented by the same
38
- * identifier.
39
- *
40
- * It can be configured by consuming applications.
41
- *
42
- * @class IdentifierCache
43
- @public
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
- createIdentifierForNewRecord(data: {
133
- type: string;
134
- id?: string | null;
135
- }): StableRecordIdentifier;
136
- /**
137
- Provides the opportunity to update secondary lookup tables for existing identifiers
138
- Called after an identifier created with `createIdentifierForNewRecord` has been
139
- committed.
140
-
141
- Assigned `id` to an `Identifier` if `id` has not previously existed; however,
142
- attempting to change the `id` or calling update without providing an `id` when
143
- one is missing will throw an error.
144
-
145
- - sets `id` (if `id` was previously `null`)
146
- - `lid` and `type` MUST NOT be altered post creation
147
-
148
- If a merge occurs, it is possible the returned identifier does not match the originally
149
- provided identifier. In this case the abandoned identifier will go through the usual
150
- `forgetRecordIdentifier` codepaths.
151
-
152
- @method updateRecordIdentifier
153
- @param identifierObject
154
- @param data
155
- @return {StableRecordIdentifier}
156
- @public
157
- */
158
- updateRecordIdentifier(identifierObject: RecordIdentifier, data: unknown): StableRecordIdentifier;
159
- /**
160
- * @method _mergeRecordIdentifiers
161
- * @private
162
- */
163
- _mergeRecordIdentifiers(keyInfo: KeyInfo, identifier: StableRecordIdentifier, existingIdentifier: StableRecordIdentifier, data: unknown): StableRecordIdentifier;
164
- /**
165
- Provides the opportunity to eliminate an identifier from secondary lookup tables
166
- as well as eliminates it from ember-data's own lookup tables and book keeping.
167
-
168
- Useful when a record has been deleted and the deletion has been persisted and
169
- we do not care about the record anymore. Especially useful when an `id` of a
170
- deleted record might be reused later for a new record.
171
-
172
- @method forgetRecordIdentifier
173
- @param identifierObject
174
- @public
175
- */
176
- forgetRecordIdentifier(identifierObject: RecordIdentifier): void;
177
- destroy(): void;
178
- }
179
- export {};
180
- //# sourceMappingURL=identifier-cache.d.ts.map
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
+ }