@warp-drive/legacy 5.6.0-alpha.14 → 5.6.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/declarations/adapter/-private/build-url-mixin.d.ts +41 -29
- package/declarations/adapter/-private/fastboot-interface.d.ts +4 -5
- package/declarations/adapter/-private/utils/continue-on-reject.d.ts +5 -6
- package/declarations/adapter/-private/utils/determine-body-promise.d.ts +1 -2
- package/declarations/adapter/-private/utils/fetch.d.ts +2 -3
- package/declarations/adapter/-private/utils/parse-response-headers.d.ts +0 -1
- package/declarations/adapter/-private/utils/serialize-into-hash.d.ts +5 -6
- package/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -2
- package/declarations/adapter/-private.d.ts +5 -6
- package/declarations/adapter/error.d.ts +206 -178
- package/declarations/adapter/json-api.d.ts +206 -207
- package/declarations/adapter/rest.d.ts +805 -808
- package/declarations/adapter.d.ts +742 -766
- package/declarations/compat/-private.d.ts +10 -11
- package/declarations/compat/builders/find-all.d.ts +26 -24
- package/declarations/compat/builders/find-record.d.ts +41 -39
- package/declarations/compat/builders/query.d.ts +50 -45
- package/declarations/compat/builders/save-record.d.ts +26 -24
- package/declarations/compat/builders/utils.d.ts +1 -2
- package/declarations/compat/builders.d.ts +10 -11
- package/declarations/compat/extensions.d.ts +59 -0
- package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +39 -38
- package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +1 -2
- package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +9 -10
- package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +1 -2
- package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +1 -2
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +521 -517
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +214 -215
- package/declarations/compat/legacy-network-handler/serializer-response.d.ts +5 -6
- package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +83 -84
- package/declarations/compat/legacy-network-handler/snapshot.d.ts +228 -229
- package/declarations/compat/utils.d.ts +118 -119
- package/declarations/compat.d.ts +106 -104
- package/declarations/model/-private/attr.d.ts +164 -145
- package/declarations/model/-private/belongs-to.d.ts +135 -122
- package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +15 -4
- package/declarations/model/-private/errors.d.ts +272 -267
- package/declarations/model/-private/has-many.d.ts +119 -116
- package/declarations/model/-private/hooks.d.ts +5 -6
- package/declarations/model/-private/legacy-relationships-support.d.ts +51 -52
- package/declarations/model/-private/model-for-mixin.d.ts +18 -3
- package/declarations/model/-private/model-methods.d.ts +29 -24
- package/declarations/model/-private/model.d.ts +1306 -1254
- package/declarations/model/-private/notify-changes.d.ts +3 -4
- package/declarations/model/-private/promise-belongs-to.d.ts +33 -27
- package/declarations/model/-private/promise-many-array.d.ts +125 -116
- package/declarations/model/-private/record-state.d.ts +63 -60
- package/declarations/model/-private/references/belongs-to.d.ts +491 -487
- package/declarations/model/-private/references/has-many.d.ts +495 -492
- package/declarations/model/-private/schema-provider.d.ts +53 -56
- package/declarations/model/-private/type-utils.d.ts +41 -41
- package/declarations/model/-private/util.d.ts +1 -2
- package/declarations/model/-private.d.ts +8 -8
- package/declarations/model/migration-support.d.ts +281 -271
- package/declarations/model.d.ts +48 -49
- package/declarations/serializer/-private/embedded-records-mixin.d.ts +70 -71
- package/declarations/serializer/-private/transforms/boolean.d.ts +37 -37
- package/declarations/serializer/-private/transforms/date.d.ts +22 -22
- package/declarations/serializer/-private/transforms/number.d.ts +22 -22
- package/declarations/serializer/-private/transforms/string.d.ts +22 -22
- package/declarations/serializer/-private/transforms/transform.d.ts +109 -110
- package/declarations/serializer/-private/utils.d.ts +0 -1
- package/declarations/serializer/json-api.d.ts +124 -494
- package/declarations/serializer/json.d.ts +62 -1031
- package/declarations/serializer/rest.d.ts +52 -552
- package/declarations/serializer/transform.d.ts +5 -6
- package/declarations/serializer.d.ts +217 -218
- package/dist/{-private-DFfBszo5.js → -private-CKrP0ogQ.js} +1 -1
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +17 -0
- package/dist/adapter/json-api.js +1 -1
- package/dist/adapter/rest.js +5 -7
- package/dist/adapter.js +6 -35
- package/dist/compat/-private.js +1 -1
- package/dist/compat/extensions.js +243 -0
- package/dist/compat.js +3 -4
- package/dist/{errors-D74uk36r.js → errors-BX5wowuz.js} +12 -10
- package/dist/{json-DSOlH9A8.js → json-Et4mt_LM.js} +84 -157
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +15 -4
- package/dist/model.js +3 -3
- package/dist/{schema-provider-CXFLTMjg.js → schema-provider-BdQhkT-Q.js} +20 -13
- package/dist/{serialize-into-hash-BxfqWC8u.js → serialize-into-hash-Bp58npke.js} +1 -1
- package/dist/serializer/json-api.js +42 -2
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.js +46 -41
- package/dist/serializer/transform.js +0 -44
- package/package.json +7 -7
- package/declarations/adapter/-private/build-url-mixin.d.ts.map +0 -1
- package/declarations/adapter/-private/fastboot-interface.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/continue-on-reject.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/determine-body-promise.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/fetch.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/parse-response-headers.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/serialize-into-hash.d.ts.map +0 -1
- package/declarations/adapter/-private/utils/serialize-query-params.d.ts.map +0 -1
- package/declarations/adapter/-private.d.ts.map +0 -1
- package/declarations/adapter/error.d.ts.map +0 -1
- package/declarations/adapter/json-api.d.ts.map +0 -1
- package/declarations/adapter/rest.d.ts.map +0 -1
- package/declarations/adapter.d.ts.map +0 -1
- package/declarations/compat/-private.d.ts.map +0 -1
- package/declarations/compat/builders/find-all.d.ts.map +0 -1
- package/declarations/compat/builders/find-record.d.ts.map +0 -1
- package/declarations/compat/builders/query.d.ts.map +0 -1
- package/declarations/compat/builders/save-record.d.ts.map +0 -1
- package/declarations/compat/builders/utils.d.ts.map +0 -1
- package/declarations/compat/builders.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/fetch-manager.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/serializer-response.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts.map +0 -1
- package/declarations/compat/legacy-network-handler/snapshot.d.ts.map +0 -1
- package/declarations/compat/utils.d.ts.map +0 -1
- package/declarations/compat.d.ts.map +0 -1
- package/declarations/model/-private/attr.d.ts.map +0 -1
- package/declarations/model/-private/attr.type-test.d.ts +0 -2
- package/declarations/model/-private/attr.type-test.d.ts.map +0 -1
- package/declarations/model/-private/belongs-to.d.ts.map +0 -1
- package/declarations/model/-private/belongs-to.type-test.d.ts +0 -2
- package/declarations/model/-private/belongs-to.type-test.d.ts.map +0 -1
- package/declarations/model/-private/debug/assert-polymorphic-type.d.ts.map +0 -1
- package/declarations/model/-private/errors.d.ts.map +0 -1
- package/declarations/model/-private/has-many.d.ts.map +0 -1
- package/declarations/model/-private/has-many.type-test.d.ts +0 -2
- package/declarations/model/-private/has-many.type-test.d.ts.map +0 -1
- package/declarations/model/-private/hooks.d.ts.map +0 -1
- package/declarations/model/-private/legacy-relationships-support.d.ts.map +0 -1
- package/declarations/model/-private/model-for-mixin.d.ts.map +0 -1
- package/declarations/model/-private/model-methods.d.ts.map +0 -1
- package/declarations/model/-private/model.d.ts.map +0 -1
- package/declarations/model/-private/model.type-test.d.ts +0 -2
- package/declarations/model/-private/model.type-test.d.ts.map +0 -1
- package/declarations/model/-private/notify-changes.d.ts.map +0 -1
- package/declarations/model/-private/promise-belongs-to.d.ts.map +0 -1
- package/declarations/model/-private/promise-many-array.d.ts.map +0 -1
- package/declarations/model/-private/promise-proxy-base.d.ts +0 -3
- package/declarations/model/-private/promise-proxy-base.d.ts.map +0 -1
- package/declarations/model/-private/record-state.d.ts.map +0 -1
- package/declarations/model/-private/references/belongs-to.d.ts.map +0 -1
- package/declarations/model/-private/references/has-many.d.ts.map +0 -1
- package/declarations/model/-private/schema-provider.d.ts.map +0 -1
- package/declarations/model/-private/type-utils.d.ts.map +0 -1
- package/declarations/model/-private/util.d.ts.map +0 -1
- package/declarations/model/-private.d.ts.map +0 -1
- package/declarations/model/migration-support.d.ts.map +0 -1
- package/declarations/model/migration-support.type-test.d.ts +0 -2
- package/declarations/model/migration-support.type-test.d.ts.map +0 -1
- package/declarations/model.d.ts.map +0 -1
- package/declarations/serializer/-private/embedded-records-mixin.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/boolean.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/boolean.type-test.d.ts +0 -2
- package/declarations/serializer/-private/transforms/boolean.type-test.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/date.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/number.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/string.d.ts.map +0 -1
- package/declarations/serializer/-private/transforms/transform.d.ts.map +0 -1
- package/declarations/serializer/-private/utils.d.ts.map +0 -1
- package/declarations/serializer/json-api.d.ts.map +0 -1
- package/declarations/serializer/json.d.ts.map +0 -1
- package/declarations/serializer/rest.d.ts.map +0 -1
- package/declarations/serializer/transform.d.ts.map +0 -1
- package/declarations/serializer.d.ts.map +0 -1
- package/dist/-private-DFfBszo5.js.map +0 -1
- package/dist/adapter/-private.js.map +0 -1
- package/dist/adapter/error.js.map +0 -1
- package/dist/adapter/json-api.js.map +0 -1
- package/dist/adapter/rest.js.map +0 -1
- package/dist/adapter.js.map +0 -1
- package/dist/compat/-private.js.map +0 -1
- package/dist/compat/builders.js.map +0 -1
- package/dist/compat/utils.js.map +0 -1
- package/dist/compat.js.map +0 -1
- package/dist/errors-D74uk36r.js.map +0 -1
- package/dist/json-DSOlH9A8.js.map +0 -1
- package/dist/model/-private.js.map +0 -1
- package/dist/model/migration-support.js.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/runtime-BPCpkOf1-BKOwiRJp.js.map +0 -1
- package/dist/schema-provider-CXFLTMjg.js.map +0 -1
- package/dist/serialize-into-hash-BxfqWC8u.js.map +0 -1
- package/dist/serializer/json-api.js.map +0 -1
- package/dist/serializer/json.js.map +0 -1
- package/dist/serializer/rest.js.map +0 -1
- package/dist/serializer/transform.js.map +0 -1
- package/dist/serializer.js.map +0 -1
package/declarations/model.d.ts
CHANGED
|
@@ -1,50 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export { attr } from
|
|
40
|
-
export { belongsTo } from
|
|
41
|
-
export { hasMany } from
|
|
42
|
-
export { Model } from
|
|
43
|
-
export { Model as default } from
|
|
44
|
-
export type { PromiseBelongsTo as AsyncBelongsTo } from
|
|
45
|
-
export type { PromiseManyArray as AsyncHasMany } from
|
|
46
|
-
export type { RelatedCollection as ManyArray } from
|
|
47
|
-
export type { RelatedCollection as HasMany } from
|
|
48
|
-
export { instantiateRecord, teardownRecord, modelFor } from
|
|
49
|
-
export { buildSchema } from
|
|
50
|
-
//# sourceMappingURL=model.d.ts.map
|
|
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 '@ember-data/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
|
+
### Defining a Model
|
|
18
|
+
|
|
19
|
+
```js [app/models/person.js]
|
|
20
|
+
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
|
|
21
|
+
|
|
22
|
+
export default class PersonModel extends Model {
|
|
23
|
+
@attr name;
|
|
24
|
+
|
|
25
|
+
@belongsTo('pet', { inverse: 'owners', async: false }) dog;
|
|
26
|
+
|
|
27
|
+
@hasMany('person', { inverse: 'friends', async: true }) friends;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### modelName convention
|
|
32
|
+
|
|
33
|
+
By convention, the name of a given model (its `type`) matches the name
|
|
34
|
+
of the file in the `app/models` folder and should be lowercase, singular
|
|
35
|
+
and dasherized.
|
|
36
|
+
|
|
37
|
+
@module
|
|
38
|
+
*/
|
|
39
|
+
export { attr } from "./model/-private/attr.js";
|
|
40
|
+
export { belongsTo } from "./model/-private/belongs-to.js";
|
|
41
|
+
export { hasMany } from "./model/-private/has-many.js";
|
|
42
|
+
export { Model } from "./model/-private/model.js";
|
|
43
|
+
export { Model as default } from "./model/-private/model.js";
|
|
44
|
+
export type { PromiseBelongsTo as AsyncBelongsTo } from "./model/-private/promise-belongs-to.js";
|
|
45
|
+
export type { PromiseManyArray as AsyncHasMany } from "./model/-private/promise-many-array.js";
|
|
46
|
+
export type { RelatedCollection as ManyArray } from "@warp-drive/core/store/-private";
|
|
47
|
+
export type { RelatedCollection as HasMany } from "@warp-drive/core/store/-private";
|
|
48
|
+
export { instantiateRecord, teardownRecord, modelFor } from "./model/-private/hooks.js";
|
|
49
|
+
export { buildSchema } from "./model/-private/schema-provider.js";
|
|
@@ -1,97 +1,96 @@
|
|
|
1
|
+
import Mixin from "@ember/object/mixin";
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
+
## Using Embedded Records
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
`EmbeddedRecordsMixin` supports serializing embedded records.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
To set up embedded records, include the mixin when extending a serializer,
|
|
8
|
+
then define and configure embedded (model) relationships.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
Note that embedded records will serialize with the serializer for their model instead of the serializer in which they are defined.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
Note also that this mixin does not work with JSONAPISerializer because the JSON:API specification does not describe how to format embedded resources.
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
Below is an example of a per-type serializer (`post` type).
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
```js [app/serializers/post.js]
|
|
17
|
+
import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {
|
|
20
|
+
attrs = {
|
|
21
|
+
author: { embedded: 'always' },
|
|
22
|
+
comments: { serialize: 'ids' }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
Note that this use of `{ embedded: 'always' }` is unrelated to
|
|
27
|
+
the `{ embedded: 'always' }` that is defined as an option on `attr` as part of
|
|
28
|
+
defining a model while working with the `ActiveModelSerializer`. Nevertheless,
|
|
29
|
+
using `{ embedded: 'always' }` as an option to `attr` is not a valid way to set up
|
|
30
|
+
embedded records.
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
The `attrs` option for a resource `{ embedded: 'always' }` is shorthand for:
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
```js
|
|
35
|
+
{
|
|
36
|
+
serialize: 'records',
|
|
37
|
+
deserialize: 'records'
|
|
38
|
+
}
|
|
39
|
+
```
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
### Configuring Attrs
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
A resource's `attrs` option may be set to use `ids`, `records` or false for the
|
|
44
|
+
`serialize` and `deserialize` settings.
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
The `attrs` property can be set on the `ApplicationSerializer` or a per-type
|
|
47
|
+
serializer.
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
In the case where embedded JSON is expected while extracting a payload (reading)
|
|
50
|
+
the setting is `deserialize: 'records'`, there is no need to use `ids` when
|
|
51
|
+
extracting as that is the default behaviour without this mixin if you are using
|
|
52
|
+
the vanilla `EmbeddedRecordsMixin`. Likewise, to embed JSON in the payload while
|
|
53
|
+
serializing `serialize: 'records'` is the setting to use. There is an option of
|
|
54
|
+
not embedding JSON in the serialized payload by using `serialize: 'ids'`. If you
|
|
55
|
+
do not want the relationship sent at all, you can use `serialize: false`.
|
|
55
56
|
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
### EmbeddedRecordsMixin defaults
|
|
59
|
+
If you do not overwrite `attrs` for a specific relationship, the `EmbeddedRecordsMixin`
|
|
60
|
+
will behave in the following way:
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
BelongsTo: `{ serialize: 'id', deserialize: 'id' }`
|
|
63
|
+
HasMany: `{ serialize: false, deserialize: 'ids' }`
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
### Model Relationships
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
Embedded records must have a model defined to be extracted and serialized. Note that
|
|
68
|
+
when defining any relationships on your model such as `belongsTo` and `hasMany`, you
|
|
69
|
+
should not both specify `async: true` and also indicate through the serializer's
|
|
70
|
+
`attrs` attribute that the related model should be embedded for deserialization.
|
|
71
|
+
If a model is declared embedded for deserialization (`embedded: 'always'` or `deserialize: 'records'`),
|
|
72
|
+
then do not use `async: true`.
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
To successfully extract and serialize embedded records the model relationships
|
|
75
|
+
must be set up correctly. See the
|
|
76
|
+
[defining relationships](https://guides.emberjs.com/current/models/relationships)
|
|
77
|
+
section of the **Defining Models** guide page.
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
Records without an `id` property are not considered embedded records, model
|
|
80
|
+
instances must have an `id` property to be used with Ember Data.
|
|
80
81
|
|
|
81
|
-
|
|
82
|
+
### Example JSON payloads, Models and Serializers
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
**When customizing a serializer it is important to grok what the customizations
|
|
85
|
+
are. Please read the docs for the methods this mixin provides, in case you need
|
|
86
|
+
to modify it to fit your specific needs.**
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
For example, review the docs for each method of this mixin:
|
|
89
|
+
* [normalize](/ember-data/release/classes/EmbeddedRecordsMixin/methods/normalize?anchor=normalize)
|
|
90
|
+
* [serializeBelongsTo](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeBelongsTo?anchor=serializeBelongsTo)
|
|
91
|
+
* [serializeHasMany](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeHasMany?anchor=serializeHasMany)
|
|
91
92
|
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
@class EmbeddedRecordsMixin
|
|
94
|
+
@public
|
|
94
95
|
*/
|
|
95
|
-
export const EmbeddedRecordsMixin: Mixin;
|
|
96
|
-
import Mixin from '@ember/object/mixin';
|
|
97
|
-
//# sourceMappingURL=embedded-records-mixin.d.ts.map
|
|
96
|
+
export declare const EmbeddedRecordsMixin: Mixin;
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import type { TransformName } from
|
|
1
|
+
import type { TransformName } from "@warp-drive/core/types/symbols";
|
|
2
|
+
export interface BooleanTransform {
|
|
3
|
+
[TransformName]: "boolean";
|
|
4
|
+
}
|
|
2
5
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
The `BooleanTransform` class is used to serialize and deserialize
|
|
7
|
+
boolean attributes on Ember Data record objects. This transform is
|
|
8
|
+
used when `boolean` is passed as the type parameter to the
|
|
9
|
+
[attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function.
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
Usage
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
```js [app/models/user.js]
|
|
14
|
+
import { Model, attr } from '@warp-drive/legacy/model';
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
export default class UserModel extends Model {
|
|
17
|
+
@attr('boolean') isAdmin;
|
|
18
|
+
@attr('string') name;
|
|
19
|
+
@attr('string') email;
|
|
20
|
+
}
|
|
21
|
+
```
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
By default, the boolean transform only allows for values of `true` or
|
|
24
|
+
`false`. You can opt into allowing `null` values for
|
|
25
|
+
boolean attributes via `attr('boolean', { allowNull: true })`
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
```js [app/models/user.js]
|
|
28
|
+
import { Model, attr } from '@warp-drive/legacy/model';
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
export default class UserModel extends Model {
|
|
31
|
+
@attr('string') email;
|
|
32
|
+
@attr('string') username;
|
|
33
|
+
@attr('boolean', { allowNull: true }) wantsWeeklyEmail;
|
|
34
|
+
}
|
|
35
|
+
```
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*/
|
|
37
|
+
@public
|
|
38
|
+
*/
|
|
37
39
|
export declare class BooleanTransform {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
static create(): BooleanTransform;
|
|
40
|
+
deserialize(serialized: boolean | null | number | string, options?: {
|
|
41
|
+
allowNull?: boolean;
|
|
42
|
+
}): boolean | null;
|
|
43
|
+
serialize(deserialized: boolean | null, options?: {
|
|
44
|
+
allowNull?: boolean;
|
|
45
|
+
}): boolean | null;
|
|
46
|
+
static create(): BooleanTransform;
|
|
46
47
|
}
|
|
47
|
-
//# sourceMappingURL=boolean.d.ts.map
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { TransformName } from
|
|
1
|
+
import type { TransformName } from "@warp-drive/core/types/symbols";
|
|
2
|
+
export interface DateTransform {
|
|
3
|
+
[TransformName]: "date";
|
|
4
|
+
}
|
|
2
5
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
The `DateTransform` class is used to serialize and deserialize
|
|
7
|
+
date attributes on Ember Data record objects. This transform is used
|
|
8
|
+
when `date` is passed as the type parameter to the
|
|
9
|
+
[attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function. It uses the [`ISO 8601`](https://en.wikipedia.org/wiki/ISO_8601)
|
|
10
|
+
standard.
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
```js [app/models/score.js]
|
|
13
|
+
import Model, { attr, belongsTo } from '@ember-data/model';
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
export default class ScoreModel extends Model {
|
|
16
|
+
@attr('number') value;
|
|
17
|
+
@belongsTo('player') player;
|
|
18
|
+
@attr('date') date;
|
|
19
|
+
}
|
|
20
|
+
```
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*/
|
|
22
|
+
@public
|
|
23
|
+
*/
|
|
22
24
|
export declare class DateTransform {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
static create(): DateTransform;
|
|
25
|
+
deserialize(serialized: string | number | null, _options?: Record<string, unknown>): Date | null;
|
|
26
|
+
serialize(date: Date, _options?: Record<string, unknown>): string | null;
|
|
27
|
+
static create(): DateTransform;
|
|
27
28
|
}
|
|
28
|
-
//# sourceMappingURL=date.d.ts.map
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { TransformName } from
|
|
1
|
+
import type { TransformName } from "@warp-drive/core/types/symbols";
|
|
2
|
+
export interface NumberTransform {
|
|
3
|
+
[TransformName]: "number";
|
|
4
|
+
}
|
|
2
5
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
The `NumberTransform` class is used to serialize and deserialize
|
|
7
|
+
numeric attributes on Ember Data record objects. This transform is
|
|
8
|
+
used when `number` is passed as the type parameter to the
|
|
9
|
+
[attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function.
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
Usage
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
```js [app/models/score.js]
|
|
14
|
+
import Model, { attr, belongsTo } from '@ember-data/model';
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
export default class ScoreModel extends Model {
|
|
17
|
+
@attr('number') value;
|
|
18
|
+
@belongsTo('player') player;
|
|
19
|
+
@attr('date') date;
|
|
20
|
+
}
|
|
21
|
+
```
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
+
@public
|
|
24
|
+
*/
|
|
23
25
|
export declare class NumberTransform {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
static create(): NumberTransform;
|
|
26
|
+
deserialize(serialized: string | number | null | undefined, _options?: Record<string, unknown>): number | null;
|
|
27
|
+
serialize(deserialized: string | number | null | undefined, _options?: Record<string, unknown>): number | null;
|
|
28
|
+
static create(): NumberTransform;
|
|
28
29
|
}
|
|
29
|
-
//# sourceMappingURL=number.d.ts.map
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { TransformName } from
|
|
1
|
+
import type { TransformName } from "@warp-drive/core/types/symbols";
|
|
2
|
+
export interface StringTransform {
|
|
3
|
+
[TransformName]: "string";
|
|
4
|
+
}
|
|
2
5
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
The `StringTransform` class is used to serialize and deserialize
|
|
7
|
+
string attributes on Ember Data record objects. This transform is
|
|
8
|
+
used when `string` is passed as the type parameter to the
|
|
9
|
+
[attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function.
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
Usage
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
```js [app/models/user.js]
|
|
14
|
+
import Model, { attr, belongsTo } from '@ember-data/model';
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
export default class UserModel extends Model {
|
|
17
|
+
@attr('boolean') isAdmin;
|
|
18
|
+
@attr('string') name;
|
|
19
|
+
@attr('string') email;
|
|
20
|
+
}
|
|
21
|
+
```
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
+
@public
|
|
24
|
+
*/
|
|
23
25
|
export declare class StringTransform {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
static create(): StringTransform;
|
|
26
|
+
deserialize(serialized: unknown, _options?: Record<string, unknown>): string | null;
|
|
27
|
+
serialize(deserialized: unknown, _options?: Record<string, unknown>): string | null;
|
|
28
|
+
static create(): StringTransform;
|
|
28
29
|
}
|
|
29
|
-
//# sourceMappingURL=string.d.ts.map
|