@ember-data/serializer 4.12.0-beta.2 → 4.12.0-beta.4
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/addon/-private.js +23 -16
- package/addon/-private.js.map +1 -1
- package/addon/{embedded-records-mixin-0a9e9148.js → embedded-records-mixin-d75385ff.js} +1 -2
- package/addon/embedded-records-mixin-d75385ff.js.map +1 -0
- package/addon/index.js +4 -1
- package/addon/index.js.map +1 -1
- package/addon/json-api.js +10 -12
- package/addon/json-api.js.map +1 -1
- package/addon/json.js +8 -11
- package/addon/json.js.map +1 -1
- package/addon/rest.js +5 -6
- package/addon/rest.js.map +1 -1
- package/addon/transform.js +3 -4
- package/addon/transform.js.map +1 -1
- package/addon-main.js +18 -15
- package/package.json +7 -10
- package/addon/embedded-records-mixin-0a9e9148.js.map +0 -1
- package/addon/transform-63fba437.js +0 -112
- package/addon/transform-63fba437.js.map +0 -1
package/addon/-private.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { e as EmbeddedRecordsMixin } from "./embedded-records-mixin-
|
|
2
|
-
|
|
3
|
-
import { isNone } from '@ember/utils';
|
|
1
|
+
export { e as EmbeddedRecordsMixin } from "./embedded-records-mixin-d75385ff";
|
|
2
|
+
export { default as Transform } from '@ember/object';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
@module @ember-data/serializer
|
|
@@ -40,11 +39,10 @@ import { isNone } from '@ember/utils';
|
|
|
40
39
|
|
|
41
40
|
@class BooleanTransform
|
|
42
41
|
@public
|
|
43
|
-
@extends Transform
|
|
44
42
|
*/
|
|
45
|
-
class BooleanTransform
|
|
43
|
+
class BooleanTransform {
|
|
46
44
|
deserialize(serialized, options) {
|
|
47
|
-
if (
|
|
45
|
+
if ((serialized === null || serialized === undefined) && options.allowNull === true) {
|
|
48
46
|
return null;
|
|
49
47
|
}
|
|
50
48
|
let type = typeof serialized;
|
|
@@ -59,11 +57,14 @@ class BooleanTransform extends Transform {
|
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
59
|
serialize(deserialized, options) {
|
|
62
|
-
if (
|
|
60
|
+
if ((deserialized === null || deserialized === undefined) && options.allowNull === true) {
|
|
63
61
|
return null;
|
|
64
62
|
}
|
|
65
63
|
return Boolean(deserialized);
|
|
66
64
|
}
|
|
65
|
+
static create() {
|
|
66
|
+
return new this();
|
|
67
|
+
}
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
/**
|
|
@@ -89,10 +90,9 @@ class BooleanTransform extends Transform {
|
|
|
89
90
|
|
|
90
91
|
@class DateTransform
|
|
91
92
|
@public
|
|
92
|
-
@extends Transform
|
|
93
93
|
*/
|
|
94
94
|
|
|
95
|
-
class DateTransform
|
|
95
|
+
class DateTransform {
|
|
96
96
|
deserialize(serialized) {
|
|
97
97
|
let type = typeof serialized;
|
|
98
98
|
if (type === 'string') {
|
|
@@ -119,6 +119,9 @@ class DateTransform extends Transform {
|
|
|
119
119
|
return null;
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
+
static create() {
|
|
123
|
+
return new this();
|
|
124
|
+
}
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
/**
|
|
@@ -149,9 +152,8 @@ function isNumber(value) {
|
|
|
149
152
|
|
|
150
153
|
@class NumberTransform
|
|
151
154
|
@public
|
|
152
|
-
@extends Transform
|
|
153
155
|
*/
|
|
154
|
-
class NumberTransform
|
|
156
|
+
class NumberTransform {
|
|
155
157
|
deserialize(serialized) {
|
|
156
158
|
let transformed;
|
|
157
159
|
if (serialized === '' || serialized === null || serialized === undefined) {
|
|
@@ -170,6 +172,9 @@ class NumberTransform extends Transform {
|
|
|
170
172
|
return isNumber(transformed) ? transformed : null;
|
|
171
173
|
}
|
|
172
174
|
}
|
|
175
|
+
static create() {
|
|
176
|
+
return new this();
|
|
177
|
+
}
|
|
173
178
|
}
|
|
174
179
|
|
|
175
180
|
/**
|
|
@@ -196,14 +201,16 @@ class NumberTransform extends Transform {
|
|
|
196
201
|
|
|
197
202
|
@class StringTransform
|
|
198
203
|
@public
|
|
199
|
-
@extends Transform
|
|
200
204
|
*/
|
|
201
|
-
class StringTransform
|
|
205
|
+
class StringTransform {
|
|
202
206
|
deserialize(serialized) {
|
|
203
|
-
return
|
|
207
|
+
return !serialized && serialized !== '' ? null : String(serialized);
|
|
204
208
|
}
|
|
205
209
|
serialize(deserialized) {
|
|
206
|
-
return
|
|
210
|
+
return !deserialized && deserialized !== '' ? null : String(deserialized);
|
|
211
|
+
}
|
|
212
|
+
static create() {
|
|
213
|
+
return new this();
|
|
207
214
|
}
|
|
208
215
|
}
|
|
209
|
-
export { BooleanTransform, DateTransform, NumberTransform, StringTransform
|
|
216
|
+
export { BooleanTransform, DateTransform, NumberTransform, StringTransform };
|
package/addon/-private.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"-private.js","sources":["../src/-private/transforms/boolean.js","../src/-private/transforms/date.js","../src/-private/transforms/number.js","../src/-private/transforms/string.js"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"-private.js","sources":["../src/-private/transforms/boolean.js","../src/-private/transforms/date.js","../src/-private/transforms/number.js","../src/-private/transforms/string.js"],"sourcesContent":["/**\n @module @ember-data/serializer\n*/\n\n/**\n The `BooleanTransform` class is used to serialize and deserialize\n boolean attributes on Ember Data record objects. This transform is\n used when `boolean` is passed as the type parameter to the\n [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function.\n\n Usage\n\n ```app/models/user.js\n import Model, { attr } from '@ember-data/model';\n\n export default class UserModel extends Model {\n @attr('boolean') isAdmin;\n @attr('string') name;\n @attr('string') email;\n }\n ```\n\n By default, the boolean transform only allows for values of `true` or\n `false`. You can opt into allowing `null` values for\n boolean attributes via `attr('boolean', { allowNull: true })`\n\n ```app/models/user.js\n import Model, { attr } from '@ember-data/model';\n\n export default class UserModel extends Model {\n @attr('string') email;\n @attr('string') username;\n @attr('boolean', { allowNull: true }) wantsWeeklyEmail;\n }\n ```\n\n @class BooleanTransform\n @public\n */\nexport default class BooleanTransform {\n deserialize(serialized, options) {\n if ((serialized === null || serialized === undefined) && options.allowNull === true) {\n return null;\n }\n\n let type = typeof serialized;\n if (type === 'boolean') {\n return serialized;\n } else if (type === 'string') {\n return /^(true|t|1)$/i.test(serialized);\n } else if (type === 'number') {\n return serialized === 1;\n } else {\n return false;\n }\n }\n\n serialize(deserialized, options) {\n if ((deserialized === null || deserialized === undefined) && options.allowNull === true) {\n return null;\n }\n\n return Boolean(deserialized);\n }\n\n static create() {\n return new this();\n }\n}\n","/**\n @module @ember-data/serializer\n*/\n\n/**\n The `DateTransform` class is used to serialize and deserialize\n date attributes on Ember Data record objects. This transform is used\n when `date` is passed as the type parameter to the\n [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function. It uses the [`ISO 8601`](https://en.wikipedia.org/wiki/ISO_8601)\n standard.\n\n ```app/models/score.js\n import Model, { attr, belongsTo } from '@ember-data/model';\n\n export default class ScoreModel extends Model {\n @attr('number') value;\n @belongsTo('player') player;\n @attr('date') date;\n }\n ```\n\n @class DateTransform\n @public\n */\n\nexport default class DateTransform {\n deserialize(serialized) {\n let type = typeof serialized;\n\n if (type === 'string') {\n let offset = serialized.indexOf('+');\n\n if (offset !== -1 && serialized.length - 5 === offset) {\n offset += 3;\n return new Date(serialized.slice(0, offset) + ':' + serialized.slice(offset));\n }\n return new Date(serialized);\n } else if (type === 'number') {\n return new Date(serialized);\n } else if (serialized === null || serialized === undefined) {\n // if the value is null return null\n // if the value is not present in the data return undefined\n return serialized;\n } else {\n return null;\n }\n }\n\n serialize(date) {\n if (date instanceof Date && !isNaN(date)) {\n return date.toISOString();\n } else {\n return null;\n }\n }\n\n static create() {\n return new this();\n }\n}\n","/**\n @module @ember-data/serializer\n*/\n\nfunction isNumber(value) {\n return value === value && value !== Infinity && value !== -Infinity;\n}\n\n/**\n The `NumberTransform` class is used to serialize and deserialize\n numeric attributes on Ember Data record objects. This transform is\n used when `number` is passed as the type parameter to the\n [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function.\n\n Usage\n\n ```app/models/score.js\n import Model, { attr, belongsTo } from '@ember-data/model';\n\n export default class ScoreModel extends Model {\n @attr('number') value;\n @belongsTo('player') player;\n @attr('date') date;\n }\n ```\n\n @class NumberTransform\n @public\n */\nexport default class NumberTransform {\n deserialize(serialized) {\n let transformed;\n\n if (serialized === '' || serialized === null || serialized === undefined) {\n return null;\n } else {\n transformed = Number(serialized);\n\n return isNumber(transformed) ? transformed : null;\n }\n }\n\n serialize(deserialized) {\n let transformed;\n\n if (deserialized === '' || deserialized === null || deserialized === undefined) {\n return null;\n } else {\n transformed = Number(deserialized);\n\n return isNumber(transformed) ? transformed : null;\n }\n }\n\n static create() {\n return new this();\n }\n}\n","/**\n @module @ember-data/serializer\n*/\n\n/**\n The `StringTransform` class is used to serialize and deserialize\n string attributes on Ember Data record objects. This transform is\n used when `string` is passed as the type parameter to the\n [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function.\n\n Usage\n\n ```app/models/user.js\n import Model, { attr, belongsTo } from '@ember-data/model';\n\n export default class UserModel extends Model {\n @attr('boolean') isAdmin;\n @attr('string') name;\n @attr('string') email;\n }\n ```\n\n @class StringTransform\n @public\n */\nexport default class StringTransform {\n deserialize(serialized) {\n return !serialized && serialized !== '' ? null : String(serialized);\n }\n serialize(deserialized) {\n return !deserialized && deserialized !== '' ? null : String(deserialized);\n }\n\n static create() {\n return new this();\n }\n}\n"],"names":["BooleanTransform","deserialize","serialized","options","undefined","allowNull","type","test","serialize","deserialized","Boolean","create","DateTransform","offset","indexOf","length","Date","slice","date","isNaN","toISOString","isNumber","value","Infinity","NumberTransform","transformed","Number","StringTransform","String"],"mappings":";;;AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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B,IAAA,OAAO,CAACA,YAAY,IAAIA,YAAY,KAAK,EAAE,GAAG,IAAI,GAAGmB,MAAM,CAACnB,YAAY,CAAC,CAAA;AAC3E,GAAA;EAEA,OAAOE,MAAMA,GAAG;IACd,OAAO,IAAI,IAAI,EAAE,CAAA;AACnB,GAAA;AACF;;;;"}
|
|
@@ -2,7 +2,6 @@ import { A } from '@ember/array';
|
|
|
2
2
|
import { warn } from '@ember/debug';
|
|
3
3
|
import Mixin from '@ember/object/mixin';
|
|
4
4
|
import { camelize } from '@ember/string';
|
|
5
|
-
import { typeOf } from '@ember/utils';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
@module @ember-data/serializer/rest
|
|
@@ -392,7 +391,7 @@ var embeddedRecordsMixin = Mixin.create({
|
|
|
392
391
|
if (serializedKey === relationship.key && this.keyForRelationship) {
|
|
393
392
|
serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');
|
|
394
393
|
}
|
|
395
|
-
warn(`The embedded relationship '${serializedKey}' is undefined for '${snapshot.modelName}' with id '${snapshot.id}'. Please include it in your original payload.`,
|
|
394
|
+
warn(`The embedded relationship '${serializedKey}' is undefined for '${snapshot.modelName}' with id '${snapshot.id}'. Please include it in your original payload.`, typeof snapshot.hasMany(relationship.key) !== 'undefined', {
|
|
396
395
|
id: 'ds.serializer.embedded-relationship-undefined'
|
|
397
396
|
});
|
|
398
397
|
json[serializedKey] = this._generateSerializedHasMany(snapshot, relationship);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedded-records-mixin-d75385ff.js","sources":["../src/-private/embedded-records-mixin.js"],"sourcesContent":["import { A } from '@ember/array';\nimport { warn } from '@ember/debug';\nimport Mixin from '@ember/object/mixin';\nimport { camelize } from '@ember/string';\n\n/**\n @module @ember-data/serializer/rest\n*/\n\n/**\n ## Using Embedded Records\n\n `EmbeddedRecordsMixin` supports serializing embedded records.\n\n To set up embedded records, include the mixin when extending a serializer,\n then define and configure embedded (model) relationships.\n\n Note that embedded records will serialize with the serializer for their model instead of the serializer in which they are defined.\n\n Note also that this mixin does not work with JSONAPISerializer because the JSON:API specification does not describe how to format embedded resources.\n\n Below is an example of a per-type serializer (`post` type).\n\n ```app/serializers/post.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n author: { embedded: 'always' },\n comments: { serialize: 'ids' }\n }\n }\n ```\n Note that this use of `{ embedded: 'always' }` is unrelated to\n the `{ embedded: 'always' }` that is defined as an option on `attr` as part of\n defining a model while working with the `ActiveModelSerializer`. Nevertheless,\n using `{ embedded: 'always' }` as an option to `attr` is not a valid way to set up\n embedded records.\n\n The `attrs` option for a resource `{ embedded: 'always' }` is shorthand for:\n\n ```js\n {\n serialize: 'records',\n deserialize: 'records'\n }\n ```\n\n ### Configuring Attrs\n\n A resource's `attrs` option may be set to use `ids`, `records` or false for the\n `serialize` and `deserialize` settings.\n\n The `attrs` property can be set on the `ApplicationSerializer` or a per-type\n serializer.\n\n In the case where embedded JSON is expected while extracting a payload (reading)\n the setting is `deserialize: 'records'`, there is no need to use `ids` when\n extracting as that is the default behaviour without this mixin if you are using\n the vanilla `EmbeddedRecordsMixin`. Likewise, to embed JSON in the payload while\n serializing `serialize: 'records'` is the setting to use. There is an option of\n not embedding JSON in the serialized payload by using `serialize: 'ids'`. If you\n do not want the relationship sent at all, you can use `serialize: false`.\n\n\n ### EmbeddedRecordsMixin defaults\n If you do not overwrite `attrs` for a specific relationship, the `EmbeddedRecordsMixin`\n will behave in the following way:\n\n BelongsTo: `{ serialize: 'id', deserialize: 'id' }`\n HasMany: `{ serialize: false, deserialize: 'ids' }`\n\n ### Model Relationships\n\n Embedded records must have a model defined to be extracted and serialized. Note that\n when defining any relationships on your model such as `belongsTo` and `hasMany`, you\n should not both specify `async: true` and also indicate through the serializer's\n `attrs` attribute that the related model should be embedded for deserialization.\n If a model is declared embedded for deserialization (`embedded: 'always'` or `deserialize: 'records'`),\n then do not use `async: true`.\n\n To successfully extract and serialize embedded records the model relationships\n must be set up correctly. See the\n [defining relationships](https://guides.emberjs.com/current/models/relationships)\n section of the **Defining Models** guide page.\n\n Records without an `id` property are not considered embedded records, model\n instances must have an `id` property to be used with Ember Data.\n\n ### Example JSON payloads, Models and Serializers\n\n **When customizing a serializer it is important to grok what the customizations\n are. Please read the docs for the methods this mixin provides, in case you need\n to modify it to fit your specific needs.**\n\n For example, review the docs for each method of this mixin:\n * [normalize](/ember-data/release/classes/EmbeddedRecordsMixin/methods/normalize?anchor=normalize)\n * [serializeBelongsTo](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeBelongsTo?anchor=serializeBelongsTo)\n * [serializeHasMany](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeHasMany?anchor=serializeHasMany)\n\n @class EmbeddedRecordsMixin\n @public\n*/\nexport default Mixin.create({\n /**\n Normalize the record and recursively normalize/extract all the embedded records\n while pushing them into the store as they are encountered\n\n A payload with an attr configured for embedded records needs to be extracted:\n\n ```js\n {\n \"post\": {\n \"id\": \"1\"\n \"title\": \"Rails is omakase\",\n \"comments\": [{\n \"id\": \"1\",\n \"body\": \"Rails is unagi\"\n }, {\n \"id\": \"2\",\n \"body\": \"Omakase O_o\"\n }]\n }\n }\n ```\n @method normalize\n @public\n @param {Model} typeClass\n @param {Object} hash to be normalized\n @param {String} prop the hash has been referenced by\n @return {Object} the normalized hash\n **/\n normalize(typeClass, hash, prop) {\n let normalizedHash = this._super(typeClass, hash, prop);\n return this._extractEmbeddedRecords(this, this.store, typeClass, normalizedHash);\n },\n\n keyForRelationship(key, typeClass, method) {\n if (\n (method === 'serialize' && this.hasSerializeRecordsOption(key)) ||\n (method === 'deserialize' && this.hasDeserializeRecordsOption(key))\n ) {\n return this.keyForAttribute(key, method);\n } else {\n return this._super(key, typeClass, method) || key;\n }\n },\n\n /**\n Serialize `belongsTo` relationship when it is configured as an embedded object.\n\n This example of an author model belongs to a post model:\n\n ```js\n import Model, { attr, belongsTo } from '@ember-data/model';\n\n Post = Model.extend({\n title: attr('string'),\n body: attr('string'),\n author: belongsTo('author')\n });\n\n Author = Model.extend({\n name: attr('string'),\n post: belongsTo('post')\n });\n ```\n\n Use a custom (type) serializer for the post model to configure embedded author\n\n ```app/serializers/post.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n author: { embedded: 'always' }\n }\n }\n ```\n\n A payload with an attribute configured for embedded records can serialize\n the records together under the root attribute's payload:\n\n ```js\n {\n \"post\": {\n \"id\": \"1\"\n \"title\": \"Rails is omakase\",\n \"author\": {\n \"id\": \"2\"\n \"name\": \"dhh\"\n }\n }\n }\n ```\n\n @method serializeBelongsTo\n @public\n @param {Snapshot} snapshot\n @param {Object} json\n @param {Object} relationship\n */\n serializeBelongsTo(snapshot, json, relationship) {\n let attr = relationship.key;\n if (this.noSerializeOptionSpecified(attr)) {\n this._super(snapshot, json, relationship);\n return;\n }\n let includeIds = this.hasSerializeIdsOption(attr);\n let includeRecords = this.hasSerializeRecordsOption(attr);\n let embeddedSnapshot = snapshot.belongsTo(attr);\n if (includeIds) {\n let schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.key, schema);\n if (serializedKey === relationship.key && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');\n }\n\n if (!embeddedSnapshot) {\n json[serializedKey] = null;\n } else {\n json[serializedKey] = embeddedSnapshot.id;\n\n if (relationship.options.polymorphic) {\n this.serializePolymorphicType(snapshot, json, relationship);\n }\n }\n } else if (includeRecords) {\n this._serializeEmbeddedBelongsTo(snapshot, json, relationship);\n }\n },\n\n _serializeEmbeddedBelongsTo(snapshot, json, relationship) {\n let embeddedSnapshot = snapshot.belongsTo(relationship.key);\n let schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.key, schema);\n if (serializedKey === relationship.key && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');\n }\n\n if (!embeddedSnapshot) {\n json[serializedKey] = null;\n } else {\n json[serializedKey] = embeddedSnapshot.serialize({ includeId: true });\n this.removeEmbeddedForeignKey(snapshot, embeddedSnapshot, relationship, json[serializedKey]);\n\n if (relationship.options.polymorphic) {\n this.serializePolymorphicType(snapshot, json, relationship);\n }\n }\n },\n\n /**\n Serializes `hasMany` relationships when it is configured as embedded objects.\n\n This example of a post model has many comments:\n\n ```js\n import Model, { attr, belongsTo, hasMany } from '@ember-data/model';\n\n Post = Model.extend({\n title: attr('string'),\n body: attr('string'),\n comments: hasMany('comment')\n });\n\n Comment = Model.extend({\n body: attr('string'),\n post: belongsTo('post')\n });\n ```\n\n Use a custom (type) serializer for the post model to configure embedded comments\n\n ```app/serializers/post.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n comments: { embedded: 'always' }\n }\n }\n ```\n\n A payload with an attribute configured for embedded records can serialize\n the records together under the root attribute's payload:\n\n ```js\n {\n \"post\": {\n \"id\": \"1\"\n \"title\": \"Rails is omakase\",\n \"body\": \"I want this for my ORM, I want that for my template language...\"\n \"comments\": [{\n \"id\": \"1\",\n \"body\": \"Rails is unagi\"\n }, {\n \"id\": \"2\",\n \"body\": \"Omakase O_o\"\n }]\n }\n }\n ```\n\n The attrs options object can use more specific instruction for extracting and\n serializing. When serializing, an option to embed `ids`, `ids-and-types` or `records` can be set.\n When extracting the only option is `records`.\n\n So `{ embedded: 'always' }` is shorthand for:\n `{ serialize: 'records', deserialize: 'records' }`\n\n To embed the `ids` for a related object (using a hasMany relationship):\n\n ```app/serializers/post.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n comments: { serialize: 'ids', deserialize: 'records' }\n }\n }\n ```\n\n ```js\n {\n \"post\": {\n \"id\": \"1\"\n \"title\": \"Rails is omakase\",\n \"body\": \"I want this for my ORM, I want that for my template language...\"\n \"comments\": [\"1\", \"2\"]\n }\n }\n ```\n\n To embed the relationship as a collection of objects with `id` and `type` keys, set\n `ids-and-types` for the related object.\n\n This is particularly useful for polymorphic relationships where records don't share\n the same table and the `id` is not enough information.\n\n For example having a user that has many pets:\n\n ```js\n User = Model.extend({\n name: attr('string'),\n pets: hasMany('pet', { polymorphic: true })\n });\n\n Pet = Model.extend({\n name: attr('string'),\n });\n\n Cat = Pet.extend({\n // ...\n });\n\n Parrot = Pet.extend({\n // ...\n });\n ```\n\n ```app/serializers/user.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class UserSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n pets: { serialize: 'ids-and-types', deserialize: 'records' }\n }\n }\n ```\n\n ```js\n {\n \"user\": {\n \"id\": \"1\"\n \"name\": \"Bertin Osborne\",\n \"pets\": [\n { \"id\": \"1\", \"type\": \"Cat\" },\n { \"id\": \"1\", \"type\": \"Parrot\"}\n ]\n }\n }\n ```\n\n @method serializeHasMany\n @public\n @param {Snapshot} snapshot\n @param {Object} json\n @param {Object} relationship\n */\n serializeHasMany(snapshot, json, relationship) {\n let attr = relationship.key;\n if (this.noSerializeOptionSpecified(attr)) {\n this._super(snapshot, json, relationship);\n return;\n }\n\n if (this.hasSerializeIdsOption(attr)) {\n let schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.key, schema);\n if (serializedKey === relationship.key && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');\n }\n\n json[serializedKey] = snapshot.hasMany(attr, { ids: true });\n } else if (this.hasSerializeRecordsOption(attr)) {\n this._serializeEmbeddedHasMany(snapshot, json, relationship);\n } else {\n if (this.hasSerializeIdsAndTypesOption(attr)) {\n this._serializeHasManyAsIdsAndTypes(snapshot, json, relationship);\n }\n }\n },\n\n /*\n Serializes a hasMany relationship as an array of objects containing only `id` and `type`\n keys.\n This has its use case on polymorphic hasMany relationships where the server is not storing\n all records in the same table using STI, and therefore the `id` is not enough information\n\n TODO: Make the default in Ember-data 3.0??\n */\n _serializeHasManyAsIdsAndTypes(snapshot, json, relationship) {\n let serializedKey = this.keyForAttribute(relationship.key, 'serialize');\n let hasMany = snapshot.hasMany(relationship.key);\n\n json[serializedKey] = A(hasMany).map(function (recordSnapshot) {\n //\n // I'm sure I'm being utterly naive here. Probably id is a configurable property and\n // type too, and the modelName has to be normalized somehow.\n //\n return { id: recordSnapshot.id, type: recordSnapshot.modelName };\n });\n },\n\n _serializeEmbeddedHasMany(snapshot, json, relationship) {\n let schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.key, schema);\n if (serializedKey === relationship.key && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');\n }\n\n warn(\n `The embedded relationship '${serializedKey}' is undefined for '${snapshot.modelName}' with id '${snapshot.id}'. Please include it in your original payload.`,\n typeof snapshot.hasMany(relationship.key) !== 'undefined',\n { id: 'ds.serializer.embedded-relationship-undefined' }\n );\n\n json[serializedKey] = this._generateSerializedHasMany(snapshot, relationship);\n },\n\n /*\n Returns an array of embedded records serialized to JSON\n */\n _generateSerializedHasMany(snapshot, relationship) {\n let hasMany = snapshot.hasMany(relationship.key);\n let manyArray = A(hasMany);\n let ret = new Array(manyArray.length);\n\n for (let i = 0; i < manyArray.length; i++) {\n let embeddedSnapshot = manyArray[i];\n let embeddedJson = embeddedSnapshot.serialize({ includeId: true });\n this.removeEmbeddedForeignKey(snapshot, embeddedSnapshot, relationship, embeddedJson);\n ret[i] = embeddedJson;\n }\n\n return ret;\n },\n\n /**\n When serializing an embedded record, modify the property (in the `JSON` payload)\n that refers to the parent record (foreign key for the relationship).\n\n Serializing a `belongsTo` relationship removes the property that refers to the\n parent record\n\n Serializing a `hasMany` relationship does not remove the property that refers to\n the parent record.\n\n @method removeEmbeddedForeignKey\n @public\n @param {Snapshot} snapshot\n @param {Snapshot} embeddedSnapshot\n @param {Object} relationship\n @param {Object} json\n */\n removeEmbeddedForeignKey(snapshot, embeddedSnapshot, relationship, json) {\n if (relationship.kind === 'belongsTo') {\n let schema = this.store.modelFor(snapshot.modelName);\n let parentRecord = schema.inverseFor(relationship.key, this.store);\n if (parentRecord) {\n let name = parentRecord.name;\n let embeddedSerializer = this.store.serializerFor(embeddedSnapshot.modelName);\n let parentKey = embeddedSerializer.keyForRelationship(name, parentRecord.kind, 'deserialize');\n if (parentKey) {\n delete json[parentKey];\n }\n }\n } /*else if (relationship.kind === 'hasMany') {\n return;\n }*/\n },\n\n // checks config for attrs option to embedded (always) - serialize and deserialize\n hasEmbeddedAlwaysOption(attr) {\n let option = this.attrsOption(attr);\n return option && option.embedded === 'always';\n },\n\n // checks config for attrs option to serialize ids\n hasSerializeRecordsOption(attr) {\n let alwaysEmbed = this.hasEmbeddedAlwaysOption(attr);\n let option = this.attrsOption(attr);\n return alwaysEmbed || (option && option.serialize === 'records');\n },\n\n // checks config for attrs option to serialize records\n hasSerializeIdsOption(attr) {\n let option = this.attrsOption(attr);\n return option && (option.serialize === 'ids' || option.serialize === 'id');\n },\n\n // checks config for attrs option to serialize records as objects containing id and types\n hasSerializeIdsAndTypesOption(attr) {\n let option = this.attrsOption(attr);\n return option && (option.serialize === 'ids-and-types' || option.serialize === 'id-and-type');\n },\n\n // checks config for attrs option to serialize records\n noSerializeOptionSpecified(attr) {\n let option = this.attrsOption(attr);\n return !(option && (option.serialize || option.embedded));\n },\n\n // checks config for attrs option to deserialize records\n // a defined option object for a resource is treated the same as\n // `deserialize: 'records'`\n hasDeserializeRecordsOption(attr) {\n let alwaysEmbed = this.hasEmbeddedAlwaysOption(attr);\n let option = this.attrsOption(attr);\n return alwaysEmbed || (option && option.deserialize === 'records');\n },\n\n attrsOption(attr) {\n let attrs = this.attrs;\n return attrs && (attrs[camelize(attr)] || attrs[attr]);\n },\n\n /**\n @method _extractEmbeddedRecords\n @private\n */\n _extractEmbeddedRecords(serializer, store, typeClass, partial) {\n typeClass.eachRelationship((key, relationship) => {\n if (serializer.hasDeserializeRecordsOption(key)) {\n if (relationship.kind === 'hasMany') {\n this._extractEmbeddedHasMany(store, key, partial, relationship);\n }\n if (relationship.kind === 'belongsTo') {\n this._extractEmbeddedBelongsTo(store, key, partial, relationship);\n }\n }\n });\n return partial;\n },\n\n /**\n @method _extractEmbeddedHasMany\n @private\n */\n _extractEmbeddedHasMany(store, key, hash, relationshipMeta) {\n let relationshipHash = hash.data?.relationships?.[key]?.data;\n\n if (!relationshipHash) {\n return;\n }\n\n let hasMany = new Array(relationshipHash.length);\n\n for (let i = 0; i < relationshipHash.length; i++) {\n let item = relationshipHash[i];\n let { data, included } = this._normalizeEmbeddedRelationship(store, relationshipMeta, item);\n hash.included = hash.included || [];\n hash.included.push(data);\n if (included) {\n hash.included = hash.included.concat(included);\n }\n\n hasMany[i] = { id: data.id, type: data.type };\n }\n\n let relationship = { data: hasMany };\n hash.data.relationships[key] = relationship;\n },\n\n /**\n @method _extractEmbeddedBelongsTo\n @private\n */\n _extractEmbeddedBelongsTo(store, key, hash, relationshipMeta) {\n let relationshipHash = hash.data?.relationships?.[key]?.data;\n if (!relationshipHash) {\n return;\n }\n\n let { data, included } = this._normalizeEmbeddedRelationship(store, relationshipMeta, relationshipHash);\n hash.included = hash.included || [];\n hash.included.push(data);\n if (included) {\n hash.included = hash.included.concat(included);\n }\n\n let belongsTo = { id: data.id, type: data.type };\n let relationship = { data: belongsTo };\n\n hash.data.relationships[key] = relationship;\n },\n\n /**\n @method _normalizeEmbeddedRelationship\n @private\n */\n _normalizeEmbeddedRelationship(store, relationshipMeta, relationshipHash) {\n let modelName = relationshipMeta.type;\n if (relationshipMeta.options.polymorphic) {\n modelName = relationshipHash.type;\n }\n let modelClass = store.modelFor(modelName);\n let serializer = store.serializerFor(modelName);\n\n return serializer.normalize(modelClass, relationshipHash, null);\n },\n isEmbeddedRecordsMixin: true,\n});\n"],"names":["Mixin","create","normalize","typeClass","hash","prop","normalizedHash","_super","_extractEmbeddedRecords","store","keyForRelationship","key","method","hasSerializeRecordsOption","hasDeserializeRecordsOption","keyForAttribute","serializeBelongsTo","snapshot","json","relationship","attr","noSerializeOptionSpecified","includeIds","hasSerializeIdsOption","includeRecords","embeddedSnapshot","belongsTo","schema","modelFor","modelName","serializedKey","_getMappedKey","kind","id","options","polymorphic","serializePolymorphicType","_serializeEmbeddedBelongsTo","serialize","includeId","removeEmbeddedForeignKey","serializeHasMany","hasMany","ids","_serializeEmbeddedHasMany","hasSerializeIdsAndTypesOption","_serializeHasManyAsIdsAndTypes","A","map","recordSnapshot","type","warn","_generateSerializedHasMany","manyArray","ret","Array","length","i","embeddedJson","parentRecord","inverseFor","name","embeddedSerializer","serializerFor","parentKey","hasEmbeddedAlwaysOption","option","attrsOption","embedded","alwaysEmbed","deserialize","attrs","camelize","serializer","partial","eachRelationship","_extractEmbeddedHasMany","_extractEmbeddedBelongsTo","relationshipMeta","relationshipHash","data","relationships","item","included","_normalizeEmbeddedRelationship","push","concat","modelClass","isEmbeddedRecordsMixin"],"mappings":";;;;;AAKA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAAeA,KAAK,CAACC,MAAM,CAAC;AAC1B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGEC,EAAAA,SAASA,CAACC,SAAS,EAAEC,IAAI,EAAEC,IAAI,EAAE;IAC/B,IAAIC,cAAc,GAAG,IAAI,CAACC,MAAM,CAACJ,SAAS,EAAEC,IAAI,EAAEC,IAAI,CAAC,CAAA;AACvD,IAAA,OAAO,IAAI,CAACG,uBAAuB,CAAC,IAAI,EAAE,IAAI,CAACC,KAAK,EAAEN,SAAS,EAAEG,cAAc,CAAC,CAAA;GACjF;AAEDI,EAAAA,kBAAkBA,CAACC,GAAG,EAAER,SAAS,EAAES,MAAM,EAAE;IACzC,IACGA,MAAM,KAAK,WAAW,IAAI,IAAI,CAACC,yBAAyB,CAACF,GAAG,CAAC,IAC7DC,MAAM,KAAK,aAAa,IAAI,IAAI,CAACE,2BAA2B,CAACH,GAAG,CAAE,EACnE;AACA,MAAA,OAAO,IAAI,CAACI,eAAe,CAACJ,GAAG,EAAEC,MAAM,CAAC,CAAA;AAC1C,KAAC,MAAM;MACL,OAAO,IAAI,CAACL,MAAM,CAACI,GAAG,EAAER,SAAS,EAAES,MAAM,CAAC,IAAID,GAAG,CAAA;AACnD,KAAA;GACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAWEK,EAAAA,kBAAkBA,CAACC,QAAQ,EAAEC,IAAI,EAAEC,YAAY,EAAE;AAC/C,IAAA,IAAI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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA2BEsB,EAAAA,gBAAgBA,CAACxB,QAAQ,EAAEC,IAAI,EAAEC,YAAY,EAAE;AAC7C,IAAA,IAAIC,IAAI,GAAGD,YAAY,CAACR,GAAG,CAAA;AAC3B,IAAA,IAAI,IAAI,CAACU,0BAA0B,CAACD,IAAI,CAAC,EAAE;MACzC,IAAI,CAACb,MAAM,CAACU,QAAQ,EAAEC,IAAI,EAAEC,YAAY,CAAC,CAAA;AACzC,MAAA,OAAA;AACF,KAAA;AAEA,IAAA,IAAI,IAAI,CAACI,qBAAqB,CAACH,IAAI,CAAC,EAAE;MACpC,IAAIO,MAAM,GAAG,IAAI,CAAClB,KAAK,CAACmB,QAAQ,CAACX,QAAQ,CAACY,SAAS,CAAC,CAAA;MACpD,IAAIC,aAAa,GAAG,IAAI,CAACC,aAAa,CAACZ,YAAY,CAACR,GAAG,EAAEgB,MAAM,CAAC,CAAA;MAChE,IAAIG,aAAa,KAAKX,YAAY,CAACR,GAAG,IAAI,IAAI,CAACD,kBAAkB,EAAE;AACjEoB,QAAAA,aAAa,GAAG,IAAI,CAACpB,kBAAkB,CAACS,YAAY,CAACR,GAAG,EAAEQ,YAAY,CAACa,IAAI,EA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4C,UAAU,GAAGhE,KAAK,CAACsD,aAAa,CAAClC,SAAS,CAAC,CAAA;IAE/C,OAAO4C,UAAU,CAACvE,SAAS,CAACqF,UAAU,EAAER,gBAAgB,EAAE,IAAI,CAAC,CAAA;GAChE;AACDS,EAAAA,sBAAsB,EAAE,IAAA;AAC1B,CAAC,CAAC;;;;"}
|
package/addon/index.js
CHANGED
|
@@ -34,7 +34,10 @@ function _applyDecoratedDescriptor(target, property, decorators, descriptor, con
|
|
|
34
34
|
}
|
|
35
35
|
var _class2, _descriptor;
|
|
36
36
|
/**
|
|
37
|
-
|
|
37
|
+
> ⚠️ CAUTION you likely want the docs for [<Interface> Serializer](/ember-data/release/classes/%3CInterface%3E%20Serializer)
|
|
38
|
+
> as extending this abstract class is unnecessary.
|
|
39
|
+
|
|
40
|
+
`Serializer` is an abstract base class that you may override in your
|
|
38
41
|
application to customize it for your backend. The minimum set of methods
|
|
39
42
|
that you should implement is:
|
|
40
43
|
|
package/addon/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../node_modules/.pnpm/@babel+runtime@7.21.0/node_modules/@babel/runtime/helpers/esm/initializerDefineProperty.js","../../../node_modules/.pnpm/@babel+runtime@7.21.0/node_modules/@babel/runtime/helpers/esm/applyDecoratedDescriptor.js","../src/index.ts"],"sourcesContent":["export default function _initializerDefineProperty(target, property, descriptor, context) {\n if (!descriptor) return;\n Object.defineProperty(target, property, {\n enumerable: descriptor.enumerable,\n configurable: descriptor.configurable,\n writable: descriptor.writable,\n value: descriptor.initializer ? descriptor.initializer.call(context) : void 0\n });\n}","export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {\n var desc = {};\n Object.keys(descriptor).forEach(function (key) {\n desc[key] = descriptor[key];\n });\n desc.enumerable = !!desc.enumerable;\n desc.configurable = !!desc.configurable;\n if ('value' in desc || desc.initializer) {\n desc.writable = true;\n }\n desc = decorators.slice().reverse().reduce(function (desc, decorator) {\n return decorator(target, property, desc) || desc;\n }, desc);\n if (context && desc.initializer !== void 0) {\n desc.value = desc.initializer ? desc.initializer.call(context) : void 0;\n desc.initializer = undefined;\n }\n if (desc.initializer === void 0) {\n Object.defineProperty(target, property, desc);\n desc = null;\n }\n return desc;\n}","/**\n ## Overview\n\n In order to properly manage and present your data, EmberData\n needs to understand the structure of data it receives.\n\n `Serializers` convert data between the server's API format and\n the format EmberData understands.\n\n Data received from an API response is **normalized** into\n [JSON:API](https://jsonapi.org/) (the format used internally\n by EmberData), while data sent to an API is **serialized**\n into the format the API expects.\n\n ### Implementing a Serializer\n\n There are only two required serializer methods, one for\n normalizing data from the server API format into JSON:API, and\n another for serializing records via `Snapshots` into the expected\n server API format.\n\n To implement a serializer, export a class that conforms to the structure\n described by the [MinimumSerializerInterface](/ember-data/release/classes/MinimumSerializerInterface)\n from the `app/serializers/` directory. An example is below.\n\n ```ts\n import EmberObject from '@ember/object';\n\n export default class ApplicationSerializer extends EmberObject {\n normalizeResponse(store, schema, rawPayload) {\n return rawPayload;\n }\n\n serialize(snapshot, options) {\n const serializedResource = {\n id: snapshot.id,\n type: snapshot.modelName,\n attributes: snapshot.attributes()\n };\n\n return serializedResource;\n }\n }\n ```\n\n\n ### Serializer Resolution\n\n `store.serializerFor(name)` will lookup serializers defined in\n `app/serializers/` and return an instance. If no serializer is found, an\n error will be thrown.\n\n `serializerFor` first attempts to find a serializer with an exact match on `name`,\n then falls back to checking for the presence of a serializer named `application`.\n\n ```ts\n store.serializerFor('author');\n\n // lookup paths (in order) =>\n // app/serializers/author.js\n // app/serializers/application.js\n ```\n\n Most requests in EmberData are made with respect to a particular `type` (or `modelName`)\n (e.g., \"get me the full collection of **books**\" or \"get me the **employee** whose id is 37\"). We\n refer to this as the **primary** resource `type`.\n\n Typically `serializerFor` will be used to find a serializer with a name matching that of the primary\n resource `type` for the request, falling back to the `application` serializer for those types that\n do not have a defined serializer. This is often described as a `per-model` or `per-type` strategy\n for defining serializers. However, because APIs rarely format payloads per-type but rather\n per-API-version, this may not be a desired strategy.\n\n It is recommended that applications define only a single `application` adapter and serializer\n where possible.\n\n If you have multiple API formats and the per-type strategy is not viable, one strategy is to\n write an `application` adapter and serializer that make use of `options` to specify the desired\n format when making a request.\n\n ### Using a Serializer\n\n Any serializer in `app/serializers/` can be looked up by `name` using `store.serializerFor(name)`.\n\n ### Default Serializers\n\n For applications whose APIs are *very close to* or *exactly* the **REST** format or **JSON:API**\n format the `@ember-data/serializer` package contains implementations these applications can\n extend. It also contains a simple `JSONSerializer` for serializing to/from very basic JSON objects.\n\n Many applications will find writing their own serializer to be more performant and less\n complex than extending these classes even when their API format is very close to that expected\n by these serializers.\n\n It is recommended that apps write their own serializer to best suit the needs of their API and\n application.\n\n @module @ember-data/serializer\n @main @ember-data/serializer\n*/\n\nimport EmberObject from '@ember/object';\nimport { inject as service } from '@ember/service';\n\nimport type Store from '@ember-data/store';\n\n/**\n `Serializer` is an abstract base class that you should override in your\n application to customize it for your backend. The minimum set of methods\n that you should implement is:\n\n * `normalizeResponse()`\n * `serialize()`\n\n And you can optionally override the following methods:\n\n * `normalize()`\n\n For an example implementation, see\n [JSONSerializer](JSONSerializer), the included JSON serializer.\n\n @class Serializer\n @public\n @extends Ember.EmberObject\n*/\n\nexport default class extends EmberObject {\n @service declare store: Store;\n /**\n The `store` property is the application's `store` that contains\n all records. It can be used to look up serializers for other model\n types that may be nested inside the payload response.\n\n Example:\n\n ```js\n Serializer.extend({\n extractRelationship(relationshipModelName, relationshipHash) {\n let modelClass = this.store.modelFor(relationshipModelName);\n let relationshipSerializer = this.store.serializerFor(relationshipModelName);\n return relationshipSerializer.normalize(modelClass, relationshipHash);\n }\n });\n ```\n\n @property store\n @type {Store}\n @public\n */\n\n /**\n The `normalizeResponse` method is used to normalize a payload from the\n server to a JSON-API Document.\n\n http://jsonapi.org/format/#document-structure\n\n Example:\n\n ```js\n Serializer.extend({\n normalizeResponse(store, primaryModelClass, payload, id, requestType) {\n if (requestType === 'findRecord') {\n return this.normalize(primaryModelClass, payload);\n } else {\n return payload.reduce(function(documentHash, item) {\n let { data, included } = this.normalize(primaryModelClass, item);\n documentHash.included.push(...included);\n documentHash.data.push(data);\n return documentHash;\n }, { data: [], included: [] })\n }\n }\n });\n ```\n\n @since 1.13.0\n @method normalizeResponse\n @public\n @param {Store} store\n @param {Model} primaryModelClass\n @param {Object} payload\n @param {String|Number} id\n @param {String} requestType\n @return {Object} JSON-API Document\n */\n\n /**\n The `serialize` method is used when a record is saved in order to convert\n the record into the form that your external data source expects.\n\n `serialize` takes an optional `options` hash with a single option:\n\n - `includeId`: If this is `true`, `serialize` should include the ID\n in the serialized object it builds.\n\n Example:\n\n ```js\n Serializer.extend({\n serialize(snapshot, options) {\n let json = {\n id: snapshot.id\n };\n\n snapshot.eachAttribute((key, attribute) => {\n json[key] = snapshot.attr(key);\n });\n\n snapshot.eachRelationship((key, relationship) => {\n if (relationship.kind === 'belongsTo') {\n json[key] = snapshot.belongsTo(key, { id: true });\n } else if (relationship.kind === 'hasMany') {\n json[key] = snapshot.hasMany(key, { ids: true });\n }\n });\n\n return json;\n },\n });\n ```\n\n @method serialize\n @public\n @param {Snapshot} snapshot\n @param {Object} [options]\n @return {Object}\n */\n\n /**\n The `normalize` method is used to convert a payload received from your\n external data source into the normalized form `store.push()` expects. You\n should override this method, munge the hash and return the normalized\n payload.\n\n Example:\n\n ```js\n Serializer.extend({\n normalize(modelClass, resourceHash) {\n let data = {\n id: resourceHash.id,\n type: modelClass.modelName,\n attributes: resourceHash\n };\n return { data: data };\n }\n })\n ```\n\n @method normalize\n @public\n @param {Model} typeClass\n @param {Object} hash\n @return {Object}\n */\n normalize(typeClass, hash) {\n return hash;\n }\n}\n"],"names":["_initializerDefineProperty","target","property","descriptor","context","Object","defineProperty","enumerable","configurable","writable","value","initializer","call","_applyDecoratedDescriptor","decorators","desc","keys","forEach","key","slice","reverse","reduce","decorator","undefined","_class","_class2","EmberObject","constructor","args","_descriptor","normalize","typeClass","hash","prototype","service"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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIEC,EAAAA,SAASA,CAACC,SAAS,EAAEC,IAAI,EAAE;AACzB,IAAA,OAAOA,IAAI,CAAA;AACb,GAAA;AACF,CAAC,GAAAH,WAAA,GAAAhB,yBAAA,CAAAY,OAAA,CAAAQ,SAAA,EAAA,OAAA,EAAA,CAnIEC,MAAO,CAAA,EAAA;EAAA1B,YAAA,EAAA,IAAA;EAAAD,UAAA,EAAA,IAAA;EAAAE,QAAA,EAAA,IAAA;EAAAE,WAAA,EAAA,IAAA;AAAA,CAAA,CAAA,GAAAc,OAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../node_modules/.pnpm/@babel+runtime@7.21.0/node_modules/@babel/runtime/helpers/esm/initializerDefineProperty.js","../../../node_modules/.pnpm/@babel+runtime@7.21.0/node_modules/@babel/runtime/helpers/esm/applyDecoratedDescriptor.js","../src/index.ts"],"sourcesContent":["export default function _initializerDefineProperty(target, property, descriptor, context) {\n if (!descriptor) return;\n Object.defineProperty(target, property, {\n enumerable: descriptor.enumerable,\n configurable: descriptor.configurable,\n writable: descriptor.writable,\n value: descriptor.initializer ? descriptor.initializer.call(context) : void 0\n });\n}","export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {\n var desc = {};\n Object.keys(descriptor).forEach(function (key) {\n desc[key] = descriptor[key];\n });\n desc.enumerable = !!desc.enumerable;\n desc.configurable = !!desc.configurable;\n if ('value' in desc || desc.initializer) {\n desc.writable = true;\n }\n desc = decorators.slice().reverse().reduce(function (desc, decorator) {\n return decorator(target, property, desc) || desc;\n }, desc);\n if (context && desc.initializer !== void 0) {\n desc.value = desc.initializer ? desc.initializer.call(context) : void 0;\n desc.initializer = undefined;\n }\n if (desc.initializer === void 0) {\n Object.defineProperty(target, property, desc);\n desc = null;\n }\n return desc;\n}","/**\n ## Overview\n\n In order to properly manage and present your data, EmberData\n needs to understand the structure of data it receives.\n\n `Serializers` convert data between the server's API format and\n the format EmberData understands.\n\n Data received from an API response is **normalized** into\n [JSON:API](https://jsonapi.org/) (the format used internally\n by EmberData), while data sent to an API is **serialized**\n into the format the API expects.\n\n ### Implementing a Serializer\n\n There are only two required serializer methods, one for\n normalizing data from the server API format into JSON:API, and\n another for serializing records via `Snapshots` into the expected\n server API format.\n\n To implement a serializer, export a class that conforms to the structure\n described by [<Interface> Serializer](/ember-data/release/classes/%3CInterface%3E%20Serializer)\n from the `app/serializers/` directory. An example is below.\n\n ```ts\n import EmberObject from '@ember/object';\n\n export default class ApplicationSerializer extends EmberObject {\n normalizeResponse(store, schema, rawPayload) {\n return rawPayload;\n }\n\n serialize(snapshot, options) {\n const serializedResource = {\n id: snapshot.id,\n type: snapshot.modelName,\n attributes: snapshot.attributes()\n };\n\n return serializedResource;\n }\n }\n ```\n\n\n ### Serializer Resolution\n\n `store.serializerFor(name)` will lookup serializers defined in\n `app/serializers/` and return an instance. If no serializer is found, an\n error will be thrown.\n\n `serializerFor` first attempts to find a serializer with an exact match on `name`,\n then falls back to checking for the presence of a serializer named `application`.\n\n ```ts\n store.serializerFor('author');\n\n // lookup paths (in order) =>\n // app/serializers/author.js\n // app/serializers/application.js\n ```\n\n Most requests in EmberData are made with respect to a particular `type` (or `modelName`)\n (e.g., \"get me the full collection of **books**\" or \"get me the **employee** whose id is 37\"). We\n refer to this as the **primary** resource `type`.\n\n Typically `serializerFor` will be used to find a serializer with a name matching that of the primary\n resource `type` for the request, falling back to the `application` serializer for those types that\n do not have a defined serializer. This is often described as a `per-model` or `per-type` strategy\n for defining serializers. However, because APIs rarely format payloads per-type but rather\n per-API-version, this may not be a desired strategy.\n\n It is recommended that applications define only a single `application` adapter and serializer\n where possible.\n\n If you have multiple API formats and the per-type strategy is not viable, one strategy is to\n write an `application` adapter and serializer that make use of `options` to specify the desired\n format when making a request.\n\n ### Using a Serializer\n\n Any serializer in `app/serializers/` can be looked up by `name` using `store.serializerFor(name)`.\n\n ### Default Serializers\n\n For applications whose APIs are *very close to* or *exactly* the **REST** format or **JSON:API**\n format the `@ember-data/serializer` package contains implementations these applications can\n extend. It also contains a simple `JSONSerializer` for serializing to/from very basic JSON objects.\n\n Many applications will find writing their own serializer to be more performant and less\n complex than extending these classes even when their API format is very close to that expected\n by these serializers.\n\n It is recommended that apps write their own serializer to best suit the needs of their API and\n application.\n\n @module @ember-data/serializer\n @main @ember-data/serializer\n*/\n\nimport EmberObject from '@ember/object';\nimport { inject as service } from '@ember/service';\n\nimport type Store from '@ember-data/store';\n\n/**\n > ⚠️ CAUTION you likely want the docs for [<Interface> Serializer](/ember-data/release/classes/%3CInterface%3E%20Serializer)\n > as extending this abstract class is unnecessary.\n\n `Serializer` is an abstract base class that you may override in your\n application to customize it for your backend. The minimum set of methods\n that you should implement is:\n\n * `normalizeResponse()`\n * `serialize()`\n\n And you can optionally override the following methods:\n\n * `normalize()`\n\n For an example implementation, see\n [JSONSerializer](JSONSerializer), the included JSON serializer.\n\n @class Serializer\n @public\n @extends Ember.EmberObject\n*/\n\nexport default class extends EmberObject {\n @service declare store: Store;\n /**\n The `store` property is the application's `store` that contains\n all records. It can be used to look up serializers for other model\n types that may be nested inside the payload response.\n\n Example:\n\n ```js\n Serializer.extend({\n extractRelationship(relationshipModelName, relationshipHash) {\n let modelClass = this.store.modelFor(relationshipModelName);\n let relationshipSerializer = this.store.serializerFor(relationshipModelName);\n return relationshipSerializer.normalize(modelClass, relationshipHash);\n }\n });\n ```\n\n @property store\n @type {Store}\n @public\n */\n\n /**\n The `normalizeResponse` method is used to normalize a payload from the\n server to a JSON-API Document.\n\n http://jsonapi.org/format/#document-structure\n\n Example:\n\n ```js\n Serializer.extend({\n normalizeResponse(store, primaryModelClass, payload, id, requestType) {\n if (requestType === 'findRecord') {\n return this.normalize(primaryModelClass, payload);\n } else {\n return payload.reduce(function(documentHash, item) {\n let { data, included } = this.normalize(primaryModelClass, item);\n documentHash.included.push(...included);\n documentHash.data.push(data);\n return documentHash;\n }, { data: [], included: [] })\n }\n }\n });\n ```\n\n @since 1.13.0\n @method normalizeResponse\n @public\n @param {Store} store\n @param {Model} primaryModelClass\n @param {Object} payload\n @param {String|Number} id\n @param {String} requestType\n @return {Object} JSON-API Document\n */\n\n /**\n The `serialize` method is used when a record is saved in order to convert\n the record into the form that your external data source expects.\n\n `serialize` takes an optional `options` hash with a single option:\n\n - `includeId`: If this is `true`, `serialize` should include the ID\n in the serialized object it builds.\n\n Example:\n\n ```js\n Serializer.extend({\n serialize(snapshot, options) {\n let json = {\n id: snapshot.id\n };\n\n snapshot.eachAttribute((key, attribute) => {\n json[key] = snapshot.attr(key);\n });\n\n snapshot.eachRelationship((key, relationship) => {\n if (relationship.kind === 'belongsTo') {\n json[key] = snapshot.belongsTo(key, { id: true });\n } else if (relationship.kind === 'hasMany') {\n json[key] = snapshot.hasMany(key, { ids: true });\n }\n });\n\n return json;\n },\n });\n ```\n\n @method serialize\n @public\n @param {Snapshot} snapshot\n @param {Object} [options]\n @return {Object}\n */\n\n /**\n The `normalize` method is used to convert a payload received from your\n external data source into the normalized form `store.push()` expects. You\n should override this method, munge the hash and return the normalized\n payload.\n\n Example:\n\n ```js\n Serializer.extend({\n normalize(modelClass, resourceHash) {\n let data = {\n id: resourceHash.id,\n type: modelClass.modelName,\n attributes: resourceHash\n };\n return { data: data };\n }\n })\n ```\n\n @method normalize\n @public\n @param {Model} typeClass\n @param {Object} hash\n @return {Object}\n */\n normalize(typeClass, hash) {\n return hash;\n }\n}\n"],"names":["_initializerDefineProperty","target","property","descriptor","context","Object","defineProperty","enumerable","configurable","writable","value","initializer","call","_applyDecoratedDescriptor","decorators","desc","keys","forEach","key","slice","reverse","reduce","decorator","undefined","_class","_class2","EmberObject","constructor","args","_descriptor","normalize","typeClass","hash","prototype","service"],"mappings":";;;A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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIEC,EAAAA,SAASA,CAACC,SAAS,EAAEC,IAAI,EAAE;AACzB,IAAA,OAAOA,IAAI,CAAA;AACb,GAAA;AACF,CAAC,GAAAH,WAAA,GAAAhB,yBAAA,CAAAY,OAAA,CAAAQ,SAAA,EAAA,OAAA,EAAA,CAnIEC,MAAO,CAAA,EAAA;EAAA1B,YAAA,EAAA,IAAA;EAAAD,UAAA,EAAA,IAAA;EAAAE,QAAA,EAAA,IAAA;EAAAE,WAAA,EAAA,IAAA;AAAA,CAAA,CAAA,GAAAc,OAAA;;;;","x_google_ignoreList":[0,1]}
|
package/addon/json-api.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { macroCondition,
|
|
1
|
+
import { macroCondition, getOwnConfig } from '@embroider/macros';
|
|
2
2
|
import { assert, warn } from '@ember/debug';
|
|
3
3
|
import { dasherize } from '@ember/string';
|
|
4
|
-
import { typeOf, isNone } from '@ember/utils';
|
|
5
4
|
import { singularize, pluralize } from 'ember-inflector';
|
|
6
5
|
import JSONSerializer from "./json";
|
|
7
6
|
|
|
@@ -132,15 +131,15 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
132
131
|
@private
|
|
133
132
|
*/
|
|
134
133
|
_normalizeDocumentHelper(documentHash) {
|
|
135
|
-
if (
|
|
136
|
-
documentHash.data = this._normalizeResourceHelper(documentHash.data);
|
|
137
|
-
} else if (Array.isArray(documentHash.data)) {
|
|
134
|
+
if (Array.isArray(documentHash.data)) {
|
|
138
135
|
let ret = new Array(documentHash.data.length);
|
|
139
136
|
for (let i = 0; i < documentHash.data.length; i++) {
|
|
140
137
|
let data = documentHash.data[i];
|
|
141
138
|
ret[i] = this._normalizeResourceHelper(data);
|
|
142
139
|
}
|
|
143
140
|
documentHash.data = ret;
|
|
141
|
+
} else if (documentHash.data && typeof documentHash.data === 'object') {
|
|
142
|
+
documentHash.data = this._normalizeResourceHelper(documentHash.data);
|
|
144
143
|
}
|
|
145
144
|
if (Array.isArray(documentHash.included)) {
|
|
146
145
|
let ret = new Array();
|
|
@@ -173,7 +172,7 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
173
172
|
@private
|
|
174
173
|
*/
|
|
175
174
|
_normalizeResourceHelper(resourceHash) {
|
|
176
|
-
assert(this.warnMessageForUndefinedType(),
|
|
175
|
+
assert(this.warnMessageForUndefinedType(), resourceHash.type);
|
|
177
176
|
let modelName, usedLookup;
|
|
178
177
|
modelName = this.modelNameFromPayloadKey(resourceHash.type);
|
|
179
178
|
usedLookup = 'modelNameFromPayloadKey';
|
|
@@ -229,7 +228,7 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
229
228
|
if (resourceHash.attributes[attributeKey] !== undefined) {
|
|
230
229
|
attributes[key] = resourceHash.attributes[attributeKey];
|
|
231
230
|
}
|
|
232
|
-
if (macroCondition(
|
|
231
|
+
if (macroCondition(getOwnConfig().env.DEBUG)) {
|
|
233
232
|
if (resourceHash.attributes[attributeKey] === undefined && resourceHash.attributes[key] !== undefined) {
|
|
234
233
|
assert(`Your payload for '${modelClass.modelName}' contains '${key}', but your serializer is setup to look for '${attributeKey}'. This is most likely because Ember Data's JSON API serializer dasherizes attribute keys by default. You should subclass JSONAPISerializer and implement 'keyForAttribute(key) { return key; }' to prevent Ember Data from customizing your attribute keys.`, false);
|
|
235
234
|
}
|
|
@@ -247,9 +246,6 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
247
246
|
@return {Object}
|
|
248
247
|
*/
|
|
249
248
|
extractRelationship(relationshipHash) {
|
|
250
|
-
if (typeOf(relationshipHash.data) === 'object') {
|
|
251
|
-
relationshipHash.data = this._normalizeRelationshipDataHelper(relationshipHash.data);
|
|
252
|
-
}
|
|
253
249
|
if (Array.isArray(relationshipHash.data)) {
|
|
254
250
|
let ret = new Array(relationshipHash.data.length);
|
|
255
251
|
for (let i = 0; i < relationshipHash.data.length; i++) {
|
|
@@ -257,6 +253,8 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
257
253
|
ret[i] = this._normalizeRelationshipDataHelper(data);
|
|
258
254
|
}
|
|
259
255
|
relationshipHash.data = ret;
|
|
256
|
+
} else if (relationshipHash.data && typeof relationshipHash.data === 'object') {
|
|
257
|
+
relationshipHash.data = this._normalizeRelationshipDataHelper(relationshipHash.data);
|
|
260
258
|
}
|
|
261
259
|
return relationshipHash;
|
|
262
260
|
},
|
|
@@ -278,7 +276,7 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
278
276
|
let relationshipHash = resourceHash.relationships[relationshipKey];
|
|
279
277
|
relationships[key] = this.extractRelationship(relationshipHash);
|
|
280
278
|
}
|
|
281
|
-
if (macroCondition(
|
|
279
|
+
if (macroCondition(getOwnConfig().env.DEBUG)) {
|
|
282
280
|
if (resourceHash.relationships[relationshipKey] === undefined && resourceHash.relationships[key] !== undefined) {
|
|
283
281
|
assert(`Your payload for '${modelClass.modelName}' contains '${key}', but your serializer is setup to look for '${relationshipKey}'. This is most likely because Ember Data's JSON API serializer dasherizes relationship keys by default. You should subclass JSONAPISerializer and implement 'keyForRelationship(key) { return key; }' to prevent Ember Data from customizing your relationship keys.`, false);
|
|
284
282
|
}
|
|
@@ -604,7 +602,7 @@ const JSONAPISerializer = JSONSerializer.extend({
|
|
|
604
602
|
}
|
|
605
603
|
}
|
|
606
604
|
});
|
|
607
|
-
if (macroCondition(
|
|
605
|
+
if (macroCondition(getOwnConfig().env.DEBUG)) {
|
|
608
606
|
JSONAPISerializer.reopen({
|
|
609
607
|
init(...args) {
|
|
610
608
|
this._super(...args);
|