ember-data-source 2.15.3 → 2.15.4

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: 764abf56e7002de2521ba185a895ab20be1da3af
4
- data.tar.gz: 09e4fb246ac4f51a99524c6b17b69809c490f4bc
3
+ metadata.gz: 1380b8c09ae4eaa8a34d2f1fffeb7871e462460f
4
+ data.tar.gz: 9bb17d836450a299cdfb416ec55c15c1139fafef
5
5
  SHA512:
6
- metadata.gz: ec33d70bd2ca281445fb31e7e8c75905021b3204c709e43cff5dd7b9ce88dd93eb1b361a2d20f355d5469807e6020288e1bd923d160fa0d3f02263e50e9ebe88
7
- data.tar.gz: 8259713fa6e9a1816da600d4c835951026ee791270eca54235b2bc550983c9c436610978368decbef075b522aebb12ae37819f85ab87787143240226782c69e9
6
+ metadata.gz: b2855ad5fcabd0bb3830ce97b3bb06cec759c3e81f8267f46ae9f4096380fd4884d3f34b627bb565fb2d42ad5f0d02029ff0d9723fa204b34cb9440df5e0f593
7
+ data.tar.gz: 56d7dd0e5c14a35a4b684ea9cef4985ba393cf25c49b7bfcbf86108d876fc357a3b437c749ab4f8cadb405931beeec2bb4b1fc278cd50849b9afca0406044907
@@ -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 2.15.3
9
+ * @version 2.15.4
10
10
  */
11
11
 
12
12
  var loader, define, requireModule, require, requirejs;
@@ -4902,6 +4902,10 @@ define('ember-data/-private/system/model/model', ['exports', 'ember', 'ember-dat
4902
4902
  // the computed property.
4903
4903
  var meta = value.meta();
4904
4904
 
4905
+ /*
4906
+ This is buggy because if the parent has never been looked up
4907
+ via `modelFor` it will not have `modelName` set.
4908
+ */
4905
4909
  meta.parentType = proto.constructor;
4906
4910
  }
4907
4911
  }
@@ -7689,7 +7693,7 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
7689
7693
  }
7690
7694
 
7691
7695
  function relationshipFromMeta(meta) {
7692
- var result = {
7696
+ return {
7693
7697
  key: meta.key,
7694
7698
  kind: meta.kind,
7695
7699
  type: typeForRelationshipMeta(meta),
@@ -7698,12 +7702,6 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
7698
7702
  parentType: meta.parentType,
7699
7703
  isRelationship: true
7700
7704
  };
7701
-
7702
- if (false) {
7703
- result.parentType = meta.parentType;
7704
- }
7705
-
7706
- return result;
7707
7705
  }
7708
7706
  });
7709
7707
  define('ember-data/-private/system/relationships/belongs-to', ['exports', 'ember', 'ember-data/-private/system/normalize-model-name'], function (exports, _ember, _normalizeModelName) {
@@ -8109,7 +8107,8 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8109
8107
  }
8110
8108
  }
8111
8109
 
8112
- var _get = _ember.default.get;
8110
+ var get = _ember.default.get;
8111
+ var assert = _ember.default.assert;
8113
8112
 
8114
8113
  /**
8115
8114
  Manages relationship payloads for a given store, for uninitialized
@@ -8172,6 +8171,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8172
8171
  this._store = store;
8173
8172
  // cache of `RelationshipPayload`s
8174
8173
  this._cache = Object.create(null);
8174
+ this._inverseLookupCache = new _relationshipPayloads.TypeCache();
8175
8175
  }
8176
8176
 
8177
8177
  /**
@@ -8192,9 +8192,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8192
8192
 
8193
8193
 
8194
8194
  RelationshipPayloadsManager.prototype.get = function get(modelName, id, relationshipName) {
8195
- var modelClass = this._store._modelFor(modelName);
8196
- var relationshipsByName = _get(modelClass, 'relationshipsByName');
8197
- var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
8195
+ var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, false);
8198
8196
  return relationshipPayloads && relationshipPayloads.get(modelName, id, relationshipName);
8199
8197
  };
8200
8198
 
@@ -8205,10 +8203,8 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8205
8203
  return;
8206
8204
  }
8207
8205
 
8208
- var modelClass = this._store._modelFor(modelName);
8209
- var relationshipsByName = _get(modelClass, 'relationshipsByName');
8210
8206
  Object.keys(relationshipsData).forEach(function (key) {
8211
- var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, modelClass, relationshipsByName, true);
8207
+ var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, true);
8212
8208
  if (relationshipPayloads) {
8213
8209
  relationshipPayloads.push(modelName, id, key, relationshipsData[key]);
8214
8210
  }
@@ -8219,51 +8215,153 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8219
8215
  var _this2 = this;
8220
8216
 
8221
8217
  var modelClass = this._store._modelFor(modelName);
8222
- var relationshipsByName = _get(modelClass, 'relationshipsByName');
8218
+ var relationshipsByName = get(modelClass, 'relationshipsByName');
8223
8219
  relationshipsByName.forEach(function (_, relationshipName) {
8224
- var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
8220
+ var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, false);
8225
8221
  if (relationshipPayloads) {
8226
8222
  relationshipPayloads.unload(modelName, id, relationshipName);
8227
8223
  }
8228
8224
  });
8229
8225
  };
8230
8226
 
8231
- RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, init) {
8232
- if (!relationshipsByName.has(relationshipName)) {
8227
+ RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, init) {
8228
+ var relInfo = this.getRelationshipInfo(modelName, relationshipName);
8229
+
8230
+ if (relInfo === null) {
8233
8231
  return;
8234
8232
  }
8235
8233
 
8236
- var key = modelName + ':' + relationshipName;
8237
- if (!this._cache[key] && init) {
8238
- return this._initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName);
8234
+ var cache = this._cache[relInfo.lhs_key];
8235
+
8236
+ if (!cache && init) {
8237
+ return this._initializeRelationshipPayloads(relInfo);
8239
8238
  }
8240
8239
 
8241
- return this._cache[key];
8240
+ return cache;
8242
8241
  };
8243
8242
 
8244
- RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName) {
8243
+ RelationshipPayloadsManager.prototype.getRelationshipInfo = function getRelationshipInfo(modelName, relationshipName) {
8244
+ var inverseCache = this._inverseLookupCache;
8245
+ var store = this._store;
8246
+ var cached = inverseCache.get(modelName, relationshipName);
8247
+
8248
+ // CASE: We have a cached resolution (null if no relationship exists)
8249
+ if (cached !== undefined) {
8250
+ return cached;
8251
+ }
8252
+
8253
+ var modelClass = store._modelFor(modelName);
8254
+ var relationshipsByName = get(modelClass, 'relationshipsByName');
8255
+
8256
+ // CASE: We don't have a relationship at all
8257
+ if (!relationshipsByName.has(relationshipName)) {
8258
+ inverseCache.set(modelName, relationshipName, null);
8259
+ return null;
8260
+ }
8261
+
8262
+ var inverseMeta = modelClass.inverseFor(relationshipName, store);
8245
8263
  var relationshipMeta = relationshipsByName.get(relationshipName);
8246
- var inverseMeta = modelClass.inverseFor(relationshipName, this._store);
8247
-
8248
- var inverseModelName = void 0;
8249
- var inverseRelationshipName = void 0;
8250
- var inverseRelationshipMeta = void 0;
8251
-
8252
- // figure out the inverse relationship; we need two things
8253
- // a) the inverse model name
8254
- //- b) the name of the inverse relationship
8255
- if (inverseMeta) {
8256
- inverseRelationshipName = inverseMeta.name;
8257
- inverseModelName = relationshipMeta.type;
8258
- inverseRelationshipMeta = _get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
8259
- } else {
8260
- // relationship has no inverse
8261
- inverseModelName = inverseRelationshipName = '';
8262
- inverseRelationshipMeta = null;
8264
+ var selfIsPolymorphic = relationshipMeta.options !== undefined && relationshipMeta.options.polymorphic === true;
8265
+ var inverseBaseModelName = relationshipMeta.type;
8266
+
8267
+ // CASE: We have no inverse
8268
+ if (!inverseMeta) {
8269
+ var _info = {
8270
+ lhs_key: modelName + ':' + relationshipName,
8271
+ lhs_modelNames: [modelName],
8272
+ lhs_baseModelName: modelName,
8273
+ lhs_relationshipName: relationshipName,
8274
+ lhs_relationshipMeta: relationshipMeta,
8275
+ lhs_isPolymorphic: selfIsPolymorphic,
8276
+ rhs_key: '',
8277
+ rhs_modelNames: [],
8278
+ rhs_baseModelName: inverseBaseModelName,
8279
+ rhs_relationshipName: '',
8280
+ rhs_relationshipMeta: null,
8281
+ rhs_isPolymorphic: false,
8282
+ hasInverse: false,
8283
+ isSelfReferential: false, // modelName === inverseBaseModelName,
8284
+ isReflexive: false
8285
+ };
8286
+
8287
+ inverseCache.set(modelName, relationshipName, _info);
8288
+
8289
+ return _info;
8263
8290
  }
8264
8291
 
8265
- var lhsKey = modelName + ':' + relationshipName;
8266
- var rhsKey = inverseModelName + ':' + inverseRelationshipName;
8292
+ // CASE: We do have an inverse
8293
+
8294
+ var inverseRelationshipName = inverseMeta.name;
8295
+ var inverseRelationshipMeta = get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
8296
+ var baseModelName = inverseRelationshipMeta.type;
8297
+ var isSelfReferential = baseModelName === inverseBaseModelName;
8298
+
8299
+ // TODO we want to assert this but this breaks all of our shoddily written tests
8300
+ /*
8301
+ if (DEBUG) {
8302
+ let inverseDoubleCheck = inverseMeta.type.inverseFor(inverseRelationshipName, store);
8303
+ assert(`The ${inverseBaseModelName}:${inverseRelationshipName} relationship declares 'inverse: null', but it was resolved as the inverse for ${baseModelName}:${relationshipName}.`, inverseDoubleCheck);
8304
+ }
8305
+ */
8306
+
8307
+ // CASE: We may have already discovered the inverse for the baseModelName
8308
+ // CASE: We have already discovered the inverse
8309
+ cached = inverseCache.get(baseModelName, relationshipName) || inverseCache.get(inverseBaseModelName, inverseRelationshipName);
8310
+ if (cached) {
8311
+ // TODO this assert can be removed if the above assert is enabled
8312
+ assert('The ' + inverseBaseModelName + ':' + inverseRelationshipName + ' relationship declares \'inverse: null\', but it was resolved as the inverse for ' + baseModelName + ':' + relationshipName + '.', cached.hasInverse !== false);
8313
+
8314
+ var isLHS = cached.lhs_baseModelName === baseModelName;
8315
+ var modelNames = isLHS ? cached.lhs_modelNames : cached.rhs_modelNames;
8316
+ // make this lookup easier in the future by caching the key
8317
+ modelNames.push(modelName);
8318
+ inverseCache.set(modelName, relationshipName, cached);
8319
+
8320
+ return cached;
8321
+ }
8322
+
8323
+ var info = {
8324
+ lhs_key: baseModelName + ':' + relationshipName,
8325
+ lhs_modelNames: [modelName],
8326
+ lhs_baseModelName: baseModelName,
8327
+ lhs_relationshipName: relationshipName,
8328
+ lhs_relationshipMeta: relationshipMeta,
8329
+ lhs_isPolymorphic: selfIsPolymorphic,
8330
+ rhs_key: inverseBaseModelName + ':' + inverseRelationshipName,
8331
+ rhs_modelNames: [],
8332
+ rhs_baseModelName: inverseBaseModelName,
8333
+ rhs_relationshipName: inverseRelationshipName,
8334
+ rhs_relationshipMeta: inverseRelationshipMeta,
8335
+ rhs_isPolymorphic: inverseRelationshipMeta.options !== undefined && inverseRelationshipMeta.options.polymorphic === true,
8336
+ hasInverse: true,
8337
+ isSelfReferential: isSelfReferential,
8338
+ isReflexive: isSelfReferential && relationshipName === inverseRelationshipName
8339
+ };
8340
+
8341
+ // Create entries for the baseModelName as well as modelName to speed up
8342
+ // inverse lookups
8343
+ inverseCache.set(baseModelName, relationshipName, info);
8344
+ inverseCache.set(modelName, relationshipName, info);
8345
+
8346
+ // Greedily populate the inverse
8347
+ inverseCache.set(inverseBaseModelName, inverseRelationshipName, info);
8348
+
8349
+ return info;
8350
+ };
8351
+
8352
+ RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(relInfo) {
8353
+ var lhsKey = relInfo.lhs_key;
8354
+ var rhsKey = relInfo.rhs_key;
8355
+ var existingPayloads = this._cache[lhsKey];
8356
+
8357
+ if (relInfo.hasInverse === true && relInfo.rhs_isPolymorphic === true) {
8358
+ existingPayloads = this._cache[rhsKey];
8359
+
8360
+ if (existingPayloads !== undefined) {
8361
+ this._cache[lhsKey] = existingPayloads;
8362
+ return existingPayloads;
8363
+ }
8364
+ }
8267
8365
 
8268
8366
  // populate the cache for both sides of the relationship, as they both use
8269
8367
  // the same `RelationshipPayloads`.
@@ -8271,7 +8369,13 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8271
8369
  // This works out better than creating a single common key, because to
8272
8370
  // compute that key we would need to do work to look up the inverse
8273
8371
  //
8274
- return this._cache[lhsKey] = this._cache[rhsKey] = new _relationshipPayloads.default(this._store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta);
8372
+ var cache = this._cache[lhsKey] = new _relationshipPayloads.default(relInfo);
8373
+
8374
+ if (relInfo.hasInverse === true) {
8375
+ this._cache[rhsKey] = cache;
8376
+ }
8377
+
8378
+ return cache;
8275
8379
  };
8276
8380
 
8277
8381
  return RelationshipPayloadsManager;
@@ -8284,12 +8388,6 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8284
8388
 
8285
8389
  exports.__esModule = true;
8286
8390
 
8287
- function _classCallCheck(instance, Constructor) {
8288
- if (!(instance instanceof Constructor)) {
8289
- throw new TypeError("Cannot call a class as a function");
8290
- }
8291
- }
8292
-
8293
8391
  var _createClass = function () {
8294
8392
  function defineProperties(target, props) {
8295
8393
  for (var i = 0; i < props.length; i++) {
@@ -8308,38 +8406,62 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8308
8406
  };
8309
8407
  }();
8310
8408
 
8311
- var RelationshipPayloads = function () {
8312
- function RelationshipPayloads(store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta) {
8313
- _classCallCheck(this, RelationshipPayloads);
8409
+ function _classCallCheck(instance, Constructor) {
8410
+ if (!(instance instanceof Constructor)) {
8411
+ throw new TypeError("Cannot call a class as a function");
8412
+ }
8413
+ }
8314
8414
 
8315
- this._store = store;
8415
+ var TypeCache = exports.TypeCache = function () {
8416
+ function TypeCache() {
8417
+ _classCallCheck(this, TypeCache);
8316
8418
 
8317
- this._lhsModelName = modelName;
8318
- this._lhsRelationshipName = relationshipName;
8319
- this._lhsRelationshipMeta = relationshipMeta;
8419
+ this.types = Object.create(null);
8420
+ }
8320
8421
 
8321
- this._rhsModelName = inverseModelName;
8322
- this._rhsRelationshipName = inverseRelationshipName;
8323
- this._rhsRelationshipMeta = inverseRelationshipMeta;
8422
+ TypeCache.prototype.get = function get(modelName, id) {
8423
+ var types = this.types;
8324
8424
 
8325
- // a map of id -> payloads for the left hand side of the relationship.
8326
- this._lhsPayloads = Object.create(null);
8327
- if (modelName !== inverseModelName || relationshipName !== inverseRelationshipName) {
8328
- // The common case of a non-reflexive relationship, or a reflexive
8329
- // relationship whose inverse is not itself
8330
- this._rhsPayloads = Object.create(null);
8331
- this._isReflexive = false;
8332
- } else {
8333
- // Edge case when we have a reflexive relationship to itself
8334
- // eg user hasMany friends inverse friends
8335
- //
8336
- // In this case there aren't really two sides to the relationship, but
8337
- // we set `_rhsPayloads = _lhsPayloads` to make things easier to reason
8338
- // about
8339
- this._rhsPayloads = this._lhsPayloads;
8340
- this._isReflexive = true;
8425
+
8426
+ if (types[modelName] !== undefined) {
8427
+ return types[modelName][id];
8428
+ }
8429
+ };
8430
+
8431
+ TypeCache.prototype.set = function set(modelName, id, payload) {
8432
+ var types = this.types;
8433
+
8434
+ var typeMap = types[modelName];
8435
+
8436
+ if (typeMap === undefined) {
8437
+ typeMap = types[modelName] = Object.create(null);
8341
8438
  }
8342
8439
 
8440
+ typeMap[id] = payload;
8441
+ };
8442
+
8443
+ TypeCache.prototype.delete = function _delete(modelName, id) {
8444
+ var types = this.types;
8445
+
8446
+
8447
+ if (types[modelName] !== undefined) {
8448
+ delete types[modelName][id];
8449
+ }
8450
+ };
8451
+
8452
+ return TypeCache;
8453
+ }();
8454
+
8455
+ var RelationshipPayloads = function () {
8456
+ function RelationshipPayloads(relInfo) {
8457
+ _classCallCheck(this, RelationshipPayloads);
8458
+
8459
+ this._relInfo = relInfo;
8460
+
8461
+ // a map of id -> payloads for the left hand side of the relationship.
8462
+ this.lhs_payloads = new TypeCache();
8463
+ this.rhs_payloads = relInfo.isReflexive ? this.lhs_payloads : new TypeCache();
8464
+
8343
8465
  // When we push relationship payloads, just stash them in a queue until
8344
8466
  // somebody actually asks for one of them.
8345
8467
  //
@@ -8349,22 +8471,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8349
8471
  }
8350
8472
 
8351
8473
  /**
8352
- Get the payload for the relationship of an individual record.
8353
- This might return the raw payload as pushed into the store, or one computed
8354
- from the payload of the inverse relationship.
8355
- @method
8356
- */
8474
+ Get the payload for the relationship of an individual record.
8475
+ This might return the raw payload as pushed into the store, or one computed
8476
+ from the payload of the inverse relationship.
8477
+ @method
8478
+ */
8357
8479
 
8358
8480
 
8359
8481
  RelationshipPayloads.prototype.get = function get(modelName, id, relationshipName) {
8360
8482
  this._flushPending();
8361
8483
 
8362
8484
  if (this._isLHS(modelName, relationshipName)) {
8363
- return this._lhsPayloads[id];
8485
+ return this.lhs_payloads.get(modelName, id);
8364
8486
  } else {
8365
- (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
8487
+ (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName)));
8366
8488
 
8367
- return this._rhsPayloads[id];
8489
+ return this.rhs_payloads.get(modelName, id);
8368
8490
  }
8369
8491
  };
8370
8492
 
@@ -8376,20 +8498,40 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8376
8498
  this._flushPending();
8377
8499
 
8378
8500
  if (this._isLHS(modelName, relationshipName)) {
8379
- delete this._lhsPayloads[id];
8501
+ delete this.lhs_payloads.delete(modelName, id);
8380
8502
  } else {
8381
- (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
8503
+ (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)));
8382
8504
 
8383
- delete this._rhsPayloads[id];
8505
+ delete this.rhs_payloads.delete(modelName, id);
8384
8506
  }
8385
8507
  };
8386
8508
 
8387
8509
  RelationshipPayloads.prototype._isLHS = function _isLHS(modelName, relationshipName) {
8388
- return modelName === this._lhsModelName && relationshipName === this._lhsRelationshipName;
8510
+ var relInfo = this._relInfo;
8511
+ var isSelfReferential = relInfo.isSelfReferential;
8512
+ var isRelationship = relationshipName === relInfo.lhs_relationshipName;
8513
+
8514
+ if (isRelationship === true) {
8515
+ return isSelfReferential === true || // itself
8516
+ modelName === relInfo.lhs_baseModelName || // base or non-polymorphic
8517
+ relInfo.lhs_modelNames.indexOf(modelName) !== -1; // polymorphic
8518
+ }
8519
+
8520
+ return false;
8389
8521
  };
8390
8522
 
8391
8523
  RelationshipPayloads.prototype._isRHS = function _isRHS(modelName, relationshipName) {
8392
- return modelName === this._rhsModelName && relationshipName === this._rhsRelationshipName;
8524
+ var relInfo = this._relInfo;
8525
+ var isSelfReferential = relInfo.isSelfReferential;
8526
+ var isRelationship = relationshipName === relInfo.rhs_relationshipName;
8527
+
8528
+ if (isRelationship === true) {
8529
+ return isSelfReferential === true || // itself
8530
+ modelName === relInfo.rhs_baseModelName || // base or non-polymorphic
8531
+ relInfo.rhs_modelNames.indexOf(modelName) !== -1; // polymorphic
8532
+ }
8533
+
8534
+ return false;
8393
8535
  };
8394
8536
 
8395
8537
  RelationshipPayloads.prototype._flushPending = function _flushPending() {
@@ -8410,26 +8552,28 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8410
8552
  id: id,
8411
8553
  type: modelName
8412
8554
  }
8555
+ };
8413
8556
 
8414
- // start flushing this individual payload. The logic is the same whether
8415
- // it's for the left hand side of the relationship or the right hand side,
8416
- // except the role of primary and inverse idToPayloads is reversed
8417
- //
8418
- };var previousPayload = void 0;
8419
- var idToPayloads = void 0;
8420
- var inverseIdToPayloads = void 0;
8557
+ // start flushing this individual payload. The logic is the same whether
8558
+ // it's for the left hand side of the relationship or the right hand side,
8559
+ // except the role of primary and inverse idToPayloads is reversed
8560
+ //
8561
+ var previousPayload = void 0;
8562
+ var payloadMap = void 0;
8563
+ var inversePayloadMap = void 0;
8421
8564
  var inverseIsMany = void 0;
8565
+
8422
8566
  if (this._isLHS(modelName, relationshipName)) {
8423
- previousPayload = this._lhsPayloads[id];
8424
- idToPayloads = this._lhsPayloads;
8425
- inverseIdToPayloads = this._rhsPayloads;
8567
+ previousPayload = this.lhs_payloads.get(modelName, id);
8568
+ payloadMap = this.lhs_payloads;
8569
+ inversePayloadMap = this.rhs_payloads;
8426
8570
  inverseIsMany = this._rhsRelationshipIsMany;
8427
8571
  } else {
8428
- (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
8572
+ (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName)));
8429
8573
 
8430
- previousPayload = this._rhsPayloads[id];
8431
- idToPayloads = this._rhsPayloads;
8432
- inverseIdToPayloads = this._lhsPayloads;
8574
+ previousPayload = this.rhs_payloads.get(modelName, id);
8575
+ payloadMap = this.rhs_payloads;
8576
+ inversePayloadMap = this.lhs_payloads;
8433
8577
  inverseIsMany = this._lhsRelationshipIsMany;
8434
8578
  }
8435
8579
 
@@ -8473,14 +8617,14 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8473
8617
  // * undefined is NOT considered new information, we should keep original state
8474
8618
  // * anything else is considered new information, and it should win
8475
8619
  if (relationshipData.data !== undefined) {
8476
- this._removeInverse(id, previousPayload, inverseIdToPayloads);
8620
+ this._removeInverse(id, previousPayload, inversePayloadMap);
8477
8621
  }
8478
- idToPayloads[id] = relationshipData;
8479
- this._populateInverse(relationshipData, inverseRelationshipData, inverseIdToPayloads, inverseIsMany);
8622
+ payloadMap.set(modelName, id, relationshipData);
8623
+ this._populateInverse(relationshipData, inverseRelationshipData, inversePayloadMap, inverseIsMany);
8480
8624
  }
8481
8625
  };
8482
8626
 
8483
- RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inverseIdToPayloads, inverseIsMany) {
8627
+ RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inversePayloadMap, inverseIsMany) {
8484
8628
  if (!relationshipData.data) {
8485
8629
  // This id doesn't have an inverse, eg a belongsTo with a payload
8486
8630
  // { data: null }, so there's nothing to populate
@@ -8489,22 +8633,24 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8489
8633
 
8490
8634
  if (Array.isArray(relationshipData.data)) {
8491
8635
  for (var i = 0; i < relationshipData.data.length; ++i) {
8492
- var inverseId = relationshipData.data[i].id;
8493
- this._addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany);
8636
+ var resourceIdentifier = relationshipData.data[i];
8637
+ this._addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany);
8494
8638
  }
8495
8639
  } else {
8496
- var _inverseId = relationshipData.data.id;
8497
- this._addToInverse(inversePayload, _inverseId, inverseIdToPayloads, inverseIsMany);
8640
+ var _resourceIdentifier = relationshipData.data;
8641
+ this._addToInverse(inversePayload, _resourceIdentifier, inversePayloadMap, inverseIsMany);
8498
8642
  }
8499
8643
  };
8500
8644
 
8501
- RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany) {
8502
- if (this._isReflexive && inversePayload.data.id === inverseId) {
8645
+ RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany) {
8646
+ var relInfo = this._relInfo;
8647
+
8648
+ if (relInfo.isReflexive && inversePayload.data.id === resourceIdentifier.id) {
8503
8649
  // eg <user:1>.friends = [{ id: 1, type: 'user' }]
8504
8650
  return;
8505
8651
  }
8506
8652
 
8507
- var existingPayload = inverseIdToPayloads[inverseId];
8653
+ var existingPayload = inversePayloadMap.get(resourceIdentifier.type, resourceIdentifier.id);
8508
8654
  var existingData = existingPayload && existingPayload.data;
8509
8655
 
8510
8656
  if (existingData) {
@@ -8514,22 +8660,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8514
8660
  if (Array.isArray(existingData)) {
8515
8661
  existingData.push(inversePayload.data);
8516
8662
  } else {
8517
- inverseIdToPayloads[inverseId] = inversePayload;
8663
+ inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload);
8518
8664
  }
8519
8665
  } else {
8520
8666
  // first time we're populating the inverse side
8521
8667
  //
8522
8668
  if (inverseIsMany) {
8523
- inverseIdToPayloads[inverseId] = {
8669
+ inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, {
8524
8670
  data: [inversePayload.data]
8525
- };
8671
+ });
8526
8672
  } else {
8527
- inverseIdToPayloads[inverseId] = inversePayload;
8673
+ inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload);
8528
8674
  }
8529
8675
  }
8530
8676
  };
8531
8677
 
8532
- RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inverseIdToPayloads) {
8678
+ RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inversePayloadMap) {
8533
8679
  var data = previousPayload && previousPayload.data;
8534
8680
  if (!data) {
8535
8681
  // either this is the first time we've seen a payload for this id, or its
@@ -8544,15 +8690,16 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8544
8690
  if (Array.isArray(data)) {
8545
8691
  // TODO: diff rather than removeall addall?
8546
8692
  for (var i = 0; i < data.length; ++i) {
8547
- this._removeFromInverse(id, data[i].id, inverseIdToPayloads);
8693
+ var resourceIdentifier = data[i];
8694
+ this._removeFromInverse(id, resourceIdentifier, inversePayloadMap);
8548
8695
  }
8549
8696
  } else {
8550
- this._removeFromInverse(id, data.id, inverseIdToPayloads);
8697
+ this._removeFromInverse(id, data, inversePayloadMap);
8551
8698
  }
8552
8699
  };
8553
8700
 
8554
- RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, inverseId, inversePayloads) {
8555
- var inversePayload = inversePayloads[inverseId];
8701
+ RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, resourceIdentifier, inversePayloads) {
8702
+ var inversePayload = inversePayloads.get(resourceIdentifier.type, resourceIdentifier.id);
8556
8703
  var data = inversePayload && inversePayload.data;
8557
8704
 
8558
8705
  if (!data) {
@@ -8564,21 +8711,23 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8564
8711
  return x.id !== id;
8565
8712
  });
8566
8713
  } else {
8567
- inversePayloads[inverseId] = {
8714
+ inversePayloads.set(resourceIdentifier.type, resourceIdentifier.id, {
8568
8715
  data: null
8569
- };
8716
+ });
8570
8717
  }
8571
8718
  };
8572
8719
 
8573
8720
  _createClass(RelationshipPayloads, [{
8574
8721
  key: '_lhsRelationshipIsMany',
8575
8722
  get: function () {
8576
- return this._lhsRelationshipMeta && this._lhsRelationshipMeta.kind === 'hasMany';
8723
+ var meta = this._relInfo.lhs_relationshipMeta;
8724
+ return meta !== null && meta.kind === 'hasMany';
8577
8725
  }
8578
8726
  }, {
8579
8727
  key: '_rhsRelationshipIsMany',
8580
8728
  get: function () {
8581
- return this._rhsRelationshipMeta && this._rhsRelationshipMeta.kind === 'hasMany';
8729
+ var meta = this._relInfo.rhs_relationshipMeta;
8730
+ return meta !== null && meta.kind === 'hasMany';
8582
8731
  }
8583
8732
  }]);
8584
8733
 
@@ -18444,7 +18593,7 @@ define("ember-data/version", ["exports"], function (exports) {
18444
18593
  "use strict";
18445
18594
 
18446
18595
  exports.__esModule = true;
18447
- exports.default = "2.15.3";
18596
+ exports.default = "2.15.4";
18448
18597
  });
18449
18598
  define("ember-inflector", ["module", "exports", "ember", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (module, exports, _ember, _system) {
18450
18599
  "use strict";