@ember-data/store 5.4.0-alpha.30 → 5.4.0-alpha.32
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/addon/cache-handler-oB00-31L.js.map +1 -1
- package/package.json +11 -10
- package/unstable-preview-types/-private/cache-handler.d.ts +99 -0
- package/unstable-preview-types/-private/cache-handler.d.ts.map +1 -0
- package/unstable-preview-types/-private/caches/cache-utils.d.ts +9 -0
- package/unstable-preview-types/-private/caches/cache-utils.d.ts.map +1 -0
- package/unstable-preview-types/-private/caches/identifier-cache.d.ts +180 -0
- package/unstable-preview-types/-private/caches/identifier-cache.d.ts.map +1 -0
- package/unstable-preview-types/-private/caches/instance-cache.d.ts +61 -0
- package/unstable-preview-types/-private/caches/instance-cache.d.ts.map +1 -0
- package/unstable-preview-types/-private/caches/resource-utils.d.ts +10 -0
- package/unstable-preview-types/-private/caches/resource-utils.d.ts.map +1 -0
- package/unstable-preview-types/-private/document.d.ts +144 -0
- package/unstable-preview-types/-private/document.d.ts.map +1 -0
- package/unstable-preview-types/-private/index.d.ts +16 -0
- package/unstable-preview-types/-private/index.d.ts.map +1 -0
- package/unstable-preview-types/-private/legacy-model-support/record-reference.d.ts +177 -0
- package/unstable-preview-types/-private/legacy-model-support/record-reference.d.ts.map +1 -0
- package/unstable-preview-types/-private/legacy-model-support/shim-model-class.d.ts +17 -0
- package/unstable-preview-types/-private/legacy-model-support/shim-model-class.d.ts.map +1 -0
- package/unstable-preview-types/-private/managers/cache-capabilities-manager.d.ts +27 -0
- package/unstable-preview-types/-private/managers/cache-capabilities-manager.d.ts.map +1 -0
- package/unstable-preview-types/-private/managers/cache-manager.d.ts +440 -0
- package/unstable-preview-types/-private/managers/cache-manager.d.ts.map +1 -0
- package/unstable-preview-types/-private/managers/notification-manager.d.ts +96 -0
- package/unstable-preview-types/-private/managers/notification-manager.d.ts.map +1 -0
- package/unstable-preview-types/-private/managers/record-array-manager.d.ts +95 -0
- package/unstable-preview-types/-private/managers/record-array-manager.d.ts.map +1 -0
- package/unstable-preview-types/-private/network/request-cache.d.ts +107 -0
- package/unstable-preview-types/-private/network/request-cache.d.ts.map +1 -0
- package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts +135 -0
- package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts.map +1 -0
- package/unstable-preview-types/-private/store-service.d.ts +1552 -0
- package/unstable-preview-types/-private/store-service.d.ts.map +1 -0
- package/unstable-preview-types/-private/utils/coerce-id.d.ts +8 -0
- package/unstable-preview-types/-private/utils/coerce-id.d.ts.map +1 -0
- package/unstable-preview-types/-private/utils/construct-resource.d.ts +8 -0
- package/unstable-preview-types/-private/utils/construct-resource.d.ts.map +1 -0
- package/unstable-preview-types/-private/utils/identifier-debug-consts.d.ts +5 -0
- package/unstable-preview-types/-private/utils/identifier-debug-consts.d.ts.map +1 -0
- package/unstable-preview-types/-private/utils/is-non-empty-string.d.ts +2 -0
- package/unstable-preview-types/-private/utils/is-non-empty-string.d.ts.map +1 -0
- package/unstable-preview-types/-private/utils/normalize-model-name.d.ts +2 -0
- package/unstable-preview-types/-private/utils/normalize-model-name.d.ts.map +1 -0
- package/unstable-preview-types/-private/utils/uuid-polyfill.d.ts +2 -0
- package/unstable-preview-types/-private/utils/uuid-polyfill.d.ts.map +1 -0
- package/unstable-preview-types/-private.d.ts +2 -0
- package/unstable-preview-types/-private.d.ts.map +1 -0
- package/unstable-preview-types/-types/overview.d.ts +19 -0
- package/unstable-preview-types/-types/overview.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/cache-store-wrapper.d.ts +105 -0
- package/unstable-preview-types/-types/q/cache-store-wrapper.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/cache.d.ts +45 -0
- package/unstable-preview-types/-types/q/cache.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/ds-model.d.ts +13 -0
- package/unstable-preview-types/-types/q/ds-model.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/identifier.d.ts +169 -0
- package/unstable-preview-types/-types/q/identifier.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/promise-proxies.d.ts +2 -0
- package/unstable-preview-types/-types/q/promise-proxies.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/record-data-json-api.d.ts +34 -0
- package/unstable-preview-types/-types/q/record-data-json-api.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/record-instance.d.ts +27 -0
- package/unstable-preview-types/-types/q/record-instance.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/schema-service.d.ts +212 -0
- package/unstable-preview-types/-types/q/schema-service.d.ts.map +1 -0
- package/unstable-preview-types/-types/q/store.d.ts +15 -0
- package/unstable-preview-types/-types/q/store.d.ts.map +1 -0
- package/unstable-preview-types/index.d.ts +185 -0
- package/unstable-preview-types/index.d.ts.map +1 -0
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.32",
|
|
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"
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "Chris Thoburn <runspired@users.noreply.github.com>",
|
|
15
15
|
"files": [
|
|
16
|
+
"unstable-preview-types",
|
|
16
17
|
"addon-main.js",
|
|
17
18
|
"addon",
|
|
18
19
|
"README.md",
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
"ember-data-logo-light.svg"
|
|
22
23
|
],
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@ember-data/private-build-infra": "5.4.0-alpha.
|
|
25
|
+
"@ember-data/private-build-infra": "5.4.0-alpha.32",
|
|
25
26
|
"@embroider/macros": "^1.13.5",
|
|
26
27
|
"ember-cli-babel": "^8.2.0",
|
|
27
28
|
"pnpm-sync-dependencies-meta-injected": "0.0.10"
|
|
@@ -44,10 +45,10 @@
|
|
|
44
45
|
}
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"@ember-data/request": "5.4.0-alpha.
|
|
48
|
-
"@ember-data/tracking": "5.4.0-alpha.
|
|
48
|
+
"@ember-data/request": "5.4.0-alpha.32",
|
|
49
|
+
"@ember-data/tracking": "5.4.0-alpha.32",
|
|
49
50
|
"@ember/string": "^3.1.1",
|
|
50
|
-
"@warp-drive/core-types": "0.0.0-alpha.
|
|
51
|
+
"@warp-drive/core-types": "0.0.0-alpha.18"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"@babel/cli": "^7.23.9",
|
|
@@ -60,15 +61,15 @@
|
|
|
60
61
|
"@babel/preset-env": "^7.23.9",
|
|
61
62
|
"@babel/preset-typescript": "^7.23.3",
|
|
62
63
|
"@babel/runtime": "^7.23.9",
|
|
63
|
-
"@ember-data/request": "5.4.0-alpha.
|
|
64
|
-
"@ember-data/tracking": "5.4.0-alpha.
|
|
64
|
+
"@ember-data/request": "5.4.0-alpha.32",
|
|
65
|
+
"@ember-data/tracking": "5.4.0-alpha.32",
|
|
65
66
|
"@ember/string": "^3.1.1",
|
|
66
67
|
"@embroider/addon-dev": "^4.1.2",
|
|
67
68
|
"@glimmer/component": "^1.1.2",
|
|
68
69
|
"@rollup/plugin-babel": "^6.0.4",
|
|
69
70
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
70
|
-
"@warp-drive/core-types": "0.0.0-alpha.
|
|
71
|
-
"@warp-drive/internal-config": "5.4.0-alpha.
|
|
71
|
+
"@warp-drive/core-types": "0.0.0-alpha.18",
|
|
72
|
+
"@warp-drive/internal-config": "5.4.0-alpha.32",
|
|
72
73
|
"ember-source": "~5.6.0",
|
|
73
74
|
"rollup": "^4.9.6",
|
|
74
75
|
"typescript": "^5.3.3",
|
|
@@ -93,7 +94,7 @@
|
|
|
93
94
|
"scripts": {
|
|
94
95
|
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
|
|
95
96
|
"build:runtime": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
|
|
96
|
-
"build:types": "
|
|
97
|
+
"build:types": "tsc --build",
|
|
97
98
|
"_build": "bun run build:runtime && bun run build:types",
|
|
98
99
|
"_syncPnpm": "bun run sync-dependencies-meta-injected"
|
|
99
100
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-handler.d.ts","sourceRoot":"","sources":["../../src/-private/cache-handler.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAU,OAAO,EAAU,MAAM,oCAAoC,CAAC;AAClF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,KAAK,EAGV,oBAAoB,EAEpB,cAAc,EACd,YAAY,EAGb,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,eAAe,EAAa,MAAM,gCAAgC,CAAC;AAO5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAIhF,OAAO,KAAK,KAAK,MAAM,iBAAiB,CA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{ 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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-utils.d.ts","sourceRoot":"","sources":["../../../src/-private/caches/cache-utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAEhF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAO3E,eAAO,MAAM,uBAAuB,qBAAkE,CAAC;AAEvG,wBAAgB,WAAW,CAAC,UAAU,EAAE,sBAAsB,GAAG,oBAAoB,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAMzG;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,sBAAsB,GAAG,oBAAoB,GAAG,IAAI,CAEnG;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,QAAQ,EAAE,sBAAsB,GAAG,KAAK,GAAG,IAAI,CAAC;AAClF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,QAAQ,EAAE,oBAAoB,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
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}
|
|
130
|
+
@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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifier-cache.d.ts","sourceRoot":"","sources":["../../../src/-private/caches/identifier-cache.ts"],"names":[],"mappings":"AASA,OAAO,EAKL,KAAK,UAAU,EAEf,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAE7B,KAAK,sBAAsB,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,KAAK,EAA0B,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAExG,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,WAAW,EAEX,YAAY,EACb,MAAM,2BAA2B,CAAC;AASnC,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,IAAI,sBAAsB,CAE5F;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,IAAI,wBAAwB,CAEhG;AAwBD,UAAU,UAAU;IAClB,GAAG,EAAE,aAAa,CAAC;IACnB,EAAE,EAAE,aAAa,CAAC;CACnB;AACD,KAAK,OAAO,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,CAAC;AAI7C,KAAK,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;AACzD,KAAK,OAAO,GAAG;IACb,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,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E,sBAAsB,EAC1C,IAAI,EAAE,OAAO,GACZ,sBAAsB;IAoCzB;;;;;;;;;;;MAWE;IACF,sBAAsB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI;IA+BhE,OAAO;CAOR"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { RecordIdentifier, StableRecordIdentifier } from '@warp-drive/core-types/identifier';
|
|
2
|
+
import type { Value } from '@warp-drive/core-types/json/raw';
|
|
3
|
+
import type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core-types/record';
|
|
4
|
+
import type { Cache } from '../../-types/q/cache';
|
|
5
|
+
import type { OpaqueRecordInstance } from '../../-types/q/record-instance';
|
|
6
|
+
import RecordReference from '../legacy-model-support/record-reference';
|
|
7
|
+
import { CacheCapabilitiesManager } from '../managers/cache-capabilities-manager';
|
|
8
|
+
import type { CacheManager } from '../managers/cache-manager';
|
|
9
|
+
import type { CreateRecordProperties } from '../store-service';
|
|
10
|
+
import type Store from '../store-service';
|
|
11
|
+
export declare function peekRecordIdentifier(record: OpaqueRecordInstance): StableRecordIdentifier | undefined;
|
|
12
|
+
/**
|
|
13
|
+
Retrieves the unique referentially-stable [RecordIdentifier](/ember-data/release/classes/StableRecordIdentifier)
|
|
14
|
+
assigned to the given record instance.
|
|
15
|
+
```js
|
|
16
|
+
import { recordIdentifierFor } from "@ember-data/store";
|
|
17
|
+
// ... gain access to a record, for instance with peekRecord or findRecord
|
|
18
|
+
const record = store.peekRecord("user", "1");
|
|
19
|
+
// get the identifier for the record (see docs for StableRecordIdentifier)
|
|
20
|
+
const identifier = recordIdentifierFor(record);
|
|
21
|
+
// access the identifier's properties.
|
|
22
|
+
const { id, type, lid } = identifier;
|
|
23
|
+
```
|
|
24
|
+
@method recordIdentifierFor
|
|
25
|
+
@public
|
|
26
|
+
@static
|
|
27
|
+
@for @ember-data/store
|
|
28
|
+
@param {Object} record a record instance previously obstained from the store.
|
|
29
|
+
@return {StableRecordIdentifier}
|
|
30
|
+
*/
|
|
31
|
+
export declare function recordIdentifierFor<T extends TypedRecordInstance>(record: T): StableRecordIdentifier<TypeFromInstance<T>>;
|
|
32
|
+
export declare function recordIdentifierFor(record: OpaqueRecordInstance): StableRecordIdentifier;
|
|
33
|
+
export declare function setRecordIdentifier(record: OpaqueRecordInstance, identifier: StableRecordIdentifier): void;
|
|
34
|
+
export declare const StoreMap: Map<unknown, Store>;
|
|
35
|
+
export declare function storeFor(record: OpaqueRecordInstance): Store | undefined;
|
|
36
|
+
type Caches = {
|
|
37
|
+
record: Map<StableRecordIdentifier, OpaqueRecordInstance>;
|
|
38
|
+
reference: WeakMap<StableRecordIdentifier, RecordReference>;
|
|
39
|
+
};
|
|
40
|
+
export declare class InstanceCache {
|
|
41
|
+
store: Store;
|
|
42
|
+
cache: Cache;
|
|
43
|
+
_storeWrapper: CacheCapabilitiesManager;
|
|
44
|
+
__cacheFor: (resource: RecordIdentifier) => Cache;
|
|
45
|
+
__cacheManager: CacheManager;
|
|
46
|
+
__instances: Caches;
|
|
47
|
+
constructor(store: Store);
|
|
48
|
+
peek(identifier: StableRecordIdentifier): Cache | OpaqueRecordInstance | undefined;
|
|
49
|
+
getRecord(identifier: StableRecordIdentifier, properties?: CreateRecordProperties): OpaqueRecordInstance;
|
|
50
|
+
getReference(identifier: StableRecordIdentifier): RecordReference;
|
|
51
|
+
recordIsLoaded(identifier: StableRecordIdentifier, filterDeleted?: boolean): boolean;
|
|
52
|
+
disconnect(identifier: StableRecordIdentifier): void;
|
|
53
|
+
unloadRecord(identifier: StableRecordIdentifier): void;
|
|
54
|
+
clear(type?: string): void;
|
|
55
|
+
setRecordId(identifier: StableRecordIdentifier, id: string): void;
|
|
56
|
+
}
|
|
57
|
+
export declare function resourceIsFullyDeleted(instanceCache: InstanceCache, identifier: StableRecordIdentifier): boolean;
|
|
58
|
+
export declare function preloadData(store: Store, identifier: StableRecordIdentifier, preload: Record<string, Value>): void;
|
|
59
|
+
export declare function _clearCaches(): void;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=instance-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-cache.d.ts","sourceRoot":"","sources":["../../../src/-private/caches/instance-cache.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAClG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAA4B,MAAM,+BAA+B,CAAC;AAIrH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,eAAe,MAAM,0CAA0C,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAoB1C,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,sBAAsB,GAAG,SAAS,CAErG;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,mBAAmB,EAC/D,MAAM,EAAE,CAAC,GACR,sBAAsB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,oBAAoB,GAAG,sBAAsB,CAAC;AAM1F,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,oBAAoB,EAAE,UAAU,EAAE,sBAAsB,GAAG,IAAI,CAgB1G;AAED,eAAO,MAAM,QAAQ,qBAAyC,CAAC;AAE/D,wBAAgB,QAAQ,CAAC,MAAM,EA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function hasLid(resource: unknown): resource is {
|
|
2
|
+
lid: string;
|
|
3
|
+
};
|
|
4
|
+
export declare function hasId(resource: unknown): resource is {
|
|
5
|
+
id: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function hasType(resource: unknown): resource is {
|
|
8
|
+
type: string;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=resource-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-utils.d.ts","sourceRoot":"","sources":["../../../src/-private/caches/resource-utils.ts"],"names":[],"mappings":"AAUA,wBAAgB,MAAM,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAErE;AAED,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAInE;AAED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAEvE"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { StableDocumentIdentifier } from '@warp-drive/core-types/identifier';
|
|
2
|
+
import type { RequestInfo } from '@warp-drive/core-types/request';
|
|
3
|
+
import type { Meta, PaginationLinks } from '@warp-drive/core-types/spec/raw';
|
|
4
|
+
import type Store from './store-service';
|
|
5
|
+
/**
|
|
6
|
+
* A Document is a class that wraps the response content from a request to the API
|
|
7
|
+
* returned by `Cache.put` or `Cache.peek`, converting resource-identifiers into
|
|
8
|
+
* record instances.
|
|
9
|
+
*
|
|
10
|
+
* It is not directly instantiated by the user, and its properties should not
|
|
11
|
+
* be directly modified. Whether individual properties are mutable or not is
|
|
12
|
+
* determined by the record instance itself.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
* @class Document
|
|
16
|
+
*/
|
|
17
|
+
export declare class Document<T> {
|
|
18
|
+
#private;
|
|
19
|
+
/**
|
|
20
|
+
* The links object for this document, if any
|
|
21
|
+
*
|
|
22
|
+
* e.g.
|
|
23
|
+
*
|
|
24
|
+
* ```
|
|
25
|
+
* {
|
|
26
|
+
* self: '/articles?page[number]=3',
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @property links
|
|
31
|
+
* @type {object|undefined} - a links object
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
links?: PaginationLinks;
|
|
35
|
+
/**
|
|
36
|
+
* The primary data for this document, if any.
|
|
37
|
+
*
|
|
38
|
+
* If this document has no primary data (e.g. because it is an error document)
|
|
39
|
+
* this property will be `undefined`.
|
|
40
|
+
*
|
|
41
|
+
* For collections this will be an array of record instances,
|
|
42
|
+
* for single resource requests it will be a single record instance or null.
|
|
43
|
+
*
|
|
44
|
+
* @property data
|
|
45
|
+
* @public
|
|
46
|
+
* @type {object|Array<object>|null|undefined} - a data object
|
|
47
|
+
*/
|
|
48
|
+
data?: T;
|
|
49
|
+
/**
|
|
50
|
+
* The errors returned by the API for this request, if any
|
|
51
|
+
*
|
|
52
|
+
* @property errors
|
|
53
|
+
* @public
|
|
54
|
+
* @type {object|undefined} - an errors object
|
|
55
|
+
*/
|
|
56
|
+
errors?: object[];
|
|
57
|
+
/**
|
|
58
|
+
* The meta object for this document, if any
|
|
59
|
+
*
|
|
60
|
+
* @property meta
|
|
61
|
+
* @public
|
|
62
|
+
* @type {object|undefined} - a meta object
|
|
63
|
+
*/
|
|
64
|
+
meta?: Meta;
|
|
65
|
+
/**
|
|
66
|
+
* The identifier associated with this document, if any
|
|
67
|
+
*
|
|
68
|
+
* @property identifier
|
|
69
|
+
* @public
|
|
70
|
+
* @type {StableDocumentIdentifier|null}
|
|
71
|
+
*/
|
|
72
|
+
identifier: StableDocumentIdentifier | null;
|
|
73
|
+
constructor(store: Store, identifier: StableDocumentIdentifier | null);
|
|
74
|
+
/**
|
|
75
|
+
* Fetches the related link for this document, returning a promise that resolves
|
|
76
|
+
* with the document when the request completes. If no related link is present,
|
|
77
|
+
* will fallback to the self link if present
|
|
78
|
+
*
|
|
79
|
+
* @method fetch
|
|
80
|
+
* @public
|
|
81
|
+
* @param {object} options
|
|
82
|
+
* @return Promise<Document>
|
|
83
|
+
*/
|
|
84
|
+
fetch(options?: Partial<RequestInfo>): Promise<Document<T>>;
|
|
85
|
+
/**
|
|
86
|
+
* Fetches the next link for this document, returning a promise that resolves
|
|
87
|
+
* with the new document when the request completes, or null if there is no
|
|
88
|
+
* next link.
|
|
89
|
+
*
|
|
90
|
+
* @method next
|
|
91
|
+
* @public
|
|
92
|
+
* @param {object} options
|
|
93
|
+
* @return Promise<Document | null>
|
|
94
|
+
*/
|
|
95
|
+
next(options?: Partial<RequestInfo>): Promise<Document<T> | null>;
|
|
96
|
+
/**
|
|
97
|
+
* Fetches the prev link for this document, returning a promise that resolves
|
|
98
|
+
* with the new document when the request completes, or null if there is no
|
|
99
|
+
* prev link.
|
|
100
|
+
*
|
|
101
|
+
* @method prev
|
|
102
|
+
* @public
|
|
103
|
+
* @param {object} options
|
|
104
|
+
* @return Promise<Document | null>
|
|
105
|
+
*/
|
|
106
|
+
prev(options?: Partial<RequestInfo>): Promise<Document<T> | null>;
|
|
107
|
+
/**
|
|
108
|
+
* Fetches the first link for this document, returning a promise that resolves
|
|
109
|
+
* with the new document when the request completes, or null if there is no
|
|
110
|
+
* first link.
|
|
111
|
+
*
|
|
112
|
+
* @method first
|
|
113
|
+
* @public
|
|
114
|
+
* @param {object} options
|
|
115
|
+
* @return Promise<Document | null>
|
|
116
|
+
*/
|
|
117
|
+
first(options?: Partial<RequestInfo>): Promise<Document<T> | null>;
|
|
118
|
+
/**
|
|
119
|
+
* Fetches the last link for this document, returning a promise that resolves
|
|
120
|
+
* with the new document when the request completes, or null if there is no
|
|
121
|
+
* last link.
|
|
122
|
+
*
|
|
123
|
+
* @method last
|
|
124
|
+
* @public
|
|
125
|
+
* @param {object} options
|
|
126
|
+
* @return Promise<Document | null>
|
|
127
|
+
*/
|
|
128
|
+
last(options?: Partial<RequestInfo>): Promise<Document<T> | null>;
|
|
129
|
+
/**
|
|
130
|
+
* Implemented for `JSON.stringify` support.
|
|
131
|
+
*
|
|
132
|
+
* Returns the JSON representation of the document wrapper.
|
|
133
|
+
*
|
|
134
|
+
* This is a shallow serialization, it does not deeply serialize
|
|
135
|
+
* the document's contents, leaving that to the individual record
|
|
136
|
+
* instances to determine how to do, if at all.
|
|
137
|
+
*
|
|
138
|
+
* @method toJSON
|
|
139
|
+
* @public
|
|
140
|
+
* @return
|
|
141
|
+
*/
|
|
142
|
+
toJSON(): object;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/-private/document.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,KAAK,EAAQ,IAAI,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEnF,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAC;AAOzC;;;;;;;;;;;GAWG;AACH,qBAAa,QAAQ,CAAC,CAAC;;IACrB;;;;;;;;;;;;;;OAcG;IACK,KAAK,CAAC,EAAE,eAAe,CAAC;IAChC;;;;;;;;;;;;OAYG;IACK,IAAI,CAAC,EAAE,CAAC,CAAC;IAEjB;;;;;;OAMG;IACK,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B;;;;;;OAMG;IACK,IAAI,CAAC,EAAE,IAAI,CAAC;IAEpB;;;;;;OAMG;IACK,UAAU,EAAE,wBAAwB,GAAG,IAAI,CAAC;gBAGxC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,wBAAwB,GAAG,IAAI;IAiBrE;;;;;;;;;OASG;IACH,KAAK,CAAC,OAAO,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAO/D;;;;;;;;;OASG;IACH,IAAI,CAAC,OAAO,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAIrE;;;;;;;;;OASG;IACH,IAAI,CAAC,OAAO,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAIrE;;;;;;;;;OASG;IACH,KAAK,CAAC,OAAO,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAItE;;;;;;;;;OASG;IACH,IAAI,CAAC,OAAO,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAIrE;;;;;;;;;;;;OAYG;IACH,MAAM,IAAI,MAAM;CAiBjB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@module @ember-data/store
|
|
3
|
+
*/
|
|
4
|
+
export { default as Store, storeFor } from './store-service';
|
|
5
|
+
export { recordIdentifierFor } from './caches/instance-cache';
|
|
6
|
+
export { CacheHandler, type LifetimesService } from './cache-handler';
|
|
7
|
+
export { setIdentifierGenerationMethod, setIdentifierUpdateMethod, setIdentifierForgetMethod, setIdentifierResetMethod, isStableIdentifier, } from './caches/identifier-cache';
|
|
8
|
+
export { default as coerceId } from './utils/coerce-id';
|
|
9
|
+
export { default as RecordArray, default as IdentifierArray, Collection as AdapterPopulatedRecordArray, notifyArray, SOURCE, MUTATE, ARRAY_SIGNAL, } from './record-arrays/identifier-array';
|
|
10
|
+
export { default as RecordArrayManager, fastPush } from './managers/record-array-manager';
|
|
11
|
+
export { _clearCaches } from './caches/instance-cache';
|
|
12
|
+
export { default as peekCache, removeRecordDataFor } from './caches/cache-utils';
|
|
13
|
+
export { setRecordIdentifier, StoreMap } from './caches/instance-cache';
|
|
14
|
+
export { setCacheFor } from './caches/cache-utils';
|
|
15
|
+
export { default as _deprecatingNormalize } from './utils/normalize-model-name';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/-private/index.ts"],"names":[],"mappings":"AAAA;;EAEE;AAEF,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EACL,OAAO,IAAI,WAAW,EACtB,OAAO,IAAI,eAAe,EAC1B,UAAU,IAAI,2BAA2B,EACzC,WAAW,EACX,MAAM,EACN,MAAM,EACN,YAAY,GACb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAG1F,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGjF,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,8BAA8B,CAAC"}
|