@warp-drive-mirror/legacy 5.10.0-alpha.16 → 5.10.0-alpha.17
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/adapter/json-api.d.ts +0 -5
- package/dist/adapter/json-api.d.ts.map +1 -1
- package/dist/adapter.d.ts +0 -218
- package/dist/compat/builders.d.ts +0 -12
- package/dist/compat/builders.d.ts.map +1 -1
- package/dist/compat/extensions.d.ts +0 -5
- package/dist/index.d.ts +0 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/model-fragments.d.ts +0 -5
- package/dist/model-fragments.d.ts.map +1 -1
- package/dist/model.d.ts +0 -68
- package/dist/model.d.ts.map +1 -1
- package/dist/runtime--fcdnjmJ-DMTJ0Kb3.js.map +1 -1
- package/dist/serializer/transform.d.ts +0 -5
- package/dist/serializer/transform.d.ts.map +1 -1
- package/dist/serializer.d.ts +0 -143
- package/dist/serializer.d.ts.map +1 -1
- package/dist/store.d.ts +0 -5
- package/dist/store.d.ts.map +1 -1
- package/dist/unpkg/dev/compat-DwphQcTd.js.map +1 -1
- package/dist/unpkg/dev/runtime--fcdnjmJ-DMTJ0Kb3.js.map +1 -1
- package/dist/unpkg/dev-deprecated/compat-BPmhn8BS.js.map +1 -1
- package/dist/unpkg/dev-deprecated/runtime--fcdnjmJ-DMTJ0Kb3.js.map +1 -1
- package/dist/unpkg/prod/runtime--fcdnjmJ-DMTJ0Kb3.js.map +1 -1
- package/dist/unpkg/prod-deprecated/runtime--fcdnjmJ-DMTJ0Kb3.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module
|
|
3
|
-
* @summary Legacy `JSONAPIAdapter`, which turns store requests into HTTP requests following JSON:API URL, verb and
|
|
4
|
-
* header conventions.
|
|
5
|
-
*/
|
|
6
1
|
import { _ as AdapterPayload, m as Snapshot, p as SnapshotRecordArray } from "../compat-BZlQ-5eI.js";
|
|
7
2
|
import { i as RESTAdapter, n as JQueryRequestInit, r as QueryState, t as FetchRequestInit } from "../rest-ddU-K5eS.js";
|
|
8
3
|
import { Store } from "@warp-drive-mirror/core";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-api.d.ts","names":[],"sources":["../../src/adapter/json-api.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"json-api.d.ts","names":[],"sources":["../../src/adapter/json-api.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmKM,uBAAuB;;;;;EAK3B;;;;;;;;EASA,YACE,aACA,MAAM,YACN,UAAS,qBAAqB,cAC7B,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAgEnB;MAQA,qBAAqB;EAIzB,SAAS,OAAO,OAAO,MAAM,aAAa,eAAe,WAAW,aAAa,QAAQ;;;;;;;;EAYzF,YAAY;EAKZ,aAAa,OAAO,OAAO,QAAQ,aAAa,UAAU,WAAW,QAAQ;;;;;;;;;;EAoB7E,WAAW,UAAU,WAAW,sBAAsB"}
|
package/dist/adapter.d.ts
CHANGED
|
@@ -1,220 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ## Overview
|
|
3
|
-
*
|
|
4
|
-
* :::danger
|
|
5
|
-
* ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
6
|
-
* If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
7
|
-
* {@link Handler} instead to be used with the {@link RequestManager}
|
|
8
|
-
* ::::
|
|
9
|
-
*
|
|
10
|
-
* In order to properly fetch and update data, @warp-drive-mirror/legacy
|
|
11
|
-
* needs to understand how to connect to your API.
|
|
12
|
-
*
|
|
13
|
-
* `Adapters` accept various kinds of requests from the store
|
|
14
|
-
* and manage fulfillment of the request from your API.
|
|
15
|
-
*
|
|
16
|
-
* ### Why It's Legacy
|
|
17
|
-
*
|
|
18
|
-
* The Adapter pattern was designed for class-based architectures in which each resource type
|
|
19
|
-
* could have its own data-fetching logic:
|
|
20
|
-
*
|
|
21
|
-
* - `store.adapterFor` resolves an adapter by resource type at runtime, looking up
|
|
22
|
-
* `adapter:<type>` and then `adapter:application` through Ember's owner.
|
|
23
|
-
* - Each request is fulfilled by a single adapter, so sharing behavior across resource types
|
|
24
|
-
* means extending a common base class rather than composing request logic.
|
|
25
|
-
* - The provided adapter classes extend `EmberObject`, which, together with the owner lookup,
|
|
26
|
-
* ties the pattern to Ember.
|
|
27
|
-
* - Adapter methods resolve with an untyped `AdapterPayload`, so nothing ties the response's
|
|
28
|
-
* type to the request that produced it.
|
|
29
|
-
*
|
|
30
|
-
* ### Modern Alternative
|
|
31
|
-
*
|
|
32
|
-
* Use [Handlers](/api/@warp-drive-mirror/core/request/types/Handler) with the {@link RequestManager}.
|
|
33
|
-
* Each request passes through a chain of handlers, any of which can fulfill it, modify it or
|
|
34
|
-
* pass it along. Handlers support:
|
|
35
|
-
*
|
|
36
|
-
* - request builders, which return a request typed with its expected response, so
|
|
37
|
-
* `store.request` resolves with that type
|
|
38
|
-
* - composition: `RequestManager.use` takes a list of handlers, such as the built-in `Fetch`
|
|
39
|
-
* handler, and wrappers such as `Gate` from `@warp-drive-mirror/utilities/handlers` run another
|
|
40
|
-
* handler only for the requests it accepts
|
|
41
|
-
* - explicit imports rather than lookup by name at runtime
|
|
42
|
-
* - any framework ***Warp*Drive** supports, since `@warp-drive-mirror/core` has no runtime
|
|
43
|
-
* dependency on Ember (see [Installation](/guides/installation/))
|
|
44
|
-
*
|
|
45
|
-
* For an alternative modern pattern to Adapters, see the
|
|
46
|
-
* [Request Handlers Guide](/guides/the-manual/requests/handlers).
|
|
47
|
-
*
|
|
48
|
-
* ### Request Flow
|
|
49
|
-
*
|
|
50
|
-
* When the store decides it needs to issue a request it uses the following flow to manage the request and process the data.
|
|
51
|
-
*
|
|
52
|
-
* - find the appropriate adapter
|
|
53
|
-
* - issue the request to the adapter
|
|
54
|
-
* - await the adapter's response
|
|
55
|
-
* - if an error occurs reject with the error
|
|
56
|
-
* - if no error
|
|
57
|
-
* - if there is response data
|
|
58
|
-
* - pass the response data to the appropriate serializer
|
|
59
|
-
* - update the cache using the JSON:API formatted data from the serializer's response
|
|
60
|
-
* - return the primary record(s) associated with the request
|
|
61
|
-
*
|
|
62
|
-
* ### Request Errors
|
|
63
|
-
*
|
|
64
|
-
* When a request errors and your adapter does not have the ability to recover from the error,
|
|
65
|
-
* you may either reject the promise returned by your adapter method with the error or simply
|
|
66
|
-
* throw the error.
|
|
67
|
-
*
|
|
68
|
-
* If the request was for a `createRecord` `updateRecord` or `deleteRecord` special rules
|
|
69
|
-
* apply to how this error will affect the state of the store and additional properties on
|
|
70
|
-
* the `Error` class may be used. See the documentation for these methods in
|
|
71
|
-
* {@link MinimumAdapterInterface} for more information.
|
|
72
|
-
*
|
|
73
|
-
* ### Implementing an Adapter
|
|
74
|
-
*
|
|
75
|
-
* There are seven required adapter methods, one for each of
|
|
76
|
-
* the primary request types that @warp-drive-mirror/legacy issues.
|
|
77
|
-
*
|
|
78
|
-
* They are:
|
|
79
|
-
*
|
|
80
|
-
* - findRecord
|
|
81
|
-
* - findAll
|
|
82
|
-
* - queryRecord
|
|
83
|
-
* - query
|
|
84
|
-
* - createRecord
|
|
85
|
-
* - updateRecord
|
|
86
|
-
* - deleteRecord
|
|
87
|
-
*
|
|
88
|
-
* Each of these request types has a matching store method that triggers it
|
|
89
|
-
* and matching `requestType` that is passed to the serializer's
|
|
90
|
-
* `normalizeResponse` method.
|
|
91
|
-
*
|
|
92
|
-
* If your app only reads data but never writes data, it is not necessary
|
|
93
|
-
* to implement the methods for create, update, and delete. This extends to
|
|
94
|
-
* all of the store's find methods with the exception of `findRecord` (`findAll`,
|
|
95
|
-
* `query`, `queryRecord`): if you do not use the store method in your app then
|
|
96
|
-
* your Adapter does not need the method.
|
|
97
|
-
*
|
|
98
|
-
* ```ts
|
|
99
|
-
* async function fetchData(url, options = {}) {
|
|
100
|
-
* let response = await fetch(url, options);
|
|
101
|
-
* return response.toJSON();
|
|
102
|
-
* }
|
|
103
|
-
*
|
|
104
|
-
* export default class ApplicationAdapter {
|
|
105
|
-
* findRecord(_, { modelName }, id) {
|
|
106
|
-
* return fetchData(`./${modelName}s/${id}`);
|
|
107
|
-
* }
|
|
108
|
-
*
|
|
109
|
-
* static create() {
|
|
110
|
-
* return new this();
|
|
111
|
-
* }
|
|
112
|
-
* }
|
|
113
|
-
* ```
|
|
114
|
-
*
|
|
115
|
-
* ### Adapter Resolution
|
|
116
|
-
*
|
|
117
|
-
* `store.adapterFor(name)` will lookup adapters defined in `app/adapters/` and
|
|
118
|
-
* return an instance.
|
|
119
|
-
*
|
|
120
|
-
* `adapterFor` first attempts to find an adapter with an exact match on `name`,
|
|
121
|
-
then falls back to checking for the presence of an adapter named `application`.
|
|
122
|
-
|
|
123
|
-
If no adapter is found, an error will be thrown.
|
|
124
|
-
|
|
125
|
-
```ts
|
|
126
|
-
store.adapterFor('author');
|
|
127
|
-
|
|
128
|
-
// lookup paths (in order) =>
|
|
129
|
-
// app/adapters/author.js
|
|
130
|
-
// app/adapters/application.js
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
Most requests in @warp-drive-mirror/legacy are made with respect to a particular `type` (or `modelName`)
|
|
134
|
-
(e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We
|
|
135
|
-
refer to this as the **primary** resource `type`.
|
|
136
|
-
|
|
137
|
-
`adapterFor` is used by the store to find an adapter with a name matching that of the primary
|
|
138
|
-
resource `type` for the request, which then falls back to the `application` adapter.
|
|
139
|
-
|
|
140
|
-
It is recommended that applications define only a single `application` adapter and serializer
|
|
141
|
-
where possible, only implementing an adapter specific to the `type` when absolutely necessary.
|
|
142
|
-
|
|
143
|
-
If you need to support multiple API versions for the same type, the per-type strategy for
|
|
144
|
-
defining adapters might not be adequate.
|
|
145
|
-
|
|
146
|
-
If you have multiple APIs or multiple API versions and the single application adapter and per-type
|
|
147
|
-
strategy does not suite your needs, one strategy is to write an `application` adapter and serializer
|
|
148
|
-
that make use of `options` to specify the desired format when making a request, then forwards to the
|
|
149
|
-
request to the desired adapter or serializer as needed.
|
|
150
|
-
|
|
151
|
-
```js [app/adapters/application.js]
|
|
152
|
-
export default class Adapter extends EmberObject {
|
|
153
|
-
findRecord(store, schema, id, snapshot) {
|
|
154
|
-
let { apiVersion } = snapshot.adapterOptions;
|
|
155
|
-
return this.adapterFor(`-api-${apiVersion}`).findRecord(store, schema, id, snapshot);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
### Overriding `Store.adapterFor`
|
|
161
|
-
|
|
162
|
-
```js
|
|
163
|
-
import Store from '@ember-data-mirror/store';
|
|
164
|
-
import Adapter from '@ember-data-mirror/adapter/json-api';
|
|
165
|
-
|
|
166
|
-
class extends Store {
|
|
167
|
-
#adapter = new Adapter();
|
|
168
|
-
|
|
169
|
-
adapterFor() {
|
|
170
|
-
return this.#adapter;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
Note: If you are using Ember and would like to make use of `service` injections in your adapter, you will want to additionally `setOwner` for the Adapter.
|
|
177
|
-
|
|
178
|
-
```js
|
|
179
|
-
import Store from '@ember-data-mirror/store';
|
|
180
|
-
import Adapter from '@ember-data-mirror/adapter/json-api';
|
|
181
|
-
import { getOwner, setOwner } from '@ember/owner';
|
|
182
|
-
|
|
183
|
-
class extends Store {
|
|
184
|
-
#adapter = null;
|
|
185
|
-
|
|
186
|
-
adapterFor() {
|
|
187
|
-
let adapter = this.#adapter;
|
|
188
|
-
if (!adapter) {
|
|
189
|
-
const owner = getOwner(this);
|
|
190
|
-
adapter = new Adapter();
|
|
191
|
-
setOwner(adapter, owner);
|
|
192
|
-
this.#adapter = adapter;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return adapter;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
By default when using with Ember you only need to implement this hook if you want your adapter usage to be statically analyzeable. *Ember***Data** will attempt to resolve adapters using Ember's resolver. To provide a single Adapter for your application like the above you would provide it as the default export of the file `app/adapters/application.{js/ts}`
|
|
201
|
-
|
|
202
|
-
### Using an Adapter
|
|
203
|
-
|
|
204
|
-
Any adapter in `app/adapters/` can be looked up by `name` using `store.adapterFor(name)`.
|
|
205
|
-
|
|
206
|
-
### Default Adapters
|
|
207
|
-
|
|
208
|
-
Applications whose API's structure endpoint URLs *very close to* or *exactly* the **REST**
|
|
209
|
-
or **JSON:API** convention, the `@ember-data-mirror/adapter` package contains implementations
|
|
210
|
-
these applications can extend.
|
|
211
|
-
|
|
212
|
-
Many applications will find writing their own adapter to be allow greater flexibility,
|
|
213
|
-
customization, and maintenance than attempting to override methods in these adapters.
|
|
214
|
-
|
|
215
|
-
@summary Legacy adapter layer through which the store fetches and saves data from an API, superseded by
|
|
216
|
-
`RequestManager` handlers.
|
|
217
|
-
@module
|
|
218
|
-
*/
|
|
219
1
|
import { n as BuildURLMixin, t as Adapter } from "./adapter-D3A8ixjz.js";
|
|
220
2
|
export { Adapter, BuildURLMixin };
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
Builders for migrating from `store` methods to `store.request`.
|
|
3
|
-
|
|
4
|
-
These builders enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.
|
|
5
|
-
This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
|
|
6
|
-
To that end, these builders are deprecated and will be removed in a future version of Ember Data.
|
|
7
|
-
|
|
8
|
-
@summary Deprecated request builders that move `findRecord`, `query`, and `saveRecord` calls to `store.request`
|
|
9
|
-
while still using adapters and serializers.
|
|
10
|
-
@module
|
|
11
|
-
@deprecated
|
|
12
|
-
*/
|
|
13
1
|
import { StoreRequestInput } from "@warp-drive-mirror/core";
|
|
14
2
|
import { RequestSignature } from "@warp-drive-mirror/core/types/symbols";
|
|
15
3
|
import { FindAllOptions, FindRecordOptions, LegacyResourceQuery, QueryOptions, ResourceKey } from "@warp-drive-mirror/core/types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.d.ts","names":[],"sources":["../../src/compat/builders/find-all.ts","../../src/compat/builders/find-record.ts","../../src/compat/builders/query.ts","../../src/compat/builders/save-record.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"builders.d.ts","names":[],"sources":["../../src/compat/builders/find-all.ts","../../src/compat/builders/find-record.ts","../../src/compat/builders/query.ts","../../src/compat/builders/save-record.ts"],"mappings":";;;;;;KASK,oBAAoB,2BAA2B,kBAAkB;EACpE;EACA;IACE,MAAM;IACN,SAAS;;GAEV,oBAAoB;;KAGlB,wBAAwB;;;;;;;;;;;;;;;;;;iBAmBb,eAAe,UAAU,qBACvC,MAAM,iBAAiB,IACvB,UAAU,wBACT,oBAAoB,iBAAiB,IAAI;iBAC5B,eAAe,cAAc,UAAU,wBAAwB;;;KC9B1E,uBAAuB,2BAA2B,gBAAgB;EACrE;EACA;IACE,QAAQ,yBAAyB;IACjC,SAAS;;GAEV,oBAAoB;;KAGlB,2BAA2B,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCrB,kBAAkB,UAAU,qBAC1C,MAAM,iBAAiB,IACvB,YACA,UAAU,2BACT,uBAAuB,iBAAiB,IAAI;iBAC/B,kBAAkB,cAAc,YAAY,UAAU,2BAA2B;iBACjF,kBAAkB,UAAU,qBAC1C,UAAU,yBAAyB,iBAAiB,KACpD,UAAU,2BACT,uBAAuB,iBAAiB,IAAI;iBAC/B,kBACd,UAAU,0BACV,UAAU,2BACT;;;KC9DE,kBAAkB,2BAA2B,kBAAkB;EAClE;EACA;IACE,MAAM;IACN,OAAO;IACP,SAAS;;GAEV,oBAAoB;;KAGlB,sBAAsB;;;;;;;;;;;;;;;;;;;iBAoBX,aAAa,UAAU,qBACrC,MAAM,iBAAiB,IACvB,OAAO,qBACP,UAAU,sBACT,kBAAkB,iBAAiB,IAAI;iBAC1B,aACd,cACA,OAAO,qBACP,UAAU,sBACT;KAwBE,wBAAwB,2BAA2B,gBAAgB;EACtE;EACA;IACE,MAAM;IACN,OAAO;IACP,SAAS;;GAEV,oBAAoB;;;;;;;;;;;;;;;;;;;;iBAqBP,mBAAmB,UAAU,qBAC3C,MAAM,iBAAiB,IACvB,OAAO,qBACP,UAAU,sBACT,wBAAwB,iBAAiB,IAAI;iBAChC,mBACd,cACA,OAAO,qBACP,UAAU,sBACT;;;KCpGE,uBAAuB,2BAA2B,gBAAgB;EACrE;EACA;IACE,QAAQ,YAAY;IACpB,SAAS;;EAEX,UAAU,YAAY;GACrB,oBAAoB;;KAGlB,2BAA2B;;;;;;;;;;;;;;;;;;iBA4BhB,kBAAkB,UAAU,qBAC1C,QAAQ,GACR,UAAS,0BACR,uBAAuB,iBAAiB,IAAI"}
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module
|
|
3
|
-
* @summary Legacy schema extensions that give reactive objects and arrays the classic `EmberObject` and Ember array
|
|
4
|
-
* APIs, such as `get`, `set` and `mapBy`, plus matching types.
|
|
5
|
-
*/
|
|
6
1
|
import { a as WithArrayLike, i as EmberObjectExtension, n as EmberArrayLikeExtension, o as WithEmberObject, r as EmberObjectArrayExtension, t as ArrayType } from "../extensions-fwdnX9n4.js";
|
|
7
2
|
export { ArrayType, EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension, WithArrayLike, WithEmberObject };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @summary Legacy `Model`, adapter, and serializer support for WarpDrive, including `useLegacyStore` to configure a
|
|
3
|
-
* store that uses them.
|
|
4
|
-
* @module
|
|
5
|
-
* @mergeModuleWith <project>
|
|
6
|
-
*/
|
|
7
1
|
import { Store, StoreSetupOptions } from "@warp-drive-mirror/core";
|
|
8
2
|
import { CacheCapabilitiesManager } from "@warp-drive-mirror/core/types";
|
|
9
3
|
import { Cache } from "@warp-drive-mirror/core/types/cache";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;UA6CU,yBAAyB,UAAU,eAAe,KAAK,kBAAkB;;;;;;;;;;;EAWjF,UAAU,MAAM,iBAAiB;;;;;;EAOjC;;;;;;;;;;iBAWe,6BAA6B,UAAU,eAAe,yBAAyB;;;;;;;;;EAS9F;;;;;;;;;EASA;;;;;;;;;;;iBAYe,uCAAuC,UAAU,eAAe,yBAAyB;;;;;;;EAOxG;;;;;;;;;EASA;;;;;;;;;;;iBAYe,iDAAiD,UAAU,eAAe,yBAAyB;;;;;;;EAOlH;;;;;;;;;EASA;;;;;;;;;;;;;YAgBU,wBAAwB,UAAU,QAAQ,SAClD,6BAA6B,KAC7B,uCAAuC,KACvC,iDAAiD;qBAEhC,gBACnB;;;;EAIE,OAAO;WAED;EAER,YAAY,cAAc,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA4HvC,eAAe,UAAU,OACvC,SAAS,6BAA6B,IACtC,oBAAoB,eACZ;EAAkB,OAAO;;wBACnB,eAAe,UAAU,OACvC,SAAS,uCAAuC,IAChD,oBAAoB,eACZ;EAAkB,OAAO;;wBACnB,eAAe,UAAU,OACvC,SAAS,iDAAiD,IAC1D,oBAAoB,eACZ;EAAkB,OAAO"}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module
|
|
3
|
-
* @summary Legacy helpers for migrating ember-data-model-fragments to WarpDrive schemas, including `withLegacy`,
|
|
4
|
-
* `withFragmentDefaults` and the `Fragment` and `FragmentArray` extensions.
|
|
5
|
-
*/
|
|
6
1
|
import { a as WithArrayLike, o as WithEmberObject } from "./extensions-fwdnX9n4.js";
|
|
7
2
|
import { Store } from "@warp-drive-mirror/core";
|
|
8
3
|
import { PrivateReactiveResource } from "@warp-drive-mirror/core/reactive/-private";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-fragments.d.ts","names":[],"sources":["../src/model-fragments/utilities/with-array-defaults.ts","../src/model-fragments/utilities/with-fragment-defaults.ts","../src/model-fragments/utilities/with-fragment-array-defaults.ts","../src/model-fragments/utilities/with-legacy.ts","../src/model-fragments/instance-initializers/fragment-extensions.ts","../src/model-fragments/hooks/model-for.ts","../src/model-fragments/extensions/fragment.ts","../src/model-fragments/extensions/fragment-array.ts","../src/model-fragments/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"model-fragments.d.ts","names":[],"sources":["../src/model-fragments/utilities/with-array-defaults.ts","../src/model-fragments/utilities/with-fragment-defaults.ts","../src/model-fragments/utilities/with-fragment-array-defaults.ts","../src/model-fragments/utilities/with-legacy.ts","../src/model-fragments/instance-initializers/fragment-extensions.ts","../src/model-fragments/hooks/model-for.ts","../src/model-fragments/extensions/fragment.ts","../src/model-fragments/extensions/fragment-array.ts","../src/model-fragments/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;wBAUgB,kBAAkB,0BAA0B,8BAC1D,WAAW,WACX,gBAAgB,gBACf;;;;EAKG;;;;EAIA,MAAM;;;;EAIN;;;;EAIA;;;;IAIE;;;;;;EAOF;;;;EAIA,MAAM;;;;EAIN,eAAe;;;;EAIf;;;;IAIE;;;;;;;;;;;;;;;wBC/CQ,qBAAqB,6BAA6B,6BAChE,cAAc,cACd,eAAe;;;;EAKf;;;;EAIA,kBAAkB;;;;EAIlB,MAAM,eAAe;;;;EAIrB;;;;IAIE;;;;;;;;;;;;;;;wBCrBY,0BAA0B,kCAAkC,kCAC1E,mBAAmB,mBACnB,oBAAoB;;;;EAKpB;;;;EAIA;;;;EAIA;;;;EAIA;;;;IAIE;;;;IAIA;;;;;;;;;;;;;;;wBCxBY,WAAW,QAAQ,YAAY,+CAA+C;;;;;;;;;;;wBCC9E,2BAA2B,QAAQ;;;KCV9C,YAAY,WAAW,0CAA0C;cA4BzD,eAAe,wBAAwB,YAAY;EAC9D,SAAiB;EACjB,WAAmB,UAAU,sBAAsB,iBAAiB;EACpE,YAAY,OAAO,OAAO,WAAW,UAAU,sBAAsB,iBAAiB;MAKlF,UAAU,IAAI,YAAY;MAgB1B,cAAc,IAAI,YAAY,IAAI;MAqBlC,uBAAuB,IAAI,YAAY,IAAI;EAa/C,cAAc,UAAU,YAAY,IAClC,WAAW,KAAK,GAAG,WAAW,+BAC9B,UAAU;EAOZ,iBAAiB,UAAU,YAAY,IACrC,WAAW,KAAK,GAAG,cAAc,kCACjC,UAAU;EASZ,yBAAyB,UAAU,YAAY,IAC7C,WAAW,KAAK,GAAG,8BACnB,UAAU;;iBAWE,kBAAkB,UAAU,qBAAA,MACpC,OACN,WAAW,UAAU,sBAAsB,iBAAiB,cAC3D,eAAe;;;;;;;;;;qBAaL,iBAAiB;;;;;;;;;;qBC7HjB;;;;EAKX;;;;EAIA;;;;MAMI;;;;MAeA;;;;MAOA;;;;EAQJ,mBAAA,MAAyB;;;;;;;;;qBAiBd;;;;EAIX;;;;EAIA;;;;EAIA,iBAAiB;;;;;;;;;;;qBC1EN,cAAc,UAAU;;;;EAKnC;;;;EAIA;;;;MAMI;;;;EAiBJ,YAAY,WAAW,IAAI;;;;EAW3B,eAAe,WAAW,IAAI;;;;EAW9B,eAAe,WAAW;;;;EAe1B;;;;;;;;;qBAeW;;;;EAIX;;;;EAIA;;;;EAIA,iBAAiB;;;;;;;;;;;KCrGP,aAAa,KAAK,IAAI,gBAAgB,KAAK;;;;;;;;KAQ3C,kBAAkB,UAAU,YAAY,IAAI,cAAc,KAAK,cAAc"}
|
package/dist/model.d.ts
CHANGED
|
@@ -1,71 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This package provides a Presentation Model for resource data in an WarpDrive Cache.
|
|
3
|
-
*
|
|
4
|
-
* Models are defined as classes extending from `import Model from '@warp-drive-mirror/legacy/model';` and the
|
|
5
|
-
* attributes and relationships on these classes are parsed at runtime to supply static "schema"
|
|
6
|
-
* to WarpDrive's SchemaService.
|
|
7
|
-
*
|
|
8
|
-
* Resource data for individual resources fetched from your API is presented to the UI via instances
|
|
9
|
-
* of the `Model`s you define. An instantiated `Model` is referred to as a `record`.
|
|
10
|
-
|
|
11
|
-
When we refer to the `ModelClass` as opposed to a `Model` or `Record` we are referring
|
|
12
|
-
specifically to the class definition and the static schema methods present on it.
|
|
13
|
-
|
|
14
|
-
When we refer to a `record` we refer to a specific class instance presenting
|
|
15
|
-
the resource data for a given `type` and `id`.
|
|
16
|
-
|
|
17
|
-
### Why It's Legacy
|
|
18
|
-
|
|
19
|
-
The `Model` pattern uses class inheritance and decorators to define your data schema:
|
|
20
|
-
|
|
21
|
-
- The `attr`, `belongsTo` and `hasMany` decorators are Ember computed properties, and the
|
|
22
|
-
schema is read at runtime by walking each Model class's computed properties.
|
|
23
|
-
- Every record is an instance of its own `Model` subclass, and `Model` extends `EmberObject`,
|
|
24
|
-
which ties your data layer to Ember and its object model.
|
|
25
|
-
|
|
26
|
-
### Modern Alternative
|
|
27
|
-
|
|
28
|
-
Use **schemas** with `@warp-drive-mirror/core`. Modern ***Warp*Drive**:
|
|
29
|
-
|
|
30
|
-
- defines each resource's schema as a plain object, a `ResourceSchema`, registered with the
|
|
31
|
-
store's SchemaService, with no class or decorators
|
|
32
|
-
- presents every resource type through one record implementation,
|
|
33
|
-
[ReactiveResource](/api/@warp-drive-mirror/core/reactive/types/ReactiveResource), which reads
|
|
34
|
-
its fields from the registered schema
|
|
35
|
-
- shares fields across schemas with [traits](/guides/the-manual/schemas/traits), and adds
|
|
36
|
-
memoized read-only fields with [derivations](/guides/the-manual/schemas/derivations) and
|
|
37
|
-
value conversions with [transformations](/guides/the-manual/schemas/transformations),
|
|
38
|
-
instead of inheritance
|
|
39
|
-
- works in any framework ***Warp*Drive** supports, since `@warp-drive-mirror/core` has no runtime
|
|
40
|
-
dependency on Ember (see [Installation](/guides/installation/))
|
|
41
|
-
|
|
42
|
-
For guidance on migrating from Model classes to schemas, see the
|
|
43
|
-
[Schemas Guide](/guides/the-manual/schemas/) and the [Migration Guide](/upgrading/v5/).
|
|
44
|
-
|
|
45
|
-
### Defining a Model
|
|
46
|
-
|
|
47
|
-
```js [app/models/person.js]
|
|
48
|
-
import Model, { attr, belongsTo, hasMany } from '@warp-drive-mirror/legacy/model';
|
|
49
|
-
|
|
50
|
-
export default class PersonModel extends Model {
|
|
51
|
-
@attr name;
|
|
52
|
-
|
|
53
|
-
@belongsTo('pet', { inverse: 'owners', async: false }) dog;
|
|
54
|
-
|
|
55
|
-
@hasMany('person', { inverse: 'friends', async: true }) friends;
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### modelName convention
|
|
60
|
-
|
|
61
|
-
By convention, the name of a given model (its `type`) matches the name
|
|
62
|
-
of the file in the `app/models` folder and should be lowercase, singular
|
|
63
|
-
and dasherized.
|
|
64
|
-
|
|
65
|
-
@summary Legacy `Model` base class and `attr`, `belongsTo`, and `hasMany` decorators that define resource schemas
|
|
66
|
-
as classes and present records.
|
|
67
|
-
@module
|
|
68
|
-
*/
|
|
69
1
|
import { S as belongsTo, b as RelationshipDecorator, m as PromiseBelongsTo, r as restoreDeprecatedModelRequestBehaviors, t as Model, v as PromiseManyArray, x as RelationshipOptions, y as NoNull } from "./model-BPVLf-rp.js";
|
|
70
2
|
import { Store } from "@warp-drive-mirror/core";
|
|
71
3
|
import { RelatedCollection as HasMany, RelatedCollection as ManyArray, Store as Store$1 } from "@warp-drive-mirror/core/store/-private";
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","names":["TypeFromInstance","Store","ResourceKey"],"sources":["../src/model/-private/util.ts","../src/model/-private/attr.ts","../src/model/-private/has-many.ts","../src/model/-private/hooks.ts","../src/model/-private/schema-provider.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"model.d.ts","names":["TypeFromInstance","Store","ResourceKey"],"sources":["../src/model/-private/util.ts","../src/model/-private/attr.ts","../src/model/-private/has-many.ts","../src/model/-private/hooks.ts","../src/model/-private/schema-provider.ts"],"mappings":";;;;;;;;;;;KAKY,+BAA+B;EAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;KC+BtD,YAAY,KAAK;;;;;;;;;;;EAW3B,eAAe,WAAW,iBAAiB,WAAW;;;;;;;;;;;;;;;;;;;;;EAsBtD;;KA8EG,uBAAuB,GAAG,KAAK;;;;;EAOlC,YAAY,OAAO,GAAG,iBAAiB;;;;;EAOvC,cAAc,OAAO,KAAK,iBAAiB;GAE1C,gBAAgB;;KAEP;GAAsB;;KAEtB,uBAAuB,GAAG,oBAClC,uBAAuB,WAAW,KAClC,uBAAuB,WAAW,KAClC,uBAAuB,YAAY,KACnC,uBAAuB,SAAS,KAChC,uBAAuB,GAAG,aAAa,KACvC,uBAAuB,GAAG,YAAY,KACtC,uBAAuB,kBAAkB,KACzC,uBAAuB,kBAAkB,KACzC,uBAAuB,mBAAmB,KAC1C,uBAAuB,GAAG,oBAAoB,KAC9C,uBAAuB,GAAG,mBAAmB;KAIrC,yBAAyB,KAAK;EAAY,iBAAiB;IACnE,WAAW;KAGHA,mBAAiB,KAAK,UAAU,mBAAmB,SAAS;KAG5D,oBAAoB,KAC9BA,mBAAiB,2BAEb,yBAAyB,2BAEvB,UAAU,uBAAuB,yBAAyB,IAAIA,mBAAiB,MAC7E,WAAW,uBAAuB,WAAW,qBAAqB,YAAY,WAAW;;;;;;;KASvF,iBAAiB,gBAAgB,aAAa,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0FjD,QAAQ;wBACR,KAAK,GAAG,MAAMA,mBAAiB,KAAK;wBACpC,KAAK,eAAe;wBACpB,KAAK,SAAS,cAAc;wBAC5B,KAAK,GAAG,MAAMA,mBAAiB,IAAI,UAAU,oBAAoB,KAAK;wBACtE,KAAK,cAAc,UAAU,uBAAuB;wBACpD,KAAK,gBAAgB,sBAAsB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBC9ClD;wBACA,QAAQ;wBACR,QAAQ,GACtB,MAAM,iBAAiB,OAAO,KAC9B,SAAS,oBAAoB,cAC5B,sBAAsB;wBAKT,QAAQ,cAAc,SAAS,wCAAwC;;;;;;;;;;;;wBClPvE,kBAAA,MACRC,SACN,YAAYC,eACZ;;IACC;;;;;;;;;wBAgCa,eAAe,QAAQ;;;;;;;;;;wBAiBvB,SAAS,GAAG,MAAM,iBAAiB,YAAY;;;;;;wBAM/C,SAAS,sBAAsB;;;;;;;;;;;;wBCkM/B,YAAY,OAAO,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime--fcdnjmJ-DMTJ0Kb3.js","names":[],"sources":["../../../node_modules/.pnpm/decorat_5d4eca388601a94e7fbc656401b751d1/node_modules/decorator-transforms/dist/runtime--fcdnjmJ.js"],"sourcesContent":["const deferred = /* @__PURE__ */ new WeakMap();\nfunction deferDecorator(proto, prop, desc) {\n let map = deferred.get(proto);\n if (!map) {\n map = /* @__PURE__ */ new Map();\n deferred.set(proto, map);\n }\n map.set(prop, desc);\n}\nfunction findDeferredDecorator(target, prop) {\n var _a;\n let cursor = target.prototype;\n while (cursor) {\n let desc = (_a = deferred.get(cursor)) == null ? void 0 : _a.get(prop);\n if (desc) {\n return desc;\n }\n cursor = Object.getPrototypeOf(cursor);\n }\n}\nfunction decorateFieldV1(target, prop, decorators, initializer) {\n return decorateFieldV2(target.prototype, prop, decorators, initializer);\n}\nfunction decorateFieldV2(prototype, prop, decorators, initializer) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: null\n };\n if (initializer) {\n desc.initializer = initializer;\n }\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer === void 0) {\n Object.defineProperty(prototype, prop, desc);\n } else {\n deferDecorator(prototype, prop, desc);\n }\n}\nfunction decorateMethodV1({ prototype }, prop, decorators) {\n return decorateMethodV2(prototype, prop, decorators);\n}\nfunction decorateMethodV2(prototype, prop, decorators) {\n const origDesc = Object.getOwnPropertyDescriptor(prototype, prop);\n let desc = { ...origDesc };\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer !== void 0) {\n desc.value = desc.initializer ? desc.initializer.call(prototype) : void 0;\n desc.initializer = void 0;\n }\n Object.defineProperty(prototype, prop, desc);\n}\nfunction initializeDeferredDecorator(target, prop) {\n let desc = findDeferredDecorator(target.constructor, prop);\n if (desc) {\n Object.defineProperty(target, prop, {\n enumerable: desc.enumerable,\n configurable: desc.configurable,\n writable: desc.writable,\n value: desc.initializer ? desc.initializer.call(target) : void 0\n });\n }\n}\nfunction decorateClass(target, decorators) {\n return decorators.reduce(\n (accum, decorator) => decorator(accum) || accum,\n target\n );\n}\nfunction decoratePOJO(pojo, decorated) {\n for (let [type, prop, decorators] of decorated) {\n if (type === \"field\") {\n decoratePojoField(pojo, prop, decorators);\n } else {\n decorateMethodV2(pojo, prop, decorators);\n }\n }\n return pojo;\n}\nfunction decoratePojoField(pojo, prop, decorators) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: () => {\n var _a;\n return (_a = Object.getOwnPropertyDescriptor(pojo, prop)) == null ? void 0 : _a.value;\n }\n };\n for (let decorator of decorators) {\n desc = decorator(pojo, prop, desc) || desc;\n }\n if (desc.initializer) {\n desc.value = desc.initializer.call(pojo);\n delete desc.initializer;\n }\n Object.defineProperty(pojo, prop, desc);\n}\nconst runtime = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({\n __proto__: null,\n c: decorateClass,\n f: decorateFieldV1,\n g: decorateFieldV2,\n i: initializeDeferredDecorator,\n m: decorateMethodV1,\n n: decorateMethodV2,\n p: decoratePOJO\n}, Symbol.toStringTag, { value: \"Module\" }));\nexport {\n decorateFieldV1 as a,\n decorateFieldV2 as b,\n decorateMethodV1 as c,\n decorateClass as d,\n decorateMethodV2 as e,\n decoratePOJO as f,\n initializeDeferredDecorator as i,\n runtime as r\n};\n//# sourceMappingURL=runtime--fcdnjmJ.js.map\n"],"
|
|
1
|
+
{"version":3,"file":"runtime--fcdnjmJ-DMTJ0Kb3.js","names":[],"sources":["../../../node_modules/.pnpm/decorat_5d4eca388601a94e7fbc656401b751d1/node_modules/decorator-transforms/dist/runtime--fcdnjmJ.js"],"sourcesContent":["const deferred = /* @__PURE__ */ new WeakMap();\nfunction deferDecorator(proto, prop, desc) {\n let map = deferred.get(proto);\n if (!map) {\n map = /* @__PURE__ */ new Map();\n deferred.set(proto, map);\n }\n map.set(prop, desc);\n}\nfunction findDeferredDecorator(target, prop) {\n var _a;\n let cursor = target.prototype;\n while (cursor) {\n let desc = (_a = deferred.get(cursor)) == null ? void 0 : _a.get(prop);\n if (desc) {\n return desc;\n }\n cursor = Object.getPrototypeOf(cursor);\n }\n}\nfunction decorateFieldV1(target, prop, decorators, initializer) {\n return decorateFieldV2(target.prototype, prop, decorators, initializer);\n}\nfunction decorateFieldV2(prototype, prop, decorators, initializer) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: null\n };\n if (initializer) {\n desc.initializer = initializer;\n }\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer === void 0) {\n Object.defineProperty(prototype, prop, desc);\n } else {\n deferDecorator(prototype, prop, desc);\n }\n}\nfunction decorateMethodV1({ prototype }, prop, decorators) {\n return decorateMethodV2(prototype, prop, decorators);\n}\nfunction decorateMethodV2(prototype, prop, decorators) {\n const origDesc = Object.getOwnPropertyDescriptor(prototype, prop);\n let desc = { ...origDesc };\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer !== void 0) {\n desc.value = desc.initializer ? desc.initializer.call(prototype) : void 0;\n desc.initializer = void 0;\n }\n Object.defineProperty(prototype, prop, desc);\n}\nfunction initializeDeferredDecorator(target, prop) {\n let desc = findDeferredDecorator(target.constructor, prop);\n if (desc) {\n Object.defineProperty(target, prop, {\n enumerable: desc.enumerable,\n configurable: desc.configurable,\n writable: desc.writable,\n value: desc.initializer ? desc.initializer.call(target) : void 0\n });\n }\n}\nfunction decorateClass(target, decorators) {\n return decorators.reduce(\n (accum, decorator) => decorator(accum) || accum,\n target\n );\n}\nfunction decoratePOJO(pojo, decorated) {\n for (let [type, prop, decorators] of decorated) {\n if (type === \"field\") {\n decoratePojoField(pojo, prop, decorators);\n } else {\n decorateMethodV2(pojo, prop, decorators);\n }\n }\n return pojo;\n}\nfunction decoratePojoField(pojo, prop, decorators) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: () => {\n var _a;\n return (_a = Object.getOwnPropertyDescriptor(pojo, prop)) == null ? void 0 : _a.value;\n }\n };\n for (let decorator of decorators) {\n desc = decorator(pojo, prop, desc) || desc;\n }\n if (desc.initializer) {\n desc.value = desc.initializer.call(pojo);\n delete desc.initializer;\n }\n Object.defineProperty(pojo, prop, desc);\n}\nconst runtime = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({\n __proto__: null,\n c: decorateClass,\n f: decorateFieldV1,\n g: decorateFieldV2,\n i: initializeDeferredDecorator,\n m: decorateMethodV1,\n n: decorateMethodV2,\n p: decoratePOJO\n}, Symbol.toStringTag, { value: \"Module\" }));\nexport {\n decorateFieldV1 as a,\n decorateFieldV2 as b,\n decorateMethodV1 as c,\n decorateClass as d,\n decorateMethodV2 as e,\n decoratePOJO as f,\n initializeDeferredDecorator as i,\n runtime as r\n};\n//# sourceMappingURL=runtime--fcdnjmJ.js.map\n"],"ignoreList":[0],"mappings":";AAAA,MAAM,2BAA2B,IAAI,QAAQ;AAC7C,SAAS,eAAe,OAAO,MAAM,MAAM;CACzC,IAAI,MAAM,SAAS,IAAI,KAAK;CAC5B,IAAI,CAAC,KAAK;EACR,sBAAsB,IAAI,IAAI;EAC9B,SAAS,IAAI,OAAO,GAAG;CACzB;CACA,IAAI,IAAI,MAAM,IAAI;AACpB;AACA,SAAS,sBAAsB,QAAQ,MAAM;CAC3C,IAAI;CACJ,IAAI,SAAS,OAAO;CACpB,OAAO,QAAQ;EACb,IAAI,QAAQ,KAAK,SAAS,IAAI,MAAM,MAAM,OAAO,KAAK,IAAI,GAAG,IAAI,IAAI;EACrE,IAAI,MACF,OAAO;EAET,SAAS,OAAO,eAAe,MAAM;CACvC;AACF;AAIA,SAAS,gBAAgB,WAAW,MAAM,YAAY,aAAa;CACjE,IAAI,OAAO;EACT,cAAc;EACd,YAAY;EACZ,UAAU;EACV,aAAa;CACf;CACA,IAAI,aACF,KAAK,cAAc;CAErB,KAAK,IAAI,aAAa,YACpB,OAAO,UAAU,WAAW,MAAM,IAAI,KAAK;CAE7C,IAAI,KAAK,gBAAgB,KAAK,GAC5B,OAAO,eAAe,WAAW,MAAM,IAAI;MAE3C,eAAe,WAAW,MAAM,IAAI;AAExC;AAIA,SAAS,iBAAiB,WAAW,MAAM,YAAY;CAErD,IAAI,OAAO,EAAE,GADI,OAAO,yBAAyB,WAAW,IACrC,EAAE;CACzB,KAAK,IAAI,aAAa,YACpB,OAAO,UAAU,WAAW,MAAM,IAAI,KAAK;CAE7C,IAAI,KAAK,gBAAgB,KAAK,GAAG;EAC/B,KAAK,QAAQ,KAAK,cAAc,KAAK,YAAY,KAAK,SAAS,IAAI,KAAK;EACxE,KAAK,cAAc,KAAK;CAC1B;CACA,OAAO,eAAe,WAAW,MAAM,IAAI;AAC7C;AACA,SAAS,4BAA4B,QAAQ,MAAM;CACjD,IAAI,OAAO,sBAAsB,OAAO,aAAa,IAAI;CACzD,IAAI,MACF,OAAO,eAAe,QAAQ,MAAM;EAClC,YAAY,KAAK;EACjB,cAAc,KAAK;EACnB,UAAU,KAAK;EACf,OAAO,KAAK,cAAc,KAAK,YAAY,KAAK,MAAM,IAAI,KAAK;CACjE,CAAC;AAEL"}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module
|
|
3
|
-
* @summary Legacy transforms that serialize and deserialize attribute values: the `Transform` base class plus the
|
|
4
|
-
* boolean, date, number and string transforms.
|
|
5
|
-
*/
|
|
6
1
|
import EmberObject from "@ember/object";
|
|
7
2
|
import { TransformName } from "@warp-drive-mirror/core/types/symbols";
|
|
8
3
|
import { LegacyAttributeField } from "@warp-drive-mirror/core/types/schema/fields";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","names":[],"sources":["../../src/serializer/-private/transforms/transform.ts","../../src/serializer/-private/transforms/boolean.ts","../../src/serializer/-private/transforms/date.ts","../../src/serializer/-private/transforms/number.ts","../../src/serializer/-private/transforms/string.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"transform.d.ts","names":[],"sources":["../../src/serializer/-private/transforms/transform.ts","../../src/serializer/-private/transforms/boolean.ts","../../src/serializer/-private/transforms/date.ts","../../src/serializer/-private/transforms/number.ts","../../src/serializer/-private/transforms/string.ts"],"mappings":";;;;iBAIiB;;;;;;;;;;;;;;;;;;EAkBf,UAAU,gBAAgB,SAAS;;;;;;;;;;;;;;;;;;EAmBnC,YAAY,gBAAgB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAkF1B,kBAAkB;;;iBCtHd;;;;GAId;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAuCU;;;;;EAKX,YAAY,8CAA8C;IAAY;;;;;EAmBtE,UAAU,8BAA8B;IAAY;;;;;SAW7C,UAAU;;;;iBC9EF;;;;GAId;;;;;;;;;;;;;;;;;;;;;;;qBAwBU;;;;;EAKX,YAAY,oCAAoC,WAAW,0BAA0B;;;;;EAwBrF,UAAU,MAAM,MAAM,WAAW;;;;SAY1B,UAAU;;;;iBCjEF;;;;GAId;;;;;;;;;;;;;;;;;;;;;;;;qBAyBU;;;;;EAKX,YAAY,gDAAgD,WAAW;;;;EAavE,UAAU,kDAAkD,WAAW;;;;SAahE,UAAU;;;;iBChEF;;;;GAId;;;;;;;;;;;;;;;;;;;;;;;qBAuBU;;;;;EAKX,YAAY,qBAAqB,WAAW;;;;EAM5C,UAAU,uBAAuB,WAAW;;;;SAOrC,UAAU"}
|
package/dist/serializer.d.ts
CHANGED
|
@@ -1,146 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
## Overview
|
|
3
|
-
|
|
4
|
-
:::danger
|
|
5
|
-
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
6
|
-
If starting a new app or thinking of implementing a new serializer, consider writing a
|
|
7
|
-
{@link Handler} instead to be used with the {@link RequestManager}
|
|
8
|
-
:::
|
|
9
|
-
|
|
10
|
-
In order to properly manage and present your data, WarpDrive
|
|
11
|
-
needs to understand the structure of data it receives.
|
|
12
|
-
|
|
13
|
-
`Serializers` convert data between the server's API format and
|
|
14
|
-
the format WarpDrive understands.
|
|
15
|
-
|
|
16
|
-
Data received from an API response is **normalized** into
|
|
17
|
-
[{json:api}](https://jsonapi.org/) (the format used internally
|
|
18
|
-
by WarpDrive), while data sent to an API is **serialized**
|
|
19
|
-
into the format the API expects.
|
|
20
|
-
|
|
21
|
-
### Why It's Legacy
|
|
22
|
-
|
|
23
|
-
The Serializer pattern was designed to transform data between your API's format and the
|
|
24
|
-
{json:api} format the legacy store works with:
|
|
25
|
-
|
|
26
|
-
- `store.serializerFor` resolves a serializer by resource type at runtime, looking up
|
|
27
|
-
`serializer:<type>` and then `serializer:application` through Ember's owner, though an
|
|
28
|
-
API's format more often varies per API version than per resource type (see Serializer
|
|
29
|
-
Resolution below).
|
|
30
|
-
- Every response is converted into {json:api} before it reaches the cache, whatever format
|
|
31
|
-
the API actually uses.
|
|
32
|
-
- The provided serializer classes extend `EmberObject`, which, together with the owner
|
|
33
|
-
lookup, ties the pattern to Ember.
|
|
34
|
-
|
|
35
|
-
### Modern Alternative
|
|
36
|
-
|
|
37
|
-
Use [Handlers](/api/@warp-drive-mirror/core/request/types/Handler) with the {@link RequestManager}.
|
|
38
|
-
Modern ***Warp*Drive**:
|
|
39
|
-
|
|
40
|
-
- normalizes a payload inside a handler when it needs transforming, using plain functions
|
|
41
|
-
and helpers such as `dasherize` and `singularize` from `@warp-drive-mirror/utilities/string`
|
|
42
|
-
- lets you pick a cache that understands your API's format natively, such as `JSONAPICache`
|
|
43
|
-
from `@warp-drive-mirror/json-api` for {json:api}, or write your own that implements the Cache
|
|
44
|
-
interface
|
|
45
|
-
|
|
46
|
-
For an alternative modern pattern to Serializers, see the
|
|
47
|
-
[Request Handlers Guide](/guides/the-manual/requests/handlers).
|
|
48
|
-
|
|
49
|
-
### Setup
|
|
50
|
-
|
|
51
|
-
Serializers run inside the `LegacyNetworkHandler` from
|
|
52
|
-
[`@warp-drive-mirror/legacy/compat`](/api/@warp-drive-mirror/legacy/compat/). A store created with
|
|
53
|
-
`useLegacyStore` adds it unless `linksMode` is `true`; a store you build yourself must add it
|
|
54
|
-
to its `RequestManager`, as shown in
|
|
55
|
-
[Configure the Store](/guides/configuration/legacy-package-setup/setup/universal.md#configure-the-store).
|
|
56
|
-
|
|
57
|
-
### Implementing a Serializer
|
|
58
|
-
|
|
59
|
-
There are only two required serializer methods, one for
|
|
60
|
-
normalizing data from the server API format into {json:api}, and
|
|
61
|
-
another for serializing records via `Snapshots` into the expected
|
|
62
|
-
server API format.
|
|
63
|
-
|
|
64
|
-
To implement a serializer, export a class that conforms to the structure
|
|
65
|
-
described by {@link MinimumSerializerInterface}
|
|
66
|
-
from the `app/serializers/` directory. An example is below.
|
|
67
|
-
|
|
68
|
-
```ts
|
|
69
|
-
import EmberObject from '@ember/object';
|
|
70
|
-
|
|
71
|
-
export default class ApplicationSerializer extends EmberObject {
|
|
72
|
-
normalizeResponse(store, schema, rawPayload) {
|
|
73
|
-
return rawPayload;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
serialize(snapshot, options) {
|
|
77
|
-
const serializedResource = {
|
|
78
|
-
id: snapshot.id,
|
|
79
|
-
type: snapshot.modelName,
|
|
80
|
-
attributes: snapshot.attributes()
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
return serializedResource;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
### Serializer Resolution
|
|
90
|
-
|
|
91
|
-
`store.serializerFor(name)` will lookup serializers defined in
|
|
92
|
-
`app/serializers/` and return an instance. If no serializer is found, an
|
|
93
|
-
error will be thrown.
|
|
94
|
-
|
|
95
|
-
`serializerFor` first attempts to find a serializer with an exact match on `name`,
|
|
96
|
-
then falls back to checking for the presence of a serializer named `application`.
|
|
97
|
-
|
|
98
|
-
```ts
|
|
99
|
-
store.serializerFor('author');
|
|
100
|
-
|
|
101
|
-
// lookup paths (in order) =>
|
|
102
|
-
// app/serializers/author.js
|
|
103
|
-
// app/serializers/application.js
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
Most requests in `@warp-drive-mirror/legacy` are made with respect to a particular `type` (or `modelName`)
|
|
107
|
-
(e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We
|
|
108
|
-
refer to this as the **primary** resource `type`.
|
|
109
|
-
|
|
110
|
-
Typically `serializerFor` will be used to find a serializer with a name matching that of the primary
|
|
111
|
-
resource `type` for the request, falling back to the `application` serializer for those types that
|
|
112
|
-
do not have a defined serializer. This is often described as a `per-model` or `per-type` strategy
|
|
113
|
-
for defining serializers. However, because APIs rarely format payloads per-type but rather
|
|
114
|
-
per-API-version, this may not be a desired strategy.
|
|
115
|
-
|
|
116
|
-
It is recommended that applications define only a single `application` adapter and serializer
|
|
117
|
-
where possible.
|
|
118
|
-
|
|
119
|
-
If you have multiple API formats and the per-type strategy is not viable, one strategy is to
|
|
120
|
-
write an `application` adapter and serializer that make use of `options` to specify the desired
|
|
121
|
-
format when making a request.
|
|
122
|
-
|
|
123
|
-
### Using a Serializer
|
|
124
|
-
|
|
125
|
-
Any serializer in `app/serializers/` can be looked up by `name` using `store.serializerFor(name)`.
|
|
126
|
-
|
|
127
|
-
### Default Serializers
|
|
128
|
-
|
|
129
|
-
For applications whose APIs are *very close to* or *exactly* the **REST** format or **JSON:API**
|
|
130
|
-
format the `@warp-drive-mirror/legacy/serializer` package contains implementations these applications can
|
|
131
|
-
extend. It also contains a simple `JSONSerializer` for serializing to/from very basic JSON objects.
|
|
132
|
-
|
|
133
|
-
Many applications will find writing their own serializer to be more performant and less
|
|
134
|
-
complex than extending these classes even when their API format is very close to that expected
|
|
135
|
-
by these serializers.
|
|
136
|
-
|
|
137
|
-
It is recommended that apps write their own serializer to best suit the needs of their API and
|
|
138
|
-
application.
|
|
139
|
-
|
|
140
|
-
@summary Legacy serializer layer that converts data between an API's format and JSON:API for the adapter-based
|
|
141
|
-
request flow.
|
|
142
|
-
@module
|
|
143
|
-
*/
|
|
144
1
|
import { Store } from "@warp-drive-mirror/core";
|
|
145
2
|
import EmberObject from "@ember/object";
|
|
146
3
|
import { ModelSchema } from "@warp-drive-mirror/core/types";
|
package/dist/serializer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.d.ts","names":[],"sources":["../src/serializer.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","names":[],"sources":["../src/serializer.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;qBAuLa,mBAAmB;;;;;;;;;;;;;;;;;;;;EAoB9B,OAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwGxB,UAAU,YAAY,aAAa,MAAM,0BAA0B,yBAAyB"}
|
package/dist/store.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module
|
|
3
|
-
* @summary Legacy `restoreDeprecatedStoreBehaviors`, which restores the adapter-based `findRecord`, `findAll`, `query`,
|
|
4
|
-
* `saveRecord` and related methods onto a `Store` class.
|
|
5
|
-
*/
|
|
6
1
|
import { Store } from "@warp-drive-mirror/core";
|
|
7
2
|
//#region src/store.d.ts
|
|
8
3
|
/**
|
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","names":[],"sources":["../src/store.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"store.d.ts","names":[],"sources":["../src/store.ts"],"mappings":";;;;;;;;;;;;wBA0CgB,gCAAgC,mBAAmB"}
|