@ember-data/store 5.9.0-alpha.21 → 5.9.0-alpha.22
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/dist/-private.d.ts +1 -0
- package/dist/-private.js +1 -1
- package/dist/configure.d.ts +2 -0
- package/dist/configure.js +3 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +216 -192
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +0 -1
- package/package.json +12 -11
- package/unstable-preview-types/-private.d.ts +0 -1
- package/unstable-preview-types/configure.d.ts +2 -15
- package/unstable-preview-types/index.d.ts +2 -4
- package/unstable-preview-types/types.d.ts +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@warp-drive/core/store/-private";
|
package/dist/-private.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "@warp-drive/core/store/-private"
|
package/dist/configure.js
CHANGED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { CacheHandler, CacheOperation, CachePolicy, Document, DocumentCacheOperation, NotificationType, Store, StoreRequestContext, StoreRequestInput, recordIdentifierFor, setIdentifierForgetMethod, setIdentifierGenerationMethod, setIdentifierResetMethod, setIdentifierUpdateMethod, setKeyInfoForResource, storeFor } from "@warp-drive/core";
|
|
2
|
+
export { CacheHandler, type CacheOperation, type CachePolicy, type Document, type DocumentCacheOperation, type NotificationType, type StoreRequestContext, type StoreRequestInput, Store as default, recordIdentifierFor, setIdentifierForgetMethod, setIdentifierGenerationMethod, setIdentifierResetMethod, setIdentifierUpdateMethod, setKeyInfoForResource, storeFor };
|
package/dist/index.js
CHANGED
|
@@ -1,196 +1,220 @@
|
|
|
1
|
-
import { deprecate } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { setupSignals } from
|
|
5
|
-
import { peekTransient } from
|
|
1
|
+
import { deprecate } from "@ember/debug";
|
|
2
|
+
import { dependencySatisfies, getGlobalConfig, importSync, macroCondition } from "@embroider/macros";
|
|
3
|
+
import { CacheHandler, Store, recordIdentifierFor, setIdentifierForgetMethod, setIdentifierGenerationMethod, setIdentifierResetMethod, setIdentifierUpdateMethod, setKeyInfoForResource, storeFor } from "@warp-drive/core";
|
|
4
|
+
import { setupSignals } from "@warp-drive/core/configure";
|
|
5
|
+
import { peekTransient } from "@warp-drive/core/types/-private";
|
|
6
6
|
|
|
7
|
+
//#region src/index.ts
|
|
7
8
|
/**
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
9
|
+
* This package provides [*Ember***Data**](https://github.com/warp-drive-data/warp-drive/)'s `Store` class.
|
|
10
|
+
*
|
|
11
|
+
* A {@link Store} coordinates interaction between your application, a {@link Cache},
|
|
12
|
+
* and sources of data (such as your API or a local persistence layer) accessed via a {@link RequestManager}.
|
|
13
|
+
*
|
|
14
|
+
* Optionally, a Store can be configured to hydrate the response data into rich presentation classes.
|
|
15
|
+
*
|
|
16
|
+
* ## 🔨 Creating A Store
|
|
17
|
+
*
|
|
18
|
+
* To use a `Store` we will need to do few things: add a {@link Cache}
|
|
19
|
+
* to store data **in-memory**, add a {@link Handler} to fetch data from a source,
|
|
20
|
+
* and implement `instantiateRecord` to tell the store how to display the data for individual resources.
|
|
21
|
+
*
|
|
22
|
+
* > **Note**
|
|
23
|
+
* > If you are using the package `ember-data` then a JSON:API cache, RequestManager, LegacyNetworkHandler,
|
|
24
|
+
* > and `instantiateRecord` are configured for you by default.
|
|
25
|
+
*
|
|
26
|
+
* ### Configuring A Cache
|
|
27
|
+
*
|
|
28
|
+
* To start, let's install a [JSON:API](https://jsonapi.org/) cache. If your app uses `GraphQL` or `REST` other
|
|
29
|
+
* caches may better fit your data. You can author your own cache by creating one that
|
|
30
|
+
* conforms to the {@link Cache | spec}.
|
|
31
|
+
*
|
|
32
|
+
* The package `@ember-data/json-api` provides a [JSON:API](https://jsonapi.org/) cache we can use.
|
|
33
|
+
* After installing it, we can configure the store to use this cache.
|
|
34
|
+
*
|
|
35
|
+
* ```js
|
|
36
|
+
* import Store from '@ember-data/store';
|
|
37
|
+
* import Cache from '@ember-data/json-api';
|
|
38
|
+
*
|
|
39
|
+
* class extends Store {
|
|
40
|
+
* createCache(storeWrapper) {
|
|
41
|
+
* return new Cache(storeWrapper);
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* Now that we have a `cache` let's setup something to handle fetching
|
|
47
|
+
* and saving data via our API.
|
|
48
|
+
*
|
|
49
|
+
* > **Note**
|
|
50
|
+
* > The `ember-data` package automatically includes and configures
|
|
51
|
+
* > the `@ember-data/json-api` cache for you.
|
|
52
|
+
*
|
|
53
|
+
* ### Handling Requests
|
|
54
|
+
*
|
|
55
|
+
* When *Ember***Data** needs to fetch or save data it will pass that request to your application's `RequestManager` for fulfillment. How this fulfillment occurs (in-memory, device storage, via single or multiple API requests, etc.) is then up to the registered request handlers.
|
|
56
|
+
*
|
|
57
|
+
* To start, let's install the `RequestManager` from `@ember-data/request` and the basic `Fetch` handler from ``@ember-data/request/fetch`.
|
|
58
|
+
*
|
|
59
|
+
* > **Note**
|
|
60
|
+
* > If your app uses `GraphQL`, `REST` or different conventions for `JSON:API` than your cache expects, other handlers may better fit your data. You can author your own handler by creating one that conforms to the [handler interface](https://github.com/warp-drive-data/warp-drive/tree/main/packages/request#handling-requests).
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* import Store from '@ember-data/store';
|
|
64
|
+
* import RequestManager from '@ember-data/request';
|
|
65
|
+
* import Fetch from '@ember-data/request/fetch';
|
|
66
|
+
*
|
|
67
|
+
* export default class extends Store {
|
|
68
|
+
* requestManager = new RequestManager()
|
|
69
|
+
* .use([Fetch]);
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* **Using RequestManager as a Service**
|
|
74
|
+
*
|
|
75
|
+
* Alternatively if you have configured the `RequestManager` to be a service you may re-use it.
|
|
76
|
+
*
|
|
77
|
+
* *app/services/request.js*
|
|
78
|
+
* ```ts
|
|
79
|
+
* import RequestManager from '@ember-data/request';
|
|
80
|
+
* import Fetch from '@ember-data/request/fetch';
|
|
81
|
+
*
|
|
82
|
+
* export default {
|
|
83
|
+
* create() {
|
|
84
|
+
* return new RequestManager()
|
|
85
|
+
* .use([Fetch])
|
|
86
|
+
* .useCache(CacheHandler);
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* *app/services/store.js*
|
|
92
|
+
* ```ts
|
|
93
|
+
* import Store from '@ember-data/store';
|
|
94
|
+
* import { service } from '@ember/service';
|
|
95
|
+
*
|
|
96
|
+
* export default class extends Store {
|
|
97
|
+
* @service('request') requestManager
|
|
98
|
+
* }
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
*
|
|
102
|
+
* ### Presenting Data from the Cache
|
|
103
|
+
*
|
|
104
|
+
* Now that we have a source and a cache for our data, we need to configure how
|
|
105
|
+
* the Store delivers that data back to our application. We do this via the {@link Store.instantiateRecord | instantiateRecord hook}
|
|
106
|
+
* which allows us to transform the data for a resource before handing it to the application.
|
|
107
|
+
*
|
|
108
|
+
* A naive way to present the data would be to return it as JSON. Typically instead
|
|
109
|
+
* this hook will be used to add reactivity and make each unique resource a singleton,
|
|
110
|
+
* ensuring that if the cache updates our presented data will reflect the new state.
|
|
111
|
+
*
|
|
112
|
+
* Below is an example of using the hooks `instantiateRecord` and a `teardownRecord`
|
|
113
|
+
* to provide minimal read-only reactive state for simple resources.
|
|
114
|
+
*
|
|
115
|
+
* ```ts
|
|
116
|
+
* import Store, { recordIdentifierFor } from '@ember-data/store';
|
|
117
|
+
* import { TrackedObject } from 'tracked-built-ins';
|
|
118
|
+
*
|
|
119
|
+
* class extends Store {
|
|
120
|
+
* instantiateRecord(identifier) {
|
|
121
|
+
* const { cache, notifications } = this;
|
|
122
|
+
*
|
|
123
|
+
* // create a TrackedObject with our attributes, id and type
|
|
124
|
+
* const record = new TrackedObject(Object.assign({}, cache.peek(identifier)));
|
|
125
|
+
* record.type = identifier.type;
|
|
126
|
+
* record.id = identifier.id;
|
|
127
|
+
*
|
|
128
|
+
* notifications.subscribe(identifier, (_, change) => {
|
|
129
|
+
* if (change === 'attributes') {
|
|
130
|
+
* Object.assign(record, cache.peek(identifier));
|
|
131
|
+
* }
|
|
132
|
+
* });
|
|
133
|
+
*
|
|
134
|
+
* return record;
|
|
135
|
+
* }
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* Because `instantiateRecord` is opaque to the nature of the record, an implementation
|
|
140
|
+
* can be anything from a fairly simple object to a robust proxy that intelligently links
|
|
141
|
+
* together associated records through relationships.
|
|
142
|
+
*
|
|
143
|
+
* This also enables creating a record that separates `edit` flows from `create` flows
|
|
144
|
+
* entirely. A record class might choose to implement a `checkout`method that gives access
|
|
145
|
+
* to an editable instance while the primary record continues to be read-only and reflect
|
|
146
|
+
* only persisted (non-mutated) state.
|
|
147
|
+
*
|
|
148
|
+
* Typically you will choose an existing record implementation such as `@ember-data/model`
|
|
149
|
+
* for your application.
|
|
150
|
+
*
|
|
151
|
+
* Because of the boundaries around instantiation and the cache, record implementations
|
|
152
|
+
* should be capable of interop both with each other and with any `Cache`. Due to this,
|
|
153
|
+
* if needed an application can utilize multiple record implementations and multiple cache
|
|
154
|
+
* implementations either to support enhanced features for only a subset of records or to
|
|
155
|
+
* be able to incrementally migrate from one record/cache to another record or cache.
|
|
156
|
+
*
|
|
157
|
+
* > **Note**
|
|
158
|
+
* > The `ember-data` package automatically includes the `@ember-data/model`
|
|
159
|
+
* > package and configures it for you.
|
|
160
|
+
*
|
|
161
|
+
* @module
|
|
162
|
+
*/
|
|
162
163
|
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_TRACKING_PACKAGE)) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
164
|
+
let hasEmberDataTracking = false;
|
|
165
|
+
let hasWarpDriveEmber = false;
|
|
166
|
+
let hasRegisteredFromEmberPackage = false;
|
|
167
|
+
if (macroCondition(dependencySatisfies("@warp-drive/ember", "*"))) {
|
|
168
|
+
hasWarpDriveEmber = true;
|
|
169
|
+
hasRegisteredFromEmberPackage = peekTransient("signalHooks") !== null;
|
|
170
|
+
}
|
|
171
|
+
if (macroCondition(dependencySatisfies("@ember-data/tracking", "*"))) {
|
|
172
|
+
hasEmberDataTracking = true;
|
|
173
|
+
if (!hasRegisteredFromEmberPackage) {
|
|
174
|
+
const { buildSignalConfig } = importSync("@ember-data/tracking");
|
|
175
|
+
setupSignals(buildSignalConfig);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (!hasRegisteredFromEmberPackage) {
|
|
179
|
+
const message = [
|
|
180
|
+
`Using WarpDrive with EmberJS requires configuring it to use Ember's reactivity system.`,
|
|
181
|
+
`Previously this was provided by installing the package '@ember-data/tracking', but this package is now deprecated.`,
|
|
182
|
+
``,
|
|
183
|
+
`To resolve this deprecation, follow these steps:`,
|
|
184
|
+
hasEmberDataTracking ? `- remove "@ember-data/tracking" and (if needed) "@ember-data-types/tracking" from your project in both your package.json and tsconfig.json` : false,
|
|
185
|
+
hasWarpDriveEmber ? false : `- add "@warp-drive/ember" to your project in your package.json (and run install)`,
|
|
186
|
+
"- add the following import to your app.js file:",
|
|
187
|
+
"",
|
|
188
|
+
" ```",
|
|
189
|
+
`\timport '@warp-drive/ember/install';`,
|
|
190
|
+
" ```",
|
|
191
|
+
``,
|
|
192
|
+
"- mark this deprecation as resolved in your project by adding the following to your WarpDrive config in ember-cli-build.js:",
|
|
193
|
+
"",
|
|
194
|
+
" ```",
|
|
195
|
+
" const { setConfig } = await import(\"@warp-drive/build-config\");",
|
|
196
|
+
" setConfig(app, __dirname, {",
|
|
197
|
+
" deprecations: {",
|
|
198
|
+
" DEPRECATE_TRACKING_PACKAGE: false,",
|
|
199
|
+
" },",
|
|
200
|
+
" });",
|
|
201
|
+
" ```",
|
|
202
|
+
``,
|
|
203
|
+
`For more information, see the Package Unification RFC: https://rfcs.emberjs.com/id/1075-warp-drive-package-unification/`
|
|
204
|
+
].filter((l) => l !== false).join("\n");
|
|
205
|
+
deprecate(message, false, {
|
|
206
|
+
id: "warp-drive.deprecate-tracking-package",
|
|
207
|
+
until: "6.0.0",
|
|
208
|
+
for: "warp-drive",
|
|
209
|
+
since: {
|
|
210
|
+
enabled: "5.3.4",
|
|
211
|
+
available: "4.13"
|
|
212
|
+
},
|
|
213
|
+
url: "https://deprecations.emberjs.com/id/warp-drive.deprecate-tracking-package"
|
|
214
|
+
});
|
|
215
|
+
}
|
|
196
216
|
}
|
|
217
|
+
|
|
218
|
+
//#endregion
|
|
219
|
+
export { CacheHandler, Store as default, recordIdentifierFor, setIdentifierForgetMethod, setIdentifierGenerationMethod, setIdentifierResetMethod, setIdentifierUpdateMethod, setKeyInfoForResource, storeFor };
|
|
220
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["deprecate","dependencySatisfies","importSync","macroCondition","getGlobalConfig","Store","setupSignals","peekTransient","default","CacheHandler","recordIdentifierFor","storeFor","setIdentifierGenerationMethod","setIdentifierUpdateMethod","setIdentifierForgetMethod","setIdentifierResetMethod","setKeyInfoForResource","WarpDrive","deprecations","DEPRECATE_TRACKING_PACKAGE","hasEmberDataTracking","hasWarpDriveEmber","hasRegisteredFromEmberPackage","buildSignalConfig","message","filter","l","join","id","until","for","since","enabled","available","url"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * This package provides [*Ember***Data**](https://github.com/warp-drive-data/warp-drive/)'s `Store` class.\n *\n * A {@link Store} coordinates interaction between your application, a {@link Cache},\n * and sources of data (such as your API or a local persistence layer) accessed via a {@link RequestManager}.\n *\n * Optionally, a Store can be configured to hydrate the response data into rich presentation classes.\n *\n * ## 🔨 Creating A Store\n *\n * To use a `Store` we will need to do few things: add a {@link Cache}\n * to store data **in-memory**, add a {@link Handler} to fetch data from a source,\n * and implement `instantiateRecord` to tell the store how to display the data for individual resources.\n *\n * > **Note**\n * > If you are using the package `ember-data` then a JSON:API cache, RequestManager, LegacyNetworkHandler,\n * > and `instantiateRecord` are configured for you by default.\n *\n * ### Configuring A Cache\n *\n * To start, let's install a [JSON:API](https://jsonapi.org/) cache. If your app uses `GraphQL` or `REST` other\n * caches may better fit your data. You can author your own cache by creating one that\n * conforms to the {@link Cache | spec}.\n *\n * The package `@ember-data/json-api` provides a [JSON:API](https://jsonapi.org/) cache we can use.\n * After installing it, we can configure the store to use this cache.\n *\n * ```js\n * import Store from '@ember-data/store';\n * import Cache from '@ember-data/json-api';\n *\n * class extends Store {\n * createCache(storeWrapper) {\n * return new Cache(storeWrapper);\n * }\n * }\n * ```\n *\n * Now that we have a `cache` let's setup something to handle fetching\n * and saving data via our API.\n *\n * > **Note**\n * > The `ember-data` package automatically includes and configures\n * > the `@ember-data/json-api` cache for you.\n *\n * ### Handling Requests\n *\n * When *Ember***Data** needs to fetch or save data it will pass that request to your application's `RequestManager` for fulfillment. How this fulfillment occurs (in-memory, device storage, via single or multiple API requests, etc.) is then up to the registered request handlers.\n *\n * To start, let's install the `RequestManager` from `@ember-data/request` and the basic `Fetch` handler from ``@ember-data/request/fetch`.\n *\n * > **Note**\n * > If your app uses `GraphQL`, `REST` or different conventions for `JSON:API` than your cache expects, other handlers may better fit your data. You can author your own handler by creating one that conforms to the [handler interface](https://github.com/warp-drive-data/warp-drive/tree/main/packages/request#handling-requests).\n *\n * ```ts\n * import Store from '@ember-data/store';\n * import RequestManager from '@ember-data/request';\n * import Fetch from '@ember-data/request/fetch';\n *\n * export default class extends Store {\n * requestManager = new RequestManager()\n * .use([Fetch]);\n * }\n * ```\n *\n * **Using RequestManager as a Service**\n *\n * Alternatively if you have configured the `RequestManager` to be a service you may re-use it.\n *\n * *app/services/request.js*\n * ```ts\n * import RequestManager from '@ember-data/request';\n * import Fetch from '@ember-data/request/fetch';\n *\n * export default {\n * create() {\n * return new RequestManager()\n * .use([Fetch])\n * .useCache(CacheHandler);\n * }\n * }\n * ```\n *\n * *app/services/store.js*\n * ```ts\n * import Store from '@ember-data/store';\n * import { service } from '@ember/service';\n *\n * export default class extends Store {\n * @service('request') requestManager\n * }\n * ```\n *\n *\n * ### Presenting Data from the Cache\n *\n * Now that we have a source and a cache for our data, we need to configure how\n * the Store delivers that data back to our application. We do this via the {@link Store.instantiateRecord | instantiateRecord hook}\n * which allows us to transform the data for a resource before handing it to the application.\n *\n * A naive way to present the data would be to return it as JSON. Typically instead\n * this hook will be used to add reactivity and make each unique resource a singleton,\n * ensuring that if the cache updates our presented data will reflect the new state.\n *\n * Below is an example of using the hooks `instantiateRecord` and a `teardownRecord`\n * to provide minimal read-only reactive state for simple resources.\n *\n * ```ts\n * import Store, { recordIdentifierFor } from '@ember-data/store';\n * import { TrackedObject } from 'tracked-built-ins';\n *\n * class extends Store {\n * instantiateRecord(identifier) {\n * const { cache, notifications } = this;\n *\n * // create a TrackedObject with our attributes, id and type\n * const record = new TrackedObject(Object.assign({}, cache.peek(identifier)));\n * record.type = identifier.type;\n * record.id = identifier.id;\n *\n * notifications.subscribe(identifier, (_, change) => {\n * if (change === 'attributes') {\n * Object.assign(record, cache.peek(identifier));\n * }\n * });\n *\n * return record;\n * }\n * }\n * ```\n *\n * Because `instantiateRecord` is opaque to the nature of the record, an implementation\n * can be anything from a fairly simple object to a robust proxy that intelligently links\n * together associated records through relationships.\n *\n * This also enables creating a record that separates `edit` flows from `create` flows\n * entirely. A record class might choose to implement a `checkout`method that gives access\n * to an editable instance while the primary record continues to be read-only and reflect\n * only persisted (non-mutated) state.\n *\n * Typically you will choose an existing record implementation such as `@ember-data/model`\n * for your application.\n *\n * Because of the boundaries around instantiation and the cache, record implementations\n * should be capable of interop both with each other and with any `Cache`. Due to this,\n * if needed an application can utilize multiple record implementations and multiple cache\n * implementations either to support enhanced features for only a subset of records or to\n * be able to incrementally migrate from one record/cache to another record or cache.\n *\n * > **Note**\n * > The `ember-data` package automatically includes the `@ember-data/model`\n * > package and configures it for you.\n *\n * @module\n */\nimport { deprecate } from '@ember/debug';\n\nimport { dependencySatisfies, importSync, macroCondition } from '@embroider/macros';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type RequestManager, Store } from '@warp-drive/core';\nimport { DEPRECATE_TRACKING_PACKAGE } from '@warp-drive/core/build-config/deprecations';\nimport { setupSignals } from '@warp-drive/core/configure';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { Handler } from '@warp-drive/core/request';\nimport { peekTransient } from '@warp-drive/core/types/-private';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { Cache } from '@warp-drive/core/types/cache';\n\nexport { Store as default };\n\nexport {\n type StoreRequestContext,\n CacheHandler,\n type Document,\n type CachePolicy,\n type StoreRequestInput,\n recordIdentifierFor,\n storeFor,\n type DocumentCacheOperation,\n type CacheOperation,\n type NotificationType,\n setIdentifierGenerationMethod,\n setIdentifierUpdateMethod,\n setIdentifierForgetMethod,\n setIdentifierResetMethod,\n setKeyInfoForResource,\n} from '@warp-drive/core';\n\nif (DEPRECATE_TRACKING_PACKAGE) {\n let hasEmberDataTracking = false;\n let hasWarpDriveEmber = false;\n let hasRegisteredFromEmberPackage = false;\n\n if (macroCondition(dependencySatisfies('@warp-drive/ember', '*'))) {\n hasWarpDriveEmber = true;\n hasRegisteredFromEmberPackage = peekTransient('signalHooks') !== null;\n }\n\n if (macroCondition(dependencySatisfies('@ember-data/tracking', '*'))) {\n hasEmberDataTracking = true;\n\n if (!hasRegisteredFromEmberPackage) {\n // @ts-expect-error\n const { buildSignalConfig } = importSync('@ember-data/tracking');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n setupSignals(buildSignalConfig);\n }\n }\n\n // we should probably still print here if @ember-data/tracking is present\n if (!hasRegisteredFromEmberPackage) {\n const message = [\n `Using WarpDrive with EmberJS requires configuring it to use Ember's reactivity system.`,\n `Previously this was provided by installing the package '@ember-data/tracking', but this package is now deprecated.`,\n ``,\n `To resolve this deprecation, follow these steps:`,\n hasEmberDataTracking\n ? `- remove \"@ember-data/tracking\" and (if needed) \"@ember-data-types/tracking\" from your project in both your package.json and tsconfig.json`\n : false,\n hasWarpDriveEmber ? false : `- add \"@warp-drive/ember\" to your project in your package.json (and run install)`,\n '- add the following import to your app.js file:',\n '',\n '\\t```',\n `\\timport '@warp-drive/ember/install';`,\n '\\t```',\n ``,\n '- mark this deprecation as resolved in your project by adding the following to your WarpDrive config in ember-cli-build.js:',\n '',\n '\\t```',\n '\\tconst { setConfig } = await import(\"@warp-drive/build-config\");',\n '\\tsetConfig(app, __dirname, {',\n '\\t deprecations: {',\n '\\t DEPRECATE_TRACKING_PACKAGE: false,',\n '\\t },',\n '\\t});',\n '\\t```',\n ``,\n `For more information, see the Package Unification RFC: https://rfcs.emberjs.com/id/1075-warp-drive-package-unification/`,\n ]\n .filter((l) => l !== false)\n .join('\\n');\n\n deprecate(message, false, {\n id: 'warp-drive.deprecate-tracking-package',\n until: '6.0.0',\n for: 'warp-drive',\n since: {\n enabled: '5.3.4',\n available: '4.13',\n },\n url: 'https://deprecations.emberjs.com/id/warp-drive.deprecate-tracking-package',\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6LA,IAAAG,eAAAC,gBAAA,CAAA,CAAAa,UAAAC,aAAAC,0BAAA,GAAgC;CAC9B,IAAIC,uBAAuB;CAC3B,IAAIC,oBAAoB;CACxB,IAAIC,gCAAgC;CAEpC,IAAInB,eAAeF,oBAAoB,qBAAqB,GAAG,CAAC,GAAG;EACjEoB,oBAAoB;EACpBC,gCAAgCf,cAAc,aAAa,MAAM;CACnE;CAEA,IAAIJ,eAAeF,oBAAoB,wBAAwB,GAAG,CAAC,GAAG;EACpEmB,uBAAuB;EAEvB,IAAI,CAACE,+BAA+B;GAElC,MAAM,EAAEC,sBAAsBrB,WAAW,sBAAsB;GAE/DI,aAAaiB,iBAAiB;EAChC;CACF;CAGA,IAAI,CAACD,+BAA+B;EAClC,MAAME,UAAU;GACd;GACA;GACA;GACA;GACAJ,uBACI,+IACA;GACJC,oBAAoB,QAAQ;GAC5B;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EAAyH,CAC1H,CACEI,QAAQC,MAAMA,MAAM,KAAK,CAAC,CAC1BC,KAAK,IAAI;EAEZ3B,UAAUwB,SAAS,OAAO;GACxBI,IAAI;GACJC,OAAO;GACPC,KAAK;GACLC,OAAO;IACLC,SAAS;IACTC,WAAW;GACb;GACAC,KAAK;EACP,CAAC;CACH;AACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { BaseFinderOptions, CacheCapabilitiesManager, FindAllOptions, FindRecordOptions, LegacyResourceQuery, ModelSchema, QueryOptions, SchemaService } from "@warp-drive/core/types";
|
|
2
|
+
export type { BaseFinderOptions, CacheCapabilitiesManager, FindAllOptions, FindRecordOptions, LegacyResourceQuery, ModelSchema, QueryOptions, SchemaService };
|
package/dist/types.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-data/store",
|
|
3
|
-
"version": "5.9.0-alpha.
|
|
3
|
+
"version": "5.9.0-alpha.22",
|
|
4
4
|
"description": "(Legacy) EmberData Store service which coordinates the cache with the network and presentation layers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "Chris Thoburn <runspired@users.noreply.github.com>",
|
|
15
15
|
"files": [
|
|
16
|
-
"unstable-preview-types",
|
|
17
16
|
"addon-main.cjs",
|
|
18
17
|
"dist",
|
|
19
18
|
"README.md",
|
|
20
19
|
"LICENSE.md",
|
|
21
|
-
"logos"
|
|
20
|
+
"logos",
|
|
21
|
+
"unstable-preview-types"
|
|
22
22
|
],
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@embroider/macros": "^1.20.6",
|
|
36
|
-
"@warp-drive/core": "5.9.0-alpha.
|
|
36
|
+
"@warp-drive/core": "5.9.0-alpha.22"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@ember-data/tracking": "5.9.0-alpha.
|
|
39
|
+
"@ember-data/tracking": "5.9.0-alpha.22",
|
|
40
40
|
"@ember/test-waiters": "^3.1.0 || ^4.0.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependenciesMeta": {
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"@babel/plugin-transform-typescript": "^7.28.0",
|
|
53
53
|
"@babel/preset-env": "^7.28.3",
|
|
54
54
|
"@babel/preset-typescript": "^7.27.1",
|
|
55
|
-
"@ember-data/tracking": "5.9.0-alpha.
|
|
55
|
+
"@ember-data/tracking": "5.9.0-alpha.22",
|
|
56
56
|
"@ember/test-waiters": "^4.1.1",
|
|
57
|
-
"@warp-drive/internal-config": "5.9.0-alpha.
|
|
57
|
+
"@warp-drive/internal-config": "5.9.0-alpha.22",
|
|
58
58
|
"ember-source": "~6.12.0",
|
|
59
|
-
"
|
|
60
|
-
"
|
|
59
|
+
"tsdown": "^0.22.14",
|
|
60
|
+
"typescript": "^5.9.3"
|
|
61
61
|
},
|
|
62
62
|
"volta": {
|
|
63
63
|
"extends": "../../package.json"
|
|
@@ -79,8 +79,9 @@
|
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"lint": "eslint . --quiet --cache --cache-strategy=content",
|
|
82
|
-
"
|
|
82
|
+
"check:types": "tsc --noEmit",
|
|
83
|
+
"build:pkg": "node node_modules/tsdown/dist/run.mjs",
|
|
83
84
|
"sync": "echo \"syncing\"",
|
|
84
|
-
"start": "
|
|
85
|
+
"start": "node node_modules/tsdown/dist/run.mjs --watch"
|
|
85
86
|
}
|
|
86
87
|
}
|
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
declare module '@ember-data/store/configure' {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* that WarpDrive should use.
|
|
5
|
-
*
|
|
6
|
-
* @module
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Configures the signals implementation to use. Supports multiple
|
|
10
|
-
* implementations simultaneously.
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
* @param {function} buildConfig - a function that takes options and returns a configuration object
|
|
14
|
-
*/
|
|
15
|
-
export { setupSignals } from "@warp-drive/core/configure";
|
|
16
|
-
|
|
2
|
+
import { setupSignals } from "@warp-drive/core/configure";
|
|
3
|
+
export { setupSignals };
|
|
17
4
|
}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
/// <reference path="./types.d.ts" />
|
|
3
3
|
/// <reference path="./-private.d.ts" />
|
|
4
4
|
declare module '@ember-data/store' {
|
|
5
|
-
import { Store } from "@warp-drive/core";
|
|
6
|
-
export { Store as default };
|
|
7
|
-
export { type StoreRequestContext, CacheHandler, type Document, type CachePolicy, type StoreRequestInput, recordIdentifierFor, storeFor, type DocumentCacheOperation, type CacheOperation, type NotificationType, setIdentifierGenerationMethod, setIdentifierUpdateMethod, setIdentifierForgetMethod, setIdentifierResetMethod, setKeyInfoForResource } from "@warp-drive/core";
|
|
8
|
-
|
|
5
|
+
import { CacheHandler, CacheOperation, CachePolicy, Document, DocumentCacheOperation, NotificationType, Store, StoreRequestContext, StoreRequestInput, recordIdentifierFor, setIdentifierForgetMethod, setIdentifierGenerationMethod, setIdentifierResetMethod, setIdentifierUpdateMethod, setKeyInfoForResource, storeFor } from "@warp-drive/core";
|
|
6
|
+
export { CacheHandler, type CacheOperation, type CachePolicy, type Document, type DocumentCacheOperation, type NotificationType, type StoreRequestContext, type StoreRequestInput, Store as default, recordIdentifierFor, setIdentifierForgetMethod, setIdentifierGenerationMethod, setIdentifierResetMethod, setIdentifierUpdateMethod, setKeyInfoForResource, storeFor };
|
|
9
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
declare module '@ember-data/store/types' {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { BaseFinderOptions, CacheCapabilitiesManager, FindAllOptions, FindRecordOptions, LegacyResourceQuery, ModelSchema, QueryOptions, SchemaService } from "@warp-drive/core/types";
|
|
3
|
+
export type { BaseFinderOptions, CacheCapabilitiesManager, FindAllOptions, FindRecordOptions, LegacyResourceQuery, ModelSchema, QueryOptions, SchemaService };
|
|
4
4
|
}
|