@ember-data/serializer 4.12.0-beta.1 → 4.12.0-beta.11

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.
Files changed (37) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +82 -16
  3. package/addon/-private.js +23 -16
  4. package/addon/-private.js.map +1 -1
  5. package/addon/{embedded-records-mixin-0a9e9148.js → embedded-records-mixin-d75385ff.js} +1 -2
  6. package/addon/embedded-records-mixin-d75385ff.js.map +1 -0
  7. package/addon/index.js +4 -2
  8. package/addon/index.js.map +1 -1
  9. package/addon/json-api.js +18 -14
  10. package/addon/json-api.js.map +1 -1
  11. package/addon/json.js +17 -14
  12. package/addon/json.js.map +1 -1
  13. package/addon/rest.js +13 -6
  14. package/addon/rest.js.map +1 -1
  15. package/addon/transform.js +3 -4
  16. package/addon/transform.js.map +1 -1
  17. package/addon-main.js +18 -15
  18. package/blueprints/serializer/files/__root__/__path__/__name__.js +4 -0
  19. package/blueprints/serializer/index.js +14 -0
  20. package/blueprints/serializer/native-files/__root__/__path__/__name__.js +4 -0
  21. package/blueprints/serializer-test/index.js +29 -0
  22. package/blueprints/serializer-test/mocha-files/__root__/__path__/__test__.js +20 -0
  23. package/blueprints/serializer-test/mocha-rfc-232-files/__root__/__path__/__test__.js +25 -0
  24. package/blueprints/serializer-test/qunit-files/__root__/__path__/__test__.js +24 -0
  25. package/blueprints/transform/files/__root__/__path__/__name__.js +13 -0
  26. package/blueprints/transform/index.js +7 -0
  27. package/blueprints/transform/native-files/__root__/__path__/__name__.js +13 -0
  28. package/blueprints/transform-test/index.js +29 -0
  29. package/blueprints/transform-test/mocha-files/__root__/__path__/__test__.js +17 -0
  30. package/blueprints/transform-test/mocha-rfc-232-files/__root__/__path__/__test__.js +14 -0
  31. package/blueprints/transform-test/qunit-files/__root__/__path__/__test__.js +13 -0
  32. package/ember-data-logo-dark.svg +12 -0
  33. package/ember-data-logo-light.svg +12 -0
  34. package/package.json +23 -21
  35. package/addon/embedded-records-mixin-0a9e9148.js.map +0 -1
  36. package/addon/transform-63fba437.js +0 -112
  37. package/addon/transform-63fba437.js.map +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ember-data/serializer",
3
- "version": "4.12.0-beta.1",
4
- "description": "Provides reference Serializer implementations for use with @ember-data/store",
3
+ "version": "4.12.0-beta.11",
4
+ "description": "Provides Legacy JSON, JSON:API and REST Implementations of the Serializer Interface for use with @ember-data/store",
5
5
  "keywords": [
6
6
  "ember-addon"
7
7
  ],
@@ -19,56 +19,58 @@
19
19
  "version": 1
20
20
  },
21
21
  "files": [
22
+ "blueprints",
22
23
  "addon-main.js",
23
- "addon"
24
+ "addon",
25
+ "README.md",
26
+ "LICENSE.md",
27
+ "ember-data-logo-dark.svg",
28
+ "ember-data-logo-light.svg"
24
29
  ],
25
30
  "peerDependencies": {
26
- "@ember-data/store": "4.12.0-beta.1",
31
+ "@ember-data/store": "4.12.0-beta.11",
27
32
  "@ember/string": "^3.0.1",
28
33
  "ember-inflector": "^4.0.2"
29
34
  },
30
35
  "dependenciesMeta": {
31
- "@ember-data/canary-features": {
32
- "injected": true
33
- },
34
36
  "@ember-data/private-build-infra": {
35
37
  "injected": true
36
38
  }
37
39
  },
38
40
  "dependencies": {
39
- "@ember-data/private-build-infra": "4.12.0-beta.1",
41
+ "@ember-data/private-build-infra": "4.12.0-beta.11",
40
42
  "@embroider/macros": "^1.10.0",
41
43
  "ember-cli-babel": "^7.26.11",
42
44
  "ember-cli-test-info": "^1.0.0"
43
45
  },
44
46
  "devDependencies": {
45
- "@babel/core": "^7.21.0",
47
+ "@babel/core": "^7.21.4",
46
48
  "@babel/cli": "^7.21.0",
47
49
  "@glimmer/component": "^1.1.2",
48
- "ember-source": "~4.11.0",
49
- "@embroider/addon-dev": "^2.0.0",
50
- "rollup": "^3.17.2",
50
+ "ember-source": "~4.12.0",
51
+ "@embroider/addon-dev": "^3.0.0",
52
+ "rollup": "^3.20.2",
51
53
  "@babel/plugin-proposal-class-properties": "^7.18.6",
52
54
  "@babel/plugin-proposal-private-methods": "^7.18.6",
53
55
  "@babel/plugin-proposal-decorators": "^7.21.0",
54
- "@babel/plugin-transform-typescript": "^7.21.0",
55
- "@babel/plugin-transform-runtime": "^7.21.0",
56
- "@babel/preset-typescript": "^7.21.0",
57
- "@babel/preset-env": "^7.20.2",
56
+ "@babel/plugin-transform-typescript": "^7.21.3",
57
+ "@babel/plugin-transform-runtime": "^7.21.4",
58
+ "@babel/preset-typescript": "^7.21.4",
59
+ "@babel/preset-env": "^7.21.4",
58
60
  "@babel/runtime": "^7.21.0",
59
61
  "@rollup/plugin-babel": "^6.0.3",
60
- "@rollup/plugin-node-resolve": "^15.0.1",
61
- "tslib": "^2.4.1",
62
+ "@rollup/plugin-node-resolve": "^15.0.2",
63
+ "tslib": "^2.5.0",
62
64
  "walk-sync": "^3.0.0",
63
- "typescript": "^4.9.5"
65
+ "typescript": "^5.0.3"
64
66
  },
65
67
  "engines": {
66
- "node": "^14.8.0 || 16.* || >= 18.*"
68
+ "node": "16.* || >= 18.*"
67
69
  },
68
70
  "volta": {
69
71
  "extends": "../../package.json"
70
72
  },
71
- "packageManager": "pnpm@7.27.1",
73
+ "packageManager": "pnpm@8.1.0",
72
74
  "scripts": {
73
75
  "build": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
74
76
  "start": "rollup --config --watch"
@@ -1 +0,0 @@
1
- {"version":3,"file":"embedded-records-mixin-0a9e9148.js","sources":["../src/-private/embedded-records-mixin.js"],"sourcesContent":["import { A } from '@ember/array';\nimport { warn } from '@ember/debug';\nimport Mixin from '@ember/object/mixin';\nimport { camelize } from '@ember/string';\nimport { typeOf } from '@ember/utils';\n\n/**\n @module @ember-data/serializer/rest\n*/\n\n/**\n ## Using Embedded Records\n\n `EmbeddedRecordsMixin` supports serializing embedded records.\n\n To set up embedded records, include the mixin when extending a serializer,\n then define and configure embedded (model) relationships.\n\n Note that embedded records will serialize with the serializer for their model instead of the serializer in which they are defined.\n\n Note also that this mixin does not work with JSONAPISerializer because the JSON:API specification does not describe how to format embedded resources.\n\n Below is an example of a per-type serializer (`post` type).\n\n ```app/serializers/post.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n author: { embedded: 'always' },\n comments: { serialize: 'ids' }\n }\n }\n ```\n Note that this use of `{ embedded: 'always' }` is unrelated to\n the `{ embedded: 'always' }` that is defined as an option on `attr` as part of\n defining a model while working with the `ActiveModelSerializer`. Nevertheless,\n using `{ embedded: 'always' }` as an option to `attr` is not a valid way to set up\n embedded records.\n\n The `attrs` option for a resource `{ embedded: 'always' }` is shorthand for:\n\n ```js\n {\n serialize: 'records',\n deserialize: 'records'\n }\n ```\n\n ### Configuring Attrs\n\n A resource's `attrs` option may be set to use `ids`, `records` or false for the\n `serialize` and `deserialize` settings.\n\n The `attrs` property can be set on the `ApplicationSerializer` or a per-type\n serializer.\n\n In the case where embedded JSON is expected while extracting a payload (reading)\n the setting is `deserialize: 'records'`, there is no need to use `ids` when\n extracting as that is the default behaviour without this mixin if you are using\n the vanilla `EmbeddedRecordsMixin`. Likewise, to embed JSON in the payload while\n serializing `serialize: 'records'` is the setting to use. There is an option of\n not embedding JSON in the serialized payload by using `serialize: 'ids'`. If you\n do not want the relationship sent at all, you can use `serialize: false`.\n\n\n ### EmbeddedRecordsMixin defaults\n If you do not overwrite `attrs` for a specific relationship, the `EmbeddedRecordsMixin`\n will behave in the following way:\n\n BelongsTo: `{ serialize: 'id', deserialize: 'id' }`\n HasMany: `{ serialize: false, deserialize: 'ids' }`\n\n ### Model Relationships\n\n Embedded records must have a model defined to be extracted and serialized. Note that\n when defining any relationships on your model such as `belongsTo` and `hasMany`, you\n should not both specify `async: true` and also indicate through the serializer's\n `attrs` attribute that the related model should be embedded for deserialization.\n If a model is declared embedded for deserialization (`embedded: 'always'` or `deserialize: 'records'`),\n then do not use `async: true`.\n\n To successfully extract and serialize embedded records the model relationships\n must be set up correctly. See the\n [defining relationships](https://guides.emberjs.com/current/models/relationships)\n section of the **Defining Models** guide page.\n\n Records without an `id` property are not considered embedded records, model\n instances must have an `id` property to be used with Ember Data.\n\n ### Example JSON payloads, Models and Serializers\n\n **When customizing a serializer it is important to grok what the customizations\n are. Please read the docs for the methods this mixin provides, in case you need\n to modify it to fit your specific needs.**\n\n For example, review the docs for each method of this mixin:\n * [normalize](/ember-data/release/classes/EmbeddedRecordsMixin/methods/normalize?anchor=normalize)\n * [serializeBelongsTo](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeBelongsTo?anchor=serializeBelongsTo)\n * [serializeHasMany](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeHasMany?anchor=serializeHasMany)\n\n @class EmbeddedRecordsMixin\n @public\n*/\nexport default Mixin.create({\n /**\n Normalize the record and recursively normalize/extract all the embedded records\n while pushing them into the store as they are encountered\n\n A payload with an attr configured for embedded records needs to be extracted:\n\n ```js\n {\n \"post\": {\n \"id\": \"1\"\n \"title\": \"Rails is omakase\",\n \"comments\": [{\n \"id\": \"1\",\n \"body\": \"Rails is unagi\"\n }, {\n \"id\": \"2\",\n \"body\": \"Omakase O_o\"\n }]\n }\n }\n ```\n @method normalize\n @public\n @param {Model} typeClass\n @param {Object} hash to be normalized\n @param {String} prop the hash has been referenced by\n @return {Object} the normalized hash\n **/\n normalize(typeClass, hash, prop) {\n let normalizedHash = this._super(typeClass, hash, prop);\n return this._extractEmbeddedRecords(this, this.store, typeClass, normalizedHash);\n },\n\n keyForRelationship(key, typeClass, method) {\n if (\n (method === 'serialize' && this.hasSerializeRecordsOption(key)) ||\n (method === 'deserialize' && this.hasDeserializeRecordsOption(key))\n ) {\n return this.keyForAttribute(key, method);\n } else {\n return this._super(key, typeClass, method) || key;\n }\n },\n\n /**\n Serialize `belongsTo` relationship when it is configured as an embedded object.\n\n This example of an author model belongs to a post model:\n\n ```js\n import Model, { attr, belongsTo } from '@ember-data/model';\n\n Post = Model.extend({\n title: attr('string'),\n body: attr('string'),\n author: belongsTo('author')\n });\n\n Author = Model.extend({\n name: attr('string'),\n post: belongsTo('post')\n });\n ```\n\n Use a custom (type) serializer for the post model to configure embedded author\n\n ```app/serializers/post.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n author: { embedded: 'always' }\n }\n }\n ```\n\n A payload with an attribute configured for embedded records can serialize\n the records together under the root attribute's payload:\n\n ```js\n {\n \"post\": {\n \"id\": \"1\"\n \"title\": \"Rails is omakase\",\n \"author\": {\n \"id\": \"2\"\n \"name\": \"dhh\"\n }\n }\n }\n ```\n\n @method serializeBelongsTo\n @public\n @param {Snapshot} snapshot\n @param {Object} json\n @param {Object} relationship\n */\n serializeBelongsTo(snapshot, json, relationship) {\n let attr = relationship.key;\n if (this.noSerializeOptionSpecified(attr)) {\n this._super(snapshot, json, relationship);\n return;\n }\n let includeIds = this.hasSerializeIdsOption(attr);\n let includeRecords = this.hasSerializeRecordsOption(attr);\n let embeddedSnapshot = snapshot.belongsTo(attr);\n if (includeIds) {\n let schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.key, schema);\n if (serializedKey === relationship.key && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');\n }\n\n if (!embeddedSnapshot) {\n json[serializedKey] = null;\n } else {\n json[serializedKey] = embeddedSnapshot.id;\n\n if (relationship.options.polymorphic) {\n this.serializePolymorphicType(snapshot, json, relationship);\n }\n }\n } else if (includeRecords) {\n this._serializeEmbeddedBelongsTo(snapshot, json, relationship);\n }\n },\n\n _serializeEmbeddedBelongsTo(snapshot, json, relationship) {\n let embeddedSnapshot = snapshot.belongsTo(relationship.key);\n let schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.key, schema);\n if (serializedKey === relationship.key && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');\n }\n\n if (!embeddedSnapshot) {\n json[serializedKey] = null;\n } else {\n json[serializedKey] = embeddedSnapshot.serialize({ includeId: true });\n this.removeEmbeddedForeignKey(snapshot, embeddedSnapshot, relationship, json[serializedKey]);\n\n if (relationship.options.polymorphic) {\n this.serializePolymorphicType(snapshot, json, relationship);\n }\n }\n },\n\n /**\n Serializes `hasMany` relationships when it is configured as embedded objects.\n\n This example of a post model has many comments:\n\n ```js\n import Model, { attr, belongsTo, hasMany } from '@ember-data/model';\n\n Post = Model.extend({\n title: attr('string'),\n body: attr('string'),\n comments: hasMany('comment')\n });\n\n Comment = Model.extend({\n body: attr('string'),\n post: belongsTo('post')\n });\n ```\n\n Use a custom (type) serializer for the post model to configure embedded comments\n\n ```app/serializers/post.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n comments: { embedded: 'always' }\n }\n }\n ```\n\n A payload with an attribute configured for embedded records can serialize\n the records together under the root attribute's payload:\n\n ```js\n {\n \"post\": {\n \"id\": \"1\"\n \"title\": \"Rails is omakase\",\n \"body\": \"I want this for my ORM, I want that for my template language...\"\n \"comments\": [{\n \"id\": \"1\",\n \"body\": \"Rails is unagi\"\n }, {\n \"id\": \"2\",\n \"body\": \"Omakase O_o\"\n }]\n }\n }\n ```\n\n The attrs options object can use more specific instruction for extracting and\n serializing. When serializing, an option to embed `ids`, `ids-and-types` or `records` can be set.\n When extracting the only option is `records`.\n\n So `{ embedded: 'always' }` is shorthand for:\n `{ serialize: 'records', deserialize: 'records' }`\n\n To embed the `ids` for a related object (using a hasMany relationship):\n\n ```app/serializers/post.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n comments: { serialize: 'ids', deserialize: 'records' }\n }\n }\n ```\n\n ```js\n {\n \"post\": {\n \"id\": \"1\"\n \"title\": \"Rails is omakase\",\n \"body\": \"I want this for my ORM, I want that for my template language...\"\n \"comments\": [\"1\", \"2\"]\n }\n }\n ```\n\n To embed the relationship as a collection of objects with `id` and `type` keys, set\n `ids-and-types` for the related object.\n\n This is particularly useful for polymorphic relationships where records don't share\n the same table and the `id` is not enough information.\n\n For example having a user that has many pets:\n\n ```js\n User = Model.extend({\n name: attr('string'),\n pets: hasMany('pet', { polymorphic: true })\n });\n\n Pet = Model.extend({\n name: attr('string'),\n });\n\n Cat = Pet.extend({\n // ...\n });\n\n Parrot = Pet.extend({\n // ...\n });\n ```\n\n ```app/serializers/user.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class UserSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n pets: { serialize: 'ids-and-types', deserialize: 'records' }\n }\n }\n ```\n\n ```js\n {\n \"user\": {\n \"id\": \"1\"\n \"name\": \"Bertin Osborne\",\n \"pets\": [\n { \"id\": \"1\", \"type\": \"Cat\" },\n { \"id\": \"1\", \"type\": \"Parrot\"}\n ]\n }\n }\n ```\n\n @method serializeHasMany\n @public\n @param {Snapshot} snapshot\n @param {Object} json\n @param {Object} relationship\n */\n serializeHasMany(snapshot, json, relationship) {\n let attr = relationship.key;\n if (this.noSerializeOptionSpecified(attr)) {\n this._super(snapshot, json, relationship);\n return;\n }\n\n if (this.hasSerializeIdsOption(attr)) {\n let schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.key, schema);\n if (serializedKey === relationship.key && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');\n }\n\n json[serializedKey] = snapshot.hasMany(attr, { ids: true });\n } else if (this.hasSerializeRecordsOption(attr)) {\n this._serializeEmbeddedHasMany(snapshot, json, relationship);\n } else {\n if (this.hasSerializeIdsAndTypesOption(attr)) {\n this._serializeHasManyAsIdsAndTypes(snapshot, json, relationship);\n }\n }\n },\n\n /*\n Serializes a hasMany relationship as an array of objects containing only `id` and `type`\n keys.\n This has its use case on polymorphic hasMany relationships where the server is not storing\n all records in the same table using STI, and therefore the `id` is not enough information\n\n TODO: Make the default in Ember-data 3.0??\n */\n _serializeHasManyAsIdsAndTypes(snapshot, json, relationship) {\n let serializedKey = this.keyForAttribute(relationship.key, 'serialize');\n let hasMany = snapshot.hasMany(relationship.key);\n\n json[serializedKey] = A(hasMany).map(function (recordSnapshot) {\n //\n // I'm sure I'm being utterly naive here. Probably id is a configurable property and\n // type too, and the modelName has to be normalized somehow.\n //\n return { id: recordSnapshot.id, type: recordSnapshot.modelName };\n });\n },\n\n _serializeEmbeddedHasMany(snapshot, json, relationship) {\n let schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.key, schema);\n if (serializedKey === relationship.key && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');\n }\n\n warn(\n `The embedded relationship '${serializedKey}' is undefined for '${snapshot.modelName}' with id '${snapshot.id}'. Please include it in your original payload.`,\n typeOf(snapshot.hasMany(relationship.key)) !== 'undefined',\n { id: 'ds.serializer.embedded-relationship-undefined' }\n );\n\n json[serializedKey] = this._generateSerializedHasMany(snapshot, relationship);\n },\n\n /*\n Returns an array of embedded records serialized to JSON\n */\n _generateSerializedHasMany(snapshot, relationship) {\n let hasMany = snapshot.hasMany(relationship.key);\n let manyArray = A(hasMany);\n let ret = new Array(manyArray.length);\n\n for (let i = 0; i < manyArray.length; i++) {\n let embeddedSnapshot = manyArray[i];\n let embeddedJson = embeddedSnapshot.serialize({ includeId: true });\n this.removeEmbeddedForeignKey(snapshot, embeddedSnapshot, relationship, embeddedJson);\n ret[i] = embeddedJson;\n }\n\n return ret;\n },\n\n /**\n When serializing an embedded record, modify the property (in the `JSON` payload)\n that refers to the parent record (foreign key for the relationship).\n\n Serializing a `belongsTo` relationship removes the property that refers to the\n parent record\n\n Serializing a `hasMany` relationship does not remove the property that refers to\n the parent record.\n\n @method removeEmbeddedForeignKey\n @public\n @param {Snapshot} snapshot\n @param {Snapshot} embeddedSnapshot\n @param {Object} relationship\n @param {Object} json\n */\n removeEmbeddedForeignKey(snapshot, embeddedSnapshot, relationship, json) {\n if (relationship.kind === 'belongsTo') {\n let schema = this.store.modelFor(snapshot.modelName);\n let parentRecord = schema.inverseFor(relationship.key, this.store);\n if (parentRecord) {\n let name = parentRecord.name;\n let embeddedSerializer = this.store.serializerFor(embeddedSnapshot.modelName);\n let parentKey = embeddedSerializer.keyForRelationship(name, parentRecord.kind, 'deserialize');\n if (parentKey) {\n delete json[parentKey];\n }\n }\n } /*else if (relationship.kind === 'hasMany') {\n return;\n }*/\n },\n\n // checks config for attrs option to embedded (always) - serialize and deserialize\n hasEmbeddedAlwaysOption(attr) {\n let option = this.attrsOption(attr);\n return option && option.embedded === 'always';\n },\n\n // checks config for attrs option to serialize ids\n hasSerializeRecordsOption(attr) {\n let alwaysEmbed = this.hasEmbeddedAlwaysOption(attr);\n let option = this.attrsOption(attr);\n return alwaysEmbed || (option && option.serialize === 'records');\n },\n\n // checks config for attrs option to serialize records\n hasSerializeIdsOption(attr) {\n let option = this.attrsOption(attr);\n return option && (option.serialize === 'ids' || option.serialize === 'id');\n },\n\n // checks config for attrs option to serialize records as objects containing id and types\n hasSerializeIdsAndTypesOption(attr) {\n let option = this.attrsOption(attr);\n return option && (option.serialize === 'ids-and-types' || option.serialize === 'id-and-type');\n },\n\n // checks config for attrs option to serialize records\n noSerializeOptionSpecified(attr) {\n let option = this.attrsOption(attr);\n return !(option && (option.serialize || option.embedded));\n },\n\n // checks config for attrs option to deserialize records\n // a defined option object for a resource is treated the same as\n // `deserialize: 'records'`\n hasDeserializeRecordsOption(attr) {\n let alwaysEmbed = this.hasEmbeddedAlwaysOption(attr);\n let option = this.attrsOption(attr);\n return alwaysEmbed || (option && option.deserialize === 'records');\n },\n\n attrsOption(attr) {\n let attrs = this.attrs;\n return attrs && (attrs[camelize(attr)] || attrs[attr]);\n },\n\n /**\n @method _extractEmbeddedRecords\n @private\n */\n _extractEmbeddedRecords(serializer, store, typeClass, partial) {\n typeClass.eachRelationship((key, relationship) => {\n if (serializer.hasDeserializeRecordsOption(key)) {\n if (relationship.kind === 'hasMany') {\n this._extractEmbeddedHasMany(store, key, partial, relationship);\n }\n if (relationship.kind === 'belongsTo') {\n this._extractEmbeddedBelongsTo(store, key, partial, relationship);\n }\n }\n });\n return partial;\n },\n\n /**\n @method _extractEmbeddedHasMany\n @private\n */\n _extractEmbeddedHasMany(store, key, hash, relationshipMeta) {\n let relationshipHash = hash.data?.relationships?.[key]?.data;\n\n if (!relationshipHash) {\n return;\n }\n\n let hasMany = new Array(relationshipHash.length);\n\n for (let i = 0; i < relationshipHash.length; i++) {\n let item = relationshipHash[i];\n let { data, included } = this._normalizeEmbeddedRelationship(store, relationshipMeta, item);\n hash.included = hash.included || [];\n hash.included.push(data);\n if (included) {\n hash.included = hash.included.concat(included);\n }\n\n hasMany[i] = { id: data.id, type: data.type };\n }\n\n let relationship = { data: hasMany };\n hash.data.relationships[key] = relationship;\n },\n\n /**\n @method _extractEmbeddedBelongsTo\n @private\n */\n _extractEmbeddedBelongsTo(store, key, hash, relationshipMeta) {\n let relationshipHash = hash.data?.relationships?.[key]?.data;\n if (!relationshipHash) {\n return;\n }\n\n let { data, included } = this._normalizeEmbeddedRelationship(store, relationshipMeta, relationshipHash);\n hash.included = hash.included || [];\n hash.included.push(data);\n if (included) {\n hash.included = hash.included.concat(included);\n }\n\n let belongsTo = { id: data.id, type: data.type };\n let relationship = { data: belongsTo };\n\n hash.data.relationships[key] = relationship;\n },\n\n /**\n @method _normalizeEmbeddedRelationship\n @private\n */\n _normalizeEmbeddedRelationship(store, relationshipMeta, relationshipHash) {\n let modelName = relationshipMeta.type;\n if (relationshipMeta.options.polymorphic) {\n modelName = relationshipHash.type;\n }\n let modelClass = store.modelFor(modelName);\n let serializer = store.serializerFor(modelName);\n\n return serializer.normalize(modelClass, relationshipHash, null);\n },\n isEmbeddedRecordsMixin: true,\n});\n"],"names":["Mixin","create","normalize","typeClass","hash","prop","normalizedHash","_super","_extractEmbeddedRecords","store","keyForRelationship","key","method","hasSerializeRecordsOption","hasDeserializeRecordsOption","keyForAttribute","serializeBelongsTo","snapshot","json","relationship","attr","noSerializeOptionSpecified","includeIds","hasSerializeIdsOption","includeRecords","embeddedSnapshot","belongsTo","schema","modelFor","modelName","serializedKey","_getMappedKey","kind","id","options","polymorphic","serializePolymorphicType","_serializeEmbeddedBelongsTo","serialize","includeId","removeEmbeddedForeignKey","serializeHasMany","hasMany","ids","_serializeEmbeddedHasMany","hasSerializeIdsAndTypesOption","_serializeHasManyAsIdsAndTypes","A","map","recordSnapshot","type","warn","typeOf","_generateSerializedHasMany","manyArray","ret","Array","length","i","embeddedJson","parentRecord","inverseFor","name","embeddedSerializer","serializerFor","parentKey","hasEmbeddedAlwaysOption","option","attrsOption","embedded","alwaysEmbed","deserialize","attrs","camelize","serializer","partial","eachRelationship","_extractEmbeddedHasMany","_extractEmbeddedBelongsTo","relationshipMeta","relationshipHash","data","relationships","item","included","_normalizeEmbeddedRelationship","push","concat","modelClass","isEmbeddedRecordsMixin"],"mappings":";;;;;;AAMA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAAeA,KAAK,CAACC,MAAM,CAAC;AAC1B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGEC,EAAAA,SAASA,CAACC,SAAS,EAAEC,IAAI,EAAEC,IAAI,EAAE;IAC/B,IAAIC,cAAc,GAAG,IAAI,CAACC,MAAM,CAACJ,SAAS,EAAEC,IAAI,EAAEC,IAAI,CAAC,CAAA;AACvD,IAAA,OAAO,IAAI,CAACG,uBAAuB,CAAC,IAAI,EAAE,IAAI,CAACC,KAAK,EAAEN,SAAS,EAAEG,cAAc,CAAC,CAAA;GACjF;AAEDI,EAAAA,kBAAkBA,CAACC,GAAG,EAAER,SAAS,EAAES,MAAM,EAAE;IACzC,IACGA,MAAM,KAAK,WAAW,IAAI,IAAI,CAACC,yBAAyB,CAACF,GAAG,CAAC,IAC7DC,MAAM,KAAK,aAAa,IAAI,IAAI,CAACE,2BAA2B,CAACH,GAAG,CAAE,EACnE;AACA,MAAA,OAAO,IAAI,CAACI,eAAe,CAACJ,GAAG,EAAEC,MAAM,CAAC,CAAA;AAC1C,KAAC,MAAM;MACL,OAAO,IAAI,CAACL,MAAM,CAACI,GAAG,EAAER,SAAS,EAAES,MAAM,CAAC,IAAID,GAAG,CAAA;AACnD,KAAA;GACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAWEK,EAAAA,kBAAkBA,CAACC,QAAQ,EAAEC,IAAI,EAAEC,YAAY,EAA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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA2BEsB,EAAAA,gBAAgBA,CAACxB,QAAQ,EAAEC,IAAI,EAAEC,YAAY,EAAE;AAC7C,IAAA,IAAIC,IAAI,GAAGD,YAAY,CAACR,GAAG,CAAA;AAC3B,IAAA,IAAI,IAAI,CAACU,0BAA0B,CAACD,IAAI,CAAC,EAAE;MACzC,IAAI,CAACb,MAAM,CAACU,QAAQ,EAAEC,IAAI,EAAEC,YAAY,CAAC,CAAA;AACzC,MAAA,OAAA;AACF,KAAA;AAEA,IAAA,IAAI,IAAI,CAACI,qBAAqB,CAACH,IAAI,CAAC,EAAE;MACpC,IAAIO,MAAM,GAAG,IAAI,CAAClB,KAAK,CAACmB,QAAQ,CAACX,QAAQ,CAACY,SAAS,CAAC,CAAA;MACpD,IAAIC,aAAa,GAAG,IAAI,CAACC,aAAa,CAACZ,YAAY,CAACR,GAAG,EAAEgB,MAAM,CAAC,CAAA;MAChE,IAAIG,aAAa,KAAKX,YAAY,CAACR,GAAG,IAAI,IAAI,CAACD,kBAAkB,EAAE;AACjEoB,QAAAA,aAAa,GAAG,IAAI,CAACpB,kBAAkB,CAACS,YAAY,CAACR,GAAG,EAAEQ,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IAAA,IAAI6C,UAAU,GAAGjE,KAAK,CAACuD,aAAa,CAACnC,SAAS,CAAC,CAAA;IAE/C,OAAO6C,UAAU,CAACxE,SAAS,CAACsF,UAAU,EAAER,gBAAgB,EAAE,IAAI,CAAC,CAAA;GAChE;AACDS,EAAAA,sBAAsB,EAAE,IAAA;AAC1B,CAAC,CAAC;;;;"}
@@ -1,112 +0,0 @@
1
- import EmberObject from '@ember/object';
2
-
3
- /**
4
- @module @ember-data/serializer
5
- */
6
-
7
- /**
8
- The `Transform` class is used to serialize and deserialize model
9
- attributes when they are saved or loaded from an
10
- adapter. Subclassing `Transform` is useful for creating custom
11
- attributes. All subclasses of `Transform` must implement a
12
- `serialize` and a `deserialize` method.
13
-
14
- Example
15
-
16
- ```app/transforms/temperature.js
17
- import Transform from '@ember-data/serializer/transform';
18
-
19
- // Converts centigrade in the JSON to fahrenheit in the app
20
- export default class TemperatureTransform extends Transform {
21
- deserialize(serialized, options) {
22
- return (serialized * 1.8) + 32;
23
- }
24
-
25
- serialize(deserialized, options) {
26
- return (deserialized - 32) / 1.8;
27
- }
28
- }
29
- ```
30
-
31
- Usage
32
-
33
- ```app/models/requirement.js
34
- import Model, { attr } from '@ember-data/model';
35
-
36
- export default class RequirementModel extends Model {
37
- @attr('string') name;
38
- @attr('temperature') temperature;
39
- }
40
- ```
41
-
42
- The options passed into the `attr` function when the attribute is
43
- declared on the model is also available in the transform.
44
-
45
- ```app/models/post.js
46
- import Model, { attr } from '@ember-data/model';
47
-
48
- export default class PostModel extends Model {
49
- @attr('string') title;
50
- @attr('markdown', {
51
- markdown: {
52
- gfm: false,
53
- sanitize: true
54
- }
55
- })
56
- markdown;
57
- }
58
- ```
59
-
60
- ```app/transforms/markdown.js
61
- import Transform from '@ember-data/serializer/transform';
62
-
63
- export default class MarkdownTransform extends Transform {
64
- serialize(deserialized, options) {
65
- return deserialized.raw;
66
- }
67
-
68
- deserialize(serialized, options) {
69
- let markdownOptions = options.markdown || {};
70
-
71
- return marked(serialized, markdownOptions);
72
- }
73
- }
74
- ```
75
-
76
- @class Transform
77
- @public
78
- */
79
- class Transform extends EmberObject {
80
- /**
81
- When given a deserialized value from a record attribute this
82
- method must return the serialized value.
83
- Example
84
- ```javascript
85
- import { isEmpty } from '@ember/utils';
86
- serialize(deserialized, options) {
87
- return isEmpty(deserialized) ? null : Number(deserialized);
88
- }
89
- ```
90
- @method serialize
91
- @public
92
- @param deserialized The deserialized value
93
- @param options hash of options passed to `attr`
94
- @return The serialized value
95
- */
96
- /**
97
- When given a serialized value from a JSON object this method must
98
- return the deserialized value for the record attribute.
99
- Example
100
- ```javascript
101
- deserialize(serialized, options) {
102
- return empty(serialized) ? null : Number(serialized);
103
- }
104
- ```
105
- @method deserialize
106
- @public
107
- @param serialized The serialized value
108
- @param options hash of options passed to `attr`
109
- @return The deserialized value
110
- */
111
- }
112
- export { Transform as T };
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform-63fba437.js","sources":["../src/-private/transforms/transform.js"],"sourcesContent":["import EmberObject from '@ember/object';\n\n/**\n @module @ember-data/serializer\n*/\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 import Transform from '@ember-data/serializer/transform';\n\n // Converts centigrade in the JSON to fahrenheit in the app\n export default class TemperatureTransform extends Transform {\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 ```\n\n Usage\n\n ```app/models/requirement.js\n import Model, { attr } from '@ember-data/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/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 import Transform from '@ember-data/serializer/transform';\n\n export default class MarkdownTransform extends Transform {\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 ```\n\n @class Transform\n @public\n */\nexport default class Transform extends EmberObject {\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 import { isEmpty } from '@ember/utils';\n\n serialize(deserialized, options) {\n return isEmpty(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 */\n}\n"],"names":["Transform","EmberObject"],"mappings":";;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,MAAMA,SAAS,SAASC,WAAW,CAAC;AACjD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAdE;;;;"}