ember-data-source 2.6.0.beta.1 → 2.6.0.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dist/globals/ember-data.js +568 -760
- data/dist/globals/ember-data.min.js +5 -5
- data/dist/globals/ember-data.prod.js +288 -51
- 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: b4e14899e03d2ce787afc72a12858bb8137bc1d8
|
4
|
+
data.tar.gz: 62e76414b4f6d6024f3fb22c73570d503bfc8999
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66befa12de9851f18f254b4786c644aa731d347f07bb2d7fde687f3deae784e4d54a6de8a4175d33a8f4e915690701597e09013824f3ca892903fe1dcbf9b6d8
|
7
|
+
data.tar.gz: 0235b563e7e1d5d4d9c99c117cd959d21dc13e6f7611d1e57a860bb6997b00f8b26bec1d5ac4de2987c2e314af6725b62e386bd6f3eb94989996735d3a4e6ebe
|
data/dist/globals/ember-data.js
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
* @copyright Copyright 2011-2016 Tilde Inc. and contributors.
|
7
7
|
* Portions Copyright 2011 LivingSocial Inc.
|
8
8
|
* @license Licensed under MIT license (see license.js)
|
9
|
-
* @version 2.6.0-beta.
|
9
|
+
* @version 2.6.0-beta.2
|
10
10
|
*/
|
11
11
|
|
12
12
|
var loader, define, requireModule, require, requirejs;
|
@@ -63,16 +63,17 @@ var loader, define, requireModule, require, requirejs;
|
|
63
63
|
|
64
64
|
var defaultDeps = ['require', 'exports', 'module'];
|
65
65
|
|
66
|
-
function Module(name, deps, callback) {
|
66
|
+
function Module(name, deps, callback, alias) {
|
67
67
|
this.id = uuid++;
|
68
68
|
this.name = name;
|
69
69
|
this.deps = !deps.length && callback.length ? defaultDeps : deps;
|
70
70
|
this.module = { exports: {} };
|
71
71
|
this.callback = callback;
|
72
72
|
this.state = undefined;
|
73
|
-
this._require = undefined;
|
74
73
|
this.finalized = false;
|
75
74
|
this.hasExportsAsDep = false;
|
75
|
+
this.isAlias = alias;
|
76
|
+
this.reified = new Array(deps.length);
|
76
77
|
}
|
77
78
|
|
78
79
|
Module.prototype.makeDefaultExport = function() {
|
@@ -84,14 +85,14 @@ var loader, define, requireModule, require, requirejs;
|
|
84
85
|
}
|
85
86
|
};
|
86
87
|
|
87
|
-
Module.prototype.exports = function(
|
88
|
+
Module.prototype.exports = function() {
|
88
89
|
if (this.finalized) {
|
89
90
|
return this.module.exports;
|
90
91
|
} else {
|
91
92
|
if (loader.wrapModules) {
|
92
93
|
this.callback = loader.wrapModules(this.name, this.callback);
|
93
94
|
}
|
94
|
-
var result = this.callback.apply(this,
|
95
|
+
var result = this.callback.apply(this, this.reified);
|
95
96
|
if (!(this.hasExportsAsDep && result === undefined)) {
|
96
97
|
this.module.exports = result;
|
97
98
|
}
|
@@ -109,11 +110,10 @@ var loader, define, requireModule, require, requirejs;
|
|
109
110
|
|
110
111
|
Module.prototype.reify = function() {
|
111
112
|
var deps = this.deps;
|
112
|
-
var length = deps.length;
|
113
|
-
var reified = new Array(length);
|
114
113
|
var dep;
|
114
|
+
var reified = this.reified;
|
115
115
|
|
116
|
-
for (var i = 0
|
116
|
+
for (var i = 0; i < deps.length; i++) {
|
117
117
|
dep = deps[i];
|
118
118
|
if (dep === 'exports') {
|
119
119
|
this.hasExportsAsDep = true;
|
@@ -126,22 +126,25 @@ var loader, define, requireModule, require, requirejs;
|
|
126
126
|
reified[i] = findModule(resolve(dep, this.name), this.name).module.exports;
|
127
127
|
}
|
128
128
|
}
|
129
|
-
|
130
|
-
return reified;
|
131
129
|
};
|
132
130
|
|
133
131
|
Module.prototype.makeRequire = function() {
|
134
132
|
var name = this.name;
|
135
|
-
|
136
|
-
return this._require || (this._require = function(dep) {
|
133
|
+
var r = function(dep) {
|
137
134
|
return require(resolve(dep, name));
|
138
|
-
}
|
135
|
+
};
|
136
|
+
r['default'] = r;
|
137
|
+
r.has = function(dep) {
|
138
|
+
return has(resolve(dep, name));
|
139
|
+
}
|
140
|
+
return r;
|
139
141
|
};
|
140
142
|
|
141
143
|
Module.prototype.build = function() {
|
142
|
-
if (this.state === FAILED) { return; }
|
144
|
+
if (this.state === FAILED || this.state === LOADED) { return; }
|
143
145
|
this.state = FAILED;
|
144
|
-
this.
|
146
|
+
this.reify()
|
147
|
+
this.exports();
|
145
148
|
this.state = LOADED;
|
146
149
|
};
|
147
150
|
|
@@ -155,7 +158,11 @@ var loader, define, requireModule, require, requirejs;
|
|
155
158
|
deps = [];
|
156
159
|
}
|
157
160
|
|
158
|
-
|
161
|
+
if (callback instanceof Alias) {
|
162
|
+
registry[name] = new Module(callback.name, deps, callback, true);
|
163
|
+
} else {
|
164
|
+
registry[name] = new Module(name, deps, callback, false);
|
165
|
+
}
|
159
166
|
};
|
160
167
|
|
161
168
|
// we don't support all of AMD
|
@@ -182,9 +189,8 @@ var loader, define, requireModule, require, requirejs;
|
|
182
189
|
function findModule(name, referrer) {
|
183
190
|
var mod = registry[name] || registry[name + '/index'];
|
184
191
|
|
185
|
-
while (mod && mod.
|
186
|
-
|
187
|
-
mod = registry[name];
|
192
|
+
while (mod && mod.isAlias) {
|
193
|
+
mod = registry[mod.name];
|
188
194
|
}
|
189
195
|
|
190
196
|
if (!mod) { missingModule(name, referrer); }
|
@@ -216,7 +222,12 @@ var loader, define, requireModule, require, requirejs;
|
|
216
222
|
return parentBase.join('/');
|
217
223
|
}
|
218
224
|
|
225
|
+
function has(name) {
|
226
|
+
return !!(registry[name] || registry[name + '/index']);
|
227
|
+
}
|
228
|
+
|
219
229
|
requirejs.entries = requirejs._eak_seen = registry;
|
230
|
+
requirejs.has = has;
|
220
231
|
requirejs.unsee = function(moduleName) {
|
221
232
|
findModule(moduleName, '(unsee)').unsee();
|
222
233
|
};
|
@@ -225,6 +236,28 @@ var loader, define, requireModule, require, requirejs;
|
|
225
236
|
requirejs.entries = requirejs._eak_seen = registry = {};
|
226
237
|
seen = {};
|
227
238
|
};
|
239
|
+
|
240
|
+
// prime
|
241
|
+
define('foo', function() {});
|
242
|
+
define('foo/bar', [], function() {});
|
243
|
+
define('foo/asdf', ['module', 'exports', 'require'], function(module, exports, require) {
|
244
|
+
if (require.has('foo/bar')) {
|
245
|
+
require('foo/bar');
|
246
|
+
}
|
247
|
+
});
|
248
|
+
define('foo/baz', [], define.alias('foo'));
|
249
|
+
define('foo/quz', define.alias('foo'));
|
250
|
+
define('foo/bar', ['foo', './quz', './baz', './asdf', './bar', '../foo'], function() {});
|
251
|
+
define('foo/main', ['foo/bar'], function() {});
|
252
|
+
|
253
|
+
require('foo/main');
|
254
|
+
require.unsee('foo/bar');
|
255
|
+
|
256
|
+
requirejs.clear();
|
257
|
+
|
258
|
+
if (typeof module !== 'undefined') {
|
259
|
+
module.exports = { require: require, define: define };
|
260
|
+
}
|
228
261
|
})(this);
|
229
262
|
|
230
263
|
define("ember-data/-private/adapters", ["exports", "ember-data/adapters/json-api", "ember-data/adapters/rest"], function (exports, _emberDataAdaptersJsonApi, _emberDataAdaptersRest) {
|
@@ -2856,26 +2889,23 @@ define("ember-data/-private/system/model/internal-model", ["exports", "ember", "
|
|
2856
2889
|
}
|
2857
2890
|
};
|
2858
2891
|
|
2859
|
-
|
2860
|
-
|
2861
|
-
InternalModel.prototype.referenceFor = function (type, name) {
|
2862
|
-
var reference = this.references[name];
|
2863
|
-
|
2864
|
-
if (!reference) {
|
2865
|
-
var relationship = this._relationships.get(name);
|
2892
|
+
InternalModel.prototype.referenceFor = function (type, name) {
|
2893
|
+
var reference = this.references[name];
|
2866
2894
|
|
2867
|
-
|
2868
|
-
|
2869
|
-
} else if (type === "hasMany") {
|
2870
|
-
reference = new _emberDataPrivateSystemReferences.HasManyReference(this.store, this, relationship);
|
2871
|
-
}
|
2895
|
+
if (!reference) {
|
2896
|
+
var relationship = this._relationships.get(name);
|
2872
2897
|
|
2873
|
-
|
2898
|
+
if (type === "belongsTo") {
|
2899
|
+
reference = new _emberDataPrivateSystemReferences.BelongsToReference(this.store, this, relationship);
|
2900
|
+
} else if (type === "hasMany") {
|
2901
|
+
reference = new _emberDataPrivateSystemReferences.HasManyReference(this.store, this, relationship);
|
2874
2902
|
}
|
2875
2903
|
|
2876
|
-
|
2877
|
-
}
|
2878
|
-
|
2904
|
+
this.references[name] = reference;
|
2905
|
+
}
|
2906
|
+
|
2907
|
+
return reference;
|
2908
|
+
};
|
2879
2909
|
});
|
2880
2910
|
define("ember-data/-private/system/model/model", ["exports", "ember", "ember-data/-private/debug", "ember-data/-private/system/promise-proxies", "ember-data/-private/system/model/errors", "ember-data/-private/features", "ember-data/-private/system/debug/debug-info", "ember-data/-private/system/relationships/belongs-to", "ember-data/-private/system/relationships/has-many", "ember-data/-private/system/relationships/ext", "ember-data/-private/system/model/attr"], function (exports, _ember, _emberDataPrivateDebug, _emberDataPrivateSystemPromiseProxies, _emberDataPrivateSystemModelErrors, _emberDataPrivateFeatures, _emberDataPrivateSystemDebugDebugInfo, _emberDataPrivateSystemRelationshipsBelongsTo, _emberDataPrivateSystemRelationshipsHasMany, _emberDataPrivateSystemRelationshipsExt, _emberDataPrivateSystemModelAttr) {
|
2881
2911
|
|
@@ -3389,18 +3419,31 @@ define("ember-data/-private/system/model/model", ["exports", "ember", "ember-dat
|
|
3389
3419
|
/**
|
3390
3420
|
Returns an object, whose keys are changed properties, and value is
|
3391
3421
|
an [oldProp, newProp] array.
|
3422
|
+
The array represents the diff of the canonical state with the local state
|
3423
|
+
of the model. Note: if the model is created locally, the canonical state is
|
3424
|
+
empty since the adapter hasn't acknowledged the attributes yet:
|
3392
3425
|
Example
|
3393
3426
|
```app/models/mascot.js
|
3394
3427
|
import DS from 'ember-data';
|
3395
3428
|
export default DS.Model.extend({
|
3396
|
-
name: attr('string')
|
3429
|
+
name: attr('string'),
|
3430
|
+
isAdmin: attr('boolean', {
|
3431
|
+
defaultValue: false
|
3432
|
+
})
|
3397
3433
|
});
|
3398
3434
|
```
|
3399
3435
|
```javascript
|
3400
3436
|
var mascot = store.createRecord('mascot');
|
3401
|
-
|
3402
|
-
|
3403
|
-
mascot.changedAttributes(); // {name: [undefined, 'Tomster']}
|
3437
|
+
mascot.changedAttributes(); // {}
|
3438
|
+
mascot.set('name', 'Tomster');
|
3439
|
+
mascot.changedAttributes(); // { name: [undefined, 'Tomster'] }
|
3440
|
+
mascot.set('isAdmin', true);
|
3441
|
+
mascot.changedAttributes(); // { isAdmin: [undefined, true], name: [undefined, 'Tomster'] }
|
3442
|
+
mascot.save().then(function() {
|
3443
|
+
mascot.changedAttributes(); // {}
|
3444
|
+
mascot.set('isAdmin', false);
|
3445
|
+
mascot.changedAttributes(); // { isAdmin: [true, false] }
|
3446
|
+
});
|
3404
3447
|
```
|
3405
3448
|
@method changedAttributes
|
3406
3449
|
@return {Object} an object, whose keys are changed properties,
|
@@ -3633,108 +3676,105 @@ define("ember-data/-private/system/model/model", ["exports", "ember", "ember-dat
|
|
3633
3676
|
});
|
3634
3677
|
}
|
3635
3678
|
|
3636
|
-
|
3637
|
-
|
3638
|
-
Model.reopen({
|
3679
|
+
Model.reopen({
|
3639
3680
|
|
3640
|
-
|
3641
|
-
|
3642
|
-
|
3643
|
-
|
3644
|
-
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3648
|
-
|
3649
|
-
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3653
|
-
}
|
3654
|
-
});
|
3655
|
-
var userRef = blog.belongsTo('user');
|
3656
|
-
// check if the user relationship is loaded
|
3657
|
-
var isLoaded = userRef.value() !== null;
|
3658
|
-
// get the record of the reference (null if not yet available)
|
3659
|
-
var user = userRef.value();
|
3660
|
-
// get the identifier of the reference
|
3661
|
-
if (userRef.remoteType() === "id") {
|
3662
|
-
var id = userRef.id();
|
3663
|
-
} else if (userRef.remoteType() === "link") {
|
3664
|
-
var link = userRef.link();
|
3681
|
+
/**
|
3682
|
+
Get the reference for the specified belongsTo relationship.
|
3683
|
+
Example
|
3684
|
+
```javascript
|
3685
|
+
// models/blog.js
|
3686
|
+
export default DS.Model.extend({
|
3687
|
+
user: DS.belongsTo({ async: true })
|
3688
|
+
});
|
3689
|
+
var blog = store.push({
|
3690
|
+
type: 'blog',
|
3691
|
+
id: 1,
|
3692
|
+
relationships: {
|
3693
|
+
user: { type: 'user', id: 1 }
|
3665
3694
|
}
|
3666
|
-
|
3667
|
-
|
3668
|
-
|
3669
|
-
|
3670
|
-
|
3671
|
-
|
3672
|
-
|
3673
|
-
|
3674
|
-
|
3675
|
-
|
3676
|
-
|
3677
|
-
|
3678
|
-
|
3679
|
-
|
3680
|
-
|
3681
|
-
|
3682
|
-
|
3683
|
-
|
3684
|
-
|
3685
|
-
|
3686
|
-
|
3687
|
-
|
3695
|
+
});
|
3696
|
+
var userRef = blog.belongsTo('user');
|
3697
|
+
// check if the user relationship is loaded
|
3698
|
+
var isLoaded = userRef.value() !== null;
|
3699
|
+
// get the record of the reference (null if not yet available)
|
3700
|
+
var user = userRef.value();
|
3701
|
+
// get the identifier of the reference
|
3702
|
+
if (userRef.remoteType() === "id") {
|
3703
|
+
var id = userRef.id();
|
3704
|
+
} else if (userRef.remoteType() === "link") {
|
3705
|
+
var link = userRef.link();
|
3706
|
+
}
|
3707
|
+
// load user (via store.findRecord or store.findBelongsTo)
|
3708
|
+
userRef.load().then(...)
|
3709
|
+
// or trigger a reload
|
3710
|
+
userRef.reload().then(...)
|
3711
|
+
// provide data for reference
|
3712
|
+
userRef.push({
|
3713
|
+
type: 'user',
|
3714
|
+
id: 1,
|
3715
|
+
attributes: {
|
3716
|
+
username: "@user"
|
3717
|
+
}
|
3718
|
+
}).then(function(user) {
|
3719
|
+
userRef.value() === user;
|
3720
|
+
});
|
3721
|
+
```
|
3722
|
+
@method belongsTo
|
3723
|
+
@param {String} name of the relationship
|
3724
|
+
@return {BelongsToReference} reference for this relationship
|
3725
|
+
*/
|
3726
|
+
belongsTo: function (name) {
|
3727
|
+
return this._internalModel.referenceFor('belongsTo', name);
|
3728
|
+
},
|
3688
3729
|
|
3689
|
-
|
3690
|
-
|
3691
|
-
|
3692
|
-
|
3693
|
-
|
3694
|
-
|
3695
|
-
|
3696
|
-
|
3697
|
-
|
3698
|
-
|
3699
|
-
|
3700
|
-
|
3701
|
-
|
3702
|
-
|
3703
|
-
|
3704
|
-
|
3705
|
-
|
3706
|
-
}
|
3730
|
+
/**
|
3731
|
+
Get the reference for the specified hasMany relationship.
|
3732
|
+
Example
|
3733
|
+
```javascript
|
3734
|
+
// models/blog.js
|
3735
|
+
export default DS.Model.extend({
|
3736
|
+
comments: DS.hasMany({ async: true })
|
3737
|
+
});
|
3738
|
+
var blog = store.push({
|
3739
|
+
type: 'blog',
|
3740
|
+
id: 1,
|
3741
|
+
relationships: {
|
3742
|
+
comments: {
|
3743
|
+
data: [
|
3744
|
+
{ type: 'comment', id: 1 },
|
3745
|
+
{ type: 'comment', id: 2 }
|
3746
|
+
]
|
3707
3747
|
}
|
3708
|
-
});
|
3709
|
-
var commentsRef = blog.hasMany('comments');
|
3710
|
-
// check if the comments are loaded already
|
3711
|
-
var isLoaded = commentsRef.value() !== null;
|
3712
|
-
// get the records of the reference (null if not yet available)
|
3713
|
-
var comments = commentsRef.value();
|
3714
|
-
// get the identifier of the reference
|
3715
|
-
if (commentsRef.remoteType() === "ids") {
|
3716
|
-
var ids = commentsRef.ids();
|
3717
|
-
} else if (commentsRef.remoteType() === "link") {
|
3718
|
-
var link = commentsRef.link();
|
3719
3748
|
}
|
3720
|
-
|
3721
|
-
|
3722
|
-
|
3723
|
-
|
3724
|
-
|
3725
|
-
|
3726
|
-
|
3727
|
-
|
3728
|
-
|
3729
|
-
|
3730
|
-
|
3731
|
-
|
3732
|
-
|
3733
|
-
|
3734
|
-
|
3735
|
-
|
3736
|
-
|
3737
|
-
|
3749
|
+
});
|
3750
|
+
var commentsRef = blog.hasMany('comments');
|
3751
|
+
// check if the comments are loaded already
|
3752
|
+
var isLoaded = commentsRef.value() !== null;
|
3753
|
+
// get the records of the reference (null if not yet available)
|
3754
|
+
var comments = commentsRef.value();
|
3755
|
+
// get the identifier of the reference
|
3756
|
+
if (commentsRef.remoteType() === "ids") {
|
3757
|
+
var ids = commentsRef.ids();
|
3758
|
+
} else if (commentsRef.remoteType() === "link") {
|
3759
|
+
var link = commentsRef.link();
|
3760
|
+
}
|
3761
|
+
// load comments (via store.findMany or store.findHasMany)
|
3762
|
+
commentsRef.load().then(...)
|
3763
|
+
// or trigger a reload
|
3764
|
+
commentsRef.reload().then(...)
|
3765
|
+
// provide data for reference
|
3766
|
+
commentsRef.push([{ type: 'comment', id: 1 }, { type: 'comment', id: 2 }]).then(function(comments) {
|
3767
|
+
commentsRef.value() === comments;
|
3768
|
+
});
|
3769
|
+
```
|
3770
|
+
@method hasMany
|
3771
|
+
@param {String} name of the relationship
|
3772
|
+
@return {HasManyReference} reference for this relationship
|
3773
|
+
*/
|
3774
|
+
hasMany: function (name) {
|
3775
|
+
return this._internalModel.referenceFor('hasMany', name);
|
3776
|
+
}
|
3777
|
+
});
|
3738
3778
|
|
3739
3779
|
Model.reopenClass(_emberDataPrivateSystemRelationshipsExt.RelationshipsClassMethodsMixin);
|
3740
3780
|
Model.reopenClass(_emberDataPrivateSystemModelAttr.AttrClassMethodsMixin);
|
@@ -5121,10 +5161,6 @@ define("ember-data/-private/system/record-arrays/adapter-populated-record-array"
|
|
5121
5161
|
meta: (0, _emberDataPrivateSystemCloneNull.default)(payload.meta)
|
5122
5162
|
});
|
5123
5163
|
|
5124
|
-
if ((0, _emberDataPrivateFeatures.default)('ds-links-in-record-array')) {
|
5125
|
-
this.set('links', (0, _emberDataPrivateSystemCloneNull.default)(payload.links));
|
5126
|
-
}
|
5127
|
-
|
5128
5164
|
internalModels.forEach(function (record) {
|
5129
5165
|
_this.manager.recordArraysForRecord(record).add(_this);
|
5130
5166
|
});
|
@@ -7363,9 +7399,7 @@ define('ember-data/-private/system/snapshot-record-array', ['exports', 'ember-da
|
|
7363
7399
|
*/
|
7364
7400
|
this.adapterOptions = options.adapterOptions;
|
7365
7401
|
|
7366
|
-
|
7367
|
-
this.include = options.include;
|
7368
|
-
}
|
7402
|
+
this.include = options.include;
|
7369
7403
|
}
|
7370
7404
|
|
7371
7405
|
/**
|
@@ -7428,9 +7462,7 @@ define('ember-data/-private/system/snapshot', ['exports', 'ember', 'ember-data/-
|
|
7428
7462
|
*/
|
7429
7463
|
this.adapterOptions = options.adapterOptions;
|
7430
7464
|
|
7431
|
-
|
7432
|
-
this.include = options.include;
|
7433
|
-
}
|
7465
|
+
this.include = options.include;
|
7434
7466
|
|
7435
7467
|
this._changedAttributes = record.changedAttributes();
|
7436
7468
|
}
|
@@ -8056,12 +8088,10 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
|
|
8056
8088
|
|
8057
8089
|
/**
|
8058
8090
|
This method returns a record for a given type and id combination.
|
8059
|
-
The `findRecord` method will always return a **promise** that will be
|
8060
|
-
resolved with the record. If the record was already in the store,
|
8061
|
-
the promise will be resolved immediately. Otherwise, the store
|
8062
|
-
will ask the adapter's `find` method to find the necessary data.
|
8063
8091
|
The `findRecord` method will always resolve its promise with the same
|
8064
8092
|
object for a given type and `id`.
|
8093
|
+
The `findRecord` method will always return a **promise** that will be
|
8094
|
+
resolved with the record.
|
8065
8095
|
Example
|
8066
8096
|
```app/routes/post.js
|
8067
8097
|
import Ember from 'ember';
|
@@ -8071,17 +8101,73 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
|
|
8071
8101
|
}
|
8072
8102
|
});
|
8073
8103
|
```
|
8074
|
-
If
|
8075
|
-
|
8076
|
-
|
8077
|
-
|
8078
|
-
|
8079
|
-
|
8080
|
-
|
8081
|
-
|
8104
|
+
If the record is not yet available, the store will ask the adapter's `find`
|
8105
|
+
method to find the necessary data. If the record is already present in the
|
8106
|
+
store, it depends on the reload behavior _when_ the returned promise
|
8107
|
+
resolves.
|
8108
|
+
The reload behavior is configured either via the passed `options` hash or
|
8109
|
+
the result of the adapter's `shouldReloadRecord`.
|
8110
|
+
If `{ reload: true }` is passed or `adapter.shouldReloadRecord` evaluates
|
8111
|
+
to `true`, then the returned promise resolves once the adapter returns
|
8112
|
+
data, regardless if the requested record is already in the store:
|
8113
|
+
```js
|
8114
|
+
store.push({
|
8115
|
+
data: {
|
8116
|
+
id: 1,
|
8117
|
+
type: 'post',
|
8118
|
+
revision: 1
|
8082
8119
|
}
|
8120
|
+
});
|
8121
|
+
// adapter#findRecord resolves with
|
8122
|
+
// [
|
8123
|
+
// {
|
8124
|
+
// id: 1,
|
8125
|
+
// type: 'post',
|
8126
|
+
// revision: 2
|
8127
|
+
// }
|
8128
|
+
// ]
|
8129
|
+
store.findRecord('post', 1, { reload: true }).then(function(post) {
|
8130
|
+
post.get("revision"); // 2
|
8083
8131
|
});
|
8084
8132
|
```
|
8133
|
+
If no reload is indicated via the abovementioned ways, then the promise
|
8134
|
+
immediately resolves with the cached version in the store.
|
8135
|
+
Optionally, if `adapter.shouldBackgroundReloadRecord` evaluates to `true`,
|
8136
|
+
then a background reload is started, which updates the records' data, once
|
8137
|
+
it is available:
|
8138
|
+
```js
|
8139
|
+
// app/adapters/post.js
|
8140
|
+
import ApplicationAdapter from "./application";
|
8141
|
+
export default ApplicationAdapter.extend({
|
8142
|
+
shouldReloadRecord(store, snapshot) {
|
8143
|
+
return false;
|
8144
|
+
},
|
8145
|
+
shouldBackgroundReloadRecord(store, snapshot) {
|
8146
|
+
return true;
|
8147
|
+
}
|
8148
|
+
});
|
8149
|
+
// ...
|
8150
|
+
store.push({
|
8151
|
+
data: {
|
8152
|
+
id: 1,
|
8153
|
+
type: 'post',
|
8154
|
+
revision: 1
|
8155
|
+
}
|
8156
|
+
});
|
8157
|
+
var blogPost = store.findRecord('post', 1).then(function(post) {
|
8158
|
+
post.get('revision'); // 1
|
8159
|
+
});
|
8160
|
+
// later, once adapter#findRecord resolved with
|
8161
|
+
// [
|
8162
|
+
// {
|
8163
|
+
// id: 1,
|
8164
|
+
// type: 'post',
|
8165
|
+
// revision: 2
|
8166
|
+
// }
|
8167
|
+
// ]
|
8168
|
+
blogPost.get('revision'); // 2
|
8169
|
+
```
|
8170
|
+
See [peekRecord](#method_peekRecord) to get the cached version of a record.
|
8085
8171
|
@method findRecord
|
8086
8172
|
@param {String} modelName
|
8087
8173
|
@param {(String|Integer)} id
|
@@ -8563,11 +8649,10 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
|
|
8563
8649
|
},
|
8564
8650
|
|
8565
8651
|
/**
|
8566
|
-
`findAll` ask the adapter's `findAll` method to find the records
|
8567
|
-
|
8568
|
-
|
8569
|
-
|
8570
|
-
only returns a subset of them.
|
8652
|
+
`findAll` ask the adapter's `findAll` method to find the records for the
|
8653
|
+
given type, and returns a promise which will resolve with all records of
|
8654
|
+
this type present in the store, even if the adapter only returns a subset
|
8655
|
+
of them.
|
8571
8656
|
```app/routes/authors.js
|
8572
8657
|
import Ember from 'ember';
|
8573
8658
|
export default Ember.Route.extend({
|
@@ -8576,6 +8661,70 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
|
|
8576
8661
|
}
|
8577
8662
|
});
|
8578
8663
|
```
|
8664
|
+
_When_ the returned promise resolves depends on the reload behavior,
|
8665
|
+
configured via the passed `options` hash and the result of the adapter's
|
8666
|
+
`shouldReloadAll` method.
|
8667
|
+
If `{ reload: true }` is passed or `adapter.shouldReloadAll` evaluates to
|
8668
|
+
`true`, then the returned promise resolves once the adapter returns data,
|
8669
|
+
regardless if there are already records in the store:
|
8670
|
+
```js
|
8671
|
+
store.push({
|
8672
|
+
data: {
|
8673
|
+
id: 'first',
|
8674
|
+
type: 'author'
|
8675
|
+
}
|
8676
|
+
});
|
8677
|
+
// adapter#findAll resolves with
|
8678
|
+
// [
|
8679
|
+
// {
|
8680
|
+
// id: 'second',
|
8681
|
+
// type: 'author'
|
8682
|
+
// }
|
8683
|
+
// ]
|
8684
|
+
store.findAll('author', { reload: true }).then(function(authors) {
|
8685
|
+
authors.getEach("id"); // ['first', 'second']
|
8686
|
+
});
|
8687
|
+
```
|
8688
|
+
If no reload is indicated via the abovementioned ways, then the promise
|
8689
|
+
immediately resolves with all the records currently loaded in the store.
|
8690
|
+
Optionally, if `adapter.shouldBackgroundReloadAll` evaluates to `true`,
|
8691
|
+
then a background reload is started. Once this resolves, the array with
|
8692
|
+
which the promise resolves, is updated automatically so it contains all the
|
8693
|
+
records in the store:
|
8694
|
+
```js
|
8695
|
+
// app/adapters/application.js
|
8696
|
+
export default DS.Adapter.extend({
|
8697
|
+
shouldReloadAll(store, snapshotsArray) {
|
8698
|
+
return false;
|
8699
|
+
},
|
8700
|
+
shouldBackgroundReloadAll(store, snapshotsArray) {
|
8701
|
+
return true;
|
8702
|
+
}
|
8703
|
+
});
|
8704
|
+
// ...
|
8705
|
+
store.push({
|
8706
|
+
data: {
|
8707
|
+
id: 'first',
|
8708
|
+
type: 'author'
|
8709
|
+
}
|
8710
|
+
});
|
8711
|
+
var allAuthors;
|
8712
|
+
store.findAll('author').then(function(authors) {
|
8713
|
+
authors.getEach('id'); // ['first']
|
8714
|
+
allAuthors = authors;
|
8715
|
+
});
|
8716
|
+
// later, once adapter#findAll resolved with
|
8717
|
+
// [
|
8718
|
+
// {
|
8719
|
+
// id: 'second',
|
8720
|
+
// type: 'author'
|
8721
|
+
// }
|
8722
|
+
// ]
|
8723
|
+
allAuthors.getEach('id'); // ['first', 'second']
|
8724
|
+
```
|
8725
|
+
See [peekAll](#method_peekAll) to get an array of current records in the
|
8726
|
+
store, without waiting until a reload is finished.
|
8727
|
+
See [query](#method_query) to only get a subset of records from the server.
|
8579
8728
|
@method findAll
|
8580
8729
|
@param {String} modelName
|
8581
8730
|
@param {Object} options
|
@@ -9331,15 +9480,10 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
|
|
9331
9480
|
(0, _emberDataPrivateDebug.assert)('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + _ember.default.inspect(modelName), typeof modelName === 'string');
|
9332
9481
|
serializer = this.serializerFor(modelName);
|
9333
9482
|
}
|
9334
|
-
|
9335
|
-
|
9336
|
-
|
9337
|
-
|
9338
|
-
} else {
|
9339
|
-
this._adapterRun(function () {
|
9340
|
-
return serializer.pushPayload(_this3, payload);
|
9341
|
-
});
|
9342
|
-
}
|
9483
|
+
|
9484
|
+
this._adapterRun(function () {
|
9485
|
+
return serializer.pushPayload(_this3, payload);
|
9486
|
+
});
|
9343
9487
|
},
|
9344
9488
|
|
9345
9489
|
/**
|
@@ -9532,41 +9676,38 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
|
|
9532
9676
|
|
9533
9677
|
});
|
9534
9678
|
|
9535
|
-
|
9536
|
-
|
9537
|
-
|
9538
|
-
|
9539
|
-
|
9540
|
-
|
9541
|
-
|
9542
|
-
|
9543
|
-
|
9544
|
-
|
9545
|
-
|
9546
|
-
|
9547
|
-
|
9548
|
-
|
9549
|
-
|
9550
|
-
|
9551
|
-
|
9552
|
-
|
9553
|
-
|
9554
|
-
|
9555
|
-
|
9556
|
-
|
9557
|
-
|
9558
|
-
|
9559
|
-
|
9560
|
-
|
9561
|
-
|
9562
|
-
|
9563
|
-
|
9564
|
-
|
9565
|
-
|
9566
|
-
|
9567
|
-
}
|
9568
|
-
});
|
9569
|
-
}
|
9679
|
+
Store.reopen({
|
9680
|
+
/**
|
9681
|
+
Get the reference for the specified record.
|
9682
|
+
Example
|
9683
|
+
```javascript
|
9684
|
+
var userRef = store.getReference('user', 1);
|
9685
|
+
// check if the user is loaded
|
9686
|
+
var isLoaded = userRef.value() !== null;
|
9687
|
+
// get the record of the reference (null if not yet available)
|
9688
|
+
var user = userRef.value();
|
9689
|
+
// get the identifier of the reference
|
9690
|
+
if (userRef.remoteType() === "id") {
|
9691
|
+
var id = userRef.id();
|
9692
|
+
}
|
9693
|
+
// load user (via store.find)
|
9694
|
+
userRef.load().then(...)
|
9695
|
+
// or trigger a reload
|
9696
|
+
userRef.reload().then(...)
|
9697
|
+
// provide data for reference
|
9698
|
+
userRef.push({ id: 1, username: "@user" }).then(function(user) {
|
9699
|
+
userRef.value() === user;
|
9700
|
+
});
|
9701
|
+
```
|
9702
|
+
@method getReference
|
9703
|
+
@param {String} type
|
9704
|
+
@param {String|Integer} id
|
9705
|
+
@return {RecordReference}
|
9706
|
+
*/
|
9707
|
+
getReference: function (type, id) {
|
9708
|
+
return this._internalModelForId(type, id).recordReference;
|
9709
|
+
}
|
9710
|
+
});
|
9570
9711
|
|
9571
9712
|
function deserializeRecordId(store, key, relationship, id) {
|
9572
9713
|
if (isNone(id)) {
|
@@ -10164,14 +10305,6 @@ define('ember-data/-private/transforms/boolean', ['exports', 'ember', 'ember-dat
|
|
10164
10305
|
deserialize: function (serialized, options) {
|
10165
10306
|
var type = typeof serialized;
|
10166
10307
|
|
10167
|
-
if ((0, _emberDataPrivateFeatures.default)('ds-transform-pass-options')) {
|
10168
|
-
if ((0, _emberDataPrivateFeatures.default)('ds-boolean-transform-allow-null')) {
|
10169
|
-
if (isNone(serialized) && options.allowNull === true) {
|
10170
|
-
return null;
|
10171
|
-
}
|
10172
|
-
}
|
10173
|
-
}
|
10174
|
-
|
10175
10308
|
if (type === "boolean") {
|
10176
10309
|
return serialized;
|
10177
10310
|
} else if (type === "string") {
|
@@ -10184,13 +10317,6 @@ define('ember-data/-private/transforms/boolean', ['exports', 'ember', 'ember-dat
|
|
10184
10317
|
},
|
10185
10318
|
|
10186
10319
|
serialize: function (deserialized, options) {
|
10187
|
-
if ((0, _emberDataPrivateFeatures.default)('ds-transform-pass-options')) {
|
10188
|
-
if ((0, _emberDataPrivateFeatures.default)('ds-boolean-transform-allow-null')) {
|
10189
|
-
if (isNone(deserialized) && options.allowNull === true) {
|
10190
|
-
return null;
|
10191
|
-
}
|
10192
|
-
}
|
10193
|
-
}
|
10194
10320
|
|
10195
10321
|
return Boolean(deserialized);
|
10196
10322
|
}
|
@@ -10821,9 +10947,29 @@ define('ember-data/adapter', ['exports', 'ember'], function (exports, _ember) {
|
|
10821
10947
|
This method is used by the store to determine if the store should
|
10822
10948
|
reload a record from the adapter when a record is requested by
|
10823
10949
|
`store.findRecord`.
|
10824
|
-
If this method returns true
|
10825
|
-
the adapter. If this method returns false
|
10950
|
+
If this method returns `true`, the store will re-fetch a record from
|
10951
|
+
the adapter. If this method returns `false`, the store will resolve
|
10826
10952
|
immediately using the cached record.
|
10953
|
+
For example, if you are building an events ticketing system, in which users
|
10954
|
+
can only reserve tickets for 20 minutes at a time, and want to ensure that
|
10955
|
+
in each route you have data that is no more than 20 minutes old you could
|
10956
|
+
write:
|
10957
|
+
```javascript
|
10958
|
+
shouldReloadRecord: function(store, ticketSnapshot) {
|
10959
|
+
var timeDiff = moment().diff(ticketSnapshot.attr('lastAccessedAt')).minutes();
|
10960
|
+
if (timeDiff > 20) {
|
10961
|
+
return true;
|
10962
|
+
} else {
|
10963
|
+
return false;
|
10964
|
+
}
|
10965
|
+
}
|
10966
|
+
```
|
10967
|
+
This method would ensure that whenever you do `store.findRecord('ticket',
|
10968
|
+
id)` you will always get a ticket that is no more than 20 minutes old. In
|
10969
|
+
case the cached version is more than 20 minutes old, `findRecord` will not
|
10970
|
+
resolve until you fetched the latest version.
|
10971
|
+
By default this hook returns `false`, as most UIs should not block user
|
10972
|
+
interactions while waiting on data update.
|
10827
10973
|
@method shouldReloadRecord
|
10828
10974
|
@param {DS.Store} store
|
10829
10975
|
@param {DS.Snapshot} snapshot
|
@@ -10837,9 +10983,33 @@ define('ember-data/adapter', ['exports', 'ember'], function (exports, _ember) {
|
|
10837
10983
|
This method is used by the store to determine if the store should
|
10838
10984
|
reload all records from the adapter when records are requested by
|
10839
10985
|
`store.findAll`.
|
10840
|
-
If this method returns true
|
10841
|
-
the adapter. If this method returns false
|
10842
|
-
immediately using the cached
|
10986
|
+
If this method returns `true`, the store will re-fetch all records from
|
10987
|
+
the adapter. If this method returns `false`, the store will resolve
|
10988
|
+
immediately using the cached records.
|
10989
|
+
For example, if you are building an events ticketing system, in which users
|
10990
|
+
can only reserve tickets for 20 minutes at a time, and want to ensure that
|
10991
|
+
in each route you have data that is no more than 20 minutes old you could
|
10992
|
+
write:
|
10993
|
+
```javascript
|
10994
|
+
shouldReloadAll: function(store, snapshotArray) {
|
10995
|
+
var snapshots = snapshotArray.snapshots();
|
10996
|
+
return snapshots.any(function(ticketSnapshot) {
|
10997
|
+
var timeDiff = moment().diff(ticketSnapshot.attr('lastAccessedAt')).minutes();
|
10998
|
+
if (timeDiff > 20) {
|
10999
|
+
return true;
|
11000
|
+
} else {
|
11001
|
+
return false;
|
11002
|
+
}
|
11003
|
+
});
|
11004
|
+
}
|
11005
|
+
```
|
11006
|
+
This method would ensure that whenever you do `store.findAll('ticket')` you
|
11007
|
+
will always get a list of tickets that are no more than 20 minutes old. In
|
11008
|
+
case a cached version is more than 20 minutes old, `findAll` will not
|
11009
|
+
resolve until you fetched the latest versions.
|
11010
|
+
By default this methods returns `true` if the passed `snapshotRecordArray`
|
11011
|
+
is empty (meaning that there are no records locally available yet),
|
11012
|
+
otherwise it returns `false`.
|
10843
11013
|
@method shouldReloadAll
|
10844
11014
|
@param {DS.Store} store
|
10845
11015
|
@param {DS.SnapshotRecordArray} snapshotRecordArray
|
@@ -10855,8 +11025,23 @@ define('ember-data/adapter', ['exports', 'ember'], function (exports, _ember) {
|
|
10855
11025
|
cached record.
|
10856
11026
|
This method is *only* checked by the store when the store is
|
10857
11027
|
returning a cached record.
|
10858
|
-
If this method returns true the store will re-fetch a record from
|
11028
|
+
If this method returns `true` the store will re-fetch a record from
|
10859
11029
|
the adapter.
|
11030
|
+
For example, if you do not want to fetch complex data over a mobile
|
11031
|
+
connection, or if the network is down, you can implement
|
11032
|
+
`shouldBackgroundReloadRecord` as follows:
|
11033
|
+
```javascript
|
11034
|
+
shouldBackgroundReloadRecord: function(store, snapshot) {
|
11035
|
+
var connection = window.navigator.connection;
|
11036
|
+
if (connection === 'cellular' || connection === 'none') {
|
11037
|
+
return false;
|
11038
|
+
} else {
|
11039
|
+
return true;
|
11040
|
+
}
|
11041
|
+
}
|
11042
|
+
```
|
11043
|
+
By default this hook returns `true` so the data for the record is updated
|
11044
|
+
in the background.
|
10860
11045
|
@method shouldBackgroundReloadRecord
|
10861
11046
|
@param {DS.Store} store
|
10862
11047
|
@param {DS.Snapshot} snapshot
|
@@ -10872,8 +11057,23 @@ define('ember-data/adapter', ['exports', 'ember'], function (exports, _ember) {
|
|
10872
11057
|
with a cached record array.
|
10873
11058
|
This method is *only* checked by the store when the store is
|
10874
11059
|
returning a cached record array.
|
10875
|
-
If this method returns true the store will re-fetch all records
|
11060
|
+
If this method returns `true` the store will re-fetch all records
|
10876
11061
|
from the adapter.
|
11062
|
+
For example, if you do not want to fetch complex data over a mobile
|
11063
|
+
connection, or if the network is down, you can implement
|
11064
|
+
`shouldBackgroundReloadAll` as follows:
|
11065
|
+
```javascript
|
11066
|
+
shouldBackgroundReloadAll: function(store, snapshotArray) {
|
11067
|
+
var connection = window.navigator.connection;
|
11068
|
+
if (connection === 'cellular' || connection === 'none') {
|
11069
|
+
return false;
|
11070
|
+
} else {
|
11071
|
+
return true;
|
11072
|
+
}
|
11073
|
+
}
|
11074
|
+
```
|
11075
|
+
By default this method returns `true`, indicating that a background reload
|
11076
|
+
should always be triggered.
|
10877
11077
|
@method shouldBackgroundReloadAll
|
10878
11078
|
@param {DS.Store} store
|
10879
11079
|
@param {DS.SnapshotRecordArray} snapshotRecordArray
|
@@ -10916,9 +11116,6 @@ define('ember-data/adapters/errors', ['exports', 'ember', 'ember-data/-private/d
|
|
10916
11116
|
}
|
10917
11117
|
|
10918
11118
|
var extendedErrorsEnabled = false;
|
10919
|
-
if ((0, _emberDataPrivateFeatures.default)('ds-extended-errors')) {
|
10920
|
-
extendedErrorsEnabled = true;
|
10921
|
-
}
|
10922
11119
|
|
10923
11120
|
function extendFn(ErrorClass) {
|
10924
11121
|
return function () {
|
@@ -11206,12 +11403,8 @@ define('ember-data/adapters/json-api', ['exports', 'ember', 'ember-data/adapters
|
|
11206
11403
|
@return {Promise} promise
|
11207
11404
|
*/
|
11208
11405
|
findMany: function (store, type, ids, snapshots) {
|
11209
|
-
|
11210
|
-
|
11211
|
-
} else {
|
11212
|
-
var url = this.buildURL(type.modelName, ids, snapshots, 'findMany');
|
11213
|
-
return this.ajax(url, 'GET', { data: { filter: { id: ids.join(',') } } });
|
11214
|
-
}
|
11406
|
+
var url = this.buildURL(type.modelName, ids, snapshots, 'findMany');
|
11407
|
+
return this.ajax(url, 'GET', { data: { filter: { id: ids.join(',') } } });
|
11215
11408
|
},
|
11216
11409
|
|
11217
11410
|
/**
|
@@ -11233,81 +11426,18 @@ define('ember-data/adapters/json-api', ['exports', 'ember', 'ember-data/adapters
|
|
11233
11426
|
@return {Promise} promise
|
11234
11427
|
*/
|
11235
11428
|
updateRecord: function (store, type, snapshot) {
|
11236
|
-
|
11237
|
-
|
11238
|
-
} else {
|
11239
|
-
var data = {};
|
11240
|
-
var serializer = store.serializerFor(type.modelName);
|
11429
|
+
var data = {};
|
11430
|
+
var serializer = store.serializerFor(type.modelName);
|
11241
11431
|
|
11242
|
-
|
11432
|
+
serializer.serializeIntoHash(data, type, snapshot, { includeId: true });
|
11243
11433
|
|
11244
|
-
|
11245
|
-
|
11434
|
+
var id = snapshot.id;
|
11435
|
+
var url = this.buildURL(type.modelName, id, snapshot, 'updateRecord');
|
11246
11436
|
|
11247
|
-
|
11248
|
-
}
|
11437
|
+
return this.ajax(url, 'PATCH', { data: data });
|
11249
11438
|
}
|
11250
11439
|
});
|
11251
11440
|
|
11252
|
-
if ((0, _emberDataPrivateFeatures.default)('ds-improved-ajax')) {
|
11253
|
-
|
11254
|
-
JSONAPIAdapter.reopen({
|
11255
|
-
|
11256
|
-
methodForRequest: function (params) {
|
11257
|
-
if (params.requestType === 'updateRecord') {
|
11258
|
-
return 'PATCH';
|
11259
|
-
}
|
11260
|
-
|
11261
|
-
return this._super.apply(this, arguments);
|
11262
|
-
},
|
11263
|
-
|
11264
|
-
dataForRequest: function (params) {
|
11265
|
-
var requestType = params.requestType;
|
11266
|
-
var ids = params.ids;
|
11267
|
-
|
11268
|
-
if (requestType === 'findMany') {
|
11269
|
-
return {
|
11270
|
-
filter: { id: ids.join(',') }
|
11271
|
-
};
|
11272
|
-
}
|
11273
|
-
|
11274
|
-
if (requestType === 'updateRecord') {
|
11275
|
-
var store = params.store;
|
11276
|
-
var type = params.type;
|
11277
|
-
var snapshot = params.snapshot;
|
11278
|
-
|
11279
|
-
var data = {};
|
11280
|
-
var serializer = store.serializerFor(type.modelName);
|
11281
|
-
|
11282
|
-
serializer.serializeIntoHash(data, type, snapshot, { includeId: true });
|
11283
|
-
|
11284
|
-
return data;
|
11285
|
-
}
|
11286
|
-
|
11287
|
-
return this._super.apply(this, arguments);
|
11288
|
-
},
|
11289
|
-
|
11290
|
-
headersForRequest: function () {
|
11291
|
-
var headers = this._super.apply(this, arguments) || {};
|
11292
|
-
|
11293
|
-
headers['Accept'] = 'application/vnd.api+json';
|
11294
|
-
|
11295
|
-
return headers;
|
11296
|
-
},
|
11297
|
-
|
11298
|
-
_requestToJQueryAjaxHash: function () {
|
11299
|
-
var hash = this._super.apply(this, arguments);
|
11300
|
-
|
11301
|
-
if (hash.contentType) {
|
11302
|
-
hash.contentType = 'application/vnd.api+json';
|
11303
|
-
}
|
11304
|
-
|
11305
|
-
return hash;
|
11306
|
-
}
|
11307
|
-
|
11308
|
-
});
|
11309
|
-
}
|
11310
|
-
|
11311
11441
|
exports.default = JSONAPIAdapter;
|
11312
11442
|
});
|
11313
11443
|
/**
|
@@ -11674,19 +11804,10 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
11674
11804
|
@return {Promise} promise
|
11675
11805
|
*/
|
11676
11806
|
findRecord: function (store, type, id, snapshot) {
|
11677
|
-
|
11678
|
-
|
11679
|
-
store: store, type: type, id: id, snapshot: snapshot,
|
11680
|
-
requestType: 'findRecord'
|
11681
|
-
});
|
11682
|
-
|
11683
|
-
return this._makeRequest(request);
|
11684
|
-
} else {
|
11685
|
-
var url = this.buildURL(type.modelName, id, snapshot, 'findRecord');
|
11686
|
-
var query = this.buildQuery(snapshot);
|
11807
|
+
var url = this.buildURL(type.modelName, id, snapshot, 'findRecord');
|
11808
|
+
var query = this.buildQuery(snapshot);
|
11687
11809
|
|
11688
|
-
|
11689
|
-
}
|
11810
|
+
return this.ajax(url, 'GET', { data: query });
|
11690
11811
|
},
|
11691
11812
|
|
11692
11813
|
/**
|
@@ -11704,23 +11825,13 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
11704
11825
|
findAll: function (store, type, sinceToken, snapshotRecordArray) {
|
11705
11826
|
var query = this.buildQuery(snapshotRecordArray);
|
11706
11827
|
|
11707
|
-
|
11708
|
-
var request = this._requestFor({
|
11709
|
-
store: store, type: type, sinceToken: sinceToken, query: query,
|
11710
|
-
snapshots: snapshotRecordArray,
|
11711
|
-
requestType: 'findAll'
|
11712
|
-
});
|
11713
|
-
|
11714
|
-
return this._makeRequest(request);
|
11715
|
-
} else {
|
11716
|
-
var url = this.buildURL(type.modelName, null, snapshotRecordArray, 'findAll');
|
11828
|
+
var url = this.buildURL(type.modelName, null, snapshotRecordArray, 'findAll');
|
11717
11829
|
|
11718
|
-
|
11719
|
-
|
11720
|
-
}
|
11721
|
-
|
11722
|
-
return this.ajax(url, 'GET', { data: query });
|
11830
|
+
if (sinceToken) {
|
11831
|
+
query.since = sinceToken;
|
11723
11832
|
}
|
11833
|
+
|
11834
|
+
return this.ajax(url, 'GET', { data: query });
|
11724
11835
|
},
|
11725
11836
|
|
11726
11837
|
/**
|
@@ -11738,22 +11849,13 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
11738
11849
|
@return {Promise} promise
|
11739
11850
|
*/
|
11740
11851
|
query: function (store, type, query) {
|
11741
|
-
|
11742
|
-
var request = this._requestFor({
|
11743
|
-
store: store, type: type, query: query,
|
11744
|
-
requestType: 'query'
|
11745
|
-
});
|
11746
|
-
|
11747
|
-
return this._makeRequest(request);
|
11748
|
-
} else {
|
11749
|
-
var url = this.buildURL(type.modelName, null, null, 'query', query);
|
11750
|
-
|
11751
|
-
if (this.sortQueryParams) {
|
11752
|
-
query = this.sortQueryParams(query);
|
11753
|
-
}
|
11852
|
+
var url = this.buildURL(type.modelName, null, null, 'query', query);
|
11754
11853
|
|
11755
|
-
|
11854
|
+
if (this.sortQueryParams) {
|
11855
|
+
query = this.sortQueryParams(query);
|
11756
11856
|
}
|
11857
|
+
|
11858
|
+
return this.ajax(url, 'GET', { data: query });
|
11757
11859
|
},
|
11758
11860
|
|
11759
11861
|
/**
|
@@ -11771,22 +11873,13 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
11771
11873
|
@return {Promise} promise
|
11772
11874
|
*/
|
11773
11875
|
queryRecord: function (store, type, query) {
|
11774
|
-
|
11775
|
-
var request = this._requestFor({
|
11776
|
-
store: store, type: type, query: query,
|
11777
|
-
requestType: 'queryRecord'
|
11778
|
-
});
|
11779
|
-
|
11780
|
-
return this._makeRequest(request);
|
11781
|
-
} else {
|
11782
|
-
var url = this.buildURL(type.modelName, null, null, 'queryRecord', query);
|
11783
|
-
|
11784
|
-
if (this.sortQueryParams) {
|
11785
|
-
query = this.sortQueryParams(query);
|
11786
|
-
}
|
11876
|
+
var url = this.buildURL(type.modelName, null, null, 'queryRecord', query);
|
11787
11877
|
|
11788
|
-
|
11878
|
+
if (this.sortQueryParams) {
|
11879
|
+
query = this.sortQueryParams(query);
|
11789
11880
|
}
|
11881
|
+
|
11882
|
+
return this.ajax(url, 'GET', { data: query });
|
11790
11883
|
},
|
11791
11884
|
|
11792
11885
|
/**
|
@@ -11816,17 +11909,8 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
11816
11909
|
@return {Promise} promise
|
11817
11910
|
*/
|
11818
11911
|
findMany: function (store, type, ids, snapshots) {
|
11819
|
-
|
11820
|
-
|
11821
|
-
store: store, type: type, ids: ids, snapshots: snapshots,
|
11822
|
-
requestType: 'findMany'
|
11823
|
-
});
|
11824
|
-
|
11825
|
-
return this._makeRequest(request);
|
11826
|
-
} else {
|
11827
|
-
var url = this.buildURL(type.modelName, ids, snapshots, 'findMany');
|
11828
|
-
return this.ajax(url, 'GET', { data: { ids: ids } });
|
11829
|
-
}
|
11912
|
+
var url = this.buildURL(type.modelName, ids, snapshots, 'findMany');
|
11913
|
+
return this.ajax(url, 'GET', { data: { ids: ids } });
|
11830
11914
|
},
|
11831
11915
|
|
11832
11916
|
/**
|
@@ -11856,21 +11940,12 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
11856
11940
|
@return {Promise} promise
|
11857
11941
|
*/
|
11858
11942
|
findHasMany: function (store, snapshot, url, relationship) {
|
11859
|
-
|
11860
|
-
|
11861
|
-
store: store, snapshot: snapshot, url: url, relationship: relationship,
|
11862
|
-
requestType: 'findHasMany'
|
11863
|
-
});
|
11864
|
-
|
11865
|
-
return this._makeRequest(request);
|
11866
|
-
} else {
|
11867
|
-
var id = snapshot.id;
|
11868
|
-
var type = snapshot.modelName;
|
11943
|
+
var id = snapshot.id;
|
11944
|
+
var type = snapshot.modelName;
|
11869
11945
|
|
11870
|
-
|
11946
|
+
url = this.urlPrefix(url, this.buildURL(type, id, snapshot, 'findHasMany'));
|
11871
11947
|
|
11872
|
-
|
11873
|
-
}
|
11948
|
+
return this.ajax(url, 'GET');
|
11874
11949
|
},
|
11875
11950
|
|
11876
11951
|
/**
|
@@ -11900,20 +11975,11 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
11900
11975
|
@return {Promise} promise
|
11901
11976
|
*/
|
11902
11977
|
findBelongsTo: function (store, snapshot, url, relationship) {
|
11903
|
-
|
11904
|
-
|
11905
|
-
store: store, snapshot: snapshot, url: url, relationship: relationship,
|
11906
|
-
requestType: 'findBelongsTo'
|
11907
|
-
});
|
11908
|
-
|
11909
|
-
return this._makeRequest(request);
|
11910
|
-
} else {
|
11911
|
-
var id = snapshot.id;
|
11912
|
-
var type = snapshot.modelName;
|
11978
|
+
var id = snapshot.id;
|
11979
|
+
var type = snapshot.modelName;
|
11913
11980
|
|
11914
|
-
|
11915
|
-
|
11916
|
-
}
|
11981
|
+
url = this.urlPrefix(url, this.buildURL(type, id, snapshot, 'findBelongsTo'));
|
11982
|
+
return this.ajax(url, 'GET');
|
11917
11983
|
},
|
11918
11984
|
|
11919
11985
|
/**
|
@@ -11930,22 +11996,13 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
11930
11996
|
@return {Promise} promise
|
11931
11997
|
*/
|
11932
11998
|
createRecord: function (store, type, snapshot) {
|
11933
|
-
|
11934
|
-
|
11935
|
-
|
11936
|
-
requestType: 'createRecord'
|
11937
|
-
});
|
11999
|
+
var data = {};
|
12000
|
+
var serializer = store.serializerFor(type.modelName);
|
12001
|
+
var url = this.buildURL(type.modelName, null, snapshot, 'createRecord');
|
11938
12002
|
|
11939
|
-
|
11940
|
-
} else {
|
11941
|
-
var data = {};
|
11942
|
-
var serializer = store.serializerFor(type.modelName);
|
11943
|
-
var url = this.buildURL(type.modelName, null, snapshot, 'createRecord');
|
11944
|
-
|
11945
|
-
serializer.serializeIntoHash(data, type, snapshot, { includeId: true });
|
12003
|
+
serializer.serializeIntoHash(data, type, snapshot, { includeId: true });
|
11946
12004
|
|
11947
|
-
|
11948
|
-
}
|
12005
|
+
return this.ajax(url, "POST", { data: data });
|
11949
12006
|
},
|
11950
12007
|
|
11951
12008
|
/**
|
@@ -11962,24 +12019,15 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
11962
12019
|
@return {Promise} promise
|
11963
12020
|
*/
|
11964
12021
|
updateRecord: function (store, type, snapshot) {
|
11965
|
-
|
11966
|
-
|
11967
|
-
store: store, type: type, snapshot: snapshot,
|
11968
|
-
requestType: 'updateRecord'
|
11969
|
-
});
|
11970
|
-
|
11971
|
-
return this._makeRequest(request);
|
11972
|
-
} else {
|
11973
|
-
var data = {};
|
11974
|
-
var serializer = store.serializerFor(type.modelName);
|
12022
|
+
var data = {};
|
12023
|
+
var serializer = store.serializerFor(type.modelName);
|
11975
12024
|
|
11976
|
-
|
12025
|
+
serializer.serializeIntoHash(data, type, snapshot);
|
11977
12026
|
|
11978
|
-
|
11979
|
-
|
12027
|
+
var id = snapshot.id;
|
12028
|
+
var url = this.buildURL(type.modelName, id, snapshot, 'updateRecord');
|
11980
12029
|
|
11981
|
-
|
11982
|
-
}
|
12030
|
+
return this.ajax(url, "PUT", { data: data });
|
11983
12031
|
},
|
11984
12032
|
|
11985
12033
|
/**
|
@@ -11992,18 +12040,9 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
11992
12040
|
@return {Promise} promise
|
11993
12041
|
*/
|
11994
12042
|
deleteRecord: function (store, type, snapshot) {
|
11995
|
-
|
11996
|
-
var request = this._requestFor({
|
11997
|
-
store: store, type: type, snapshot: snapshot,
|
11998
|
-
requestType: 'deleteRecord'
|
11999
|
-
});
|
12000
|
-
|
12001
|
-
return this._makeRequest(request);
|
12002
|
-
} else {
|
12003
|
-
var id = snapshot.id;
|
12043
|
+
var id = snapshot.id;
|
12004
12044
|
|
12005
|
-
|
12006
|
-
}
|
12045
|
+
return this.ajax(this.buildURL(type.modelName, id, snapshot, 'deleteRecord'), "DELETE");
|
12007
12046
|
},
|
12008
12047
|
|
12009
12048
|
_stripIDFromURL: function (store, snapshot) {
|
@@ -12123,23 +12162,6 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
12123
12162
|
var errors = this.normalizeErrorResponse(status, headers, payload);
|
12124
12163
|
var detailedMessage = this.generatedDetailedMessage(status, headers, payload, requestData);
|
12125
12164
|
|
12126
|
-
if ((0, _emberDataPrivateFeatures.default)('ds-extended-errors')) {
|
12127
|
-
switch (status) {
|
12128
|
-
case 401:
|
12129
|
-
return new _emberDataAdaptersErrors.UnauthorizedError(errors, detailedMessage);
|
12130
|
-
case 403:
|
12131
|
-
return new _emberDataAdaptersErrors.ForbiddenError(errors, detailedMessage);
|
12132
|
-
case 404:
|
12133
|
-
return new _emberDataAdaptersErrors.NotFoundError(errors, detailedMessage);
|
12134
|
-
case 409:
|
12135
|
-
return new _emberDataAdaptersErrors.ConflictError(errors, detailedMessage);
|
12136
|
-
default:
|
12137
|
-
if (status >= 500) {
|
12138
|
-
return new _emberDataAdaptersErrors.ServerError(errors, detailedMessage);
|
12139
|
-
}
|
12140
|
-
}
|
12141
|
-
}
|
12142
|
-
|
12143
12165
|
return new _emberDataAdaptersErrors.AdapterError(errors, detailedMessage);
|
12144
12166
|
},
|
12145
12167
|
|
@@ -12346,13 +12368,11 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
12346
12368
|
buildQuery: function (snapshot) {
|
12347
12369
|
var query = {};
|
12348
12370
|
|
12349
|
-
if (
|
12350
|
-
|
12351
|
-
var include = snapshot.include;
|
12371
|
+
if (snapshot) {
|
12372
|
+
var include = snapshot.include;
|
12352
12373
|
|
12353
|
-
|
12354
|
-
|
12355
|
-
}
|
12374
|
+
if (include) {
|
12375
|
+
query.include = include;
|
12356
12376
|
}
|
12357
12377
|
}
|
12358
12378
|
|
@@ -12360,266 +12380,6 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
12360
12380
|
}
|
12361
12381
|
});
|
12362
12382
|
|
12363
|
-
if ((0, _emberDataPrivateFeatures.default)('ds-improved-ajax')) {
|
12364
|
-
|
12365
|
-
RESTAdapter.reopen({
|
12366
|
-
|
12367
|
-
/**
|
12368
|
-
* Get the data (body or query params) for a request.
|
12369
|
-
*
|
12370
|
-
* @public
|
12371
|
-
* @method dataForRequest
|
12372
|
-
* @param {Object} params
|
12373
|
-
* @return {Object} data
|
12374
|
-
*/
|
12375
|
-
dataForRequest: function (params) {
|
12376
|
-
var store = params.store;
|
12377
|
-
var type = params.type;
|
12378
|
-
var snapshot = params.snapshot;
|
12379
|
-
var requestType = params.requestType;
|
12380
|
-
var query = params.query;
|
12381
|
-
|
12382
|
-
// type is not passed to findBelongsTo and findHasMany
|
12383
|
-
type = type || snapshot && snapshot.type;
|
12384
|
-
|
12385
|
-
var serializer = store.serializerFor(type.modelName);
|
12386
|
-
var data = {};
|
12387
|
-
|
12388
|
-
switch (requestType) {
|
12389
|
-
case 'createRecord':
|
12390
|
-
serializer.serializeIntoHash(data, type, snapshot, { includeId: true });
|
12391
|
-
break;
|
12392
|
-
|
12393
|
-
case 'updateRecord':
|
12394
|
-
serializer.serializeIntoHash(data, type, snapshot);
|
12395
|
-
break;
|
12396
|
-
|
12397
|
-
case 'findRecord':
|
12398
|
-
data = this.buildQuery(snapshot);
|
12399
|
-
break;
|
12400
|
-
|
12401
|
-
case 'findAll':
|
12402
|
-
if (params.sinceToken) {
|
12403
|
-
query = query || {};
|
12404
|
-
query.since = params.sinceToken;
|
12405
|
-
}
|
12406
|
-
data = query;
|
12407
|
-
break;
|
12408
|
-
|
12409
|
-
case 'query':
|
12410
|
-
case 'queryRecord':
|
12411
|
-
if (this.sortQueryParams) {
|
12412
|
-
query = this.sortQueryParams(query);
|
12413
|
-
}
|
12414
|
-
data = query;
|
12415
|
-
break;
|
12416
|
-
|
12417
|
-
case 'findMany':
|
12418
|
-
data = { ids: params.ids };
|
12419
|
-
break;
|
12420
|
-
|
12421
|
-
default:
|
12422
|
-
data = undefined;
|
12423
|
-
break;
|
12424
|
-
}
|
12425
|
-
|
12426
|
-
return data;
|
12427
|
-
},
|
12428
|
-
|
12429
|
-
/**
|
12430
|
-
* Get the HTTP method for a request.
|
12431
|
-
*
|
12432
|
-
* @public
|
12433
|
-
* @method methodForRequest
|
12434
|
-
* @param {Object} params
|
12435
|
-
* @return {String} HTTP method
|
12436
|
-
*/
|
12437
|
-
methodForRequest: function (params) {
|
12438
|
-
var requestType = params.requestType;
|
12439
|
-
|
12440
|
-
switch (requestType) {
|
12441
|
-
case 'createRecord':
|
12442
|
-
return 'POST';
|
12443
|
-
case 'updateRecord':
|
12444
|
-
return 'PUT';
|
12445
|
-
case 'deleteRecord':
|
12446
|
-
return 'DELETE';
|
12447
|
-
}
|
12448
|
-
|
12449
|
-
return 'GET';
|
12450
|
-
},
|
12451
|
-
|
12452
|
-
/**
|
12453
|
-
* Get the URL for a request.
|
12454
|
-
*
|
12455
|
-
* @public
|
12456
|
-
* @method urlForRequest
|
12457
|
-
* @param {Object} params
|
12458
|
-
* @return {String} URL
|
12459
|
-
*/
|
12460
|
-
urlForRequest: function (params) {
|
12461
|
-
var type = params.type;
|
12462
|
-
var id = params.id;
|
12463
|
-
var ids = params.ids;
|
12464
|
-
var snapshot = params.snapshot;
|
12465
|
-
var snapshots = params.snapshots;
|
12466
|
-
var requestType = params.requestType;
|
12467
|
-
var query = params.query;
|
12468
|
-
|
12469
|
-
// type and id are not passed from updateRecord and deleteRecord, hence they
|
12470
|
-
// are defined if not set
|
12471
|
-
type = type || snapshot && snapshot.type;
|
12472
|
-
id = id || snapshot && snapshot.id;
|
12473
|
-
|
12474
|
-
switch (requestType) {
|
12475
|
-
case 'findAll':
|
12476
|
-
return this.buildURL(type.modelName, null, snapshots, requestType);
|
12477
|
-
|
12478
|
-
case 'query':
|
12479
|
-
case 'queryRecord':
|
12480
|
-
return this.buildURL(type.modelName, null, null, requestType, query);
|
12481
|
-
|
12482
|
-
case 'findMany':
|
12483
|
-
return this.buildURL(type.modelName, ids, snapshots, requestType);
|
12484
|
-
|
12485
|
-
case 'findHasMany':
|
12486
|
-
case 'findBelongsTo':
|
12487
|
-
var url = this.buildURL(type.modelName, id, snapshot, requestType);
|
12488
|
-
return this.urlPrefix(params.url, url);
|
12489
|
-
}
|
12490
|
-
|
12491
|
-
return this.buildURL(type.modelName, id, snapshot, requestType, query);
|
12492
|
-
},
|
12493
|
-
|
12494
|
-
/**
|
12495
|
-
* Get the headers for a request.
|
12496
|
-
*
|
12497
|
-
* By default the value of the `headers` property of the adapter is
|
12498
|
-
* returned.
|
12499
|
-
*
|
12500
|
-
* @public
|
12501
|
-
* @method headersForRequest
|
12502
|
-
* @param {Object} params
|
12503
|
-
* @return {Object} headers
|
12504
|
-
*/
|
12505
|
-
headersForRequest: function (params) {
|
12506
|
-
return this.get('headers');
|
12507
|
-
},
|
12508
|
-
|
12509
|
-
/**
|
12510
|
-
* Get an object which contains all properties for a request which should
|
12511
|
-
* be made.
|
12512
|
-
*
|
12513
|
-
* @private
|
12514
|
-
* @method _requestFor
|
12515
|
-
* @param {Object} params
|
12516
|
-
* @return {Object} request object
|
12517
|
-
*/
|
12518
|
-
_requestFor: function (params) {
|
12519
|
-
var method = this.methodForRequest(params);
|
12520
|
-
var url = this.urlForRequest(params);
|
12521
|
-
var headers = this.headersForRequest(params);
|
12522
|
-
var data = this.dataForRequest(params);
|
12523
|
-
|
12524
|
-
return { method: method, url: url, headers: headers, data: data };
|
12525
|
-
},
|
12526
|
-
|
12527
|
-
/**
|
12528
|
-
* Convert a request object into a hash which can be passed to `jQuery.ajax`.
|
12529
|
-
*
|
12530
|
-
* @private
|
12531
|
-
* @method _requestToJQueryAjaxHash
|
12532
|
-
* @param {Object} request
|
12533
|
-
* @return {Object} jQuery ajax hash
|
12534
|
-
*/
|
12535
|
-
_requestToJQueryAjaxHash: function (request) {
|
12536
|
-
var hash = {};
|
12537
|
-
|
12538
|
-
hash.type = request.method;
|
12539
|
-
hash.url = request.url;
|
12540
|
-
hash.dataType = 'json';
|
12541
|
-
hash.context = this;
|
12542
|
-
|
12543
|
-
if (request.data) {
|
12544
|
-
if (request.type !== 'GET') {
|
12545
|
-
hash.contentType = 'application/json; charset=utf-8';
|
12546
|
-
hash.data = JSON.stringify(request.data);
|
12547
|
-
} else {
|
12548
|
-
hash.data = request.data;
|
12549
|
-
}
|
12550
|
-
}
|
12551
|
-
|
12552
|
-
var headers = request.headers;
|
12553
|
-
if (headers !== undefined) {
|
12554
|
-
hash.beforeSend = function (xhr) {
|
12555
|
-
Object.keys(headers).forEach(function (key) {
|
12556
|
-
return xhr.setRequestHeader(key, headers[key]);
|
12557
|
-
});
|
12558
|
-
};
|
12559
|
-
}
|
12560
|
-
|
12561
|
-
return hash;
|
12562
|
-
},
|
12563
|
-
|
12564
|
-
/**
|
12565
|
-
* Make a request using `jQuery.ajax`.
|
12566
|
-
*
|
12567
|
-
* @private
|
12568
|
-
* @method _makeRequest
|
12569
|
-
* @param {Object} request
|
12570
|
-
* @return {Promise} promise
|
12571
|
-
*/
|
12572
|
-
_makeRequest: function (request) {
|
12573
|
-
var adapter = this;
|
12574
|
-
var hash = this._requestToJQueryAjaxHash(request);
|
12575
|
-
|
12576
|
-
var method = request.method;
|
12577
|
-
var url = request.url;
|
12578
|
-
|
12579
|
-
var requestData = { method: method, url: url };
|
12580
|
-
|
12581
|
-
return new _ember.default.RSVP.Promise(function (resolve, reject) {
|
12582
|
-
|
12583
|
-
hash.success = function (payload, textStatus, jqXHR) {
|
12584
|
-
var response = adapter.handleResponse(jqXHR.status, (0, _emberDataPrivateUtilsParseResponseHeaders.default)(jqXHR.getAllResponseHeaders()), payload, requestData);
|
12585
|
-
|
12586
|
-
if (response instanceof _emberDataAdaptersErrors.AdapterError) {
|
12587
|
-
_ember.default.run.join(null, reject, response);
|
12588
|
-
} else {
|
12589
|
-
_ember.default.run.join(null, resolve, response);
|
12590
|
-
}
|
12591
|
-
};
|
12592
|
-
|
12593
|
-
hash.error = function (jqXHR, textStatus, errorThrown) {
|
12594
|
-
(0, _emberDataPrivateDebug.runInDebug)(function () {
|
12595
|
-
var message = 'The server returned an empty string for ' + method + ' ' + url + ', which cannot be parsed into a valid JSON. Return either null or {}.';
|
12596
|
-
var validJSONString = !(textStatus === "parsererror" && jqXHR.responseText === "");
|
12597
|
-
(0, _emberDataPrivateDebug.warn)(message, validJSONString, {
|
12598
|
-
id: 'ds.adapter.returned-empty-string-as-JSON'
|
12599
|
-
});
|
12600
|
-
});
|
12601
|
-
|
12602
|
-
var error = undefined;
|
12603
|
-
|
12604
|
-
if (errorThrown instanceof Error) {
|
12605
|
-
error = errorThrown;
|
12606
|
-
} else if (textStatus === 'timeout') {
|
12607
|
-
error = new _emberDataAdaptersErrors.TimeoutError();
|
12608
|
-
} else if (textStatus === 'abort') {
|
12609
|
-
error = new _emberDataAdaptersErrors.AbortError();
|
12610
|
-
} else {
|
12611
|
-
error = adapter.handleResponse(jqXHR.status, (0, _emberDataPrivateUtilsParseResponseHeaders.default)(jqXHR.getAllResponseHeaders()), adapter.parseErrorResponse(jqXHR.responseText) || errorThrown, requestData);
|
12612
|
-
}
|
12613
|
-
|
12614
|
-
_ember.default.run.join(null, reject, error);
|
12615
|
-
};
|
12616
|
-
|
12617
|
-
adapter._ajaxRequest(hash);
|
12618
|
-
}, 'DS: RESTAdapter#makeRequest: ' + method + ' ' + url);
|
12619
|
-
}
|
12620
|
-
});
|
12621
|
-
}
|
12622
|
-
|
12623
12383
|
//From http://stackoverflow.com/questions/280634/endswith-in-javascript
|
12624
12384
|
function endsWith(string, suffix) {
|
12625
12385
|
if (typeof String.prototype.endsWith !== 'function') {
|
@@ -12634,6 +12394,78 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
|
|
12634
12394
|
/**
|
12635
12395
|
@module ember-data
|
12636
12396
|
*/
|
12397
|
+
|
12398
|
+
/**
|
12399
|
+
* Get the data (body or query params) for a request.
|
12400
|
+
*
|
12401
|
+
* @public
|
12402
|
+
* @method dataForRequest
|
12403
|
+
* @param {Object} params
|
12404
|
+
* @return {Object} data
|
12405
|
+
*/
|
12406
|
+
|
12407
|
+
// type is not passed to findBelongsTo and findHasMany
|
12408
|
+
|
12409
|
+
/**
|
12410
|
+
* Get the HTTP method for a request.
|
12411
|
+
*
|
12412
|
+
* @public
|
12413
|
+
* @method methodForRequest
|
12414
|
+
* @param {Object} params
|
12415
|
+
* @return {String} HTTP method
|
12416
|
+
*/
|
12417
|
+
|
12418
|
+
/**
|
12419
|
+
* Get the URL for a request.
|
12420
|
+
*
|
12421
|
+
* @public
|
12422
|
+
* @method urlForRequest
|
12423
|
+
* @param {Object} params
|
12424
|
+
* @return {String} URL
|
12425
|
+
*/
|
12426
|
+
|
12427
|
+
// type and id are not passed from updateRecord and deleteRecord, hence they
|
12428
|
+
// are defined if not set
|
12429
|
+
|
12430
|
+
/**
|
12431
|
+
* Get the headers for a request.
|
12432
|
+
*
|
12433
|
+
* By default the value of the `headers` property of the adapter is
|
12434
|
+
* returned.
|
12435
|
+
*
|
12436
|
+
* @public
|
12437
|
+
* @method headersForRequest
|
12438
|
+
* @param {Object} params
|
12439
|
+
* @return {Object} headers
|
12440
|
+
*/
|
12441
|
+
|
12442
|
+
/**
|
12443
|
+
* Get an object which contains all properties for a request which should
|
12444
|
+
* be made.
|
12445
|
+
*
|
12446
|
+
* @private
|
12447
|
+
* @method _requestFor
|
12448
|
+
* @param {Object} params
|
12449
|
+
* @return {Object} request object
|
12450
|
+
*/
|
12451
|
+
|
12452
|
+
/**
|
12453
|
+
* Convert a request object into a hash which can be passed to `jQuery.ajax`.
|
12454
|
+
*
|
12455
|
+
* @private
|
12456
|
+
* @method _requestToJQueryAjaxHash
|
12457
|
+
* @param {Object} request
|
12458
|
+
* @return {Object} jQuery ajax hash
|
12459
|
+
*/
|
12460
|
+
|
12461
|
+
/**
|
12462
|
+
* Make a request using `jQuery.ajax`.
|
12463
|
+
*
|
12464
|
+
* @private
|
12465
|
+
* @method _makeRequest
|
12466
|
+
* @param {Object} request
|
12467
|
+
* @return {Promise} promise
|
12468
|
+
*/
|
12637
12469
|
define('ember-data/attr', ['exports', 'ember', 'ember-data/-private/debug'], function (exports, _ember, _emberDataPrivateDebug) {
|
12638
12470
|
exports.default = attr;
|
12639
12471
|
|
@@ -12828,14 +12660,6 @@ define("ember-data", ["exports", "ember", "ember-data/-private/debug", "ember-da
|
|
12828
12660
|
_emberDataPrivateCore.default.TimeoutError = _emberDataAdaptersErrors.TimeoutError;
|
12829
12661
|
_emberDataPrivateCore.default.AbortError = _emberDataAdaptersErrors.AbortError;
|
12830
12662
|
|
12831
|
-
if ((0, _emberDataPrivateFeatures.default)('ds-extended-errors')) {
|
12832
|
-
_emberDataPrivateCore.default.UnauthorizedError = _emberDataAdaptersErrors.UnauthorizedError;
|
12833
|
-
_emberDataPrivateCore.default.ForbiddenError = _emberDataAdaptersErrors.ForbiddenError;
|
12834
|
-
_emberDataPrivateCore.default.NotFoundError = _emberDataAdaptersErrors.NotFoundError;
|
12835
|
-
_emberDataPrivateCore.default.ConflictError = _emberDataAdaptersErrors.ConflictError;
|
12836
|
-
_emberDataPrivateCore.default.ServerError = _emberDataAdaptersErrors.ServerError;
|
12837
|
-
}
|
12838
|
-
|
12839
12663
|
_emberDataPrivateCore.default.errorsHashToArray = _emberDataAdaptersErrors.errorsHashToArray;
|
12840
12664
|
_emberDataPrivateCore.default.errorsArrayToHash = _emberDataAdaptersErrors.errorsArrayToHash;
|
12841
12665
|
|
@@ -13131,7 +12955,7 @@ define('ember-data/serializers/embedded-records-mixin', ['exports', 'ember', 'em
|
|
13131
12955
|
```
|
13132
12956
|
Use a custom (type) serializer for the post model to configure embedded author
|
13133
12957
|
```app/serializers/post.js
|
13134
|
-
import DS from 'ember-data;
|
12958
|
+
import DS from 'ember-data';
|
13135
12959
|
export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
|
13136
12960
|
attrs: {
|
13137
12961
|
author: { embedded: 'always' }
|
@@ -13326,10 +13150,8 @@ define('ember-data/serializers/embedded-records-mixin', ['exports', 'ember', 'em
|
|
13326
13150
|
} else if (this.hasSerializeRecordsOption(attr)) {
|
13327
13151
|
this._serializeEmbeddedHasMany(snapshot, json, relationship);
|
13328
13152
|
} else {
|
13329
|
-
if (
|
13330
|
-
|
13331
|
-
this._serializeHasManyAsIdsAndTypes(snapshot, json, relationship);
|
13332
|
-
}
|
13153
|
+
if (this.hasSerializeIdsAndTypesOption(attr)) {
|
13154
|
+
this._serializeHasManyAsIdsAndTypes(snapshot, json, relationship);
|
13333
13155
|
}
|
13334
13156
|
}
|
13335
13157
|
},
|
@@ -13735,11 +13557,8 @@ define('ember-data/serializers/json-api', ['exports', 'ember', 'ember-data/-priv
|
|
13735
13557
|
*/
|
13736
13558
|
pushPayload: function (store, payload) {
|
13737
13559
|
var normalizedPayload = this._normalizeDocumentHelper(payload);
|
13738
|
-
|
13739
|
-
|
13740
|
-
} else {
|
13741
|
-
store.push(normalizedPayload);
|
13742
|
-
}
|
13560
|
+
|
13561
|
+
store.push(normalizedPayload);
|
13743
13562
|
},
|
13744
13563
|
|
13745
13564
|
/**
|
@@ -14231,9 +14050,8 @@ define('ember-data/serializers/json', ['exports', 'ember', 'ember-data/-private/
|
|
14231
14050
|
var _this = this;
|
14232
14051
|
|
14233
14052
|
var attributes = undefined;
|
14234
|
-
|
14235
|
-
|
14236
|
-
}
|
14053
|
+
|
14054
|
+
attributes = get(typeClass, 'attributes');
|
14237
14055
|
|
14238
14056
|
typeClass.eachTransformedAttribute(function (key, typeClass) {
|
14239
14057
|
if (!(key in data)) {
|
@@ -14241,12 +14059,9 @@ define('ember-data/serializers/json', ['exports', 'ember', 'ember-data/-private/
|
|
14241
14059
|
}
|
14242
14060
|
|
14243
14061
|
var transform = _this.transformFor(typeClass);
|
14244
|
-
|
14245
|
-
|
14246
|
-
|
14247
|
-
} else {
|
14248
|
-
data[key] = transform.deserialize(data[key]);
|
14249
|
-
}
|
14062
|
+
|
14063
|
+
var transformMeta = attributes.get(key);
|
14064
|
+
data[key] = transform.deserialize(data[key], transformMeta.options);
|
14250
14065
|
});
|
14251
14066
|
|
14252
14067
|
return data;
|
@@ -15090,11 +14905,8 @@ define('ember-data/serializers/json', ['exports', 'ember', 'ember-data/-private/
|
|
15090
14905
|
var value = snapshot.attr(key);
|
15091
14906
|
if (type) {
|
15092
14907
|
var transform = this.transformFor(type);
|
15093
|
-
|
15094
|
-
|
15095
|
-
} else {
|
15096
|
-
value = transform.serialize(value);
|
15097
|
-
}
|
14908
|
+
|
14909
|
+
value = transform.serialize(value, attribute.options);
|
15098
14910
|
}
|
15099
14911
|
|
15100
14912
|
// if provided, use the mapping provided by `attrs` in
|
@@ -15828,11 +15640,7 @@ define("ember-data/serializers/rest", ["exports", "ember", "ember-data/-private/
|
|
15828
15640
|
});
|
15829
15641
|
}
|
15830
15642
|
|
15831
|
-
|
15832
|
-
return store.push(documentHash);
|
15833
|
-
} else {
|
15834
|
-
store.push(documentHash);
|
15835
|
-
}
|
15643
|
+
store.push(documentHash);
|
15836
15644
|
},
|
15837
15645
|
|
15838
15646
|
/**
|
@@ -16255,7 +16063,7 @@ define('ember-data/transform', ['exports', 'ember'], function (exports, _ember)
|
|
16255
16063
|
});
|
16256
16064
|
});
|
16257
16065
|
define("ember-data/version", ["exports"], function (exports) {
|
16258
|
-
exports.default = "2.6.0-beta.
|
16066
|
+
exports.default = "2.6.0-beta.2";
|
16259
16067
|
});
|
16260
16068
|
define("ember-inflector", ["exports", "ember", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (exports, _ember, _emberInflectorLibSystem, _emberInflectorLibExtString) {
|
16261
16069
|
|