ember-data-source 3.1.0.beta.1 → 3.1.0.beta.2

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: 442c4caf0795074faa3d43e249d038608d8e8ea8
4
- data.tar.gz: 7d1278741187c5cb9b30825a8725704a3d5cb2d5
3
+ metadata.gz: 8e5bec730b62b6bd53d1ac99ef3fcef13d505c29
4
+ data.tar.gz: 74f65ef983a034e9958badf3fccbf70dd652924f
5
5
  SHA512:
6
- metadata.gz: 0d0820aaa6d2bedc1a98d2543ed176bb6122252efb9acc454158e13c522a69a769476fb964e1e35bc4d9be9fbda86ef73885c9348d3f01da996f640dd7310e60
7
- data.tar.gz: 447a16f2a0c9aa740f9c1814470751a432d0b738228b9fed637f97f3b7f52823ad59b1f9a90ec7ff18aba5b624089e80f3e4ed97a9d40a0e2f3553db75f10fb9
6
+ metadata.gz: 6979d1e6d59e1b930fdf94cbcfabfc6d97c9759d59738369b9422f4b9f4bbe36df65fc94fafc79a2d51fd3ce197a1d778eb054fb2d80762df9aa87d56cba0d9e
7
+ data.tar.gz: fccfea36217ebcae33b3dabb9a872901567f2bcb7f79eaee79bc0e25fccc87e7d837dde022e29a38b5c8d8b01b1223a101b920aa88e80d93de9f3509e628e959
@@ -6,7 +6,7 @@
6
6
  * @copyright Copyright 2011-2017 Tilde Inc. and contributors.
7
7
  * Portions Copyright 2011 LivingSocial Inc.
8
8
  * @license Licensed under MIT license (see license.js)
9
- * @version 3.1.0-beta.1
9
+ * @version 3.1.0-beta.2
10
10
  */
11
11
 
12
12
  var loader, define, requireModule, require, requirejs;
@@ -1307,7 +1307,7 @@ define('ember-data/-private/features', ['exports'], function (exports) {
1307
1307
  return (_Ember$FEATURES = Ember.FEATURES).isEnabled.apply(_Ember$FEATURES, arguments);
1308
1308
  }
1309
1309
  });
1310
- define('ember-data/-private', ['exports', 'ember-data/-private/system/model/model', 'ember-data/-private/system/model/errors', 'ember-data/-private/system/store', 'ember-data/-private/core', 'ember-data/-private/system/relationships/belongs-to', 'ember-data/-private/system/relationships/has-many', 'ember-data/-private/adapters/build-url-mixin', 'ember-data/-private/system/snapshot', 'ember-data/-private/adapters/errors', 'ember-data/-private/system/normalize-model-name', 'ember-data/-private/utils', 'ember-data/-private/system/coerce-id', 'ember-data/-private/utils/parse-response-headers', 'ember-data/-private/features', 'ember-data/-private/system/model/states', 'ember-data/-private/system/model/internal-model', 'ember-data/-private/system/promise-proxies', 'ember-data/-private/system/record-arrays', 'ember-data/-private/system/many-array', 'ember-data/-private/system/record-array-manager', 'ember-data/-private/system/relationships/state/relationship', 'ember-data/-private/system/debug/debug-adapter', 'ember-data/-private/system/diff-array', 'ember-data/-private/system/relationships/relationship-payloads-manager', 'ember-data/-private/system/relationships/relationship-payloads', 'ember-data/-private/system/snapshot-record-array'], function (exports, _model, _errors, _store, _core, _belongsTo, _hasMany, _buildUrlMixin, _snapshot, _errors2, _normalizeModelName, _utils, _coerceId, _parseResponseHeaders, _features, _states, _internalModel, _promiseProxies, _recordArrays, _manyArray, _recordArrayManager, _relationship, _debugAdapter, _diffArray, _relationshipPayloadsManager, _relationshipPayloads, _snapshotRecordArray) {
1310
+ define('ember-data/-private', ['exports', 'ember-data/-private/system/model/model', 'ember-data/-private/system/model/errors', 'ember-data/-private/system/store', 'ember-data/-private/core', 'ember-data/-private/system/relationships/belongs-to', 'ember-data/-private/system/relationships/has-many', 'ember-data/-private/adapters/build-url-mixin', 'ember-data/-private/system/snapshot', 'ember-data/-private/adapters/errors', 'ember-data/-private/system/normalize-model-name', 'ember-data/-private/utils', 'ember-data/-private/system/coerce-id', 'ember-data/-private/utils/parse-response-headers', 'ember-data/-private/features', 'ember-data/-private/system/model/states', 'ember-data/-private/system/model/internal-model', 'ember-data/-private/system/promise-proxies', 'ember-data/-private/system/record-arrays', 'ember-data/-private/system/many-array', 'ember-data/-private/system/record-array-manager', 'ember-data/-private/system/relationships/state/relationship', 'ember-data/-private/system/map', 'ember-data/-private/system/map-with-default', 'ember-data/-private/system/debug/debug-adapter', 'ember-data/-private/system/diff-array', 'ember-data/-private/system/relationships/relationship-payloads-manager', 'ember-data/-private/system/relationships/relationship-payloads', 'ember-data/-private/system/snapshot-record-array'], function (exports, _model, _errors, _store, _core, _belongsTo, _hasMany, _buildUrlMixin, _snapshot, _errors2, _normalizeModelName, _utils, _coerceId, _parseResponseHeaders, _features, _states, _internalModel, _promiseProxies, _recordArrays, _manyArray, _recordArrayManager, _relationship, _map, _mapWithDefault, _debugAdapter, _diffArray, _relationshipPayloadsManager, _relationshipPayloads, _snapshotRecordArray) {
1311
1311
  'use strict';
1312
1312
 
1313
1313
  exports.__esModule = true;
@@ -1527,6 +1527,18 @@ define('ember-data/-private', ['exports', 'ember-data/-private/system/model/mode
1527
1527
  return _relationship.default;
1528
1528
  }
1529
1529
  });
1530
+ Object.defineProperty(exports, 'Map', {
1531
+ enumerable: true,
1532
+ get: function () {
1533
+ return _map.default;
1534
+ }
1535
+ });
1536
+ Object.defineProperty(exports, 'MapWithDefault', {
1537
+ enumerable: true,
1538
+ get: function () {
1539
+ return _mapWithDefault.default;
1540
+ }
1541
+ });
1530
1542
  Object.defineProperty(exports, 'DebugAdapter', {
1531
1543
  enumerable: true,
1532
1544
  get: function () {
@@ -2230,7 +2242,194 @@ define('ember-data/-private/system/many-array', ['exports', 'ember-data/-private
2230
2242
  }
2231
2243
  });
2232
2244
  });
2233
- define('ember-data/-private/system/model/errors', ['exports'], function (exports) {
2245
+ define('ember-data/-private/system/map-with-default', ['exports', 'ember-data/-private/system/map'], function (exports, _map) {
2246
+ 'use strict';
2247
+
2248
+ exports.__esModule = true;
2249
+
2250
+ function _classCallCheck(instance, Constructor) {
2251
+ if (!(instance instanceof Constructor)) {
2252
+ throw new TypeError("Cannot call a class as a function");
2253
+ }
2254
+ }
2255
+
2256
+ function _possibleConstructorReturn(self, call) {
2257
+ if (!self) {
2258
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2259
+ }
2260
+
2261
+ return call && (typeof call === "object" || typeof call === "function") ? call : self;
2262
+ }
2263
+
2264
+ function _inherits(subClass, superClass) {
2265
+ if (typeof superClass !== "function" && superClass !== null) {
2266
+ throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
2267
+ }
2268
+
2269
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
2270
+ constructor: {
2271
+ value: subClass,
2272
+ enumerable: false,
2273
+ writable: true,
2274
+ configurable: true
2275
+ }
2276
+ });
2277
+ if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
2278
+ }
2279
+
2280
+ var MapWithDefault = function (_Map) {
2281
+ _inherits(MapWithDefault, _Map);
2282
+
2283
+ function MapWithDefault(options) {
2284
+ _classCallCheck(this, MapWithDefault);
2285
+
2286
+ var _this = _possibleConstructorReturn(this, _Map.call(this));
2287
+
2288
+ _this.defaultValue = options.defaultValue;
2289
+ return _this;
2290
+ }
2291
+
2292
+ MapWithDefault.prototype.get = function get(key) {
2293
+ var hasValue = this.has(key);
2294
+
2295
+ if (hasValue) {
2296
+ return _Map.prototype.get.call(this, key);
2297
+ } else {
2298
+ var defaultValue = this.defaultValue(key);
2299
+ this.set(key, defaultValue);
2300
+ return defaultValue;
2301
+ }
2302
+ };
2303
+
2304
+ return MapWithDefault;
2305
+ }(_map.default);
2306
+
2307
+ exports.default = MapWithDefault;
2308
+ });
2309
+ define('ember-data/-private/system/map', ['exports'], function (exports) {
2310
+ 'use strict';
2311
+
2312
+ exports.__esModule = true;
2313
+
2314
+ function _classCallCheck(instance, Constructor) {
2315
+ if (!(instance instanceof Constructor)) {
2316
+ throw new TypeError("Cannot call a class as a function");
2317
+ }
2318
+ }
2319
+
2320
+ var _createClass = function () {
2321
+ function defineProperties(target, props) {
2322
+ for (var i = 0; i < props.length; i++) {
2323
+ var descriptor = props[i];
2324
+ descriptor.enumerable = descriptor.enumerable || false;
2325
+ descriptor.configurable = true;
2326
+ if ("value" in descriptor) descriptor.writable = true;
2327
+ Object.defineProperty(target, descriptor.key, descriptor);
2328
+ }
2329
+ }
2330
+
2331
+ return function (Constructor, protoProps, staticProps) {
2332
+ if (protoProps) defineProperties(Constructor.prototype, protoProps);
2333
+ if (staticProps) defineProperties(Constructor, staticProps);
2334
+ return Constructor;
2335
+ };
2336
+ }();
2337
+
2338
+ var MapWithDeprecations = function () {
2339
+ function MapWithDeprecations(options) {
2340
+ _classCallCheck(this, MapWithDeprecations);
2341
+
2342
+ this._map = new Map();
2343
+ }
2344
+
2345
+ MapWithDeprecations.prototype.copy = function copy() {
2346
+ (false && !(false) && Ember.deprecate('Calling `.copy()` on a map generated by ember-data is deprecated, please migrate to using native Map functionality only.', false, { id: 'ember-data.map.copy', until: '3.5.0' }));
2347
+
2348
+
2349
+ // can't just pass `this._map` here because IE11 doesn't accept
2350
+ // constructor args with its `Map`
2351
+ var newMap = new MapWithDeprecations();
2352
+ this._map.forEach(function (value, key) {
2353
+ newMap.set(key, value);
2354
+ });
2355
+
2356
+ return newMap;
2357
+ };
2358
+
2359
+ MapWithDeprecations.prototype.isEmpty = function isEmpty() {
2360
+ (false && !(false) && Ember.deprecate('Calling `.isEmpty()` on a map generated by ember-data is deprecated, please migrate to using native Map functionality only.', false, { id: 'ember-data.map.isEmpty', until: '3.5.0' }));
2361
+
2362
+
2363
+ return this.size === 0;
2364
+ };
2365
+
2366
+ MapWithDeprecations.prototype.clear = function clear() {
2367
+ var _map;
2368
+
2369
+ return (_map = this._map).clear.apply(_map, arguments);
2370
+ };
2371
+
2372
+ MapWithDeprecations.prototype.delete = function _delete() {
2373
+ var _map2;
2374
+
2375
+ return (_map2 = this._map).delete.apply(_map2, arguments);
2376
+ };
2377
+
2378
+ MapWithDeprecations.prototype.entries = function entries() {
2379
+ var _map3;
2380
+
2381
+ return (_map3 = this._map).entries.apply(_map3, arguments);
2382
+ };
2383
+
2384
+ MapWithDeprecations.prototype.forEach = function forEach() {
2385
+ var _map4;
2386
+
2387
+ return (_map4 = this._map).forEach.apply(_map4, arguments);
2388
+ };
2389
+
2390
+ MapWithDeprecations.prototype.get = function get() {
2391
+ var _map5;
2392
+
2393
+ return (_map5 = this._map).get.apply(_map5, arguments);
2394
+ };
2395
+
2396
+ MapWithDeprecations.prototype.has = function has() {
2397
+ var _map6;
2398
+
2399
+ return (_map6 = this._map).has.apply(_map6, arguments);
2400
+ };
2401
+
2402
+ MapWithDeprecations.prototype.keys = function keys() {
2403
+ var _map7;
2404
+
2405
+ return (_map7 = this._map).keys.apply(_map7, arguments);
2406
+ };
2407
+
2408
+ MapWithDeprecations.prototype.set = function set() {
2409
+ var _map8;
2410
+
2411
+ return (_map8 = this._map).set.apply(_map8, arguments);
2412
+ };
2413
+
2414
+ MapWithDeprecations.prototype.values = function values() {
2415
+ var _map9;
2416
+
2417
+ return (_map9 = this._map).values.apply(_map9, arguments);
2418
+ };
2419
+
2420
+ _createClass(MapWithDeprecations, [{
2421
+ key: 'size',
2422
+ get: function () {
2423
+ return this._map.size;
2424
+ }
2425
+ }]);
2426
+
2427
+ return MapWithDeprecations;
2428
+ }();
2429
+
2430
+ exports.default = MapWithDeprecations;
2431
+ });
2432
+ define('ember-data/-private/system/model/errors', ['exports', 'ember-data/-private/system/map-with-default'], function (exports, _mapWithDefault) {
2234
2433
  'use strict';
2235
2434
 
2236
2435
  exports.__esModule = true;
@@ -2241,10 +2440,8 @@ define('ember-data/-private/system/model/errors', ['exports'], function (exports
2241
2440
  var set = Ember.set;
2242
2441
  var get = Ember.get;
2243
2442
  var computed = Ember.computed;
2244
- var isEmpty = Ember.isEmpty;
2245
2443
  var makeArray = Ember.makeArray;
2246
2444
  var A = Ember.A;
2247
- var MapWithDefault = Ember.MapWithDefault;
2248
2445
  exports.default = ArrayProxy.extend(Evented, {
2249
2446
  /**
2250
2447
  Register with target handler
@@ -2278,11 +2475,11 @@ define('ember-data/-private/system/model/errors', ['exports'], function (exports
2278
2475
 
2279
2476
  /**
2280
2477
  @property errorsByAttributeName
2281
- @type {Ember.MapWithDefault}
2478
+ @type {MapWithDefault}
2282
2479
  @private
2283
2480
  */
2284
2481
  errorsByAttributeName: computed(function () {
2285
- return MapWithDefault.create({
2482
+ return new _mapWithDefault.default({
2286
2483
  defaultValue: function () {
2287
2484
  return A();
2288
2485
  }
@@ -2340,7 +2537,7 @@ define('ember-data/-private/system/model/errors', ['exports'], function (exports
2340
2537
  */
2341
2538
  unknownProperty: function (attribute) {
2342
2539
  var errors = this.errorsFor(attribute);
2343
- if (isEmpty(errors)) {
2540
+ if (errors.length === 0) {
2344
2541
  return undefined;
2345
2542
  }
2346
2543
  return errors;
@@ -2577,7 +2774,7 @@ define('ember-data/-private/system/model/errors', ['exports'], function (exports
2577
2774
  @return {Boolean} true if there some errors on given attribute
2578
2775
  */
2579
2776
  has: function (attribute) {
2580
- return !isEmpty(this.errorsFor(attribute));
2777
+ return this.errorsFor(attribute).length > 0;
2581
2778
  }
2582
2779
  });
2583
2780
  });
@@ -2617,7 +2814,6 @@ define('ember-data/-private/system/model/internal-model', ['exports', 'ember-dat
2617
2814
  var copy = Ember.copy;
2618
2815
  var EmberError = Ember.Error;
2619
2816
  var isEqual = Ember.isEqual;
2620
- var isEmpty = Ember.isEmpty;
2621
2817
  var setOwner = Ember.setOwner;
2622
2818
  var run = Ember.run;
2623
2819
  var RSVP = Ember.RSVP;
@@ -3429,7 +3625,7 @@ define('ember-data/-private/system/model/internal-model', ['exports', 'ember-dat
3429
3625
  InternalModel.prototype.hasErrors = function hasErrors() {
3430
3626
  var errors = get(this.getRecord(), 'errors');
3431
3627
 
3432
- return !isEmpty(errors);
3628
+ return errors.get('length') > 0;
3433
3629
  };
3434
3630
 
3435
3631
  InternalModel.prototype.adapterDidInvalidate = function adapterDidInvalidate(errors) {
@@ -3662,7 +3858,7 @@ define('ember-data/-private/system/model/internal-model', ['exports', 'ember-dat
3662
3858
  };
3663
3859
  }
3664
3860
  });
3665
- define('ember-data/-private/system/model/model', ['exports', 'ember-data/-private/system/promise-proxies', 'ember-data/-private/system/model/errors', 'ember-data/-private/features', 'ember-data/-private/system/model/states', 'ember-data/-private/system/relationships/ext'], function (exports, _promiseProxies, _errors, _features, _states, _ext) {
3861
+ define('ember-data/-private/system/model/model', ['exports', 'ember-data/-private/system/map', 'ember-data/-private/system/promise-proxies', 'ember-data/-private/system/model/errors', 'ember-data/-private/features', 'ember-data/-private/system/model/states', 'ember-data/-private/system/relationships/ext'], function (exports, _map, _promiseProxies, _errors, _features, _states, _ext) {
3666
3862
  'use strict';
3667
3863
 
3668
3864
  exports.__esModule = true;
@@ -3674,7 +3870,6 @@ define('ember-data/-private/system/model/model', ['exports', 'ember-data/-privat
3674
3870
  var computed = Ember.computed;
3675
3871
  var get = Ember.get;
3676
3872
  var observer = Ember.observer;
3677
- var Map = Ember.Map;
3678
3873
 
3679
3874
 
3680
3875
  /**
@@ -4440,7 +4635,7 @@ define('ember-data/-private/system/model/model', ['exports', 'ember-data/-privat
4440
4635
  ```
4441
4636
  @property relationships
4442
4637
  @static
4443
- @type Ember.Map
4638
+ @type Map
4444
4639
  @readOnly
4445
4640
  */
4446
4641
 
@@ -4540,7 +4735,7 @@ define('ember-data/-private/system/model/model', ['exports', 'ember-data/-privat
4540
4735
  ```
4541
4736
  @property relationshipsByName
4542
4737
  @static
4543
- @type Ember.Map
4738
+ @type Map
4544
4739
  @readOnly
4545
4740
  */
4546
4741
  relationshipsByName: _ext.relationshipsByNameDescriptor,
@@ -4574,11 +4769,11 @@ define('ember-data/-private/system/model/model', ['exports', 'ember-data/-privat
4574
4769
  ```
4575
4770
  @property fields
4576
4771
  @static
4577
- @type Ember.Map
4772
+ @type Map
4578
4773
  @readOnly
4579
4774
  */
4580
4775
  fields: computed(function () {
4581
- var map = Map.create();
4776
+ var map = new _map.default();
4582
4777
 
4583
4778
  this.eachComputedProperty(function (name, meta) {
4584
4779
  if (meta.isRelationship) {
@@ -4653,13 +4848,13 @@ define('ember-data/-private/system/model/model', ['exports', 'ember-data/-privat
4653
4848
  ```
4654
4849
  @property attributes
4655
4850
  @static
4656
- @type {Ember.Map}
4851
+ @type {Map}
4657
4852
  @readOnly
4658
4853
  */
4659
4854
  attributes: computed(function () {
4660
4855
  var _this3 = this;
4661
4856
 
4662
- var map = Map.create();
4857
+ var map = new _map.default();
4663
4858
 
4664
4859
  this.eachComputedProperty(function (name, meta) {
4665
4860
  if (meta.isAttribute) {
@@ -4701,11 +4896,11 @@ define('ember-data/-private/system/model/model', ['exports', 'ember-data/-privat
4701
4896
  ```
4702
4897
  @property transformedAttributes
4703
4898
  @static
4704
- @type {Ember.Map}
4899
+ @type {Map}
4705
4900
  @readOnly
4706
4901
  */
4707
4902
  transformedAttributes: computed(function () {
4708
- var map = Map.create();
4903
+ var map = new _map.default();
4709
4904
 
4710
4905
  this.eachAttribute(function (key, meta) {
4711
4906
  if (meta.type) {
@@ -4754,6 +4949,10 @@ define('ember-data/-private/system/model/model', ['exports', 'ember-data/-privat
4754
4949
  // the computed property.
4755
4950
  var meta = value.meta();
4756
4951
 
4952
+ /*
4953
+ This is buggy because if the parent has never been looked up
4954
+ via `modelFor` it will not have `modelName` set.
4955
+ */
4757
4956
  meta.parentType = proto.constructor;
4758
4957
  }
4759
4958
  }
@@ -5513,16 +5712,12 @@ define('ember-data/-private/system/normalize-model-name', ['exports'], function
5513
5712
  return dasherize(modelName);
5514
5713
  }
5515
5714
  });
5516
- define('ember-data/-private/system/ordered-set', ['exports'], function (exports) {
5715
+ define('ember-data/-private/system/ordered-set', ['exports', '@ember/ordered-set'], function (exports, _orderedSet) {
5517
5716
  'use strict';
5518
5717
 
5519
5718
  exports.__esModule = true;
5520
5719
  exports.default = OrderedSet;
5521
5720
  var guidFor = Ember.guidFor;
5522
-
5523
-
5524
- var EmberOrderedSet = Ember.OrderedSet;
5525
-
5526
5721
  function OrderedSet() {
5527
5722
  this._super$constructor();
5528
5723
  }
@@ -5532,9 +5727,9 @@ define('ember-data/-private/system/ordered-set', ['exports'], function (exports)
5532
5727
  return new Constructor();
5533
5728
  };
5534
5729
 
5535
- OrderedSet.prototype = Object.create(EmberOrderedSet.prototype);
5730
+ OrderedSet.prototype = Object.create(_orderedSet.default.prototype);
5536
5731
  OrderedSet.prototype.constructor = OrderedSet;
5537
- OrderedSet.prototype._super$constructor = EmberOrderedSet;
5732
+ OrderedSet.prototype._super$constructor = _orderedSet.default;
5538
5733
 
5539
5734
  OrderedSet.prototype.addWithIndex = function (obj, idx) {
5540
5735
  var guid = guidFor(obj);
@@ -7566,7 +7761,7 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
7566
7761
  }
7567
7762
 
7568
7763
  function relationshipFromMeta(meta) {
7569
- var result = {
7764
+ return {
7570
7765
  key: meta.key,
7571
7766
  kind: meta.kind,
7572
7767
  type: typeForRelationshipMeta(meta),
@@ -7575,12 +7770,6 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
7575
7770
  parentType: meta.parentType,
7576
7771
  isRelationship: true
7577
7772
  };
7578
-
7579
- if (false) {
7580
- result.parentType = meta.parentType;
7581
- }
7582
-
7583
- return result;
7584
7773
  }
7585
7774
  });
7586
7775
  define('ember-data/-private/system/relationships/belongs-to', ['exports', 'ember-data/-private/system/normalize-model-name'], function (exports, _normalizeModelName) {
@@ -7726,17 +7915,15 @@ define('ember-data/-private/system/relationships/belongs-to', ['exports', 'ember
7726
7915
  }).meta(meta);
7727
7916
  }
7728
7917
  });
7729
- define('ember-data/-private/system/relationships/ext', ['exports', 'ember-data/-private/system/relationship-meta'], function (exports, _relationshipMeta) {
7918
+ define('ember-data/-private/system/relationships/ext', ['exports', 'ember-data/-private/system/map-with-default', 'ember-data/-private/system/map', 'ember-data/-private/system/relationship-meta'], function (exports, _mapWithDefault, _map, _relationshipMeta) {
7730
7919
  'use strict';
7731
7920
 
7732
7921
  exports.__esModule = true;
7733
7922
  exports.relationshipsByNameDescriptor = exports.relatedTypesDescriptor = exports.relationshipsDescriptor = undefined;
7734
7923
  var A = Ember.A;
7735
7924
  var computed = Ember.computed;
7736
- var MapWithDefault = Ember.MapWithDefault;
7737
- var Map = Ember.Map;
7738
7925
  var relationshipsDescriptor = exports.relationshipsDescriptor = computed(function () {
7739
- var map = new MapWithDefault({
7926
+ var map = new _mapWithDefault.default({
7740
7927
  defaultValue: function () {
7741
7928
  return [];
7742
7929
  }
@@ -7789,7 +7976,7 @@ define('ember-data/-private/system/relationships/ext', ['exports', 'ember-data/-
7789
7976
  }).readOnly();
7790
7977
 
7791
7978
  var relationshipsByNameDescriptor = exports.relationshipsByNameDescriptor = computed(function () {
7792
- var map = Map.create();
7979
+ var map = new _map.default();
7793
7980
 
7794
7981
  this.eachComputedProperty(function (name, meta) {
7795
7982
  if (meta.isRelationship) {
@@ -7982,7 +8169,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
7982
8169
  }
7983
8170
  }
7984
8171
 
7985
- var _get = Ember.get;
8172
+ var get = Ember.get;
7986
8173
 
7987
8174
  var RelationshipPayloadsManager = function () {
7988
8175
  function RelationshipPayloadsManager(store) {
@@ -7991,6 +8178,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
7991
8178
  this._store = store;
7992
8179
  // cache of `RelationshipPayload`s
7993
8180
  this._cache = Object.create(null);
8181
+ this._inverseLookupCache = new _relationshipPayloads.TypeCache();
7994
8182
  }
7995
8183
 
7996
8184
  /**
@@ -8011,9 +8199,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8011
8199
 
8012
8200
 
8013
8201
  RelationshipPayloadsManager.prototype.get = function get(modelName, id, relationshipName) {
8014
- var modelClass = this._store._modelFor(modelName);
8015
- var relationshipsByName = _get(modelClass, 'relationshipsByName');
8016
- var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
8202
+ var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, false);
8017
8203
  return relationshipPayloads && relationshipPayloads.get(modelName, id, relationshipName);
8018
8204
  };
8019
8205
 
@@ -8024,10 +8210,8 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8024
8210
  return;
8025
8211
  }
8026
8212
 
8027
- var modelClass = this._store._modelFor(modelName);
8028
- var relationshipsByName = _get(modelClass, 'relationshipsByName');
8029
8213
  Object.keys(relationshipsData).forEach(function (key) {
8030
- var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, modelClass, relationshipsByName, true);
8214
+ var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, true);
8031
8215
  if (relationshipPayloads) {
8032
8216
  relationshipPayloads.push(modelName, id, key, relationshipsData[key]);
8033
8217
  }
@@ -8038,51 +8222,153 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8038
8222
  var _this2 = this;
8039
8223
 
8040
8224
  var modelClass = this._store._modelFor(modelName);
8041
- var relationshipsByName = _get(modelClass, 'relationshipsByName');
8225
+ var relationshipsByName = get(modelClass, 'relationshipsByName');
8042
8226
  relationshipsByName.forEach(function (_, relationshipName) {
8043
- var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
8227
+ var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, false);
8044
8228
  if (relationshipPayloads) {
8045
8229
  relationshipPayloads.unload(modelName, id, relationshipName);
8046
8230
  }
8047
8231
  });
8048
8232
  };
8049
8233
 
8050
- RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, init) {
8051
- if (!relationshipsByName.has(relationshipName)) {
8234
+ RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, init) {
8235
+ var relInfo = this.getRelationshipInfo(modelName, relationshipName);
8236
+
8237
+ if (relInfo === null) {
8052
8238
  return;
8053
8239
  }
8054
8240
 
8055
- var key = modelName + ':' + relationshipName;
8056
- if (!this._cache[key] && init) {
8057
- return this._initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName);
8241
+ var cache = this._cache[relInfo.lhs_key];
8242
+
8243
+ if (!cache && init) {
8244
+ return this._initializeRelationshipPayloads(relInfo);
8058
8245
  }
8059
8246
 
8060
- return this._cache[key];
8247
+ return cache;
8061
8248
  };
8062
8249
 
8063
- RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName) {
8250
+ RelationshipPayloadsManager.prototype.getRelationshipInfo = function getRelationshipInfo(modelName, relationshipName) {
8251
+ var inverseCache = this._inverseLookupCache;
8252
+ var store = this._store;
8253
+ var cached = inverseCache.get(modelName, relationshipName);
8254
+
8255
+ // CASE: We have a cached resolution (null if no relationship exists)
8256
+ if (cached !== undefined) {
8257
+ return cached;
8258
+ }
8259
+
8260
+ var modelClass = store._modelFor(modelName);
8261
+ var relationshipsByName = get(modelClass, 'relationshipsByName');
8262
+
8263
+ // CASE: We don't have a relationship at all
8264
+ if (!relationshipsByName.has(relationshipName)) {
8265
+ inverseCache.set(modelName, relationshipName, null);
8266
+ return null;
8267
+ }
8268
+
8269
+ var inverseMeta = modelClass.inverseFor(relationshipName, store);
8064
8270
  var relationshipMeta = relationshipsByName.get(relationshipName);
8065
- var inverseMeta = modelClass.inverseFor(relationshipName, this._store);
8066
-
8067
- var inverseModelName = void 0;
8068
- var inverseRelationshipName = void 0;
8069
- var inverseRelationshipMeta = void 0;
8070
-
8071
- // figure out the inverse relationship; we need two things
8072
- // a) the inverse model name
8073
- //- b) the name of the inverse relationship
8074
- if (inverseMeta) {
8075
- inverseRelationshipName = inverseMeta.name;
8076
- inverseModelName = relationshipMeta.type;
8077
- inverseRelationshipMeta = _get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
8078
- } else {
8079
- // relationship has no inverse
8080
- inverseModelName = inverseRelationshipName = '';
8081
- inverseRelationshipMeta = null;
8271
+ var selfIsPolymorphic = relationshipMeta.options !== undefined && relationshipMeta.options.polymorphic === true;
8272
+ var inverseBaseModelName = relationshipMeta.type;
8273
+
8274
+ // CASE: We have no inverse
8275
+ if (!inverseMeta) {
8276
+ var _info = {
8277
+ lhs_key: modelName + ':' + relationshipName,
8278
+ lhs_modelNames: [modelName],
8279
+ lhs_baseModelName: modelName,
8280
+ lhs_relationshipName: relationshipName,
8281
+ lhs_relationshipMeta: relationshipMeta,
8282
+ lhs_isPolymorphic: selfIsPolymorphic,
8283
+ rhs_key: '',
8284
+ rhs_modelNames: [],
8285
+ rhs_baseModelName: inverseBaseModelName,
8286
+ rhs_relationshipName: '',
8287
+ rhs_relationshipMeta: null,
8288
+ rhs_isPolymorphic: false,
8289
+ hasInverse: false,
8290
+ isSelfReferential: false, // modelName === inverseBaseModelName,
8291
+ isReflexive: false
8292
+ };
8293
+
8294
+ inverseCache.set(modelName, relationshipName, _info);
8295
+
8296
+ return _info;
8082
8297
  }
8083
8298
 
8084
- var lhsKey = modelName + ':' + relationshipName;
8085
- var rhsKey = inverseModelName + ':' + inverseRelationshipName;
8299
+ // CASE: We do have an inverse
8300
+
8301
+ var inverseRelationshipName = inverseMeta.name;
8302
+ var inverseRelationshipMeta = get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
8303
+ var baseModelName = inverseRelationshipMeta.type;
8304
+ var isSelfReferential = baseModelName === inverseBaseModelName;
8305
+
8306
+ // TODO we want to assert this but this breaks all of our shoddily written tests
8307
+ /*
8308
+ if (DEBUG) {
8309
+ let inverseDoubleCheck = inverseMeta.type.inverseFor(inverseRelationshipName, store);
8310
+ assert(`The ${inverseBaseModelName}:${inverseRelationshipName} relationship declares 'inverse: null', but it was resolved as the inverse for ${baseModelName}:${relationshipName}.`, inverseDoubleCheck);
8311
+ }
8312
+ */
8313
+
8314
+ // CASE: We may have already discovered the inverse for the baseModelName
8315
+ // CASE: We have already discovered the inverse
8316
+ cached = inverseCache.get(baseModelName, relationshipName) || inverseCache.get(inverseBaseModelName, inverseRelationshipName);
8317
+ if (cached) {
8318
+ (false && Ember.assert('The ' + inverseBaseModelName + ':' + inverseRelationshipName + ' relationship declares \'inverse: null\', but it was resolved as the inverse for ' + baseModelName + ':' + relationshipName + '.', cached.hasInverse !== false));
8319
+
8320
+
8321
+ var isLHS = cached.lhs_baseModelName === baseModelName;
8322
+ var modelNames = isLHS ? cached.lhs_modelNames : cached.rhs_modelNames;
8323
+ // make this lookup easier in the future by caching the key
8324
+ modelNames.push(modelName);
8325
+ inverseCache.set(modelName, relationshipName, cached);
8326
+
8327
+ return cached;
8328
+ }
8329
+
8330
+ var info = {
8331
+ lhs_key: baseModelName + ':' + relationshipName,
8332
+ lhs_modelNames: [modelName],
8333
+ lhs_baseModelName: baseModelName,
8334
+ lhs_relationshipName: relationshipName,
8335
+ lhs_relationshipMeta: relationshipMeta,
8336
+ lhs_isPolymorphic: selfIsPolymorphic,
8337
+ rhs_key: inverseBaseModelName + ':' + inverseRelationshipName,
8338
+ rhs_modelNames: [],
8339
+ rhs_baseModelName: inverseBaseModelName,
8340
+ rhs_relationshipName: inverseRelationshipName,
8341
+ rhs_relationshipMeta: inverseRelationshipMeta,
8342
+ rhs_isPolymorphic: inverseRelationshipMeta.options !== undefined && inverseRelationshipMeta.options.polymorphic === true,
8343
+ hasInverse: true,
8344
+ isSelfReferential: isSelfReferential,
8345
+ isReflexive: isSelfReferential && relationshipName === inverseRelationshipName
8346
+ };
8347
+
8348
+ // Create entries for the baseModelName as well as modelName to speed up
8349
+ // inverse lookups
8350
+ inverseCache.set(baseModelName, relationshipName, info);
8351
+ inverseCache.set(modelName, relationshipName, info);
8352
+
8353
+ // Greedily populate the inverse
8354
+ inverseCache.set(inverseBaseModelName, inverseRelationshipName, info);
8355
+
8356
+ return info;
8357
+ };
8358
+
8359
+ RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(relInfo) {
8360
+ var lhsKey = relInfo.lhs_key;
8361
+ var rhsKey = relInfo.rhs_key;
8362
+ var existingPayloads = this._cache[lhsKey];
8363
+
8364
+ if (relInfo.hasInverse === true && relInfo.rhs_isPolymorphic === true) {
8365
+ existingPayloads = this._cache[rhsKey];
8366
+
8367
+ if (existingPayloads !== undefined) {
8368
+ this._cache[lhsKey] = existingPayloads;
8369
+ return existingPayloads;
8370
+ }
8371
+ }
8086
8372
 
8087
8373
  // populate the cache for both sides of the relationship, as they both use
8088
8374
  // the same `RelationshipPayloads`.
@@ -8090,7 +8376,13 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8090
8376
  // This works out better than creating a single common key, because to
8091
8377
  // compute that key we would need to do work to look up the inverse
8092
8378
  //
8093
- return this._cache[lhsKey] = this._cache[rhsKey] = new _relationshipPayloads.default(this._store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta);
8379
+ var cache = this._cache[lhsKey] = new _relationshipPayloads.default(relInfo);
8380
+
8381
+ if (relInfo.hasInverse === true) {
8382
+ this._cache[rhsKey] = cache;
8383
+ }
8384
+
8385
+ return cache;
8094
8386
  };
8095
8387
 
8096
8388
  return RelationshipPayloadsManager;
@@ -8103,12 +8395,6 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8103
8395
 
8104
8396
  exports.__esModule = true;
8105
8397
 
8106
- function _classCallCheck(instance, Constructor) {
8107
- if (!(instance instanceof Constructor)) {
8108
- throw new TypeError("Cannot call a class as a function");
8109
- }
8110
- }
8111
-
8112
8398
  var _createClass = function () {
8113
8399
  function defineProperties(target, props) {
8114
8400
  for (var i = 0; i < props.length; i++) {
@@ -8127,37 +8413,61 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8127
8413
  };
8128
8414
  }();
8129
8415
 
8130
- var RelationshipPayloads = function () {
8131
- function RelationshipPayloads(store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta) {
8132
- _classCallCheck(this, RelationshipPayloads);
8416
+ function _classCallCheck(instance, Constructor) {
8417
+ if (!(instance instanceof Constructor)) {
8418
+ throw new TypeError("Cannot call a class as a function");
8419
+ }
8420
+ }
8133
8421
 
8134
- this._store = store;
8422
+ var TypeCache = exports.TypeCache = function () {
8423
+ function TypeCache() {
8424
+ _classCallCheck(this, TypeCache);
8135
8425
 
8136
- this._lhsModelName = modelName;
8137
- this._lhsRelationshipName = relationshipName;
8138
- this._lhsRelationshipMeta = relationshipMeta;
8426
+ this.types = Object.create(null);
8427
+ }
8139
8428
 
8140
- this._rhsModelName = inverseModelName;
8141
- this._rhsRelationshipName = inverseRelationshipName;
8142
- this._rhsRelationshipMeta = inverseRelationshipMeta;
8429
+ TypeCache.prototype.get = function get(modelName, id) {
8430
+ var types = this.types;
8143
8431
 
8144
- // a map of id -> payloads for the left hand side of the relationship.
8145
- this._lhsPayloads = Object.create(null);
8146
- if (modelName !== inverseModelName || relationshipName !== inverseRelationshipName) {
8147
- // The common case of a non-reflexive relationship, or a reflexive
8148
- // relationship whose inverse is not itself
8149
- this._rhsPayloads = Object.create(null);
8150
- this._isReflexive = false;
8151
- } else {
8152
- // Edge case when we have a reflexive relationship to itself
8153
- // eg user hasMany friends inverse friends
8154
- //
8155
- // In this case there aren't really two sides to the relationship, but
8156
- // we set `_rhsPayloads = _lhsPayloads` to make things easier to reason
8157
- // about
8158
- this._rhsPayloads = this._lhsPayloads;
8159
- this._isReflexive = true;
8432
+
8433
+ if (types[modelName] !== undefined) {
8434
+ return types[modelName][id];
8160
8435
  }
8436
+ };
8437
+
8438
+ TypeCache.prototype.set = function set(modelName, id, payload) {
8439
+ var types = this.types;
8440
+
8441
+ var typeMap = types[modelName];
8442
+
8443
+ if (typeMap === undefined) {
8444
+ typeMap = types[modelName] = Object.create(null);
8445
+ }
8446
+
8447
+ typeMap[id] = payload;
8448
+ };
8449
+
8450
+ TypeCache.prototype.delete = function _delete(modelName, id) {
8451
+ var types = this.types;
8452
+
8453
+
8454
+ if (types[modelName] !== undefined) {
8455
+ delete types[modelName][id];
8456
+ }
8457
+ };
8458
+
8459
+ return TypeCache;
8460
+ }();
8461
+
8462
+ var RelationshipPayloads = function () {
8463
+ function RelationshipPayloads(relInfo) {
8464
+ _classCallCheck(this, RelationshipPayloads);
8465
+
8466
+ this._relInfo = relInfo;
8467
+
8468
+ // a map of id -> payloads for the left hand side of the relationship.
8469
+ this.lhs_payloads = new TypeCache();
8470
+ this.rhs_payloads = relInfo.isReflexive ? this.lhs_payloads : new TypeCache();
8161
8471
 
8162
8472
  // When we push relationship payloads, just stash them in a queue until
8163
8473
  // somebody actually asks for one of them.
@@ -8168,22 +8478,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8168
8478
  }
8169
8479
 
8170
8480
  /**
8171
- Get the payload for the relationship of an individual record.
8172
- This might return the raw payload as pushed into the store, or one computed
8173
- from the payload of the inverse relationship.
8174
- @method
8175
- */
8481
+ Get the payload for the relationship of an individual record.
8482
+ This might return the raw payload as pushed into the store, or one computed
8483
+ from the payload of the inverse relationship.
8484
+ @method
8485
+ */
8176
8486
 
8177
8487
 
8178
8488
  RelationshipPayloads.prototype.get = function get(modelName, id, relationshipName) {
8179
8489
  this._flushPending();
8180
8490
 
8181
8491
  if (this._isLHS(modelName, relationshipName)) {
8182
- return this._lhsPayloads[id];
8492
+ return this.lhs_payloads.get(modelName, id);
8183
8493
  } else {
8184
- (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
8494
+ (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName)));
8185
8495
 
8186
- return this._rhsPayloads[id];
8496
+ return this.rhs_payloads.get(modelName, id);
8187
8497
  }
8188
8498
  };
8189
8499
 
@@ -8195,20 +8505,40 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8195
8505
  this._flushPending();
8196
8506
 
8197
8507
  if (this._isLHS(modelName, relationshipName)) {
8198
- delete this._lhsPayloads[id];
8508
+ delete this.lhs_payloads.delete(modelName, id);
8199
8509
  } else {
8200
- (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
8510
+ (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_baseModelName + ':' + this._relInfo.lhs_relationshipName + '<->' + this._relInfo.rhs_baseModelName + ':' + this._relInfo.rhs_relationshipName, this._isRHS(modelName, relationshipName)));
8201
8511
 
8202
- delete this._rhsPayloads[id];
8512
+ delete this.rhs_payloads.delete(modelName, id);
8203
8513
  }
8204
8514
  };
8205
8515
 
8206
8516
  RelationshipPayloads.prototype._isLHS = function _isLHS(modelName, relationshipName) {
8207
- return modelName === this._lhsModelName && relationshipName === this._lhsRelationshipName;
8517
+ var relInfo = this._relInfo;
8518
+ var isSelfReferential = relInfo.isSelfReferential;
8519
+ var isRelationship = relationshipName === relInfo.lhs_relationshipName;
8520
+
8521
+ if (isRelationship === true) {
8522
+ return isSelfReferential === true || // itself
8523
+ modelName === relInfo.lhs_baseModelName || // base or non-polymorphic
8524
+ relInfo.lhs_modelNames.indexOf(modelName) !== -1; // polymorphic
8525
+ }
8526
+
8527
+ return false;
8208
8528
  };
8209
8529
 
8210
8530
  RelationshipPayloads.prototype._isRHS = function _isRHS(modelName, relationshipName) {
8211
- return modelName === this._rhsModelName && relationshipName === this._rhsRelationshipName;
8531
+ var relInfo = this._relInfo;
8532
+ var isSelfReferential = relInfo.isSelfReferential;
8533
+ var isRelationship = relationshipName === relInfo.rhs_relationshipName;
8534
+
8535
+ if (isRelationship === true) {
8536
+ return isSelfReferential === true || // itself
8537
+ modelName === relInfo.rhs_baseModelName || // base or non-polymorphic
8538
+ relInfo.rhs_modelNames.indexOf(modelName) !== -1; // polymorphic
8539
+ }
8540
+
8541
+ return false;
8212
8542
  };
8213
8543
 
8214
8544
  RelationshipPayloads.prototype._flushPending = function _flushPending() {
@@ -8229,26 +8559,28 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8229
8559
  id: id,
8230
8560
  type: modelName
8231
8561
  }
8562
+ };
8232
8563
 
8233
- // start flushing this individual payload. The logic is the same whether
8234
- // it's for the left hand side of the relationship or the right hand side,
8235
- // except the role of primary and inverse idToPayloads is reversed
8236
- //
8237
- };var previousPayload = void 0;
8238
- var idToPayloads = void 0;
8239
- var inverseIdToPayloads = void 0;
8564
+ // start flushing this individual payload. The logic is the same whether
8565
+ // it's for the left hand side of the relationship or the right hand side,
8566
+ // except the role of primary and inverse idToPayloads is reversed
8567
+ //
8568
+ var previousPayload = void 0;
8569
+ var payloadMap = void 0;
8570
+ var inversePayloadMap = void 0;
8240
8571
  var inverseIsMany = void 0;
8572
+
8241
8573
  if (this._isLHS(modelName, relationshipName)) {
8242
- previousPayload = this._lhsPayloads[id];
8243
- idToPayloads = this._lhsPayloads;
8244
- inverseIdToPayloads = this._rhsPayloads;
8574
+ previousPayload = this.lhs_payloads.get(modelName, id);
8575
+ payloadMap = this.lhs_payloads;
8576
+ inversePayloadMap = this.rhs_payloads;
8245
8577
  inverseIsMany = this._rhsRelationshipIsMany;
8246
8578
  } else {
8247
- (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
8579
+ (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName)));
8248
8580
 
8249
- previousPayload = this._rhsPayloads[id];
8250
- idToPayloads = this._rhsPayloads;
8251
- inverseIdToPayloads = this._lhsPayloads;
8581
+ previousPayload = this.rhs_payloads.get(modelName, id);
8582
+ payloadMap = this.rhs_payloads;
8583
+ inversePayloadMap = this.lhs_payloads;
8252
8584
  inverseIsMany = this._lhsRelationshipIsMany;
8253
8585
  }
8254
8586
 
@@ -8292,14 +8624,14 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8292
8624
  // * undefined is NOT considered new information, we should keep original state
8293
8625
  // * anything else is considered new information, and it should win
8294
8626
  if (relationshipData.data !== undefined) {
8295
- this._removeInverse(id, previousPayload, inverseIdToPayloads);
8627
+ this._removeInverse(id, previousPayload, inversePayloadMap);
8296
8628
  }
8297
- idToPayloads[id] = relationshipData;
8298
- this._populateInverse(relationshipData, inverseRelationshipData, inverseIdToPayloads, inverseIsMany);
8629
+ payloadMap.set(modelName, id, relationshipData);
8630
+ this._populateInverse(relationshipData, inverseRelationshipData, inversePayloadMap, inverseIsMany);
8299
8631
  }
8300
8632
  };
8301
8633
 
8302
- RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inverseIdToPayloads, inverseIsMany) {
8634
+ RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inversePayloadMap, inverseIsMany) {
8303
8635
  if (!relationshipData.data) {
8304
8636
  // This id doesn't have an inverse, eg a belongsTo with a payload
8305
8637
  // { data: null }, so there's nothing to populate
@@ -8308,22 +8640,24 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8308
8640
 
8309
8641
  if (Array.isArray(relationshipData.data)) {
8310
8642
  for (var i = 0; i < relationshipData.data.length; ++i) {
8311
- var inverseId = relationshipData.data[i].id;
8312
- this._addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany);
8643
+ var resourceIdentifier = relationshipData.data[i];
8644
+ this._addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany);
8313
8645
  }
8314
8646
  } else {
8315
- var _inverseId = relationshipData.data.id;
8316
- this._addToInverse(inversePayload, _inverseId, inverseIdToPayloads, inverseIsMany);
8647
+ var _resourceIdentifier = relationshipData.data;
8648
+ this._addToInverse(inversePayload, _resourceIdentifier, inversePayloadMap, inverseIsMany);
8317
8649
  }
8318
8650
  };
8319
8651
 
8320
- RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany) {
8321
- if (this._isReflexive && inversePayload.data.id === inverseId) {
8652
+ RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany) {
8653
+ var relInfo = this._relInfo;
8654
+
8655
+ if (relInfo.isReflexive && inversePayload.data.id === resourceIdentifier.id) {
8322
8656
  // eg <user:1>.friends = [{ id: 1, type: 'user' }]
8323
8657
  return;
8324
8658
  }
8325
8659
 
8326
- var existingPayload = inverseIdToPayloads[inverseId];
8660
+ var existingPayload = inversePayloadMap.get(resourceIdentifier.type, resourceIdentifier.id);
8327
8661
  var existingData = existingPayload && existingPayload.data;
8328
8662
 
8329
8663
  if (existingData) {
@@ -8333,22 +8667,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8333
8667
  if (Array.isArray(existingData)) {
8334
8668
  existingData.push(inversePayload.data);
8335
8669
  } else {
8336
- inverseIdToPayloads[inverseId] = inversePayload;
8670
+ inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload);
8337
8671
  }
8338
8672
  } else {
8339
8673
  // first time we're populating the inverse side
8340
8674
  //
8341
8675
  if (inverseIsMany) {
8342
- inverseIdToPayloads[inverseId] = {
8676
+ inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, {
8343
8677
  data: [inversePayload.data]
8344
- };
8678
+ });
8345
8679
  } else {
8346
- inverseIdToPayloads[inverseId] = inversePayload;
8680
+ inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload);
8347
8681
  }
8348
8682
  }
8349
8683
  };
8350
8684
 
8351
- RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inverseIdToPayloads) {
8685
+ RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inversePayloadMap) {
8352
8686
  var data = previousPayload && previousPayload.data;
8353
8687
  if (!data) {
8354
8688
  // either this is the first time we've seen a payload for this id, or its
@@ -8363,15 +8697,16 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8363
8697
  if (Array.isArray(data)) {
8364
8698
  // TODO: diff rather than removeall addall?
8365
8699
  for (var i = 0; i < data.length; ++i) {
8366
- this._removeFromInverse(id, data[i].id, inverseIdToPayloads);
8700
+ var resourceIdentifier = data[i];
8701
+ this._removeFromInverse(id, resourceIdentifier, inversePayloadMap);
8367
8702
  }
8368
8703
  } else {
8369
- this._removeFromInverse(id, data.id, inverseIdToPayloads);
8704
+ this._removeFromInverse(id, data, inversePayloadMap);
8370
8705
  }
8371
8706
  };
8372
8707
 
8373
- RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, inverseId, inversePayloads) {
8374
- var inversePayload = inversePayloads[inverseId];
8708
+ RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, resourceIdentifier, inversePayloads) {
8709
+ var inversePayload = inversePayloads.get(resourceIdentifier.type, resourceIdentifier.id);
8375
8710
  var data = inversePayload && inversePayload.data;
8376
8711
 
8377
8712
  if (!data) {
@@ -8383,21 +8718,23 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8383
8718
  return x.id !== id;
8384
8719
  });
8385
8720
  } else {
8386
- inversePayloads[inverseId] = {
8721
+ inversePayloads.set(resourceIdentifier.type, resourceIdentifier.id, {
8387
8722
  data: null
8388
- };
8723
+ });
8389
8724
  }
8390
8725
  };
8391
8726
 
8392
8727
  _createClass(RelationshipPayloads, [{
8393
8728
  key: '_lhsRelationshipIsMany',
8394
8729
  get: function () {
8395
- return this._lhsRelationshipMeta && this._lhsRelationshipMeta.kind === 'hasMany';
8730
+ var meta = this._relInfo.lhs_relationshipMeta;
8731
+ return meta !== null && meta.kind === 'hasMany';
8396
8732
  }
8397
8733
  }, {
8398
8734
  key: '_rhsRelationshipIsMany',
8399
8735
  get: function () {
8400
- return this._rhsRelationshipMeta && this._rhsRelationshipMeta.kind === 'hasMany';
8736
+ var meta = this._relInfo.rhs_relationshipMeta;
8737
+ return meta !== null && meta.kind === 'hasMany';
8401
8738
  }
8402
8739
  }]);
8403
8740
 
@@ -9334,6 +9671,7 @@ define('ember-data/-private/system/relationships/state/relationship', ['exports'
9334
9671
  };
9335
9672
 
9336
9673
  Relationship.prototype.inverseDidDematerialize = function inverseDidDematerialize(inverseInternalModel) {
9674
+ this.linkPromise = null;
9337
9675
  if (!this.isAsync) {
9338
9676
  // unloading inverse of a sync relationship is treated as a client-side
9339
9677
  // delete, so actually remove the models don't merely invalidate the cp
@@ -10109,7 +10447,7 @@ define('ember-data/-private/system/snapshot', ['exports'], function (exports) {
10109
10447
 
10110
10448
  exports.default = Snapshot;
10111
10449
  });
10112
- define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adapters/errors', 'ember-data/-private/system/model/model', 'ember-data/-private/system/normalize-model-name', 'ember-data/-private/system/identity-map', '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/relationships/relationship-payloads-manager', '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/model/internal-model', 'ember-data/-private/features'], function (exports, _errors, _model, _normalizeModelName, _identityMap, _promiseProxies, _common, _serializerResponse, _serializers, _relationshipPayloadsManager, _finders, _utils, _coerceId, _recordArrayManager, _internalModel5, _features) {
10450
+ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/system/map-with-default', 'ember-data/-private/adapters/errors', 'ember-data/-private/system/model/model', 'ember-data/-private/system/normalize-model-name', 'ember-data/-private/system/identity-map', '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/relationships/relationship-payloads-manager', '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/model/internal-model', 'ember-data/-private/features'], function (exports, _mapWithDefault, _errors, _model, _normalizeModelName, _identityMap, _promiseProxies, _common, _serializerResponse, _serializers, _relationshipPayloadsManager, _finders, _utils, _coerceId, _recordArrayManager, _internalModel6, _features) {
10113
10451
  'use strict';
10114
10452
 
10115
10453
  exports.__esModule = true;
@@ -10117,7 +10455,6 @@ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adap
10117
10455
  var A = Ember.A;
10118
10456
  var copy = Ember.copy;
10119
10457
  var EmberError = Ember.Error;
10120
- var MapWithDefault = Ember.MapWithDefault;
10121
10458
  var emberRun = Ember.run;
10122
10459
  var set = Ember.set;
10123
10460
  var get = Ember.get;
@@ -10270,7 +10607,7 @@ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adap
10270
10607
  this._updatedInternalModels = [];
10271
10608
 
10272
10609
  // used to keep track of all the find requests that need to be coalesced
10273
- this._pendingFetch = MapWithDefault.create({
10610
+ this._pendingFetch = new _mapWithDefault.default({
10274
10611
  defaultValue: function () {
10275
10612
  return [];
10276
10613
  }
@@ -10836,6 +11173,18 @@ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adap
10836
11173
  seeking[_internalModel.id] = pendingItem;
10837
11174
  }
10838
11175
 
11176
+ for (var _i2 = 0; _i2 < totalItems; _i2++) {
11177
+ var _internalModel2 = internalModels[_i2];
11178
+ // We may have unloaded the record after scheduling this fetch, in which
11179
+ // case we must cancel the destory. This is because we require a record
11180
+ // to build a snapshot. This is not fundamental: this cancelation code
11181
+ // can be removed when snapshots can be created for internal models that
11182
+ // have no records.
11183
+ if (_internalModel2.hasScheduledDestroy()) {
11184
+ internalModels[_i2].cancelDestroy();
11185
+ }
11186
+ }
11187
+
10839
11188
  function _fetchRecord(recordResolverPair) {
10840
11189
  var recordFetch = store._fetchRecord(recordResolverPair.internalModel, recordResolverPair.options); // TODO adapter options
10841
11190
 
@@ -10845,25 +11194,25 @@ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adap
10845
11194
  function handleFoundRecords(foundInternalModels, expectedInternalModels) {
10846
11195
  // resolve found records
10847
11196
  var found = Object.create(null);
10848
- for (var _i2 = 0, _l = foundInternalModels.length; _i2 < _l; _i2++) {
10849
- var _internalModel2 = foundInternalModels[_i2];
10850
- var _pair = seeking[_internalModel2.id];
10851
- found[_internalModel2.id] = _internalModel2;
11197
+ for (var _i3 = 0, _l = foundInternalModels.length; _i3 < _l; _i3++) {
11198
+ var _internalModel3 = foundInternalModels[_i3];
11199
+ var _pair = seeking[_internalModel3.id];
11200
+ found[_internalModel3.id] = _internalModel3;
10852
11201
 
10853
11202
  if (_pair) {
10854
11203
  var resolver = _pair.resolver;
10855
- resolver.resolve(_internalModel2);
11204
+ resolver.resolve(_internalModel3);
10856
11205
  }
10857
11206
  }
10858
11207
 
10859
11208
  // reject missing records
10860
11209
  var missingInternalModels = [];
10861
11210
 
10862
- for (var _i3 = 0, _l2 = expectedInternalModels.length; _i3 < _l2; _i3++) {
10863
- var _internalModel3 = expectedInternalModels[_i3];
11211
+ for (var _i4 = 0, _l2 = expectedInternalModels.length; _i4 < _l2; _i4++) {
11212
+ var _internalModel4 = expectedInternalModels[_i4];
10864
11213
 
10865
- if (!found[_internalModel3.id]) {
10866
- missingInternalModels.push(_internalModel3);
11214
+ if (!found[_internalModel4.id]) {
11215
+ missingInternalModels.push(_internalModel4);
10867
11216
  }
10868
11217
  }
10869
11218
 
@@ -10879,12 +11228,12 @@ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adap
10879
11228
  }
10880
11229
 
10881
11230
  function rejectInternalModels(internalModels, error) {
10882
- for (var _i4 = 0, _l3 = internalModels.length; _i4 < _l3; _i4++) {
10883
- var _internalModel4 = internalModels[_i4];
10884
- var _pair2 = seeking[_internalModel4.id];
11231
+ for (var _i5 = 0, _l3 = internalModels.length; _i5 < _l3; _i5++) {
11232
+ var _internalModel5 = internalModels[_i5];
11233
+ var _pair2 = seeking[_internalModel5.id];
10885
11234
 
10886
11235
  if (_pair2) {
10887
- _pair2.resolver.reject(error || new Error('Expected: \'' + _internalModel4 + '\' to be present in the adapter provided payload, but it was not found.'));
11236
+ _pair2.resolver.reject(error || new Error('Expected: \'' + _internalModel5 + '\' to be present in the adapter provided payload, but it was not found.'));
10888
11237
  }
10889
11238
  }
10890
11239
  }
@@ -10901,8 +11250,8 @@ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adap
10901
11250
  // records from the grouped snapshots even though the _findMany() finder
10902
11251
  // will once again convert the records to snapshots for adapter.findMany()
10903
11252
  var snapshots = new Array(totalItems);
10904
- for (var _i5 = 0; _i5 < totalItems; _i5++) {
10905
- snapshots[_i5] = internalModels[_i5].createSnapshot();
11253
+ for (var _i6 = 0; _i6 < totalItems; _i6++) {
11254
+ snapshots[_i6] = internalModels[_i6].createSnapshot();
10906
11255
  }
10907
11256
 
10908
11257
  var groups = adapter.groupRecordsForFindMany(this, snapshots);
@@ -10936,8 +11285,8 @@ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adap
10936
11285
  }
10937
11286
  }
10938
11287
  } else {
10939
- for (var _i6 = 0; _i6 < totalItems; _i6++) {
10940
- _fetchRecord(pendingFetchItems[_i6]);
11288
+ for (var _i7 = 0; _i7 < totalItems; _i7++) {
11289
+ _fetchRecord(pendingFetchItems[_i7]);
10941
11290
  }
10942
11291
  }
10943
11292
  },
@@ -12414,7 +12763,7 @@ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adap
12414
12763
  // lookupFactory should really return an object that creates
12415
12764
  // instances with the injections applied
12416
12765
 
12417
- var internalModel = new _internalModel5.default(modelName, id, this, data);
12766
+ var internalModel = new _internalModel6.default(modelName, id, this, data);
12418
12767
 
12419
12768
  this._internalModelsFor(modelName).add(internalModel, id);
12420
12769
 
@@ -13071,7 +13420,6 @@ define('ember-data/-private/system/store/serializer-response', ['exports'], func
13071
13420
  exports.__esModule = true;
13072
13421
  exports.validateDocumentStructure = validateDocumentStructure;
13073
13422
  exports.normalizeResponseHelper = normalizeResponseHelper;
13074
- var isEmpty = Ember.isEmpty;
13075
13423
 
13076
13424
 
13077
13425
  /*
@@ -13149,7 +13497,7 @@ define('ember-data/-private/system/store/serializer-response', ['exports'], func
13149
13497
  if (false) {
13150
13498
  validationErrors = validateDocumentStructure(normalizedResponse);
13151
13499
  }
13152
- (false && Ember.assert('normalizeResponse must return a valid JSON API document:\n\t* ' + validationErrors.join('\n\t* '), isEmpty(validationErrors)));
13500
+ (false && Ember.assert('normalizeResponse must return a valid JSON API document:\n\t* ' + validationErrors.join('\n\t* '), validationErrors.length === 0));
13153
13501
 
13154
13502
 
13155
13503
  return normalizedResponse;
@@ -14207,7 +14555,6 @@ define('ember-data/adapters/rest', ['exports', 'ember-data/adapter', 'ember-data
14207
14555
  exports.__esModule = true;
14208
14556
  var $ = Ember.$;
14209
14557
  var EmberPromise = Ember.RSVP.Promise;
14210
- var MapWithDefault = Ember.MapWithDefault;
14211
14558
  var get = Ember.get;
14212
14559
  var run = Ember.run;
14213
14560
 
@@ -14728,7 +15075,7 @@ define('ember-data/adapters/rest', ['exports', 'ember-data/adapter', 'ember-data
14728
15075
  maxURLLength: 2048,
14729
15076
 
14730
15077
  groupRecordsForFindMany: function (store, snapshots) {
14731
- var groups = MapWithDefault.create({
15078
+ var groups = new _private.MapWithDefault({
14732
15079
  defaultValue: function () {
14733
15080
  return [];
14734
15081
  }
@@ -18000,7 +18347,6 @@ define('ember-data/transforms/number', ['exports', 'ember-data/transforms/transf
18000
18347
  'use strict';
18001
18348
 
18002
18349
  exports.__esModule = true;
18003
- var empty = Ember.isEmpty;
18004
18350
 
18005
18351
 
18006
18352
  function isNumber(value) {
@@ -18033,7 +18379,7 @@ define('ember-data/transforms/number', ['exports', 'ember-data/transforms/transf
18033
18379
  deserialize: function (serialized) {
18034
18380
  var transformed = void 0;
18035
18381
 
18036
- if (empty(serialized)) {
18382
+ if (serialized === '' || serialized === null || serialized === undefined) {
18037
18383
  return null;
18038
18384
  } else {
18039
18385
  transformed = Number(serialized);
@@ -18044,7 +18390,7 @@ define('ember-data/transforms/number', ['exports', 'ember-data/transforms/transf
18044
18390
  serialize: function (deserialized) {
18045
18391
  var transformed = void 0;
18046
18392
 
18047
- if (empty(deserialized)) {
18393
+ if (deserialized === '' || deserialized === null || deserialized === undefined) {
18048
18394
  return null;
18049
18395
  } else {
18050
18396
  transformed = Number(deserialized);
@@ -18112,7 +18458,7 @@ define("ember-data/version", ["exports"], function (exports) {
18112
18458
  "use strict";
18113
18459
 
18114
18460
  exports.__esModule = true;
18115
- exports.default = "3.1.0-beta.1";
18461
+ exports.default = "3.1.0-beta.2";
18116
18462
  });
18117
18463
  define("ember-inflector", ["module", "exports", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (module, exports, _system) {
18118
18464
  "use strict";