@warp-drive/legacy 5.8.0-alpha.4 → 5.8.0-alpha.41
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 +6 -8
- package/declarations/adapter/rest.d.ts +26 -112
- package/declarations/adapter.d.ts +6 -8
- package/declarations/compat/-private.d.ts +1 -1
- 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/extensions.d.ts +1 -1
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +7 -9
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +20 -30
- package/declarations/compat/utils.d.ts +17 -17
- package/declarations/compat.d.ts +35 -11
- package/declarations/index.d.ts +70 -0
- package/declarations/model/-private/attr.d.ts +5 -6
- package/declarations/model/-private/belongs-to.d.ts +4 -5
- package/declarations/model/-private/has-many.d.ts +4 -5
- package/declarations/model/-private/hooks.d.ts +1 -1
- package/declarations/model/-private/legacy-relationships-support.d.ts +2 -2
- package/declarations/model/-private/model.d.ts +18 -59
- package/declarations/model/-private/promise-many-array.d.ts +0 -18
- package/declarations/model/-private/record-state.d.ts +1 -1
- package/declarations/model/-private/references/belongs-to.d.ts +19 -29
- package/declarations/model/-private/references/has-many.d.ts +14 -16
- package/declarations/model/migration-support.d.ts +46 -21
- 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 -6
- package/declarations/serializer/-private/transforms/boolean.d.ts +2 -2
- package/declarations/serializer/-private/transforms/date.d.ts +2 -2
- package/declarations/serializer/-private/transforms/number.d.ts +1 -1
- package/declarations/serializer/-private/transforms/string.d.ts +1 -1
- package/declarations/serializer/json-api.d.ts +11 -12
- package/declarations/serializer/json.d.ts +9 -11
- package/declarations/serializer/rest.d.ts +4 -6
- package/declarations/serializer.d.ts +9 -12
- package/dist/{-private-8UmnAf9J.js → -private-BG3bMiKp.js} +3 -2
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +14 -15
- package/dist/adapter/json-api.js +4 -1
- package/dist/adapter/rest.js +38 -125
- package/dist/adapter.js +6 -8
- package/dist/compat/-private.js +1 -1
- package/dist/compat/builders.js +26 -26
- package/dist/compat/utils.js +17 -18
- package/dist/compat.js +61 -43
- package/dist/{errors-8kD2mSe_.js → errors-Cz5KrzBk.js} +115 -122
- package/dist/hooks-D6diaM34.js +74 -0
- package/dist/index.js +195 -0
- package/dist/{json-DziiodPf.js → json-ChdEfB0X.js} +18 -35
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +57 -25
- package/dist/model-for-CqXsIKws.js +221 -0
- package/dist/model-fragments.js +76 -0
- package/dist/model.js +18 -90
- package/dist/{schema-provider-DQu4Rjco.js → schema-provider-DJCV_6AF.js} +50 -95
- package/dist/{serialize-into-hash-CS0MIv4F.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 +14 -21
- package/dist/serializer/transform.js +15 -6
- package/dist/serializer.js +9 -13
- package/dist/store.js +5 -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
package/dist/serializer/rest.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { warn } from '@ember/debug';
|
|
2
2
|
import { camelize, dasherize, singularize } from '@warp-drive/utilities/string';
|
|
3
|
-
import { J as JSONSerializer, c as coerceId } from "../json-
|
|
3
|
+
import { J as JSONSerializer, c as coerceId } from "../json-ChdEfB0X.js";
|
|
4
4
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
5
5
|
import Mixin from '@ember/object/mixin';
|
|
6
6
|
|
|
@@ -25,7 +25,7 @@ import Mixin from '@ember/object/mixin';
|
|
|
25
25
|
Below is an example of a per-type serializer (`post` type).
|
|
26
26
|
|
|
27
27
|
```js [app/serializers/post.js]
|
|
28
|
-
import RESTSerializer, { EmbeddedRecordsMixin } from '@
|
|
28
|
+
import RESTSerializer, { EmbeddedRecordsMixin } from '@warp-drive/legacy/serializer/rest';
|
|
29
29
|
|
|
30
30
|
export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {
|
|
31
31
|
attrs = {
|
|
@@ -96,11 +96,6 @@ import Mixin from '@ember/object/mixin';
|
|
|
96
96
|
are. Please read the docs for the methods this mixin provides, in case you need
|
|
97
97
|
to modify it to fit your specific needs.**
|
|
98
98
|
|
|
99
|
-
For example, review the docs for each method of this mixin:
|
|
100
|
-
* [normalize](/ember-data/release/classes/EmbeddedRecordsMixin/methods/normalize?anchor=normalize)
|
|
101
|
-
* [serializeBelongsTo](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeBelongsTo?anchor=serializeBelongsTo)
|
|
102
|
-
* [serializeHasMany](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeHasMany?anchor=serializeHasMany)
|
|
103
|
-
|
|
104
99
|
@class EmbeddedRecordsMixin
|
|
105
100
|
@public
|
|
106
101
|
*/
|
|
@@ -145,7 +140,7 @@ const EmbeddedRecordsMixin = Mixin.create({
|
|
|
145
140
|
Serialize `belongsTo` relationship when it is configured as an embedded object.
|
|
146
141
|
This example of an author model belongs to a post model:
|
|
147
142
|
```js
|
|
148
|
-
import Model, { attr, belongsTo } from '@
|
|
143
|
+
import Model, { attr, belongsTo } from '@warp-drive/legacy/model';
|
|
149
144
|
Post = Model.extend({
|
|
150
145
|
title: attr('string'),
|
|
151
146
|
body: attr('string'),
|
|
@@ -158,7 +153,7 @@ const EmbeddedRecordsMixin = Mixin.create({
|
|
|
158
153
|
```
|
|
159
154
|
Use a custom (type) serializer for the post model to configure embedded author
|
|
160
155
|
```js [app/serializers/post.js]
|
|
161
|
-
import RESTSerializer, { EmbeddedRecordsMixin } from '@
|
|
156
|
+
import RESTSerializer, { EmbeddedRecordsMixin } from '@warp-drive/legacy/serializer/rest';
|
|
162
157
|
export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {
|
|
163
158
|
attrs = {
|
|
164
159
|
author: { embedded: 'always' }
|
|
@@ -234,7 +229,7 @@ const EmbeddedRecordsMixin = Mixin.create({
|
|
|
234
229
|
Serializes `hasMany` relationships when it is configured as embedded objects.
|
|
235
230
|
This example of a post model has many comments:
|
|
236
231
|
```js
|
|
237
|
-
import Model, { attr, belongsTo, hasMany } from '@
|
|
232
|
+
import Model, { attr, belongsTo, hasMany } from '@warp-drive/legacy/model';
|
|
238
233
|
Post = Model.extend({
|
|
239
234
|
title: attr('string'),
|
|
240
235
|
body: attr('string'),
|
|
@@ -247,7 +242,7 @@ const EmbeddedRecordsMixin = Mixin.create({
|
|
|
247
242
|
```
|
|
248
243
|
Use a custom (type) serializer for the post model to configure embedded comments
|
|
249
244
|
```js [app/serializers/post.js]
|
|
250
|
-
import RESTSerializer, { EmbeddedRecordsMixin } from '@
|
|
245
|
+
import RESTSerializer, { EmbeddedRecordsMixin } from '@warp-drive/legacy/serializer/rest';
|
|
251
246
|
export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {
|
|
252
247
|
attrs = {
|
|
253
248
|
comments: { embedded: 'always' }
|
|
@@ -279,7 +274,7 @@ const EmbeddedRecordsMixin = Mixin.create({
|
|
|
279
274
|
`{ serialize: 'records', deserialize: 'records' }`
|
|
280
275
|
To embed the `ids` for a related object (using a hasMany relationship):
|
|
281
276
|
```js [app/serializers/post.js]
|
|
282
|
-
import RESTSerializer, { EmbeddedRecordsMixin } from '@
|
|
277
|
+
import RESTSerializer, { EmbeddedRecordsMixin } from '@warp-drive/legacy/serializer/rest';
|
|
283
278
|
export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {
|
|
284
279
|
attrs = {
|
|
285
280
|
comments: { serialize: 'ids', deserialize: 'records' }
|
|
@@ -317,7 +312,7 @@ const EmbeddedRecordsMixin = Mixin.create({
|
|
|
317
312
|
});
|
|
318
313
|
```
|
|
319
314
|
```js [app/serializers/user.js]
|
|
320
|
-
import RESTSerializer, { EmbeddedRecordsMixin } from '@
|
|
315
|
+
import RESTSerializer, { EmbeddedRecordsMixin } from '@warp-drive/legacy/serializer/rest';
|
|
321
316
|
export default class UserSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {
|
|
322
317
|
attrs = {
|
|
323
318
|
pets: { serialize: 'ids-and-types', deserialize: 'records' }
|
|
@@ -583,13 +578,11 @@ function makeArray(value) {
|
|
|
583
578
|
}
|
|
584
579
|
|
|
585
580
|
/**
|
|
586
|
-
*
|
|
587
|
-
|
|
588
|
-
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
581
|
+
* :::danger
|
|
582
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
589
583
|
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
</blockquote>
|
|
584
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
585
|
+
:::
|
|
593
586
|
|
|
594
587
|
Normally, applications will use the `RESTSerializer` by implementing
|
|
595
588
|
the `normalize` method.
|
|
@@ -958,7 +951,7 @@ const RESTSerializer = JSONSerializer.extend({
|
|
|
958
951
|
the name of the model in your app. Let's take a look at an example model,
|
|
959
952
|
and an example payload:
|
|
960
953
|
```js [app/models/post.js]
|
|
961
|
-
import Model from '@
|
|
954
|
+
import Model from '@warp-drive/legacy/model';
|
|
962
955
|
export default class Post extends Model {}
|
|
963
956
|
```
|
|
964
957
|
```javascript
|
|
@@ -1007,7 +1000,7 @@ const RESTSerializer = JSONSerializer.extend({
|
|
|
1007
1000
|
each attribute and belongsTo relationship.
|
|
1008
1001
|
For example, consider this model:
|
|
1009
1002
|
```js [app/models/comment.js]
|
|
1010
|
-
import Model, { attr, belongsTo } from '@
|
|
1003
|
+
import Model, { attr, belongsTo } from '@warp-drive/legacy/model';
|
|
1011
1004
|
export default class Comment extends Model {
|
|
1012
1005
|
@attr title
|
|
1013
1006
|
@attr body
|
|
@@ -79,11 +79,13 @@ import EmberObject from '@ember/object';
|
|
|
79
79
|
*/
|
|
80
80
|
const Transform = EmberObject;
|
|
81
81
|
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
83
|
+
|
|
82
84
|
/**
|
|
83
85
|
The `BooleanTransform` class is used to serialize and deserialize
|
|
84
86
|
boolean attributes on Ember Data record objects. This transform is
|
|
85
|
-
used when `boolean` is passed as the type parameter to the
|
|
86
|
-
|
|
87
|
+
used when `'boolean'` is passed as the type parameter to the
|
|
88
|
+
{@link attr}function.
|
|
87
89
|
|
|
88
90
|
Usage
|
|
89
91
|
|
|
@@ -139,11 +141,13 @@ class BooleanTransform {
|
|
|
139
141
|
}
|
|
140
142
|
}
|
|
141
143
|
|
|
144
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
145
|
+
|
|
142
146
|
/**
|
|
143
147
|
The `DateTransform` class is used to serialize and deserialize
|
|
144
148
|
date attributes on Ember Data record objects. This transform is used
|
|
145
|
-
when `date` is passed as the type parameter to the
|
|
146
|
-
|
|
149
|
+
when `'date'` is passed as the type parameter to the
|
|
150
|
+
{@link attr} function. It uses the [`ISO 8601`](https://en.wikipedia.org/wiki/ISO_8601)
|
|
147
151
|
standard.
|
|
148
152
|
|
|
149
153
|
```js [app/models/score.js]
|
|
@@ -190,6 +194,9 @@ class DateTransform {
|
|
|
190
194
|
return new this();
|
|
191
195
|
}
|
|
192
196
|
}
|
|
197
|
+
|
|
198
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
199
|
+
|
|
193
200
|
function isNumber(value) {
|
|
194
201
|
return value === value && value !== Infinity && value !== -Infinity;
|
|
195
202
|
}
|
|
@@ -197,7 +204,7 @@ function isNumber(value) {
|
|
|
197
204
|
The `NumberTransform` class is used to serialize and deserialize
|
|
198
205
|
numeric attributes on Ember Data record objects. This transform is
|
|
199
206
|
used when `number` is passed as the type parameter to the
|
|
200
|
-
|
|
207
|
+
{@link attr} function.
|
|
201
208
|
|
|
202
209
|
Usage
|
|
203
210
|
|
|
@@ -235,11 +242,13 @@ class NumberTransform {
|
|
|
235
242
|
}
|
|
236
243
|
}
|
|
237
244
|
|
|
245
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
246
|
+
|
|
238
247
|
/**
|
|
239
248
|
The `StringTransform` class is used to serialize and deserialize
|
|
240
249
|
string attributes on Ember Data record objects. This transform is
|
|
241
250
|
used when `string` is passed as the type parameter to the
|
|
242
|
-
|
|
251
|
+
{@link attr} function.
|
|
243
252
|
|
|
244
253
|
Usage
|
|
245
254
|
|
package/dist/serializer.js
CHANGED
|
@@ -5,13 +5,11 @@ import { a as decorateFieldV2, i as initializeDeferredDecorator } from "./runtim
|
|
|
5
5
|
/**
|
|
6
6
|
## Overview
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
8
|
+
:::danger
|
|
9
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
11
10
|
If starting a new app or thinking of implementing a new serializer, consider writing a
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
</blockquote>
|
|
11
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
12
|
+
:::
|
|
15
13
|
|
|
16
14
|
In order to properly manage and present your data, WarpDrive
|
|
17
15
|
needs to understand the structure of data it receives.
|
|
@@ -20,14 +18,14 @@ import { a as decorateFieldV2, i as initializeDeferredDecorator } from "./runtim
|
|
|
20
18
|
the format WarpDrive understands.
|
|
21
19
|
|
|
22
20
|
Data received from an API response is **normalized** into
|
|
23
|
-
[
|
|
21
|
+
[{json:api}](https://jsonapi.org/) (the format used internally
|
|
24
22
|
by WarpDrive), while data sent to an API is **serialized**
|
|
25
23
|
into the format the API expects.
|
|
26
24
|
|
|
27
25
|
### Implementing a Serializer
|
|
28
26
|
|
|
29
27
|
There are only two required serializer methods, one for
|
|
30
|
-
normalizing data from the server API format into
|
|
28
|
+
normalizing data from the server API format into {json:api}, and
|
|
31
29
|
another for serializing records via `Snapshots` into the expected
|
|
32
30
|
server API format.
|
|
33
31
|
|
|
@@ -73,7 +71,7 @@ import { a as decorateFieldV2, i as initializeDeferredDecorator } from "./runtim
|
|
|
73
71
|
// app/serializers/application.js
|
|
74
72
|
```
|
|
75
73
|
|
|
76
|
-
Most requests in
|
|
74
|
+
Most requests in `@warp-drive/legacy` are made with respect to a particular `type` (or `modelName`)
|
|
77
75
|
(e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We
|
|
78
76
|
refer to this as the **primary** resource `type`.
|
|
79
77
|
|
|
@@ -97,7 +95,7 @@ import { a as decorateFieldV2, i as initializeDeferredDecorator } from "./runtim
|
|
|
97
95
|
### Default Serializers
|
|
98
96
|
|
|
99
97
|
For applications whose APIs are *very close to* or *exactly* the **REST** format or **JSON:API**
|
|
100
|
-
format the `@
|
|
98
|
+
format the `@warp-drive/legacy/serializer` package contains implementations these applications can
|
|
101
99
|
extend. It also contains a simple `JSONSerializer` for serializing to/from very basic JSON objects.
|
|
102
100
|
|
|
103
101
|
Many applications will find writing their own serializer to be more performant and less
|
|
@@ -109,7 +107,6 @@ import { a as decorateFieldV2, i as initializeDeferredDecorator } from "./runtim
|
|
|
109
107
|
|
|
110
108
|
@module
|
|
111
109
|
*/
|
|
112
|
-
|
|
113
110
|
const service = s.service ?? s.inject;
|
|
114
111
|
|
|
115
112
|
/**
|
|
@@ -127,8 +124,7 @@ const service = s.service ?? s.inject;
|
|
|
127
124
|
|
|
128
125
|
* `normalize()`
|
|
129
126
|
|
|
130
|
-
For an example implementation, see
|
|
131
|
-
[JSONSerializer](JSONSerializer), the included JSON serializer.
|
|
127
|
+
For an example implementation, see the included {@link JSONSerializer}.
|
|
132
128
|
|
|
133
129
|
@class Serializer
|
|
134
130
|
@public
|
package/dist/store.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assertPrivateStore, ensureStringId, recordIdentifierFor, constructResource, storeFor } from '@warp-drive/core/store/-private';
|
|
2
2
|
import { SkipCache } from '@warp-drive/core/types/request';
|
|
3
3
|
import { i as isMaybeIdentifier } from "./utils-Cqw9eRj5.js";
|
|
4
4
|
import { n as normalizeModelName } from "./util-Dul6TZts.js";
|
|
5
|
+
import { defineSignal } from '@warp-drive/core/signals/-leaked';
|
|
5
6
|
import { getOrSetGlobal } from '@warp-drive/core/types/-private';
|
|
6
7
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
7
8
|
|
|
@@ -524,6 +525,9 @@ function restoreDeprecatedStoreBehaviors(StoreKlass) {
|
|
|
524
525
|
});
|
|
525
526
|
return promise.then(document => document.content);
|
|
526
527
|
};
|
|
528
|
+
|
|
529
|
+
// do not put a ts-expect-error here, because typedoc will fail to
|
|
530
|
+
// build due to this error only occurring when references are in use in the editor
|
|
527
531
|
StoreKlass.prototype.getReference = function (resource, id) {
|
|
528
532
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
529
533
|
if (!test) {
|