@ember-data-mirror/serializer 5.6.0-alpha.3 → 5.6.0-alpha.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/dist/index.js +5 -10
- package/dist/index.js.map +1 -1
- package/dist/{json-CVTR4xWv.js → json-CYP2BhR9.js} +42 -89
- package/dist/json-CYP2BhR9.js.map +1 -0
- package/dist/json-api.js +14 -31
- package/dist/json-api.js.map +1 -1
- package/dist/json.js +1 -1
- package/dist/rest.js +30 -59
- package/dist/rest.js.map +1 -1
- package/dist/transform.js +9 -32
- package/dist/transform.js.map +1 -1
- package/package.json +13 -16
- package/unstable-preview-types/-private/embedded-records-mixin.d.ts +1 -4
- package/unstable-preview-types/-private/embedded-records-mixin.d.ts.map +1 -1
- package/unstable-preview-types/-private/transforms/boolean.d.ts +2 -5
- package/unstable-preview-types/-private/transforms/boolean.d.ts.map +1 -1
- package/unstable-preview-types/-private/transforms/date.d.ts +1 -4
- package/unstable-preview-types/-private/transforms/date.d.ts.map +1 -1
- package/unstable-preview-types/-private/transforms/number.d.ts +1 -4
- package/unstable-preview-types/-private/transforms/number.d.ts.map +1 -1
- package/unstable-preview-types/-private/transforms/string.d.ts +1 -4
- package/unstable-preview-types/-private/transforms/string.d.ts.map +1 -1
- package/unstable-preview-types/-private/transforms/transform.d.ts +4 -9
- package/unstable-preview-types/-private/transforms/transform.d.ts.map +1 -1
- package/unstable-preview-types/index.d.ts +7 -12
- package/unstable-preview-types/index.d.ts.map +1 -1
- package/unstable-preview-types/json-api.d.ts +9 -24
- package/unstable-preview-types/json-api.d.ts.map +1 -1
- package/unstable-preview-types/json.d.ts +19 -62
- package/unstable-preview-types/json.d.ts.map +1 -1
- package/unstable-preview-types/rest.d.ts +11 -24
- package/unstable-preview-types/rest.d.ts.map +1 -1
- package/unstable-preview-types/transform.d.ts +0 -3
- package/unstable-preview-types/transform.d.ts.map +1 -1
- package/dist/json-CVTR4xWv.js.map +0 -1
package/dist/rest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest.js","sources":["../src/-private/embedded-records-mixin.js","../src/rest.js"],"sourcesContent":["import { warn } from '@ember/debug';\nimport Mixin from '@ember/object/mixin';\n\nimport { camelize } from '@ember-data-mirror/request-utils/string';\n\n/**\n @module @ember-data-mirror/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-mirror/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 const EmbeddedRecordsMixin = 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 const 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-mirror/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-mirror/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 const attr = relationship.name;\n if (this.noSerializeOptionSpecified(attr)) {\n this._super(snapshot, json, relationship);\n return;\n }\n const includeIds = this.hasSerializeIdsOption(attr);\n const includeRecords = this.hasSerializeRecordsOption(attr);\n const embeddedSnapshot = snapshot.belongsTo(attr);\n if (includeIds) {\n const schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.name, schema);\n if (serializedKey === relationship.name && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.name, 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 const embeddedSnapshot = snapshot.belongsTo(relationship.name);\n const schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.name, schema);\n if (serializedKey === relationship.name && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.name, 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-mirror/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-mirror/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-mirror/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-mirror/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 const attr = relationship.name;\n if (this.noSerializeOptionSpecified(attr)) {\n this._super(snapshot, json, relationship);\n return;\n }\n\n if (this.hasSerializeIdsOption(attr)) {\n const schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.name, schema);\n if (serializedKey === relationship.name && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.name, 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 const serializedKey = this.keyForAttribute(relationship.name, 'serialize');\n const hasMany = snapshot.hasMany(relationship.name) || [];\n\n json[serializedKey] = 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 const schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.name, schema);\n if (serializedKey === relationship.name && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.name, 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.name) !== '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 const hasMany = snapshot.hasMany(relationship.name) || [];\n const ret = new Array(hasMany.length);\n\n for (let i = 0; i < hasMany.length; i++) {\n const embeddedSnapshot = hasMany[i];\n const 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 const schema = this.store.modelFor(snapshot.modelName);\n const parentRecord = schema.inverseFor(relationship.name, this.store);\n if (parentRecord) {\n const name = parentRecord.name;\n const embeddedSerializer = this.store.serializerFor(embeddedSnapshot.modelName);\n const 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 const 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 const alwaysEmbed = this.hasEmbeddedAlwaysOption(attr);\n const 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 const 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 const 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 const 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 const alwaysEmbed = this.hasEmbeddedAlwaysOption(attr);\n const option = this.attrsOption(attr);\n return alwaysEmbed || (option && option.deserialize === 'records');\n },\n\n attrsOption(attr) {\n const 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 const relationshipHash = hash.data?.relationships?.[key]?.data;\n\n if (!relationshipHash) {\n return;\n }\n\n const hasMany = new Array(relationshipHash.length);\n\n for (let i = 0; i < relationshipHash.length; i++) {\n const item = relationshipHash[i];\n const { 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 if (data.lid) {\n hasMany[i].lid = data.lid;\n }\n }\n\n const 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 const relationshipHash = hash.data?.relationships?.[key]?.data;\n if (!relationshipHash) {\n return;\n }\n\n const { 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 const belongsTo = { id: data.id, type: data.type };\n const relationship = { data: belongsTo };\n\n if (data.lid) {\n belongsTo.lid = data.lid;\n }\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 const modelClass = store.modelFor(modelName);\n const serializer = store.serializerFor(modelName);\n\n return serializer.normalize(modelClass, relationshipHash, null);\n },\n isEmbeddedRecordsMixin: true,\n});\n","/**\n * @module @ember-data-mirror/serializer/rest\n */\nimport { warn } from '@ember/debug';\n\nimport { camelize, dasherize, singularize } from '@ember-data-mirror/request-utils/string';\nimport { DEBUG } from '@warp-drive-mirror/build-config/env';\nimport { assert } from '@warp-drive-mirror/build-config/macros';\n\nimport { coerceId } from './-private/utils';\nimport JSONSerializer from './json';\n\nfunction makeArray(value) {\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * <blockquote style=\"margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;\">\n <p>\n ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.\n If starting a new app or thinking of implementing a new adapter, consider writing a\n <a href=\"/ember-data/release/classes/%3CInterface%3E%20Handler\">Handler</a> instead to be used with the <a href=\"https://github.com/emberjs/data/tree/main/packages/request#readme\">RequestManager</a>\n </p>\n </blockquote>\n\n Normally, applications will use the `RESTSerializer` by implementing\n the `normalize` method.\n\n This allows you to do whatever kind of munging you need and is\n especially useful if your server is inconsistent and you need to\n do munging differently for many different kinds of responses.\n\n See the `normalize` documentation for more information.\n\n ## Across the Board Normalization\n\n There are also a number of hooks that you might find useful to define\n across-the-board rules for your payload. These rules will be useful\n if your server is consistent, or if you're building an adapter for\n an infrastructure service, like Firebase, and want to encode service\n conventions.\n\n For example, if all of your keys are underscored and all-caps, but\n otherwise consistent with the names you use in your models, you\n can implement across-the-board rules for how to convert an attribute\n name in your model to a key in your JSON.\n\n ```app/serializers/application.js\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n import { underscore } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends RESTSerializer {\n keyForAttribute(attr, method) {\n return underscore(attr).toUpperCase();\n }\n }\n ```\n\n You can also implement `keyForRelationship`, which takes the name\n of the relationship as the first parameter, the kind of\n relationship (`hasMany` or `belongsTo`) as the second parameter, and\n the method (`serialize` or `deserialize`) as the third parameter.\n\n @class RESTSerializer\n @main @ember-data-mirror/serializer/rest\n @public\n @extends JSONSerializer\n*/\nconst RESTSerializer = JSONSerializer.extend({\n /**\n `keyForPolymorphicType` can be used to define a custom key when\n serializing and deserializing a polymorphic type. By default, the\n returned key is `${key}Type`.\n\n Example\n\n ```app/serializers/post.js\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n\n export default class ApplicationSerializer extends RESTSerializer {\n keyForPolymorphicType(key, relationship) {\n let relationshipKey = this.keyForRelationship(key);\n\n return 'type-' + relationshipKey;\n }\n }\n ```\n\n @method keyForPolymorphicType\n @public\n @param {String} key\n @param {String} typeClass\n @param {String} method\n @return {String} normalized key\n */\n keyForPolymorphicType(key, typeClass, method) {\n const relationshipKey = this.keyForRelationship(key);\n\n return `${relationshipKey}Type`;\n },\n\n /**\n Normalizes a part of the JSON payload returned by\n the server. You should override this method, munge the hash\n and call super if you have generic normalization to do.\n\n It takes the type of the record that is being normalized\n (as a Model class), the property where the hash was\n originally found, and the hash to normalize.\n\n For example, if you have a payload that looks like this:\n\n ```js\n {\n \"post\": {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n \"comments\": [ 1, 2 ]\n },\n \"comments\": [{\n \"id\": 1,\n \"body\": \"FIRST\"\n }, {\n \"id\": 2,\n \"body\": \"Rails is unagi\"\n }]\n }\n ```\n\n The `normalize` method will be called three times:\n\n * With `App.Post`, `\"posts\"` and `{ id: 1, title: \"Rails is omakase\", ... }`\n * With `App.Comment`, `\"comments\"` and `{ id: 1, body: \"FIRST\" }`\n * With `App.Comment`, `\"comments\"` and `{ id: 2, body: \"Rails is unagi\" }`\n\n You can use this method, for example, to normalize underscored keys to camelized\n or other general-purpose normalizations. You will only need to implement\n `normalize` and manipulate the payload as desired.\n\n For example, if the `IDs` under `\"comments\"` are provided as `_id` instead of\n `id`, you can specify how to normalize just the comments:\n\n ```app/serializers/post.js\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n\n export default class ApplicationSerializer extends RESTSerializer {\n normalize(model, hash, prop) {\n if (prop === 'comments') {\n hash.id = hash._id;\n delete hash._id;\n }\n\n return super.normalize(...arguments);\n }\n }\n ```\n\n On each call to the `normalize` method, the third parameter (`prop`) is always\n one of the keys that were in the original payload or in the result of another\n normalization as `normalizeResponse`.\n\n @method normalize\n @public\n @param {Model} modelClass\n @param {Object} resourceHash\n @param {String} prop\n @return {Object}\n */\n\n /**\n Normalizes an array of resource payloads and returns a JSON-API Document\n with primary data and, if any, included data as `{ data, included }`.\n\n @method _normalizeArray\n @param {Store} store\n @param {String} modelName\n @param {Object} arrayHash\n @param {String} prop\n @return {Object}\n @private\n */\n _normalizeArray(store, modelName, arrayHash, prop) {\n const documentHash = {\n data: [],\n included: [],\n };\n\n const modelClass = store.modelFor(modelName);\n const serializer = store.serializerFor(modelName);\n\n makeArray(arrayHash).forEach((hash) => {\n const { data, included } = this._normalizePolymorphicRecord(store, hash, prop, modelClass, serializer);\n documentHash.data.push(data);\n if (included) {\n documentHash.included = documentHash.included.concat(included);\n }\n });\n\n return documentHash;\n },\n\n _normalizePolymorphicRecord(store, hash, prop, primaryModelClass, primarySerializer) {\n let serializer = primarySerializer;\n let modelClass = primaryModelClass;\n\n const primaryHasTypeAttribute = primaryModelClass.fields.has('type');\n\n if (!primaryHasTypeAttribute && hash.type) {\n // Support polymorphic records in async relationships\n const type = this.modelNameFromPayloadKey(hash.type);\n\n if (store.schema.hasResource({ type })) {\n serializer = store.serializerFor(type);\n modelClass = store.modelFor(type);\n }\n }\n\n return serializer.normalize(modelClass, hash, prop);\n },\n\n /**\n @method _normalizeResponse\n @param {Store} store\n @param {Model} primaryModelClass\n @param {Object} payload\n @param {String|Number} id\n @param {String} requestType\n @param {Boolean} isSingle\n @return {Object} JSON-API Document\n @private\n */\n _normalizeResponse(store, primaryModelClass, payload, id, requestType, isSingle) {\n const documentHash = {\n data: null,\n included: [],\n };\n\n const meta = this.extractMeta(store, primaryModelClass, payload);\n if (meta) {\n assert(\n 'The `meta` returned from `extractMeta` has to be an object, not \"' + typeof meta + '\".',\n typeof meta === 'object'\n );\n documentHash.meta = meta;\n }\n\n const keys = Object.keys(payload);\n\n for (var i = 0, length = keys.length; i < length; i++) {\n var prop = keys[i];\n var modelName = prop;\n var forcedSecondary = false;\n\n /*\n If you want to provide sideloaded records of the same type that the\n primary data you can do that by prefixing the key with `_`.\n\n Example\n\n ```\n {\n users: [\n { id: 1, title: 'Tom', manager: 3 },\n { id: 2, title: 'Yehuda', manager: 3 }\n ],\n _users: [\n { id: 3, title: 'Tomster' }\n ]\n }\n ```\n\n This forces `_users` to be added to `included` instead of `data`.\n */\n if (prop.charAt(0) === '_') {\n forcedSecondary = true;\n modelName = prop.substr(1);\n }\n\n const type = this.modelNameFromPayloadKey(modelName);\n if (!store.schema.hasResource({ type })) {\n if (DEBUG) {\n warn(this.warnMessageNoModelForKey(modelName, type), false, {\n id: 'ds.serializer.model-for-key-missing',\n });\n }\n continue;\n }\n\n var isPrimary = !forcedSecondary && this.isPrimaryType(store, type, primaryModelClass);\n var value = payload[prop];\n\n if (value === null) {\n continue;\n }\n\n assert(\n 'The adapter returned an array for the primary data of a `queryRecord` response. `queryRecord` should return a single record.',\n !(requestType === 'queryRecord' && isPrimary && Array.isArray(value))\n );\n\n /*\n Support primary data as an object instead of an array.\n\n Example\n\n ```\n {\n user: { id: 1, title: 'Tom', manager: 3 }\n }\n ```\n */\n if (isPrimary && !Array.isArray(value)) {\n const { data, included } = this._normalizePolymorphicRecord(store, value, prop, primaryModelClass, this);\n documentHash.data = data;\n if (included) {\n documentHash.included = documentHash.included.concat(included);\n }\n continue;\n }\n\n const { data, included } = this._normalizeArray(store, type, value, prop);\n\n if (included) {\n documentHash.included = documentHash.included.concat(included);\n }\n\n if (isSingle) {\n data.forEach((resource) => {\n /*\n Figures out if this is the primary record or not.\n\n It's either:\n\n 1. The record with the same ID as the original request\n 2. If it's a newly created record without an ID, the first record\n in the array\n */\n const isUpdatedRecord = isPrimary && coerceId(resource.id) === id;\n const isFirstCreatedRecord = isPrimary && !id && !documentHash.data;\n\n if (isFirstCreatedRecord || isUpdatedRecord) {\n documentHash.data = resource;\n } else {\n documentHash.included.push(resource);\n }\n });\n } else {\n if (isPrimary) {\n documentHash.data = data;\n } else {\n if (data) {\n documentHash.included = documentHash.included.concat(data);\n }\n }\n }\n }\n\n return documentHash;\n },\n\n isPrimaryType(store, modelName, primaryModelClass) {\n return dasherize(modelName) === primaryModelClass.modelName;\n },\n\n /**\n This method allows you to push a payload containing top-level\n collections of records organized per type.\n\n ```js\n {\n \"posts\": [{\n \"id\": \"1\",\n \"title\": \"Rails is omakase\",\n \"author\", \"1\",\n \"comments\": [ \"1\" ]\n }],\n \"comments\": [{\n \"id\": \"1\",\n \"body\": \"FIRST\"\n }],\n \"users\": [{\n \"id\": \"1\",\n \"name\": \"@d2h\"\n }]\n }\n ```\n\n It will first normalize the payload, so you can use this to push\n in data streaming in from your server structured the same way\n that fetches and saves are structured.\n\n @method pushPayload\n @public\n @param {Store} store\n @param {Object} payload\n */\n pushPayload(store, payload) {\n const documentHash = {\n data: [],\n included: [],\n };\n\n for (const prop in payload) {\n const type = this.modelNameFromPayloadKey(prop);\n if (!store.schema.hasResource({ type })) {\n if (DEBUG) {\n warn(this.warnMessageNoModelForKey(prop, type), false, {\n id: 'ds.serializer.model-for-key-missing',\n });\n }\n continue;\n }\n const ModelSchema = store.modelFor(type);\n const typeSerializer = store.serializerFor(ModelSchema.modelName);\n\n makeArray(payload[prop]).forEach((hash) => {\n const { data, included } = typeSerializer.normalize(ModelSchema, hash, prop);\n documentHash.data.push(data);\n if (included) {\n documentHash.included = documentHash.included.concat(included);\n }\n });\n }\n\n store.push(documentHash);\n },\n\n /**\n This method is used to convert each JSON root key in the payload\n into a modelName that it can use to look up the appropriate model for\n that part of the payload.\n\n For example, your server may send a model name that does not correspond with\n the name of the model in your app. Let's take a look at an example model,\n and an example payload:\n\n ```app/models/post.js\n import Model from '@ember-data-mirror/model';\n\n export default class Post extends Model {}\n ```\n\n ```javascript\n {\n \"blog/post\": {\n \"id\": \"1\n }\n }\n ```\n\n Ember Data is going to normalize the payload's root key for the modelName. As a result,\n it will try to look up the \"blog/post\" model. Since we don't have a model called \"blog/post\"\n (or a file called app/models/blog/post.js in ember-cli), Ember Data will throw an error\n because it cannot find the \"blog/post\" model.\n\n Since we want to remove this namespace, we can define a serializer for the application that will\n remove \"blog/\" from the payload key whenver it's encountered by Ember Data:\n\n ```app/serializers/application.js\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n\n export default class ApplicationSerializer extends RESTSerializer {\n modelNameFromPayloadKey(payloadKey) {\n if (payloadKey === 'blog/post') {\n return super.modelNameFromPayloadKey(payloadKey.replace('blog/', ''));\n } else {\n return super.modelNameFromPayloadKey(payloadKey);\n }\n }\n }\n ```\n\n After refreshing, Ember Data will appropriately look up the \"post\" model.\n\n By default the modelName for a model is its\n name in dasherized form. This means that a payload key like \"blogPost\" would be\n normalized to \"blog-post\" when Ember Data looks up the model. Usually, Ember Data\n can use the correct inflection to do this for you. Most of the time, you won't\n need to override `modelNameFromPayloadKey` for this purpose.\n\n @method modelNameFromPayloadKey\n @public\n @param {String} key\n @return {String} the model's modelName\n */\n modelNameFromPayloadKey(key) {\n return dasherize(singularize(key));\n },\n\n // SERIALIZE\n\n /**\n Called when a record is saved in order to convert the\n record into JSON.\n\n By default, it creates a JSON object with a key for\n each attribute and belongsTo relationship.\n\n For example, consider this model:\n\n ```app/models/comment.js\n import Model, { attr, belongsTo } from '@ember-data-mirror/model';\n\n export default class Comment extends Model {\n @attr title\n @attr body\n\n @belongsTo('user') author\n }\n ```\n\n The default serialization would create a JSON object like:\n\n ```js\n {\n \"title\": \"Rails is unagi\",\n \"body\": \"Rails? Omakase? O_O\",\n \"author\": 12\n }\n ```\n\n By default, attributes are passed through as-is, unless\n you specified an attribute type (`attr('date')`). If\n you specify a transform, the JavaScript value will be\n serialized when inserted into the JSON hash.\n\n By default, belongs-to relationships are converted into\n IDs when inserted into the JSON hash.\n\n ## IDs\n\n `serialize` takes an options hash with a single option:\n `includeId`. If this option is `true`, `serialize` will,\n by default include the ID in the JSON object it builds.\n\n The adapter passes in `includeId: true` when serializing\n a record for `createRecord`, but not for `updateRecord`.\n\n ## Customization\n\n Your server may expect a different JSON format than the\n built-in serialization format.\n\n In that case, you can implement `serialize` yourself and\n return a JSON hash of your choosing.\n\n ```app/serializers/post.js\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n\n export default class ApplicationSerializer extends RESTSerializer {\n serialize(snapshot, options) {\n let json = {\n POST_TTL: snapshot.attr('title'),\n POST_BDY: snapshot.attr('body'),\n POST_CMS: snapshot.hasMany('comments', { ids: true })\n };\n\n if (options.includeId) {\n json.POST_ID_ = snapshot.id;\n }\n\n return json;\n }\n }\n ```\n\n ## Customizing an App-Wide Serializer\n\n If you want to define a serializer for your entire\n application, you'll probably want to use `eachAttribute`\n and `eachRelationship` on the record.\n\n ```app/serializers/application.js\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n import { pluralize } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends RESTSerializer {\n serialize(snapshot, options) {\n let json = {};\n\n snapshot.eachAttribute(function(name) {\n json[serverAttributeName(name)] = snapshot.attr(name);\n });\n\n snapshot.eachRelationship(function(name, relationship) {\n if (relationship.kind === 'hasMany') {\n json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true });\n }\n });\n\n if (options.includeId) {\n json.ID_ = snapshot.id;\n }\n\n return json;\n }\n }\n\n function serverAttributeName(attribute) {\n return attribute.underscore().toUpperCase();\n }\n\n function serverHasManyName(name) {\n return serverAttributeName(singularize(name)) + \"_IDS\";\n }\n ```\n\n This serializer will generate JSON that looks like this:\n\n ```js\n {\n \"TITLE\": \"Rails is omakase\",\n \"BODY\": \"Yep. Omakase.\",\n \"COMMENT_IDS\": [ 1, 2, 3 ]\n }\n ```\n\n ## Tweaking the Default JSON\n\n If you just want to do some small tweaks on the default JSON,\n you can call super first and make the tweaks on the returned\n JSON.\n\n ```app/serializers/post.js\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n\n export default class ApplicationSerializer extends RESTSerializer {\n serialize(snapshot, options) {\n let json = super.serialize(snapshot, options);\n\n json.subject = json.title;\n delete json.title;\n\n return json;\n }\n }\n ```\n\n @method serialize\n @public\n @param {Snapshot} snapshot\n @param {Object} options\n @return {Object} json\n */\n serialize(snapshot, options) {\n return this._super(...arguments);\n },\n\n /**\n You can use this method to customize the root keys serialized into the JSON.\n The hash property should be modified by reference (possibly using something like _.extend)\n By default the REST Serializer sends the modelName of a model, which is a camelized\n version of the name.\n\n For example, your server may expect underscored root objects.\n\n ```app/serializers/application.js\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n import { underscore } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends RESTSerializer {\n serializeIntoHash(data, type, record, options) {\n let root = underscore(type.modelName);\n data[root] = this.serialize(record, options);\n }\n }\n ```\n\n @method serializeIntoHash\n @public\n @param {Object} hash\n @param {Model} typeClass\n @param {Snapshot} snapshot\n @param {Object} options\n */\n serializeIntoHash(hash, typeClass, snapshot, options) {\n const normalizedRootKey = this.payloadKeyFromModelName(typeClass.modelName);\n hash[normalizedRootKey] = this.serialize(snapshot, options);\n },\n\n /**\n You can use `payloadKeyFromModelName` to override the root key for an outgoing\n request. By default, the RESTSerializer returns a camelized version of the\n model's name.\n\n For a model called TacoParty, its `modelName` would be the string `taco-party`. The RESTSerializer\n will send it to the server with `tacoParty` as the root key in the JSON payload:\n\n ```js\n {\n \"tacoParty\": {\n \"id\": \"1\",\n \"location\": \"Matthew Beale's House\"\n }\n }\n ```\n\n For example, your server may expect dasherized root objects:\n\n ```app/serializers/application.js\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n import { dasherize } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends RESTSerializer {\n payloadKeyFromModelName(modelName) {\n return dasherize(modelName);\n }\n }\n ```\n\n Given a `TacoParty` model, calling `save` on it would produce an outgoing\n request like:\n\n ```js\n {\n \"taco-party\": {\n \"id\": \"1\",\n \"location\": \"Matthew Beale's House\"\n }\n }\n ```\n\n @method payloadKeyFromModelName\n @public\n @param {String} modelName\n @return {String}\n */\n payloadKeyFromModelName(modelName) {\n return camelize(modelName);\n },\n\n /**\n You can use this method to customize how polymorphic objects are serialized.\n By default the REST Serializer creates the key by appending `Type` to\n the attribute and value from the model's camelcased model name.\n\n @method serializePolymorphicType\n @public\n @param {Snapshot} snapshot\n @param {Object} json\n @param {Object} relationship\n */\n serializePolymorphicType(snapshot, json, relationship) {\n const name = relationship.name;\n const typeKey = this.keyForPolymorphicType(name, relationship.type, 'serialize');\n const belongsTo = snapshot.belongsTo(name);\n\n if (!belongsTo) {\n json[typeKey] = null;\n } else {\n json[typeKey] = camelize(belongsTo.modelName);\n }\n },\n\n /**\n You can use this method to customize how a polymorphic relationship should\n be extracted.\n\n @method extractPolymorphicRelationship\n @public\n @param {Object} relationshipType\n @param {Object} relationshipHash\n @param {Object} relationshipOptions\n @return {Object}\n */\n extractPolymorphicRelationship(relationshipType, relationshipHash, relationshipOptions) {\n const { key, resourceHash, relationshipMeta } = relationshipOptions;\n\n // A polymorphic belongsTo relationship can be present in the payload\n // either in the form where the `id` and the `type` are given:\n //\n // {\n // message: { id: 1, type: 'post' }\n // }\n //\n // or by the `id` and a `<relationship>Type` attribute:\n //\n // {\n // message: 1,\n // messageType: 'post'\n // }\n //\n // The next code checks if the latter case is present and returns the\n // corresponding JSON-API representation. The former case is handled within\n // the base class JSONSerializer.\n const isPolymorphic = relationshipMeta.options.polymorphic;\n const typeProperty = this.keyForPolymorphicType(key, relationshipType, 'deserialize');\n\n if (isPolymorphic && resourceHash[typeProperty] !== undefined && typeof relationshipHash !== 'object') {\n const type = this.modelNameFromPayloadKey(resourceHash[typeProperty]);\n return {\n id: coerceId(relationshipHash),\n type: type,\n };\n }\n\n return this._super(...arguments);\n },\n});\n\nif (DEBUG) {\n RESTSerializer.reopen({\n warnMessageNoModelForKey(prop, typeKey) {\n return (\n 'Encountered \"' +\n prop +\n '\" in payload, but no model was found for model name \"' +\n typeKey +\n '\" (resolved model name using ' +\n this.constructor.toString() +\n '.modelNameFromPayloadKey(\"' +\n prop +\n '\"))'\n );\n },\n });\n}\n\nexport { EmbeddedRecordsMixin } from './-private/embedded-records-mixin';\n\nexport default RESTSerializer;\n"],"names":["EmbeddedRecordsMixin","Mixin","create","normalize","typeClass","hash","prop","normalizedHash","_super","_extractEmbeddedRecords","store","keyForRelationship","key","method","hasSerializeRecordsOption","hasDeserializeRecordsOption","keyForAttribute","serializeBelongsTo","snapshot","json","relationship","attr","name","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","map","recordSnapshot","type","warn","_generateSerializedHasMany","ret","Array","length","i","embeddedJson","parentRecord","inverseFor","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","lid","modelClass","isEmbeddedRecordsMixin","makeArray","value","isArray","RESTSerializer","JSONSerializer","extend","keyForPolymorphicType","relationshipKey","_normalizeArray","arrayHash","documentHash","forEach","_normalizePolymorphicRecord","primaryModelClass","primarySerializer","primaryHasTypeAttribute","fields","has","modelNameFromPayloadKey","hasResource","_normalizeResponse","payload","requestType","isSingle","meta","extractMeta","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","keys","Object","forcedSecondary","charAt","substr","warnMessageNoModelForKey","isPrimary","isPrimaryType","resource","isUpdatedRecord","coerceId","isFirstCreatedRecord","dasherize","pushPayload","ModelSchema","typeSerializer","singularize","arguments","serializeIntoHash","normalizedRootKey","payloadKeyFromModelName","typeKey","extractPolymorphicRelationship","relationshipType","relationshipOptions","resourceHash","isPolymorphic","typeProperty","undefined","reopen","constructor","toString"],"mappings":";;;;;;AAKA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;MACaA,oBAAoB,GAAGC,KAAK,CAACC,MAAM,CAAC;AAC/C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;A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AAI,CAACnB,KAAK,CAACoB,QAAQ,CAACZ,QAAQ,CAACa,SAAS,CAAC;IACtD,IAAIC,aAAa,GAAG,IAAI,CAACC,aAAa,CAACb,YAAY,CAACE,IAAI,EAAEO,MAAM,CAAC;IACjE,IAAIG,aAAa,KAAKZ,YAAY,CAACE,IAAI,IAAI,IAAI,CAACX,kBAAkB,EAAE;AAClEqB,MAAAA,aAAa,GAAG,IAAI,CAACrB,kBAAkB,CAACS,YAAY,CAACE,IAAI,EAAEF,YAAY,CAACc,IAAI,EAAE,WAAW,CAAC;AAC5F;IAEA,IAAI,CAACP,gBAAgB,EAAE;AACrBR,MAAAA,IAAI,CAACa,aAAa,CAAC,GAAG,IAAI;AAC5B,KAAC,MAAM;AACLb,MAAAA,IAAI,CAACa,aAAa,CAAC,GAAGL,gBAAgB,CAACa,SAAS,CAAC;AAAEC,QAAAA,SAAS,EAAE;AAAK,OAAC,CAAC;AACrE,MAAA,IAAI,CAACC,wBAAwB,CAACxB,QAAQ,EAAES,gBAAgB,EAAEP,YAAY,EAAED,IAAI,CAACa,aAAa,CAAC,CAAC;AAE5F,MAAA,IAAIZ,YAAY,CAACgB,OAAO,CAACC,WAAW,EAAE;QACpC,IAAI,CAACC,wBAAwB,CAACpB,QAAQ,EAAEC,IAAI,EAAEC,YAAY,CAAC;AAC7D;AACF;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;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;A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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;EAYEQ,uBAAuBA,CAAC/F,GAAG,EAAE;AAC3B,IAAA,OAAO0H,SAAS,CAACI,WAAW,CAAC9H,GAAG,CAAC,CAAC;GACnC;AAED;;AAEA;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;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;AAuCE4B,EAAAA,SAASA,CAACtB,QAAQ,EAAEkB,OAAO,EAAE;AAC3B,IAAA,OAAO,IAAI,CAAC5B,MAAM,CAAC,GAAGmI,SAAS,CAAC;GACjC;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EAKEC,iBAAiBA,CAACvI,IAAI,EAAED,SAAS,EAAEc,QAAQ,EAAEkB,OAAO,EAAE;IACpD,MAAMyG,iBAAiB,GAAG,IAAI,CAACC,uBAAuB,CAAC1I,SAAS,CAAC2B,SAA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A;AACA,IAAA,MAAME,aAAa,GAAGvE,gBAAgB,CAACzC,OAAO,CAACC,WAAW;IAC1D,MAAMgH,YAAY,GAAG,IAAI,CAACtD,qBAAqB,CAACnF,GAAG,EAAEqI,gBAAgB,EAAE,aAAa,CAAC;AAErF,IAAA,IAAIG,aAAa,IAAID,YAAY,CAACE,YAAY,CAAC,KAAKC,SAAS,IAAI,OAAOxE,gBAAgB,KAAK,QAAQ,EAAE;MACrG,MAAM3B,IAAI,GAAG,IAAI,CAACwD,uBAAuB,CAACwC,YAAY,CAACE,YAAY,CAAC,CAAC;MACrE,OAAO;AACLlH,QAAAA,EAAE,EAAEiG,QAAQ,CAACtD,gBAAgB,CAAC;AAC9B3B,QAAAA,IAAI,EAAEA;OACP;AACH;AAEA,IAAA,OAAO,IAAI,CAAC3C,MAAM,CAAC,GAAGmI,SAAS,CAAC;AAClC;AACF,CAAC;AAED,IAAAxB,cAAA,CAAAC,eAAA,EAAA,CAAAC,SAAA,CAAAC,GAAA,CAAAC,KAAA,CAAW,EAAA;EACT3B,cAAc,CAAC2D,MAAM,CAAC;AACpBxB,IAAAA,wBAAwBA,CAACzH,IAAI,EAAEyI,OAAO,EAAE;MACtC,OACE,eAAe,GACfzI,IAAI,GACJ,uDAAuD,GACvDyI,OAAO,GACP,+BAA+B,GAC/B,IAAI,CAACS,WAAW,CAACC,QAAQ,EAAE,GAC3B,4BAA4B,GAC5BnJ,IAAI,GACJ,KAAK;AAET;AACF,GAAC,CAAC;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"rest.js","sources":["../src/-private/embedded-records-mixin.js","../src/rest.js"],"sourcesContent":["import { warn } from '@ember/debug';\nimport Mixin from '@ember/object/mixin';\n\nimport { camelize } from '@ember-data-mirror/request-utils/string';\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 ```js [app/serializers/post.js]\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data-mirror/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 const EmbeddedRecordsMixin = 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 @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 const 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-mirror/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 ```js [app/serializers/post.js]\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data-mirror/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 @public\n @param {Snapshot} snapshot\n @param {Object} json\n @param {Object} relationship\n */\n serializeBelongsTo(snapshot, json, relationship) {\n const attr = relationship.name;\n if (this.noSerializeOptionSpecified(attr)) {\n this._super(snapshot, json, relationship);\n return;\n }\n const includeIds = this.hasSerializeIdsOption(attr);\n const includeRecords = this.hasSerializeRecordsOption(attr);\n const embeddedSnapshot = snapshot.belongsTo(attr);\n if (includeIds) {\n const schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.name, schema);\n if (serializedKey === relationship.name && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.name, 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 const embeddedSnapshot = snapshot.belongsTo(relationship.name);\n const schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.name, schema);\n if (serializedKey === relationship.name && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.name, 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-mirror/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 ```js [app/serializers/post.js]\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data-mirror/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 ```js [app/serializers/post.js]\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data-mirror/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 ```js [app/serializers/user.js]\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data-mirror/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 @public\n @param {Snapshot} snapshot\n @param {Object} json\n @param {Object} relationship\n */\n serializeHasMany(snapshot, json, relationship) {\n const attr = relationship.name;\n if (this.noSerializeOptionSpecified(attr)) {\n this._super(snapshot, json, relationship);\n return;\n }\n\n if (this.hasSerializeIdsOption(attr)) {\n const schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.name, schema);\n if (serializedKey === relationship.name && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.name, 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 const serializedKey = this.keyForAttribute(relationship.name, 'serialize');\n const hasMany = snapshot.hasMany(relationship.name) || [];\n\n json[serializedKey] = 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 const schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.name, schema);\n if (serializedKey === relationship.name && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.name, 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.name) !== '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 const hasMany = snapshot.hasMany(relationship.name) || [];\n const ret = new Array(hasMany.length);\n\n for (let i = 0; i < hasMany.length; i++) {\n const embeddedSnapshot = hasMany[i];\n const 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 @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 const schema = this.store.modelFor(snapshot.modelName);\n const parentRecord = schema.inverseFor(relationship.name, this.store);\n if (parentRecord) {\n const name = parentRecord.name;\n const embeddedSerializer = this.store.serializerFor(embeddedSnapshot.modelName);\n const 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 const 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 const alwaysEmbed = this.hasEmbeddedAlwaysOption(attr);\n const 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 const 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 const 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 const 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 const alwaysEmbed = this.hasEmbeddedAlwaysOption(attr);\n const option = this.attrsOption(attr);\n return alwaysEmbed || (option && option.deserialize === 'records');\n },\n\n attrsOption(attr) {\n const attrs = this.attrs;\n return attrs && (attrs[camelize(attr)] || attrs[attr]);\n },\n\n /**\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 @private\n */\n _extractEmbeddedHasMany(store, key, hash, relationshipMeta) {\n const relationshipHash = hash.data?.relationships?.[key]?.data;\n\n if (!relationshipHash) {\n return;\n }\n\n const hasMany = new Array(relationshipHash.length);\n\n for (let i = 0; i < relationshipHash.length; i++) {\n const item = relationshipHash[i];\n const { 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 if (data.lid) {\n hasMany[i].lid = data.lid;\n }\n }\n\n const relationship = { data: hasMany };\n hash.data.relationships[key] = relationship;\n },\n\n /**\n @private\n */\n _extractEmbeddedBelongsTo(store, key, hash, relationshipMeta) {\n const relationshipHash = hash.data?.relationships?.[key]?.data;\n if (!relationshipHash) {\n return;\n }\n\n const { 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 const belongsTo = { id: data.id, type: data.type };\n const relationship = { data: belongsTo };\n\n if (data.lid) {\n belongsTo.lid = data.lid;\n }\n\n hash.data.relationships[key] = relationship;\n },\n\n /**\n @private\n */\n _normalizeEmbeddedRelationship(store, relationshipMeta, relationshipHash) {\n let modelName = relationshipMeta.type;\n if (relationshipMeta.options.polymorphic) {\n modelName = relationshipHash.type;\n }\n const modelClass = store.modelFor(modelName);\n const serializer = store.serializerFor(modelName);\n\n return serializer.normalize(modelClass, relationshipHash, null);\n },\n isEmbeddedRecordsMixin: true,\n});\n","import { warn } from '@ember/debug';\n\nimport { camelize, dasherize, singularize } from '@ember-data-mirror/request-utils/string';\nimport { DEBUG } from '@warp-drive-mirror/build-config/env';\nimport { assert } from '@warp-drive-mirror/build-config/macros';\n\nimport { coerceId } from './-private/utils';\nimport JSONSerializer from './json';\n\nfunction makeArray(value) {\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * <blockquote style=\"margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;\">\n <p>\n ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.\n If starting a new app or thinking of implementing a new adapter, consider writing a\n <a href=\"/ember-data/release/classes/%3CInterface%3E%20Handler\">Handler</a> instead to be used with the <a href=\"https://github.com/emberjs/data/tree/main/packages/request#readme\">RequestManager</a>\n </p>\n </blockquote>\n\n Normally, applications will use the `RESTSerializer` by implementing\n the `normalize` method.\n\n This allows you to do whatever kind of munging you need and is\n especially useful if your server is inconsistent and you need to\n do munging differently for many different kinds of responses.\n\n See the `normalize` documentation for more information.\n\n ## Across the Board Normalization\n\n There are also a number of hooks that you might find useful to define\n across-the-board rules for your payload. These rules will be useful\n if your server is consistent, or if you're building an adapter for\n an infrastructure service, like Firebase, and want to encode service\n conventions.\n\n For example, if all of your keys are underscored and all-caps, but\n otherwise consistent with the names you use in your models, you\n can implement across-the-board rules for how to convert an attribute\n name in your model to a key in your JSON.\n\n ```js [app/serializers/application.js]\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n import { underscore } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends RESTSerializer {\n keyForAttribute(attr, method) {\n return underscore(attr).toUpperCase();\n }\n }\n ```\n\n You can also implement `keyForRelationship`, which takes the name\n of the relationship as the first parameter, the kind of\n relationship (`hasMany` or `belongsTo`) as the second parameter, and\n the method (`serialize` or `deserialize`) as the third parameter.\n\n @class RESTSerializer\n @public\n*/\nconst RESTSerializer = JSONSerializer.extend({\n /**\n `keyForPolymorphicType` can be used to define a custom key when\n serializing and deserializing a polymorphic type. By default, the\n returned key is `${key}Type`.\n\n Example\n\n ```js [app/serializers/post.js]\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n\n export default class ApplicationSerializer extends RESTSerializer {\n keyForPolymorphicType(key, relationship) {\n let relationshipKey = this.keyForRelationship(key);\n\n return 'type-' + relationshipKey;\n }\n }\n ```\n\n @public\n @param {String} key\n @param {String} typeClass\n @param {String} method\n @return {String} normalized key\n */\n keyForPolymorphicType(key, typeClass, method) {\n const relationshipKey = this.keyForRelationship(key);\n\n return `${relationshipKey}Type`;\n },\n\n /**\n Normalizes a part of the JSON payload returned by\n the server. You should override this method, munge the hash\n and call super if you have generic normalization to do.\n\n It takes the type of the record that is being normalized\n (as a Model class), the property where the hash was\n originally found, and the hash to normalize.\n\n For example, if you have a payload that looks like this:\n\n ```js\n {\n \"post\": {\n \"id\": 1,\n \"title\": \"Rails is omakase\",\n \"comments\": [ 1, 2 ]\n },\n \"comments\": [{\n \"id\": 1,\n \"body\": \"FIRST\"\n }, {\n \"id\": 2,\n \"body\": \"Rails is unagi\"\n }]\n }\n ```\n\n The `normalize` method will be called three times:\n\n * With `App.Post`, `\"posts\"` and `{ id: 1, title: \"Rails is omakase\", ... }`\n * With `App.Comment`, `\"comments\"` and `{ id: 1, body: \"FIRST\" }`\n * With `App.Comment`, `\"comments\"` and `{ id: 2, body: \"Rails is unagi\" }`\n\n You can use this method, for example, to normalize underscored keys to camelized\n or other general-purpose normalizations. You will only need to implement\n `normalize` and manipulate the payload as desired.\n\n For example, if the `IDs` under `\"comments\"` are provided as `_id` instead of\n `id`, you can specify how to normalize just the comments:\n\n ```js [app/serializers/post.js]\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n\n export default class ApplicationSerializer extends RESTSerializer {\n normalize(model, hash, prop) {\n if (prop === 'comments') {\n hash.id = hash._id;\n delete hash._id;\n }\n\n return super.normalize(...arguments);\n }\n }\n ```\n\n On each call to the `normalize` method, the third parameter (`prop`) is always\n one of the keys that were in the original payload or in the result of another\n normalization as `normalizeResponse`.\n\n @public\n @param {Model} modelClass\n @param {Object} resourceHash\n @param {String} prop\n @return {Object}\n */\n\n /**\n Normalizes an array of resource payloads and returns a JSON-API Document\n with primary data and, if any, included data as `{ data, included }`.\n\n @param {Store} store\n @param {String} modelName\n @param {Object} arrayHash\n @param {String} prop\n @return {Object}\n @private\n */\n _normalizeArray(store, modelName, arrayHash, prop) {\n const documentHash = {\n data: [],\n included: [],\n };\n\n const modelClass = store.modelFor(modelName);\n const serializer = store.serializerFor(modelName);\n\n makeArray(arrayHash).forEach((hash) => {\n const { data, included } = this._normalizePolymorphicRecord(store, hash, prop, modelClass, serializer);\n documentHash.data.push(data);\n if (included) {\n documentHash.included = documentHash.included.concat(included);\n }\n });\n\n return documentHash;\n },\n\n _normalizePolymorphicRecord(store, hash, prop, primaryModelClass, primarySerializer) {\n let serializer = primarySerializer;\n let modelClass = primaryModelClass;\n\n const primaryHasTypeAttribute = primaryModelClass.fields.has('type');\n\n if (!primaryHasTypeAttribute && hash.type) {\n // Support polymorphic records in async relationships\n const type = this.modelNameFromPayloadKey(hash.type);\n\n if (store.schema.hasResource({ type })) {\n serializer = store.serializerFor(type);\n modelClass = store.modelFor(type);\n }\n }\n\n return serializer.normalize(modelClass, hash, prop);\n },\n\n /**\n @param {Store} store\n @param {Model} primaryModelClass\n @param {Object} payload\n @param {String|Number} id\n @param {String} requestType\n @param {Boolean} isSingle\n @return {Object} JSON-API Document\n @private\n */\n _normalizeResponse(store, primaryModelClass, payload, id, requestType, isSingle) {\n const documentHash = {\n data: null,\n included: [],\n };\n\n const meta = this.extractMeta(store, primaryModelClass, payload);\n if (meta) {\n assert(\n 'The `meta` returned from `extractMeta` has to be an object, not \"' + typeof meta + '\".',\n typeof meta === 'object'\n );\n documentHash.meta = meta;\n }\n\n const keys = Object.keys(payload);\n\n for (var i = 0, length = keys.length; i < length; i++) {\n var prop = keys[i];\n var modelName = prop;\n var forcedSecondary = false;\n\n /*\n If you want to provide sideloaded records of the same type that the\n primary data you can do that by prefixing the key with `_`.\n\n Example\n\n ```\n {\n users: [\n { id: 1, title: 'Tom', manager: 3 },\n { id: 2, title: 'Yehuda', manager: 3 }\n ],\n _users: [\n { id: 3, title: 'Tomster' }\n ]\n }\n ```\n\n This forces `_users` to be added to `included` instead of `data`.\n */\n if (prop.charAt(0) === '_') {\n forcedSecondary = true;\n modelName = prop.substr(1);\n }\n\n const type = this.modelNameFromPayloadKey(modelName);\n if (!store.schema.hasResource({ type })) {\n if (DEBUG) {\n warn(this.warnMessageNoModelForKey(modelName, type), false, {\n id: 'ds.serializer.model-for-key-missing',\n });\n }\n continue;\n }\n\n var isPrimary = !forcedSecondary && this.isPrimaryType(store, type, primaryModelClass);\n var value = payload[prop];\n\n if (value === null) {\n continue;\n }\n\n assert(\n 'The adapter returned an array for the primary data of a `queryRecord` response. `queryRecord` should return a single record.',\n !(requestType === 'queryRecord' && isPrimary && Array.isArray(value))\n );\n\n /*\n Support primary data as an object instead of an array.\n\n Example\n\n ```\n {\n user: { id: 1, title: 'Tom', manager: 3 }\n }\n ```\n */\n if (isPrimary && !Array.isArray(value)) {\n const { data, included } = this._normalizePolymorphicRecord(store, value, prop, primaryModelClass, this);\n documentHash.data = data;\n if (included) {\n documentHash.included = documentHash.included.concat(included);\n }\n continue;\n }\n\n const { data, included } = this._normalizeArray(store, type, value, prop);\n\n if (included) {\n documentHash.included = documentHash.included.concat(included);\n }\n\n if (isSingle) {\n data.forEach((resource) => {\n /*\n Figures out if this is the primary record or not.\n\n It's either:\n\n 1. The record with the same ID as the original request\n 2. If it's a newly created record without an ID, the first record\n in the array\n */\n const isUpdatedRecord = isPrimary && coerceId(resource.id) === id;\n const isFirstCreatedRecord = isPrimary && !id && !documentHash.data;\n\n if (isFirstCreatedRecord || isUpdatedRecord) {\n documentHash.data = resource;\n } else {\n documentHash.included.push(resource);\n }\n });\n } else {\n if (isPrimary) {\n documentHash.data = data;\n } else {\n if (data) {\n documentHash.included = documentHash.included.concat(data);\n }\n }\n }\n }\n\n return documentHash;\n },\n\n isPrimaryType(store, modelName, primaryModelClass) {\n return dasherize(modelName) === primaryModelClass.modelName;\n },\n\n /**\n This method allows you to push a payload containing top-level\n collections of records organized per type.\n\n ```js\n {\n \"posts\": [{\n \"id\": \"1\",\n \"title\": \"Rails is omakase\",\n \"author\", \"1\",\n \"comments\": [ \"1\" ]\n }],\n \"comments\": [{\n \"id\": \"1\",\n \"body\": \"FIRST\"\n }],\n \"users\": [{\n \"id\": \"1\",\n \"name\": \"@d2h\"\n }]\n }\n ```\n\n It will first normalize the payload, so you can use this to push\n in data streaming in from your server structured the same way\n that fetches and saves are structured.\n\n @public\n @param {Store} store\n @param {Object} payload\n */\n pushPayload(store, payload) {\n const documentHash = {\n data: [],\n included: [],\n };\n\n for (const prop in payload) {\n const type = this.modelNameFromPayloadKey(prop);\n if (!store.schema.hasResource({ type })) {\n if (DEBUG) {\n warn(this.warnMessageNoModelForKey(prop, type), false, {\n id: 'ds.serializer.model-for-key-missing',\n });\n }\n continue;\n }\n const ModelSchema = store.modelFor(type);\n const typeSerializer = store.serializerFor(ModelSchema.modelName);\n\n makeArray(payload[prop]).forEach((hash) => {\n const { data, included } = typeSerializer.normalize(ModelSchema, hash, prop);\n documentHash.data.push(data);\n if (included) {\n documentHash.included = documentHash.included.concat(included);\n }\n });\n }\n\n store.push(documentHash);\n },\n\n /**\n This method is used to convert each JSON root key in the payload\n into a modelName that it can use to look up the appropriate model for\n that part of the payload.\n\n For example, your server may send a model name that does not correspond with\n the name of the model in your app. Let's take a look at an example model,\n and an example payload:\n\n ```js [app/models/post.js]\n import Model from '@ember-data-mirror/model';\n\n export default class Post extends Model {}\n ```\n\n ```javascript\n {\n \"blog/post\": {\n \"id\": \"1\n }\n }\n ```\n\n Ember Data is going to normalize the payload's root key for the modelName. As a result,\n it will try to look up the \"blog/post\" model. Since we don't have a model called \"blog/post\"\n (or a file called app/models/blog/post.js in ember-cli), Ember Data will throw an error\n because it cannot find the \"blog/post\" model.\n\n Since we want to remove this namespace, we can define a serializer for the application that will\n remove \"blog/\" from the payload key whenver it's encountered by Ember Data:\n\n ```js [app/serializers/application.js]\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n\n export default class ApplicationSerializer extends RESTSerializer {\n modelNameFromPayloadKey(payloadKey) {\n if (payloadKey === 'blog/post') {\n return super.modelNameFromPayloadKey(payloadKey.replace('blog/', ''));\n } else {\n return super.modelNameFromPayloadKey(payloadKey);\n }\n }\n }\n ```\n\n After refreshing, Ember Data will appropriately look up the \"post\" model.\n\n By default the modelName for a model is its\n name in dasherized form. This means that a payload key like \"blogPost\" would be\n normalized to \"blog-post\" when Ember Data looks up the model. Usually, Ember Data\n can use the correct inflection to do this for you. Most of the time, you won't\n need to override `modelNameFromPayloadKey` for this purpose.\n\n @public\n @param {String} key\n @return {String} the model's modelName\n */\n modelNameFromPayloadKey(key) {\n return dasherize(singularize(key));\n },\n\n // SERIALIZE\n\n /**\n Called when a record is saved in order to convert the\n record into JSON.\n\n By default, it creates a JSON object with a key for\n each attribute and belongsTo relationship.\n\n For example, consider this model:\n\n ```js [app/models/comment.js]\n import Model, { attr, belongsTo } from '@ember-data-mirror/model';\n\n export default class Comment extends Model {\n @attr title\n @attr body\n\n @belongsTo('user') author\n }\n ```\n\n The default serialization would create a JSON object like:\n\n ```js\n {\n \"title\": \"Rails is unagi\",\n \"body\": \"Rails? Omakase? O_O\",\n \"author\": 12\n }\n ```\n\n By default, attributes are passed through as-is, unless\n you specified an attribute type (`attr('date')`). If\n you specify a transform, the JavaScript value will be\n serialized when inserted into the JSON hash.\n\n By default, belongs-to relationships are converted into\n IDs when inserted into the JSON hash.\n\n ## IDs\n\n `serialize` takes an options hash with a single option:\n `includeId`. If this option is `true`, `serialize` will,\n by default include the ID in the JSON object it builds.\n\n The adapter passes in `includeId: true` when serializing\n a record for `createRecord`, but not for `updateRecord`.\n\n ## Customization\n\n Your server may expect a different JSON format than the\n built-in serialization format.\n\n In that case, you can implement `serialize` yourself and\n return a JSON hash of your choosing.\n\n ```js [app/serializers/post.js]\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n\n export default class ApplicationSerializer extends RESTSerializer {\n serialize(snapshot, options) {\n let json = {\n POST_TTL: snapshot.attr('title'),\n POST_BDY: snapshot.attr('body'),\n POST_CMS: snapshot.hasMany('comments', { ids: true })\n };\n\n if (options.includeId) {\n json.POST_ID_ = snapshot.id;\n }\n\n return json;\n }\n }\n ```\n\n ## Customizing an App-Wide Serializer\n\n If you want to define a serializer for your entire\n application, you'll probably want to use `eachAttribute`\n and `eachRelationship` on the record.\n\n ```js [app/serializers/application.js]\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n import { pluralize } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends RESTSerializer {\n serialize(snapshot, options) {\n let json = {};\n\n snapshot.eachAttribute(function(name) {\n json[serverAttributeName(name)] = snapshot.attr(name);\n });\n\n snapshot.eachRelationship(function(name, relationship) {\n if (relationship.kind === 'hasMany') {\n json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true });\n }\n });\n\n if (options.includeId) {\n json.ID_ = snapshot.id;\n }\n\n return json;\n }\n }\n\n function serverAttributeName(attribute) {\n return attribute.underscore().toUpperCase();\n }\n\n function serverHasManyName(name) {\n return serverAttributeName(singularize(name)) + \"_IDS\";\n }\n ```\n\n This serializer will generate JSON that looks like this:\n\n ```js\n {\n \"TITLE\": \"Rails is omakase\",\n \"BODY\": \"Yep. Omakase.\",\n \"COMMENT_IDS\": [ 1, 2, 3 ]\n }\n ```\n\n ## Tweaking the Default JSON\n\n If you just want to do some small tweaks on the default JSON,\n you can call super first and make the tweaks on the returned\n JSON.\n\n ```js [app/serializers/post.js]\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n\n export default class ApplicationSerializer extends RESTSerializer {\n serialize(snapshot, options) {\n let json = super.serialize(snapshot, options);\n\n json.subject = json.title;\n delete json.title;\n\n return json;\n }\n }\n ```\n\n @public\n @param {Snapshot} snapshot\n @param {Object} options\n @return {Object} json\n */\n serialize(snapshot, options) {\n return this._super(...arguments);\n },\n\n /**\n You can use this method to customize the root keys serialized into the JSON.\n The hash property should be modified by reference (possibly using something like _.extend)\n By default the REST Serializer sends the modelName of a model, which is a camelized\n version of the name.\n\n For example, your server may expect underscored root objects.\n\n ```js [app/serializers/application.js]\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n import { underscore } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends RESTSerializer {\n serializeIntoHash(data, type, record, options) {\n let root = underscore(type.modelName);\n data[root] = this.serialize(record, options);\n }\n }\n ```\n\n @public\n @param {Object} hash\n @param {Model} typeClass\n @param {Snapshot} snapshot\n @param {Object} options\n */\n serializeIntoHash(hash, typeClass, snapshot, options) {\n const normalizedRootKey = this.payloadKeyFromModelName(typeClass.modelName);\n hash[normalizedRootKey] = this.serialize(snapshot, options);\n },\n\n /**\n You can use `payloadKeyFromModelName` to override the root key for an outgoing\n request. By default, the RESTSerializer returns a camelized version of the\n model's name.\n\n For a model called TacoParty, its `modelName` would be the string `taco-party`. The RESTSerializer\n will send it to the server with `tacoParty` as the root key in the JSON payload:\n\n ```js\n {\n \"tacoParty\": {\n \"id\": \"1\",\n \"location\": \"Matthew Beale's House\"\n }\n }\n ```\n\n For example, your server may expect dasherized root objects:\n\n ```js [app/serializers/application.js]\n import RESTSerializer from '@ember-data-mirror/serializer/rest';\n import { dasherize } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends RESTSerializer {\n payloadKeyFromModelName(modelName) {\n return dasherize(modelName);\n }\n }\n ```\n\n Given a `TacoParty` model, calling `save` on it would produce an outgoing\n request like:\n\n ```js\n {\n \"taco-party\": {\n \"id\": \"1\",\n \"location\": \"Matthew Beale's House\"\n }\n }\n ```\n\n @public\n @param {String} modelName\n @return {String}\n */\n payloadKeyFromModelName(modelName) {\n return camelize(modelName);\n },\n\n /**\n You can use this method to customize how polymorphic objects are serialized.\n By default the REST Serializer creates the key by appending `Type` to\n the attribute and value from the model's camelcased model name.\n\n @public\n @param {Snapshot} snapshot\n @param {Object} json\n @param {Object} relationship\n */\n serializePolymorphicType(snapshot, json, relationship) {\n const name = relationship.name;\n const typeKey = this.keyForPolymorphicType(name, relationship.type, 'serialize');\n const belongsTo = snapshot.belongsTo(name);\n\n if (!belongsTo) {\n json[typeKey] = null;\n } else {\n json[typeKey] = camelize(belongsTo.modelName);\n }\n },\n\n /**\n You can use this method to customize how a polymorphic relationship should\n be extracted.\n\n @public\n @param {Object} relationshipType\n @param {Object} relationshipHash\n @param {Object} relationshipOptions\n @return {Object}\n */\n extractPolymorphicRelationship(relationshipType, relationshipHash, relationshipOptions) {\n const { key, resourceHash, relationshipMeta } = relationshipOptions;\n\n // A polymorphic belongsTo relationship can be present in the payload\n // either in the form where the `id` and the `type` are given:\n //\n // {\n // message: { id: 1, type: 'post' }\n // }\n //\n // or by the `id` and a `<relationship>Type` attribute:\n //\n // {\n // message: 1,\n // messageType: 'post'\n // }\n //\n // The next code checks if the latter case is present and returns the\n // corresponding JSON-API representation. The former case is handled within\n // the base class JSONSerializer.\n const isPolymorphic = relationshipMeta.options.polymorphic;\n const typeProperty = this.keyForPolymorphicType(key, relationshipType, 'deserialize');\n\n if (isPolymorphic && resourceHash[typeProperty] !== undefined && typeof relationshipHash !== 'object') {\n const type = this.modelNameFromPayloadKey(resourceHash[typeProperty]);\n return {\n id: coerceId(relationshipHash),\n type: type,\n };\n }\n\n return this._super(...arguments);\n },\n});\n\nif (DEBUG) {\n RESTSerializer.reopen({\n warnMessageNoModelForKey(prop, typeKey) {\n return (\n 'Encountered \"' +\n prop +\n '\" in payload, but no model was found for model name \"' +\n typeKey +\n '\" (resolved model name using ' +\n this.constructor.toString() +\n '.modelNameFromPayloadKey(\"' +\n prop +\n '\"))'\n );\n },\n });\n}\n\nexport { EmbeddedRecordsMixin } from './-private/embedded-records-mixin';\n\nexport default RESTSerializer;\n"],"names":["EmbeddedRecordsMixin","Mixin","create","normalize","typeClass","hash","prop","normalizedHash","_super","_extractEmbeddedRecords","store","keyForRelationship","key","method","hasSerializeRecordsOption","hasDeserializeRecordsOption","keyForAttribute","serializeBelongsTo","snapshot","json","relationship","attr","name","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","map","recordSnapshot","type","warn","_generateSerializedHasMany","ret","Array","length","i","embeddedJson","parentRecord","inverseFor","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","lid","modelClass","isEmbeddedRecordsMixin","makeArray","value","isArray","RESTSerializer","JSONSerializer","extend","keyForPolymorphicType","relationshipKey","_normalizeArray","arrayHash","documentHash","forEach","_normalizePolymorphicRecord","primaryModelClass","primarySerializer","primaryHasTypeAttribute","fields","has","modelNameFromPayloadKey","hasResource","_normalizeResponse","payload","requestType","isSingle","meta","extractMeta","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","keys","Object","forcedSecondary","charAt","substr","warnMessageNoModelForKey","isPrimary","isPrimaryType","resource","isUpdatedRecord","coerceId","isFirstCreatedRecord","dasherize","pushPayload","ModelSchema","typeSerializer","singularize","arguments","serializeIntoHash","normalizedRootKey","payloadKeyFromModelName","typeKey","extractPolymorphicRelationship","relationshipType","relationshipOptions","resourceHash","isPolymorphic","typeProperty","undefined","reopen","constructor","toString"],"mappings":";;;;;;AAKA;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;MACaA,oBAAoB,GAAGC,KAAK,CAACC,MAAM,CAAC;AAC/C;AACF;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,MAAMC,cAAc,GAAG,IAAI,CAACC,MAAM,CAACJ,SAAS,EAAEC,IAAI,EAAEC,IAAI,CAAC;AACzD,IAAA,OAAO,IAAI,CAACG,uBAAuB,CAAC,IAAI,EAAE,IAAI,CAACC,KAAK,EAAEN,SAAS,EAAEG,cAAc,CAAC;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;AAC1C,KAAC,MAAM;MACL,OAAO,IAAI,CAACL,MAAM,CAACI,GAAG,EAAER,SAAS,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,OAAO,CAACC,WAAW,EAAE;QACpC,IAAI,CAACC,wBAAwB,CAACpB,QAAQ,EAAEC,IAAI,EAAEC,YAAY,CAAC;AAC7D;AACF;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;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;AA2BEuB,EAAAA,gBAAgBA,CAACzB,QAAQ,EAAEC,IAAI,EAAEC,YAAY,EAAE;AAC7C,IAAA,MAAMC,IAAI,GAAGD,YAAY,CAACE,IAAI;AAC9B,IAAA,IAAI,IAAI,CAACC,0BAA0B,CAACF,IAAI,CAAC,EAAE;MACzC,IAAI,CAACb,MAAM,CAACU,QAAQ,EAAEC,IAAI,EAAEC,YAAY,CAAC;AACzC,MAAA;AACF;AAEA,IAAA,IAAI,IAAI,CAACK,qBAAqB,CAACJ,IAAI,CAAC,EAAE;MACpC,MAAMQ,MAAM,GAAG,IAAI,CAACnB,KAAK,CAACoB,QAAQ,CAACZ,QAAQ,CAACa,SAAS,CAAC;MACtD,IAAIC,aAAa,GAAG,IAAI,CAACC,aAAa,CAACb,YAAY,CAACE,IAAI,EAAEO,MAAM,CAAC;MACjE,IAAIG,aAAa,KAAKZ,YAAY,CAACE,IAAI,IAAI,IAAI,CAACX,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ACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAME,cAAc,GAAGC,cAAc,CAACC,MAAM,CAAC;AAC3C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMEC,EAAAA,qBAAqBA,CAACnF,GAAG,EAAER,SAAS,EAAES,MAAM,EAAE;AAC5C,IAAA,MAAMmF,eAAe,GAAG,IAAI,CAACrF,kBAAkB,CAACC,GAAG,CAAC;IAEpD,OAAO,CAAA,EAAGoF,eAAe,CAAM,IAAA,CAAA;GAChC;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EAEEC,eAAeA,CAACvF,KAAK,EAAEqB,SAAS,EAAEmE,SAAS,EAAE5F,IAAI,EAAE;AACjD,IAAA,MAAM6F,YAAY,GAAG;AACnBpB,MAAAA,IAAI,EAAE,EAAE;AACRG,MAAAA,QAAQ,EAAE;KACX;AAED,IAAA,MAAMK,UAAU,GAAG7E,KAAK,CAACoB,QAAQ,CAACC,SAAS,CAAC;AAC5C,IAAA,MAAMyC,UAAU,GAAG9D,KAAK,CAACoD,aAAa,CAAC/B,SAAS,CAAC;AAEjD0D,IAAAA,SAAS,CAACS,SAAS,CAAC,CAACE,OAAO,CAAE/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,IAAI;AAAEG,UAAAA;SAAU,GAAGuD,cAAc,CAACtI,SAAS,CAACqI,WAAW,EAAEnI,IAAI,EAAEC,IAAI,CAAC;AAC5E6F,QAAAA,YAAY,CAACpB,IAAI,CAACK,IAAI,CAACL,IAAI,CAAC;AAC5B,QAAA,IAAIG,QAAQ,EAAE;UACZiB,YAAY,CAACjB,QAAQ,GAAGiB,YAAY,CAACjB,QAAQ,CAACG,MAAM,CAACH,QAAQ,CAAC;AAChE;AACF,OAAC,CAAC;AACJ;AAEAxE,IAAAA,KAAK,CAAC0E,IAAI,CAACe,YAAY,CAAC;GACzB;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;AACA;AACA;EAYEQ,uBAAuBA,CAAC/F,GAAG,EAAE;AAC3B,IAAA,OAAO0H,SAAS,CAACI,WAAW,CAAC9H,GAAG,CAAC,CAAC;GACnC;AAED;;AAEA;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;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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ACS,WAAW,CAACC,QAAQ,EAAE,GAC3B,4BAA4B,GAC5BnJ,IAAI,GACJ,KAAK;AAET;AACF,GAAC,CAAC;AACJ;;;;"}
|
package/dist/transform.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import EmberObject from '@ember/object';
|
|
2
2
|
import { TransformName } from '@warp-drive-mirror/core-types/symbols';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
@module @ember-data-mirror/serializer
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
4
|
/**
|
|
9
5
|
The `Transform` class is used to serialize and deserialize model
|
|
10
6
|
attributes when they are saved or loaded from an
|
|
@@ -14,7 +10,7 @@ import { TransformName } from '@warp-drive-mirror/core-types/symbols';
|
|
|
14
10
|
|
|
15
11
|
Example
|
|
16
12
|
|
|
17
|
-
```app/transforms/temperature.js
|
|
13
|
+
```js [app/transforms/temperature.js]
|
|
18
14
|
|
|
19
15
|
// Converts centigrade in the JSON to fahrenheit in the app
|
|
20
16
|
export default class TemperatureTransform {
|
|
@@ -34,7 +30,7 @@ import { TransformName } from '@warp-drive-mirror/core-types/symbols';
|
|
|
34
30
|
|
|
35
31
|
Usage
|
|
36
32
|
|
|
37
|
-
```app/models/requirement.js
|
|
33
|
+
```js [app/models/requirement.js]
|
|
38
34
|
import Model, { attr } from '@ember-data-mirror/model';
|
|
39
35
|
|
|
40
36
|
export default class RequirementModel extends Model {
|
|
@@ -46,7 +42,7 @@ import { TransformName } from '@warp-drive-mirror/core-types/symbols';
|
|
|
46
42
|
The options passed into the `attr` function when the attribute is
|
|
47
43
|
declared on the model is also available in the transform.
|
|
48
44
|
|
|
49
|
-
```app/models/post.js
|
|
45
|
+
```js [app/models/post.js]
|
|
50
46
|
import Model, { attr } from '@ember-data-mirror/model';
|
|
51
47
|
|
|
52
48
|
export default class PostModel extends Model {
|
|
@@ -61,7 +57,7 @@ import { TransformName } from '@warp-drive-mirror/core-types/symbols';
|
|
|
61
57
|
}
|
|
62
58
|
```
|
|
63
59
|
|
|
64
|
-
```app/transforms/markdown.js
|
|
60
|
+
```js [app/transforms/markdown.js]
|
|
65
61
|
export default class MarkdownTransform {
|
|
66
62
|
serialize(deserialized, options) {
|
|
67
63
|
return deserialized.raw;
|
|
@@ -94,7 +90,6 @@ import { TransformName } from '@warp-drive-mirror/core-types/symbols';
|
|
|
94
90
|
}
|
|
95
91
|
```
|
|
96
92
|
|
|
97
|
-
@method serialize
|
|
98
93
|
@public
|
|
99
94
|
@param deserialized The deserialized value
|
|
100
95
|
@param options hash of options passed to `attr`
|
|
@@ -112,7 +107,6 @@ import { TransformName } from '@warp-drive-mirror/core-types/symbols';
|
|
|
112
107
|
}
|
|
113
108
|
```
|
|
114
109
|
|
|
115
|
-
@method deserialize
|
|
116
110
|
@public
|
|
117
111
|
@param serialized The serialized value
|
|
118
112
|
@param options hash of options passed to `attr`
|
|
@@ -121,10 +115,6 @@ import { TransformName } from '@warp-drive-mirror/core-types/symbols';
|
|
|
121
115
|
|
|
122
116
|
const Transform = EmberObject;
|
|
123
117
|
|
|
124
|
-
/**
|
|
125
|
-
@module @ember-data-mirror/serializer
|
|
126
|
-
*/
|
|
127
|
-
|
|
128
118
|
/**
|
|
129
119
|
The `BooleanTransform` class is used to serialize and deserialize
|
|
130
120
|
boolean attributes on Ember Data record objects. This transform is
|
|
@@ -133,7 +123,7 @@ const Transform = EmberObject;
|
|
|
133
123
|
|
|
134
124
|
Usage
|
|
135
125
|
|
|
136
|
-
```app/models/user.js
|
|
126
|
+
```js [app/models/user.js]
|
|
137
127
|
import Model, { attr } from '@ember-data-mirror/model';
|
|
138
128
|
|
|
139
129
|
export default class UserModel extends Model {
|
|
@@ -147,7 +137,7 @@ const Transform = EmberObject;
|
|
|
147
137
|
`false`. You can opt into allowing `null` values for
|
|
148
138
|
boolean attributes via `attr('boolean', { allowNull: true })`
|
|
149
139
|
|
|
150
|
-
```app/models/user.js
|
|
140
|
+
```js [app/models/user.js]
|
|
151
141
|
import Model, { attr } from '@ember-data-mirror/model';
|
|
152
142
|
|
|
153
143
|
export default class UserModel extends Model {
|
|
@@ -186,10 +176,6 @@ class BooleanTransform {
|
|
|
186
176
|
}
|
|
187
177
|
}
|
|
188
178
|
|
|
189
|
-
/**
|
|
190
|
-
@module @ember-data-mirror/serializer
|
|
191
|
-
*/
|
|
192
|
-
|
|
193
179
|
/**
|
|
194
180
|
The `DateTransform` class is used to serialize and deserialize
|
|
195
181
|
date attributes on Ember Data record objects. This transform is used
|
|
@@ -197,7 +183,7 @@ class BooleanTransform {
|
|
|
197
183
|
[attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function. It uses the [`ISO 8601`](https://en.wikipedia.org/wiki/ISO_8601)
|
|
198
184
|
standard.
|
|
199
185
|
|
|
200
|
-
```app/models/score.js
|
|
186
|
+
```js [app/models/score.js]
|
|
201
187
|
import Model, { attr, belongsTo } from '@ember-data-mirror/model';
|
|
202
188
|
|
|
203
189
|
export default class ScoreModel extends Model {
|
|
@@ -243,11 +229,6 @@ class DateTransform {
|
|
|
243
229
|
return new this();
|
|
244
230
|
}
|
|
245
231
|
}
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
@module @ember-data-mirror/serializer
|
|
249
|
-
*/
|
|
250
|
-
|
|
251
232
|
function isNumber(value) {
|
|
252
233
|
return value === value && value !== Infinity && value !== -Infinity;
|
|
253
234
|
}
|
|
@@ -260,7 +241,7 @@ function isNumber(value) {
|
|
|
260
241
|
|
|
261
242
|
Usage
|
|
262
243
|
|
|
263
|
-
```app/models/score.js
|
|
244
|
+
```js [app/models/score.js]
|
|
264
245
|
import Model, { attr, belongsTo } from '@ember-data-mirror/model';
|
|
265
246
|
|
|
266
247
|
export default class ScoreModel extends Model {
|
|
@@ -296,10 +277,6 @@ class NumberTransform {
|
|
|
296
277
|
}
|
|
297
278
|
}
|
|
298
279
|
|
|
299
|
-
/**
|
|
300
|
-
@module @ember-data-mirror/serializer
|
|
301
|
-
*/
|
|
302
|
-
|
|
303
280
|
/**
|
|
304
281
|
The `StringTransform` class is used to serialize and deserialize
|
|
305
282
|
string attributes on Ember Data record objects. This transform is
|
|
@@ -308,7 +285,7 @@ class NumberTransform {
|
|
|
308
285
|
|
|
309
286
|
Usage
|
|
310
287
|
|
|
311
|
-
```app/models/user.js
|
|
288
|
+
```js [app/models/user.js]
|
|
312
289
|
import Model, { attr, belongsTo } from '@ember-data-mirror/model';
|
|
313
290
|
|
|
314
291
|
export default class UserModel extends Model {
|
package/dist/transform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sources":["../src/-private/transforms/transform.ts","../src/-private/transforms/boolean.ts","../src/-private/transforms/date.ts","../src/-private/transforms/number.ts","../src/-private/transforms/string.ts"],"sourcesContent":["/**\n @module @ember-data-mirror/serializer\n*/\nimport EmberObject from '@ember/object';\n\nimport type { LegacyAttributeField } from '@warp-drive-mirror/core-types/schema/fields';\n\n/**\n The `Transform` class is used to serialize and deserialize model\n attributes when they are saved or loaded from an\n adapter. Subclassing `Transform` is useful for creating custom\n attributes. All subclasses of `Transform` must implement a\n `serialize` and a `deserialize` method.\n\n Example\n\n ```app/transforms/temperature.js\n\n // Converts centigrade in the JSON to fahrenheit in the app\n export default class TemperatureTransform {\n deserialize(serialized, options) {\n return (serialized * 1.8) + 32;\n }\n\n serialize(deserialized, options) {\n return (deserialized - 32) / 1.8;\n }\n\n static create() {\n return new this();\n }\n }\n ```\n\n Usage\n\n ```app/models/requirement.js\n import Model, { attr } from '@ember-data-mirror/model';\n\n export default class RequirementModel extends Model {\n @attr('string') name;\n @attr('temperature') temperature;\n }\n ```\n\n The options passed into the `attr` function when the attribute is\n declared on the model is also available in the transform.\n\n ```app/models/post.js\n import Model, { attr } from '@ember-data-mirror/model';\n\n export default class PostModel extends Model {\n @attr('string') title;\n @attr('markdown', {\n markdown: {\n gfm: false,\n sanitize: true\n }\n })\n markdown;\n }\n ```\n\n ```app/transforms/markdown.js\n export default class MarkdownTransform {\n serialize(deserialized, options) {\n return deserialized.raw;\n }\n\n deserialize(serialized, options) {\n let markdownOptions = options.markdown || {};\n\n return marked(serialized, markdownOptions);\n }\n\n static create() {\n return new this();\n }\n }\n ```\n\n @class Transform\n @public\n */\n/**\n When given a deserialized value from a record attribute this\n method must return the serialized value.\n\n Example\n\n ```javascript\n serialize(deserialized, options) {\n return deserialized ? null : Number(deserialized);\n }\n ```\n\n @method serialize\n @public\n @param deserialized The deserialized value\n @param options hash of options passed to `attr`\n @return The serialized value\n*/\n/**\n When given a serialized value from a JSON object this method must\n return the deserialized value for the record attribute.\n\n Example\n\n ```javascript\n deserialize(serialized, options) {\n return empty(serialized) ? null : Number(serialized);\n }\n ```\n\n @method deserialize\n @public\n @param serialized The serialized value\n @param options hash of options passed to `attr`\n @return The deserialized value\n*/\nexport interface Transform {\n serialize(value: unknown, options: LegacyAttributeField['options']): unknown;\n deserialize(value: unknown, options: LegacyAttributeField['options']): unknown;\n}\nexport const Transform = EmberObject;\n","/**\n @module @ember-data-mirror/serializer\n*/\n\nimport type { TransformName } from '@warp-drive-mirror/core-types/symbols';\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-mirror/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-mirror/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 class BooleanTransform {\n deserialize(serialized: boolean | null | number | string, options?: { allowNull?: boolean }): boolean | null {\n if ((serialized === null || serialized === undefined) && options?.allowNull === true) {\n return null;\n }\n\n if (typeof serialized === 'boolean') {\n return serialized;\n } else if (typeof serialized === 'string') {\n return /^(true|t|1)$/i.test(serialized);\n } else if (typeof serialized === 'number') {\n return serialized === 1;\n } else {\n return false;\n }\n }\n\n serialize(deserialized: boolean | null, options?: { allowNull?: boolean }): boolean | null {\n if ((deserialized === null || deserialized === undefined) && options?.allowNull === true) {\n return null;\n }\n\n return Boolean(deserialized);\n }\n\n declare [TransformName]: 'boolean';\n\n static create() {\n return new this();\n }\n}\n","/**\n @module @ember-data-mirror/serializer\n*/\n\nimport { TransformName } from '@warp-drive-mirror/core-types/symbols';\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-mirror/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 class DateTransform {\n deserialize(serialized: string | number | null, _options?: Record<string, unknown>) {\n if (typeof serialized === '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 (typeof serialized === '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: Date, _options?: Record<string, unknown>): string | null {\n // @ts-expect-error isNaN accepts date as it is coercible\n if (date instanceof Date && !isNaN(date)) {\n return date.toISOString();\n } else {\n return null;\n }\n }\n\n [TransformName] = 'date' as const;\n\n static create() {\n return new this();\n }\n}\n","/**\n @module @ember-data-mirror/serializer\n*/\n\nimport { TransformName } from '@warp-drive-mirror/core-types/symbols';\n\nfunction isNumber(value: number) {\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-mirror/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 class NumberTransform {\n deserialize(serialized: string | number | null | undefined, _options?: Record<string, unknown>): number | null {\n if (serialized === '' || serialized === null || serialized === undefined) {\n return null;\n } else {\n const transformed = Number(serialized);\n\n return isNumber(transformed) ? transformed : null;\n }\n }\n\n serialize(deserialized: string | number | null | undefined, _options?: Record<string, unknown>): number | null {\n if (deserialized === '' || deserialized === null || deserialized === undefined) {\n return null;\n } else {\n const transformed = Number(deserialized);\n\n return isNumber(transformed) ? transformed : null;\n }\n }\n\n [TransformName] = 'number' as const;\n\n static create() {\n return new this();\n }\n}\n","/**\n @module @ember-data-mirror/serializer\n*/\n\nimport { TransformName } from '@warp-drive-mirror/core-types/symbols';\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-mirror/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 class StringTransform {\n deserialize(serialized: unknown, _options?: Record<string, unknown>): string | null {\n return !serialized && serialized !== '' ? null : String(serialized);\n }\n serialize(deserialized: unknown, _options?: Record<string, unknown>): string | null {\n return !deserialized && deserialized !== '' ? null : String(deserialized);\n }\n\n [TransformName] = 'string' as const;\n\n static create() {\n return new this();\n }\n}\n"],"names":["Transform","EmberObject","BooleanTransform","deserialize","serialized","options","undefined","allowNull","test","serialize","deserialized","Boolean","create","DateTransform","_options","offset","indexOf","length","Date","slice","date","isNaN","toISOString","TransformName","isNumber","value","Infinity","NumberTransform","transformed","Number","StringTransform","String"],"mappings":";;;AAAA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAKO,MAAMA,SAAS,GAAGC;;AC5HzB;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMC,gBAAgB,CAAC;AAC5BC,EAAAA,WAAWA,CAACC,UAA4C,EAAEC,OAAiC,EAAkB;AAC3G,IAAA,IAAI,CAACD,UAAU,KAAK,IAAI,IAAIA,UAAU,KAAKE,SAAS,KAAKD,OAAO,EAAEE,SAAS,KAAK,IAAI,EAAE;AACpF,MAAA,OAAO,IAAI;AACb;AAEA,IAAA,IAAI,OAAOH,UAAU,KAAK,SAAS,EAAE;AACnC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B;IAC7G,IAAIJ,YAAY,KAAK,EAAE,IAAIA,YAAY,KAAK,IAAI,IAAIA,YAAY,KAAKJ,SAAS,EAAE;AAC9E,MAAA,OAAO,IAAI;AACb,KAAC,MAAM;AACL,MAAA,MAAMsB,WAAW,GAAGC,MAAM,CAACnB,YAAY,CAAC;AAExC,MAAA,OAAOc,QAAQ,CAACI,WAAW,CAAC,GAAGA,WAAW,GAAG,IAAI;AACnD;AACF;EAEA,CAACL,aAAa,IAAI,QAAQ;EAE1B,OAAOX,MAAMA,GAAG;IACd,OAAO,IAAI,IAAI,EAAE;AACnB;AACF;;ACzDA;AACA;AACA;;;AAIA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMkB,eAAe,CAAC;AAC3B3B,EAAAA,WAAWA,CAACC,UAAmB,EAAEU,QAAkC,EAAiB;AAClF,IAAA,OAAO,CAACV,UAAU,IAAIA,UAAU,KAAK,EAAE,GAAG,IAAI,GAAG2B,MAAM,CAAC3B,UAAU,CAAC;AACrE;AACAK,EAAAA,SAASA,CAACC,YAAqB,EAAEI,QAAkC,EAAiB;AAClF,IAAA,OAAO,CAACJ,YAAY,IAAIA,YAAY,KAAK,EAAE,GAAG,IAAI,GAAGqB,MAAM,CAACrB,YAAY,CAAC;AAC3E;EAEA,CAACa,aAAa,IAAI,QAAQ;EAE1B,OAAOX,MAAMA,GAAG;IACd,OAAO,IAAI,IAAI,EAAE;AACnB;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"transform.js","sources":["../src/-private/transforms/transform.ts","../src/-private/transforms/boolean.ts","../src/-private/transforms/date.ts","../src/-private/transforms/number.ts","../src/-private/transforms/string.ts"],"sourcesContent":["import EmberObject from '@ember/object';\n\nimport type { LegacyAttributeField } from '@warp-drive-mirror/core-types/schema/fields';\n\n/**\n The `Transform` class is used to serialize and deserialize model\n attributes when they are saved or loaded from an\n adapter. Subclassing `Transform` is useful for creating custom\n attributes. All subclasses of `Transform` must implement a\n `serialize` and a `deserialize` method.\n\n Example\n\n ```js [app/transforms/temperature.js]\n\n // Converts centigrade in the JSON to fahrenheit in the app\n export default class TemperatureTransform {\n deserialize(serialized, options) {\n return (serialized * 1.8) + 32;\n }\n\n serialize(deserialized, options) {\n return (deserialized - 32) / 1.8;\n }\n\n static create() {\n return new this();\n }\n }\n ```\n\n Usage\n\n ```js [app/models/requirement.js]\n import Model, { attr } from '@ember-data-mirror/model';\n\n export default class RequirementModel extends Model {\n @attr('string') name;\n @attr('temperature') temperature;\n }\n ```\n\n The options passed into the `attr` function when the attribute is\n declared on the model is also available in the transform.\n\n ```js [app/models/post.js]\n import Model, { attr } from '@ember-data-mirror/model';\n\n export default class PostModel extends Model {\n @attr('string') title;\n @attr('markdown', {\n markdown: {\n gfm: false,\n sanitize: true\n }\n })\n markdown;\n }\n ```\n\n ```js [app/transforms/markdown.js]\n export default class MarkdownTransform {\n serialize(deserialized, options) {\n return deserialized.raw;\n }\n\n deserialize(serialized, options) {\n let markdownOptions = options.markdown || {};\n\n return marked(serialized, markdownOptions);\n }\n\n static create() {\n return new this();\n }\n }\n ```\n\n @class Transform\n @public\n */\n/**\n When given a deserialized value from a record attribute this\n method must return the serialized value.\n\n Example\n\n ```javascript\n serialize(deserialized, options) {\n return deserialized ? null : Number(deserialized);\n }\n ```\n\n @public\n @param deserialized The deserialized value\n @param options hash of options passed to `attr`\n @return The serialized value\n*/\n/**\n When given a serialized value from a JSON object this method must\n return the deserialized value for the record attribute.\n\n Example\n\n ```javascript\n deserialize(serialized, options) {\n return empty(serialized) ? null : Number(serialized);\n }\n ```\n\n @public\n @param serialized The serialized value\n @param options hash of options passed to `attr`\n @return The deserialized value\n*/\nexport interface Transform {\n serialize(value: unknown, options: LegacyAttributeField['options']): unknown;\n deserialize(value: unknown, options: LegacyAttributeField['options']): unknown;\n}\nexport const Transform = EmberObject;\n","import type { TransformName } from '@warp-drive-mirror/core-types/symbols';\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 ```js [app/models/user.js]\n import Model, { attr } from '@ember-data-mirror/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 ```js [app/models/user.js]\n import Model, { attr } from '@ember-data-mirror/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 class BooleanTransform {\n deserialize(serialized: boolean | null | number | string, options?: { allowNull?: boolean }): boolean | null {\n if ((serialized === null || serialized === undefined) && options?.allowNull === true) {\n return null;\n }\n\n if (typeof serialized === 'boolean') {\n return serialized;\n } else if (typeof serialized === 'string') {\n return /^(true|t|1)$/i.test(serialized);\n } else if (typeof serialized === 'number') {\n return serialized === 1;\n } else {\n return false;\n }\n }\n\n serialize(deserialized: boolean | null, options?: { allowNull?: boolean }): boolean | null {\n if ((deserialized === null || deserialized === undefined) && options?.allowNull === true) {\n return null;\n }\n\n return Boolean(deserialized);\n }\n\n declare [TransformName]: 'boolean';\n\n static create() {\n return new this();\n }\n}\n","import { TransformName } from '@warp-drive-mirror/core-types/symbols';\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 ```js [app/models/score.js]\n import Model, { attr, belongsTo } from '@ember-data-mirror/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 class DateTransform {\n deserialize(serialized: string | number | null, _options?: Record<string, unknown>) {\n if (typeof serialized === '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 (typeof serialized === '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: Date, _options?: Record<string, unknown>): string | null {\n // @ts-expect-error isNaN accepts date as it is coercible\n if (date instanceof Date && !isNaN(date)) {\n return date.toISOString();\n } else {\n return null;\n }\n }\n\n [TransformName] = 'date' as const;\n\n static create() {\n return new this();\n }\n}\n","import { TransformName } from '@warp-drive-mirror/core-types/symbols';\n\nfunction isNumber(value: number) {\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 ```js [app/models/score.js]\n import Model, { attr, belongsTo } from '@ember-data-mirror/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 class NumberTransform {\n deserialize(serialized: string | number | null | undefined, _options?: Record<string, unknown>): number | null {\n if (serialized === '' || serialized === null || serialized === undefined) {\n return null;\n } else {\n const transformed = Number(serialized);\n\n return isNumber(transformed) ? transformed : null;\n }\n }\n\n serialize(deserialized: string | number | null | undefined, _options?: Record<string, unknown>): number | null {\n if (deserialized === '' || deserialized === null || deserialized === undefined) {\n return null;\n } else {\n const transformed = Number(deserialized);\n\n return isNumber(transformed) ? transformed : null;\n }\n }\n\n [TransformName] = 'number' as const;\n\n static create() {\n return new this();\n }\n}\n","import { TransformName } from '@warp-drive-mirror/core-types/symbols';\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 ```js [app/models/user.js]\n import Model, { attr, belongsTo } from '@ember-data-mirror/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 class StringTransform {\n deserialize(serialized: unknown, _options?: Record<string, unknown>): string | null {\n return !serialized && serialized !== '' ? null : String(serialized);\n }\n serialize(deserialized: unknown, _options?: Record<string, unknown>): string | null {\n return !deserialized && deserialized !== '' ? null : String(deserialized);\n }\n\n [TransformName] = 'string' as const;\n\n static create() {\n return new this();\n }\n}\n"],"names":["Transform","EmberObject","BooleanTransform","deserialize","serialized","options","undefined","allowNull","test","serialize","deserialized","Boolean","create","DateTransform","_options","offset","indexOf","length","Date","slice","date","isNaN","toISOString","TransformName","isNumber","value","Infinity","NumberTransform","transformed","Number","StringTransform","String"],"mappings":";;;AAIA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAKO,MAAMA,SAAS,GAAGC;;ACrHzB;AACA;AAC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