@ember-data/serializer 4.10.0-alpha.2 → 4.10.0-alpha.21
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 +210 -0
- package/addon/-private.js.map +1 -0
- package/addon/{-private/embedded-records-mixin.js → embedded-records-mixin-0a9e9148.js} +87 -146
- package/addon/embedded-records-mixin-0a9e9148.js.map +1 -0
- package/addon/index.js +178 -0
- package/addon/index.js.map +1 -0
- package/addon/json-api.js +96 -233
- package/addon/json-api.js.map +1 -0
- package/addon/json.js +198 -432
- package/addon/json.js.map +1 -0
- package/addon/rest.js +133 -270
- package/addon/rest.js.map +1 -0
- package/addon/{-private/transforms/transform.js → transform-63fba437.js} +9 -15
- package/addon/transform-63fba437.js.map +1 -0
- package/addon/transform.js +3 -4
- package/addon/transform.js.map +1 -0
- package/addon-main.js +90 -0
- package/package.json +39 -8
- package/addon/-private/index.js +0 -11
- package/addon/-private/transforms/boolean.js +0 -70
- package/addon/-private/transforms/date.js +0 -59
- package/addon/-private/transforms/number.js +0 -57
- package/addon/-private/transforms/string.js +0 -38
- package/addon/index.ts +0 -259
- package/blueprints/serializer/files/__root__/__path__/__name__.js +0 -4
- package/blueprints/serializer/index.js +0 -14
- package/blueprints/serializer/native-files/__root__/__path__/__name__.js +0 -4
- package/blueprints/serializer-test/index.js +0 -29
- package/blueprints/serializer-test/mocha-files/__root__/__path__/__test__.js +0 -20
- package/blueprints/serializer-test/mocha-rfc-232-files/__root__/__path__/__test__.js +0 -25
- package/blueprints/serializer-test/qunit-files/__root__/__path__/__test__.js +0 -24
- package/blueprints/transform/files/__root__/__path__/__name__.js +0 -11
- package/blueprints/transform/index.js +0 -7
- package/blueprints/transform/native-files/__root__/__path__/__name__.js +0 -11
- package/blueprints/transform-test/index.js +0 -29
- package/blueprints/transform-test/mocha-files/__root__/__path__/__test__.js +0 -17
- package/blueprints/transform-test/mocha-rfc-232-files/__root__/__path__/__test__.js +0 -14
- package/blueprints/transform-test/qunit-files/__root__/__path__/__test__.js +0 -13
- package/index.js +0 -25
|
@@ -102,14 +102,12 @@ import { typeOf } from '@ember/utils';
|
|
|
102
102
|
@class EmbeddedRecordsMixin
|
|
103
103
|
@public
|
|
104
104
|
*/
|
|
105
|
-
|
|
105
|
+
var embeddedRecordsMixin = Mixin.create({
|
|
106
106
|
/**
|
|
107
107
|
Normalize the record and recursively normalize/extract all the embedded records
|
|
108
108
|
while pushing them into the store as they are encountered
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
```js
|
|
109
|
+
A payload with an attr configured for embedded records needs to be extracted:
|
|
110
|
+
```js
|
|
113
111
|
{
|
|
114
112
|
"post": {
|
|
115
113
|
"id": "1"
|
|
@@ -135,54 +133,40 @@ export default Mixin.create({
|
|
|
135
133
|
let normalizedHash = this._super(typeClass, hash, prop);
|
|
136
134
|
return this._extractEmbeddedRecords(this, this.store, typeClass, normalizedHash);
|
|
137
135
|
},
|
|
138
|
-
|
|
139
136
|
keyForRelationship(key, typeClass, method) {
|
|
140
|
-
if (
|
|
141
|
-
(method === 'serialize' && this.hasSerializeRecordsOption(key)) ||
|
|
142
|
-
(method === 'deserialize' && this.hasDeserializeRecordsOption(key))
|
|
143
|
-
) {
|
|
137
|
+
if (method === 'serialize' && this.hasSerializeRecordsOption(key) || method === 'deserialize' && this.hasDeserializeRecordsOption(key)) {
|
|
144
138
|
return this.keyForAttribute(key, method);
|
|
145
139
|
} else {
|
|
146
140
|
return this._super(key, typeClass, method) || key;
|
|
147
141
|
}
|
|
148
142
|
},
|
|
149
|
-
|
|
150
143
|
/**
|
|
151
144
|
Serialize `belongsTo` relationship when it is configured as an embedded object.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
```js
|
|
145
|
+
This example of an author model belongs to a post model:
|
|
146
|
+
```js
|
|
156
147
|
import Model, { attr, belongsTo } from '@ember-data/model';
|
|
157
|
-
|
|
158
|
-
Post = Model.extend({
|
|
148
|
+
Post = Model.extend({
|
|
159
149
|
title: attr('string'),
|
|
160
150
|
body: attr('string'),
|
|
161
151
|
author: belongsTo('author')
|
|
162
152
|
});
|
|
163
|
-
|
|
164
|
-
Author = Model.extend({
|
|
153
|
+
Author = Model.extend({
|
|
165
154
|
name: attr('string'),
|
|
166
155
|
post: belongsTo('post')
|
|
167
156
|
});
|
|
168
157
|
```
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
```app/serializers/post.js
|
|
158
|
+
Use a custom (type) serializer for the post model to configure embedded author
|
|
159
|
+
```app/serializers/post.js
|
|
173
160
|
import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';
|
|
174
|
-
|
|
175
|
-
export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {
|
|
161
|
+
export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {
|
|
176
162
|
attrs = {
|
|
177
163
|
author: { embedded: 'always' }
|
|
178
164
|
}
|
|
179
165
|
}
|
|
180
166
|
```
|
|
181
|
-
|
|
182
|
-
A payload with an attribute configured for embedded records can serialize
|
|
167
|
+
A payload with an attribute configured for embedded records can serialize
|
|
183
168
|
the records together under the root attribute's payload:
|
|
184
|
-
|
|
185
|
-
```js
|
|
169
|
+
```js
|
|
186
170
|
{
|
|
187
171
|
"post": {
|
|
188
172
|
"id": "1"
|
|
@@ -194,8 +178,7 @@ export default Mixin.create({
|
|
|
194
178
|
}
|
|
195
179
|
}
|
|
196
180
|
```
|
|
197
|
-
|
|
198
|
-
@method serializeBelongsTo
|
|
181
|
+
@method serializeBelongsTo
|
|
199
182
|
@public
|
|
200
183
|
@param {Snapshot} snapshot
|
|
201
184
|
@param {Object} json
|
|
@@ -216,12 +199,10 @@ export default Mixin.create({
|
|
|
216
199
|
if (serializedKey === relationship.key && this.keyForRelationship) {
|
|
217
200
|
serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');
|
|
218
201
|
}
|
|
219
|
-
|
|
220
202
|
if (!embeddedSnapshot) {
|
|
221
203
|
json[serializedKey] = null;
|
|
222
204
|
} else {
|
|
223
205
|
json[serializedKey] = embeddedSnapshot.id;
|
|
224
|
-
|
|
225
206
|
if (relationship.options.polymorphic) {
|
|
226
207
|
this.serializePolymorphicType(snapshot, json, relationship);
|
|
227
208
|
}
|
|
@@ -230,7 +211,6 @@ export default Mixin.create({
|
|
|
230
211
|
this._serializeEmbeddedBelongsTo(snapshot, json, relationship);
|
|
231
212
|
}
|
|
232
213
|
},
|
|
233
|
-
|
|
234
214
|
_serializeEmbeddedBelongsTo(snapshot, json, relationship) {
|
|
235
215
|
let embeddedSnapshot = snapshot.belongsTo(relationship.key);
|
|
236
216
|
let schema = this.store.modelFor(snapshot.modelName);
|
|
@@ -238,55 +218,45 @@ export default Mixin.create({
|
|
|
238
218
|
if (serializedKey === relationship.key && this.keyForRelationship) {
|
|
239
219
|
serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');
|
|
240
220
|
}
|
|
241
|
-
|
|
242
221
|
if (!embeddedSnapshot) {
|
|
243
222
|
json[serializedKey] = null;
|
|
244
223
|
} else {
|
|
245
|
-
json[serializedKey] = embeddedSnapshot.serialize({
|
|
224
|
+
json[serializedKey] = embeddedSnapshot.serialize({
|
|
225
|
+
includeId: true
|
|
226
|
+
});
|
|
246
227
|
this.removeEmbeddedForeignKey(snapshot, embeddedSnapshot, relationship, json[serializedKey]);
|
|
247
|
-
|
|
248
228
|
if (relationship.options.polymorphic) {
|
|
249
229
|
this.serializePolymorphicType(snapshot, json, relationship);
|
|
250
230
|
}
|
|
251
231
|
}
|
|
252
232
|
},
|
|
253
|
-
|
|
254
233
|
/**
|
|
255
234
|
Serializes `hasMany` relationships when it is configured as embedded objects.
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
```js
|
|
235
|
+
This example of a post model has many comments:
|
|
236
|
+
```js
|
|
260
237
|
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
|
|
261
|
-
|
|
262
|
-
Post = Model.extend({
|
|
238
|
+
Post = Model.extend({
|
|
263
239
|
title: attr('string'),
|
|
264
240
|
body: attr('string'),
|
|
265
241
|
comments: hasMany('comment')
|
|
266
242
|
});
|
|
267
|
-
|
|
268
|
-
Comment = Model.extend({
|
|
243
|
+
Comment = Model.extend({
|
|
269
244
|
body: attr('string'),
|
|
270
245
|
post: belongsTo('post')
|
|
271
246
|
});
|
|
272
247
|
```
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
```app/serializers/post.js
|
|
248
|
+
Use a custom (type) serializer for the post model to configure embedded comments
|
|
249
|
+
```app/serializers/post.js
|
|
277
250
|
import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';
|
|
278
|
-
|
|
279
|
-
export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {
|
|
251
|
+
export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {
|
|
280
252
|
attrs = {
|
|
281
253
|
comments: { embedded: 'always' }
|
|
282
254
|
}
|
|
283
255
|
}
|
|
284
256
|
```
|
|
285
|
-
|
|
286
|
-
A payload with an attribute configured for embedded records can serialize
|
|
257
|
+
A payload with an attribute configured for embedded records can serialize
|
|
287
258
|
the records together under the root attribute's payload:
|
|
288
|
-
|
|
289
|
-
```js
|
|
259
|
+
```js
|
|
290
260
|
{
|
|
291
261
|
"post": {
|
|
292
262
|
"id": "1"
|
|
@@ -302,27 +272,21 @@ export default Mixin.create({
|
|
|
302
272
|
}
|
|
303
273
|
}
|
|
304
274
|
```
|
|
305
|
-
|
|
306
|
-
The attrs options object can use more specific instruction for extracting and
|
|
275
|
+
The attrs options object can use more specific instruction for extracting and
|
|
307
276
|
serializing. When serializing, an option to embed `ids`, `ids-and-types` or `records` can be set.
|
|
308
277
|
When extracting the only option is `records`.
|
|
309
|
-
|
|
310
|
-
So `{ embedded: 'always' }` is shorthand for:
|
|
278
|
+
So `{ embedded: 'always' }` is shorthand for:
|
|
311
279
|
`{ serialize: 'records', deserialize: 'records' }`
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
```app/serializers/post.js
|
|
280
|
+
To embed the `ids` for a related object (using a hasMany relationship):
|
|
281
|
+
```app/serializers/post.js
|
|
316
282
|
import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';
|
|
317
|
-
|
|
318
|
-
export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {
|
|
283
|
+
export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {
|
|
319
284
|
attrs = {
|
|
320
285
|
comments: { serialize: 'ids', deserialize: 'records' }
|
|
321
286
|
}
|
|
322
287
|
}
|
|
323
288
|
```
|
|
324
|
-
|
|
325
|
-
```js
|
|
289
|
+
```js
|
|
326
290
|
{
|
|
327
291
|
"post": {
|
|
328
292
|
"id": "1"
|
|
@@ -332,45 +296,35 @@ export default Mixin.create({
|
|
|
332
296
|
}
|
|
333
297
|
}
|
|
334
298
|
```
|
|
335
|
-
|
|
336
|
-
To embed the relationship as a collection of objects with `id` and `type` keys, set
|
|
299
|
+
To embed the relationship as a collection of objects with `id` and `type` keys, set
|
|
337
300
|
`ids-and-types` for the related object.
|
|
338
|
-
|
|
339
|
-
This is particularly useful for polymorphic relationships where records don't share
|
|
301
|
+
This is particularly useful for polymorphic relationships where records don't share
|
|
340
302
|
the same table and the `id` is not enough information.
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
```js
|
|
303
|
+
For example having a user that has many pets:
|
|
304
|
+
```js
|
|
345
305
|
User = Model.extend({
|
|
346
306
|
name: attr('string'),
|
|
347
307
|
pets: hasMany('pet', { polymorphic: true })
|
|
348
308
|
});
|
|
349
|
-
|
|
350
|
-
Pet = Model.extend({
|
|
309
|
+
Pet = Model.extend({
|
|
351
310
|
name: attr('string'),
|
|
352
311
|
});
|
|
353
|
-
|
|
354
|
-
Cat = Pet.extend({
|
|
312
|
+
Cat = Pet.extend({
|
|
355
313
|
// ...
|
|
356
314
|
});
|
|
357
|
-
|
|
358
|
-
Parrot = Pet.extend({
|
|
315
|
+
Parrot = Pet.extend({
|
|
359
316
|
// ...
|
|
360
317
|
});
|
|
361
318
|
```
|
|
362
|
-
|
|
363
|
-
```app/serializers/user.js
|
|
319
|
+
```app/serializers/user.js
|
|
364
320
|
import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';
|
|
365
|
-
|
|
366
|
-
export default class UserSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {
|
|
321
|
+
export default class UserSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {
|
|
367
322
|
attrs = {
|
|
368
323
|
pets: { serialize: 'ids-and-types', deserialize: 'records' }
|
|
369
324
|
}
|
|
370
325
|
}
|
|
371
326
|
```
|
|
372
|
-
|
|
373
|
-
```js
|
|
327
|
+
```js
|
|
374
328
|
{
|
|
375
329
|
"user": {
|
|
376
330
|
"id": "1"
|
|
@@ -382,8 +336,7 @@ export default Mixin.create({
|
|
|
382
336
|
}
|
|
383
337
|
}
|
|
384
338
|
```
|
|
385
|
-
|
|
386
|
-
@method serializeHasMany
|
|
339
|
+
@method serializeHasMany
|
|
387
340
|
@public
|
|
388
341
|
@param {Snapshot} snapshot
|
|
389
342
|
@param {Object} json
|
|
@@ -395,15 +348,15 @@ export default Mixin.create({
|
|
|
395
348
|
this._super(snapshot, json, relationship);
|
|
396
349
|
return;
|
|
397
350
|
}
|
|
398
|
-
|
|
399
351
|
if (this.hasSerializeIdsOption(attr)) {
|
|
400
352
|
let schema = this.store.modelFor(snapshot.modelName);
|
|
401
353
|
let serializedKey = this._getMappedKey(relationship.key, schema);
|
|
402
354
|
if (serializedKey === relationship.key && this.keyForRelationship) {
|
|
403
355
|
serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');
|
|
404
356
|
}
|
|
405
|
-
|
|
406
|
-
|
|
357
|
+
json[serializedKey] = snapshot.hasMany(attr, {
|
|
358
|
+
ids: true
|
|
359
|
+
});
|
|
407
360
|
} else if (this.hasSerializeRecordsOption(attr)) {
|
|
408
361
|
this._serializeEmbeddedHasMany(snapshot, json, relationship);
|
|
409
362
|
} else {
|
|
@@ -412,44 +365,38 @@ export default Mixin.create({
|
|
|
412
365
|
}
|
|
413
366
|
}
|
|
414
367
|
},
|
|
415
|
-
|
|
416
368
|
/*
|
|
417
369
|
Serializes a hasMany relationship as an array of objects containing only `id` and `type`
|
|
418
370
|
keys.
|
|
419
371
|
This has its use case on polymorphic hasMany relationships where the server is not storing
|
|
420
372
|
all records in the same table using STI, and therefore the `id` is not enough information
|
|
421
|
-
|
|
422
|
-
TODO: Make the default in Ember-data 3.0??
|
|
373
|
+
TODO: Make the default in Ember-data 3.0??
|
|
423
374
|
*/
|
|
424
375
|
_serializeHasManyAsIdsAndTypes(snapshot, json, relationship) {
|
|
425
376
|
let serializedKey = this.keyForAttribute(relationship.key, 'serialize');
|
|
426
377
|
let hasMany = snapshot.hasMany(relationship.key);
|
|
427
|
-
|
|
428
378
|
json[serializedKey] = A(hasMany).map(function (recordSnapshot) {
|
|
429
379
|
//
|
|
430
380
|
// I'm sure I'm being utterly naive here. Probably id is a configurable property and
|
|
431
381
|
// type too, and the modelName has to be normalized somehow.
|
|
432
382
|
//
|
|
433
|
-
return {
|
|
383
|
+
return {
|
|
384
|
+
id: recordSnapshot.id,
|
|
385
|
+
type: recordSnapshot.modelName
|
|
386
|
+
};
|
|
434
387
|
});
|
|
435
388
|
},
|
|
436
|
-
|
|
437
389
|
_serializeEmbeddedHasMany(snapshot, json, relationship) {
|
|
438
390
|
let schema = this.store.modelFor(snapshot.modelName);
|
|
439
391
|
let serializedKey = this._getMappedKey(relationship.key, schema);
|
|
440
392
|
if (serializedKey === relationship.key && this.keyForRelationship) {
|
|
441
393
|
serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');
|
|
442
394
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
typeOf(snapshot.hasMany(relationship.key)) !== 'undefined',
|
|
447
|
-
{ id: 'ds.serializer.embedded-relationship-undefined' }
|
|
448
|
-
);
|
|
449
|
-
|
|
395
|
+
warn(`The embedded relationship '${serializedKey}' is undefined for '${snapshot.modelName}' with id '${snapshot.id}'. Please include it in your original payload.`, typeOf(snapshot.hasMany(relationship.key)) !== 'undefined', {
|
|
396
|
+
id: 'ds.serializer.embedded-relationship-undefined'
|
|
397
|
+
});
|
|
450
398
|
json[serializedKey] = this._generateSerializedHasMany(snapshot, relationship);
|
|
451
399
|
},
|
|
452
|
-
|
|
453
400
|
/*
|
|
454
401
|
Returns an array of embedded records serialized to JSON
|
|
455
402
|
*/
|
|
@@ -457,28 +404,24 @@ export default Mixin.create({
|
|
|
457
404
|
let hasMany = snapshot.hasMany(relationship.key);
|
|
458
405
|
let manyArray = A(hasMany);
|
|
459
406
|
let ret = new Array(manyArray.length);
|
|
460
|
-
|
|
461
407
|
for (let i = 0; i < manyArray.length; i++) {
|
|
462
408
|
let embeddedSnapshot = manyArray[i];
|
|
463
|
-
let embeddedJson = embeddedSnapshot.serialize({
|
|
409
|
+
let embeddedJson = embeddedSnapshot.serialize({
|
|
410
|
+
includeId: true
|
|
411
|
+
});
|
|
464
412
|
this.removeEmbeddedForeignKey(snapshot, embeddedSnapshot, relationship, embeddedJson);
|
|
465
413
|
ret[i] = embeddedJson;
|
|
466
414
|
}
|
|
467
|
-
|
|
468
415
|
return ret;
|
|
469
416
|
},
|
|
470
|
-
|
|
471
417
|
/**
|
|
472
418
|
When serializing an embedded record, modify the property (in the `JSON` payload)
|
|
473
419
|
that refers to the parent record (foreign key for the relationship).
|
|
474
|
-
|
|
475
|
-
Serializing a `belongsTo` relationship removes the property that refers to the
|
|
420
|
+
Serializing a `belongsTo` relationship removes the property that refers to the
|
|
476
421
|
parent record
|
|
477
|
-
|
|
478
|
-
Serializing a `hasMany` relationship does not remove the property that refers to
|
|
422
|
+
Serializing a `hasMany` relationship does not remove the property that refers to
|
|
479
423
|
the parent record.
|
|
480
|
-
|
|
481
|
-
@method removeEmbeddedForeignKey
|
|
424
|
+
@method removeEmbeddedForeignKey
|
|
482
425
|
@public
|
|
483
426
|
@param {Snapshot} snapshot
|
|
484
427
|
@param {Snapshot} embeddedSnapshot
|
|
@@ -499,7 +442,7 @@ export default Mixin.create({
|
|
|
499
442
|
}
|
|
500
443
|
} /*else if (relationship.kind === 'hasMany') {
|
|
501
444
|
return;
|
|
502
|
-
|
|
445
|
+
}*/
|
|
503
446
|
},
|
|
504
447
|
|
|
505
448
|
// checks config for attrs option to embedded (always) - serialize and deserialize
|
|
@@ -507,46 +450,39 @@ export default Mixin.create({
|
|
|
507
450
|
let option = this.attrsOption(attr);
|
|
508
451
|
return option && option.embedded === 'always';
|
|
509
452
|
},
|
|
510
|
-
|
|
511
453
|
// checks config for attrs option to serialize ids
|
|
512
454
|
hasSerializeRecordsOption(attr) {
|
|
513
455
|
let alwaysEmbed = this.hasEmbeddedAlwaysOption(attr);
|
|
514
456
|
let option = this.attrsOption(attr);
|
|
515
|
-
return alwaysEmbed ||
|
|
457
|
+
return alwaysEmbed || option && option.serialize === 'records';
|
|
516
458
|
},
|
|
517
|
-
|
|
518
459
|
// checks config for attrs option to serialize records
|
|
519
460
|
hasSerializeIdsOption(attr) {
|
|
520
461
|
let option = this.attrsOption(attr);
|
|
521
462
|
return option && (option.serialize === 'ids' || option.serialize === 'id');
|
|
522
463
|
},
|
|
523
|
-
|
|
524
464
|
// checks config for attrs option to serialize records as objects containing id and types
|
|
525
465
|
hasSerializeIdsAndTypesOption(attr) {
|
|
526
466
|
let option = this.attrsOption(attr);
|
|
527
467
|
return option && (option.serialize === 'ids-and-types' || option.serialize === 'id-and-type');
|
|
528
468
|
},
|
|
529
|
-
|
|
530
469
|
// checks config for attrs option to serialize records
|
|
531
470
|
noSerializeOptionSpecified(attr) {
|
|
532
471
|
let option = this.attrsOption(attr);
|
|
533
472
|
return !(option && (option.serialize || option.embedded));
|
|
534
473
|
},
|
|
535
|
-
|
|
536
474
|
// checks config for attrs option to deserialize records
|
|
537
475
|
// a defined option object for a resource is treated the same as
|
|
538
476
|
// `deserialize: 'records'`
|
|
539
477
|
hasDeserializeRecordsOption(attr) {
|
|
540
478
|
let alwaysEmbed = this.hasEmbeddedAlwaysOption(attr);
|
|
541
479
|
let option = this.attrsOption(attr);
|
|
542
|
-
return alwaysEmbed ||
|
|
480
|
+
return alwaysEmbed || option && option.deserialize === 'records';
|
|
543
481
|
},
|
|
544
|
-
|
|
545
482
|
attrsOption(attr) {
|
|
546
483
|
let attrs = this.attrs;
|
|
547
484
|
return attrs && (attrs[camelize(attr)] || attrs[attr]);
|
|
548
485
|
},
|
|
549
|
-
|
|
550
486
|
/**
|
|
551
487
|
@method _extractEmbeddedRecords
|
|
552
488
|
@private
|
|
@@ -564,36 +500,37 @@ export default Mixin.create({
|
|
|
564
500
|
});
|
|
565
501
|
return partial;
|
|
566
502
|
},
|
|
567
|
-
|
|
568
503
|
/**
|
|
569
504
|
@method _extractEmbeddedHasMany
|
|
570
505
|
@private
|
|
571
506
|
*/
|
|
572
507
|
_extractEmbeddedHasMany(store, key, hash, relationshipMeta) {
|
|
573
508
|
let relationshipHash = hash.data?.relationships?.[key]?.data;
|
|
574
|
-
|
|
575
509
|
if (!relationshipHash) {
|
|
576
510
|
return;
|
|
577
511
|
}
|
|
578
|
-
|
|
579
512
|
let hasMany = new Array(relationshipHash.length);
|
|
580
|
-
|
|
581
513
|
for (let i = 0; i < relationshipHash.length; i++) {
|
|
582
514
|
let item = relationshipHash[i];
|
|
583
|
-
let {
|
|
515
|
+
let {
|
|
516
|
+
data,
|
|
517
|
+
included
|
|
518
|
+
} = this._normalizeEmbeddedRelationship(store, relationshipMeta, item);
|
|
584
519
|
hash.included = hash.included || [];
|
|
585
520
|
hash.included.push(data);
|
|
586
521
|
if (included) {
|
|
587
522
|
hash.included = hash.included.concat(included);
|
|
588
523
|
}
|
|
589
|
-
|
|
590
|
-
|
|
524
|
+
hasMany[i] = {
|
|
525
|
+
id: data.id,
|
|
526
|
+
type: data.type
|
|
527
|
+
};
|
|
591
528
|
}
|
|
592
|
-
|
|
593
|
-
|
|
529
|
+
let relationship = {
|
|
530
|
+
data: hasMany
|
|
531
|
+
};
|
|
594
532
|
hash.data.relationships[key] = relationship;
|
|
595
533
|
},
|
|
596
|
-
|
|
597
534
|
/**
|
|
598
535
|
@method _extractEmbeddedBelongsTo
|
|
599
536
|
@private
|
|
@@ -603,20 +540,24 @@ export default Mixin.create({
|
|
|
603
540
|
if (!relationshipHash) {
|
|
604
541
|
return;
|
|
605
542
|
}
|
|
606
|
-
|
|
607
|
-
|
|
543
|
+
let {
|
|
544
|
+
data,
|
|
545
|
+
included
|
|
546
|
+
} = this._normalizeEmbeddedRelationship(store, relationshipMeta, relationshipHash);
|
|
608
547
|
hash.included = hash.included || [];
|
|
609
548
|
hash.included.push(data);
|
|
610
549
|
if (included) {
|
|
611
550
|
hash.included = hash.included.concat(included);
|
|
612
551
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
552
|
+
let belongsTo = {
|
|
553
|
+
id: data.id,
|
|
554
|
+
type: data.type
|
|
555
|
+
};
|
|
556
|
+
let relationship = {
|
|
557
|
+
data: belongsTo
|
|
558
|
+
};
|
|
617
559
|
hash.data.relationships[key] = relationship;
|
|
618
560
|
},
|
|
619
|
-
|
|
620
561
|
/**
|
|
621
562
|
@method _normalizeEmbeddedRelationship
|
|
622
563
|
@private
|
|
@@ -628,8 +569,8 @@ export default Mixin.create({
|
|
|
628
569
|
}
|
|
629
570
|
let modelClass = store.modelFor(modelName);
|
|
630
571
|
let serializer = store.serializerFor(modelName);
|
|
631
|
-
|
|
632
572
|
return serializer.normalize(modelClass, relationshipHash, null);
|
|
633
573
|
},
|
|
634
|
-
isEmbeddedRecordsMixin: true
|
|
574
|
+
isEmbeddedRecordsMixin: true
|
|
635
575
|
});
|
|
576
|
+
export { embeddedRecordsMixin as e };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedded-records-mixin-0a9e9148.js","sources":["../src/-private/embedded-records-mixin.js"],"sourcesContent":["import { A } from '@ember/array';\nimport { warn } from '@ember/debug';\nimport Mixin from '@ember/object/mixin';\nimport { camelize } from '@ember/string';\nimport { typeOf } from '@ember/utils';\n\n/**\n @module @ember-data/serializer/rest\n*/\n\n/**\n ## Using Embedded Records\n\n `EmbeddedRecordsMixin` supports serializing embedded records.\n\n To set up embedded records, include the mixin when extending a serializer,\n then define and configure embedded (model) relationships.\n\n Note that embedded records will serialize with the serializer for their model instead of the serializer in which they are defined.\n\n Note also that this mixin does not work with JSONAPISerializer because the JSON:API specification does not describe how to format embedded resources.\n\n Below is an example of a per-type serializer (`post` type).\n\n ```app/serializers/post.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n author: { embedded: 'always' },\n comments: { serialize: 'ids' }\n }\n }\n ```\n Note that this use of `{ embedded: 'always' }` is unrelated to\n the `{ embedded: 'always' }` that is defined as an option on `attr` as part of\n defining a model while working with the `ActiveModelSerializer`. Nevertheless,\n using `{ embedded: 'always' }` as an option to `attr` is not a valid way to set up\n embedded records.\n\n The `attrs` option for a resource `{ embedded: 'always' }` is shorthand for:\n\n ```js\n {\n serialize: 'records',\n deserialize: 'records'\n }\n ```\n\n ### Configuring Attrs\n\n A resource's `attrs` option may be set to use `ids`, `records` or false for the\n `serialize` and `deserialize` settings.\n\n The `attrs` property can be set on the `ApplicationSerializer` or a per-type\n serializer.\n\n In the case where embedded JSON is expected while extracting a payload (reading)\n the setting is `deserialize: 'records'`, there is no need to use `ids` when\n extracting as that is the default behaviour without this mixin if you are using\n the vanilla `EmbeddedRecordsMixin`. Likewise, to embed JSON in the payload while\n serializing `serialize: 'records'` is the setting to use. There is an option of\n not embedding JSON in the serialized payload by using `serialize: 'ids'`. If you\n do not want the relationship sent at all, you can use `serialize: false`.\n\n\n ### EmbeddedRecordsMixin defaults\n If you do not overwrite `attrs` for a specific relationship, the `EmbeddedRecordsMixin`\n will behave in the following way:\n\n BelongsTo: `{ serialize: 'id', deserialize: 'id' }`\n HasMany: `{ serialize: false, deserialize: 'ids' }`\n\n ### Model Relationships\n\n Embedded records must have a model defined to be extracted and serialized. Note that\n when defining any relationships on your model such as `belongsTo` and `hasMany`, you\n should not both specify `async: true` and also indicate through the serializer's\n `attrs` attribute that the related model should be embedded for deserialization.\n If a model is declared embedded for deserialization (`embedded: 'always'` or `deserialize: 'records'`),\n then do not use `async: true`.\n\n To successfully extract and serialize embedded records the model relationships\n must be set up correctly. See the\n [defining relationships](https://guides.emberjs.com/current/models/relationships)\n section of the **Defining Models** guide page.\n\n Records without an `id` property are not considered embedded records, model\n instances must have an `id` property to be used with Ember Data.\n\n ### Example JSON payloads, Models and Serializers\n\n **When customizing a serializer it is important to grok what the customizations\n are. Please read the docs for the methods this mixin provides, in case you need\n to modify it to fit your specific needs.**\n\n For example, review the docs for each method of this mixin:\n * [normalize](/ember-data/release/classes/EmbeddedRecordsMixin/methods/normalize?anchor=normalize)\n * [serializeBelongsTo](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeBelongsTo?anchor=serializeBelongsTo)\n * [serializeHasMany](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeHasMany?anchor=serializeHasMany)\n\n @class EmbeddedRecordsMixin\n @public\n*/\nexport default Mixin.create({\n /**\n Normalize the record and recursively normalize/extract all the embedded records\n while pushing them into the store as they are encountered\n\n A payload with an attr configured for embedded records needs to be extracted:\n\n ```js\n {\n \"post\": {\n \"id\": \"1\"\n \"title\": \"Rails is omakase\",\n \"comments\": [{\n \"id\": \"1\",\n \"body\": \"Rails is unagi\"\n }, {\n \"id\": \"2\",\n \"body\": \"Omakase O_o\"\n }]\n }\n }\n ```\n @method normalize\n @public\n @param {Model} typeClass\n @param {Object} hash to be normalized\n @param {String} prop the hash has been referenced by\n @return {Object} the normalized hash\n **/\n normalize(typeClass, hash, prop) {\n let normalizedHash = this._super(typeClass, hash, prop);\n return this._extractEmbeddedRecords(this, this.store, typeClass, normalizedHash);\n },\n\n keyForRelationship(key, typeClass, method) {\n if (\n (method === 'serialize' && this.hasSerializeRecordsOption(key)) ||\n (method === 'deserialize' && this.hasDeserializeRecordsOption(key))\n ) {\n return this.keyForAttribute(key, method);\n } else {\n return this._super(key, typeClass, method) || key;\n }\n },\n\n /**\n Serialize `belongsTo` relationship when it is configured as an embedded object.\n\n This example of an author model belongs to a post model:\n\n ```js\n import Model, { attr, belongsTo } from '@ember-data/model';\n\n Post = Model.extend({\n title: attr('string'),\n body: attr('string'),\n author: belongsTo('author')\n });\n\n Author = Model.extend({\n name: attr('string'),\n post: belongsTo('post')\n });\n ```\n\n Use a custom (type) serializer for the post model to configure embedded author\n\n ```app/serializers/post.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n author: { embedded: 'always' }\n }\n }\n ```\n\n A payload with an attribute configured for embedded records can serialize\n the records together under the root attribute's payload:\n\n ```js\n {\n \"post\": {\n \"id\": \"1\"\n \"title\": \"Rails is omakase\",\n \"author\": {\n \"id\": \"2\"\n \"name\": \"dhh\"\n }\n }\n }\n ```\n\n @method serializeBelongsTo\n @public\n @param {Snapshot} snapshot\n @param {Object} json\n @param {Object} relationship\n */\n serializeBelongsTo(snapshot, json, relationship) {\n let attr = relationship.key;\n if (this.noSerializeOptionSpecified(attr)) {\n this._super(snapshot, json, relationship);\n return;\n }\n let includeIds = this.hasSerializeIdsOption(attr);\n let includeRecords = this.hasSerializeRecordsOption(attr);\n let embeddedSnapshot = snapshot.belongsTo(attr);\n if (includeIds) {\n let schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.key, schema);\n if (serializedKey === relationship.key && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');\n }\n\n if (!embeddedSnapshot) {\n json[serializedKey] = null;\n } else {\n json[serializedKey] = embeddedSnapshot.id;\n\n if (relationship.options.polymorphic) {\n this.serializePolymorphicType(snapshot, json, relationship);\n }\n }\n } else if (includeRecords) {\n this._serializeEmbeddedBelongsTo(snapshot, json, relationship);\n }\n },\n\n _serializeEmbeddedBelongsTo(snapshot, json, relationship) {\n let embeddedSnapshot = snapshot.belongsTo(relationship.key);\n let schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.key, schema);\n if (serializedKey === relationship.key && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');\n }\n\n if (!embeddedSnapshot) {\n json[serializedKey] = null;\n } else {\n json[serializedKey] = embeddedSnapshot.serialize({ includeId: true });\n this.removeEmbeddedForeignKey(snapshot, embeddedSnapshot, relationship, json[serializedKey]);\n\n if (relationship.options.polymorphic) {\n this.serializePolymorphicType(snapshot, json, relationship);\n }\n }\n },\n\n /**\n Serializes `hasMany` relationships when it is configured as embedded objects.\n\n This example of a post model has many comments:\n\n ```js\n import Model, { attr, belongsTo, hasMany } from '@ember-data/model';\n\n Post = Model.extend({\n title: attr('string'),\n body: attr('string'),\n comments: hasMany('comment')\n });\n\n Comment = Model.extend({\n body: attr('string'),\n post: belongsTo('post')\n });\n ```\n\n Use a custom (type) serializer for the post model to configure embedded comments\n\n ```app/serializers/post.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n comments: { embedded: 'always' }\n }\n }\n ```\n\n A payload with an attribute configured for embedded records can serialize\n the records together under the root attribute's payload:\n\n ```js\n {\n \"post\": {\n \"id\": \"1\"\n \"title\": \"Rails is omakase\",\n \"body\": \"I want this for my ORM, I want that for my template language...\"\n \"comments\": [{\n \"id\": \"1\",\n \"body\": \"Rails is unagi\"\n }, {\n \"id\": \"2\",\n \"body\": \"Omakase O_o\"\n }]\n }\n }\n ```\n\n The attrs options object can use more specific instruction for extracting and\n serializing. When serializing, an option to embed `ids`, `ids-and-types` or `records` can be set.\n When extracting the only option is `records`.\n\n So `{ embedded: 'always' }` is shorthand for:\n `{ serialize: 'records', deserialize: 'records' }`\n\n To embed the `ids` for a related object (using a hasMany relationship):\n\n ```app/serializers/post.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n comments: { serialize: 'ids', deserialize: 'records' }\n }\n }\n ```\n\n ```js\n {\n \"post\": {\n \"id\": \"1\"\n \"title\": \"Rails is omakase\",\n \"body\": \"I want this for my ORM, I want that for my template language...\"\n \"comments\": [\"1\", \"2\"]\n }\n }\n ```\n\n To embed the relationship as a collection of objects with `id` and `type` keys, set\n `ids-and-types` for the related object.\n\n This is particularly useful for polymorphic relationships where records don't share\n the same table and the `id` is not enough information.\n\n For example having a user that has many pets:\n\n ```js\n User = Model.extend({\n name: attr('string'),\n pets: hasMany('pet', { polymorphic: true })\n });\n\n Pet = Model.extend({\n name: attr('string'),\n });\n\n Cat = Pet.extend({\n // ...\n });\n\n Parrot = Pet.extend({\n // ...\n });\n ```\n\n ```app/serializers/user.js\n import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\n\n export default class UserSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) {\n attrs = {\n pets: { serialize: 'ids-and-types', deserialize: 'records' }\n }\n }\n ```\n\n ```js\n {\n \"user\": {\n \"id\": \"1\"\n \"name\": \"Bertin Osborne\",\n \"pets\": [\n { \"id\": \"1\", \"type\": \"Cat\" },\n { \"id\": \"1\", \"type\": \"Parrot\"}\n ]\n }\n }\n ```\n\n @method serializeHasMany\n @public\n @param {Snapshot} snapshot\n @param {Object} json\n @param {Object} relationship\n */\n serializeHasMany(snapshot, json, relationship) {\n let attr = relationship.key;\n if (this.noSerializeOptionSpecified(attr)) {\n this._super(snapshot, json, relationship);\n return;\n }\n\n if (this.hasSerializeIdsOption(attr)) {\n let schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.key, schema);\n if (serializedKey === relationship.key && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');\n }\n\n json[serializedKey] = snapshot.hasMany(attr, { ids: true });\n } else if (this.hasSerializeRecordsOption(attr)) {\n this._serializeEmbeddedHasMany(snapshot, json, relationship);\n } else {\n if (this.hasSerializeIdsAndTypesOption(attr)) {\n this._serializeHasManyAsIdsAndTypes(snapshot, json, relationship);\n }\n }\n },\n\n /*\n Serializes a hasMany relationship as an array of objects containing only `id` and `type`\n keys.\n This has its use case on polymorphic hasMany relationships where the server is not storing\n all records in the same table using STI, and therefore the `id` is not enough information\n\n TODO: Make the default in Ember-data 3.0??\n */\n _serializeHasManyAsIdsAndTypes(snapshot, json, relationship) {\n let serializedKey = this.keyForAttribute(relationship.key, 'serialize');\n let hasMany = snapshot.hasMany(relationship.key);\n\n json[serializedKey] = A(hasMany).map(function (recordSnapshot) {\n //\n // I'm sure I'm being utterly naive here. Probably id is a configurable property and\n // type too, and the modelName has to be normalized somehow.\n //\n return { id: recordSnapshot.id, type: recordSnapshot.modelName };\n });\n },\n\n _serializeEmbeddedHasMany(snapshot, json, relationship) {\n let schema = this.store.modelFor(snapshot.modelName);\n let serializedKey = this._getMappedKey(relationship.key, schema);\n if (serializedKey === relationship.key && this.keyForRelationship) {\n serializedKey = this.keyForRelationship(relationship.key, relationship.kind, 'serialize');\n }\n\n warn(\n `The embedded relationship '${serializedKey}' is undefined for '${snapshot.modelName}' with id '${snapshot.id}'. Please include it in your original payload.`,\n typeOf(snapshot.hasMany(relationship.key)) !== 'undefined',\n { id: 'ds.serializer.embedded-relationship-undefined' }\n );\n\n json[serializedKey] = this._generateSerializedHasMany(snapshot, relationship);\n },\n\n /*\n Returns an array of embedded records serialized to JSON\n */\n _generateSerializedHasMany(snapshot, relationship) {\n let hasMany = snapshot.hasMany(relationship.key);\n let manyArray = A(hasMany);\n let ret = new Array(manyArray.length);\n\n for (let i = 0; i < manyArray.length; i++) {\n let embeddedSnapshot = manyArray[i];\n let embeddedJson = embeddedSnapshot.serialize({ includeId: true });\n this.removeEmbeddedForeignKey(snapshot, embeddedSnapshot, relationship, embeddedJson);\n ret[i] = embeddedJson;\n }\n\n return ret;\n },\n\n /**\n When serializing an embedded record, modify the property (in the `JSON` payload)\n that refers to the parent record (foreign key for the relationship).\n\n Serializing a `belongsTo` relationship removes the property that refers to the\n parent record\n\n Serializing a `hasMany` relationship does not remove the property that refers to\n the parent record.\n\n @method removeEmbeddedForeignKey\n @public\n @param {Snapshot} snapshot\n @param {Snapshot} embeddedSnapshot\n @param {Object} relationship\n @param {Object} json\n */\n removeEmbeddedForeignKey(snapshot, embeddedSnapshot, relationship, json) {\n if (relationship.kind === 'belongsTo') {\n let schema = this.store.modelFor(snapshot.modelName);\n let parentRecord = schema.inverseFor(relationship.key, this.store);\n if (parentRecord) {\n let name = parentRecord.name;\n let embeddedSerializer = this.store.serializerFor(embeddedSnapshot.modelName);\n let parentKey = embeddedSerializer.keyForRelationship(name, parentRecord.kind, 'deserialize');\n if (parentKey) {\n delete json[parentKey];\n }\n }\n } /*else if (relationship.kind === 'hasMany') {\n return;\n }*/\n },\n\n // checks config for attrs option to embedded (always) - serialize and deserialize\n hasEmbeddedAlwaysOption(attr) {\n let option = this.attrsOption(attr);\n return option && option.embedded === 'always';\n },\n\n // checks config for attrs option to serialize ids\n hasSerializeRecordsOption(attr) {\n let alwaysEmbed = this.hasEmbeddedAlwaysOption(attr);\n let option = this.attrsOption(attr);\n return alwaysEmbed || (option && option.serialize === 'records');\n },\n\n // checks config for attrs option to serialize records\n hasSerializeIdsOption(attr) {\n let option = this.attrsOption(attr);\n return option && (option.serialize === 'ids' || option.serialize === 'id');\n },\n\n // checks config for attrs option to serialize records as objects containing id and types\n hasSerializeIdsAndTypesOption(attr) {\n let option = this.attrsOption(attr);\n return option && (option.serialize === 'ids-and-types' || option.serialize === 'id-and-type');\n },\n\n // checks config for attrs option to serialize records\n noSerializeOptionSpecified(attr) {\n let option = this.attrsOption(attr);\n return !(option && (option.serialize || option.embedded));\n },\n\n // checks config for attrs option to deserialize records\n // a defined option object for a resource is treated the same as\n // `deserialize: 'records'`\n hasDeserializeRecordsOption(attr) {\n let alwaysEmbed = this.hasEmbeddedAlwaysOption(attr);\n let option = this.attrsOption(attr);\n return alwaysEmbed || (option && option.deserialize === 'records');\n },\n\n attrsOption(attr) {\n let attrs = this.attrs;\n return attrs && (attrs[camelize(attr)] || attrs[attr]);\n },\n\n /**\n @method _extractEmbeddedRecords\n @private\n */\n _extractEmbeddedRecords(serializer, store, typeClass, partial) {\n typeClass.eachRelationship((key, relationship) => {\n if (serializer.hasDeserializeRecordsOption(key)) {\n if (relationship.kind === 'hasMany') {\n this._extractEmbeddedHasMany(store, key, partial, relationship);\n }\n if (relationship.kind === 'belongsTo') {\n this._extractEmbeddedBelongsTo(store, key, partial, relationship);\n }\n }\n });\n return partial;\n },\n\n /**\n @method _extractEmbeddedHasMany\n @private\n */\n _extractEmbeddedHasMany(store, key, hash, relationshipMeta) {\n let relationshipHash = hash.data?.relationships?.[key]?.data;\n\n if (!relationshipHash) {\n return;\n }\n\n let hasMany = new Array(relationshipHash.length);\n\n for (let i = 0; i < relationshipHash.length; i++) {\n let item = relationshipHash[i];\n let { data, included } = this._normalizeEmbeddedRelationship(store, relationshipMeta, item);\n hash.included = hash.included || [];\n hash.included.push(data);\n if (included) {\n hash.included = hash.included.concat(included);\n }\n\n hasMany[i] = { id: data.id, type: data.type };\n }\n\n let relationship = { data: hasMany };\n hash.data.relationships[key] = relationship;\n },\n\n /**\n @method _extractEmbeddedBelongsTo\n @private\n */\n _extractEmbeddedBelongsTo(store, key, hash, relationshipMeta) {\n let relationshipHash = hash.data?.relationships?.[key]?.data;\n if (!relationshipHash) {\n return;\n }\n\n let { data, included } = this._normalizeEmbeddedRelationship(store, relationshipMeta, relationshipHash);\n hash.included = hash.included || [];\n hash.included.push(data);\n if (included) {\n hash.included = hash.included.concat(included);\n }\n\n let belongsTo = { id: data.id, type: data.type };\n let relationship = { data: belongsTo };\n\n hash.data.relationships[key] = relationship;\n },\n\n /**\n @method _normalizeEmbeddedRelationship\n @private\n */\n _normalizeEmbeddedRelationship(store, relationshipMeta, relationshipHash) {\n let modelName = relationshipMeta.type;\n if (relationshipMeta.options.polymorphic) {\n modelName = relationshipHash.type;\n }\n let modelClass = store.modelFor(modelName);\n let serializer = store.serializerFor(modelName);\n\n return serializer.normalize(modelClass, relationshipHash, null);\n },\n isEmbeddedRecordsMixin: true,\n});\n"],"names":["Mixin","create","normalize","typeClass","hash","prop","normalizedHash","_super","_extractEmbeddedRecords","store","keyForRelationship","key","method","hasSerializeRecordsOption","hasDeserializeRecordsOption","keyForAttribute","serializeBelongsTo","snapshot","json","relationship","attr","noSerializeOptionSpecified","includeIds","hasSerializeIdsOption","includeRecords","embeddedSnapshot","belongsTo","schema","modelFor","modelName","serializedKey","_getMappedKey","kind","id","options","polymorphic","serializePolymorphicType","_serializeEmbeddedBelongsTo","serialize","includeId","removeEmbeddedForeignKey","serializeHasMany","hasMany","ids","_serializeEmbeddedHasMany","hasSerializeIdsAndTypesOption","_serializeHasManyAsIdsAndTypes","A","map","recordSnapshot","type","warn","typeOf","_generateSerializedHasMany","manyArray","ret","Array","length","i","embeddedJson","parentRecord","inverseFor","name","embeddedSerializer","serializerFor","parentKey","hasEmbeddedAlwaysOption","option","attrsOption","embedded","alwaysEmbed","deserialize","attrs","camelize","serializer","partial","eachRelationship","_extractEmbeddedHasMany","_extractEmbeddedBelongsTo","relationshipMeta","relationshipHash","data","relationships","item","included","_normalizeEmbeddedRelationship","push","concat","modelClass","isEmbeddedRecordsMixin"],"mappings":";;;;;;AAMA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAAeA,KAAK,CAACC,MAAM,CAAC;AAC1B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGEC,EAAAA,SAAS,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,kBAAkB,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,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S,EAAE,IAAA;AAAK,OAAC,CAAC,CAAA;AACrE,MAAA,IAAI,CAACC,wBAAwB,CAACvB,QAAQ,EAAEQ,gBAAgB,EAAEN,YAAY,EAAED,IAAI,CAACY,aAAa,CAAC,CAAC,CAAA;AAE5F,MAAA,IAAIX,YAAY,CAACe,OAAO,CAACC,WAAW,EAAE;QACpC,IAAI,CAACC,wBAAwB,CAACnB,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;AA2BEsB,EAAAA,gBAAgB,CAACxB,QAAQ,EAAEC,IAAI,EAAEC,YAAY,EAAE;AAC7C,IAAA,IAAIC,IAAI,GAAGD,YAAY,CAACR,GAAG,CAAA;AAC3B,IAAA,IAAI,IAAI,CAACU,0BAA0B,CAACD,IAAI,CAAC,EAAE;MACzC,IAAI,CAACb,MAAM,CAACU,QAAQ,EAAEC,IAAI,EAAEC,YAAY,CAAC,CAAA;AACzC,MAAA,OAAA;AACF,KAAA;AAEA,IAAA,IAAI,IAAI,CAACI,qBAAqB,CAACH,IAAI,CAAC,EAAE;MACpC,IAA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