@ember-data/serializer 5.5.0-alpha.1 → 5.5.0-alpha.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.
package/addon/-private.js CHANGED
@@ -1,4 +1,4 @@
1
- export { e as EmbeddedRecordsMixin } from "./embedded-records-mixin-d75385ff";
1
+ export { e as EmbeddedRecordsMixin } from "./embedded-records-mixin-ccd03d4f";
2
2
  export { default as Transform } from '@ember/object';
3
3
  export { B as BooleanTransform, D as DateTransform, N as NumberTransform, S as StringTransform } from "./string-22572f80";
4
4
  export { c as coerceId } from "./utils-075c5b79";
@@ -184,7 +184,7 @@ var embeddedRecordsMixin = Mixin.create({
184
184
  @param {Object} relationship
185
185
  */
186
186
  serializeBelongsTo(snapshot, json, relationship) {
187
- let attr = relationship.key;
187
+ let attr = relationship.name;
188
188
  if (this.noSerializeOptionSpecified(attr)) {
189
189
  this._super(snapshot, json, relationship);
190
190
  return;
@@ -194,9 +194,9 @@ var embeddedRecordsMixin = Mixin.create({
194
194
  let embeddedSnapshot = snapshot.belongsTo(attr);
195
195
  if (includeIds) {
196
196
  let schema = this.store.modelFor(snapshot.modelName);
197
- let serializedKey = this._getMappedKey(relationship.key, schema);
198
- if (serializedKey === relationship.key && this.keyForRelationship) {
199
- serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');
197
+ let serializedKey = this._getMappedKey(relationship.name, schema);
198
+ if (serializedKey === relationship.name && this.keyForRelationship) {
199
+ serializedKey = this.keyForRelationship(relationship.name, relationship.kind, 'serialize');
200
200
  }
201
201
  if (!embeddedSnapshot) {
202
202
  json[serializedKey] = null;
@@ -211,11 +211,11 @@ var embeddedRecordsMixin = Mixin.create({
211
211
  }
212
212
  },
213
213
  _serializeEmbeddedBelongsTo(snapshot, json, relationship) {
214
- let embeddedSnapshot = snapshot.belongsTo(relationship.key);
214
+ let embeddedSnapshot = snapshot.belongsTo(relationship.name);
215
215
  let schema = this.store.modelFor(snapshot.modelName);
216
- let serializedKey = this._getMappedKey(relationship.key, schema);
217
- if (serializedKey === relationship.key && this.keyForRelationship) {
218
- serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');
216
+ let serializedKey = this._getMappedKey(relationship.name, schema);
217
+ if (serializedKey === relationship.name && this.keyForRelationship) {
218
+ serializedKey = this.keyForRelationship(relationship.name, relationship.kind, 'serialize');
219
219
  }
220
220
  if (!embeddedSnapshot) {
221
221
  json[serializedKey] = null;
@@ -342,16 +342,16 @@ var embeddedRecordsMixin = Mixin.create({
342
342
  @param {Object} relationship
343
343
  */
344
344
  serializeHasMany(snapshot, json, relationship) {
345
- let attr = relationship.key;
345
+ let attr = relationship.name;
346
346
  if (this.noSerializeOptionSpecified(attr)) {
347
347
  this._super(snapshot, json, relationship);
348
348
  return;
349
349
  }
350
350
  if (this.hasSerializeIdsOption(attr)) {
351
351
  let schema = this.store.modelFor(snapshot.modelName);
352
- let serializedKey = this._getMappedKey(relationship.key, schema);
353
- if (serializedKey === relationship.key && this.keyForRelationship) {
354
- serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');
352
+ let serializedKey = this._getMappedKey(relationship.name, schema);
353
+ if (serializedKey === relationship.name && this.keyForRelationship) {
354
+ serializedKey = this.keyForRelationship(relationship.name, relationship.kind, 'serialize');
355
355
  }
356
356
  json[serializedKey] = snapshot.hasMany(attr, {
357
357
  ids: true
@@ -372,8 +372,8 @@ var embeddedRecordsMixin = Mixin.create({
372
372
  TODO: Make the default in Ember-data 3.0??
373
373
  */
374
374
  _serializeHasManyAsIdsAndTypes(snapshot, json, relationship) {
375
- let serializedKey = this.keyForAttribute(relationship.key, 'serialize');
376
- let hasMany = snapshot.hasMany(relationship.key);
375
+ let serializedKey = this.keyForAttribute(relationship.name, 'serialize');
376
+ let hasMany = snapshot.hasMany(relationship.name);
377
377
  json[serializedKey] = A(hasMany).map(function (recordSnapshot) {
378
378
  //
379
379
  // I'm sure I'm being utterly naive here. Probably id is a configurable property and
@@ -387,11 +387,11 @@ var embeddedRecordsMixin = Mixin.create({
387
387
  },
388
388
  _serializeEmbeddedHasMany(snapshot, json, relationship) {
389
389
  let schema = this.store.modelFor(snapshot.modelName);
390
- let serializedKey = this._getMappedKey(relationship.key, schema);
391
- if (serializedKey === relationship.key && this.keyForRelationship) {
392
- serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');
390
+ let serializedKey = this._getMappedKey(relationship.name, schema);
391
+ if (serializedKey === relationship.name && this.keyForRelationship) {
392
+ serializedKey = this.keyForRelationship(relationship.name, relationship.kind, 'serialize');
393
393
  }
394
- warn(`The embedded relationship '${serializedKey}' is undefined for '${snapshot.modelName}' with id '${snapshot.id}'. Please include it in your original payload.`, typeof snapshot.hasMany(relationship.key) !== 'undefined', {
394
+ warn(`The embedded relationship '${serializedKey}' is undefined for '${snapshot.modelName}' with id '${snapshot.id}'. Please include it in your original payload.`, typeof snapshot.hasMany(relationship.name) !== 'undefined', {
395
395
  id: 'ds.serializer.embedded-relationship-undefined'
396
396
  });
397
397
  json[serializedKey] = this._generateSerializedHasMany(snapshot, relationship);
@@ -400,7 +400,7 @@ var embeddedRecordsMixin = Mixin.create({
400
400
  Returns an array of embedded records serialized to JSON
401
401
  */
402
402
  _generateSerializedHasMany(snapshot, relationship) {
403
- let hasMany = snapshot.hasMany(relationship.key);
403
+ let hasMany = snapshot.hasMany(relationship.name);
404
404
  let manyArray = A(hasMany);
405
405
  let ret = new Array(manyArray.length);
406
406
  for (let i = 0; i < manyArray.length; i++) {
@@ -430,7 +430,7 @@ var embeddedRecordsMixin = Mixin.create({
430
430
  removeEmbeddedForeignKey(snapshot, embeddedSnapshot, relationship, json) {
431
431
  if (relationship.kind === 'belongsTo') {
432
432
  let schema = this.store.modelFor(snapshot.modelName);
433
- let parentRecord = schema.inverseFor(relationship.key, this.store);
433
+ let parentRecord = schema.inverseFor(relationship.name, this.store);
434
434
  if (parentRecord) {
435
435
  let name = parentRecord.name;
436
436
  let embeddedSerializer = this.store.serializerFor(embeddedSnapshot.modelName);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embedded-records-mixin-ccd03d4f.js","sources":["../src/-private/embedded-records-mixin.js"],"sourcesContent":["import { A } from '@ember/array';\nimport { warn } from '@ember/debug';\nimport Mixin from '@ember/object/mixin';\nimport { camelize } from '@ember/string';\n\n/**\n @module @ember-data/serializer/rest\n*/\n\n/**\n ## Using Embedded Records\n\n `EmbeddedRecordsMixin` supports serializing embedded records.\n\n To set up embedded records, include the mixin when extending a serializer,\n then define and configure embedded (model) relationships.\n\n Note that embedded records will serialize with the serializer for their model instead of the serializer in which they are defined.\n\n Note also that this mixin does not work with JSONAPISerializer because the JSON:API specification does not describe how to format embedded resources.\n\n Below is an example of a per-type serializer (`post` type).\n\n ```app/serializers/post.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n author: { embedded: 'always' },\n comments: { serialize: 'ids' }\n }\n }\n ```\n Note that this use of `{ embedded: 'always' }` is unrelated to\n the `{ embedded: 'always' }` that is defined as an option on `attr` as part of\n defining a model while working with the `ActiveModelSerializer`. Nevertheless,\n using `{ embedded: 'always' }` as an option to `attr` is not a valid way to set up\n embedded records.\n\n The `attrs` option for a resource `{ embedded: 'always' }` is shorthand for:\n\n ```js\n {\n serialize: 'records',\n deserialize: 'records'\n }\n ```\n\n ### Configuring Attrs\n\n A resource's `attrs` option may be set to use `ids`, `records` or false for the\n `serialize` and `deserialize` settings.\n\n The `attrs` property can be set on the `ApplicationSerializer` or a per-type\n serializer.\n\n In the case where embedded JSON is expected while extracting a payload (reading)\n the setting is `deserialize: 'records'`, there is no need to use `ids` when\n extracting as that is the default behaviour without this mixin if you are using\n the vanilla `EmbeddedRecordsMixin`. Likewise, to embed JSON in the payload while\n serializing `serialize: 'records'` is the setting to use. There is an option of\n not embedding JSON in the serialized payload by using `serialize: 'ids'`. If you\n do not want the relationship sent at all, you can use `serialize: false`.\n\n\n ### EmbeddedRecordsMixin defaults\n If you do not overwrite `attrs` for a specific relationship, the `EmbeddedRecordsMixin`\n will behave in the following way:\n\n BelongsTo: `{ serialize: 'id', deserialize: 'id' }`\n HasMany: `{ serialize: false, deserialize: 'ids' }`\n\n ### Model Relationships\n\n Embedded records must have a model defined to be extracted and serialized. Note that\n when defining any relationships on your model such as `belongsTo` and `hasMany`, you\n should not both specify `async: true` and also indicate through the serializer's\n `attrs` attribute that the related model should be embedded for deserialization.\n If a model is declared embedded for deserialization (`embedded: 'always'` or `deserialize: 'records'`),\n then do not use `async: true`.\n\n To successfully extract and serialize embedded records the model relationships\n must be set up correctly. See the\n [defining relationships](https://guides.emberjs.com/current/models/relationships)\n section of the **Defining Models** guide page.\n\n Records without an `id` property are not considered embedded records, model\n instances must have an `id` property to be used with Ember Data.\n\n ### Example JSON payloads, Models and Serializers\n\n **When customizing a serializer it is important to grok what the customizations\n are. Please read the docs for the methods this mixin provides, in case you need\n to modify it to fit your specific needs.**\n\n For example, review the docs for each method of this mixin:\n * [normalize](/ember-data/release/classes/EmbeddedRecordsMixin/methods/normalize?anchor=normalize)\n * [serializeBelongsTo](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeBelongsTo?anchor=serializeBelongsTo)\n * [serializeHasMany](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeHasMany?anchor=serializeHasMany)\n\n @class EmbeddedRecordsMixin\n @public\n*/\nexport default Mixin.create({\n /**\n Normalize the record and recursively normalize/extract all the embedded records\n while pushing them into the store as they are encountered\n\n A payload with an attr configured for embedded records needs to be extracted:\n\n ```js\n {\n \"post\": {\n \"id\": \"1\"\n \"title\": \"Rails is omakase\",\n \"comments\": [{\n \"id\": \"1\",\n \"body\": \"Rails is unagi\"\n }, {\n \"id\": \"2\",\n \"body\": \"Omakase O_o\"\n }]\n }\n }\n ```\n @method normalize\n @public\n @param {Model} typeClass\n @param {Object} hash to be normalized\n @param {String} prop the hash has been referenced by\n @return {Object} the normalized hash\n **/\n normalize(typeClass, hash, prop) {\n let normalizedHash = this._super(typeClass, hash, prop);\n return this._extractEmbeddedRecords(this, this.store, typeClass, normalizedHash);\n },\n\n keyForRelationship(key, typeClass, method) {\n if (\n (method === 'serialize' && this.hasSerializeRecordsOption(key)) ||\n (method === 'deserialize' && this.hasDeserializeRecordsOption(key))\n ) {\n return this.keyForAttribute(key, method);\n } else {\n return this._super(key, typeClass, method) || key;\n }\n },\n\n /**\n Serialize `belongsTo` relationship when it is configured as an embedded object.\n\n This example of an author model belongs to a post model:\n\n ```js\n import Model, { attr, belongsTo } from '@ember-data/model';\n\n Post = Model.extend({\n title: attr('string'),\n body: attr('string'),\n author: belongsTo('author')\n });\n\n Author = Model.extend({\n name: attr('string'),\n post: belongsTo('post')\n });\n ```\n\n Use a custom (type) serializer for the post model to configure embedded author\n\n ```app/serializers/post.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n author: { embedded: 'always' }\n }\n }\n ```\n\n A payload with an attribute configured for embedded records can serialize\n the records together under the root attribute's payload:\n\n ```js\n {\n \"post\": {\n \"id\": \"1\"\n \"title\": \"Rails is omakase\",\n \"author\": {\n \"id\": \"2\"\n \"name\": \"dhh\"\n }\n }\n }\n ```\n\n @method serializeBelongsTo\n @public\n @param {Snapshot} snapshot\n @param {Object} json\n @param {Object} relationship\n */\n serializeBelongsTo(snapshot, json, relationship) {\n let attr = relationship.name;\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.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 let embeddedSnapshot = snapshot.belongsTo(relationship.name);\n let 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/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.name;\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.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 let serializedKey = this.keyForAttribute(relationship.name, 'serialize');\n let hasMany = snapshot.hasMany(relationship.name);\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.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 let hasMany = snapshot.hasMany(relationship.name);\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.name, 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","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","A","map","recordSnapshot","type","warn","_generateSerializedHasMany","manyArray","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","modelClass","isEmbeddedRecordsMixin"],"mappings":";;;;;AAKA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAAeA,KAAK,CAACC,MAAM,CAAC;AAC1B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGEC,EAAAA,SAASA,CAACC,SAAS,EAAEC,IAAI,EAAEC,IAAI,EAAE;IAC/B,IAAIC,cAAc,GAAG,IAAI,CAACC,MAAM,CAACJ,SAAS,EAAEC,IAAI,EAAEC,IAAI,CAAC,CAAA;AACvD,IAAA,OAAO,IAAI,CAACG,uBAAuB,CAAC,IAAI,EAAE,IAAI,CAACC,KAAK,EAAEN,SAAS,EAAEG,cAAc,CAAC,CAAA;GACjF;AAEDI,EAAAA,kBAAkBA,CAACC,GAAG,EAAER,SAAS,EAAES,MAAM,EAAE;IACzC,IACGA,MAAM,KAAK,WAAW,IAAI,IAAI,CAACC,yBAAyB,CAACF,GAAG,CAAC,IAC7DC,MAAM,KAAK,aAAa,IAAI,IAAI,CAACE,2BAA2B,CAACH,GAAG,CAAE,EACnE;AACA,MAAA,OAAO,IAAI,CAACI,eAAe,CAACJ,GAAG,EAAEC,MAAM,CAAC,CAAA;AAC1C,KAAC,MAAM;MACL,OAAO,IAAI,CAACL,MAAM,CAACI,GAAG,EAAER,SAAS,EAAES,MAAM,C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C,CAAC,CAAA;AACrE,MAAA,IAAI,CAACC,wBAAwB,CAACxB,QAAQ,EAAES,gBAAgB,EAAEP,YAAY,EAAED,IAAI,CAACa,aAAa,CAAC,CAAC,CAAA;AAE5F,MAAA,IAAIZ,YAAY,CAACgB,OAAO,CAACC,WAAW,EAAE;QACpC,IAAI,CAACC,wBAAwB,CAACpB,QAAQ,EAAEC,IAAI,EAAEC,YAAY,CAAC,CAAA;AAC7D,OAAA;AACF,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,IAAIC,IAAI,GAAGD,YAAY,CAACE,IAAI,CAAA;AAC5B,IAAA,IAAI,IAAI,CAACC,0BAA0B,CAACF,IAAI,CAAC,EAAE;MACzC,IAAI,CAACb,MAAM,CAACU,QAAQ,EAAEC,IAAI,EAAEC,YAAY,CAAC,CAAA;AACzC,MAAA,OAAA;AACF,KAAA;AAEA,IAAA,IAAI,IAAI,CAACK,qBAAqB,CAACJ,IAAI,CAAC,EAAE;MACpC,IAAIQ,MAAM,GAAG,IAAI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8BAA8BA,CAAC3E,KAAK,EAAEqE,gBAAgB,EAAEC,gBAAgB,EAAE;AACxE,IAAA,IAAIjD,SAAS,GAAGgD,gBAAgB,CAAC3B,IAAI,CAAA;AACrC,IAAA,IAAI2B,gBAAgB,CAAC3C,OAAO,CAACC,WAAW,EAAE;MACxCN,SAAS,GAAGiD,gBAAgB,CAAC5B,IAAI,CAAA;AACnC,KAAA;AACA,IAAA,IAAIoC,UAAU,GAAG9E,KAAK,CAACoB,QAAQ,CAACC,SAAS,CAAC,CAAA;AAC1C,IAAA,IAAI2C,UAAU,GAAGhE,KAAK,CAACsD,aAAa,CAACjC,SAAS,CAAC,CAAA;IAE/C,OAAO2C,UAAU,CAACvE,SAAS,CAACqF,UAAU,EAAER,gBAAgB,EAAE,IAAI,CAAC,CAAA;GAChE;AACDS,EAAAA,sBAAsB,EAAE,IAAA;AAC1B,CAAC,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../node_modules/.pnpm/@babel+runtime@7.22.15/node_modules/@babel/runtime/helpers/esm/initializerDefineProperty.js","../../../node_modules/.pnpm/@babel+runtime@7.22.15/node_modules/@babel/runtime/helpers/esm/applyDecoratedDescriptor.js","../src/index.ts"],"sourcesContent":["export default function _initializerDefineProperty(target, property, descriptor, context) {\n if (!descriptor) return;\n Object.defineProperty(target, property, {\n enumerable: descriptor.enumerable,\n configurable: descriptor.configurable,\n writable: descriptor.writable,\n value: descriptor.initializer ? descriptor.initializer.call(context) : void 0\n });\n}","export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {\n var desc = {};\n Object.keys(descriptor).forEach(function (key) {\n desc[key] = descriptor[key];\n });\n desc.enumerable = !!desc.enumerable;\n desc.configurable = !!desc.configurable;\n if ('value' in desc || desc.initializer) {\n desc.writable = true;\n }\n desc = decorators.slice().reverse().reduce(function (desc, decorator) {\n return decorator(target, property, desc) || desc;\n }, desc);\n if (context && desc.initializer !== void 0) {\n desc.value = desc.initializer ? desc.initializer.call(context) : void 0;\n desc.initializer = undefined;\n }\n if (desc.initializer === void 0) {\n Object.defineProperty(target, property, desc);\n desc = null;\n }\n return desc;\n}","/**\n ## Overview\n\n <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 serializer, 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 In order to properly manage and present your data, EmberData\n needs to understand the structure of data it receives.\n\n `Serializers` convert data between the server's API format and\n the format EmberData understands.\n\n Data received from an API response is **normalized** into\n [JSON:API](https://jsonapi.org/) (the format used internally\n by EmberData), while data sent to an API is **serialized**\n into the format the API expects.\n\n ### Implementing a Serializer\n\n There are only two required serializer methods, one for\n normalizing data from the server API format into JSON:API, and\n another for serializing records via `Snapshots` into the expected\n server API format.\n\n To implement a serializer, export a class that conforms to the structure\n described by [<Interface> Serializer](/ember-data/release/classes/%3CInterface%3E%20Serializer)\n from the `app/serializers/` directory. An example is below.\n\n ```ts\n import EmberObject from '@ember/object';\n\n export default class ApplicationSerializer extends EmberObject {\n normalizeResponse(store, schema, rawPayload) {\n return rawPayload;\n }\n\n serialize(snapshot, options) {\n const serializedResource = {\n id: snapshot.id,\n type: snapshot.modelName,\n attributes: snapshot.attributes()\n };\n\n return serializedResource;\n }\n }\n ```\n\n\n ### Serializer Resolution\n\n `store.serializerFor(name)` will lookup serializers defined in\n `app/serializers/` and return an instance. If no serializer is found, an\n error will be thrown.\n\n `serializerFor` first attempts to find a serializer with an exact match on `name`,\n then falls back to checking for the presence of a serializer named `application`.\n\n ```ts\n store.serializerFor('author');\n\n // lookup paths (in order) =>\n // app/serializers/author.js\n // app/serializers/application.js\n ```\n\n Most requests in EmberData are made with respect to a particular `type` (or `modelName`)\n (e.g., \"get me the full collection of **books**\" or \"get me the **employee** whose id is 37\"). We\n refer to this as the **primary** resource `type`.\n\n Typically `serializerFor` will be used to find a serializer with a name matching that of the primary\n resource `type` for the request, falling back to the `application` serializer for those types that\n do not have a defined serializer. This is often described as a `per-model` or `per-type` strategy\n for defining serializers. However, because APIs rarely format payloads per-type but rather\n per-API-version, this may not be a desired strategy.\n\n It is recommended that applications define only a single `application` adapter and serializer\n where possible.\n\n If you have multiple API formats and the per-type strategy is not viable, one strategy is to\n write an `application` adapter and serializer that make use of `options` to specify the desired\n format when making a request.\n\n ### Using a Serializer\n\n Any serializer in `app/serializers/` can be looked up by `name` using `store.serializerFor(name)`.\n\n ### Default Serializers\n\n For applications whose APIs are *very close to* or *exactly* the **REST** format or **JSON:API**\n format the `@ember-data/serializer` package contains implementations these applications can\n extend. It also contains a simple `JSONSerializer` for serializing to/from very basic JSON objects.\n\n Many applications will find writing their own serializer to be more performant and less\n complex than extending these classes even when their API format is very close to that expected\n by these serializers.\n\n It is recommended that apps write their own serializer to best suit the needs of their API and\n application.\n\n @module @ember-data/serializer\n @main @ember-data/serializer\n*/\n\nimport EmberObject from '@ember/object';\nimport { inject as service } from '@ember/service';\n\nimport type Store from '@ember-data/store';\nimport { ModelSchema } from '@ember-data/types/q/ds-model';\n\n/**\n > ⚠️ CAUTION you likely want the docs for [<Interface> Serializer](/ember-data/release/classes/%3CInterface%3E%20Serializer)\n > as extending this abstract class is unnecessary.\n\n `Serializer` is an abstract base class that you may override in your\n application to customize it for your backend. The minimum set of methods\n that you should implement is:\n\n * `normalizeResponse()`\n * `serialize()`\n\n And you can optionally override the following methods:\n\n * `normalize()`\n\n For an example implementation, see\n [JSONSerializer](JSONSerializer), the included JSON serializer.\n\n @class Serializer\n @public\n @extends Ember.EmberObject\n*/\n\nexport default class extends EmberObject {\n @service declare store: Store;\n /**\n The `store` property is the application's `store` that contains\n all records. It can be used to look up serializers for other model\n types that may be nested inside the payload response.\n\n Example:\n\n ```js\n Serializer.extend({\n extractRelationship(relationshipModelName, relationshipHash) {\n let modelClass = this.store.modelFor(relationshipModelName);\n let relationshipSerializer = this.store.serializerFor(relationshipModelName);\n return relationshipSerializer.normalize(modelClass, relationshipHash);\n }\n });\n ```\n\n @property store\n @type {Store}\n @public\n */\n\n /**\n The `normalizeResponse` method is used to normalize a payload from the\n server to a JSON-API Document.\n\n http://jsonapi.org/format/#document-structure\n\n Example:\n\n ```js\n Serializer.extend({\n normalizeResponse(store, primaryModelClass, payload, id, requestType) {\n if (requestType === 'findRecord') {\n return this.normalize(primaryModelClass, payload);\n } else {\n return payload.reduce(function(documentHash, item) {\n let { data, included } = this.normalize(primaryModelClass, item);\n documentHash.included.push(...included);\n documentHash.data.push(data);\n return documentHash;\n }, { data: [], included: [] })\n }\n }\n });\n ```\n\n @since 1.13.0\n @method normalizeResponse\n @public\n @param {Store} store\n @param {Model} primaryModelClass\n @param {Object} payload\n @param {String|Number} id\n @param {String} requestType\n @return {Object} JSON-API Document\n */\n\n /**\n The `serialize` method is used when a record is saved in order to convert\n the record into the form that your external data source expects.\n\n `serialize` takes an optional `options` hash with a single option:\n\n - `includeId`: If this is `true`, `serialize` should include the ID\n in the serialized object it builds.\n\n Example:\n\n ```js\n Serializer.extend({\n serialize(snapshot, options) {\n let json = {\n id: snapshot.id\n };\n\n snapshot.eachAttribute((key, attribute) => {\n json[key] = snapshot.attr(key);\n });\n\n snapshot.eachRelationship((key, relationship) => {\n if (relationship.kind === 'belongsTo') {\n json[key] = snapshot.belongsTo(key, { id: true });\n } else if (relationship.kind === 'hasMany') {\n json[key] = snapshot.hasMany(key, { ids: true });\n }\n });\n\n return json;\n },\n });\n ```\n\n @method serialize\n @public\n @param {Snapshot} snapshot\n @param {Object} [options]\n @return {Object}\n */\n\n /**\n The `normalize` method is used to convert a payload received from your\n external data source into the normalized form `store.push()` expects. You\n should override this method, munge the hash and return the normalized\n payload.\n\n Example:\n\n ```js\n Serializer.extend({\n normalize(modelClass, resourceHash) {\n let data = {\n id: resourceHash.id,\n type: modelClass.modelName,\n attributes: resourceHash\n };\n return { data: data };\n }\n })\n ```\n\n @method normalize\n @public\n @param {Model} typeClass\n @param {Object} hash\n @return {Object}\n */\n normalize(_typeClass: ModelSchema, hash: Record<string, unknown>): Record<string, unknown> {\n return hash;\n }\n}\n"],"names":["_initializerDefineProperty","target","property","descriptor","context","Object","defineProperty","enumerable","configurable","writable","value","initializer","call","_applyDecoratedDescriptor","decorators","desc","keys","forEach","key","slice","reverse","reduce","decorator","undefined","_class","_class2","EmberObject","constructor","args","_descriptor","normalize","_typeClass","hash","prototype","service"],"mappings":";;;AAAe,SAASA,0BAA0BA,CAACC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,OAAO,EAAE;EACxF,IAAI,CAACD,UAAU,EAAE,OAAA;AACjBE,EAAAA,MAAM,CAACC,cAAc,CAACL,MAAM,EAAEC,QAAQ,EAAE;IACtCK,UAAU,EAAEJ,UAAU,CAACI,UAAU;IACjCC,YAAY,EAAEL,UAAU,CAACK,YAAY;IACrCC,QAAQ,EAAEN,UAAU,CAACM,QAAQ;AAC7BC,IAAAA,KAAK,EAAEP,UAAU,CAACQ,WAAW,GAAGR,UAAU,CAACQ,WAAW,CAACC,IAAI,CAACR,OAAO,CAAC,GAAG,KAAK,CAAA;AAC9E,GAAC,CAAC,CAAA;AACJ;;ACRe,SAASS,yBAAyBA,CAACZ,MAAM,EAAEC,QAAQ,EAAEY,UAAU,EAAEX,UAAU,EAAEC,OAAO,EAAE;EACnG,IAAIW,IAAI,GAAG,EAAE,CAAA;EACbV,MAAM,CAACW,IAAI,CAACb,UAAU,CAAC,CAACc,OAAO,CAAC,UAAUC,GAAG,EAAE;AAC7CH,IAAAA,IAAI,CAACG,GAAG,CAAC,GAAGf,UAAU,CAACe,GAAG,CAAC,CAAA;AAC7B,GAAC,CAAC,CAAA;AACFH,EAAAA,IAAI,CAACR,UAAU,GAAG,CAAC,CAACQ,IAAI,CAACR,UAAU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A,0BAAA,gBAAA6B,WAAA,EAAA,IAAA,CAAA,CAAA;AAAA,GAAA;AAEvC;AACF;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAME;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;AAUE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIEC,EAAAA,SAASA,CAACC,UAAuB,EAAEC,IAA6B,EAA2B;AACzF,IAAA,OAAOA,IAAI,CAAA;AACb,GAAA;AACF,CAAC,GAAAH,WAAA,GAAAhB,yBAAA,CAAAY,OAAA,CAAAQ,SAAA,EAAA,OAAA,EAAA,CAnIEC,MAAO,CAAA,EAAA;EAAA1B,YAAA,EAAA,IAAA;EAAAD,UAAA,EAAA,IAAA;EAAAE,QAAA,EAAA,IAAA;EAAAE,WAAA,EAAA,IAAA;AAAA,CAAA,CAAA,GAAAc,OAAA;;;;","x_google_ignoreList":[0,1]}
1
+ {"version":3,"file":"index.js","sources":["../../../node_modules/.pnpm/@babel+runtime@7.23.1/node_modules/@babel/runtime/helpers/esm/initializerDefineProperty.js","../../../node_modules/.pnpm/@babel+runtime@7.23.1/node_modules/@babel/runtime/helpers/esm/applyDecoratedDescriptor.js","../src/index.ts"],"sourcesContent":["export default function _initializerDefineProperty(target, property, descriptor, context) {\n if (!descriptor) return;\n Object.defineProperty(target, property, {\n enumerable: descriptor.enumerable,\n configurable: descriptor.configurable,\n writable: descriptor.writable,\n value: descriptor.initializer ? descriptor.initializer.call(context) : void 0\n });\n}","export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {\n var desc = {};\n Object.keys(descriptor).forEach(function (key) {\n desc[key] = descriptor[key];\n });\n desc.enumerable = !!desc.enumerable;\n desc.configurable = !!desc.configurable;\n if ('value' in desc || desc.initializer) {\n desc.writable = true;\n }\n desc = decorators.slice().reverse().reduce(function (desc, decorator) {\n return decorator(target, property, desc) || desc;\n }, desc);\n if (context && desc.initializer !== void 0) {\n desc.value = desc.initializer ? desc.initializer.call(context) : void 0;\n desc.initializer = undefined;\n }\n if (desc.initializer === void 0) {\n Object.defineProperty(target, property, desc);\n desc = null;\n }\n return desc;\n}","/**\n ## Overview\n\n <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 serializer, 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 In order to properly manage and present your data, EmberData\n needs to understand the structure of data it receives.\n\n `Serializers` convert data between the server's API format and\n the format EmberData understands.\n\n Data received from an API response is **normalized** into\n [JSON:API](https://jsonapi.org/) (the format used internally\n by EmberData), while data sent to an API is **serialized**\n into the format the API expects.\n\n ### Implementing a Serializer\n\n There are only two required serializer methods, one for\n normalizing data from the server API format into JSON:API, and\n another for serializing records via `Snapshots` into the expected\n server API format.\n\n To implement a serializer, export a class that conforms to the structure\n described by [<Interface> Serializer](/ember-data/release/classes/%3CInterface%3E%20Serializer)\n from the `app/serializers/` directory. An example is below.\n\n ```ts\n import EmberObject from '@ember/object';\n\n export default class ApplicationSerializer extends EmberObject {\n normalizeResponse(store, schema, rawPayload) {\n return rawPayload;\n }\n\n serialize(snapshot, options) {\n const serializedResource = {\n id: snapshot.id,\n type: snapshot.modelName,\n attributes: snapshot.attributes()\n };\n\n return serializedResource;\n }\n }\n ```\n\n\n ### Serializer Resolution\n\n `store.serializerFor(name)` will lookup serializers defined in\n `app/serializers/` and return an instance. If no serializer is found, an\n error will be thrown.\n\n `serializerFor` first attempts to find a serializer with an exact match on `name`,\n then falls back to checking for the presence of a serializer named `application`.\n\n ```ts\n store.serializerFor('author');\n\n // lookup paths (in order) =>\n // app/serializers/author.js\n // app/serializers/application.js\n ```\n\n Most requests in EmberData are made with respect to a particular `type` (or `modelName`)\n (e.g., \"get me the full collection of **books**\" or \"get me the **employee** whose id is 37\"). We\n refer to this as the **primary** resource `type`.\n\n Typically `serializerFor` will be used to find a serializer with a name matching that of the primary\n resource `type` for the request, falling back to the `application` serializer for those types that\n do not have a defined serializer. This is often described as a `per-model` or `per-type` strategy\n for defining serializers. However, because APIs rarely format payloads per-type but rather\n per-API-version, this may not be a desired strategy.\n\n It is recommended that applications define only a single `application` adapter and serializer\n where possible.\n\n If you have multiple API formats and the per-type strategy is not viable, one strategy is to\n write an `application` adapter and serializer that make use of `options` to specify the desired\n format when making a request.\n\n ### Using a Serializer\n\n Any serializer in `app/serializers/` can be looked up by `name` using `store.serializerFor(name)`.\n\n ### Default Serializers\n\n For applications whose APIs are *very close to* or *exactly* the **REST** format or **JSON:API**\n format the `@ember-data/serializer` package contains implementations these applications can\n extend. It also contains a simple `JSONSerializer` for serializing to/from very basic JSON objects.\n\n Many applications will find writing their own serializer to be more performant and less\n complex than extending these classes even when their API format is very close to that expected\n by these serializers.\n\n It is recommended that apps write their own serializer to best suit the needs of their API and\n application.\n\n @module @ember-data/serializer\n @main @ember-data/serializer\n*/\n\nimport EmberObject from '@ember/object';\nimport { inject as service } from '@ember/service';\n\nimport type Store from '@ember-data/store';\nimport { ModelSchema } from '@ember-data/types/q/ds-model';\n\n/**\n > ⚠️ CAUTION you likely want the docs for [<Interface> Serializer](/ember-data/release/classes/%3CInterface%3E%20Serializer)\n > as extending this abstract class is unnecessary.\n\n `Serializer` is an abstract base class that you may override in your\n application to customize it for your backend. The minimum set of methods\n that you should implement is:\n\n * `normalizeResponse()`\n * `serialize()`\n\n And you can optionally override the following methods:\n\n * `normalize()`\n\n For an example implementation, see\n [JSONSerializer](JSONSerializer), the included JSON serializer.\n\n @class Serializer\n @public\n @extends Ember.EmberObject\n*/\n\nexport default class extends EmberObject {\n @service declare store: Store;\n /**\n The `store` property is the application's `store` that contains\n all records. It can be used to look up serializers for other model\n types that may be nested inside the payload response.\n\n Example:\n\n ```js\n Serializer.extend({\n extractRelationship(relationshipModelName, relationshipHash) {\n let modelClass = this.store.modelFor(relationshipModelName);\n let relationshipSerializer = this.store.serializerFor(relationshipModelName);\n return relationshipSerializer.normalize(modelClass, relationshipHash);\n }\n });\n ```\n\n @property store\n @type {Store}\n @public\n */\n\n /**\n The `normalizeResponse` method is used to normalize a payload from the\n server to a JSON-API Document.\n\n http://jsonapi.org/format/#document-structure\n\n Example:\n\n ```js\n Serializer.extend({\n normalizeResponse(store, primaryModelClass, payload, id, requestType) {\n if (requestType === 'findRecord') {\n return this.normalize(primaryModelClass, payload);\n } else {\n return payload.reduce(function(documentHash, item) {\n let { data, included } = this.normalize(primaryModelClass, item);\n documentHash.included.push(...included);\n documentHash.data.push(data);\n return documentHash;\n }, { data: [], included: [] })\n }\n }\n });\n ```\n\n @since 1.13.0\n @method normalizeResponse\n @public\n @param {Store} store\n @param {Model} primaryModelClass\n @param {Object} payload\n @param {String|Number} id\n @param {String} requestType\n @return {Object} JSON-API Document\n */\n\n /**\n The `serialize` method is used when a record is saved in order to convert\n the record into the form that your external data source expects.\n\n `serialize` takes an optional `options` hash with a single option:\n\n - `includeId`: If this is `true`, `serialize` should include the ID\n in the serialized object it builds.\n\n Example:\n\n ```js\n Serializer.extend({\n serialize(snapshot, options) {\n let json = {\n id: snapshot.id\n };\n\n snapshot.eachAttribute((key, attribute) => {\n json[key] = snapshot.attr(key);\n });\n\n snapshot.eachRelationship((key, relationship) => {\n if (relationship.kind === 'belongsTo') {\n json[key] = snapshot.belongsTo(key, { id: true });\n } else if (relationship.kind === 'hasMany') {\n json[key] = snapshot.hasMany(key, { ids: true });\n }\n });\n\n return json;\n },\n });\n ```\n\n @method serialize\n @public\n @param {Snapshot} snapshot\n @param {Object} [options]\n @return {Object}\n */\n\n /**\n The `normalize` method is used to convert a payload received from your\n external data source into the normalized form `store.push()` expects. You\n should override this method, munge the hash and return the normalized\n payload.\n\n Example:\n\n ```js\n Serializer.extend({\n normalize(modelClass, resourceHash) {\n let data = {\n id: resourceHash.id,\n type: modelClass.modelName,\n attributes: resourceHash\n };\n return { data: data };\n }\n })\n ```\n\n @method normalize\n @public\n @param {Model} typeClass\n @param {Object} hash\n @return {Object}\n */\n normalize(_typeClass: ModelSchema, hash: Record<string, unknown>): Record<string, unknown> {\n return hash;\n }\n}\n"],"names":["_initializerDefineProperty","target","property","descriptor","context","Object","defineProperty","enumerable","configurable","writable","value","initializer","call","_applyDecoratedDescriptor","decorators","desc","keys","forEach","key","slice","reverse","reduce","decorator","undefined","_class","_class2","EmberObject","constructor","args","_descriptor","normalize","_typeClass","hash","prototype","service"],"mappings":";;;AAAe,SAASA,0BAA0BA,CAACC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,OAAO,EAAE;EACxF,IAAI,CAACD,UAAU,EAAE,OAAA;AACjBE,EAAAA,MAAM,CAACC,cAAc,CAACL,MAAM,EAAEC,QAAQ,EAAE;IACtCK,UAAU,EAAEJ,UAAU,CAACI,UAAU;IACjCC,YAAY,EAAEL,UAAU,CAACK,YAAY;IACrCC,QAAQ,EAAEN,UAAU,CAACM,QAAQ;AAC7BC,IAAAA,KAAK,EAAEP,UAAU,CAACQ,WAAW,GAAGR,UAAU,CAACQ,WAAW,CAACC,IAAI,CAACR,OAAO,CAAC,GAAG,KAAK,CAAA;AAC9E,GAAC,CAAC,CAAA;AACJ;;ACRe,SAAS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,IAAAA,IAAI,GAAG,IAAI,CAAA;AACb,GAAA;AACA,EAAA,OAAOA,IAAI,CAAA;AACb;;;AC6FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AArBAS,IAAAA,MAAA,IAAAC,OAAA,GAuBe,MAAAA,OAAA,SAAcC,WAAW,CAAC;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA,CAAA;AAAA5B,IAAAA,0BAAA,gBAAA6B,WAAA,EAAA,IAAA,CAAA,CAAA;AAAA,GAAA;AAEvC;AACF;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAME;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;AAUE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIEC,EAAAA,SAASA,CAACC,UAAuB,EAAEC,IAA6B,EAA2B;AACzF,IAAA,OAAOA,IAAI,CAAA;AACb,GAAA;AACF,CAAC,GAAAH,WAAA,GAAAhB,yBAAA,CAAAY,OAAA,CAAAQ,SAAA,EAAA,OAAA,EAAA,CAnIEC,MAAO,CAAA,EAAA;EAAA1B,YAAA,EAAA,IAAA;EAAAD,UAAA,EAAA,IAAA;EAAAE,QAAA,EAAA,IAAA;EAAAE,WAAA,EAAA,IAAA;AAAA,CAAA,CAAA,GAAAc,OAAA;;;;","x_google_ignoreList":[0,1]}
package/addon/json-api.js CHANGED
@@ -1,134 +1,12 @@
1
- import { macroCondition, getOwnConfig } from '@embroider/macros';
2
1
  import { assert, warn } from '@ember/debug';
3
2
  import { dasherize } from '@ember/string';
4
3
  import { singularize, pluralize } from 'ember-inflector';
5
4
  import JSONSerializer from "./json";
5
+ import { macroCondition, getOwnConfig } from '@embroider/macros';
6
6
 
7
7
  /**
8
- * <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
9
- <p>
10
- ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
11
- If starting a new app or thinking of implementing a new adapter, consider writing a
12
- <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>
13
- </p>
14
- </blockquote>
15
-
16
- In EmberData a Serializer is used to serialize and deserialize
17
- records when they are transferred in and out of an external source.
18
- This process involves normalizing property names, transforming
19
- attribute values and serializing relationships.
20
-
21
- `JSONAPISerializer` supports the http://jsonapi.org/ spec and is the
22
- serializer recommended by Ember Data.
23
-
24
- This serializer normalizes a JSON API payload that looks like:
25
-
26
- ```app/models/player.js
27
- import Model, { attr, belongsTo } from '@ember-data/model';
28
-
29
- export default class Player extends Model {
30
- @attr('string') name;
31
- @attr('string') skill;
32
- @attr('number') gamesPlayed;
33
- @belongsTo('club') club;
34
- }
35
- ```
36
-
37
- ```app/models/club.js
38
- import Model, { attr, hasMany } from '@ember-data/model';
39
-
40
- export default class Club extends Model {
41
- @attr('string') name;
42
- @attr('string') location;
43
- @hasMany('player') players;
44
- }
45
- ```
46
-
47
- ```js
48
- {
49
- "data": [
50
- {
51
- "attributes": {
52
- "name": "Benfica",
53
- "location": "Portugal"
54
- },
55
- "id": "1",
56
- "relationships": {
57
- "players": {
58
- "data": [
59
- {
60
- "id": "3",
61
- "type": "players"
62
- }
63
- ]
64
- }
65
- },
66
- "type": "clubs"
67
- }
68
- ],
69
- "included": [
70
- {
71
- "attributes": {
72
- "name": "Eusebio Silva Ferreira",
73
- "skill": "Rocket shot",
74
- "games-played": 431
75
- },
76
- "id": "3",
77
- "relationships": {
78
- "club": {
79
- "data": {
80
- "id": "1",
81
- "type": "clubs"
82
- }
83
- }
84
- },
85
- "type": "players"
86
- }
87
- ]
88
- }
89
- ```
90
-
91
- to the format that the Ember Data store expects.
92
-
93
- ### Customizing meta
94
-
95
- Since a JSON API Document can have meta defined in multiple locations you can
96
- use the specific serializer hooks if you need to customize the meta.
97
-
98
- One scenario would be to camelCase the meta keys of your payload. The example
99
- below shows how this could be done using `normalizeArrayResponse` and
100
- `extractRelationship`.
101
-
102
- ```app/serializers/application.js
103
- import JSONAPISerializer from '@ember-data/serializer/json-api';
104
-
105
- export default class ApplicationSerializer extends JSONAPISerializer {
106
- normalizeArrayResponse(store, primaryModelClass, payload, id, requestType) {
107
- let normalizedDocument = super.normalizeArrayResponse(...arguments);
108
-
109
- // Customize document meta
110
- normalizedDocument.meta = camelCaseKeys(normalizedDocument.meta);
111
-
112
- return normalizedDocument;
113
- }
114
-
115
- extractRelationship(relationshipHash) {
116
- let normalizedRelationship = super.extractRelationship(...arguments);
117
-
118
- // Customize relationship meta
119
- normalizedRelationship.meta = camelCaseKeys(normalizedRelationship.meta);
120
-
121
- return normalizedRelationship;
122
- }
123
- }
124
- ```
125
-
126
- @main @ember-data/serializer/json-api
127
- @since 1.13.0
128
- @class JSONAPISerializer
129
- @public
130
- @extends JSONSerializer
131
- */
8
+ * @module @ember-data/serializer/json-api
9
+ */
132
10
  const JSONAPISerializer = JSONSerializer.extend({
133
11
  /**
134
12
  @method _normalizeDocumentHelper
@@ -553,16 +431,16 @@ const JSONAPISerializer = JSONSerializer.extend({
553
431
  }
554
432
  },
555
433
  serializeBelongsTo(snapshot, json, relationship) {
556
- let key = relationship.key;
557
- if (this._canSerialize(key)) {
558
- let belongsTo = snapshot.belongsTo(key);
434
+ let name = relationship.name;
435
+ if (this._canSerialize(name)) {
436
+ let belongsTo = snapshot.belongsTo(name);
559
437
  let belongsToIsNotNew = belongsTo && !belongsTo.isNew;
560
438
  if (belongsTo === null || belongsToIsNotNew) {
561
439
  json.relationships = json.relationships || {};
562
440
  let schema = this.store.modelFor(snapshot.modelName);
563
- let payloadKey = this._getMappedKey(key, schema);
564
- if (payloadKey === key) {
565
- payloadKey = this.keyForRelationship(key, 'belongsTo', 'serialize');
441
+ let payloadKey = this._getMappedKey(name, schema);
442
+ if (payloadKey === name) {
443
+ payloadKey = this.keyForRelationship(name, 'belongsTo', 'serialize');
566
444
  }
567
445
  let data = null;
568
446
  if (belongsTo) {
@@ -579,15 +457,15 @@ const JSONAPISerializer = JSONSerializer.extend({
579
457
  }
580
458
  },
581
459
  serializeHasMany(snapshot, json, relationship) {
582
- let key = relationship.key;
583
- if (this.shouldSerializeHasMany(snapshot, key, relationship)) {
584
- let hasMany = snapshot.hasMany(key);
460
+ let name = relationship.name;
461
+ if (this.shouldSerializeHasMany(snapshot, name, relationship)) {
462
+ let hasMany = snapshot.hasMany(name);
585
463
  if (hasMany !== undefined) {
586
464
  json.relationships = json.relationships || {};
587
465
  let schema = this.store.modelFor(snapshot.modelName);
588
- let payloadKey = this._getMappedKey(key, schema);
589
- if (payloadKey === key && this.keyForRelationship) {
590
- payloadKey = this.keyForRelationship(key, 'hasMany', 'serialize');
466
+ let payloadKey = this._getMappedKey(name, schema);
467
+ if (payloadKey === name && this.keyForRelationship) {
468
+ payloadKey = this.keyForRelationship(name, 'hasMany', 'serialize');
591
469
  }
592
470
 
593
471
  // only serialize has many relationships that are not new