ember-data-source 2.5.5 → 2.6.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f4931ad5bee083305d56fa09541aff70e133984
4
- data.tar.gz: 58bade410c20c861b6174949fade2879cf0e1abf
3
+ metadata.gz: 88f79999e62cc652e4bea22f2190d6c5a6b8b92b
4
+ data.tar.gz: edca8ebda1f72c2beb8ac125854f9c1272724379
5
5
  SHA512:
6
- metadata.gz: 4bf473816f95e2d3a31e73d1feba3986062e61cc65d54c9149ef7835ce72a61483c50a0fb79ae216bb69b8d6e57ed34549b54b6c8e2aaaa67dfafb47f2bcb666
7
- data.tar.gz: a36b73a012214876f5b5ee9bd96cac9b01e1c2b54c30a751d5079cc50c40c1a6b6aedbb3c190a276a64c17ac0cf0bc64af21039037dc2736b3de69797eca286c
6
+ metadata.gz: 2b5815a20c02f767e0889846f4bf024120f215f602f24ace34827d956f889fec7c9f33bc1adbf7cd4da6d38dcd08ef2c44f75df75e6eae008b743088aecca06d
7
+ data.tar.gz: 41347e4946c0c1cb976f777fc55e77d32774b452572dbe4c59bfaa7e15c0302161f0e114bfb18317c2265d8b8eb5046e607183d83457a6f7493b52bc630648e3
@@ -6,17 +6,44 @@
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.5.5
9
+ * @version 2.6.0-beta.1
10
10
  */
11
11
 
12
- var define, requireModule, require, requirejs;
12
+ var loader, define, requireModule, require, requirejs;
13
13
 
14
- (function() {
14
+ (function(global) {
15
+ 'use strict';
16
+
17
+ // Save off the original values of these globals, so we can restore them if someone asks us to
18
+ var oldGlobals = {
19
+ loader: loader,
20
+ define: define,
21
+ requireModule: requireModule,
22
+ require: require,
23
+ requirejs: requirejs
24
+ };
25
+
26
+ loader = {
27
+ noConflict: function(aliases) {
28
+ var oldName, newName;
29
+
30
+ for (oldName in aliases) {
31
+ if (aliases.hasOwnProperty(oldName)) {
32
+ if (oldGlobals.hasOwnProperty(oldName)) {
33
+ newName = aliases[oldName];
34
+
35
+ global[newName] = global[oldName];
36
+ global[oldName] = oldGlobals[oldName];
37
+ }
38
+ }
39
+ }
40
+ }
41
+ };
15
42
 
16
43
  var _isArray;
17
44
  if (!Array.isArray) {
18
45
  _isArray = function (x) {
19
- return Object.prototype.toString.call(x) === "[object Array]";
46
+ return Object.prototype.toString.call(x) === '[object Array]';
20
47
  };
21
48
  } else {
22
49
  _isArray = Array.isArray;
@@ -25,33 +52,83 @@ var define, requireModule, require, requirejs;
25
52
  var registry = {};
26
53
  var seen = {};
27
54
  var FAILED = false;
55
+ var LOADED = true;
28
56
 
29
57
  var uuid = 0;
30
58
 
31
- function tryFinally(tryable, finalizer) {
32
- try {
33
- return tryable();
34
- } finally {
35
- finalizer();
36
- }
37
- }
38
-
39
59
  function unsupportedModule(length) {
40
- throw new Error("an unsupported module was defined, expected `define(name, deps, module)` instead got: `" + length + "` arguments to define`");
60
+ throw new Error('an unsupported module was defined, expected `define(name, deps, module)` instead got: `' +
61
+ length + '` arguments to define`');
41
62
  }
42
63
 
43
64
  var defaultDeps = ['require', 'exports', 'module'];
44
65
 
45
- function Module(name, deps, callback, exports) {
46
- this.id = uuid++;
47
- this.name = name;
48
- this.deps = !deps.length && callback.length ? defaultDeps : deps;
49
- this.exports = exports || { };
50
- this.callback = callback;
51
- this.state = undefined;
66
+ function Module(name, deps, callback) {
67
+ this.id = uuid++;
68
+ this.name = name;
69
+ this.deps = !deps.length && callback.length ? defaultDeps : deps;
70
+ this.module = { exports: {} };
71
+ this.callback = callback;
72
+ this.state = undefined;
52
73
  this._require = undefined;
74
+ this.finalized = false;
75
+ this.hasExportsAsDep = false;
53
76
  }
54
77
 
78
+ Module.prototype.makeDefaultExport = function() {
79
+ var exports = this.module.exports;
80
+ if (exports !== null &&
81
+ (typeof exports === 'object' || typeof exports === 'function') &&
82
+ exports['default'] === undefined) {
83
+ exports['default'] = exports;
84
+ }
85
+ };
86
+
87
+ Module.prototype.exports = function(reifiedDeps) {
88
+ if (this.finalized) {
89
+ return this.module.exports;
90
+ } else {
91
+ if (loader.wrapModules) {
92
+ this.callback = loader.wrapModules(this.name, this.callback);
93
+ }
94
+ var result = this.callback.apply(this, reifiedDeps);
95
+ if (!(this.hasExportsAsDep && result === undefined)) {
96
+ this.module.exports = result;
97
+ }
98
+ this.makeDefaultExport();
99
+ this.finalized = true;
100
+ return this.module.exports;
101
+ }
102
+ };
103
+
104
+ Module.prototype.unsee = function() {
105
+ this.finalized = false;
106
+ this.state = undefined;
107
+ this.module = { exports: {}};
108
+ };
109
+
110
+ Module.prototype.reify = function() {
111
+ var deps = this.deps;
112
+ var length = deps.length;
113
+ var reified = new Array(length);
114
+ var dep;
115
+
116
+ for (var i = 0, l = length; i < l; i++) {
117
+ dep = deps[i];
118
+ if (dep === 'exports') {
119
+ this.hasExportsAsDep = true;
120
+ reified[i] = this.module.exports;
121
+ } else if (dep === 'require') {
122
+ reified[i] = this.makeRequire();
123
+ } else if (dep === 'module') {
124
+ reified[i] = this.module;
125
+ } else {
126
+ reified[i] = findModule(resolve(dep, this.name), this.name).module.exports;
127
+ }
128
+ }
129
+
130
+ return reified;
131
+ };
55
132
 
56
133
  Module.prototype.makeRequire = function() {
57
134
  var name = this.name;
@@ -59,7 +136,14 @@ var define, requireModule, require, requirejs;
59
136
  return this._require || (this._require = function(dep) {
60
137
  return require(resolve(dep, name));
61
138
  });
62
- }
139
+ };
140
+
141
+ Module.prototype.build = function() {
142
+ if (this.state === FAILED) { return; }
143
+ this.state = FAILED;
144
+ this.exports(this.reify());
145
+ this.state = LOADED;
146
+ };
63
147
 
64
148
  define = function(name, deps, callback) {
65
149
  if (arguments.length < 2) {
@@ -87,91 +171,27 @@ var define, requireModule, require, requirejs;
87
171
  return new Alias(path);
88
172
  };
89
173
 
90
- function reify(mod, name, seen) {
91
- var deps = mod.deps;
92
- var length = deps.length;
93
- var reified = new Array(length);
94
- var dep;
95
- // TODO: new Module
96
- // TODO: seen refactor
97
- var module = { };
98
-
99
- for (var i = 0, l = length; i < l; i++) {
100
- dep = deps[i];
101
- if (dep === 'exports') {
102
- module.exports = reified[i] = seen;
103
- } else if (dep === 'require') {
104
- reified[i] = mod.makeRequire();
105
- } else if (dep === 'module') {
106
- mod.exports = seen;
107
- module = reified[i] = mod;
108
- } else {
109
- reified[i] = requireFrom(resolve(dep, name), name);
110
- }
111
- }
112
-
113
- return {
114
- deps: reified,
115
- module: module
116
- };
117
- }
118
-
119
- function requireFrom(name, origin) {
120
- var mod = registry[name];
121
- if (!mod) {
122
- throw new Error('Could not find module `' + name + '` imported from `' + origin + '`');
123
- }
124
- return require(name);
174
+ function missingModule(name, referrer) {
175
+ throw new Error('Could not find module `' + name + '` imported from `' + referrer + '`');
125
176
  }
126
177
 
127
- function missingModule(name) {
128
- throw new Error('Could not find module ' + name);
129
- }
130
178
  requirejs = require = requireModule = function(name) {
131
- var mod = registry[name];
132
-
133
- if (mod && mod.callback instanceof Alias) {
134
- mod = registry[mod.callback.name];
135
- }
136
-
137
- if (!mod) { missingModule(name); }
138
-
139
- if (mod.state !== FAILED &&
140
- seen.hasOwnProperty(name)) {
141
- return seen[name];
142
- }
143
-
144
- var reified;
145
- var module;
146
- var loaded = false;
147
-
148
- seen[name] = { }; // placeholder for run-time cycles
179
+ return findModule(name, '(require)').module.exports;
180
+ };
149
181
 
150
- tryFinally(function() {
151
- reified = reify(mod, name, seen[name]);
152
- module = mod.callback.apply(this, reified.deps);
153
- loaded = true;
154
- }, function() {
155
- if (!loaded) {
156
- mod.state = FAILED;
157
- }
158
- });
182
+ function findModule(name, referrer) {
183
+ var mod = registry[name] || registry[name + '/index'];
159
184
 
160
- var obj;
161
- if (module === undefined && reified.module.exports) {
162
- obj = reified.module.exports;
163
- } else {
164
- obj = seen[name] = module;
185
+ while (mod && mod.callback instanceof Alias) {
186
+ name = mod.callback.name;
187
+ mod = registry[name];
165
188
  }
166
189
 
167
- if (obj !== null &&
168
- (typeof obj === 'object' || typeof obj === 'function') &&
169
- obj['default'] === undefined) {
170
- obj['default'] = obj;
171
- }
190
+ if (!mod) { missingModule(name, referrer); }
172
191
 
173
- return (seen[name] = obj);
174
- };
192
+ mod.build();
193
+ return mod;
194
+ }
175
195
 
176
196
  function resolve(child, name) {
177
197
  if (child.charAt(0) !== '.') { return child; }
@@ -198,14 +218,14 @@ var define, requireModule, require, requirejs;
198
218
 
199
219
  requirejs.entries = requirejs._eak_seen = registry;
200
220
  requirejs.unsee = function(moduleName) {
201
- delete seen[moduleName];
221
+ findModule(moduleName, '(unsee)').unsee();
202
222
  };
203
223
 
204
224
  requirejs.clear = function() {
205
225
  requirejs.entries = requirejs._eak_seen = registry = {};
206
- seen = state = {};
226
+ seen = {};
207
227
  };
208
- })();
228
+ })(this);
209
229
 
210
230
  define("ember-data/-private/adapters", ["exports", "ember-data/adapters/json-api", "ember-data/adapters/rest"], function (exports, _emberDataAdaptersJsonApi, _emberDataAdaptersRest) {
211
231
  exports.JSONAPIAdapter = _emberDataAdaptersJsonApi.default;
@@ -389,7 +409,7 @@ define('ember-data/-private/adapters/build-url-mixin', ['exports', 'ember'], fun
389
409
  },
390
410
 
391
411
  /**
392
- * @method urlForFindBelongTo
412
+ * @method urlForFindBelongsTo
393
413
  * @param {String} id
394
414
  * @param {String} modelName
395
415
  * @param {DS.Snapshot} snapshot
@@ -498,189 +518,6 @@ define('ember-data/-private/adapters/build-url-mixin', ['exports', 'ember'], fun
498
518
  }
499
519
  });
500
520
  });
501
- define('ember-data/-private/adapters/errors', ['exports', 'ember', 'ember-data/-private/debug'], function (exports, _ember, _emberDataPrivateDebug) {
502
- exports.AdapterError = AdapterError;
503
- exports.InvalidError = InvalidError;
504
- exports.TimeoutError = TimeoutError;
505
- exports.AbortError = AbortError;
506
- exports.errorsHashToArray = errorsHashToArray;
507
- exports.errorsArrayToHash = errorsArrayToHash;
508
-
509
- var EmberError = _ember.default.Error;
510
-
511
- var SOURCE_POINTER_REGEXP = /^\/?data\/(attributes|relationships)\/(.*)/;
512
- var SOURCE_POINTER_PRIMARY_REGEXP = /^\/?data/;
513
- var PRIMARY_ATTRIBUTE_KEY = 'base';
514
-
515
- /**
516
- @class AdapterError
517
- @namespace DS
518
- */
519
-
520
- function AdapterError(errors) {
521
- var message = arguments.length <= 1 || arguments[1] === undefined ? 'Adapter operation failed' : arguments[1];
522
-
523
- this.isAdapterError = true;
524
- EmberError.call(this, message);
525
-
526
- this.errors = errors || [{
527
- title: 'Adapter Error',
528
- detail: message
529
- }];
530
- }
531
-
532
- AdapterError.prototype = Object.create(EmberError.prototype);
533
-
534
- /**
535
- A `DS.InvalidError` is used by an adapter to signal the external API
536
- was unable to process a request because the content was not
537
- semantically correct or meaningful per the API. Usually this means a
538
- record failed some form of server side validation. When a promise
539
- from an adapter is rejected with a `DS.InvalidError` the record will
540
- transition to the `invalid` state and the errors will be set to the
541
- `errors` property on the record.
542
-
543
- For Ember Data to correctly map errors to their corresponding
544
- properties on the model, Ember Data expects each error to be
545
- a valid json-api error object with a `source/pointer` that matches
546
- the property name. For example if you had a Post model that
547
- looked like this.
548
-
549
- ```app/models/post.js
550
- import DS from 'ember-data';
551
-
552
- export default DS.Model.extend({
553
- title: DS.attr('string'),
554
- content: DS.attr('string')
555
- });
556
- ```
557
-
558
- To show an error from the server related to the `title` and
559
- `content` properties your adapter could return a promise that
560
- rejects with a `DS.InvalidError` object that looks like this:
561
-
562
- ```app/adapters/post.js
563
- import Ember from 'ember';
564
- import DS from 'ember-data';
565
-
566
- export default DS.RESTAdapter.extend({
567
- updateRecord: function() {
568
- // Fictional adapter that always rejects
569
- return Ember.RSVP.reject(new DS.InvalidError([
570
- {
571
- detail: 'Must be unique',
572
- source: { pointer: '/data/attributes/title' }
573
- },
574
- {
575
- detail: 'Must not be blank',
576
- source: { pointer: '/data/attributes/content'}
577
- }
578
- ]));
579
- }
580
- });
581
- ```
582
-
583
- Your backend may use different property names for your records the
584
- store will attempt extract and normalize the errors using the
585
- serializer's `extractErrors` method before the errors get added to
586
- the the model. As a result, it is safe for the `InvalidError` to
587
- wrap the error payload unaltered.
588
-
589
- @class InvalidError
590
- @namespace DS
591
- */
592
-
593
- function InvalidError(errors) {
594
- (0, _emberDataPrivateDebug.assert)('`InvalidError` expects json-api formatted errors array.', _ember.default.isArray(errors || []));
595
- AdapterError.call(this, errors, 'The adapter rejected the commit because it was invalid');
596
- }
597
-
598
- InvalidError.prototype = Object.create(AdapterError.prototype);
599
-
600
- /**
601
- @class TimeoutError
602
- @namespace DS
603
- */
604
-
605
- function TimeoutError() {
606
- AdapterError.call(this, null, 'The adapter operation timed out');
607
- }
608
-
609
- TimeoutError.prototype = Object.create(AdapterError.prototype);
610
-
611
- /**
612
- @class AbortError
613
- @namespace DS
614
- */
615
-
616
- function AbortError() {
617
- AdapterError.call(this, null, 'The adapter operation was aborted');
618
- }
619
-
620
- AbortError.prototype = Object.create(AdapterError.prototype);
621
-
622
- /**
623
- @method errorsHashToArray
624
- @private
625
- */
626
-
627
- function errorsHashToArray(errors) {
628
- var out = [];
629
-
630
- if (_ember.default.isPresent(errors)) {
631
- Object.keys(errors).forEach(function (key) {
632
- var messages = _ember.default.makeArray(errors[key]);
633
- for (var i = 0; i < messages.length; i++) {
634
- var title = 'Invalid Attribute';
635
- var pointer = '/data/attributes/' + key;
636
- if (key === PRIMARY_ATTRIBUTE_KEY) {
637
- title = 'Invalid Document';
638
- pointer = '/data';
639
- }
640
- out.push({
641
- title: title,
642
- detail: messages[i],
643
- source: {
644
- pointer: pointer
645
- }
646
- });
647
- }
648
- });
649
- }
650
-
651
- return out;
652
- }
653
-
654
- /**
655
- @method errorsArrayToHash
656
- @private
657
- */
658
-
659
- function errorsArrayToHash(errors) {
660
- var out = {};
661
-
662
- if (_ember.default.isPresent(errors)) {
663
- errors.forEach(function (error) {
664
- if (error.source && error.source.pointer) {
665
- var key = error.source.pointer.match(SOURCE_POINTER_REGEXP);
666
-
667
- if (key) {
668
- key = key[2];
669
- } else if (error.source.pointer.search(SOURCE_POINTER_PRIMARY_REGEXP) !== -1) {
670
- key = PRIMARY_ATTRIBUTE_KEY;
671
- }
672
-
673
- if (key) {
674
- out[key] = out[key] || [];
675
- out[key].push(error.detail || error.title);
676
- }
677
- }
678
- });
679
- }
680
-
681
- return out;
682
- }
683
- });
684
521
  define('ember-data/-private/core', ['exports', 'ember', 'ember-data/version'], function (exports, _ember, _emberDataVersion) {
685
522
 
686
523
  /**
@@ -1393,7 +1230,11 @@ define("ember-data/-private/system/many-array", ["exports", "ember", "ember-data
1393
1230
 
1394
1231
  //a hack for not removing new records
1395
1232
  //TODO remove once we have proper diffing
1396
- var newRecords = this.currentState.filter(function (internalModel) {
1233
+ var newRecords = this.currentState.filter(
1234
+ // only add new records which are not yet in the canonical state of this
1235
+ // relationship (a new record can be in the canonical state if it has
1236
+ // been 'acknowleged' to be in the relationship via a store.push)
1237
+ function (internalModel) {
1397
1238
  return internalModel.isNew() && toSet.indexOf(internalModel) === -1;
1398
1239
  });
1399
1240
  toSet = toSet.concat(newRecords);
@@ -2765,7 +2606,7 @@ define("ember-data/-private/system/model/internal-model", ["exports", "ember", "
2765
2606
  },
2766
2607
 
2767
2608
  _preloadHasMany: function (key, preloadValue, type) {
2768
- (0, _emberDataPrivateDebug.assert)("You need to pass in an array to set a hasMany property on a record", _ember.default.isArray(preloadValue));
2609
+ (0, _emberDataPrivateDebug.assert)("You need to pass in an array to set a hasMany property on a record", Array.isArray(preloadValue));
2769
2610
  var recordsToSet = new Array(preloadValue.length);
2770
2611
 
2771
2612
  for (var i = 0; i < preloadValue.length; i++) {
@@ -3015,7 +2856,7 @@ define("ember-data/-private/system/model/internal-model", ["exports", "ember", "
3015
2856
  }
3016
2857
  };
3017
2858
 
3018
- if (true) {
2859
+ if ((0, _emberDataPrivateFeatures.default)('ds-references')) {
3019
2860
 
3020
2861
  InternalModel.prototype.referenceFor = function (type, name) {
3021
2862
  var reference = this.references[name];
@@ -3792,7 +3633,7 @@ define("ember-data/-private/system/model/model", ["exports", "ember", "ember-dat
3792
3633
  });
3793
3634
  }
3794
3635
 
3795
- if (true) {
3636
+ if ((0, _emberDataPrivateFeatures.default)("ds-references")) {
3796
3637
 
3797
3638
  Model.reopen({
3798
3639
 
@@ -5228,7 +5069,7 @@ define("ember-data/-private/system/record-arrays", ["exports", "ember-data/-priv
5228
5069
  /**
5229
5070
  @module ember-data
5230
5071
  */
5231
- define("ember-data/-private/system/record-arrays/adapter-populated-record-array", ["exports", "ember", "ember-data/-private/system/record-arrays/record-array", "ember-data/-private/system/clone-null"], function (exports, _ember, _emberDataPrivateSystemRecordArraysRecordArray, _emberDataPrivateSystemCloneNull) {
5072
+ define("ember-data/-private/system/record-arrays/adapter-populated-record-array", ["exports", "ember", "ember-data/-private/system/record-arrays/record-array", "ember-data/-private/system/clone-null", "ember-data/-private/features"], function (exports, _ember, _emberDataPrivateSystemRecordArraysRecordArray, _emberDataPrivateSystemCloneNull, _emberDataPrivateFeatures) {
5232
5073
 
5233
5074
  /**
5234
5075
  @module ember-data
@@ -5280,6 +5121,10 @@ define("ember-data/-private/system/record-arrays/adapter-populated-record-array"
5280
5121
  meta: (0, _emberDataPrivateSystemCloneNull.default)(payload.meta)
5281
5122
  });
5282
5123
 
5124
+ if ((0, _emberDataPrivateFeatures.default)('ds-links-in-record-array')) {
5125
+ this.set('links', (0, _emberDataPrivateSystemCloneNull.default)(payload.links));
5126
+ }
5127
+
5283
5128
  internalModels.forEach(function (record) {
5284
5129
  _this.manager.recordArraysForRecord(record).add(_this);
5285
5130
  });
@@ -6930,9 +6775,17 @@ define("ember-data/-private/system/relationships/state/create", ["exports", "emb
6930
6775
 
6931
6776
  var get = _ember.default.get;
6932
6777
 
6778
+ function shouldFindInverse(relationshipMeta) {
6779
+ var options = relationshipMeta.options;
6780
+ return !(options && options.inverse === null);
6781
+ }
6782
+
6933
6783
  function createRelationshipFor(record, relationshipMeta, store) {
6934
- var inverseKey;
6935
- var inverse = record.type.inverseFor(relationshipMeta.key, store);
6784
+ var inverseKey = undefined;
6785
+ var inverse = null;
6786
+ if (shouldFindInverse(relationshipMeta)) {
6787
+ inverse = record.type.inverseFor(relationshipMeta.key, store);
6788
+ }
6936
6789
 
6937
6790
  if (inverse) {
6938
6791
  inverseKey = inverse.name;
@@ -7510,7 +7363,7 @@ define('ember-data/-private/system/snapshot-record-array', ['exports', 'ember-da
7510
7363
  */
7511
7364
  this.adapterOptions = options.adapterOptions;
7512
7365
 
7513
- if (true) {
7366
+ if ((0, _emberDataPrivateFeatures.default)('ds-finder-include')) {
7514
7367
  this.include = options.include;
7515
7368
  }
7516
7369
  }
@@ -7575,7 +7428,7 @@ define('ember-data/-private/system/snapshot', ['exports', 'ember', 'ember-data/-
7575
7428
  */
7576
7429
  this.adapterOptions = options.adapterOptions;
7577
7430
 
7578
- if (true) {
7431
+ if ((0, _emberDataPrivateFeatures.default)('ds-finder-include')) {
7579
7432
  this.include = options.include;
7580
7433
  }
7581
7434
 
@@ -7861,13 +7714,12 @@ define('ember-data/-private/system/snapshot', ['exports', 'ember', 'ember-data/-
7861
7714
  /**
7862
7715
  @module ember-data
7863
7716
  */
7864
- define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/model', 'ember-data/-private/debug', 'ember-data/-private/system/normalize-link', 'ember-data/-private/system/normalize-model-name', 'ember-data/-private/adapters/errors', 'ember-data/-private/system/promise-proxies', 'ember-data/-private/system/store/common', 'ember-data/-private/system/store/serializer-response', 'ember-data/-private/system/store/serializers', 'ember-data/-private/system/store/finders', 'ember-data/-private/utils', 'ember-data/-private/system/coerce-id', 'ember-data/-private/system/record-array-manager', 'ember-data/-private/system/store/container-instance-cache', 'ember-data/-private/system/model/internal-model', 'ember-data/-private/system/empty-object', 'ember-data/-private/features'], function (exports, _ember, _emberDataModel, _emberDataPrivateDebug, _emberDataPrivateSystemNormalizeLink, _emberDataPrivateSystemNormalizeModelName, _emberDataPrivateAdaptersErrors, _emberDataPrivateSystemPromiseProxies, _emberDataPrivateSystemStoreCommon, _emberDataPrivateSystemStoreSerializerResponse, _emberDataPrivateSystemStoreSerializers, _emberDataPrivateSystemStoreFinders, _emberDataPrivateUtils, _emberDataPrivateSystemCoerceId, _emberDataPrivateSystemRecordArrayManager, _emberDataPrivateSystemStoreContainerInstanceCache, _emberDataPrivateSystemModelInternalModel, _emberDataPrivateSystemEmptyObject, _emberDataPrivateFeatures) {
7717
+ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/model', 'ember-data/-private/debug', 'ember-data/-private/system/normalize-link', 'ember-data/-private/system/normalize-model-name', 'ember-data/adapters/errors', 'ember-data/-private/system/promise-proxies', 'ember-data/-private/system/store/common', 'ember-data/-private/system/store/serializer-response', 'ember-data/-private/system/store/serializers', 'ember-data/-private/system/store/finders', 'ember-data/-private/utils', 'ember-data/-private/system/coerce-id', 'ember-data/-private/system/record-array-manager', 'ember-data/-private/system/store/container-instance-cache', 'ember-data/-private/system/model/internal-model', 'ember-data/-private/system/empty-object', 'ember-data/-private/features'], function (exports, _ember, _emberDataModel, _emberDataPrivateDebug, _emberDataPrivateSystemNormalizeLink, _emberDataPrivateSystemNormalizeModelName, _emberDataAdaptersErrors, _emberDataPrivateSystemPromiseProxies, _emberDataPrivateSystemStoreCommon, _emberDataPrivateSystemStoreSerializerResponse, _emberDataPrivateSystemStoreSerializers, _emberDataPrivateSystemStoreFinders, _emberDataPrivateUtils, _emberDataPrivateSystemCoerceId, _emberDataPrivateSystemRecordArrayManager, _emberDataPrivateSystemStoreContainerInstanceCache, _emberDataPrivateSystemModelInternalModel, _emberDataPrivateSystemEmptyObject, _emberDataPrivateFeatures) {
7865
7718
  var badIdFormatAssertion = '`id` has to be non-empty string or number';
7866
7719
 
7867
7720
  exports.badIdFormatAssertion = badIdFormatAssertion;
7868
7721
  var Backburner = _ember.default._Backburner;
7869
7722
  var Map = _ember.default.Map;
7870
- var isArray = Array.isArray || _ember.default.isArray;
7871
7723
 
7872
7724
  //Get the materialized model from the internalModel/promise that returns
7873
7725
  //an internal model and return it in a promiseObject. Useful for returning
@@ -8751,9 +8603,6 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
8751
8603
 
8752
8604
  (0, _emberDataPrivateDebug.assert)("You tried to load all records but you have no adapter (for " + typeClass + ")", adapter);
8753
8605
  (0, _emberDataPrivateDebug.assert)("You tried to load all records but your adapter does not implement `findAll`", typeof adapter.findAll === 'function');
8754
-
8755
- set(array, 'isUpdating', true);
8756
-
8757
8606
  if (options.reload) {
8758
8607
  return (0, _emberDataPrivateSystemPromiseProxies.promiseArray)((0, _emberDataPrivateSystemStoreFinders._findAll)(adapter, this, typeClass, sinceToken, options));
8759
8608
  }
@@ -9353,7 +9202,7 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
9353
9202
  }
9354
9203
  }
9355
9204
 
9356
- if (isArray(data.data)) {
9205
+ if (Array.isArray(data.data)) {
9357
9206
  length = data.data.length;
9358
9207
  var internalModels = new Array(length);
9359
9208
  for (i = 0; i < length; i++) {
@@ -9384,18 +9233,30 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
9384
9233
  (0, _emberDataPrivateDebug.assert)('You must include an \'id\' for ' + modelName + ' in an object passed to \'push\'', data.id != null && data.id !== '');
9385
9234
  (0, _emberDataPrivateDebug.assert)('You tried to push data with a type \'' + modelName + '\' but no model could be found with that name.', this._hasModelFor(modelName));
9386
9235
 
9387
- var type = this.modelFor(modelName);
9236
+ (0, _emberDataPrivateDebug.runInDebug)(function () {
9237
+ // If Ember.ENV.DS_WARN_ON_UNKNOWN_KEYS is set to true and the payload
9238
+ // contains unknown attributes or relationships, log a warning.
9388
9239
 
9389
- // If Ember.ENV.DS_WARN_ON_UNKNOWN_KEYS is set to true and the payload
9390
- // contains unknown keys, log a warning.
9240
+ if (_ember.default.ENV.DS_WARN_ON_UNKNOWN_KEYS) {
9241
+ (function () {
9242
+ var type = _this2.modelFor(modelName);
9391
9243
 
9392
- if (_ember.default.ENV.DS_WARN_ON_UNKNOWN_KEYS) {
9393
- (0, _emberDataPrivateDebug.warn)("The payload for '" + type.modelName + "' contains these unknown keys: " + _ember.default.inspect(Object.keys(data).forEach(function (key) {
9394
- return !(key === 'id' || key === 'links' || get(type, 'fields').has(key) || key.match(/Type$/));
9395
- })) + ". Make sure they've been defined in your model.", Object.keys(data).filter(function (key) {
9396
- return !(key === 'id' || key === 'links' || get(type, 'fields').has(key) || key.match(/Type$/));
9397
- }).length === 0, { id: 'ds.store.unknown-keys-in-payload' });
9398
- }
9244
+ // Check unknown attributes
9245
+ var unknownAttributes = Object.keys(data.attributes || {}).filter(function (key) {
9246
+ return !get(type, 'fields').has(key);
9247
+ });
9248
+ var unknownAttributesMessage = 'The payload for \'' + type.modelName + '\' contains these unknown attributes: ' + unknownAttributes + '. Make sure they\'ve been defined in your model.';
9249
+ (0, _emberDataPrivateDebug.warn)(unknownAttributesMessage, unknownAttributes.length === 0, { id: 'ds.store.unknown-keys-in-payload' });
9250
+
9251
+ // Check unknown relationships
9252
+ var unknownRelationships = Object.keys(data.relationships || {}).filter(function (key) {
9253
+ return !get(type, 'fields').has(key);
9254
+ });
9255
+ var unknownRelationshipsMessage = 'The payload for \'' + type.modelName + '\' contains these unknown relationships: ' + unknownRelationships + '. Make sure they\'ve been defined in your model.';
9256
+ (0, _emberDataPrivateDebug.warn)(unknownRelationshipsMessage, unknownRelationships.length === 0, { id: 'ds.store.unknown-keys-in-payload' });
9257
+ })();
9258
+ }
9259
+ });
9399
9260
 
9400
9261
  // Actually load the record into the store.
9401
9262
  var internalModel = this._load(data);
@@ -9470,7 +9331,7 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
9470
9331
  (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');
9471
9332
  serializer = this.serializerFor(modelName);
9472
9333
  }
9473
- if (false) {
9334
+ if ((0, _emberDataPrivateFeatures.default)('ds-pushpayload-return')) {
9474
9335
  return this._adapterRun(function () {
9475
9336
  return serializer.pushPayload(_this3, payload);
9476
9337
  });
@@ -9489,7 +9350,7 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
9489
9350
  socket.on('message', function(message) {
9490
9351
  var modelName = message.model;
9491
9352
  var data = message.data;
9492
- store.push(modelName, store.normalize(modelName, data));
9353
+ store.push(store.normalize(modelName, data));
9493
9354
  });
9494
9355
  ```
9495
9356
  @method normalize
@@ -9671,7 +9532,7 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
9671
9532
 
9672
9533
  });
9673
9534
 
9674
- if (true) {
9535
+ if ((0, _emberDataPrivateFeatures.default)("ds-references")) {
9675
9536
 
9676
9537
  Store.reopen({
9677
9538
  /**
@@ -9712,7 +9573,7 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
9712
9573
  return;
9713
9574
  }
9714
9575
 
9715
- (0, _emberDataPrivateDebug.assert)('A ' + relationship.parentType + ' record was pushed into the store with the value of ' + key + ' being ' + _ember.default.inspect(id) + ', but ' + key + ' is a belongsTo relationship so the value must not be an array. You should probably check your data payload or serializer.', !isArray(id));
9576
+ (0, _emberDataPrivateDebug.assert)('A ' + relationship.parentType + ' record was pushed into the store with the value of ' + key + ' being ' + _ember.default.inspect(id) + ', but ' + key + ' is a belongsTo relationship so the value must not be an array. You should probably check your data payload or serializer.', !Array.isArray(id));
9716
9577
 
9717
9578
  //TODO:Better asserts
9718
9579
  return store._internalModelForId(id.type, id.id);
@@ -9723,7 +9584,7 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
9723
9584
  return;
9724
9585
  }
9725
9586
 
9726
- (0, _emberDataPrivateDebug.assert)('A ' + relationship.parentType + ' record was pushed into the store with the value of ' + key + ' being \'' + _ember.default.inspect(ids) + '\', but ' + key + ' is a hasMany relationship so the value must be an array. You should probably check your data payload or serializer.', isArray(ids));
9587
+ (0, _emberDataPrivateDebug.assert)('A ' + relationship.parentType + ' record was pushed into the store with the value of ' + key + ' being \'' + _ember.default.inspect(ids) + '\', but ' + key + ' is a hasMany relationship so the value must be an array. You should probably check your data payload or serializer.', Array.isArray(ids));
9727
9588
  var _ids = new Array(ids.length);
9728
9589
 
9729
9590
  for (var i = 0; i < ids.length; i++) {
@@ -9768,7 +9629,7 @@ define('ember-data/-private/system/store', ['exports', 'ember', 'ember-data/mode
9768
9629
 
9769
9630
  return internalModel;
9770
9631
  }, function (error) {
9771
- if (error instanceof _emberDataPrivateAdaptersErrors.InvalidError) {
9632
+ if (error instanceof _emberDataAdaptersErrors.InvalidError) {
9772
9633
  var errors = serializer.extractErrors(store, typeClass, error, snapshot.id);
9773
9634
  store.recordWasInvalid(internalModel, errors);
9774
9635
  } else {
@@ -9973,7 +9834,7 @@ define("ember-data/-private/system/store/finders", ["exports", "ember", "ember-d
9973
9834
  var Promise = _ember.default.RSVP.Promise;
9974
9835
 
9975
9836
  function payloadIsNotBlank(adapterPayload) {
9976
- if (_ember.default.isArray(adapterPayload)) {
9837
+ if (Array.isArray(adapterPayload)) {
9977
9838
  return true;
9978
9839
  } else {
9979
9840
  return Object.keys(adapterPayload || {}).length;
@@ -9990,7 +9851,7 @@ define("ember-data/-private/system/store/finders", ["exports", "ember", "ember-d
9990
9851
  promise = (0, _emberDataPrivateSystemStoreCommon._guard)(promise, (0, _emberDataPrivateSystemStoreCommon._bind)(_emberDataPrivateSystemStoreCommon._objectIsAlive, store));
9991
9852
 
9992
9853
  return promise.then(function (adapterPayload) {
9993
- (0, _emberDataPrivateDebug.assert)("You made a `findRecord` request for a " + typeClass.typeClassKey + " with id " + id + ", but the adapter's response did not have any data", payloadIsNotBlank(adapterPayload));
9854
+ (0, _emberDataPrivateDebug.assert)("You made a `findRecord` request for a " + typeClass.modelName + " with id " + id + ", but the adapter's response did not have any data", payloadIsNotBlank(adapterPayload));
9994
9855
  return store._adapterRun(function () {
9995
9856
  var payload = (0, _emberDataPrivateSystemStoreSerializerResponse.normalizeResponseHelper)(serializer, store, typeClass, adapterPayload, id, 'findRecord');
9996
9857
  (0, _emberDataPrivateDebug.assert)('Ember Data expected the primary data returned from a `findRecord` response to be an object but instead it found an array.', !Array.isArray(payload.data));
@@ -10022,7 +9883,7 @@ define("ember-data/-private/system/store/finders", ["exports", "ember", "ember-d
10022
9883
  promise = (0, _emberDataPrivateSystemStoreCommon._guard)(promise, (0, _emberDataPrivateSystemStoreCommon._bind)(_emberDataPrivateSystemStoreCommon._objectIsAlive, store));
10023
9884
 
10024
9885
  return promise.then(function (adapterPayload) {
10025
- (0, _emberDataPrivateDebug.assert)("You made a `findMany` request for a " + typeClass.typeClassKey + " with ids " + ids + ", but the adapter's response did not have any data", payloadIsNotBlank(adapterPayload));
9886
+ (0, _emberDataPrivateDebug.assert)("You made a `findMany` request for " + typeClass.modelName + " records with ids " + ids + ", but the adapter's response did not have any data", payloadIsNotBlank(adapterPayload));
10026
9887
  return store._adapterRun(function () {
10027
9888
  var payload = (0, _emberDataPrivateSystemStoreSerializerResponse.normalizeResponseHelper)(serializer, store, typeClass, adapterPayload, null, 'findMany');
10028
9889
  //TODO Optimize, no need to materialize here
@@ -10102,7 +9963,7 @@ define("ember-data/-private/system/store/finders", ["exports", "ember", "ember-d
10102
9963
  promise = (0, _emberDataPrivateSystemStoreCommon._guard)(promise, (0, _emberDataPrivateSystemStoreCommon._bind)(_emberDataPrivateSystemStoreCommon._objectIsAlive, store));
10103
9964
 
10104
9965
  return promise.then(function (adapterPayload) {
10105
- (0, _emberDataPrivateDebug.assert)("You made a `findAll` request for " + typeClass.typeClassKey + "records, but the adapter's response did not have any data", payloadIsNotBlank(adapterPayload));
9966
+ (0, _emberDataPrivateDebug.assert)("You made a `findAll` request for " + typeClass.modelName + " records, but the adapter's response did not have any data", payloadIsNotBlank(adapterPayload));
10106
9967
  store._adapterRun(function () {
10107
9968
  var payload = (0, _emberDataPrivateSystemStoreSerializerResponse.normalizeResponseHelper)(serializer, store, typeClass, adapterPayload, null, 'findAll');
10108
9969
  //TODO Optimize
@@ -10132,7 +9993,7 @@ define("ember-data/-private/system/store/finders", ["exports", "ember", "ember-d
10132
9993
  records = store.push(payload);
10133
9994
  });
10134
9995
 
10135
- (0, _emberDataPrivateDebug.assert)('The response to store.query is expected to be an array but it was a single record. Please wrap your response in an array or use `store.queryRecord` to query for a single record.', _ember.default.isArray(records));
9996
+ (0, _emberDataPrivateDebug.assert)('The response to store.query is expected to be an array but it was a single record. Please wrap your response in an array or use `store.queryRecord` to query for a single record.', Array.isArray(records));
10136
9997
  recordArray.loadRecords(records, payload);
10137
9998
  return recordArray;
10138
9999
  }, null, "DS: Extract payload of query " + typeClass);
@@ -10148,7 +10009,7 @@ define("ember-data/-private/system/store/finders", ["exports", "ember", "ember-d
10148
10009
  promise = (0, _emberDataPrivateSystemStoreCommon._guard)(promise, (0, _emberDataPrivateSystemStoreCommon._bind)(_emberDataPrivateSystemStoreCommon._objectIsAlive, store));
10149
10010
 
10150
10011
  return promise.then(function (adapterPayload) {
10151
- (0, _emberDataPrivateDebug.assert)("You made a `queryRecord` request for " + typeClass.typeClassKey + "records, with query `" + query + "`, but the adapter's response did not have any data", payloadIsNotBlank(adapterPayload));
10012
+ (0, _emberDataPrivateDebug.assert)("You made a `queryRecord` request for a " + typeClass.modelName + ", but the adapter's response did not have any data", payloadIsNotBlank(adapterPayload));
10152
10013
  var record;
10153
10014
  store._adapterRun(function () {
10154
10015
  var payload = (0, _emberDataPrivateSystemStoreSerializerResponse.normalizeResponseHelper)(serializer, store, typeClass, adapterPayload, null, 'queryRecord');
@@ -10188,7 +10049,7 @@ define('ember-data/-private/system/store/serializer-response', ['exports', 'embe
10188
10049
  }
10189
10050
  }
10190
10051
  if ('data' in doc) {
10191
- if (!(doc.data === null || _ember.default.isArray(doc.data) || typeof doc.data === 'object')) {
10052
+ if (!(doc.data === null || Array.isArray(doc.data) || typeof doc.data === 'object')) {
10192
10053
  errors.push('data must be null, an object, or an array');
10193
10054
  }
10194
10055
  }
@@ -10198,7 +10059,7 @@ define('ember-data/-private/system/store/serializer-response', ['exports', 'embe
10198
10059
  }
10199
10060
  }
10200
10061
  if ('errors' in doc) {
10201
- if (!_ember.default.isArray(doc.errors)) {
10062
+ if (!Array.isArray(doc.errors)) {
10202
10063
  errors.push('errors must be an array');
10203
10064
  }
10204
10065
  }
@@ -10274,7 +10135,8 @@ define("ember-data/-private/transforms", ["exports", "ember-data/transform", "em
10274
10135
  exports.StringTransform = _emberDataPrivateTransformsString.default;
10275
10136
  exports.BooleanTransform = _emberDataPrivateTransformsBoolean.default;
10276
10137
  });
10277
- define("ember-data/-private/transforms/boolean", ["exports", "ember-data/transform"], function (exports, _emberDataTransform) {
10138
+ define('ember-data/-private/transforms/boolean', ['exports', 'ember', 'ember-data/transform', 'ember-data/-private/features'], function (exports, _ember, _emberDataTransform, _emberDataPrivateFeatures) {
10139
+ var isNone = _ember.default.isNone;
10278
10140
 
10279
10141
  /**
10280
10142
  The `DS.BooleanTransform` class is used to serialize and deserialize
@@ -10299,9 +10161,17 @@ define("ember-data/-private/transforms/boolean", ["exports", "ember-data/transfo
10299
10161
  @namespace DS
10300
10162
  */
10301
10163
  exports.default = _emberDataTransform.default.extend({
10302
- deserialize: function (serialized) {
10164
+ deserialize: function (serialized, options) {
10303
10165
  var type = typeof serialized;
10304
10166
 
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
+
10305
10175
  if (type === "boolean") {
10306
10176
  return serialized;
10307
10177
  } else if (type === "string") {
@@ -10313,7 +10183,15 @@ define("ember-data/-private/transforms/boolean", ["exports", "ember-data/transfo
10313
10183
  }
10314
10184
  },
10315
10185
 
10316
- serialize: function (deserialized) {
10186
+ 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
+
10317
10195
  return Boolean(deserialized);
10318
10196
  }
10319
10197
  });
@@ -10621,9 +10499,9 @@ define('ember-data/adapter', ['exports', 'ember'], function (exports, _ember) {
10621
10499
  /**
10622
10500
  The `findRecord()` method is invoked when the store is asked for a record that
10623
10501
  has not previously been loaded. In response to `findRecord()` being called, you
10624
- should query your persistence layer for a record with the given ID. Once
10625
- found, you can asynchronously call the store's `push()` method to push
10626
- the record into the store.
10502
+ should query your persistence layer for a record with the given ID. The `findRecord`
10503
+ method should return a promise that will resolve to a JavaScript object that will be
10504
+ normalized by the serializer.
10627
10505
  Here is an example `findRecord` implementation:
10628
10506
  ```app/adapters/application.js
10629
10507
  import DS from 'ember-data';
@@ -11009,7 +10887,242 @@ define('ember-data/adapter', ['exports', 'ember'], function (exports, _ember) {
11009
10887
  /**
11010
10888
  @module ember-data
11011
10889
  */
11012
- define('ember-data/adapters/json-api', ['exports', 'ember', 'ember-data/adapters/rest'], function (exports, _ember, _emberDataAdaptersRest) {
10890
+ define('ember-data/adapters/errors', ['exports', 'ember', 'ember-data/-private/debug', 'ember-data/-private/features'], function (exports, _ember, _emberDataPrivateDebug, _emberDataPrivateFeatures) {
10891
+ exports.AdapterError = AdapterError;
10892
+ exports.errorsHashToArray = errorsHashToArray;
10893
+ exports.errorsArrayToHash = errorsArrayToHash;
10894
+
10895
+ var EmberError = _ember.default.Error;
10896
+
10897
+ var SOURCE_POINTER_REGEXP = /^\/?data\/(attributes|relationships)\/(.*)/;
10898
+ var SOURCE_POINTER_PRIMARY_REGEXP = /^\/?data/;
10899
+ var PRIMARY_ATTRIBUTE_KEY = 'base';
10900
+
10901
+ /**
10902
+ @class AdapterError
10903
+ @namespace DS
10904
+ */
10905
+
10906
+ function AdapterError(errors) {
10907
+ var message = arguments.length <= 1 || arguments[1] === undefined ? 'Adapter operation failed' : arguments[1];
10908
+
10909
+ this.isAdapterError = true;
10910
+ EmberError.call(this, message);
10911
+
10912
+ this.errors = errors || [{
10913
+ title: 'Adapter Error',
10914
+ detail: message
10915
+ }];
10916
+ }
10917
+
10918
+ var extendedErrorsEnabled = false;
10919
+ if ((0, _emberDataPrivateFeatures.default)('ds-extended-errors')) {
10920
+ extendedErrorsEnabled = true;
10921
+ }
10922
+
10923
+ function extendFn(ErrorClass) {
10924
+ return function () {
10925
+ var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
10926
+
10927
+ var defaultMessage = _ref.message;
10928
+
10929
+ return extend(ErrorClass, defaultMessage);
10930
+ };
10931
+ }
10932
+
10933
+ function extend(ParentErrorClass, defaultMessage) {
10934
+ var ErrorClass = function (errors, message) {
10935
+ (0, _emberDataPrivateDebug.assert)('`AdapterError` expects json-api formatted errors array.', Array.isArray(errors || []));
10936
+ ParentErrorClass.call(this, errors, message || defaultMessage);
10937
+ };
10938
+ ErrorClass.prototype = Object.create(ParentErrorClass.prototype);
10939
+
10940
+ if (extendedErrorsEnabled) {
10941
+ ErrorClass.extend = extendFn(ErrorClass);
10942
+ }
10943
+
10944
+ return ErrorClass;
10945
+ }
10946
+
10947
+ AdapterError.prototype = Object.create(EmberError.prototype);
10948
+
10949
+ if (extendedErrorsEnabled) {
10950
+ AdapterError.extend = extendFn(AdapterError);
10951
+ }
10952
+
10953
+ /**
10954
+ A `DS.InvalidError` is used by an adapter to signal the external API
10955
+ was unable to process a request because the content was not
10956
+ semantically correct or meaningful per the API. Usually this means a
10957
+ record failed some form of server side validation. When a promise
10958
+ from an adapter is rejected with a `DS.InvalidError` the record will
10959
+ transition to the `invalid` state and the errors will be set to the
10960
+ `errors` property on the record.
10961
+
10962
+ For Ember Data to correctly map errors to their corresponding
10963
+ properties on the model, Ember Data expects each error to be
10964
+ a valid json-api error object with a `source/pointer` that matches
10965
+ the property name. For example if you had a Post model that
10966
+ looked like this.
10967
+
10968
+ ```app/models/post.js
10969
+ import DS from 'ember-data';
10970
+
10971
+ export default DS.Model.extend({
10972
+ title: DS.attr('string'),
10973
+ content: DS.attr('string')
10974
+ });
10975
+ ```
10976
+
10977
+ To show an error from the server related to the `title` and
10978
+ `content` properties your adapter could return a promise that
10979
+ rejects with a `DS.InvalidError` object that looks like this:
10980
+
10981
+ ```app/adapters/post.js
10982
+ import Ember from 'ember';
10983
+ import DS from 'ember-data';
10984
+
10985
+ export default DS.RESTAdapter.extend({
10986
+ updateRecord: function() {
10987
+ // Fictional adapter that always rejects
10988
+ return Ember.RSVP.reject(new DS.InvalidError([
10989
+ {
10990
+ detail: 'Must be unique',
10991
+ source: { pointer: '/data/attributes/title' }
10992
+ },
10993
+ {
10994
+ detail: 'Must not be blank',
10995
+ source: { pointer: '/data/attributes/content'}
10996
+ }
10997
+ ]));
10998
+ }
10999
+ });
11000
+ ```
11001
+
11002
+ Your backend may use different property names for your records the
11003
+ store will attempt extract and normalize the errors using the
11004
+ serializer's `extractErrors` method before the errors get added to
11005
+ the the model. As a result, it is safe for the `InvalidError` to
11006
+ wrap the error payload unaltered.
11007
+
11008
+ @class InvalidError
11009
+ @namespace DS
11010
+ */
11011
+ var InvalidError = extend(AdapterError, 'The adapter rejected the commit because it was invalid');
11012
+
11013
+ exports.InvalidError = InvalidError;
11014
+ /**
11015
+ @class TimeoutError
11016
+ @namespace DS
11017
+ */
11018
+ var TimeoutError = extend(AdapterError, 'The adapter operation timed out');
11019
+
11020
+ exports.TimeoutError = TimeoutError;
11021
+ /**
11022
+ @class AbortError
11023
+ @namespace DS
11024
+ */
11025
+ var AbortError = extend(AdapterError, 'The adapter operation was aborted');
11026
+
11027
+ exports.AbortError = AbortError;
11028
+ /**
11029
+ @class UnauthorizedError
11030
+ @namespace DS
11031
+ */
11032
+ var UnauthorizedError = extendedErrorsEnabled ? extend(AdapterError, 'The adapter operation is unauthorized') : null;
11033
+
11034
+ exports.UnauthorizedError = UnauthorizedError;
11035
+ /**
11036
+ @class ForbiddenError
11037
+ @namespace DS
11038
+ */
11039
+ var ForbiddenError = extendedErrorsEnabled ? extend(AdapterError, 'The adapter operation is forbidden') : null;
11040
+
11041
+ exports.ForbiddenError = ForbiddenError;
11042
+ /**
11043
+ @class NotFoundError
11044
+ @namespace DS
11045
+ */
11046
+ var NotFoundError = extendedErrorsEnabled ? extend(AdapterError, 'The adapter could not find the resource') : null;
11047
+
11048
+ exports.NotFoundError = NotFoundError;
11049
+ /**
11050
+ @class ConflictError
11051
+ @namespace DS
11052
+ */
11053
+ var ConflictError = extendedErrorsEnabled ? extend(AdapterError, 'The adapter operation failed due to a conflict') : null;
11054
+
11055
+ exports.ConflictError = ConflictError;
11056
+ /**
11057
+ @class ServerError
11058
+ @namespace DS
11059
+ */
11060
+ var ServerError = extendedErrorsEnabled ? extend(AdapterError, 'The adapter operation failed due to a server error') : null;
11061
+
11062
+ exports.ServerError = ServerError;
11063
+ /**
11064
+ @method errorsHashToArray
11065
+ @private
11066
+ */
11067
+
11068
+ function errorsHashToArray(errors) {
11069
+ var out = [];
11070
+
11071
+ if (_ember.default.isPresent(errors)) {
11072
+ Object.keys(errors).forEach(function (key) {
11073
+ var messages = _ember.default.makeArray(errors[key]);
11074
+ for (var i = 0; i < messages.length; i++) {
11075
+ var title = 'Invalid Attribute';
11076
+ var pointer = '/data/attributes/' + key;
11077
+ if (key === PRIMARY_ATTRIBUTE_KEY) {
11078
+ title = 'Invalid Document';
11079
+ pointer = '/data';
11080
+ }
11081
+ out.push({
11082
+ title: title,
11083
+ detail: messages[i],
11084
+ source: {
11085
+ pointer: pointer
11086
+ }
11087
+ });
11088
+ }
11089
+ });
11090
+ }
11091
+
11092
+ return out;
11093
+ }
11094
+
11095
+ /**
11096
+ @method errorsArrayToHash
11097
+ @private
11098
+ */
11099
+
11100
+ function errorsArrayToHash(errors) {
11101
+ var out = {};
11102
+
11103
+ if (_ember.default.isPresent(errors)) {
11104
+ errors.forEach(function (error) {
11105
+ if (error.source && error.source.pointer) {
11106
+ var key = error.source.pointer.match(SOURCE_POINTER_REGEXP);
11107
+
11108
+ if (key) {
11109
+ key = key[2];
11110
+ } else if (error.source.pointer.search(SOURCE_POINTER_PRIMARY_REGEXP) !== -1) {
11111
+ key = PRIMARY_ATTRIBUTE_KEY;
11112
+ }
11113
+
11114
+ if (key) {
11115
+ out[key] = out[key] || [];
11116
+ out[key].push(error.detail || error.title);
11117
+ }
11118
+ }
11119
+ });
11120
+ }
11121
+
11122
+ return out;
11123
+ }
11124
+ });
11125
+ define('ember-data/adapters/json-api', ['exports', 'ember', 'ember-data/adapters/rest', 'ember-data/-private/features'], function (exports, _ember, _emberDataAdaptersRest, _emberDataPrivateFeatures) {
11013
11126
 
11014
11127
  /**
11015
11128
  @class JSONAPIAdapter
@@ -11017,7 +11130,7 @@ define('ember-data/adapters/json-api', ['exports', 'ember', 'ember-data/adapters
11017
11130
  @namespace DS
11018
11131
  @extends DS.RESTAdapter
11019
11132
  */
11020
- exports.default = _emberDataAdaptersRest.default.extend({
11133
+ var JSONAPIAdapter = _emberDataAdaptersRest.default.extend({
11021
11134
  defaultSerializer: '-json-api',
11022
11135
 
11023
11136
  /**
@@ -11093,8 +11206,12 @@ define('ember-data/adapters/json-api', ['exports', 'ember', 'ember-data/adapters
11093
11206
  @return {Promise} promise
11094
11207
  */
11095
11208
  findMany: function (store, type, ids, snapshots) {
11096
- var url = this.buildURL(type.modelName, ids, snapshots, 'findMany');
11097
- return this.ajax(url, 'GET', { data: { filter: { id: ids.join(',') } } });
11209
+ if ((0, _emberDataPrivateFeatures.default)('ds-improved-ajax')) {
11210
+ return this._super.apply(this, arguments);
11211
+ } else {
11212
+ var url = this.buildURL(type.modelName, ids, snapshots, 'findMany');
11213
+ return this.ajax(url, 'GET', { data: { filter: { id: ids.join(',') } } });
11214
+ }
11098
11215
  },
11099
11216
 
11100
11217
  /**
@@ -11116,22 +11233,87 @@ define('ember-data/adapters/json-api', ['exports', 'ember', 'ember-data/adapters
11116
11233
  @return {Promise} promise
11117
11234
  */
11118
11235
  updateRecord: function (store, type, snapshot) {
11119
- var data = {};
11120
- var serializer = store.serializerFor(type.modelName);
11236
+ if ((0, _emberDataPrivateFeatures.default)('ds-improved-ajax')) {
11237
+ return this._super.apply(this, arguments);
11238
+ } else {
11239
+ var data = {};
11240
+ var serializer = store.serializerFor(type.modelName);
11121
11241
 
11122
- serializer.serializeIntoHash(data, type, snapshot, { includeId: true });
11242
+ serializer.serializeIntoHash(data, type, snapshot, { includeId: true });
11123
11243
 
11124
- var id = snapshot.id;
11125
- var url = this.buildURL(type.modelName, id, snapshot, 'updateRecord');
11244
+ var id = snapshot.id;
11245
+ var url = this.buildURL(type.modelName, id, snapshot, 'updateRecord');
11126
11246
 
11127
- return this.ajax(url, 'PATCH', { data: data });
11247
+ return this.ajax(url, 'PATCH', { data: data });
11248
+ }
11128
11249
  }
11129
11250
  });
11251
+
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
+ exports.default = JSONAPIAdapter;
11130
11312
  });
11131
11313
  /**
11132
11314
  @module ember-data
11133
11315
  */
11134
- define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'ember-data/-private/adapters/errors', 'ember-data/-private/adapters/build-url-mixin', 'ember-data/-private/features', 'ember-data/-private/utils/parse-response-headers'], function (exports, _ember, _emberDataAdapter, _emberDataPrivateAdaptersErrors, _emberDataPrivateAdaptersBuildUrlMixin, _emberDataPrivateFeatures, _emberDataPrivateUtilsParseResponseHeaders) {
11316
+ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'ember-data/adapters/errors', 'ember-data/-private/adapters/build-url-mixin', 'ember-data/-private/features', 'ember-data/-private/debug', 'ember-data/-private/utils/parse-response-headers'], function (exports, _ember, _emberDataAdapter, _emberDataAdaptersErrors, _emberDataPrivateAdaptersBuildUrlMixin, _emberDataPrivateFeatures, _emberDataPrivateDebug, _emberDataPrivateUtilsParseResponseHeaders) {
11135
11317
  var MapWithDefault = _ember.default.MapWithDefault;
11136
11318
  var get = _ember.default.get;
11137
11319
 
@@ -11345,7 +11527,7 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
11345
11527
  @extends DS.Adapter
11346
11528
  @uses DS.BuildURLMixin
11347
11529
  */
11348
- exports.default = _emberDataAdapter.default.extend(_emberDataPrivateAdaptersBuildUrlMixin.default, {
11530
+ var RESTAdapter = _emberDataAdapter.default.extend(_emberDataPrivateAdaptersBuildUrlMixin.default, {
11349
11531
  defaultSerializer: '-rest',
11350
11532
 
11351
11533
  /**
@@ -11492,10 +11674,19 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
11492
11674
  @return {Promise} promise
11493
11675
  */
11494
11676
  findRecord: function (store, type, id, snapshot) {
11495
- var url = this.buildURL(type.modelName, id, snapshot, 'findRecord');
11496
- var query = this.buildQuery(snapshot);
11677
+ if ((0, _emberDataPrivateFeatures.default)('ds-improved-ajax')) {
11678
+ var request = this._requestFor({
11679
+ store: store, type: type, id: id, snapshot: snapshot,
11680
+ requestType: 'findRecord'
11681
+ });
11497
11682
 
11498
- return this.ajax(url, 'GET', { data: query });
11683
+ return this._makeRequest(request);
11684
+ } else {
11685
+ var url = this.buildURL(type.modelName, id, snapshot, 'findRecord');
11686
+ var query = this.buildQuery(snapshot);
11687
+
11688
+ return this.ajax(url, 'GET', { data: query });
11689
+ }
11499
11690
  },
11500
11691
 
11501
11692
  /**
@@ -11511,10 +11702,25 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
11511
11702
  @return {Promise} promise
11512
11703
  */
11513
11704
  findAll: function (store, type, sinceToken, snapshotRecordArray) {
11514
- var url = this.buildURL(type.modelName, null, snapshotRecordArray, 'findAll');
11515
11705
  var query = this.buildQuery(snapshotRecordArray);
11516
11706
 
11517
- return this.ajax(url, 'GET', { data: query });
11707
+ if ((0, _emberDataPrivateFeatures.default)('ds-improved-ajax')) {
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');
11717
+
11718
+ if (sinceToken) {
11719
+ query.since = sinceToken;
11720
+ }
11721
+
11722
+ return this.ajax(url, 'GET', { data: query });
11723
+ }
11518
11724
  },
11519
11725
 
11520
11726
  /**
@@ -11532,13 +11738,22 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
11532
11738
  @return {Promise} promise
11533
11739
  */
11534
11740
  query: function (store, type, query) {
11535
- var url = this.buildURL(type.modelName, null, null, 'query', query);
11741
+ if ((0, _emberDataPrivateFeatures.default)('ds-improved-ajax')) {
11742
+ var request = this._requestFor({
11743
+ store: store, type: type, query: query,
11744
+ requestType: 'query'
11745
+ });
11536
11746
 
11537
- if (this.sortQueryParams) {
11538
- query = this.sortQueryParams(query);
11539
- }
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
+ }
11540
11754
 
11541
- return this.ajax(url, 'GET', { data: query });
11755
+ return this.ajax(url, 'GET', { data: query });
11756
+ }
11542
11757
  },
11543
11758
 
11544
11759
  /**
@@ -11556,13 +11771,22 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
11556
11771
  @return {Promise} promise
11557
11772
  */
11558
11773
  queryRecord: function (store, type, query) {
11559
- var url = this.buildURL(type.modelName, null, null, 'queryRecord', query);
11774
+ if ((0, _emberDataPrivateFeatures.default)('ds-improved-ajax')) {
11775
+ var request = this._requestFor({
11776
+ store: store, type: type, query: query,
11777
+ requestType: 'queryRecord'
11778
+ });
11560
11779
 
11561
- if (this.sortQueryParams) {
11562
- query = this.sortQueryParams(query);
11563
- }
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
+ }
11564
11787
 
11565
- return this.ajax(url, 'GET', { data: query });
11788
+ return this.ajax(url, 'GET', { data: query });
11789
+ }
11566
11790
  },
11567
11791
 
11568
11792
  /**
@@ -11592,8 +11816,17 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
11592
11816
  @return {Promise} promise
11593
11817
  */
11594
11818
  findMany: function (store, type, ids, snapshots) {
11595
- var url = this.buildURL(type.modelName, ids, snapshots, 'findMany');
11596
- return this.ajax(url, 'GET', { data: { ids: ids } });
11819
+ if ((0, _emberDataPrivateFeatures.default)('ds-improved-ajax')) {
11820
+ var request = this._requestFor({
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
+ }
11597
11830
  },
11598
11831
 
11599
11832
  /**
@@ -11623,12 +11856,21 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
11623
11856
  @return {Promise} promise
11624
11857
  */
11625
11858
  findHasMany: function (store, snapshot, url, relationship) {
11626
- var id = snapshot.id;
11627
- var type = snapshot.modelName;
11859
+ if ((0, _emberDataPrivateFeatures.default)('ds-improved-ajax')) {
11860
+ var request = this._requestFor({
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;
11628
11869
 
11629
- url = this.urlPrefix(url, this.buildURL(type, id, snapshot, 'findHasMany'));
11870
+ url = this.urlPrefix(url, this.buildURL(type, id, snapshot, 'findHasMany'));
11630
11871
 
11631
- return this.ajax(url, 'GET');
11872
+ return this.ajax(url, 'GET');
11873
+ }
11632
11874
  },
11633
11875
 
11634
11876
  /**
@@ -11658,11 +11900,20 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
11658
11900
  @return {Promise} promise
11659
11901
  */
11660
11902
  findBelongsTo: function (store, snapshot, url, relationship) {
11661
- var id = snapshot.id;
11662
- var type = snapshot.modelName;
11903
+ if ((0, _emberDataPrivateFeatures.default)('ds-improved-ajax')) {
11904
+ var request = this._requestFor({
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;
11663
11913
 
11664
- url = this.urlPrefix(url, this.buildURL(type, id, snapshot, 'findBelongsTo'));
11665
- return this.ajax(url, 'GET');
11914
+ url = this.urlPrefix(url, this.buildURL(type, id, snapshot, 'findBelongsTo'));
11915
+ return this.ajax(url, 'GET');
11916
+ }
11666
11917
  },
11667
11918
 
11668
11919
  /**
@@ -11679,13 +11930,22 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
11679
11930
  @return {Promise} promise
11680
11931
  */
11681
11932
  createRecord: function (store, type, snapshot) {
11682
- var data = {};
11683
- var serializer = store.serializerFor(type.modelName);
11684
- var url = this.buildURL(type.modelName, null, snapshot, 'createRecord');
11933
+ if ((0, _emberDataPrivateFeatures.default)('ds-improved-ajax')) {
11934
+ var request = this._requestFor({
11935
+ store: store, type: type, snapshot: snapshot,
11936
+ requestType: 'createRecord'
11937
+ });
11685
11938
 
11686
- serializer.serializeIntoHash(data, type, snapshot, { includeId: true });
11939
+ return this._makeRequest(request);
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 });
11687
11946
 
11688
- return this.ajax(url, "POST", { data: data });
11947
+ return this.ajax(url, "POST", { data: data });
11948
+ }
11689
11949
  },
11690
11950
 
11691
11951
  /**
@@ -11702,15 +11962,24 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
11702
11962
  @return {Promise} promise
11703
11963
  */
11704
11964
  updateRecord: function (store, type, snapshot) {
11705
- var data = {};
11706
- var serializer = store.serializerFor(type.modelName);
11965
+ if ((0, _emberDataPrivateFeatures.default)('ds-improved-ajax')) {
11966
+ var request = this._requestFor({
11967
+ store: store, type: type, snapshot: snapshot,
11968
+ requestType: 'updateRecord'
11969
+ });
11707
11970
 
11708
- serializer.serializeIntoHash(data, type, snapshot);
11971
+ return this._makeRequest(request);
11972
+ } else {
11973
+ var data = {};
11974
+ var serializer = store.serializerFor(type.modelName);
11709
11975
 
11710
- var id = snapshot.id;
11711
- var url = this.buildURL(type.modelName, id, snapshot, 'updateRecord');
11976
+ serializer.serializeIntoHash(data, type, snapshot);
11712
11977
 
11713
- return this.ajax(url, "PUT", { data: data });
11978
+ var id = snapshot.id;
11979
+ var url = this.buildURL(type.modelName, id, snapshot, 'updateRecord');
11980
+
11981
+ return this.ajax(url, "PUT", { data: data });
11982
+ }
11714
11983
  },
11715
11984
 
11716
11985
  /**
@@ -11723,9 +11992,18 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
11723
11992
  @return {Promise} promise
11724
11993
  */
11725
11994
  deleteRecord: function (store, type, snapshot) {
11726
- var id = snapshot.id;
11995
+ if ((0, _emberDataPrivateFeatures.default)('ds-improved-ajax')) {
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;
11727
12004
 
11728
- return this.ajax(this.buildURL(type.modelName, id, snapshot, 'deleteRecord'), "DELETE");
12005
+ return this.ajax(this.buildURL(type.modelName, id, snapshot, 'deleteRecord'), "DELETE");
12006
+ }
11729
12007
  },
11730
12008
 
11731
12009
  _stripIDFromURL: function (store, snapshot) {
@@ -11839,13 +12117,30 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
11839
12117
  if (this.isSuccess(status, headers, payload)) {
11840
12118
  return payload;
11841
12119
  } else if (this.isInvalid(status, headers, payload)) {
11842
- return new _emberDataPrivateAdaptersErrors.InvalidError(payload.errors);
12120
+ return new _emberDataAdaptersErrors.InvalidError(payload.errors);
11843
12121
  }
11844
12122
 
11845
12123
  var errors = this.normalizeErrorResponse(status, headers, payload);
11846
12124
  var detailedMessage = this.generatedDetailedMessage(status, headers, payload, requestData);
11847
12125
 
11848
- return new _emberDataPrivateAdaptersErrors.AdapterError(errors, detailedMessage);
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
+ return new _emberDataAdaptersErrors.AdapterError(errors, detailedMessage);
11849
12144
  },
11850
12145
 
11851
12146
  /**
@@ -11917,14 +12212,22 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
11917
12212
  };
11918
12213
 
11919
12214
  hash.error = function (jqXHR, textStatus, errorThrown) {
12215
+ (0, _emberDataPrivateDebug.runInDebug)(function () {
12216
+ var message = 'The server returned an empty string for ' + type + ' ' + url + ', which cannot be parsed into a valid JSON. Return either null or {}.';
12217
+ var validJSONString = !(textStatus === "parsererror" && jqXHR.responseText === "");
12218
+ (0, _emberDataPrivateDebug.warn)(message, validJSONString, {
12219
+ id: 'ds.adapter.returned-empty-string-as-JSON'
12220
+ });
12221
+ });
12222
+
11920
12223
  var error = undefined;
11921
12224
 
11922
12225
  if (errorThrown instanceof Error) {
11923
12226
  error = errorThrown;
11924
12227
  } else if (textStatus === 'timeout') {
11925
- error = new _emberDataPrivateAdaptersErrors.TimeoutError();
12228
+ error = new _emberDataAdaptersErrors.TimeoutError();
11926
12229
  } else if (textStatus === 'abort') {
11927
- error = new _emberDataPrivateAdaptersErrors.AbortError();
12230
+ error = new _emberDataAdaptersErrors.AbortError();
11928
12231
  } else {
11929
12232
  error = adapter.handleResponse(jqXHR.status, (0, _emberDataPrivateUtilsParseResponseHeaders.default)(jqXHR.getAllResponseHeaders()), adapter.parseErrorResponse(jqXHR.responseText) || errorThrown, requestData);
11930
12233
  }
@@ -12043,7 +12346,7 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
12043
12346
  buildQuery: function (snapshot) {
12044
12347
  var query = {};
12045
12348
 
12046
- if (true) {
12349
+ if ((0, _emberDataPrivateFeatures.default)('ds-finder-include')) {
12047
12350
  if (snapshot) {
12048
12351
  var include = snapshot.include;
12049
12352
 
@@ -12057,6 +12360,266 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
12057
12360
  }
12058
12361
  });
12059
12362
 
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
+
12060
12623
  //From http://stackoverflow.com/questions/280634/endswith-in-javascript
12061
12624
  function endsWith(string, suffix) {
12062
12625
  if (typeof String.prototype.endsWith !== 'function') {
@@ -12065,11 +12628,13 @@ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'e
12065
12628
  return string.endsWith(suffix);
12066
12629
  }
12067
12630
  }
12631
+
12632
+ exports.default = RESTAdapter;
12068
12633
  });
12069
12634
  /**
12070
12635
  @module ember-data
12071
12636
  */
12072
- define("ember-data/attr", ["exports", "ember", "ember-data/-private/debug"], function (exports, _ember, _emberDataPrivateDebug) {
12637
+ define('ember-data/attr', ['exports', 'ember', 'ember-data/-private/debug'], function (exports, _ember, _emberDataPrivateDebug) {
12073
12638
  exports.default = attr;
12074
12639
 
12075
12640
  /**
@@ -12077,11 +12642,11 @@ define("ember-data/attr", ["exports", "ember", "ember-data/-private/debug"], fun
12077
12642
  */
12078
12643
 
12079
12644
  function getDefaultValue(record, options, key) {
12080
- if (typeof options.defaultValue === "function") {
12645
+ if (typeof options.defaultValue === 'function') {
12081
12646
  return options.defaultValue.apply(null, arguments);
12082
12647
  } else {
12083
12648
  var defaultValue = options.defaultValue;
12084
- (0, _emberDataPrivateDebug.deprecate)("Non primitive defaultValues are deprecated because they are shared between all instances. If you would like to use a complex object as a default value please provide a function that returns the complex object.", typeof defaultValue !== 'object' || defaultValue === null, {
12649
+ (0, _emberDataPrivateDebug.deprecate)('Non primitive defaultValues are deprecated because they are shared between all instances. If you would like to use a complex object as a default value please provide a function that returns the complex object.', typeof defaultValue !== 'object' || defaultValue === null, {
12085
12650
  id: 'ds.defaultValue.complex-object',
12086
12651
  until: '3.0.0'
12087
12652
  });
@@ -12231,7 +12796,7 @@ define("ember-data/attr", ["exports", "ember", "ember-data/-private/debug"], fun
12231
12796
  // *
12232
12797
  // */
12233
12798
  });
12234
- define("ember-data", ["exports", "ember", "ember-data/-private/debug", "ember-data/-private/core", "ember-data/-private/system/normalize-model-name", "ember-data/-private/system/model/internal-model", "ember-data/-private/system/promise-proxies", "ember-data/-private/system/store", "ember-data/-private/system/model", "ember-data/model", "ember-data/-private/system/snapshot", "ember-data/adapter", "ember-data/serializer", "ember-data/-private/system/debug", "ember-data/-private/adapters/errors", "ember-data/-private/system/record-arrays", "ember-data/-private/system/many-array", "ember-data/-private/system/record-array-manager", "ember-data/-private/adapters", "ember-data/-private/adapters/build-url-mixin", "ember-data/-private/serializers", "ember-inflector", "ember-data/serializers/embedded-records-mixin", "ember-data/-private/transforms", "ember-data/relationships", "ember-data/setup-container", "ember-data/-private/instance-initializers/initialize-store-service", "ember-data/-private/system/container-proxy", "ember-data/-private/system/relationships/state/relationship"], function (exports, _ember, _emberDataPrivateDebug, _emberDataPrivateCore, _emberDataPrivateSystemNormalizeModelName, _emberDataPrivateSystemModelInternalModel, _emberDataPrivateSystemPromiseProxies, _emberDataPrivateSystemStore, _emberDataPrivateSystemModel, _emberDataModel, _emberDataPrivateSystemSnapshot, _emberDataAdapter, _emberDataSerializer, _emberDataPrivateSystemDebug, _emberDataPrivateAdaptersErrors, _emberDataPrivateSystemRecordArrays, _emberDataPrivateSystemManyArray, _emberDataPrivateSystemRecordArrayManager, _emberDataPrivateAdapters, _emberDataPrivateAdaptersBuildUrlMixin, _emberDataPrivateSerializers, _emberInflector, _emberDataSerializersEmbeddedRecordsMixin, _emberDataPrivateTransforms, _emberDataRelationships, _emberDataSetupContainer, _emberDataPrivateInstanceInitializersInitializeStoreService, _emberDataPrivateSystemContainerProxy, _emberDataPrivateSystemRelationshipsStateRelationship) {
12799
+ define("ember-data", ["exports", "ember", "ember-data/-private/debug", "ember-data/-private/features", "ember-data/-private/core", "ember-data/-private/system/normalize-model-name", "ember-data/-private/system/model/internal-model", "ember-data/-private/system/promise-proxies", "ember-data/-private/system/store", "ember-data/-private/system/model", "ember-data/model", "ember-data/-private/system/snapshot", "ember-data/adapter", "ember-data/serializer", "ember-data/-private/system/debug", "ember-data/adapters/errors", "ember-data/-private/system/record-arrays", "ember-data/-private/system/many-array", "ember-data/-private/system/record-array-manager", "ember-data/-private/adapters", "ember-data/-private/adapters/build-url-mixin", "ember-data/-private/serializers", "ember-inflector", "ember-data/serializers/embedded-records-mixin", "ember-data/-private/transforms", "ember-data/relationships", "ember-data/setup-container", "ember-data/-private/instance-initializers/initialize-store-service", "ember-data/-private/system/container-proxy", "ember-data/-private/system/relationships/state/relationship"], function (exports, _ember, _emberDataPrivateDebug, _emberDataPrivateFeatures, _emberDataPrivateCore, _emberDataPrivateSystemNormalizeModelName, _emberDataPrivateSystemModelInternalModel, _emberDataPrivateSystemPromiseProxies, _emberDataPrivateSystemStore, _emberDataPrivateSystemModel, _emberDataModel, _emberDataPrivateSystemSnapshot, _emberDataAdapter, _emberDataSerializer, _emberDataPrivateSystemDebug, _emberDataAdaptersErrors, _emberDataPrivateSystemRecordArrays, _emberDataPrivateSystemManyArray, _emberDataPrivateSystemRecordArrayManager, _emberDataPrivateAdapters, _emberDataPrivateAdaptersBuildUrlMixin, _emberDataPrivateSerializers, _emberInflector, _emberDataSerializersEmbeddedRecordsMixin, _emberDataPrivateTransforms, _emberDataRelationships, _emberDataSetupContainer, _emberDataPrivateInstanceInitializersInitializeStoreService, _emberDataPrivateSystemContainerProxy, _emberDataPrivateSystemRelationshipsStateRelationship) {
12235
12800
  /**
12236
12801
  Ember Data
12237
12802
  @module ember-data
@@ -12242,12 +12807,6 @@ define("ember-data", ["exports", "ember", "ember-data/-private/debug", "ember-da
12242
12807
  throw new _ember.default.Error("Ember Data requires at least Ember 1.13.0, but you have " + _ember.default.VERSION + ". Please upgrade your version of Ember, then upgrade Ember Data.");
12243
12808
  }
12244
12809
 
12245
- if (_ember.default.VERSION.match(/^1\.13\./)) {
12246
- (0, _emberDataPrivateDebug.warn)("Use of Ember Data 2+ with Ember 1.13 is unsupported. Please upgrade your version of Ember to 2.0 or higher.", false, {
12247
- id: 'ds.version.ember-1-13'
12248
- });
12249
- }
12250
-
12251
12810
  _emberDataPrivateCore.default.Store = _emberDataPrivateSystemStore.Store;
12252
12811
  _emberDataPrivateCore.default.PromiseArray = _emberDataPrivateSystemPromiseProxies.PromiseArray;
12253
12812
  _emberDataPrivateCore.default.PromiseObject = _emberDataPrivateSystemPromiseProxies.PromiseObject;
@@ -12264,13 +12823,21 @@ define("ember-data", ["exports", "ember", "ember-data/-private/debug", "ember-da
12264
12823
 
12265
12824
  _emberDataPrivateCore.default.Adapter = _emberDataAdapter.default;
12266
12825
 
12267
- _emberDataPrivateCore.default.AdapterError = _emberDataPrivateAdaptersErrors.AdapterError;
12268
- _emberDataPrivateCore.default.InvalidError = _emberDataPrivateAdaptersErrors.InvalidError;
12269
- _emberDataPrivateCore.default.TimeoutError = _emberDataPrivateAdaptersErrors.TimeoutError;
12270
- _emberDataPrivateCore.default.AbortError = _emberDataPrivateAdaptersErrors.AbortError;
12826
+ _emberDataPrivateCore.default.AdapterError = _emberDataAdaptersErrors.AdapterError;
12827
+ _emberDataPrivateCore.default.InvalidError = _emberDataAdaptersErrors.InvalidError;
12828
+ _emberDataPrivateCore.default.TimeoutError = _emberDataAdaptersErrors.TimeoutError;
12829
+ _emberDataPrivateCore.default.AbortError = _emberDataAdaptersErrors.AbortError;
12830
+
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
+ }
12271
12838
 
12272
- _emberDataPrivateCore.default.errorsHashToArray = _emberDataPrivateAdaptersErrors.errorsHashToArray;
12273
- _emberDataPrivateCore.default.errorsArrayToHash = _emberDataPrivateAdaptersErrors.errorsArrayToHash;
12839
+ _emberDataPrivateCore.default.errorsHashToArray = _emberDataAdaptersErrors.errorsHashToArray;
12840
+ _emberDataPrivateCore.default.errorsArrayToHash = _emberDataAdaptersErrors.errorsArrayToHash;
12274
12841
 
12275
12842
  _emberDataPrivateCore.default.Serializer = _emberDataSerializer.default;
12276
12843
 
@@ -12411,7 +12978,7 @@ define('ember-data/serializer', ['exports', 'ember'], function (exports, _ember)
12411
12978
  /**
12412
12979
  @module ember-data
12413
12980
  */
12414
- define('ember-data/serializers/embedded-records-mixin', ['exports', 'ember', 'ember-data/-private/debug'], function (exports, _ember, _emberDataPrivateDebug) {
12981
+ define('ember-data/serializers/embedded-records-mixin', ['exports', 'ember', 'ember-data/-private/debug', 'ember-data/-private/features'], function (exports, _ember, _emberDataPrivateDebug, _emberDataPrivateFeatures) {
12415
12982
  function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
12416
12983
 
12417
12984
  var get = _ember.default.get;
@@ -12636,7 +13203,7 @@ define('ember-data/serializers/embedded-records-mixin', ['exports', 'ember', 'em
12636
13203
  },
12637
13204
 
12638
13205
  /**
12639
- Serialize `hasMany` relationship when it is configured as embedded objects.
13206
+ Serializes `hasMany` relationships when it is configured as embedded objects.
12640
13207
  This example of a post model has many comments:
12641
13208
  ```js
12642
13209
  Post = DS.Model.extend({
@@ -12677,7 +13244,7 @@ define('ember-data/serializers/embedded-records-mixin', ['exports', 'ember', 'em
12677
13244
  }
12678
13245
  ```
12679
13246
  The attrs options object can use more specific instruction for extracting and
12680
- serializing. When serializing, an option to embed `ids` or `records` can be set.
13247
+ serializing. When serializing, an option to embed `ids`, `ids-and-types` or `records` can be set.
12681
13248
  When extracting the only option is `records`.
12682
13249
  So `{ embedded: 'always' }` is shorthand for:
12683
13250
  `{ serialize: 'records', deserialize: 'records' }`
@@ -12700,6 +13267,47 @@ define('ember-data/serializers/embedded-records-mixin', ['exports', 'ember', 'em
12700
13267
  }
12701
13268
  }
12702
13269
  ```
13270
+ To embed the relationship as a collection of objects with `id` and `type` keys, set
13271
+ `ids-and-types` for the related object.
13272
+ This is particularly useful for polymorphic relationships where records don't share
13273
+ the same table and the `id` is not enough information.
13274
+ By example having a user that has many pets:
13275
+ ```js
13276
+ User = DS.Model.extend({
13277
+ name: DS.attr('string'),
13278
+ pets: DS.hasMany('pet', { polymorphic: true })
13279
+ });
13280
+ Pet = DS.Model.extend({
13281
+ name: DS.attr('string'),
13282
+ });
13283
+ Cat = Pet.extend({
13284
+ // ...
13285
+ });
13286
+ Parrot = Pet.extend({
13287
+ // ...
13288
+ });
13289
+ ```
13290
+ ```app/serializers/user.js
13291
+ import DS from 'ember-data;
13292
+ export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
13293
+ attrs: {
13294
+ pets: { serialize: 'ids-and-types', deserialize: 'records' }
13295
+ }
13296
+ });
13297
+ ```
13298
+ ```js
13299
+ {
13300
+ "user": {
13301
+ "id": "1"
13302
+ "name": "Bertin Osborne",
13303
+ "pets": [
13304
+ { "id": "1", "type": "Cat" },
13305
+ { "id": "1", "type": "Parrot"}
13306
+ ]
13307
+ }
13308
+ }
13309
+ ```
13310
+ Note that the `ids-and-types` strategy is still behind the `ds-serialize-ids-and-types` feature flag.
12703
13311
  @method serializeHasMany
12704
13312
  @param {DS.Snapshot} snapshot
12705
13313
  @param {Object} json
@@ -12711,16 +13319,41 @@ define('ember-data/serializers/embedded-records-mixin', ['exports', 'ember', 'em
12711
13319
  this._super(snapshot, json, relationship);
12712
13320
  return;
12713
13321
  }
12714
- var includeIds = this.hasSerializeIdsOption(attr);
12715
- var includeRecords = this.hasSerializeRecordsOption(attr);
12716
- if (includeIds) {
13322
+
13323
+ if (this.hasSerializeIdsOption(attr)) {
12717
13324
  var serializedKey = this.keyForRelationship(attr, relationship.kind, 'serialize');
12718
13325
  json[serializedKey] = snapshot.hasMany(attr, { ids: true });
12719
- } else if (includeRecords) {
13326
+ } else if (this.hasSerializeRecordsOption(attr)) {
12720
13327
  this._serializeEmbeddedHasMany(snapshot, json, relationship);
13328
+ } else {
13329
+ if ((0, _emberDataPrivateFeatures.default)("ds-serialize-ids-and-types")) {
13330
+ if (this.hasSerializeIdsAndTypesOption(attr)) {
13331
+ this._serializeHasManyAsIdsAndTypes(snapshot, json, relationship);
13332
+ }
13333
+ }
12721
13334
  }
12722
13335
  },
12723
13336
 
13337
+ /**
13338
+ Serializes a hasMany relationship as an array of objects containing only `id` and `type`
13339
+ keys.
13340
+ This has its use case on polymorphic hasMany relationships where the server is not storing
13341
+ all records in the same table using STI, and therefore the `id` is not enough information
13342
+ TODO: Make the default in Ember-data 3.0??
13343
+ */
13344
+ _serializeHasManyAsIdsAndTypes: function (snapshot, json, relationship) {
13345
+ var serializedKey = this.keyForAttribute(relationship.key, 'serialize');
13346
+ var hasMany = snapshot.hasMany(relationship.key);
13347
+
13348
+ json[serializedKey] = _ember.default.A(hasMany).map(function (recordSnapshot) {
13349
+ //
13350
+ // I'm sure I'm being utterly naive here. Propably id is a configurate property and
13351
+ // type too, and the modelName has to be normalized somehow.
13352
+ //
13353
+ return { id: recordSnapshot.id, type: recordSnapshot.modelName };
13354
+ });
13355
+ },
13356
+
12724
13357
  _serializeEmbeddedHasMany: function (snapshot, json, relationship) {
12725
13358
  var serializedKey = this._getMappedKey(relationship.key, snapshot.type);
12726
13359
  if (serializedKey === relationship.key && this.keyForRelationship) {
@@ -12798,6 +13431,12 @@ define('ember-data/serializers/embedded-records-mixin', ['exports', 'ember', 'em
12798
13431
  return option && (option.serialize === 'ids' || option.serialize === 'id');
12799
13432
  },
12800
13433
 
13434
+ // checks config for attrs option to serialize records as objects containing id and types
13435
+ hasSerializeIdsAndTypesOption: function (attr) {
13436
+ var option = this.attrsOption(attr);
13437
+ return option && (option.serialize === 'ids-and-types' || option.serialize === 'id-and-type');
13438
+ },
13439
+
12801
13440
  // checks config for attrs option to serialize records
12802
13441
  noSerializeOptionSpecified: function (attr) {
12803
13442
  var option = this.attrsOption(attr);
@@ -12916,7 +13555,8 @@ define('ember-data/serializers/embedded-records-mixin', ['exports', 'ember', 'em
12916
13555
  var serializer = store.serializerFor(modelName);
12917
13556
 
12918
13557
  return serializer.normalize(modelClass, relationshipHash, null);
12919
- }
13558
+ },
13559
+ isEmbeddedRecordsMixin: true
12920
13560
  });
12921
13561
  });
12922
13562
  define('ember-data/serializers/json-api', ['exports', 'ember', 'ember-data/-private/debug', 'ember-data/serializers/json', 'ember-data/-private/system/normalize-model-name', 'ember-inflector', 'ember-data/-private/features'], function (exports, _ember, _emberDataPrivateDebug, _emberDataSerializersJson, _emberDataPrivateSystemNormalizeModelName, _emberInflector, _emberDataPrivateFeatures) {
@@ -13095,7 +13735,7 @@ define('ember-data/serializers/json-api', ['exports', 'ember', 'ember-data/-priv
13095
13735
  */
13096
13736
  pushPayload: function (store, payload) {
13097
13737
  var normalizedPayload = this._normalizeDocumentHelper(payload);
13098
- if (false) {
13738
+ if ((0, _emberDataPrivateFeatures.default)('ds-pushpayload-return')) {
13099
13739
  return store.push(normalizedPayload);
13100
13740
  } else {
13101
13741
  store.push(normalizedPayload);
@@ -13410,6 +14050,11 @@ define('ember-data/serializers/json-api', ['exports', 'ember', 'ember-data/-priv
13410
14050
 
13411
14051
  (0, _emberDataPrivateDebug.runInDebug)(function () {
13412
14052
  JSONAPISerializer.reopen({
14053
+ willMergeMixin: function (props) {
14054
+ (0, _emberDataPrivateDebug.warn)('The JSONAPISerializer does not work with the EmbeddedRecordsMixin because the JSON API spec does not describe how to format embedded resources.', !props.isEmbeddedRecordsMixin, {
14055
+ id: 'ds.serializer.embedded-records-mixin-not-supported'
14056
+ });
14057
+ },
13413
14058
  warnMessageForUndefinedType: function () {
13414
14059
  return 'Encountered a resource object with an undefined type (resolved resource using ' + this.constructor.toString() + ')';
13415
14060
  },
@@ -13424,7 +14069,7 @@ define('ember-data/serializers/json-api', ['exports', 'ember', 'ember-data/-priv
13424
14069
  /**
13425
14070
  @module ember-data
13426
14071
  */
13427
- define('ember-data/serializers/json', ['exports', 'ember', 'ember-data/-private/debug', 'ember-data/serializer', 'ember-data/-private/system/coerce-id', 'ember-data/-private/system/normalize-model-name', 'ember-data/-private/utils', 'ember-data/-private/adapters/errors', 'ember-data/-private/features'], function (exports, _ember, _emberDataPrivateDebug, _emberDataSerializer, _emberDataPrivateSystemCoerceId, _emberDataPrivateSystemNormalizeModelName, _emberDataPrivateUtils, _emberDataPrivateAdaptersErrors, _emberDataPrivateFeatures) {
14072
+ define('ember-data/serializers/json', ['exports', 'ember', 'ember-data/-private/debug', 'ember-data/serializer', 'ember-data/-private/system/coerce-id', 'ember-data/-private/system/normalize-model-name', 'ember-data/-private/utils', 'ember-data/adapters/errors', 'ember-data/-private/features'], function (exports, _ember, _emberDataPrivateDebug, _emberDataSerializer, _emberDataPrivateSystemCoerceId, _emberDataPrivateSystemNormalizeModelName, _emberDataPrivateUtils, _emberDataAdaptersErrors, _emberDataPrivateFeatures) {
13428
14073
  function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
13429
14074
 
13430
14075
  var get = _ember.default.get;
@@ -13586,17 +14231,17 @@ define('ember-data/serializers/json', ['exports', 'ember', 'ember-data/-private/
13586
14231
  var _this = this;
13587
14232
 
13588
14233
  var attributes = undefined;
13589
- if (true) {
14234
+ if ((0, _emberDataPrivateFeatures.default)('ds-transform-pass-options')) {
13590
14235
  attributes = get(typeClass, 'attributes');
13591
14236
  }
13592
14237
 
13593
14238
  typeClass.eachTransformedAttribute(function (key, typeClass) {
13594
- if (!data.hasOwnProperty(key)) {
14239
+ if (!(key in data)) {
13595
14240
  return;
13596
14241
  }
13597
14242
 
13598
14243
  var transform = _this.transformFor(typeClass);
13599
- if (true) {
14244
+ if ((0, _emberDataPrivateFeatures.default)('ds-transform-pass-options')) {
13600
14245
  var transformMeta = attributes.get(key);
13601
14246
  data[key] = transform.deserialize(data[key], transformMeta.options);
13602
14247
  } else {
@@ -14445,7 +15090,7 @@ define('ember-data/serializers/json', ['exports', 'ember', 'ember-data/-private/
14445
15090
  var value = snapshot.attr(key);
14446
15091
  if (type) {
14447
15092
  var transform = this.transformFor(type);
14448
- if (true) {
15093
+ if ((0, _emberDataPrivateFeatures.default)('ds-transform-pass-options')) {
14449
15094
  value = transform.serialize(value, attribute.options);
14450
15095
  } else {
14451
15096
  value = transform.serialize(value);
@@ -14686,7 +15331,7 @@ define('ember-data/serializers/json', ['exports', 'ember', 'ember-data/-private/
14686
15331
  var _this7 = this;
14687
15332
 
14688
15333
  if (payload && typeof payload === 'object' && payload.errors) {
14689
- payload = (0, _emberDataPrivateAdaptersErrors.errorsArrayToHash)(payload.errors);
15334
+ payload = (0, _emberDataAdaptersErrors.errorsArrayToHash)(payload.errors);
14690
15335
 
14691
15336
  this.normalizeUsingDeclaredMapping(typeClass, payload);
14692
15337
 
@@ -14791,8 +15436,7 @@ define("ember-data/serializers/rest", ["exports", "ember", "ember-data/-private/
14791
15436
 
14792
15437
  /**
14793
15438
  Normally, applications will use the `RESTSerializer` by implementing
14794
- the `normalize` method and individual normalizations under
14795
- `normalizeHash`.
15439
+ the `normalize` method.
14796
15440
 
14797
15441
  This allows you to do whatever kind of munging you need, and is
14798
15442
  especially useful if your server is inconsistent and you need to
@@ -14805,7 +15449,7 @@ define("ember-data/serializers/rest", ["exports", "ember", "ember-data/-private/
14805
15449
  There are also a number of hooks that you might find useful to define
14806
15450
  across-the-board rules for your payload. These rules will be useful
14807
15451
  if your server is consistent, or if you're building an adapter for
14808
- an infrastructure service, like Parse, and want to encode service
15452
+ an infrastructure service, like Firebase, and want to encode service
14809
15453
  conventions.
14810
15454
 
14811
15455
  For example, if all of your keys are underscored and all-caps, but
@@ -14889,25 +15533,25 @@ define("ember-data/serializers/rest", ["exports", "ember", "ember-data/-private/
14889
15533
  * With `App.Comment`, `"comments"` and `{ id: 1, body: "FIRST" }`
14890
15534
  * With `App.Comment`, `"comments"` and `{ id: 2, body: "Rails is unagi" }`
14891
15535
  You can use this method, for example, to normalize underscored keys to camelized
14892
- or other general-purpose normalizations.
14893
- If you want to do normalizations specific to some part of the payload, you
14894
- can specify those under `normalizeHash`.
15536
+ or other general-purpose normalizations. You will only need to implement
15537
+ `normalize` and manipulate the payload as desired.
14895
15538
  For example, if the `IDs` under `"comments"` are provided as `_id` instead of
14896
15539
  `id`, you can specify how to normalize just the comments:
14897
15540
  ```app/serializers/post.js
14898
15541
  import DS from 'ember-data';
14899
15542
  export default DS.RESTSerializer.extend({
14900
- normalizeHash: {
14901
- comments: function(hash) {
15543
+ normalize(model, hash, prop) {
15544
+ if (prop === 'comments') {
14902
15545
  hash.id = hash._id;
14903
- delete hash._id;
14904
- return hash;
15546
+ delete hash._id;
14905
15547
  }
15548
+ return this._super(...arguments);
14906
15549
  }
14907
15550
  });
14908
15551
  ```
14909
- The key under `normalizeHash` is just the original key that was in the original
14910
- payload.
15552
+ On each call to the `normalize` method, the third parameter (`prop`) is always
15553
+ one of the keys that were in the original payload or in the result of another
15554
+ normalization as `normalizeResponse`.
14911
15555
  @method normalize
14912
15556
  @param {DS.Model} modelClass
14913
15557
  @param {Object} resourceHash
@@ -14916,9 +15560,13 @@ define("ember-data/serializers/rest", ["exports", "ember", "ember-data/-private/
14916
15560
  */
14917
15561
  normalize: function (modelClass, resourceHash, prop) {
14918
15562
  if (this.normalizeHash && this.normalizeHash[prop]) {
15563
+ (0, _emberDataPrivateDebug.deprecate)('`RESTSerializer.normalizeHash` has been deprecated. Please use `serializer.normalize` to modify the payload of single resources.', false, {
15564
+ id: 'ds.serializer.normalize-hash-deprecated',
15565
+ until: '3.0.0'
15566
+ });
14919
15567
  this.normalizeHash[prop](resourceHash);
14920
15568
  }
14921
- return this._super(modelClass, resourceHash, prop);
15569
+ return this._super(modelClass, resourceHash);
14922
15570
  },
14923
15571
 
14924
15572
  /**
@@ -15180,7 +15828,7 @@ define("ember-data/serializers/rest", ["exports", "ember", "ember-data/-private/
15180
15828
  });
15181
15829
  }
15182
15830
 
15183
- if (false) {
15831
+ if ((0, _emberDataPrivateFeatures.default)('ds-pushpayload-return')) {
15184
15832
  return store.push(documentHash);
15185
15833
  } else {
15186
15834
  store.push(documentHash);
@@ -15607,7 +16255,7 @@ define('ember-data/transform', ['exports', 'ember'], function (exports, _ember)
15607
16255
  });
15608
16256
  });
15609
16257
  define("ember-data/version", ["exports"], function (exports) {
15610
- exports.default = "2.5.5";
16258
+ exports.default = "2.6.0-beta.1";
15611
16259
  });
15612
16260
  define("ember-inflector", ["exports", "ember", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (exports, _ember, _emberInflectorLibSystem, _emberInflectorLibExtString) {
15613
16261
 
@@ -16002,7 +16650,7 @@ define('ember-inflector/lib/system/inflector', ['exports', 'ember'], function (e
16002
16650
  return word;
16003
16651
  }
16004
16652
 
16005
- for (rule in irregular) {
16653
+ for (rule in this.rules.irregular) {
16006
16654
  if (lowercase.match(rule + "$")) {
16007
16655
  substitution = irregular[rule];
16008
16656
 
@@ -16011,7 +16659,7 @@ define('ember-inflector/lib/system/inflector', ['exports', 'ember'], function (e
16011
16659
  rule = capitalize(rule);
16012
16660
  }
16013
16661
 
16014
- return word.replace(new RegExp(rule, 'i'), substitution);
16662
+ return word.replace(rule, substitution);
16015
16663
  }
16016
16664
  }
16017
16665