@warp-drive/legacy 5.8.0-alpha.9 → 5.8.0-beta.1
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/README.md +14 -27
- package/declarations/adapter/error.d.ts +7 -7
- package/declarations/adapter/json-api.d.ts +2 -2
- package/declarations/adapter/rest.d.ts +21 -104
- package/declarations/adapter.d.ts +2 -2
- package/declarations/compat/builders/find-all.d.ts +6 -6
- package/declarations/compat/builders/find-record.d.ts +8 -8
- package/declarations/compat/builders/query.d.ts +12 -12
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +16 -24
- package/declarations/compat/utils.d.ts +13 -13
- package/declarations/compat.d.ts +31 -5
- package/declarations/index.d.ts +25 -8
- package/declarations/model/-private/legacy-relationships-support.d.ts +2 -2
- package/declarations/model/-private/model.d.ts +10 -51
- package/declarations/model/-private/promise-many-array.d.ts +0 -18
- package/declarations/model/-private/references/belongs-to.d.ts +18 -28
- package/declarations/model/-private/references/has-many.d.ts +13 -15
- package/declarations/model/migration-support.d.ts +42 -19
- package/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
- package/declarations/model-fragments/extensions/fragment.d.ts +15 -0
- package/declarations/model-fragments/hooks/model-for.d.ts +20 -0
- package/declarations/model-fragments/index.d.ts +5 -0
- package/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
- package/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
- package/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
- package/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
- package/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
- package/declarations/model-fragments.d.ts +9 -0
- package/declarations/model.d.ts +2 -2
- package/declarations/serializer/-private/embedded-records-mixin.d.ts +1 -1
- package/declarations/serializer/json-api.d.ts +7 -6
- package/declarations/serializer/json.d.ts +3 -3
- package/declarations/serializer.d.ts +5 -6
- package/dist/{-private-B1pSSN52.js → -private-BG3bMiKp.js} +2 -1
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +9 -9
- package/dist/adapter/json-api.js +1 -1
- package/dist/adapter/rest.js +33 -117
- package/dist/adapter.js +2 -2
- package/dist/compat/-private.js +1 -1
- package/dist/compat/builders.js +26 -26
- package/dist/compat/utils.js +13 -14
- package/dist/compat.js +28 -8
- package/dist/{errors-COviC59J.js → errors-Cz5KrzBk.js} +113 -120
- package/dist/{hooks-Bp8SIQBU.js → hooks-D6diaM34.js} +1 -1
- package/dist/index.js +25 -8
- package/dist/{json-ksWOHRfq.js → json-ChdEfB0X.js} +12 -27
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +55 -25
- package/dist/model-for-CqXsIKws.js +221 -0
- package/dist/model-fragments.js +76 -0
- package/dist/model.js +3 -3
- package/dist/{schema-provider-JlCneqZH.js → schema-provider-DJCV_6AF.js} +44 -87
- package/dist/{serialize-into-hash-BnYvPex3.js → serialize-into-hash-DPZYoF-i.js} +1 -1
- package/dist/serializer/json-api.js +18 -45
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.js +10 -10
- package/dist/serializer.js +5 -6
- package/dist/store.js +2 -1
- package/dist/unpkg/dev/-private-DtjBbEgy.js +1206 -0
- package/dist/unpkg/dev/adapter/-private.js +1 -0
- package/dist/unpkg/dev/adapter/error.js +335 -0
- package/dist/unpkg/dev/adapter/json-api.js +271 -0
- package/dist/unpkg/dev/adapter/rest.js +1171 -0
- package/dist/unpkg/dev/adapter.js +1252 -0
- package/dist/unpkg/dev/compat/-private.js +1 -0
- package/dist/unpkg/dev/compat/builders.js +275 -0
- package/dist/unpkg/dev/compat/extensions.js +242 -0
- package/dist/unpkg/dev/compat/utils.js +223 -0
- package/dist/unpkg/dev/compat.js +1147 -0
- package/dist/unpkg/dev/errors-DmGGJr3T.js +2562 -0
- package/dist/unpkg/dev/hooks-CkYiE6Ud.js +73 -0
- package/dist/unpkg/dev/index.js +197 -0
- package/dist/unpkg/dev/json-Cu1LNgmQ.js +1256 -0
- package/dist/unpkg/dev/model/-private.js +1 -0
- package/dist/unpkg/dev/model/migration-support.js +553 -0
- package/dist/unpkg/dev/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/dev/model-fragments.js +76 -0
- package/dist/unpkg/dev/model.js +678 -0
- package/dist/unpkg/dev/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/dev/schema-provider-DDVYxmUV.js +2186 -0
- package/dist/unpkg/dev/serialize-into-hash-B2xDbuo5.js +259 -0
- package/dist/unpkg/dev/serializer/json-api.js +649 -0
- package/dist/unpkg/dev/serializer/json.js +4 -0
- package/dist/unpkg/dev/serializer/rest.js +1242 -0
- package/dist/unpkg/dev/serializer/transform.js +278 -0
- package/dist/unpkg/dev/serializer.js +248 -0
- package/dist/unpkg/dev/store.js +637 -0
- package/dist/unpkg/dev/util-DvanW33H.js +20 -0
- package/dist/unpkg/dev/utils-BhvS1iTS.js +8 -0
- package/dist/unpkg/dev-deprecated/-private-DtjBbEgy.js +1206 -0
- package/dist/unpkg/dev-deprecated/adapter/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/adapter/error.js +335 -0
- package/dist/unpkg/dev-deprecated/adapter/json-api.js +271 -0
- package/dist/unpkg/dev-deprecated/adapter/rest.js +1171 -0
- package/dist/unpkg/dev-deprecated/adapter.js +1252 -0
- package/dist/unpkg/dev-deprecated/compat/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/compat/builders.js +275 -0
- package/dist/unpkg/dev-deprecated/compat/extensions.js +242 -0
- package/dist/unpkg/dev-deprecated/compat/utils.js +223 -0
- package/dist/unpkg/dev-deprecated/compat.js +1147 -0
- package/dist/unpkg/dev-deprecated/errors-Spt6ubMd.js +2565 -0
- package/dist/unpkg/dev-deprecated/hooks-DOXegvhL.js +73 -0
- package/dist/unpkg/dev-deprecated/index.js +196 -0
- package/dist/unpkg/dev-deprecated/json-Cu1LNgmQ.js +1256 -0
- package/dist/unpkg/dev-deprecated/model/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/model/migration-support.js +570 -0
- package/dist/unpkg/dev-deprecated/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/dev-deprecated/model-fragments.js +76 -0
- package/dist/unpkg/dev-deprecated/model.js +682 -0
- package/dist/unpkg/dev-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/dev-deprecated/schema-provider-BP6_8N-V.js +2211 -0
- package/dist/unpkg/dev-deprecated/serialize-into-hash-B2xDbuo5.js +259 -0
- package/dist/unpkg/dev-deprecated/serializer/json-api.js +649 -0
- package/dist/unpkg/dev-deprecated/serializer/json.js +4 -0
- package/dist/unpkg/dev-deprecated/serializer/rest.js +1242 -0
- package/dist/unpkg/dev-deprecated/serializer/transform.js +278 -0
- package/dist/unpkg/dev-deprecated/serializer.js +248 -0
- package/dist/unpkg/dev-deprecated/store.js +637 -0
- package/dist/unpkg/dev-deprecated/util-CWr5WQOT.js +24 -0
- package/dist/unpkg/dev-deprecated/utils-C9PJehtL.js +12 -0
- package/dist/unpkg/prod/-private-BdyZaGEh.js +971 -0
- package/dist/unpkg/prod/adapter/-private.js +1 -0
- package/dist/unpkg/prod/adapter/error.js +330 -0
- package/dist/unpkg/prod/adapter/json-api.js +266 -0
- package/dist/unpkg/prod/adapter/rest.js +1134 -0
- package/dist/unpkg/prod/adapter.js +1219 -0
- package/dist/unpkg/prod/compat/-private.js +1 -0
- package/dist/unpkg/prod/compat/builders.js +210 -0
- package/dist/unpkg/prod/compat/extensions.js +232 -0
- package/dist/unpkg/prod/compat/utils.js +218 -0
- package/dist/unpkg/prod/compat.js +727 -0
- package/dist/unpkg/prod/errors-BGVFCBmi.js +2314 -0
- package/dist/unpkg/prod/hooks-BztVA_x0.js +41 -0
- package/dist/unpkg/prod/index.js +151 -0
- package/dist/unpkg/prod/json-BWrZ5546.js +1243 -0
- package/dist/unpkg/prod/model/-private.js +1 -0
- package/dist/unpkg/prod/model/migration-support.js +546 -0
- package/dist/unpkg/prod/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/prod/model-fragments.js +76 -0
- package/dist/unpkg/prod/model.js +593 -0
- package/dist/unpkg/prod/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/prod/schema-provider-DJtD_8jZ.js +1861 -0
- package/dist/unpkg/prod/serialize-into-hash-DGlzQteF.js +215 -0
- package/dist/unpkg/prod/serializer/json-api.js +592 -0
- package/dist/unpkg/prod/serializer/json.js +4 -0
- package/dist/unpkg/prod/serializer/rest.js +1210 -0
- package/dist/unpkg/prod/serializer/transform.js +278 -0
- package/dist/unpkg/prod/serializer.js +248 -0
- package/dist/unpkg/prod/store.js +505 -0
- package/dist/unpkg/prod/util-DvanW33H.js +20 -0
- package/dist/unpkg/prod/utils-BhvS1iTS.js +8 -0
- package/dist/unpkg/prod-deprecated/-private-BdyZaGEh.js +971 -0
- package/dist/unpkg/prod-deprecated/adapter/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/adapter/error.js +330 -0
- package/dist/unpkg/prod-deprecated/adapter/json-api.js +266 -0
- package/dist/unpkg/prod-deprecated/adapter/rest.js +1134 -0
- package/dist/unpkg/prod-deprecated/adapter.js +1219 -0
- package/dist/unpkg/prod-deprecated/compat/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/compat/builders.js +210 -0
- package/dist/unpkg/prod-deprecated/compat/extensions.js +232 -0
- package/dist/unpkg/prod-deprecated/compat/utils.js +218 -0
- package/dist/unpkg/prod-deprecated/compat.js +727 -0
- package/dist/unpkg/prod-deprecated/errors-CdDaK81x.js +2317 -0
- package/dist/unpkg/prod-deprecated/hooks-yId87yyG.js +41 -0
- package/dist/unpkg/prod-deprecated/index.js +150 -0
- package/dist/unpkg/prod-deprecated/json-BWrZ5546.js +1243 -0
- package/dist/unpkg/prod-deprecated/model/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/model/migration-support.js +563 -0
- package/dist/unpkg/prod-deprecated/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/prod-deprecated/model-fragments.js +76 -0
- package/dist/unpkg/prod-deprecated/model.js +596 -0
- package/dist/unpkg/prod-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/prod-deprecated/schema-provider-CjX55uSY.js +1904 -0
- package/dist/unpkg/prod-deprecated/serialize-into-hash-DGlzQteF.js +215 -0
- package/dist/unpkg/prod-deprecated/serializer/json-api.js +592 -0
- package/dist/unpkg/prod-deprecated/serializer/json.js +4 -0
- package/dist/unpkg/prod-deprecated/serializer/rest.js +1210 -0
- package/dist/unpkg/prod-deprecated/serializer/transform.js +278 -0
- package/dist/unpkg/prod-deprecated/serializer.js +248 -0
- package/dist/unpkg/prod-deprecated/store.js +505 -0
- package/dist/unpkg/prod-deprecated/util-B6cn-i93.js +23 -0
- package/dist/unpkg/prod-deprecated/utils-BUWwQwCh.js +11 -0
- package/logos/README.md +2 -2
- package/logos/logo-yellow-slab.svg +1 -0
- package/logos/word-mark-black.svg +1 -0
- package/logos/word-mark-white.svg +1 -0
- package/package.json +14 -6
- package/logos/NCC-1701-a-blue.svg +0 -4
- package/logos/NCC-1701-a-gold.svg +0 -4
- package/logos/NCC-1701-a-gold_100.svg +0 -1
- package/logos/NCC-1701-a-gold_base-64.txt +0 -1
- package/logos/NCC-1701-a.svg +0 -4
- package/logos/docs-badge.svg +0 -2
- package/logos/ember-data-logo-dark.svg +0 -12
- package/logos/ember-data-logo-light.svg +0 -12
- package/logos/social1.png +0 -0
- package/logos/social2.png +0 -0
- package/logos/warp-drive-logo-dark.svg +0 -4
- package/logos/warp-drive-logo-gold.svg +0 -4
|
@@ -14,14 +14,14 @@ needs to understand the structure of data it receives.
|
|
|
14
14
|
the format WarpDrive understands.
|
|
15
15
|
|
|
16
16
|
Data received from an API response is **normalized** into
|
|
17
|
-
[
|
|
17
|
+
[{json:api}](https://jsonapi.org/) (the format used internally
|
|
18
18
|
by WarpDrive), while data sent to an API is **serialized**
|
|
19
19
|
into the format the API expects.
|
|
20
20
|
|
|
21
21
|
### Implementing a Serializer
|
|
22
22
|
|
|
23
23
|
There are only two required serializer methods, one for
|
|
24
|
-
normalizing data from the server API format into
|
|
24
|
+
normalizing data from the server API format into {json:api}, and
|
|
25
25
|
another for serializing records via `Snapshots` into the expected
|
|
26
26
|
server API format.
|
|
27
27
|
|
|
@@ -67,7 +67,7 @@ store.serializerFor('author');
|
|
|
67
67
|
// app/serializers/application.js
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
Most requests in
|
|
70
|
+
Most requests in `@warp-drive/legacy` are made with respect to a particular `type` (or `modelName`)
|
|
71
71
|
(e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We
|
|
72
72
|
refer to this as the **primary** resource `type`.
|
|
73
73
|
|
|
@@ -91,7 +91,7 @@ Any serializer in `app/serializers/` can be looked up by `name` using `store.ser
|
|
|
91
91
|
### Default Serializers
|
|
92
92
|
|
|
93
93
|
For applications whose APIs are *very close to* or *exactly* the **REST** format or **JSON:API**
|
|
94
|
-
format the `@
|
|
94
|
+
format the `@warp-drive/legacy/serializer` package contains implementations these applications can
|
|
95
95
|
extend. It also contains a simple `JSONSerializer` for serializing to/from very basic JSON objects.
|
|
96
96
|
|
|
97
97
|
Many applications will find writing their own serializer to be more performant and less
|
|
@@ -122,8 +122,7 @@ And you can optionally override the following methods:
|
|
|
122
122
|
|
|
123
123
|
* `normalize()`
|
|
124
124
|
|
|
125
|
-
For an example implementation, see
|
|
126
|
-
[JSONSerializer](JSONSerializer), the included JSON serializer.
|
|
125
|
+
For an example implementation, see the included {@link JSONSerializer}.
|
|
127
126
|
|
|
128
127
|
@class Serializer
|
|
129
128
|
@public
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Context } from '@warp-drive/core/reactive/-private';
|
|
2
2
|
import { warn } from '@ember/debug';
|
|
3
3
|
import { createDeferred } from '@warp-drive/core/request';
|
|
4
|
-
import {
|
|
4
|
+
import { waitFor } from '@warp-drive/core/signals/-leaked';
|
|
5
|
+
import { assertPrivateStore, coerceId } from '@warp-drive/core/store/-private';
|
|
5
6
|
import { getOrSetGlobal } from '@warp-drive/core/types/-private';
|
|
6
7
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
7
8
|
|
package/dist/adapter/-private.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { d as determineBodyPromise, g as fetch, p as parseResponseHeaders, b as serializeIntoHash, s as serializeQueryParams, a as setupFastboot } from "../serialize-into-hash-
|
|
1
|
+
export { d as determineBodyPromise, g as fetch, p as parseResponseHeaders, b as serializeIntoHash, s as serializeQueryParams, a as setupFastboot } from "../serialize-into-hash-DPZYoF-i.js";
|
package/dist/adapter/error.js
CHANGED
|
@@ -24,7 +24,7 @@ import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
|
24
24
|
it was closed for maintenance:
|
|
25
25
|
|
|
26
26
|
```js [app/adapters/maintenance-error.js]
|
|
27
|
-
import AdapterError from '@
|
|
27
|
+
import AdapterError from '@warp-drive/legacy/adapter/error';
|
|
28
28
|
|
|
29
29
|
export default AdapterError.extend({ message: "Down for maintenance." });
|
|
30
30
|
```
|
|
@@ -32,7 +32,7 @@ import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
|
32
32
|
This error would then be returned by an adapter's `handleResponse` method:
|
|
33
33
|
|
|
34
34
|
```js [app/adapters/application.js]
|
|
35
|
-
import JSONAPIAdapter from '@
|
|
35
|
+
import JSONAPIAdapter from '@warp-drive/legacy/adapter/json-api';
|
|
36
36
|
import MaintenanceError from './maintenance-error';
|
|
37
37
|
|
|
38
38
|
export default class ApplicationAdapter extends JSONAPIAdapter {
|
|
@@ -125,8 +125,8 @@ function extend(ParentErrorClass, defaultMessage) {
|
|
|
125
125
|
transition to the `invalid` state and the errors will be set to the
|
|
126
126
|
`errors` property on the record.
|
|
127
127
|
|
|
128
|
-
For
|
|
129
|
-
properties on the model,
|
|
128
|
+
For WarpDrive to correctly map errors to their corresponding
|
|
129
|
+
properties on the model, WarpDrive expects each error to be
|
|
130
130
|
a valid JSON-API error object with a `source/pointer` that matches
|
|
131
131
|
the property name. For example, if you had a Post model that
|
|
132
132
|
looked like this.
|
|
@@ -146,8 +146,8 @@ function extend(ParentErrorClass, defaultMessage) {
|
|
|
146
146
|
|
|
147
147
|
```js [app/adapters/post.js]
|
|
148
148
|
import RSVP from 'RSVP';
|
|
149
|
-
import RESTAdapter from '@
|
|
150
|
-
import { InvalidError } from '@
|
|
149
|
+
import RESTAdapter from '@warp-drive/legacy/adapter/rest';
|
|
150
|
+
import { InvalidError } from '@warp-drive/legacy/adapter/error';
|
|
151
151
|
|
|
152
152
|
export default class ApplicationAdapter extends RESTAdapter {
|
|
153
153
|
updateRecord() {
|
|
@@ -189,7 +189,7 @@ InvalidError.prototype.code = 'InvalidError';
|
|
|
189
189
|
connection if an adapter operation has timed out:
|
|
190
190
|
|
|
191
191
|
```js [app/routes/application.js]
|
|
192
|
-
import { TimeoutError } from '@
|
|
192
|
+
import { TimeoutError } from '@warp-drive/legacy/adapter/error';
|
|
193
193
|
|
|
194
194
|
export default class ApplicationRoute extends Route {
|
|
195
195
|
@action
|
|
@@ -235,7 +235,7 @@ AbortError.prototype.code = 'AbortError';
|
|
|
235
235
|
request is unauthorized:
|
|
236
236
|
|
|
237
237
|
```js [app/routes/application.js]
|
|
238
|
-
import { UnauthorizedError } from '@
|
|
238
|
+
import { UnauthorizedError } from '@warp-drive/legacy/adapter/error';
|
|
239
239
|
|
|
240
240
|
export default class ApplicationRoute extends Route {
|
|
241
241
|
@action
|
|
@@ -281,7 +281,7 @@ ForbiddenError.prototype.code = 'ForbiddenError';
|
|
|
281
281
|
for a specific model that does not exist. For example:
|
|
282
282
|
|
|
283
283
|
```js [app/routes/post.js]
|
|
284
|
-
import { NotFoundError } from '@
|
|
284
|
+
import { NotFoundError } from '@warp-drive/legacy/adapter/error';
|
|
285
285
|
|
|
286
286
|
export default class PostRoute extends Route {
|
|
287
287
|
@service store;
|
package/dist/adapter/json-api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dasherize, pluralize } from '@warp-drive/utilities/string';
|
|
2
2
|
import '@ember/debug';
|
|
3
3
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
|
-
import { b as serializeIntoHash } from "../serialize-into-hash-
|
|
4
|
+
import { b as serializeIntoHash } from "../serialize-into-hash-DPZYoF-i.js";
|
|
5
5
|
import { RESTAdapter } from './rest.js';
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
package/dist/adapter/rest.js
CHANGED
|
@@ -2,7 +2,7 @@ import { getOwner } from '@ember/application';
|
|
|
2
2
|
import { warn } from '@ember/debug';
|
|
3
3
|
import { computed } from '@ember/object';
|
|
4
4
|
import { Adapter, BuildURLMixin } from '../adapter.js';
|
|
5
|
-
import { b as serializeIntoHash, d as determineBodyPromise, g as getFetchFunction, s as serializeQueryParams, p as parseResponseHeaders } from "../serialize-into-hash-
|
|
5
|
+
import { b as serializeIntoHash, d as determineBodyPromise, g as getFetchFunction, s as serializeQueryParams, p as parseResponseHeaders } from "../serialize-into-hash-DPZYoF-i.js";
|
|
6
6
|
import { InvalidError, ServerError, ConflictError, NotFoundError, ForbiddenError, UnauthorizedError, AdapterError, TimeoutError, AbortError } from './error.js';
|
|
7
7
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
8
8
|
import { d as decorateMethodV2 } from "../runtime-BPCpkOf1-BKOwiRJp.js";
|
|
@@ -89,7 +89,7 @@ const AdapterWithBuildURLMixin = Adapter.extend(BuildURLMixin);
|
|
|
89
89
|
Note that the object root can be pluralized for both a single-object response
|
|
90
90
|
and an array response: the REST adapter is not strict on this. Further, if the
|
|
91
91
|
HTTP server responds to a `GET` request to `/posts/1` (e.g. the response to a
|
|
92
|
-
`findRecord` query) with more than one object in the array,
|
|
92
|
+
`findRecord` query) with more than one object in the array, WarpDrive will
|
|
93
93
|
only display the object with the matching ID.
|
|
94
94
|
|
|
95
95
|
### Conventional Names
|
|
@@ -150,7 +150,7 @@ const AdapterWithBuildURLMixin = Adapter.extend(BuildURLMixin);
|
|
|
150
150
|
|
|
151
151
|
If the records in the relationship are not known when the response
|
|
152
152
|
is serialized it's also possible to represent the relationship as a
|
|
153
|
-
URL using the `links` key in the response.
|
|
153
|
+
URL using the `links` key in the response. WarpDrive will fetch
|
|
154
154
|
this URL to resolve the relationship when it is accessed for the
|
|
155
155
|
first time.
|
|
156
156
|
|
|
@@ -233,17 +233,12 @@ const AdapterWithBuildURLMixin = Adapter.extend(BuildURLMixin);
|
|
|
233
233
|
}
|
|
234
234
|
```
|
|
235
235
|
|
|
236
|
-
@class RESTAdapter
|
|
237
236
|
@public
|
|
238
|
-
@constructor
|
|
239
|
-
@uses BuildURLMixin
|
|
240
237
|
*/
|
|
241
238
|
class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
242
239
|
/**
|
|
243
240
|
This property allows ajax to still be used instead when `false`.
|
|
244
|
-
@
|
|
245
|
-
@type {Boolean}
|
|
246
|
-
@default true
|
|
241
|
+
@default true
|
|
247
242
|
@public
|
|
248
243
|
*/
|
|
249
244
|
useFetch = true;
|
|
@@ -291,9 +286,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
291
286
|
}
|
|
292
287
|
}
|
|
293
288
|
```
|
|
294
|
-
@
|
|
295
|
-
@return {Object}
|
|
296
|
-
@public
|
|
289
|
+
@public
|
|
297
290
|
*/
|
|
298
291
|
sortQueryParams(obj) {
|
|
299
292
|
const keys = Object.keys(obj);
|
|
@@ -342,9 +335,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
342
335
|
will also send a request to: `GET /comments?ids[]=1&ids[]=2`
|
|
343
336
|
Note: Requests coalescing rely on URL building strategy. So if you override `buildURL` in your app
|
|
344
337
|
`groupRecordsForFindMany` more likely should be overridden as well in order for coalescing to work.
|
|
345
|
-
@
|
|
346
|
-
@public
|
|
347
|
-
@type {Boolean}
|
|
338
|
+
@public
|
|
348
339
|
*/
|
|
349
340
|
get coalesceFindRequests() {
|
|
350
341
|
const coalesceFindRequests = this._coalesceFindRequests;
|
|
@@ -367,9 +358,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
367
358
|
}
|
|
368
359
|
```
|
|
369
360
|
Requests for the `Post` model would now target `/api/1/post/`.
|
|
370
|
-
@
|
|
371
|
-
@public
|
|
372
|
-
@type {String}
|
|
361
|
+
@public
|
|
373
362
|
*/
|
|
374
363
|
|
|
375
364
|
/**
|
|
@@ -381,15 +370,13 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
381
370
|
}
|
|
382
371
|
```
|
|
383
372
|
Requests for the `Post` model would now target `https://api.example.com/post/`.
|
|
384
|
-
@
|
|
385
|
-
@public
|
|
386
|
-
@type {String}
|
|
373
|
+
@public
|
|
387
374
|
*/
|
|
388
375
|
|
|
389
376
|
/**
|
|
390
377
|
Some APIs require HTTP headers, e.g. to provide an API
|
|
391
378
|
key. Arbitrary headers can be set as key/value pairs on the
|
|
392
|
-
`RESTAdapter`'s `headers` object and
|
|
379
|
+
`RESTAdapter`'s `headers` object and WarpDrive will send them
|
|
393
380
|
along with each ajax request..
|
|
394
381
|
```js [app/adapters/application.js]
|
|
395
382
|
import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
|
|
@@ -402,9 +389,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
402
389
|
}
|
|
403
390
|
}
|
|
404
391
|
```
|
|
405
|
-
@
|
|
406
|
-
@public
|
|
407
|
-
@type {Object}
|
|
392
|
+
@public
|
|
408
393
|
*/
|
|
409
394
|
|
|
410
395
|
/**
|
|
@@ -415,11 +400,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
415
400
|
This method performs an HTTP `GET` request with the id provided as part of the query string.
|
|
416
401
|
@since 1.13.0
|
|
417
402
|
@public
|
|
418
|
-
@param {Store} store
|
|
419
|
-
@param {Model} type
|
|
420
|
-
@param {String} id
|
|
421
|
-
@param {Snapshot} snapshot
|
|
422
|
-
@return {Promise} promise
|
|
423
403
|
*/
|
|
424
404
|
findRecord(store, type, id, snapshot) {
|
|
425
405
|
const url = this.buildURL(type.modelName, id, snapshot, 'findRecord');
|
|
@@ -435,18 +415,10 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
435
415
|
The `findAll` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a
|
|
436
416
|
promise for the resulting payload.
|
|
437
417
|
@public
|
|
438
|
-
@param {Store} store
|
|
439
|
-
@param {Model} type
|
|
440
|
-
@param {undefined} neverSet a value is never provided to this argument
|
|
441
|
-
@param {SnapshotRecordArray} snapshotRecordArray
|
|
442
|
-
@return {Promise} promise
|
|
443
418
|
*/
|
|
444
|
-
findAll(store, type,
|
|
419
|
+
findAll(store, type, neverUsed, snapshotRecordArray) {
|
|
445
420
|
const query = this.buildQuery(snapshotRecordArray);
|
|
446
421
|
const url = this.buildURL(type.modelName, null, snapshotRecordArray, 'findAll');
|
|
447
|
-
if (sinceToken) {
|
|
448
|
-
query.since = sinceToken;
|
|
449
|
-
}
|
|
450
422
|
return this.ajax(url, 'GET', {
|
|
451
423
|
data: query
|
|
452
424
|
});
|
|
@@ -461,12 +433,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
461
433
|
The `query` argument is a simple JavaScript object that will be passed directly
|
|
462
434
|
to the server as parameters.
|
|
463
435
|
@public
|
|
464
|
-
@param {Store} store
|
|
465
|
-
@param {Model} type
|
|
466
|
-
@param {Object} query
|
|
467
|
-
@param {Collection} recordArray
|
|
468
|
-
@param {Object} adapterOptions
|
|
469
|
-
@return {Promise} promise
|
|
470
436
|
*/
|
|
471
437
|
query(store, type, query) {
|
|
472
438
|
const url = this.buildURL(type.modelName, null, null, 'query', query);
|
|
@@ -488,11 +454,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
488
454
|
to the server as parameters.
|
|
489
455
|
@since 1.13.0
|
|
490
456
|
@public
|
|
491
|
-
@param {Store} store
|
|
492
|
-
@param {Model} type
|
|
493
|
-
@param {Object} query
|
|
494
|
-
@param {Object} adapterOptions
|
|
495
|
-
@return {Promise} promise
|
|
496
457
|
*/
|
|
497
458
|
queryRecord(store, type, query, adapterOptions) {
|
|
498
459
|
const url = this.buildURL(type.modelName, null, null, 'queryRecord', query);
|
|
@@ -524,11 +485,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
524
485
|
The `findMany` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a
|
|
525
486
|
promise for the resulting payload.
|
|
526
487
|
@public
|
|
527
|
-
@param {Store} store
|
|
528
|
-
@param {Model} type
|
|
529
|
-
@param {Array} ids
|
|
530
|
-
@param {Array} snapshots
|
|
531
|
-
@return {Promise} promise
|
|
532
488
|
*/
|
|
533
489
|
findMany(store, type, ids, snapshots) {
|
|
534
490
|
const url = this.buildURL(type.modelName, ids, snapshots, 'findMany');
|
|
@@ -560,11 +516,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
560
516
|
* Links beginning with a single `/` will have the current adapter's `host` value prepended to it.
|
|
561
517
|
* Links with no beginning `/` will have a parentURL prepended to it, via the current adapter's `buildURL`.
|
|
562
518
|
@public
|
|
563
|
-
@param {Store} store
|
|
564
|
-
@param {Snapshot} snapshot
|
|
565
|
-
@param {String} url
|
|
566
|
-
@param {Object} relationship meta object describing the relationship
|
|
567
|
-
@return {Promise} promise
|
|
568
519
|
*/
|
|
569
520
|
findHasMany(store, snapshot, url, relationship) {
|
|
570
521
|
const id = snapshot.id;
|
|
@@ -620,10 +571,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
620
571
|
See `serialize` for information on how to customize the serialized form
|
|
621
572
|
of a record.
|
|
622
573
|
@public
|
|
623
|
-
@param {Store} store
|
|
624
|
-
@param {Model} type
|
|
625
|
-
@param {Snapshot} snapshot
|
|
626
|
-
@return {Promise} promise
|
|
627
574
|
*/
|
|
628
575
|
createRecord(store, type, snapshot) {
|
|
629
576
|
const url = this.buildURL(type.modelName, null, snapshot, 'createRecord');
|
|
@@ -641,10 +588,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
641
588
|
See `serialize` for information on how to customize the serialized form
|
|
642
589
|
of a record.
|
|
643
590
|
@public
|
|
644
|
-
@param {Store} store
|
|
645
|
-
@param {Model} schema
|
|
646
|
-
@param {Snapshot} snapshot
|
|
647
|
-
@return {Promise} promise
|
|
648
591
|
*/
|
|
649
592
|
updateRecord(store, schema, snapshot) {
|
|
650
593
|
const data = serializeIntoHash(store, schema, snapshot, {});
|
|
@@ -665,10 +608,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
665
608
|
Called by the store when a record is deleted.
|
|
666
609
|
The `deleteRecord` method makes an Ajax (HTTP DELETE) request to a URL computed by `buildURL`.
|
|
667
610
|
@public
|
|
668
|
-
@param {Store} store
|
|
669
|
-
@param {Model} type
|
|
670
|
-
@param {Snapshot} snapshot
|
|
671
|
-
@return {Promise} promise
|
|
672
611
|
*/
|
|
673
612
|
deleteRecord(store, schema, snapshot) {
|
|
674
613
|
const type = snapshot.modelName;
|
|
@@ -680,6 +619,10 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
680
619
|
})(typeof id === 'string' && id.length > 0) : {};
|
|
681
620
|
return this.ajax(this.buildURL(type, id, snapshot, 'deleteRecord'), 'DELETE');
|
|
682
621
|
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
@private
|
|
625
|
+
*/
|
|
683
626
|
_stripIDFromURL(store, snapshot) {
|
|
684
627
|
const type = snapshot.modelName;
|
|
685
628
|
const id = snapshot.id;
|
|
@@ -721,10 +664,8 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
721
664
|
It does not group records that have differing base urls, such as for example: `/posts/1/comments/2`
|
|
722
665
|
and `/posts/2/comments/3`
|
|
723
666
|
@public
|
|
724
|
-
@
|
|
725
|
-
|
|
726
|
-
@return {Array} an array of arrays of records, each of which is to be
|
|
727
|
-
loaded separately by `findMany`.
|
|
667
|
+
@return an array of arrays of records, each of which is to be
|
|
668
|
+
loaded separately by `findMany`.
|
|
728
669
|
*/
|
|
729
670
|
groupRecordsForFindMany(store, snapshots) {
|
|
730
671
|
const groups = new Map();
|
|
@@ -763,11 +704,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
763
704
|
method.
|
|
764
705
|
@since 1.13.0
|
|
765
706
|
@public
|
|
766
|
-
@param {Number} status
|
|
767
|
-
@param {Object} headers
|
|
768
|
-
@param {Object} payload
|
|
769
|
-
@param {Object} requestData - the original request information
|
|
770
|
-
@return {Object | AdapterError} response
|
|
771
707
|
*/
|
|
772
708
|
handleResponse(status, headers, payload, requestData) {
|
|
773
709
|
if (this.isSuccess(status, headers, payload)) {
|
|
@@ -800,10 +736,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
800
736
|
response is a success.
|
|
801
737
|
@since 1.13.0
|
|
802
738
|
@public
|
|
803
|
-
@param {Number} status
|
|
804
|
-
@param {Object} headers
|
|
805
|
-
@param {Object} payload
|
|
806
|
-
@return {Boolean}
|
|
807
739
|
*/
|
|
808
740
|
isSuccess(status, _headers, _payload) {
|
|
809
741
|
return status >= 200 && status < 300 || status === 304;
|
|
@@ -814,10 +746,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
814
746
|
response is an invalid error.
|
|
815
747
|
@since 1.13.0
|
|
816
748
|
@public
|
|
817
|
-
@param {Number} status
|
|
818
|
-
@param {Object} headers
|
|
819
|
-
@param {Object} payload
|
|
820
|
-
@return {Boolean}
|
|
821
749
|
*/
|
|
822
750
|
isInvalid(status, _headers, _payload) {
|
|
823
751
|
return status === 422;
|
|
@@ -826,7 +754,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
826
754
|
/**
|
|
827
755
|
Takes a URL, an HTTP method and a hash of data, and makes an
|
|
828
756
|
HTTP request.
|
|
829
|
-
When the server responds with a payload,
|
|
757
|
+
When the server responds with a payload, WarpDrive will call into `extractSingle`
|
|
830
758
|
or `extractArray` (depending on whether the original query was for one record or
|
|
831
759
|
many records).
|
|
832
760
|
By default, `ajax` method has the following behavior:
|
|
@@ -837,10 +765,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
837
765
|
data is the serialized record in the case of a save.
|
|
838
766
|
* Registers success and failure handlers.
|
|
839
767
|
@private
|
|
840
|
-
@param {String} url
|
|
841
|
-
@param {String} type The request type GET, POST, PUT, DELETE etc.
|
|
842
|
-
@param {Object} options
|
|
843
|
-
@return {Promise} promise
|
|
844
768
|
*/
|
|
845
769
|
async ajax(url, type, options = {}) {
|
|
846
770
|
const requestData = {
|
|
@@ -865,7 +789,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
865
789
|
|
|
866
790
|
/**
|
|
867
791
|
@private
|
|
868
|
-
@param
|
|
792
|
+
@param options jQuery ajax options to be used for the ajax request
|
|
869
793
|
*/
|
|
870
794
|
_ajaxRequest(options) {
|
|
871
795
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
@@ -875,10 +799,16 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
875
799
|
})(typeof jQuery !== 'undefined') : {};
|
|
876
800
|
void jQuery.ajax(options);
|
|
877
801
|
}
|
|
802
|
+
/**
|
|
803
|
+
@private
|
|
804
|
+
*/
|
|
878
805
|
_fetchRequest(options) {
|
|
879
806
|
const fetchFunction = getFetchFunction();
|
|
880
807
|
return fetchFunction(options.url, options);
|
|
881
808
|
}
|
|
809
|
+
/**
|
|
810
|
+
@private
|
|
811
|
+
*/
|
|
882
812
|
_ajax(options) {
|
|
883
813
|
if (this.useFetch) {
|
|
884
814
|
void this._fetchRequest(options);
|
|
@@ -889,10 +819,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
889
819
|
|
|
890
820
|
/**
|
|
891
821
|
@private
|
|
892
|
-
@param {String} url
|
|
893
|
-
@param {String} type The request type GET, POST, PUT, DELETE etc.
|
|
894
|
-
@param {Object} options
|
|
895
|
-
@return {Object}
|
|
896
822
|
*/
|
|
897
823
|
ajaxOptions(url, method, options) {
|
|
898
824
|
let reqOptions = Object.assign({
|
|
@@ -937,6 +863,10 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
937
863
|
reqOptions.url = this._ajaxURL(reqOptions.url);
|
|
938
864
|
return reqOptions;
|
|
939
865
|
}
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* @private
|
|
869
|
+
*/
|
|
940
870
|
_ajaxURL(url) {
|
|
941
871
|
if (this.fastboot?.isFastBoot) {
|
|
942
872
|
const httpRegex = /^https?:\/\//;
|
|
@@ -949,7 +879,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
949
879
|
try {
|
|
950
880
|
return `${protocol}//${host}${url}`;
|
|
951
881
|
} catch (fbError) {
|
|
952
|
-
throw new Error('You are using
|
|
882
|
+
throw new Error('You are using WarpDrive with no host defined in your adapter. This will attempt to use the host of the FastBoot request, which is not configured for the current host of this request. Please set the hostWhitelist property for in your environment.js. FastBoot Error: ' + fbError.message);
|
|
953
883
|
}
|
|
954
884
|
}
|
|
955
885
|
}
|
|
@@ -958,8 +888,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
958
888
|
|
|
959
889
|
/**
|
|
960
890
|
@private
|
|
961
|
-
@param {String} responseText
|
|
962
|
-
@return {Object}
|
|
963
891
|
*/
|
|
964
892
|
parseErrorResponse(responseText) {
|
|
965
893
|
let json = responseText;
|
|
@@ -973,10 +901,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
973
901
|
|
|
974
902
|
/**
|
|
975
903
|
@private
|
|
976
|
-
@
|
|
977
|
-
@param {Object} headers
|
|
978
|
-
@param {Object} payload
|
|
979
|
-
@return {Array} errors payload
|
|
904
|
+
@return errors payload
|
|
980
905
|
*/
|
|
981
906
|
normalizeErrorResponse(status, _headers, payload) {
|
|
982
907
|
if (payload && typeof payload === 'object' && 'errors' in payload && Array.isArray(payload.errors)) {
|
|
@@ -999,11 +924,7 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
999
924
|
Generates a detailed ("friendly") error message, with plenty
|
|
1000
925
|
of information for debugging (good luck!)
|
|
1001
926
|
@private
|
|
1002
|
-
@
|
|
1003
|
-
@param {Object} headers
|
|
1004
|
-
@param {Object} payload
|
|
1005
|
-
@param {Object} requestData
|
|
1006
|
-
@return {String} detailed error message
|
|
927
|
+
@return detailed error message
|
|
1007
928
|
*/
|
|
1008
929
|
generatedDetailedMessage(status, headers, payload, requestData) {
|
|
1009
930
|
let shortenedPayload;
|
|
@@ -1025,8 +946,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
1025
946
|
supplied to the ajax method.
|
|
1026
947
|
@since 2.5.0
|
|
1027
948
|
@public
|
|
1028
|
-
@param {Snapshot} snapshot
|
|
1029
|
-
@return {Object}
|
|
1030
949
|
*/
|
|
1031
950
|
buildQuery(snapshot) {
|
|
1032
951
|
const query = {};
|
|
@@ -1167,17 +1086,14 @@ function headersToObject(headers) {
|
|
|
1167
1086
|
/**
|
|
1168
1087
|
* Helper function that translates the options passed to `jQuery.ajax` into a format that `fetch` expects.
|
|
1169
1088
|
*
|
|
1170
|
-
* @param {Object} _options
|
|
1171
|
-
* @param {Adapter} adapter
|
|
1172
1089
|
* @private
|
|
1173
|
-
* @return {Object}
|
|
1174
1090
|
*/
|
|
1175
1091
|
function fetchOptions(options, adapter) {
|
|
1176
1092
|
options.credentials = options.credentials || 'same-origin';
|
|
1177
1093
|
if (options.data) {
|
|
1178
1094
|
// GET and HEAD requests can't have a `body`
|
|
1179
1095
|
if (options.method === 'GET' || options.method === 'HEAD') {
|
|
1180
|
-
// If no options are passed,
|
|
1096
|
+
// If no options are passed, WarpDrive sets `data` to an empty object, which we test for.
|
|
1181
1097
|
if (Object.keys(options.data).length && options.url) {
|
|
1182
1098
|
// Test if there are already query params in the url (mimics jQuey.ajax).
|
|
1183
1099
|
const queryParamDelimiter = options.url.includes('?') ? '&' : '?';
|
package/dist/adapter.js
CHANGED
|
@@ -949,10 +949,10 @@ class Adapter extends EmberObject {
|
|
|
949
949
|
Serializes the record update and sends it to the server.
|
|
950
950
|
The updateRecord method is expected to return a promise that will
|
|
951
951
|
resolve with the serialized record. This allows the backend to
|
|
952
|
-
inform the
|
|
952
|
+
inform the WarpDrive store the current state of this record after
|
|
953
953
|
the update. If it is not possible to return a serialized record
|
|
954
954
|
the updateRecord promise can also resolve with `undefined` and the
|
|
955
|
-
|
|
955
|
+
WarpDrive store will assume all of the updates were successfully
|
|
956
956
|
applied on the backend.
|
|
957
957
|
Example
|
|
958
958
|
```js [app/adapters/application.js]
|
package/dist/compat/-private.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { F as FetchManager, S as SaveOp, c as Snapshot, b as SnapshotRecordArray, u as upgradeStore } from "../-private-
|
|
1
|
+
export { F as FetchManager, S as SaveOp, c as Snapshot, b as SnapshotRecordArray, u as upgradeStore } from "../-private-BG3bMiKp.js";
|
package/dist/compat/builders.js
CHANGED
|
@@ -9,16 +9,16 @@ import { storeFor, recordIdentifierFor } from '@warp-drive/core';
|
|
|
9
9
|
When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request.
|
|
10
10
|
Additionally, it takes the same options as `store.findAll`.
|
|
11
11
|
|
|
12
|
-
All `@
|
|
12
|
+
All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.
|
|
13
13
|
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.
|
|
14
|
-
To that end, these builders are deprecated and will be removed in a future version of
|
|
14
|
+
To that end, these builders are deprecated and will be removed in a future version of WarpDrive.
|
|
15
15
|
|
|
16
16
|
@deprecated
|
|
17
17
|
@public
|
|
18
|
-
@param
|
|
19
|
-
@param
|
|
20
|
-
@param
|
|
21
|
-
@return
|
|
18
|
+
@param type the name of the resource
|
|
19
|
+
@param query a query to be used by the adapter
|
|
20
|
+
@param options optional, may include `adapterOptions` hash which will be passed to adapter.findAll
|
|
21
|
+
@return request config
|
|
22
22
|
*/
|
|
23
23
|
function findAllBuilder(type, options = {}) {
|
|
24
24
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
@@ -51,7 +51,7 @@ function findAllBuilder(type, options = {}) {
|
|
|
51
51
|
**Example 1**
|
|
52
52
|
|
|
53
53
|
```ts
|
|
54
|
-
import { findRecord } from '@
|
|
54
|
+
import { findRecord } from '@warp-drive/legacy/compat/builders';
|
|
55
55
|
const { content: post } = await store.request<Post>(findRecord<Post>('post', '1'));
|
|
56
56
|
```
|
|
57
57
|
|
|
@@ -62,20 +62,20 @@ function findAllBuilder(type, options = {}) {
|
|
|
62
62
|
the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification)
|
|
63
63
|
|
|
64
64
|
```ts
|
|
65
|
-
import { findRecord } from '@
|
|
65
|
+
import { findRecord } from '@warp-drive/legacy/compat/builders';
|
|
66
66
|
const { content: post } = await store.request<Post>(findRecord<Post>({ type: 'post', id }));
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
All `@
|
|
69
|
+
All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.
|
|
70
70
|
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.
|
|
71
|
-
To that end, these builders are deprecated and will be removed in a future version of
|
|
71
|
+
To that end, these builders are deprecated and will be removed in a future version of Warp Drive.
|
|
72
72
|
|
|
73
73
|
@deprecated
|
|
74
74
|
@public
|
|
75
|
-
@param
|
|
76
|
-
@param
|
|
77
|
-
@param
|
|
78
|
-
@return
|
|
75
|
+
@param resource - either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record
|
|
76
|
+
@param id - optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved
|
|
77
|
+
@param options - if the first param is a string this will be the optional options for the request. See examples for available options.
|
|
78
|
+
@return request config
|
|
79
79
|
*/
|
|
80
80
|
function findRecordBuilder(resource, idOrOptions, options) {
|
|
81
81
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
@@ -118,16 +118,16 @@ function findRecordBuilder(resource, idOrOptions, options) {
|
|
|
118
118
|
When passed to `store.request`, this config will result in the same behavior as a `store.query` request.
|
|
119
119
|
Additionally, it takes the same options as `store.query`.
|
|
120
120
|
|
|
121
|
-
All `@
|
|
121
|
+
All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.
|
|
122
122
|
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.
|
|
123
|
-
To that end, these builders are deprecated and will be removed in a future version of
|
|
123
|
+
To that end, these builders are deprecated and will be removed in a future version of WarpDrive.
|
|
124
124
|
|
|
125
125
|
@deprecated
|
|
126
126
|
@public
|
|
127
|
-
@param
|
|
128
|
-
@param
|
|
129
|
-
@param
|
|
130
|
-
@return
|
|
127
|
+
@param type the name of the resource
|
|
128
|
+
@param query a query to be used by the adapter
|
|
129
|
+
@param options optional, may include `adapterOptions` hash which will be passed to adapter.query
|
|
130
|
+
@return request config
|
|
131
131
|
*/
|
|
132
132
|
function queryBuilder(type, query, options = {}) {
|
|
133
133
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
@@ -163,16 +163,16 @@ function queryBuilder(type, query, options = {}) {
|
|
|
163
163
|
When passed to `store.request`, this config will result in the same behavior as a `store.queryRecord` request.
|
|
164
164
|
Additionally, it takes the same options as `store.queryRecord`.
|
|
165
165
|
|
|
166
|
-
All `@
|
|
166
|
+
All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.
|
|
167
167
|
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.
|
|
168
|
-
To that end, these builders are deprecated and will be removed in a future version of
|
|
168
|
+
To that end, these builders are deprecated and will be removed in a future version of WarpDrive.
|
|
169
169
|
|
|
170
170
|
@deprecated
|
|
171
171
|
@public
|
|
172
|
-
@param
|
|
173
|
-
@param
|
|
174
|
-
@param
|
|
175
|
-
@return
|
|
172
|
+
@param type the name of the resource
|
|
173
|
+
@param query a query to be used by the adapter
|
|
174
|
+
@param options optional, may include `adapterOptions` hash which will be passed to adapter.query
|
|
175
|
+
@return request config
|
|
176
176
|
*/
|
|
177
177
|
|
|
178
178
|
function queryRecordBuilder(type, query, options) {
|