ember-data-source 1.13.3 → 1.13.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dist/ember-data-tests.js +275 -7
- data/dist/ember-data.js +91 -35
- data/dist/ember-data.js.map +1 -1
- data/dist/ember-data.min.js +4 -4
- data/dist/ember-data.prod.js +88 -34
- data/package.json +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 697e9db009a98edf76770a04325a458d0883233b
|
4
|
+
data.tar.gz: c55896935e8b62f5354ad01c3b97abe5d9e0fc86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c22bae99bb68f26d374351eeef8cde7f40eb031c60d83a699a770332ee21b547d996e5e737aec70a65954ee9b67a88a124a07af2571636111f66ff0bb8569543
|
7
|
+
data.tar.gz: d09c254dbdb90ae9a5c1a0f90f8f6f7d749aaf5515cfecda1f9a1a0e5e316e00a3501251741d6ea17eeaa6ee0fcaea1693ef118e567dfa61a923949240f70027
|
data/dist/ember-data-tests.js
CHANGED
@@ -1845,7 +1845,7 @@ define(
|
|
1845
1845
|
run(function () {
|
1846
1846
|
expectDeprecation(function () {
|
1847
1847
|
store.findAll('person');
|
1848
|
-
}, 'The default behavior of shouldReloadAll will change in Ember Data 2.0 to always return false when there is at least one "person" record in the store. If you would like to preserve the current behavior please override shouldReloadAll in
|
1848
|
+
}, 'The default behavior of shouldReloadAll will change in Ember Data 2.0 to always return false when there is at least one "person" record in the store. If you would like to preserve the current behavior please override shouldReloadAll in your adapter:application and return true.');
|
1849
1849
|
});
|
1850
1850
|
});
|
1851
1851
|
|
@@ -2745,6 +2745,79 @@ define(
|
|
2745
2745
|
});
|
2746
2746
|
});
|
2747
2747
|
});
|
2748
|
+
|
2749
|
+
test('update record - serialize hasMany', function () {
|
2750
|
+
expect(3);
|
2751
|
+
|
2752
|
+
ajaxResponse([{
|
2753
|
+
data: {
|
2754
|
+
type: 'users',
|
2755
|
+
id: '1'
|
2756
|
+
}
|
2757
|
+
}]);
|
2758
|
+
|
2759
|
+
env.registry.register('serializer:user', DS.JSONAPISerializer.extend({
|
2760
|
+
attrs: {
|
2761
|
+
handles: { serialize: true }
|
2762
|
+
}
|
2763
|
+
}));
|
2764
|
+
|
2765
|
+
run(function () {
|
2766
|
+
var user = store.push({ data: {
|
2767
|
+
type: 'user',
|
2768
|
+
id: '1',
|
2769
|
+
attributes: {
|
2770
|
+
firstName: 'Yehuda',
|
2771
|
+
lastName: 'Katz'
|
2772
|
+
}
|
2773
|
+
} });
|
2774
|
+
|
2775
|
+
var githubHandle = store.push({ data: {
|
2776
|
+
type: 'github-handle',
|
2777
|
+
id: '2',
|
2778
|
+
attributes: {
|
2779
|
+
username: 'wycats'
|
2780
|
+
}
|
2781
|
+
} });
|
2782
|
+
|
2783
|
+
var twitterHandle = store.push({ data: {
|
2784
|
+
type: 'twitter-handle',
|
2785
|
+
id: '3',
|
2786
|
+
attributes: {
|
2787
|
+
nickname: '@wycats'
|
2788
|
+
}
|
2789
|
+
} });
|
2790
|
+
|
2791
|
+
user.set('firstName', 'Yehuda!');
|
2792
|
+
|
2793
|
+
user.get('handles').then(function (handles) {
|
2794
|
+
handles.addObject(githubHandle);
|
2795
|
+
handles.addObject(twitterHandle);
|
2796
|
+
|
2797
|
+
user.save().then(function () {
|
2798
|
+
equal(passedUrl[0], '/users/1');
|
2799
|
+
equal(passedVerb[0], 'PATCH');
|
2800
|
+
deepEqual(passedHash[0], {
|
2801
|
+
data: {
|
2802
|
+
data: {
|
2803
|
+
type: 'users',
|
2804
|
+
id: '1',
|
2805
|
+
attributes: {
|
2806
|
+
'first-name': 'Yehuda!',
|
2807
|
+
'last-name': 'Katz'
|
2808
|
+
},
|
2809
|
+
relationships: {
|
2810
|
+
handles: {
|
2811
|
+
data: [{ type: 'github-handles', id: '2' }, { type: 'twitter-handles', id: '3' }]
|
2812
|
+
}
|
2813
|
+
}
|
2814
|
+
}
|
2815
|
+
}
|
2816
|
+
});
|
2817
|
+
});
|
2818
|
+
});
|
2819
|
+
});
|
2820
|
+
});
|
2748
2821
|
}
|
2749
2822
|
);
|
2750
2823
|
|
@@ -3059,6 +3132,109 @@ define(
|
|
3059
3132
|
);
|
3060
3133
|
|
3061
3134
|
|
3135
|
+
define(
|
3136
|
+
"ember-data/tests/integration/adapter/rest-adapter-new-test",
|
3137
|
+
["exports"],
|
3138
|
+
function(__exports__) {
|
3139
|
+
"use strict";
|
3140
|
+
|
3141
|
+
function __es6_export__(name, value) {
|
3142
|
+
__exports__[name] = value;
|
3143
|
+
}
|
3144
|
+
|
3145
|
+
var env, store, adapter;
|
3146
|
+
|
3147
|
+
var passedUrl, passedVerb, passedHash;
|
3148
|
+
|
3149
|
+
var get = Ember.get;
|
3150
|
+
var run = Ember.run;
|
3151
|
+
|
3152
|
+
var Post, Comment;
|
3153
|
+
|
3154
|
+
module("integration/adapter/rest_adapter - REST Adapter (new API)", {
|
3155
|
+
setup: function () {
|
3156
|
+
Post = DS.Model.extend({
|
3157
|
+
title: DS.attr("string"),
|
3158
|
+
comments: DS.hasMany("comment")
|
3159
|
+
});
|
3160
|
+
|
3161
|
+
Post.toString = function () {
|
3162
|
+
return "Post";
|
3163
|
+
};
|
3164
|
+
|
3165
|
+
Comment = DS.Model.extend({
|
3166
|
+
text: DS.attr("string")
|
3167
|
+
});
|
3168
|
+
|
3169
|
+
env = setupStore({
|
3170
|
+
post: Post,
|
3171
|
+
comment: Comment,
|
3172
|
+
|
3173
|
+
adapter: DS.RESTAdapter.extend({
|
3174
|
+
defaultSerializer: "-rest-new"
|
3175
|
+
})
|
3176
|
+
});
|
3177
|
+
|
3178
|
+
store = env.store;
|
3179
|
+
adapter = env.adapter;
|
3180
|
+
|
3181
|
+
passedUrl = passedVerb = passedHash = null;
|
3182
|
+
}
|
3183
|
+
});
|
3184
|
+
|
3185
|
+
function ajaxResponse(value) {
|
3186
|
+
adapter.ajax = function (url, verb, hash) {
|
3187
|
+
passedUrl = url;
|
3188
|
+
passedVerb = verb;
|
3189
|
+
passedHash = hash;
|
3190
|
+
|
3191
|
+
return run(Ember.RSVP, "resolve", Ember.copy(value, true));
|
3192
|
+
};
|
3193
|
+
}
|
3194
|
+
|
3195
|
+
test("metadata is accessible", function () {
|
3196
|
+
ajaxResponse({
|
3197
|
+
meta: { offset: 5 },
|
3198
|
+
posts: [{ id: 1, title: "Rails is very expensive sushi" }]
|
3199
|
+
});
|
3200
|
+
|
3201
|
+
store.findAll("post").then(async(function (posts) {
|
3202
|
+
equal(store.metadataFor("post").offset, 5, "Metadata can be accessed with metadataFor.");
|
3203
|
+
}));
|
3204
|
+
});
|
3205
|
+
|
3206
|
+
test("create - sideloaded records are pushed to the store", function () {
|
3207
|
+
ajaxResponse({
|
3208
|
+
post: {
|
3209
|
+
id: 1,
|
3210
|
+
title: "The Parley Letter",
|
3211
|
+
comments: [2, 3]
|
3212
|
+
},
|
3213
|
+
comments: [{
|
3214
|
+
id: 2,
|
3215
|
+
text: "First comment"
|
3216
|
+
}, {
|
3217
|
+
id: 3,
|
3218
|
+
text: "Second comment"
|
3219
|
+
}]
|
3220
|
+
});
|
3221
|
+
var post;
|
3222
|
+
|
3223
|
+
run(function () {
|
3224
|
+
post = store.createRecord("post", { name: "The Parley Letter" });
|
3225
|
+
post.save().then(function (post) {
|
3226
|
+
var comments = store.peekAll("comment");
|
3227
|
+
|
3228
|
+
equal(get(comments, "length"), 2, "comments.length is correct");
|
3229
|
+
equal(get(comments, "firstObject.text"), "First comment", "comments.firstObject.text is correct");
|
3230
|
+
equal(get(comments, "lastObject.text"), "Second comment", "comments.lastObject.text is correct");
|
3231
|
+
});
|
3232
|
+
});
|
3233
|
+
});
|
3234
|
+
}
|
3235
|
+
);
|
3236
|
+
|
3237
|
+
|
3062
3238
|
// Noop
|
3063
3239
|
// NOOP
|
3064
3240
|
// Noop
|
@@ -15988,24 +16164,109 @@ define(
|
|
15988
16164
|
__exports__[name] = value;
|
15989
16165
|
}
|
15990
16166
|
|
15991
|
-
var env;
|
16167
|
+
var env, store, serializer;
|
16168
|
+
|
16169
|
+
var get = Ember.get;
|
15992
16170
|
var run = Ember.run;
|
15993
16171
|
|
16172
|
+
var User, Handle, GithubHandle, TwitterHandle, Company;
|
16173
|
+
|
15994
16174
|
module('integration/serializers/json-api-serializer - JSONAPISerializer', {
|
15995
16175
|
setup: function () {
|
15996
|
-
|
16176
|
+
User = DS.Model.extend({
|
16177
|
+
firstName: DS.attr('string'),
|
16178
|
+
lastName: DS.attr('string'),
|
16179
|
+
handles: DS.hasMany('handle', { async: true, polymorphic: true }),
|
16180
|
+
company: DS.belongsTo('company', { async: true })
|
16181
|
+
});
|
16182
|
+
|
16183
|
+
Handle = DS.Model.extend({
|
16184
|
+
user: DS.belongsTo('user', { async: true })
|
16185
|
+
});
|
16186
|
+
|
16187
|
+
GithubHandle = Handle.extend({
|
16188
|
+
username: DS.attr('string')
|
16189
|
+
});
|
16190
|
+
|
16191
|
+
TwitterHandle = Handle.extend({
|
16192
|
+
nickname: DS.attr('string')
|
16193
|
+
});
|
16194
|
+
|
16195
|
+
Company = DS.Model.extend({
|
16196
|
+
name: DS.attr('string'),
|
16197
|
+
employees: DS.hasMany('user', { async: true })
|
16198
|
+
});
|
16199
|
+
|
16200
|
+
env = setupStore({
|
16201
|
+
adapter: DS.JSONAPIAdapter,
|
16202
|
+
|
16203
|
+
user: User,
|
16204
|
+
handle: Handle,
|
16205
|
+
'github-handle': GithubHandle,
|
16206
|
+
'twitter-handle': TwitterHandle,
|
16207
|
+
company: Company
|
16208
|
+
});
|
16209
|
+
|
16210
|
+
store = env.store;
|
16211
|
+
serializer = env.container.lookup('serializer:-json-api');
|
15997
16212
|
},
|
15998
16213
|
|
15999
16214
|
teardown: function () {
|
16000
16215
|
run(env.store, 'destroy');
|
16001
16216
|
}
|
16002
16217
|
});
|
16003
|
-
}
|
16004
|
-
);
|
16005
16218
|
|
16006
|
-
|
16219
|
+
test('Calling pushPayload works', function () {
|
16220
|
+
run(function () {
|
16221
|
+
serializer.pushPayload(store, {
|
16222
|
+
data: {
|
16223
|
+
type: 'users',
|
16224
|
+
id: '1',
|
16225
|
+
attributes: {
|
16226
|
+
'first-name': 'Yehuda',
|
16227
|
+
'last-name': 'Katz'
|
16228
|
+
},
|
16229
|
+
relationships: {
|
16230
|
+
company: {
|
16231
|
+
data: { type: 'companies', id: '2' }
|
16232
|
+
},
|
16233
|
+
handles: {
|
16234
|
+
data: [{ type: 'github-handles', id: '3' }, { type: 'twitter-handles', id: '4' }]
|
16235
|
+
}
|
16236
|
+
}
|
16237
|
+
},
|
16238
|
+
included: [{
|
16239
|
+
type: 'companies',
|
16240
|
+
id: '2',
|
16241
|
+
attributes: {
|
16242
|
+
name: 'Tilde Inc.'
|
16243
|
+
}
|
16244
|
+
}, {
|
16245
|
+
type: 'github-handles',
|
16246
|
+
id: '3',
|
16247
|
+
attributes: {
|
16248
|
+
username: 'wycats'
|
16249
|
+
}
|
16250
|
+
}, {
|
16251
|
+
type: 'twitter-handles',
|
16252
|
+
id: '4',
|
16253
|
+
attributes: {
|
16254
|
+
nickname: '@wycats'
|
16255
|
+
}
|
16256
|
+
}]
|
16257
|
+
});
|
16258
|
+
|
16259
|
+
var user = store.peekRecord('user', 1);
|
16007
16260
|
|
16008
|
-
|
16261
|
+
equal(get(user, 'firstName'), 'Yehuda', 'firstName is correct');
|
16262
|
+
equal(get(user, 'lastName'), 'Katz', 'lastName is correct');
|
16263
|
+
equal(get(user, 'company.name'), 'Tilde Inc.', 'company.name is correct');
|
16264
|
+
equal(get(user, 'handles.firstObject.username'), 'wycats', 'handles.firstObject.username is correct');
|
16265
|
+
equal(get(user, 'handles.lastObject.nickname'), '@wycats', 'handles.lastObject.nickname is correct');
|
16266
|
+
});
|
16267
|
+
});
|
16268
|
+
}
|
16269
|
+
);
|
16009
16270
|
|
16010
16271
|
|
16011
16272
|
define(
|
@@ -26977,6 +27238,13 @@ test('ember-data/tests/integration/adapter/record-persistence-test.js should pas
|
|
26977
27238
|
ok(true, 'ember-data/tests/integration/adapter/record-persistence-test.js should pass jshint.');
|
26978
27239
|
});
|
26979
27240
|
|
27241
|
+
}
|
27242
|
+
if (!QUnit.urlParams.nojshint) {
|
27243
|
+
module('JSHint - ember-data/tests/integration/adapter');
|
27244
|
+
test('ember-data/tests/integration/adapter/rest-adapter-new-test.js should pass jshint', function() {
|
27245
|
+
ok(true, 'ember-data/tests/integration/adapter/rest-adapter-new-test.js should pass jshint.');
|
27246
|
+
});
|
27247
|
+
|
26980
27248
|
}
|
26981
27249
|
if (!QUnit.urlParams.nojshint) {
|
26982
27250
|
module('JSHint - ember-data/tests/integration/adapter');
|
data/dist/ember-data.js
CHANGED
@@ -252,7 +252,7 @@
|
|
252
252
|
/**
|
253
253
|
Implement this method in a subclass to handle the creation of
|
254
254
|
new records.
|
255
|
-
Serializes the record and
|
255
|
+
Serializes the record and sends it to the server.
|
256
256
|
Example
|
257
257
|
```app/adapters/application.js
|
258
258
|
import DS from 'ember-data';
|
@@ -287,7 +287,7 @@
|
|
287
287
|
/**
|
288
288
|
Implement this method in a subclass to handle the updating of
|
289
289
|
a record.
|
290
|
-
Serializes the record update and
|
290
|
+
Serializes the record update and sends it to the server.
|
291
291
|
Example
|
292
292
|
```app/adapters/application.js
|
293
293
|
import DS from 'ember-data';
|
@@ -360,14 +360,14 @@
|
|
360
360
|
By default the store will try to coalesce all `fetchRecord` calls within the same runloop
|
361
361
|
into as few requests as possible by calling groupRecordsForFindMany and passing it into a findMany call.
|
362
362
|
You can opt out of this behaviour by either not implementing the findMany hook or by setting
|
363
|
-
coalesceFindRequests to false
|
363
|
+
coalesceFindRequests to false.
|
364
364
|
@property coalesceFindRequests
|
365
365
|
@type {boolean}
|
366
366
|
*/
|
367
367
|
coalesceFindRequests: true,
|
368
368
|
|
369
369
|
/**
|
370
|
-
Find multiple records at once if coalesceFindRequests is true
|
370
|
+
Find multiple records at once if coalesceFindRequests is true.
|
371
371
|
@method findMany
|
372
372
|
@param {DS.Store} store
|
373
373
|
@param {DS.Model} type the DS.Model class of the records
|
@@ -396,7 +396,7 @@
|
|
396
396
|
This method is used by the store to determine if the store should
|
397
397
|
reload a record from the adapter when a record is requested by
|
398
398
|
`store.findRecord`.
|
399
|
-
If this method returns true the store will re fetch a record
|
399
|
+
If this method returns true the store will re fetch a record from
|
400
400
|
the adapter. If is method returns false the store will resolve
|
401
401
|
immediately using the cached record.
|
402
402
|
@method shouldReloadRecord
|
@@ -412,7 +412,7 @@
|
|
412
412
|
This method is used by the store to determine if the store should
|
413
413
|
reload all records from the adapter when records are requested by
|
414
414
|
`store.findAll`.
|
415
|
-
If this method returns true the store will re fetch all records
|
415
|
+
If this method returns true the store will re fetch all records from
|
416
416
|
the adapter. If is method returns false the store will resolve
|
417
417
|
immediately using the cached record.
|
418
418
|
@method shouldReloadRecord
|
@@ -422,17 +422,17 @@
|
|
422
422
|
*/
|
423
423
|
shouldReloadAll: function (store, snapshotRecordArray) {
|
424
424
|
var modelName = snapshotRecordArray.type.modelName;
|
425
|
-
Ember.deprecate('The default behavior of shouldReloadAll will change in Ember Data 2.0 to always return false when there is at least one "' + modelName + '" record in the store. If you would like to preserve the current behavior please override shouldReloadAll in
|
425
|
+
Ember.deprecate('The default behavior of shouldReloadAll will change in Ember Data 2.0 to always return false when there is at least one "' + modelName + '" record in the store. If you would like to preserve the current behavior please override shouldReloadAll in your adapter:application and return true.');
|
426
426
|
return true;
|
427
427
|
},
|
428
428
|
|
429
429
|
/**
|
430
430
|
This method is used by the store to determine if the store should
|
431
431
|
reload a record after the `store.findRecord` method resolves a
|
432
|
-
|
432
|
+
cached record.
|
433
433
|
This method is *only* checked by the store when the store is
|
434
434
|
returning a cached record.
|
435
|
-
If this method returns true the store will re-fetch a record
|
435
|
+
If this method returns true the store will re-fetch a record from
|
436
436
|
the adapter.
|
437
437
|
@method shouldBackgroundReloadRecord
|
438
438
|
@param {DS.Store} store
|
@@ -440,18 +440,18 @@
|
|
440
440
|
@return {Boolean}
|
441
441
|
*/
|
442
442
|
shouldBackgroundReloadRecord: function (store, snapshot) {
|
443
|
-
Ember.deprecate('The default behavior of `shouldBackgroundReloadRecord` will change in Ember Data 2.0 to always return true. If you would like to preserve the current behavior please override `shouldBackgroundReloadRecord` in
|
443
|
+
Ember.deprecate('The default behavior of `shouldBackgroundReloadRecord` will change in Ember Data 2.0 to always return true. If you would like to preserve the current behavior please override `shouldBackgroundReloadRecord` in your adapter:application and return false.');
|
444
444
|
return false;
|
445
445
|
},
|
446
446
|
|
447
447
|
/**
|
448
448
|
This method is used by the store to determine if the store should
|
449
449
|
reload a record array after the `store.findAll` method resolves
|
450
|
-
with a
|
450
|
+
with a cached record array.
|
451
451
|
This method is *only* checked by the store when the store is
|
452
452
|
returning a cached record array.
|
453
453
|
If this method returns true the store will re-fetch all records
|
454
|
-
|
454
|
+
from the adapter.
|
455
455
|
@method shouldBackgroundReloadAll
|
456
456
|
@param {DS.Store} store
|
457
457
|
@param {DS.SnapshotRecordArray} snapshotRecordArray
|
@@ -4347,7 +4347,7 @@
|
|
4347
4347
|
}
|
4348
4348
|
|
4349
4349
|
if (payload && payload.meta) {
|
4350
|
-
store.
|
4350
|
+
store._setMetadataFor(typeClass, payload.meta);
|
4351
4351
|
delete payload.meta;
|
4352
4352
|
}
|
4353
4353
|
},
|
@@ -5691,7 +5691,12 @@
|
|
5691
5691
|
*/
|
5692
5692
|
function ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, modelClass, payload, id, requestType) {
|
5693
5693
|
if (serializer.get('isNewSerializerAPI')) {
|
5694
|
-
|
5694
|
+
var normalizedResponse = serializer.normalizeResponse(store, modelClass, payload, id, requestType);
|
5695
|
+
// TODO: Remove after metadata refactor
|
5696
|
+
if (normalizedResponse.meta) {
|
5697
|
+
store._setMetadataFor(modelClass.modelName, normalizedResponse.meta);
|
5698
|
+
}
|
5699
|
+
return normalizedResponse;
|
5695
5700
|
} else {
|
5696
5701
|
Ember.deprecate('Your custom serializer uses the old version of the Serializer API, with `extract` hooks. Please upgrade your serializers to the new Serializer API using `normalizeResponse` hooks instead.');
|
5697
5702
|
var serializerPayload = serializer.extract(store, modelClass, payload, id, requestType);
|
@@ -5712,7 +5717,7 @@
|
|
5712
5717
|
var data = null;
|
5713
5718
|
|
5714
5719
|
if (payload) {
|
5715
|
-
if (Ember.
|
5720
|
+
if (Ember.typeOf(payload) === 'array') {
|
5716
5721
|
data = ember$data$lib$system$store$serializer$response$$map.call(payload, function (payload) {
|
5717
5722
|
return ember$data$lib$system$store$serializer$response$$_normalizeSerializerPayloadItem(modelClass, payload);
|
5718
5723
|
});
|
@@ -6905,7 +6910,7 @@
|
|
6905
6910
|
@module ember-data
|
6906
6911
|
*/
|
6907
6912
|
|
6908
|
-
var activemodel$adapter$lib$system$active$model$serializer$$forEach = Ember.
|
6913
|
+
var activemodel$adapter$lib$system$active$model$serializer$$forEach = Ember.ArrayPolyfills.forEach;
|
6909
6914
|
var activemodel$adapter$lib$system$active$model$serializer$$camelize = Ember.String.camelize;
|
6910
6915
|
var activemodel$adapter$lib$system$active$model$serializer$$classify = Ember.String.classify;
|
6911
6916
|
var activemodel$adapter$lib$system$active$model$serializer$$decamelize = Ember.String.decamelize;
|
@@ -7166,7 +7171,7 @@
|
|
7166
7171
|
payload.type = this.modelNameFromPayloadKey(payload.type);
|
7167
7172
|
} else if (payload && relationship.kind === "hasMany") {
|
7168
7173
|
var self = this;
|
7169
|
-
activemodel$adapter$lib$system$active$model$serializer$$forEach(payload, function (single) {
|
7174
|
+
activemodel$adapter$lib$system$active$model$serializer$$forEach.call(payload, function (single) {
|
7170
7175
|
single.type = self.modelNameFromPayloadKey(single.type);
|
7171
7176
|
});
|
7172
7177
|
}
|
@@ -7249,7 +7254,7 @@
|
|
7249
7254
|
registry.register("adapter:-active-model", activemodel$adapter$lib$system$active$model$adapter$$default);
|
7250
7255
|
}
|
7251
7256
|
var ember$data$lib$core$$DS = Ember.Namespace.create({
|
7252
|
-
VERSION: '1.13.
|
7257
|
+
VERSION: '1.13.4'
|
7253
7258
|
});
|
7254
7259
|
|
7255
7260
|
if (Ember.libraries) {
|
@@ -7785,7 +7790,7 @@
|
|
7785
7790
|
var store = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this, "store");
|
7786
7791
|
var type = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this, "type");
|
7787
7792
|
var modelName = type.modelName;
|
7788
|
-
var meta = store.
|
7793
|
+
var meta = store._metadataFor(modelName);
|
7789
7794
|
|
7790
7795
|
//TODO Optimize
|
7791
7796
|
var internalModels = Ember.A(records).mapBy("_internalModel");
|
@@ -12312,8 +12317,20 @@
|
|
12312
12317
|
@method metadataFor
|
12313
12318
|
@param {String} modelName
|
12314
12319
|
@return {object}
|
12320
|
+
@deprecated
|
12315
12321
|
*/
|
12316
12322
|
metadataFor: function (modelName) {
|
12323
|
+
Ember.deprecate("`store.metadataFor()` has been deprecated. You can use `.get('meta')` on relationships and arrays returned from `store.query()`.");
|
12324
|
+
return this._metadataFor(modelName);
|
12325
|
+
},
|
12326
|
+
|
12327
|
+
/**
|
12328
|
+
@method _metadataFor
|
12329
|
+
@param {String} modelName
|
12330
|
+
@return {object}
|
12331
|
+
@private
|
12332
|
+
*/
|
12333
|
+
_metadataFor: function (modelName) {
|
12317
12334
|
Ember.assert("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), typeof modelName === "string");
|
12318
12335
|
var typeClass = this.modelFor(modelName);
|
12319
12336
|
return this.typeMapFor(typeClass).metadata;
|
@@ -12325,8 +12342,20 @@
|
|
12325
12342
|
@param {String} modelName
|
12326
12343
|
@param {Object} metadata metadata to set
|
12327
12344
|
@return {object}
|
12345
|
+
@deprecated
|
12328
12346
|
*/
|
12329
12347
|
setMetadataFor: function (modelName, metadata) {
|
12348
|
+
Ember.deprecate("`store.setMetadataFor()` has been deprecated. Please return meta from your serializer's `extractMeta` hook.");
|
12349
|
+
this._setMetadataFor(modelName, metadata);
|
12350
|
+
},
|
12351
|
+
|
12352
|
+
/**
|
12353
|
+
@method _setMetadataFor
|
12354
|
+
@param {String} modelName
|
12355
|
+
@param {Object} metadata metadata to set
|
12356
|
+
@private
|
12357
|
+
*/
|
12358
|
+
_setMetadataFor: function (modelName, metadata) {
|
12330
12359
|
Ember.assert("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), typeof modelName === "string");
|
12331
12360
|
var typeClass = this.modelFor(modelName);
|
12332
12361
|
Ember.merge(this.typeMapFor(typeClass).metadata, metadata);
|
@@ -12674,11 +12703,11 @@
|
|
12674
12703
|
if (Ember.typeOf(modelNameArg) === "object" && Ember.typeOf(dataArg) === "undefined") {
|
12675
12704
|
data = modelNameArg;
|
12676
12705
|
} else {
|
12706
|
+
Ember.deprecate("store.push(type, data) has been deprecated. Please provide a JSON-API document object as the first and only argument to store.push.");
|
12677
12707
|
Ember.assert("Expected an object as `data` in a call to `push` for " + modelNameArg + " , but was " + Ember.typeOf(dataArg), Ember.typeOf(dataArg) === "object");
|
12678
12708
|
Ember.assert("You must include an `id` for " + modelNameArg + " in an object passed to `push`", dataArg.id != null && dataArg.id !== "");
|
12679
12709
|
data = ember$data$lib$system$store$serializer$response$$_normalizeSerializerPayload(this.modelFor(modelNameArg), dataArg);
|
12680
12710
|
modelName = modelNameArg;
|
12681
|
-
Ember.deprecate("store.push(type, data) has been deprecated. Please provide a JSON-API document object as the first and only argument to store.push.");
|
12682
12711
|
Ember.assert("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), typeof modelName === "string" || typeof data === "undefined");
|
12683
12712
|
}
|
12684
12713
|
|
@@ -13141,6 +13170,9 @@
|
|
13141
13170
|
var payload, data;
|
13142
13171
|
if (adapterPayload) {
|
13143
13172
|
payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, snapshot.id, operation);
|
13173
|
+
if (payload.included) {
|
13174
|
+
store.push({ data: payload.included });
|
13175
|
+
}
|
13144
13176
|
data = ember$data$lib$system$store$serializer$response$$convertResourceObject(payload.data);
|
13145
13177
|
}
|
13146
13178
|
store.didSaveRecord(internalModel, ember$data$lib$system$store$serializer$response$$_normalizeSerializerPayload(internalModel.type, data));
|
@@ -13227,7 +13259,7 @@
|
|
13227
13259
|
var ember$data$lib$system$store$$default = ember$data$lib$system$store$$Store;
|
13228
13260
|
|
13229
13261
|
var ember$data$lib$serializers$json$api$serializer$$dasherize = Ember.String.dasherize;
|
13230
|
-
var ember$data$lib$serializers$json$api$serializer$$map = Ember.
|
13262
|
+
var ember$data$lib$serializers$json$api$serializer$$map = Ember.ArrayPolyfills.map;
|
13231
13263
|
|
13232
13264
|
var ember$data$lib$serializers$json$api$serializer$$default = ember$data$lib$serializers$json$serializer$$default.extend({
|
13233
13265
|
|
@@ -13239,6 +13271,27 @@
|
|
13239
13271
|
*/
|
13240
13272
|
isNewSerializerAPI: true,
|
13241
13273
|
|
13274
|
+
/*
|
13275
|
+
@method _normalizeDocumentHelper
|
13276
|
+
@param {Object} documentHash
|
13277
|
+
@return {Object}
|
13278
|
+
@private
|
13279
|
+
*/
|
13280
|
+
_normalizeDocumentHelper: function (documentHash) {
|
13281
|
+
|
13282
|
+
if (Ember.typeOf(documentHash.data) === 'object') {
|
13283
|
+
documentHash.data = this._normalizeResourceHelper(documentHash.data);
|
13284
|
+
} else {
|
13285
|
+
documentHash.data = ember$data$lib$serializers$json$api$serializer$$map.call(documentHash.data, this._normalizeResourceHelper, this);
|
13286
|
+
}
|
13287
|
+
|
13288
|
+
if (Ember.typeOf(documentHash.included) === 'array') {
|
13289
|
+
documentHash.included = ember$data$lib$serializers$json$api$serializer$$map.call(documentHash.included, this._normalizeResourceHelper, this);
|
13290
|
+
}
|
13291
|
+
|
13292
|
+
return documentHash;
|
13293
|
+
},
|
13294
|
+
|
13242
13295
|
/*
|
13243
13296
|
@method _normalizeRelationshipDataHelper
|
13244
13297
|
@param {Object} relationshipDataHash
|
@@ -13269,6 +13322,16 @@
|
|
13269
13322
|
return data;
|
13270
13323
|
},
|
13271
13324
|
|
13325
|
+
/**
|
13326
|
+
@method pushPayload
|
13327
|
+
@param {DS.Store} store
|
13328
|
+
@param {Object} payload
|
13329
|
+
*/
|
13330
|
+
pushPayload: function (store, payload) {
|
13331
|
+
var normalizedPayload = this._normalizeDocumentHelper(payload);
|
13332
|
+
store.push(normalizedPayload);
|
13333
|
+
},
|
13334
|
+
|
13272
13335
|
/**
|
13273
13336
|
@method _normalizeResponse
|
13274
13337
|
@param {DS.Store} store
|
@@ -13282,17 +13345,8 @@
|
|
13282
13345
|
*/
|
13283
13346
|
_normalizeResponse: function (store, primaryModelClass, payload, id, requestType, isSingle) {
|
13284
13347
|
|
13285
|
-
|
13286
|
-
|
13287
|
-
} else {
|
13288
|
-
payload.data = ember$data$lib$serializers$json$api$serializer$$map(payload.data, this._normalizeResourceHelper, this);
|
13289
|
-
}
|
13290
|
-
|
13291
|
-
if (Ember.typeOf(payload.included) === 'array') {
|
13292
|
-
payload.included = ember$data$lib$serializers$json$api$serializer$$map(payload.included, this._normalizeResourceHelper, this);
|
13293
|
-
}
|
13294
|
-
|
13295
|
-
return payload;
|
13348
|
+
var normalizedPayload = this._normalizeDocumentHelper(payload);
|
13349
|
+
return normalizedPayload;
|
13296
13350
|
},
|
13297
13351
|
|
13298
13352
|
/*
|
@@ -13330,7 +13384,7 @@
|
|
13330
13384
|
}
|
13331
13385
|
|
13332
13386
|
if (Ember.typeOf(relationshipHash.data) === 'array') {
|
13333
|
-
relationshipHash.data = ember$data$lib$serializers$json$api$serializer$$map(relationshipHash.data, this._normalizeRelationshipDataHelper, this);
|
13387
|
+
relationshipHash.data = ember$data$lib$serializers$json$api$serializer$$map.call(relationshipHash.data, this._normalizeRelationshipDataHelper, this);
|
13334
13388
|
}
|
13335
13389
|
|
13336
13390
|
return relationshipHash;
|
@@ -13512,6 +13566,8 @@
|
|
13512
13566
|
@param {Object} relationship
|
13513
13567
|
*/
|
13514
13568
|
serializeHasMany: function (snapshot, json, relationship) {
|
13569
|
+
var _this3 = this;
|
13570
|
+
|
13515
13571
|
var key = relationship.key;
|
13516
13572
|
|
13517
13573
|
if (this._shouldSerializeHasMany(snapshot, key, relationship)) {
|
@@ -13525,9 +13581,9 @@
|
|
13525
13581
|
payloadKey = this.keyForRelationship(key, 'hasMany', 'serialize');
|
13526
13582
|
}
|
13527
13583
|
|
13528
|
-
var data = ember$data$lib$serializers$json$api$serializer$$map(hasMany, function (item) {
|
13584
|
+
var data = ember$data$lib$serializers$json$api$serializer$$map.call(hasMany, function (item) {
|
13529
13585
|
return {
|
13530
|
-
type: item.modelName,
|
13586
|
+
type: _this3.payloadKeyFromModelName(item.modelName),
|
13531
13587
|
id: item.id
|
13532
13588
|
};
|
13533
13589
|
});
|