@ember-data/serializer 5.4.0-beta.0 → 5.4.0-beta.2

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/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
@@ -138,9 +16,9 @@ const JSONAPISerializer = JSONSerializer.extend({
138
16
  */
139
17
  _normalizeDocumentHelper(documentHash) {
140
18
  if (Array.isArray(documentHash.data)) {
141
- let ret = new Array(documentHash.data.length);
19
+ const ret = new Array(documentHash.data.length);
142
20
  for (let i = 0; i < documentHash.data.length; i++) {
143
- let data = documentHash.data[i];
21
+ const data = documentHash.data[i];
144
22
  ret[i] = this._normalizeResourceHelper(data);
145
23
  }
146
24
  documentHash.data = ret;
@@ -148,10 +26,10 @@ const JSONAPISerializer = JSONSerializer.extend({
148
26
  documentHash.data = this._normalizeResourceHelper(documentHash.data);
149
27
  }
150
28
  if (Array.isArray(documentHash.included)) {
151
- let ret = new Array();
29
+ const ret = new Array();
152
30
  for (let i = 0; i < documentHash.included.length; i++) {
153
- let included = documentHash.included[i];
154
- let normalized = this._normalizeResourceHelper(included);
31
+ const included = documentHash.included[i];
32
+ const normalized = this._normalizeResourceHelper(included);
155
33
  if (normalized !== null) {
156
34
  // can be null when unknown type is encountered
157
35
  ret.push(normalized);
@@ -179,18 +57,16 @@ const JSONAPISerializer = JSONSerializer.extend({
179
57
  */
180
58
  _normalizeResourceHelper(resourceHash) {
181
59
  assert(this.warnMessageForUndefinedType(), resourceHash.type);
182
- let modelName, usedLookup;
183
- modelName = this.modelNameFromPayloadKey(resourceHash.type);
184
- usedLookup = 'modelNameFromPayloadKey';
60
+ const modelName = this.modelNameFromPayloadKey(resourceHash.type);
185
61
  if (!this.store.getSchemaDefinitionService().doesTypeExist(modelName)) {
186
- warn(this.warnMessageNoModelForType(modelName, resourceHash.type, usedLookup), false, {
62
+ warn(this.warnMessageNoModelForType(modelName, resourceHash.type, 'modelNameFromPayloadKey'), false, {
187
63
  id: 'ds.serializer.model-for-type-missing'
188
64
  });
189
65
  return null;
190
66
  }
191
- let modelClass = this.store.modelFor(modelName);
192
- let serializer = this.store.serializerFor(modelName);
193
- let {
67
+ const modelClass = this.store.modelFor(modelName);
68
+ const serializer = this.store.serializerFor(modelName);
69
+ const {
194
70
  data
195
71
  } = serializer.normalize(modelClass, resourceHash);
196
72
  return data;
@@ -203,7 +79,7 @@ const JSONAPISerializer = JSONSerializer.extend({
203
79
  @param {Object} payload
204
80
  */
205
81
  pushPayload(store, payload) {
206
- let normalizedPayload = this._normalizeDocumentHelper(payload);
82
+ const normalizedPayload = this._normalizeDocumentHelper(payload);
207
83
  store.push(normalizedPayload);
208
84
  },
209
85
  /**
@@ -218,19 +94,19 @@ const JSONAPISerializer = JSONSerializer.extend({
218
94
  @private
219
95
  */
220
96
  _normalizeResponse(store, primaryModelClass, payload, id, requestType, isSingle) {
221
- let normalizedPayload = this._normalizeDocumentHelper(payload);
97
+ const normalizedPayload = this._normalizeDocumentHelper(payload);
222
98
  return normalizedPayload;
223
99
  },
224
100
  normalizeQueryRecordResponse() {
225
- let normalized = this._super(...arguments);
101
+ const normalized = this._super(...arguments);
226
102
  assert('Expected the primary data returned by the serializer for a `queryRecord` response to be a single object but instead it was an array.', !Array.isArray(normalized.data));
227
103
  return normalized;
228
104
  },
229
105
  extractAttributes(modelClass, resourceHash) {
230
- let attributes = {};
106
+ const attributes = {};
231
107
  if (resourceHash.attributes) {
232
108
  modelClass.eachAttribute(key => {
233
- let attributeKey = this.keyForAttribute(key, 'deserialize');
109
+ const attributeKey = this.keyForAttribute(key, 'deserialize');
234
110
  if (resourceHash.attributes[attributeKey] !== undefined) {
235
111
  attributes[key] = resourceHash.attributes[attributeKey];
236
112
  }
@@ -253,9 +129,9 @@ const JSONAPISerializer = JSONSerializer.extend({
253
129
  */
254
130
  extractRelationship(relationshipHash) {
255
131
  if (Array.isArray(relationshipHash.data)) {
256
- let ret = new Array(relationshipHash.data.length);
132
+ const ret = new Array(relationshipHash.data.length);
257
133
  for (let i = 0; i < relationshipHash.data.length; i++) {
258
- let data = relationshipHash.data[i];
134
+ const data = relationshipHash.data[i];
259
135
  ret[i] = this._normalizeRelationshipDataHelper(data);
260
136
  }
261
137
  relationshipHash.data = ret;
@@ -274,12 +150,12 @@ const JSONAPISerializer = JSONSerializer.extend({
274
150
  @return {Object}
275
151
  */
276
152
  extractRelationships(modelClass, resourceHash) {
277
- let relationships = {};
153
+ const relationships = {};
278
154
  if (resourceHash.relationships) {
279
155
  modelClass.eachRelationship((key, relationshipMeta) => {
280
- let relationshipKey = this.keyForRelationship(key, relationshipMeta.kind, 'deserialize');
156
+ const relationshipKey = this.keyForRelationship(key, relationshipMeta.kind, 'deserialize');
281
157
  if (resourceHash.relationships[relationshipKey] !== undefined) {
282
- let relationshipHash = resourceHash.relationships[relationshipKey];
158
+ const relationshipHash = resourceHash.relationships[relationshipKey];
283
159
  relationships[key] = this.extractRelationship(relationshipHash);
284
160
  }
285
161
  if (macroCondition(getOwnConfig().env.DEBUG)) {
@@ -333,7 +209,7 @@ const JSONAPISerializer = JSONSerializer.extend({
333
209
  if (resourceHash.relationships) {
334
210
  this.normalizeUsingDeclaredMapping(modelClass, resourceHash.relationships);
335
211
  }
336
- let data = {
212
+ const data = {
337
213
  id: this.extractId(modelClass, resourceHash),
338
214
  type: this._extractType(modelClass, resourceHash),
339
215
  attributes: this.extractAttributes(modelClass, resourceHash),
@@ -529,22 +405,22 @@ const JSONAPISerializer = JSONSerializer.extend({
529
405
  @return {Object} json
530
406
  */
531
407
  serialize(snapshot, options) {
532
- let data = this._super(...arguments);
408
+ const data = this._super(...arguments);
533
409
  data.type = this.payloadKeyFromModelName(snapshot.modelName);
534
410
  return {
535
411
  data
536
412
  };
537
413
  },
538
414
  serializeAttribute(snapshot, json, key, attribute) {
539
- let type = attribute.type;
415
+ const type = attribute.type;
540
416
  if (this._canSerialize(key)) {
541
417
  json.attributes = json.attributes || {};
542
418
  let value = snapshot.attr(key);
543
419
  if (type) {
544
- let transform = this.transformFor(type);
420
+ const transform = this.transformFor(type);
545
421
  value = transform.serialize(value, attribute.options);
546
422
  }
547
- let schema = this.store.modelFor(snapshot.modelName);
423
+ const schema = this.store.modelFor(snapshot.modelName);
548
424
  let payloadKey = this._getMappedKey(key, schema);
549
425
  if (payloadKey === key) {
550
426
  payloadKey = this.keyForAttribute(key, 'serialize');
@@ -553,20 +429,20 @@ const JSONAPISerializer = JSONSerializer.extend({
553
429
  }
554
430
  },
555
431
  serializeBelongsTo(snapshot, json, relationship) {
556
- let key = relationship.key;
557
- if (this._canSerialize(key)) {
558
- let belongsTo = snapshot.belongsTo(key);
559
- let belongsToIsNotNew = belongsTo && !belongsTo.isNew;
432
+ const name = relationship.name;
433
+ if (this._canSerialize(name)) {
434
+ const belongsTo = snapshot.belongsTo(name);
435
+ const belongsToIsNotNew = belongsTo && !belongsTo.isNew;
560
436
  if (belongsTo === null || belongsToIsNotNew) {
561
437
  json.relationships = json.relationships || {};
562
- 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');
438
+ const schema = this.store.modelFor(snapshot.modelName);
439
+ let payloadKey = this._getMappedKey(name, schema);
440
+ if (payloadKey === name) {
441
+ payloadKey = this.keyForRelationship(name, 'belongsTo', 'serialize');
566
442
  }
567
443
  let data = null;
568
444
  if (belongsTo) {
569
- let payloadType = this.payloadKeyFromModelName(belongsTo.modelName);
445
+ const payloadType = this.payloadKeyFromModelName(belongsTo.modelName);
570
446
  data = {
571
447
  type: payloadType,
572
448
  id: belongsTo.id
@@ -579,23 +455,23 @@ const JSONAPISerializer = JSONSerializer.extend({
579
455
  }
580
456
  },
581
457
  serializeHasMany(snapshot, json, relationship) {
582
- let key = relationship.key;
583
- if (this.shouldSerializeHasMany(snapshot, key, relationship)) {
584
- let hasMany = snapshot.hasMany(key);
458
+ const name = relationship.name;
459
+ if (this.shouldSerializeHasMany(snapshot, name, relationship)) {
460
+ const hasMany = snapshot.hasMany(name);
585
461
  if (hasMany !== undefined) {
586
462
  json.relationships = json.relationships || {};
587
- 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');
463
+ const schema = this.store.modelFor(snapshot.modelName);
464
+ let payloadKey = this._getMappedKey(name, schema);
465
+ if (payloadKey === name && this.keyForRelationship) {
466
+ payloadKey = this.keyForRelationship(name, 'hasMany', 'serialize');
591
467
  }
592
468
 
593
469
  // only serialize has many relationships that are not new
594
- let nonNewHasMany = hasMany.filter(item => !item.isNew);
595
- let data = new Array(nonNewHasMany.length);
470
+ const nonNewHasMany = hasMany.filter(item => !item.isNew);
471
+ const data = new Array(nonNewHasMany.length);
596
472
  for (let i = 0; i < nonNewHasMany.length; i++) {
597
- let item = hasMany[i];
598
- let payloadType = this.payloadKeyFromModelName(item.modelName);
473
+ const item = hasMany[i];
474
+ const payloadType = this.payloadKeyFromModelName(item.modelName);
599
475
  data[i] = {
600
476
  type: payloadType,
601
477
  id: item.id
@@ -613,7 +489,7 @@ if (macroCondition(getOwnConfig().env.DEBUG)) {
613
489
  init(...args) {
614
490
  this._super(...args);
615
491
  assert(`You've used the EmbeddedRecordsMixin in ${this.toString()} which is not fully compatible with the JSON:API specification. Please confirm that this works for your specific API and add \`this.isEmbeddedRecordsMixinCompatible = true\` to your serializer.`, !this.isEmbeddedRecordsMixin || this.isEmbeddedRecordsMixinCompatible === true);
616
- let constructor = this.constructor;
492
+ const constructor = this.constructor;
617
493
  warn(`You've defined 'extractMeta' in ${constructor.toString()} which is not used for serializers extending JSONAPISerializer. Read more at https://api.emberjs.com/ember-data/release/classes/JSONAPISerializer on how to customize meta when using JSON API.`, this.extractMeta === JSONSerializer.prototype.extractMeta, {
618
494
  id: 'ds.serializer.json-api.extractMeta'
619
495
  });
@@ -1 +1 @@
1
- {"version":3,"file":"json-api.js","sources":["../src/json-api.js"],"sourcesContent":["/**\n * @module @ember-data/serializer/json-api\n */\nimport { assert, warn } from '@ember/debug';\nimport { dasherize } from '@ember/string';\n\nimport { pluralize, singularize } from 'ember-inflector';\n\nimport { DEBUG } from '@ember-data/env';\n\nimport JSONSerializer from './json';\n\n/**\n * <blockquote style=\"margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;\">\n <p>\n ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.\n If starting a new app or thinking of implementing a new adapter, consider writing a\n <a href=\"/ember-data/release/classes/%3CInterface%3E%20Handler\">Handler</a> instead to be used with the <a href=\"https://github.com/emberjs/data/tree/main/packages/request#readme\">RequestManager</a>\n </p>\n </blockquote>\n\n In EmberData a Serializer is used to serialize and deserialize\n records when they are transferred in and out of an external source.\n This process involves normalizing property names, transforming\n attribute values and serializing relationships.\n\n `JSONAPISerializer` supports the http://jsonapi.org/ spec and is the\n serializer recommended by Ember Data.\n\n This serializer normalizes a JSON API payload that looks like:\n\n ```app/models/player.js\n import Model, { attr, belongsTo } from '@ember-data/model';\n\n export default class Player extends Model {\n @attr('string') name;\n @attr('string') skill;\n @attr('number') gamesPlayed;\n @belongsTo('club') club;\n }\n ```\n\n ```app/models/club.js\n import Model, { attr, hasMany } from '@ember-data/model';\n\n export default class Club extends Model {\n @attr('string') name;\n @attr('string') location;\n @hasMany('player') players;\n }\n ```\n\n ```js\n {\n \"data\": [\n {\n \"attributes\": {\n \"name\": \"Benfica\",\n \"location\": \"Portugal\"\n },\n \"id\": \"1\",\n \"relationships\": {\n \"players\": {\n \"data\": [\n {\n \"id\": \"3\",\n \"type\": \"players\"\n }\n ]\n }\n },\n \"type\": \"clubs\"\n }\n ],\n \"included\": [\n {\n \"attributes\": {\n \"name\": \"Eusebio Silva Ferreira\",\n \"skill\": \"Rocket shot\",\n \"games-played\": 431\n },\n \"id\": \"3\",\n \"relationships\": {\n \"club\": {\n \"data\": {\n \"id\": \"1\",\n \"type\": \"clubs\"\n }\n }\n },\n \"type\": \"players\"\n }\n ]\n }\n ```\n\n to the format that the Ember Data store expects.\n\n ### Customizing meta\n\n Since a JSON API Document can have meta defined in multiple locations you can\n use the specific serializer hooks if you need to customize the meta.\n\n One scenario would be to camelCase the meta keys of your payload. The example\n below shows how this could be done using `normalizeArrayResponse` and\n `extractRelationship`.\n\n ```app/serializers/application.js\n import JSONAPISerializer from '@ember-data/serializer/json-api';\n\n export default class ApplicationSerializer extends JSONAPISerializer {\n normalizeArrayResponse(store, primaryModelClass, payload, id, requestType) {\n let normalizedDocument = super.normalizeArrayResponse(...arguments);\n\n // Customize document meta\n normalizedDocument.meta = camelCaseKeys(normalizedDocument.meta);\n\n return normalizedDocument;\n }\n\n extractRelationship(relationshipHash) {\n let normalizedRelationship = super.extractRelationship(...arguments);\n\n // Customize relationship meta\n normalizedRelationship.meta = camelCaseKeys(normalizedRelationship.meta);\n\n return normalizedRelationship;\n }\n }\n ```\n\n @main @ember-data/serializer/json-api\n @since 1.13.0\n @class JSONAPISerializer\n @public\n @extends JSONSerializer\n*/\nconst JSONAPISerializer = JSONSerializer.extend({\n /**\n @method _normalizeDocumentHelper\n @param {Object} documentHash\n @return {Object}\n @private\n */\n _normalizeDocumentHelper(documentHash) {\n if (Array.isArray(documentHash.data)) {\n let ret = new Array(documentHash.data.length);\n\n for (let i = 0; i < documentHash.data.length; i++) {\n let data = documentHash.data[i];\n ret[i] = this._normalizeResourceHelper(data);\n }\n\n documentHash.data = ret;\n } else if (documentHash.data && typeof documentHash.data === 'object') {\n documentHash.data = this._normalizeResourceHelper(documentHash.data);\n }\n\n if (Array.isArray(documentHash.included)) {\n let ret = new Array();\n for (let i = 0; i < documentHash.included.length; i++) {\n let included = documentHash.included[i];\n let normalized = this._normalizeResourceHelper(included);\n if (normalized !== null) {\n // can be null when unknown type is encountered\n ret.push(normalized);\n }\n }\n\n documentHash.included = ret;\n }\n\n return documentHash;\n },\n\n /**\n @method _normalizeRelationshipDataHelper\n @param {Object} relationshipDataHash\n @return {Object}\n @private\n */\n _normalizeRelationshipDataHelper(relationshipDataHash) {\n relationshipDataHash.type = this.modelNameFromPayloadKey(relationshipDataHash.type);\n\n return relationshipDataHash;\n },\n\n /**\n @method _normalizeResourceHelper\n @param {Object} resourceHash\n @return {Object}\n @private\n */\n _normalizeResourceHelper(resourceHash) {\n assert(this.warnMessageForUndefinedType(), resourceHash.type);\n\n let modelName, usedLookup;\n\n modelName = this.modelNameFromPayloadKey(resourceHash.type);\n usedLookup = 'modelNameFromPayloadKey';\n\n if (!this.store.getSchemaDefinitionService().doesTypeExist(modelName)) {\n warn(this.warnMessageNoModelForType(modelName, resourceHash.type, usedLookup), false, {\n id: 'ds.serializer.model-for-type-missing',\n });\n return null;\n }\n\n let modelClass = this.store.modelFor(modelName);\n let serializer = this.store.serializerFor(modelName);\n let { data } = serializer.normalize(modelClass, resourceHash);\n return data;\n },\n\n /**\n Normalize some data and push it into the store.\n\n @method pushPayload\n @public\n @param {Store} store\n @param {Object} payload\n */\n pushPayload(store, payload) {\n let normalizedPayload = this._normalizeDocumentHelper(payload);\n store.push(normalizedPayload);\n },\n\n /**\n @method _normalizeResponse\n @param {Store} store\n @param {Model} primaryModelClass\n @param {Object} payload\n @param {String|Number} id\n @param {String} requestType\n @param {Boolean} isSingle\n @return {Object} JSON-API Document\n @private\n */\n _normalizeResponse(store, primaryModelClass, payload, id, requestType, isSingle) {\n let normalizedPayload = this._normalizeDocumentHelper(payload);\n return normalizedPayload;\n },\n\n normalizeQueryRecordResponse() {\n let normalized = this._super(...arguments);\n\n assert(\n 'Expected the primary data returned by the serializer for a `queryRecord` response to be a single object but instead it was an array.',\n !Array.isArray(normalized.data)\n );\n\n return normalized;\n },\n\n extractAttributes(modelClass, resourceHash) {\n let attributes = {};\n\n if (resourceHash.attributes) {\n modelClass.eachAttribute((key) => {\n let attributeKey = this.keyForAttribute(key, 'deserialize');\n if (resourceHash.attributes[attributeKey] !== undefined) {\n attributes[key] = resourceHash.attributes[attributeKey];\n }\n if (DEBUG) {\n if (resourceHash.attributes[attributeKey] === undefined && resourceHash.attributes[key] !== undefined) {\n assert(\n `Your payload for '${modelClass.modelName}' contains '${key}', but your serializer is setup to look for '${attributeKey}'. This is most likely because Ember Data's JSON API serializer dasherizes attribute keys by default. You should subclass JSONAPISerializer and implement 'keyForAttribute(key) { return key; }' to prevent Ember Data from customizing your attribute keys.`,\n false\n );\n }\n }\n });\n }\n\n return attributes;\n },\n\n /**\n Returns a relationship formatted as a JSON-API \"relationship object\".\n\n http://jsonapi.org/format/#document-resource-object-relationships\n\n @method extractRelationship\n @public\n @param {Object} relationshipHash\n @return {Object}\n */\n extractRelationship(relationshipHash) {\n if (Array.isArray(relationshipHash.data)) {\n let ret = new Array(relationshipHash.data.length);\n\n for (let i = 0; i < relationshipHash.data.length; i++) {\n let data = relationshipHash.data[i];\n ret[i] = this._normalizeRelationshipDataHelper(data);\n }\n\n relationshipHash.data = ret;\n } else if (relationshipHash.data && typeof relationshipHash.data === 'object') {\n relationshipHash.data = this._normalizeRelationshipDataHelper(relationshipHash.data);\n }\n\n return relationshipHash;\n },\n\n /**\n Returns the resource's relationships formatted as a JSON-API \"relationships object\".\n\n http://jsonapi.org/format/#document-resource-object-relationships\n\n @method extractRelationships\n @public\n @param {Object} modelClass\n @param {Object} resourceHash\n @return {Object}\n */\n extractRelationships(modelClass, resourceHash) {\n let relationships = {};\n\n if (resourceHash.relationships) {\n modelClass.eachRelationship((key, relationshipMeta) => {\n let relationshipKey = this.keyForRelationship(key, relationshipMeta.kind, 'deserialize');\n if (resourceHash.relationships[relationshipKey] !== undefined) {\n let relationshipHash = resourceHash.relationships[relationshipKey];\n relationships[key] = this.extractRelationship(relationshipHash);\n }\n if (DEBUG) {\n if (\n resourceHash.relationships[relationshipKey] === undefined &&\n resourceHash.relationships[key] !== undefined\n ) {\n assert(\n `Your payload for '${modelClass.modelName}' contains '${key}', but your serializer is setup to look for '${relationshipKey}'. This is most likely because Ember Data's JSON API serializer dasherizes relationship keys by default. You should subclass JSONAPISerializer and implement 'keyForRelationship(key) { return key; }' to prevent Ember Data from customizing your relationship keys.`,\n false\n );\n }\n }\n });\n }\n\n return relationships;\n },\n\n /**\n @method _extractType\n @param {Model} modelClass\n @param {Object} resourceHash\n @return {String}\n @private\n */\n _extractType(modelClass, resourceHash) {\n return this.modelNameFromPayloadKey(resourceHash.type);\n },\n\n /**\n Dasherizes and singularizes the model name in the payload to match\n the format Ember Data uses internally for the model name.\n\n For example the key `posts` would be converted to `post` and the\n key `studentAssesments` would be converted to `student-assesment`.\n\n @method modelNameFromPayloadKey\n @public\n @param {String} key\n @return {String} the model's modelName\n */\n modelNameFromPayloadKey(key) {\n return dasherize(singularize(key));\n },\n\n /**\n Converts the model name to a pluralized version of the model name.\n\n For example `post` would be converted to `posts` and\n `student-assesment` would be converted to `student-assesments`.\n\n @method payloadKeyFromModelName\n @public\n @param {String} modelName\n @return {String}\n */\n payloadKeyFromModelName(modelName) {\n return pluralize(modelName);\n },\n\n normalize(modelClass, resourceHash) {\n if (resourceHash.attributes) {\n this.normalizeUsingDeclaredMapping(modelClass, resourceHash.attributes);\n }\n\n if (resourceHash.relationships) {\n this.normalizeUsingDeclaredMapping(modelClass, resourceHash.relationships);\n }\n\n let data = {\n id: this.extractId(modelClass, resourceHash),\n type: this._extractType(modelClass, resourceHash),\n attributes: this.extractAttributes(modelClass, resourceHash),\n relationships: this.extractRelationships(modelClass, resourceHash),\n };\n\n this.applyTransforms(modelClass, data.attributes);\n\n return { data };\n },\n\n /**\n `keyForAttribute` can be used to define rules for how to convert an\n attribute name in your model to a key in your JSON.\n By default `JSONAPISerializer` follows the format used on the examples of\n http://jsonapi.org/format and uses dashes as the word separator in the JSON\n attribute keys.\n\n This behaviour can be easily customized by extending this method.\n\n Example\n\n ```app/serializers/application.js\n import JSONAPISerializer from '@ember-data/serializer/json-api';\n import { dasherize } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends JSONAPISerializer {\n keyForAttribute(attr, method) {\n return dasherize(attr).toUpperCase();\n }\n }\n ```\n\n @method keyForAttribute\n @public\n @param {String} key\n @param {String} method\n @return {String} normalized key\n */\n keyForAttribute(key, method) {\n return dasherize(key);\n },\n\n /**\n `keyForRelationship` can be used to define a custom key when\n serializing and deserializing relationship properties.\n By default `JSONAPISerializer` follows the format used on the examples of\n http://jsonapi.org/format and uses dashes as word separators in\n relationship properties.\n\n This behaviour can be easily customized by extending this method.\n\n Example\n\n ```app/serializers/post.js\n import JSONAPISerializer from '@ember-data/serializer/json-api';\n import { underscore } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends JSONAPISerializer {\n keyForRelationship(key, relationship, method) {\n return underscore(key);\n }\n }\n ```\n @method keyForRelationship\n @public\n @param {String} key\n @param {String} typeClass\n @param {String} method\n @return {String} normalized key\n */\n keyForRelationship(key, typeClass, method) {\n return dasherize(key);\n },\n\n /**\n Called when a record is saved in order to convert the\n record into JSON.\n\n For example, consider this model:\n\n ```app/models/comment.js\n import Model, { attr, belongsTo } from '@ember-data/model';\n\n export default class CommentModel extends Model {\n @attr title;\n @attr body;\n\n @belongsTo('user', { async: false, inverse: null })\n author;\n }\n ```\n\n The default serialization would create a JSON-API resource object like:\n\n ```javascript\n {\n \"data\": {\n \"type\": \"comments\",\n \"attributes\": {\n \"title\": \"Rails is unagi\",\n \"body\": \"Rails? Omakase? O_O\",\n },\n \"relationships\": {\n \"author\": {\n \"data\": {\n \"id\": \"12\",\n \"type\": \"users\"\n }\n }\n }\n }\n }\n ```\n\n By default, attributes are passed through as-is, unless\n you specified an attribute type (`attr('date')`). If\n you specify a transform, the JavaScript value will be\n serialized when inserted into the attributes hash.\n\n Belongs-to relationships are converted into JSON-API\n resource identifier objects.\n\n ## IDs\n\n `serialize` takes an options hash with a single option:\n `includeId`. If this option is `true`, `serialize` will,\n by default include the ID in the JSON object it builds.\n\n The JSONAPIAdapter passes in `includeId: true` when serializing a record\n for `createRecord` or `updateRecord`.\n\n ## Customization\n\n Your server may expect data in a different format than the\n built-in serialization format.\n\n In that case, you can implement `serialize` yourself and\n return data formatted to match your API's expectations, or override\n the invoked adapter method and do the serialization in the adapter directly\n by using the provided snapshot.\n\n If your API's format differs greatly from the JSON:API spec, you should\n consider authoring your own adapter and serializer instead of extending\n this class.\n\n ```app/serializers/post.js\n import JSONAPISerializer from '@ember-data/serializer/json-api';\n\n export default class PostSerializer extends JSONAPISerializer {\n serialize(snapshot, options) {\n let json = {\n POST_TTL: snapshot.attr('title'),\n POST_BDY: snapshot.attr('body'),\n POST_CMS: snapshot.hasMany('comments', { ids: true })\n };\n\n if (options.includeId) {\n json.POST_ID_ = snapshot.id;\n }\n\n return json;\n }\n }\n ```\n\n ## Customizing an App-Wide Serializer\n\n If you want to define a serializer for your entire\n application, you'll probably want to use `eachAttribute`\n and `eachRelationship` on the record.\n\n ```app/serializers/application.js\n import JSONAPISerializer from '@ember-data/serializer/json-api';\n import { underscore, singularize } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends JSONAPISerializer {\n serialize(snapshot, options) {\n let json = {};\n\n snapshot.eachAttribute((name) => {\n json[serverAttributeName(name)] = snapshot.attr(name);\n });\n\n snapshot.eachRelationship((name, relationship) => {\n if (relationship.kind === 'hasMany') {\n json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true });\n }\n });\n\n if (options.includeId) {\n json.ID_ = snapshot.id;\n }\n\n return json;\n }\n }\n\n function serverAttributeName(attribute) {\n return underscore(attribute).toUpperCase();\n }\n\n function serverHasManyName(name) {\n return serverAttributeName(singularize(name)) + '_IDS';\n }\n ```\n\n This serializer will generate JSON that looks like this:\n\n ```javascript\n {\n \"TITLE\": \"Rails is omakase\",\n \"BODY\": \"Yep. Omakase.\",\n \"COMMENT_IDS\": [ \"1\", \"2\", \"3\" ]\n }\n ```\n\n ## Tweaking the Default Formatting\n\n If you just want to do some small tweaks on the default JSON:API formatted response,\n you can call `super.serialize` first and make the tweaks\n on the returned object.\n\n ```app/serializers/post.js\n import JSONAPISerializer from '@ember-data/serializer/json-api';\n\n export default class PostSerializer extends JSONAPISerializer {\n serialize(snapshot, options) {\n let json = super.serialize(...arguments);\n\n json.data.attributes.subject = json.data.attributes.title;\n delete json.data.attributes.title;\n\n return json;\n }\n }\n ```\n\n @method serialize\n @public\n @param {Snapshot} snapshot\n @param {Object} options\n @return {Object} json\n */\n serialize(snapshot, options) {\n let data = this._super(...arguments);\n data.type = this.payloadKeyFromModelName(snapshot.modelName);\n\n return { data };\n },\n\n serializeAttribute(snapshot, json, key, attribute) {\n let type = attribute.type;\n\n if (this._canSerialize(key)) {\n json.attributes = json.attributes || {};\n\n let value = snapshot.attr(key);\n if (type) {\n let transform = this.transformFor(type);\n value = transform.serialize(value, attribute.options);\n }\n\n let schema = this.store.modelFor(snapshot.modelName);\n let payloadKey = this._getMappedKey(key, schema);\n\n if (payloadKey === key) {\n payloadKey = this.keyForAttribute(key, 'serialize');\n }\n\n json.attributes[payloadKey] = value;\n }\n },\n\n serializeBelongsTo(snapshot, json, relationship) {\n let key = relationship.key;\n\n if (this._canSerialize(key)) {\n let belongsTo = snapshot.belongsTo(key);\n let belongsToIsNotNew = belongsTo && !belongsTo.isNew;\n\n if (belongsTo === null || belongsToIsNotNew) {\n json.relationships = json.relationships || {};\n\n let schema = this.store.modelFor(snapshot.modelName);\n let payloadKey = this._getMappedKey(key, schema);\n if (payloadKey === key) {\n payloadKey = this.keyForRelationship(key, 'belongsTo', 'serialize');\n }\n\n let data = null;\n if (belongsTo) {\n let payloadType = this.payloadKeyFromModelName(belongsTo.modelName);\n\n data = {\n type: payloadType,\n id: belongsTo.id,\n };\n }\n\n json.relationships[payloadKey] = { data };\n }\n }\n },\n\n serializeHasMany(snapshot, json, relationship) {\n let key = relationship.key;\n\n if (this.shouldSerializeHasMany(snapshot, key, relationship)) {\n let hasMany = snapshot.hasMany(key);\n if (hasMany !== undefined) {\n json.relationships = json.relationships || {};\n\n let schema = this.store.modelFor(snapshot.modelName);\n let payloadKey = this._getMappedKey(key, schema);\n if (payloadKey === key && this.keyForRelationship) {\n payloadKey = this.keyForRelationship(key, 'hasMany', 'serialize');\n }\n\n // only serialize has many relationships that are not new\n let nonNewHasMany = hasMany.filter((item) => !item.isNew);\n let data = new Array(nonNewHasMany.length);\n\n for (let i = 0; i < nonNewHasMany.length; i++) {\n let item = hasMany[i];\n let payloadType = this.payloadKeyFromModelName(item.modelName);\n\n data[i] = {\n type: payloadType,\n id: item.id,\n };\n }\n\n json.relationships[payloadKey] = { data };\n }\n }\n },\n});\n\nif (DEBUG) {\n JSONAPISerializer.reopen({\n init(...args) {\n this._super(...args);\n\n assert(\n `You've used the EmbeddedRecordsMixin in ${this.toString()} which is not fully compatible with the JSON:API specification. Please confirm that this works for your specific API and add \\`this.isEmbeddedRecordsMixinCompatible = true\\` to your serializer.`,\n !this.isEmbeddedRecordsMixin || this.isEmbeddedRecordsMixinCompatible === true\n );\n\n let constructor = this.constructor;\n warn(\n `You've defined 'extractMeta' in ${constructor.toString()} which is not used for serializers extending JSONAPISerializer. Read more at https://api.emberjs.com/ember-data/release/classes/JSONAPISerializer on how to customize meta when using JSON API.`,\n this.extractMeta === JSONSerializer.prototype.extractMeta,\n {\n id: 'ds.serializer.json-api.extractMeta',\n }\n );\n },\n warnMessageForUndefinedType() {\n return (\n 'Encountered a resource object with an undefined type (resolved resource using ' +\n this.constructor.toString() +\n ')'\n );\n },\n warnMessageNoModelForType(modelName, originalType, usedLookup) {\n return `Encountered a resource object with type \"${originalType}\", but no model was found for model name \"${modelName}\" (resolved model name using '${this.constructor.toString()}.${usedLookup}(\"${originalType}\")').`;\n },\n });\n}\n\nexport default JSONAPISerializer;\n"],"names":["JSONAPISerializer","JSONSerializer","extend","_normalizeDocumentHelper","documentHash","Array","isArray","data","ret","length","i","_normalizeResourceHelper","included","normalized","push","_normalizeRelationshipDataHelper","relationshipDataHash","type","modelNameFromPayloadKey","resourceHash","assert","warnMessageForUndefinedType","modelName","usedLookup","store","getSchemaDefinitionService","doesTypeExist","warn","warnMessageNoModelForType","id","modelClass","modelFor","serializer","serializerFor","normalize","pushPayload","payload","normalizedPayload","_normalizeResponse","primaryModelClass","requestType","isSingle","normalizeQueryRecordResponse","_super","arguments","extractAttributes","attributes","eachAttribute","key","attributeKey","keyForAttribute","undefined","macroCondition","getOwnConfig","env","DEBUG","extractRelationship","relationshipHash","extractRelationships","relationships","eachRelationship","relationshipMeta","relationshipKey","keyForRelationship","kind","_extractType","dasherize","singularize","payloadKeyFromModelName","pluralize","normalizeUsingDeclaredMapping","extractId","applyTransforms","method","typeClass","serialize","snapshot","options","serializeAttribute","json","attribute","_canSerialize","value","attr","transform","transformFor","schema","payloadKey","_getMappedKey","serializeBelongsTo","relationship","belongsTo","belongsToIsNotNew","isNew","payloadType","serializeHasMany","shouldSerializeHasMany","hasMany","nonNewHasMany","filter","item","reopen","init","args","toString","isEmbeddedRecordsMixin","isEmbeddedRecordsMixinCompatible","constructor","extractMeta","prototype","originalType"],"mappings":";;;;;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,iBAAiB,GAAGC,cAAc,CAACC,MAAM,CAAC;AAC9C;AACF;AACA;AACA;AACA;AACA;EACEC,wBAAwBA,CAACC,YAAY,EAAE;IACrC,IAAIC,KAAK,CAACC,OAAO,CAACF,YAAY,CAACG,IAAI,CAAC,EAAE;MACpC,IAAIC,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A,CAACF,GAAG,EAAEyB,MAAM,EAAE;IAC3B,OAAOP,SAAS,CAAClB,GAAG,CAAC,CAAA;GACtB;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKEe,EAAAA,kBAAkBA,CAACf,GAAG,EAAE0B,SAAS,EAAED,MAAM,EAAE;IACzC,OAAOP,SAAS,CAAClB,GAAG,CAAC,CAAA;GACtB;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAuCE2B,EAAAA,SAASA,CAACC,QAAQ,EAAEC,OAAO,EAAE;IAC3B,IAAItE,IAAI,GAAG,IAAI,CAACoC,MAAM,CAAC,GAAGC,SAAS,CAAC,CAAA;IACpCrC,IAAI,CAACU,IAAI,GAAG,IAAI,CAACmD,uBAAuB,CAACQ,QAAQ,CAACtD,SAAS,CAAC,CAAA;IAE5D,OAAO;AAAEf,MAAAA,IAAAA;KAAM,CAAA;GAChB;E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AA;AACF,CAAC,EAAC;AAEF,IAAA6C,cAAA,CAAAC,YAAA,GAAAC,GAAA,CAAAC,KAAA,CAAW,EAAA;EACTvD,iBAAiB,CAACqG,MAAM,CAAC;IACvBC,IAAIA,CAAC,GAAGC,IAAI,EAAE;AACZ,MAAA,IAAI,CAAC5D,MAAM,CAAC,GAAG4D,IAAI,CAAC,CAAA;AAEpBnF,MAAAA,MAAM,CACH,CAA0C,wCAAA,EAAA,IAAI,CAACoF,QAAQ,EAAG,CAAkM,iMAAA,CAAA,EAC7P,CAAC,IAAI,CAACC,sBAAsB,IAAI,IAAI,CAACC,gCAAgC,KAAK,IAC5E,CAAC,CAAA;AAED,MAAA,IAAIC,WAAW,GAAG,IAAI,CAACA,WAAW,CAAA;AAClChF,MAAAA,IAAI,CACD,CAAkCgF,gCAAAA,EAAAA,WAAW,CAACH,QAAQ,EAAG,CAAgM,+LAAA,CAAA,EAC1P,IAAI,CAACI,WAAW,KAAK3G,cAAc,CAAC4G,SAAS,CAACD,WAAW,EACzD;AACE/E,QAAAA,EAAE,EAAE,oCAAA;AACN,OACF,CAAC,CAAA;KACF;AACDR,IAAAA,2BAA2BA,GAAG;MAC5B,OACE,gFAAgF,GAChF,IAAI,CAACsF,WAAW,CAACH,QAAQ,EAAE,GAC3B,GAAG,CAAA;KAEN;AACD5E,IAAAA,yBAAyBA,CAACN,SAAS,EAAEwF,YAAY,EAAEvF,UAAU,EAAE;AAC7D,MAAA,OAAQ,4CAA2CuF,YAAa,CAAA,0CAAA,EAA4CxF,SAAU,CAAA,8BAAA,EAAgC,IAAI,CAACqF,WAAW,CAACH,QAAQ,EAAG,CAAA,CAAA,EAAGjF,UAAW,CAAA,EAAA,EAAIuF,YAAa,CAAM,KAAA,CAAA,CAAA;AACzN,KAAA;AACF,GAAC,CAAC,CAAA;AACJ;;;;"}
1
+ {"version":3,"file":"json-api.js","sources":["../src/json-api.js"],"sourcesContent":["/**\n * @module @ember-data/serializer/json-api\n */\nimport { assert, warn } from '@ember/debug';\nimport { dasherize } from '@ember/string';\n\nimport { pluralize, singularize } from 'ember-inflector';\n\nimport { DEBUG } from '@ember-data/env';\n\nimport JSONSerializer from './json';\n\n/**\n * <blockquote style=\"margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;\">\n <p>\n ⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.\n If starting a new app or thinking of implementing a new adapter, consider writing a\n <a href=\"/ember-data/release/classes/%3CInterface%3E%20Handler\">Handler</a> instead to be used with the <a href=\"https://github.com/emberjs/data/tree/main/packages/request#readme\">RequestManager</a>\n </p>\n </blockquote>\n\n In EmberData a Serializer is used to serialize and deserialize\n records when they are transferred in and out of an external source.\n This process involves normalizing property names, transforming\n attribute values and serializing relationships.\n\n `JSONAPISerializer` supports the http://jsonapi.org/ spec and is the\n serializer recommended by Ember Data.\n\n This serializer normalizes a JSON API payload that looks like:\n\n ```app/models/player.js\n import Model, { attr, belongsTo } from '@ember-data/model';\n\n export default class Player extends Model {\n @attr('string') name;\n @attr('string') skill;\n @attr('number') gamesPlayed;\n @belongsTo('club') club;\n }\n ```\n\n ```app/models/club.js\n import Model, { attr, hasMany } from '@ember-data/model';\n\n export default class Club extends Model {\n @attr('string') name;\n @attr('string') location;\n @hasMany('player') players;\n }\n ```\n\n ```js\n {\n \"data\": [\n {\n \"attributes\": {\n \"name\": \"Benfica\",\n \"location\": \"Portugal\"\n },\n \"id\": \"1\",\n \"relationships\": {\n \"players\": {\n \"data\": [\n {\n \"id\": \"3\",\n \"type\": \"players\"\n }\n ]\n }\n },\n \"type\": \"clubs\"\n }\n ],\n \"included\": [\n {\n \"attributes\": {\n \"name\": \"Eusebio Silva Ferreira\",\n \"skill\": \"Rocket shot\",\n \"games-played\": 431\n },\n \"id\": \"3\",\n \"relationships\": {\n \"club\": {\n \"data\": {\n \"id\": \"1\",\n \"type\": \"clubs\"\n }\n }\n },\n \"type\": \"players\"\n }\n ]\n }\n ```\n\n to the format that the Ember Data store expects.\n\n ### Customizing meta\n\n Since a JSON API Document can have meta defined in multiple locations you can\n use the specific serializer hooks if you need to customize the meta.\n\n One scenario would be to camelCase the meta keys of your payload. The example\n below shows how this could be done using `normalizeArrayResponse` and\n `extractRelationship`.\n\n ```app/serializers/application.js\n import JSONAPISerializer from '@ember-data/serializer/json-api';\n\n export default class ApplicationSerializer extends JSONAPISerializer {\n normalizeArrayResponse(store, primaryModelClass, payload, id, requestType) {\n let normalizedDocument = super.normalizeArrayResponse(...arguments);\n\n // Customize document meta\n normalizedDocument.meta = camelCaseKeys(normalizedDocument.meta);\n\n return normalizedDocument;\n }\n\n extractRelationship(relationshipHash) {\n let normalizedRelationship = super.extractRelationship(...arguments);\n\n // Customize relationship meta\n normalizedRelationship.meta = camelCaseKeys(normalizedRelationship.meta);\n\n return normalizedRelationship;\n }\n }\n ```\n\n @main @ember-data/serializer/json-api\n @since 1.13.0\n @class JSONAPISerializer\n @public\n @extends JSONSerializer\n*/\nconst JSONAPISerializer = JSONSerializer.extend({\n /**\n @method _normalizeDocumentHelper\n @param {Object} documentHash\n @return {Object}\n @private\n */\n _normalizeDocumentHelper(documentHash) {\n if (Array.isArray(documentHash.data)) {\n const ret = new Array(documentHash.data.length);\n\n for (let i = 0; i < documentHash.data.length; i++) {\n const data = documentHash.data[i];\n ret[i] = this._normalizeResourceHelper(data);\n }\n\n documentHash.data = ret;\n } else if (documentHash.data && typeof documentHash.data === 'object') {\n documentHash.data = this._normalizeResourceHelper(documentHash.data);\n }\n\n if (Array.isArray(documentHash.included)) {\n const ret = new Array();\n for (let i = 0; i < documentHash.included.length; i++) {\n const included = documentHash.included[i];\n const normalized = this._normalizeResourceHelper(included);\n if (normalized !== null) {\n // can be null when unknown type is encountered\n ret.push(normalized);\n }\n }\n\n documentHash.included = ret;\n }\n\n return documentHash;\n },\n\n /**\n @method _normalizeRelationshipDataHelper\n @param {Object} relationshipDataHash\n @return {Object}\n @private\n */\n _normalizeRelationshipDataHelper(relationshipDataHash) {\n relationshipDataHash.type = this.modelNameFromPayloadKey(relationshipDataHash.type);\n\n return relationshipDataHash;\n },\n\n /**\n @method _normalizeResourceHelper\n @param {Object} resourceHash\n @return {Object}\n @private\n */\n _normalizeResourceHelper(resourceHash) {\n assert(this.warnMessageForUndefinedType(), resourceHash.type);\n\n const modelName = this.modelNameFromPayloadKey(resourceHash.type);\n\n if (!this.store.getSchemaDefinitionService().doesTypeExist(modelName)) {\n warn(this.warnMessageNoModelForType(modelName, resourceHash.type, 'modelNameFromPayloadKey'), false, {\n id: 'ds.serializer.model-for-type-missing',\n });\n return null;\n }\n\n const modelClass = this.store.modelFor(modelName);\n const serializer = this.store.serializerFor(modelName);\n const { data } = serializer.normalize(modelClass, resourceHash);\n return data;\n },\n\n /**\n Normalize some data and push it into the store.\n\n @method pushPayload\n @public\n @param {Store} store\n @param {Object} payload\n */\n pushPayload(store, payload) {\n const normalizedPayload = this._normalizeDocumentHelper(payload);\n store.push(normalizedPayload);\n },\n\n /**\n @method _normalizeResponse\n @param {Store} store\n @param {Model} primaryModelClass\n @param {Object} payload\n @param {String|Number} id\n @param {String} requestType\n @param {Boolean} isSingle\n @return {Object} JSON-API Document\n @private\n */\n _normalizeResponse(store, primaryModelClass, payload, id, requestType, isSingle) {\n const normalizedPayload = this._normalizeDocumentHelper(payload);\n return normalizedPayload;\n },\n\n normalizeQueryRecordResponse() {\n const normalized = this._super(...arguments);\n\n assert(\n 'Expected the primary data returned by the serializer for a `queryRecord` response to be a single object but instead it was an array.',\n !Array.isArray(normalized.data)\n );\n\n return normalized;\n },\n\n extractAttributes(modelClass, resourceHash) {\n const attributes = {};\n\n if (resourceHash.attributes) {\n modelClass.eachAttribute((key) => {\n const attributeKey = this.keyForAttribute(key, 'deserialize');\n if (resourceHash.attributes[attributeKey] !== undefined) {\n attributes[key] = resourceHash.attributes[attributeKey];\n }\n if (DEBUG) {\n if (resourceHash.attributes[attributeKey] === undefined && resourceHash.attributes[key] !== undefined) {\n assert(\n `Your payload for '${modelClass.modelName}' contains '${key}', but your serializer is setup to look for '${attributeKey}'. This is most likely because Ember Data's JSON API serializer dasherizes attribute keys by default. You should subclass JSONAPISerializer and implement 'keyForAttribute(key) { return key; }' to prevent Ember Data from customizing your attribute keys.`,\n false\n );\n }\n }\n });\n }\n\n return attributes;\n },\n\n /**\n Returns a relationship formatted as a JSON-API \"relationship object\".\n\n http://jsonapi.org/format/#document-resource-object-relationships\n\n @method extractRelationship\n @public\n @param {Object} relationshipHash\n @return {Object}\n */\n extractRelationship(relationshipHash) {\n if (Array.isArray(relationshipHash.data)) {\n const ret = new Array(relationshipHash.data.length);\n\n for (let i = 0; i < relationshipHash.data.length; i++) {\n const data = relationshipHash.data[i];\n ret[i] = this._normalizeRelationshipDataHelper(data);\n }\n\n relationshipHash.data = ret;\n } else if (relationshipHash.data && typeof relationshipHash.data === 'object') {\n relationshipHash.data = this._normalizeRelationshipDataHelper(relationshipHash.data);\n }\n\n return relationshipHash;\n },\n\n /**\n Returns the resource's relationships formatted as a JSON-API \"relationships object\".\n\n http://jsonapi.org/format/#document-resource-object-relationships\n\n @method extractRelationships\n @public\n @param {Object} modelClass\n @param {Object} resourceHash\n @return {Object}\n */\n extractRelationships(modelClass, resourceHash) {\n const relationships = {};\n\n if (resourceHash.relationships) {\n modelClass.eachRelationship((key, relationshipMeta) => {\n const relationshipKey = this.keyForRelationship(key, relationshipMeta.kind, 'deserialize');\n if (resourceHash.relationships[relationshipKey] !== undefined) {\n const relationshipHash = resourceHash.relationships[relationshipKey];\n relationships[key] = this.extractRelationship(relationshipHash);\n }\n if (DEBUG) {\n if (\n resourceHash.relationships[relationshipKey] === undefined &&\n resourceHash.relationships[key] !== undefined\n ) {\n assert(\n `Your payload for '${modelClass.modelName}' contains '${key}', but your serializer is setup to look for '${relationshipKey}'. This is most likely because Ember Data's JSON API serializer dasherizes relationship keys by default. You should subclass JSONAPISerializer and implement 'keyForRelationship(key) { return key; }' to prevent Ember Data from customizing your relationship keys.`,\n false\n );\n }\n }\n });\n }\n\n return relationships;\n },\n\n /**\n @method _extractType\n @param {Model} modelClass\n @param {Object} resourceHash\n @return {String}\n @private\n */\n _extractType(modelClass, resourceHash) {\n return this.modelNameFromPayloadKey(resourceHash.type);\n },\n\n /**\n Dasherizes and singularizes the model name in the payload to match\n the format Ember Data uses internally for the model name.\n\n For example the key `posts` would be converted to `post` and the\n key `studentAssesments` would be converted to `student-assesment`.\n\n @method modelNameFromPayloadKey\n @public\n @param {String} key\n @return {String} the model's modelName\n */\n modelNameFromPayloadKey(key) {\n return dasherize(singularize(key));\n },\n\n /**\n Converts the model name to a pluralized version of the model name.\n\n For example `post` would be converted to `posts` and\n `student-assesment` would be converted to `student-assesments`.\n\n @method payloadKeyFromModelName\n @public\n @param {String} modelName\n @return {String}\n */\n payloadKeyFromModelName(modelName) {\n return pluralize(modelName);\n },\n\n normalize(modelClass, resourceHash) {\n if (resourceHash.attributes) {\n this.normalizeUsingDeclaredMapping(modelClass, resourceHash.attributes);\n }\n\n if (resourceHash.relationships) {\n this.normalizeUsingDeclaredMapping(modelClass, resourceHash.relationships);\n }\n\n const data = {\n id: this.extractId(modelClass, resourceHash),\n type: this._extractType(modelClass, resourceHash),\n attributes: this.extractAttributes(modelClass, resourceHash),\n relationships: this.extractRelationships(modelClass, resourceHash),\n };\n\n this.applyTransforms(modelClass, data.attributes);\n\n return { data };\n },\n\n /**\n `keyForAttribute` can be used to define rules for how to convert an\n attribute name in your model to a key in your JSON.\n By default `JSONAPISerializer` follows the format used on the examples of\n http://jsonapi.org/format and uses dashes as the word separator in the JSON\n attribute keys.\n\n This behaviour can be easily customized by extending this method.\n\n Example\n\n ```app/serializers/application.js\n import JSONAPISerializer from '@ember-data/serializer/json-api';\n import { dasherize } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends JSONAPISerializer {\n keyForAttribute(attr, method) {\n return dasherize(attr).toUpperCase();\n }\n }\n ```\n\n @method keyForAttribute\n @public\n @param {String} key\n @param {String} method\n @return {String} normalized key\n */\n keyForAttribute(key, method) {\n return dasherize(key);\n },\n\n /**\n `keyForRelationship` can be used to define a custom key when\n serializing and deserializing relationship properties.\n By default `JSONAPISerializer` follows the format used on the examples of\n http://jsonapi.org/format and uses dashes as word separators in\n relationship properties.\n\n This behaviour can be easily customized by extending this method.\n\n Example\n\n ```app/serializers/post.js\n import JSONAPISerializer from '@ember-data/serializer/json-api';\n import { underscore } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends JSONAPISerializer {\n keyForRelationship(key, relationship, method) {\n return underscore(key);\n }\n }\n ```\n @method keyForRelationship\n @public\n @param {String} key\n @param {String} typeClass\n @param {String} method\n @return {String} normalized key\n */\n keyForRelationship(key, typeClass, method) {\n return dasherize(key);\n },\n\n /**\n Called when a record is saved in order to convert the\n record into JSON.\n\n For example, consider this model:\n\n ```app/models/comment.js\n import Model, { attr, belongsTo } from '@ember-data/model';\n\n export default class CommentModel extends Model {\n @attr title;\n @attr body;\n\n @belongsTo('user', { async: false, inverse: null })\n author;\n }\n ```\n\n The default serialization would create a JSON-API resource object like:\n\n ```javascript\n {\n \"data\": {\n \"type\": \"comments\",\n \"attributes\": {\n \"title\": \"Rails is unagi\",\n \"body\": \"Rails? Omakase? O_O\",\n },\n \"relationships\": {\n \"author\": {\n \"data\": {\n \"id\": \"12\",\n \"type\": \"users\"\n }\n }\n }\n }\n }\n ```\n\n By default, attributes are passed through as-is, unless\n you specified an attribute type (`attr('date')`). If\n you specify a transform, the JavaScript value will be\n serialized when inserted into the attributes hash.\n\n Belongs-to relationships are converted into JSON-API\n resource identifier objects.\n\n ## IDs\n\n `serialize` takes an options hash with a single option:\n `includeId`. If this option is `true`, `serialize` will,\n by default include the ID in the JSON object it builds.\n\n The JSONAPIAdapter passes in `includeId: true` when serializing a record\n for `createRecord` or `updateRecord`.\n\n ## Customization\n\n Your server may expect data in a different format than the\n built-in serialization format.\n\n In that case, you can implement `serialize` yourself and\n return data formatted to match your API's expectations, or override\n the invoked adapter method and do the serialization in the adapter directly\n by using the provided snapshot.\n\n If your API's format differs greatly from the JSON:API spec, you should\n consider authoring your own adapter and serializer instead of extending\n this class.\n\n ```app/serializers/post.js\n import JSONAPISerializer from '@ember-data/serializer/json-api';\n\n export default class PostSerializer extends JSONAPISerializer {\n serialize(snapshot, options) {\n let json = {\n POST_TTL: snapshot.attr('title'),\n POST_BDY: snapshot.attr('body'),\n POST_CMS: snapshot.hasMany('comments', { ids: true })\n };\n\n if (options.includeId) {\n json.POST_ID_ = snapshot.id;\n }\n\n return json;\n }\n }\n ```\n\n ## Customizing an App-Wide Serializer\n\n If you want to define a serializer for your entire\n application, you'll probably want to use `eachAttribute`\n and `eachRelationship` on the record.\n\n ```app/serializers/application.js\n import JSONAPISerializer from '@ember-data/serializer/json-api';\n import { underscore, singularize } from '<app-name>/utils/string-utils';\n\n export default class ApplicationSerializer extends JSONAPISerializer {\n serialize(snapshot, options) {\n let json = {};\n\n snapshot.eachAttribute((name) => {\n json[serverAttributeName(name)] = snapshot.attr(name);\n });\n\n snapshot.eachRelationship((name, relationship) => {\n if (relationship.kind === 'hasMany') {\n json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true });\n }\n });\n\n if (options.includeId) {\n json.ID_ = snapshot.id;\n }\n\n return json;\n }\n }\n\n function serverAttributeName(attribute) {\n return underscore(attribute).toUpperCase();\n }\n\n function serverHasManyName(name) {\n return serverAttributeName(singularize(name)) + '_IDS';\n }\n ```\n\n This serializer will generate JSON that looks like this:\n\n ```javascript\n {\n \"TITLE\": \"Rails is omakase\",\n \"BODY\": \"Yep. Omakase.\",\n \"COMMENT_IDS\": [ \"1\", \"2\", \"3\" ]\n }\n ```\n\n ## Tweaking the Default Formatting\n\n If you just want to do some small tweaks on the default JSON:API formatted response,\n you can call `super.serialize` first and make the tweaks\n on the returned object.\n\n ```app/serializers/post.js\n import JSONAPISerializer from '@ember-data/serializer/json-api';\n\n export default class PostSerializer extends JSONAPISerializer {\n serialize(snapshot, options) {\n let json = super.serialize(...arguments);\n\n json.data.attributes.subject = json.data.attributes.title;\n delete json.data.attributes.title;\n\n return json;\n }\n }\n ```\n\n @method serialize\n @public\n @param {Snapshot} snapshot\n @param {Object} options\n @return {Object} json\n */\n serialize(snapshot, options) {\n const data = this._super(...arguments);\n data.type = this.payloadKeyFromModelName(snapshot.modelName);\n\n return { data };\n },\n\n serializeAttribute(snapshot, json, key, attribute) {\n const type = attribute.type;\n\n if (this._canSerialize(key)) {\n json.attributes = json.attributes || {};\n\n let value = snapshot.attr(key);\n if (type) {\n const transform = this.transformFor(type);\n value = transform.serialize(value, attribute.options);\n }\n\n const schema = this.store.modelFor(snapshot.modelName);\n let payloadKey = this._getMappedKey(key, schema);\n\n if (payloadKey === key) {\n payloadKey = this.keyForAttribute(key, 'serialize');\n }\n\n json.attributes[payloadKey] = value;\n }\n },\n\n serializeBelongsTo(snapshot, json, relationship) {\n const name = relationship.name;\n\n if (this._canSerialize(name)) {\n const belongsTo = snapshot.belongsTo(name);\n const belongsToIsNotNew = belongsTo && !belongsTo.isNew;\n\n if (belongsTo === null || belongsToIsNotNew) {\n json.relationships = json.relationships || {};\n\n const schema = this.store.modelFor(snapshot.modelName);\n let payloadKey = this._getMappedKey(name, schema);\n if (payloadKey === name) {\n payloadKey = this.keyForRelationship(name, 'belongsTo', 'serialize');\n }\n\n let data = null;\n if (belongsTo) {\n const payloadType = this.payloadKeyFromModelName(belongsTo.modelName);\n\n data = {\n type: payloadType,\n id: belongsTo.id,\n };\n }\n\n json.relationships[payloadKey] = { data };\n }\n }\n },\n\n serializeHasMany(snapshot, json, relationship) {\n const name = relationship.name;\n\n if (this.shouldSerializeHasMany(snapshot, name, relationship)) {\n const hasMany = snapshot.hasMany(name);\n if (hasMany !== undefined) {\n json.relationships = json.relationships || {};\n\n const schema = this.store.modelFor(snapshot.modelName);\n let payloadKey = this._getMappedKey(name, schema);\n if (payloadKey === name && this.keyForRelationship) {\n payloadKey = this.keyForRelationship(name, 'hasMany', 'serialize');\n }\n\n // only serialize has many relationships that are not new\n const nonNewHasMany = hasMany.filter((item) => !item.isNew);\n const data = new Array(nonNewHasMany.length);\n\n for (let i = 0; i < nonNewHasMany.length; i++) {\n const item = hasMany[i];\n const payloadType = this.payloadKeyFromModelName(item.modelName);\n\n data[i] = {\n type: payloadType,\n id: item.id,\n };\n }\n\n json.relationships[payloadKey] = { data };\n }\n }\n },\n});\n\nif (DEBUG) {\n JSONAPISerializer.reopen({\n init(...args) {\n this._super(...args);\n\n assert(\n `You've used the EmbeddedRecordsMixin in ${this.toString()} which is not fully compatible with the JSON:API specification. Please confirm that this works for your specific API and add \\`this.isEmbeddedRecordsMixinCompatible = true\\` to your serializer.`,\n !this.isEmbeddedRecordsMixin || this.isEmbeddedRecordsMixinCompatible === true\n );\n\n const constructor = this.constructor;\n warn(\n `You've defined 'extractMeta' in ${constructor.toString()} which is not used for serializers extending JSONAPISerializer. Read more at https://api.emberjs.com/ember-data/release/classes/JSONAPISerializer on how to customize meta when using JSON API.`,\n this.extractMeta === JSONSerializer.prototype.extractMeta,\n {\n id: 'ds.serializer.json-api.extractMeta',\n }\n );\n },\n warnMessageForUndefinedType() {\n return (\n 'Encountered a resource object with an undefined type (resolved resource using ' +\n this.constructor.toString() +\n ')'\n );\n },\n warnMessageNoModelForType(modelName, originalType, usedLookup) {\n return `Encountered a resource object with type \"${originalType}\", but no model was found for model name \"${modelName}\" (resolved model name using '${this.constructor.toString()}.${usedLookup}(\"${originalType}\")').`;\n },\n });\n}\n\nexport default JSONAPISerializer;\n"],"names":["JSONAPISerializer","JSONSerializer","extend","_normalizeDocumentHelper","documentHash","Array","isArray","data","ret","length","i","_normalizeResourceHelper","included","normalized","push","_normalizeRelationshipDataHelper","relationshipDataHash","type","modelNameFromPayloadKey","resourceHash","assert","warnMessageForUndefinedType","modelName","store","getSchemaDefinitionService","doesTypeExist","warn","warnMessageNoModelForType","id","modelClass","modelFor","serializer","serializerFor","normalize","pushPayload","payload","normalizedPayload","_normalizeResponse","primaryModelClass","requestType","isSingle","normalizeQueryRecordResponse","_super","arguments","extractAttributes","attributes","eachAttribute","key","attributeKey","keyForAttribute","undefined","macroCondition","getOwnConfig","env","DEBUG","extractRelationship","relationshipHash","extractRelationships","relationships","eachRelationship","relationshipMeta","relationshipKey","keyForRelationship","kind","_extractType","dasherize","singularize","payloadKeyFromModelName","pluralize","normalizeUsingDeclaredMapping","extractId","applyTransforms","method","typeClass","serialize","snapshot","options","serializeAttribute","json","attribute","_canSerialize","value","attr","transform","transformFor","schema","payloadKey","_getMappedKey","serializeBelongsTo","relationship","name","belongsTo","belongsToIsNotNew","isNew","payloadType","serializeHasMany","shouldSerializeHasMany","hasMany","nonNewHasMany","filter","item","reopen","init","args","toString","isEmbeddedRecordsMixin","isEmbeddedRecordsMixinCompatible","constructor","extractMeta","prototype","originalType","usedLookup"],"mappings":";;;;;;AAAA;AACA;AACA;AAuIA,MAAMA,iBAAiB,GAAGC,cAAc,CAACC,MAAM,CAAC;AAC9C;AACF;AACA;AACA;AACA;AACA;EACEC,wBAAwBA,CAACC,YAAY,EAAE;IACrC,IAAIC,KAAK,CAACC,OAAO,CAACF,YAAY,CAACG,IAAI,CAAC,EAAE;MACpC,MAAMC,GAAG,GAAG,IAAIH,KAAK,CAACD,YAAY,CAACG,IAAI,CAACE,MAAM,CAAC,CAAA;AAE/C,MAAA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,YAAY,CAACG,IAAI,CAACE,MAAM,EAAEC,CAAC,EAAE,EAAE;AACjD,QAAA,MAAMH,IAAI,GAAGH,YAAY,CAACG,IAAI,CAACG,CAAC,CAAC,CAAA;QACjCF,GAAG,CAACE,CAAC,CAAC,GAAG,IAAI,CAACC,wBAAwB,CAACJ,IAAI,CAAC,CAAA;AAC9C,OAAA;MAEAH,YAAY,CAACG,IAAI,GAAGC,GAAG,CAAA;AACzB,KAAC,MAAM,IAAIJ,YAAY,CAACG,IAAI,IAAI,OAAOH,YAAY,CAACG,IAA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AAU,EAAEV,YAAY,CAACuC,aAAa,CAAC,CAAA;AAC5E,KAAA;AAEA,IAAA,MAAMnD,IAAI,GAAG;MACXqB,EAAE,EAAE,IAAI,CAAC0C,SAAS,CAACzC,UAAU,EAAEV,YAAY,CAAC;MAC5CF,IAAI,EAAE,IAAI,CAAC+C,YAAY,CAACnC,UAAU,EAAEV,YAAY,CAAC;MACjD0B,UAAU,EAAE,IAAI,CAACD,iBAAiB,CAACf,UAAU,EAAEV,YAAY,CAAC;AAC5DuC,MAAAA,aAAa,EAAE,IAAI,CAACD,oBAAoB,CAAC5B,UAAU,EAAEV,YAAY,CAAA;KAClE,CAAA;IAED,IAAI,CAACoD,eAAe,CAAC1C,UAAU,EAAEtB,IAAI,CAACsC,UAAU,CAAC,CAAA;IAEjD,OAAO;AAAEtC,MAAAA,IAAAA;KAAM,CAAA;GAChB;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAME0C,EAAAA,eAAeA,CAACF,GAAG,EAAEyB,MAAM,EAAE;IAC3B,OAAOP,SAAS,CAAClB,GAAG,CAAC,CAAA;GACtB;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKEe,EAAAA,kBAAkBA,CAACf,GAAG,EAAE0B,SAAS,EAAED,MAAM,EAAE;IACzC,OAAOP,SAAS,CAAClB,GAAG,CAAC,CAAA;GACtB;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;A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