ember-data-source 2.16.1 → 2.16.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: 85649327e2852ecd981553c47ebafda53ad3a1c7
4
- data.tar.gz: 2e4562075e02d6328dd96e1cdc2c4072160f88ae
3
+ metadata.gz: 4c5b90c9ff97dfbcc9ed8c8ab13c9836ef49b207
4
+ data.tar.gz: 80b2b487ad5e627347751cb413ed0031e74a27c1
5
5
  SHA512:
6
- metadata.gz: ad567db5a1215f841f6582721d4bed5004e8884800b1731086edd1bbd18aec2411f00718c67337087d3dd3df86e3d007838eea0a47f1d3670aacbbd27ac0b106
7
- data.tar.gz: 1a35919ce485f24830be3509f0989fe43e9ce6a33e4ffbd002737e432bc7bf68df647644bce1d69f093c7d30a7235fa3936af9c7e043510d0f463f41bc2b3be5
6
+ metadata.gz: 0244b9de6b874ad35c685c5bbefaaf2cf8258934b8807e24a8d8a906cab63829a8881b4bbe4c1f511951672403fa56f2247bf06ecbb38f105a30fcb82a73607d
7
+ data.tar.gz: 5e4b6be7d269ab882a74e9dff4c86e63890ed8b72f515af7a46ba7610d2b4c92347a1907aadd5eba10567c91a6cb2d38c18f2f862ccb159413b5b7866822caf7
@@ -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.16.1
9
+ * @version 2.16.4
10
10
  */
11
11
 
12
12
  var loader, define, requireModule, require, requirejs;
@@ -4806,6 +4806,10 @@ define('ember-data/-private/system/model/model', ['exports', 'ember', 'ember-dat
4806
4806
  // the computed property.
4807
4807
  var meta = value.meta();
4808
4808
 
4809
+ /*
4810
+ This is buggy because if the parent has never been looked up
4811
+ via `modelFor` it will not have `modelName` set.
4812
+ */
4809
4813
  meta.parentType = proto.constructor;
4810
4814
  }
4811
4815
  }
@@ -7595,7 +7599,7 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
7595
7599
  }
7596
7600
 
7597
7601
  function relationshipFromMeta(meta) {
7598
- var result = {
7602
+ return {
7599
7603
  key: meta.key,
7600
7604
  kind: meta.kind,
7601
7605
  type: typeForRelationshipMeta(meta),
@@ -7604,12 +7608,6 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
7604
7608
  parentType: meta.parentType,
7605
7609
  isRelationship: true
7606
7610
  };
7607
-
7608
- if (false) {
7609
- result.parentType = meta.parentType;
7610
- }
7611
-
7612
- return result;
7613
7611
  }
7614
7612
  });
7615
7613
  define('ember-data/-private/system/relationships/belongs-to', ['exports', 'ember', 'ember-data/-private/system/normalize-model-name'], function (exports, _ember, _normalizeModelName) {
@@ -8015,7 +8013,8 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8015
8013
  }
8016
8014
  }
8017
8015
 
8018
- var _get = _ember.default.get;
8016
+ var get = _ember.default.get;
8017
+ var assert = _ember.default.assert;
8019
8018
 
8020
8019
  /**
8021
8020
  Manages relationship payloads for a given store, for uninitialized
@@ -8078,6 +8077,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8078
8077
  this._store = store;
8079
8078
  // cache of `RelationshipPayload`s
8080
8079
  this._cache = Object.create(null);
8080
+ this._inverseLookupCache = new _relationshipPayloads.TypeCache();
8081
8081
  }
8082
8082
 
8083
8083
  /**
@@ -8098,9 +8098,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8098
8098
 
8099
8099
 
8100
8100
  RelationshipPayloadsManager.prototype.get = function get(modelName, id, relationshipName) {
8101
- var modelClass = this._store._modelFor(modelName);
8102
- var relationshipsByName = _get(modelClass, 'relationshipsByName');
8103
- var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
8101
+ var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, false);
8104
8102
  return relationshipPayloads && relationshipPayloads.get(modelName, id, relationshipName);
8105
8103
  };
8106
8104
 
@@ -8111,10 +8109,8 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8111
8109
  return;
8112
8110
  }
8113
8111
 
8114
- var modelClass = this._store._modelFor(modelName);
8115
- var relationshipsByName = _get(modelClass, 'relationshipsByName');
8116
8112
  Object.keys(relationshipsData).forEach(function (key) {
8117
- var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, modelClass, relationshipsByName, true);
8113
+ var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, true);
8118
8114
  if (relationshipPayloads) {
8119
8115
  relationshipPayloads.push(modelName, id, key, relationshipsData[key]);
8120
8116
  }
@@ -8125,51 +8121,153 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8125
8121
  var _this2 = this;
8126
8122
 
8127
8123
  var modelClass = this._store._modelFor(modelName);
8128
- var relationshipsByName = _get(modelClass, 'relationshipsByName');
8124
+ var relationshipsByName = get(modelClass, 'relationshipsByName');
8129
8125
  relationshipsByName.forEach(function (_, relationshipName) {
8130
- var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
8126
+ var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, false);
8131
8127
  if (relationshipPayloads) {
8132
8128
  relationshipPayloads.unload(modelName, id, relationshipName);
8133
8129
  }
8134
8130
  });
8135
8131
  };
8136
8132
 
8137
- RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, init) {
8138
- if (!relationshipsByName.has(relationshipName)) {
8133
+ RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, init) {
8134
+ var relInfo = this.getRelationshipInfo(modelName, relationshipName);
8135
+
8136
+ if (relInfo === null) {
8139
8137
  return;
8140
8138
  }
8141
8139
 
8142
- var key = modelName + ':' + relationshipName;
8143
- if (!this._cache[key] && init) {
8144
- return this._initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName);
8140
+ var cache = this._cache[relInfo.lhs_key];
8141
+
8142
+ if (!cache && init) {
8143
+ return this._initializeRelationshipPayloads(relInfo);
8145
8144
  }
8146
8145
 
8147
- return this._cache[key];
8146
+ return cache;
8148
8147
  };
8149
8148
 
8150
- RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName) {
8149
+ RelationshipPayloadsManager.prototype.getRelationshipInfo = function getRelationshipInfo(modelName, relationshipName) {
8150
+ var inverseCache = this._inverseLookupCache;
8151
+ var store = this._store;
8152
+ var cached = inverseCache.get(modelName, relationshipName);
8153
+
8154
+ // CASE: We have a cached resolution (null if no relationship exists)
8155
+ if (cached !== undefined) {
8156
+ return cached;
8157
+ }
8158
+
8159
+ var modelClass = store._modelFor(modelName);
8160
+ var relationshipsByName = get(modelClass, 'relationshipsByName');
8161
+
8162
+ // CASE: We don't have a relationship at all
8163
+ if (!relationshipsByName.has(relationshipName)) {
8164
+ inverseCache.set(modelName, relationshipName, null);
8165
+ return null;
8166
+ }
8167
+
8168
+ var inverseMeta = modelClass.inverseFor(relationshipName, store);
8151
8169
  var relationshipMeta = relationshipsByName.get(relationshipName);
8152
- var inverseMeta = modelClass.inverseFor(relationshipName, this._store);
8153
-
8154
- var inverseModelName = void 0;
8155
- var inverseRelationshipName = void 0;
8156
- var inverseRelationshipMeta = void 0;
8157
-
8158
- // figure out the inverse relationship; we need two things
8159
- // a) the inverse model name
8160
- //- b) the name of the inverse relationship
8161
- if (inverseMeta) {
8162
- inverseRelationshipName = inverseMeta.name;
8163
- inverseModelName = relationshipMeta.type;
8164
- inverseRelationshipMeta = _get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
8165
- } else {
8166
- // relationship has no inverse
8167
- inverseModelName = inverseRelationshipName = '';
8168
- inverseRelationshipMeta = null;
8170
+ var selfIsPolymorphic = relationshipMeta.options !== undefined && relationshipMeta.options.polymorphic === true;
8171
+ var inverseBaseModelName = relationshipMeta.type;
8172
+
8173
+ // CASE: We have no inverse
8174
+ if (!inverseMeta) {
8175
+ var _info = {
8176
+ lhs_key: modelName + ':' + relationshipName,
8177
+ lhs_modelNames: [modelName],
8178
+ lhs_baseModelName: modelName,
8179
+ lhs_relationshipName: relationshipName,
8180
+ lhs_relationshipMeta: relationshipMeta,
8181
+ lhs_isPolymorphic: selfIsPolymorphic,
8182
+ rhs_key: '',
8183
+ rhs_modelNames: [],
8184
+ rhs_baseModelName: inverseBaseModelName,
8185
+ rhs_relationshipName: '',
8186
+ rhs_relationshipMeta: null,
8187
+ rhs_isPolymorphic: false,
8188
+ hasInverse: false,
8189
+ isSelfReferential: false, // modelName === inverseBaseModelName,
8190
+ isReflexive: false
8191
+ };
8192
+
8193
+ inverseCache.set(modelName, relationshipName, _info);
8194
+
8195
+ return _info;
8169
8196
  }
8170
8197
 
8171
- var lhsKey = modelName + ':' + relationshipName;
8172
- var rhsKey = inverseModelName + ':' + inverseRelationshipName;
8198
+ // CASE: We do have an inverse
8199
+
8200
+ var inverseRelationshipName = inverseMeta.name;
8201
+ var inverseRelationshipMeta = get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
8202
+ var baseModelName = inverseRelationshipMeta.type;
8203
+ var isSelfReferential = baseModelName === inverseBaseModelName;
8204
+
8205
+ // TODO we want to assert this but this breaks all of our shoddily written tests
8206
+ /*
8207
+ if (DEBUG) {
8208
+ let inverseDoubleCheck = inverseMeta.type.inverseFor(inverseRelationshipName, store);
8209
+ assert(`The ${inverseBaseModelName}:${inverseRelationshipName} relationship declares 'inverse: null', but it was resolved as the inverse for ${baseModelName}:${relationshipName}.`, inverseDoubleCheck);
8210
+ }
8211
+ */
8212
+
8213
+ // CASE: We may have already discovered the inverse for the baseModelName
8214
+ // CASE: We have already discovered the inverse
8215
+ cached = inverseCache.get(baseModelName, relationshipName) || inverseCache.get(inverseBaseModelName, inverseRelationshipName);
8216
+ if (cached) {
8217
+ // TODO this assert can be removed if the above assert is enabled
8218
+ assert('The ' + inverseBaseModelName + ':' + inverseRelationshipName + ' relationship declares \'inverse: null\', but it was resolved as the inverse for ' + baseModelName + ':' + relationshipName + '.', cached.hasInverse !== false);
8219
+
8220
+ var isLHS = cached.lhs_baseModelName === baseModelName;
8221
+ var modelNames = isLHS ? cached.lhs_modelNames : cached.rhs_modelNames;
8222
+ // make this lookup easier in the future by caching the key
8223
+ modelNames.push(modelName);
8224
+ inverseCache.set(modelName, relationshipName, cached);
8225
+
8226
+ return cached;
8227
+ }
8228
+
8229
+ var info = {
8230
+ lhs_key: baseModelName + ':' + relationshipName,
8231
+ lhs_modelNames: [modelName],
8232
+ lhs_baseModelName: baseModelName,
8233
+ lhs_relationshipName: relationshipName,
8234
+ lhs_relationshipMeta: relationshipMeta,
8235
+ lhs_isPolymorphic: selfIsPolymorphic,
8236
+ rhs_key: inverseBaseModelName + ':' + inverseRelationshipName,
8237
+ rhs_modelNames: [],
8238
+ rhs_baseModelName: inverseBaseModelName,
8239
+ rhs_relationshipName: inverseRelationshipName,
8240
+ rhs_relationshipMeta: inverseRelationshipMeta,
8241
+ rhs_isPolymorphic: inverseRelationshipMeta.options !== undefined && inverseRelationshipMeta.options.polymorphic === true,
8242
+ hasInverse: true,
8243
+ isSelfReferential: isSelfReferential,
8244
+ isReflexive: isSelfReferential && relationshipName === inverseRelationshipName
8245
+ };
8246
+
8247
+ // Create entries for the baseModelName as well as modelName to speed up
8248
+ // inverse lookups
8249
+ inverseCache.set(baseModelName, relationshipName, info);
8250
+ inverseCache.set(modelName, relationshipName, info);
8251
+
8252
+ // Greedily populate the inverse
8253
+ inverseCache.set(inverseBaseModelName, inverseRelationshipName, info);
8254
+
8255
+ return info;
8256
+ };
8257
+
8258
+ RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(relInfo) {
8259
+ var lhsKey = relInfo.lhs_key;
8260
+ var rhsKey = relInfo.rhs_key;
8261
+ var existingPayloads = this._cache[lhsKey];
8262
+
8263
+ if (relInfo.hasInverse === true && relInfo.rhs_isPolymorphic === true) {
8264
+ existingPayloads = this._cache[rhsKey];
8265
+
8266
+ if (existingPayloads !== undefined) {
8267
+ this._cache[lhsKey] = existingPayloads;
8268
+ return existingPayloads;
8269
+ }
8270
+ }
8173
8271
 
8174
8272
  // populate the cache for both sides of the relationship, as they both use
8175
8273
  // the same `RelationshipPayloads`.
@@ -8177,7 +8275,13 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8177
8275
  // This works out better than creating a single common key, because to
8178
8276
  // compute that key we would need to do work to look up the inverse
8179
8277
  //
8180
- return this._cache[lhsKey] = this._cache[rhsKey] = new _relationshipPayloads.default(this._store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta);
8278
+ var cache = this._cache[lhsKey] = new _relationshipPayloads.default(relInfo);
8279
+
8280
+ if (relInfo.hasInverse === true) {
8281
+ this._cache[rhsKey] = cache;
8282
+ }
8283
+
8284
+ return cache;
8181
8285
  };
8182
8286
 
8183
8287
  return RelationshipPayloadsManager;
@@ -8190,12 +8294,6 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8190
8294
 
8191
8295
  exports.__esModule = true;
8192
8296
 
8193
- function _classCallCheck(instance, Constructor) {
8194
- if (!(instance instanceof Constructor)) {
8195
- throw new TypeError("Cannot call a class as a function");
8196
- }
8197
- }
8198
-
8199
8297
  var _createClass = function () {
8200
8298
  function defineProperties(target, props) {
8201
8299
  for (var i = 0; i < props.length; i++) {
@@ -8214,38 +8312,62 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8214
8312
  };
8215
8313
  }();
8216
8314
 
8217
- var RelationshipPayloads = function () {
8218
- function RelationshipPayloads(store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta) {
8219
- _classCallCheck(this, RelationshipPayloads);
8315
+ function _classCallCheck(instance, Constructor) {
8316
+ if (!(instance instanceof Constructor)) {
8317
+ throw new TypeError("Cannot call a class as a function");
8318
+ }
8319
+ }
8220
8320
 
8221
- this._store = store;
8321
+ var TypeCache = exports.TypeCache = function () {
8322
+ function TypeCache() {
8323
+ _classCallCheck(this, TypeCache);
8222
8324
 
8223
- this._lhsModelName = modelName;
8224
- this._lhsRelationshipName = relationshipName;
8225
- this._lhsRelationshipMeta = relationshipMeta;
8325
+ this.types = Object.create(null);
8326
+ }
8226
8327
 
8227
- this._rhsModelName = inverseModelName;
8228
- this._rhsRelationshipName = inverseRelationshipName;
8229
- this._rhsRelationshipMeta = inverseRelationshipMeta;
8328
+ TypeCache.prototype.get = function get(modelName, id) {
8329
+ var types = this.types;
8230
8330
 
8231
- // a map of id -> payloads for the left hand side of the relationship.
8232
- this._lhsPayloads = Object.create(null);
8233
- if (modelName !== inverseModelName || relationshipName !== inverseRelationshipName) {
8234
- // The common case of a non-reflexive relationship, or a reflexive
8235
- // relationship whose inverse is not itself
8236
- this._rhsPayloads = Object.create(null);
8237
- this._isReflexive = false;
8238
- } else {
8239
- // Edge case when we have a reflexive relationship to itself
8240
- // eg user hasMany friends inverse friends
8241
- //
8242
- // In this case there aren't really two sides to the relationship, but
8243
- // we set `_rhsPayloads = _lhsPayloads` to make things easier to reason
8244
- // about
8245
- this._rhsPayloads = this._lhsPayloads;
8246
- this._isReflexive = true;
8331
+
8332
+ if (types[modelName] !== undefined) {
8333
+ return types[modelName][id];
8334
+ }
8335
+ };
8336
+
8337
+ TypeCache.prototype.set = function set(modelName, id, payload) {
8338
+ var types = this.types;
8339
+
8340
+ var typeMap = types[modelName];
8341
+
8342
+ if (typeMap === undefined) {
8343
+ typeMap = types[modelName] = Object.create(null);
8247
8344
  }
8248
8345
 
8346
+ typeMap[id] = payload;
8347
+ };
8348
+
8349
+ TypeCache.prototype.delete = function _delete(modelName, id) {
8350
+ var types = this.types;
8351
+
8352
+
8353
+ if (types[modelName] !== undefined) {
8354
+ delete types[modelName][id];
8355
+ }
8356
+ };
8357
+
8358
+ return TypeCache;
8359
+ }();
8360
+
8361
+ var RelationshipPayloads = function () {
8362
+ function RelationshipPayloads(relInfo) {
8363
+ _classCallCheck(this, RelationshipPayloads);
8364
+
8365
+ this._relInfo = relInfo;
8366
+
8367
+ // a map of id -> payloads for the left hand side of the relationship.
8368
+ this.lhs_payloads = new TypeCache();
8369
+ this.rhs_payloads = relInfo.isReflexive ? this.lhs_payloads : new TypeCache();
8370
+
8249
8371
  // When we push relationship payloads, just stash them in a queue until
8250
8372
  // somebody actually asks for one of them.
8251
8373
  //
@@ -8255,22 +8377,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8255
8377
  }
8256
8378
 
8257
8379
  /**
8258
- Get the payload for the relationship of an individual record.
8259
- This might return the raw payload as pushed into the store, or one computed
8260
- from the payload of the inverse relationship.
8261
- @method
8262
- */
8380
+ Get the payload for the relationship of an individual record.
8381
+ This might return the raw payload as pushed into the store, or one computed
8382
+ from the payload of the inverse relationship.
8383
+ @method
8384
+ */
8263
8385
 
8264
8386
 
8265
8387
  RelationshipPayloads.prototype.get = function get(modelName, id, relationshipName) {
8266
8388
  this._flushPending();
8267
8389
 
8268
8390
  if (this._isLHS(modelName, relationshipName)) {
8269
- return this._lhsPayloads[id];
8391
+ return this.lhs_payloads.get(modelName, id);
8270
8392
  } else {
8271
- (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
8393
+ (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName)));
8272
8394
 
8273
- return this._rhsPayloads[id];
8395
+ return this.rhs_payloads.get(modelName, id);
8274
8396
  }
8275
8397
  };
8276
8398
 
@@ -8282,20 +8404,40 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8282
8404
  this._flushPending();
8283
8405
 
8284
8406
  if (this._isLHS(modelName, relationshipName)) {
8285
- delete this._lhsPayloads[id];
8407
+ delete this.lhs_payloads.delete(modelName, id);
8286
8408
  } else {
8287
- (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
8409
+ (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)));
8288
8410
 
8289
- delete this._rhsPayloads[id];
8411
+ delete this.rhs_payloads.delete(modelName, id);
8290
8412
  }
8291
8413
  };
8292
8414
 
8293
8415
  RelationshipPayloads.prototype._isLHS = function _isLHS(modelName, relationshipName) {
8294
- return modelName === this._lhsModelName && relationshipName === this._lhsRelationshipName;
8416
+ var relInfo = this._relInfo;
8417
+ var isSelfReferential = relInfo.isSelfReferential;
8418
+ var isRelationship = relationshipName === relInfo.lhs_relationshipName;
8419
+
8420
+ if (isRelationship === true) {
8421
+ return isSelfReferential === true || // itself
8422
+ modelName === relInfo.lhs_baseModelName || // base or non-polymorphic
8423
+ relInfo.lhs_modelNames.indexOf(modelName) !== -1; // polymorphic
8424
+ }
8425
+
8426
+ return false;
8295
8427
  };
8296
8428
 
8297
8429
  RelationshipPayloads.prototype._isRHS = function _isRHS(modelName, relationshipName) {
8298
- return modelName === this._rhsModelName && relationshipName === this._rhsRelationshipName;
8430
+ var relInfo = this._relInfo;
8431
+ var isSelfReferential = relInfo.isSelfReferential;
8432
+ var isRelationship = relationshipName === relInfo.rhs_relationshipName;
8433
+
8434
+ if (isRelationship === true) {
8435
+ return isSelfReferential === true || // itself
8436
+ modelName === relInfo.rhs_baseModelName || // base or non-polymorphic
8437
+ relInfo.rhs_modelNames.indexOf(modelName) !== -1; // polymorphic
8438
+ }
8439
+
8440
+ return false;
8299
8441
  };
8300
8442
 
8301
8443
  RelationshipPayloads.prototype._flushPending = function _flushPending() {
@@ -8316,26 +8458,28 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8316
8458
  id: id,
8317
8459
  type: modelName
8318
8460
  }
8461
+ };
8319
8462
 
8320
- // start flushing this individual payload. The logic is the same whether
8321
- // it's for the left hand side of the relationship or the right hand side,
8322
- // except the role of primary and inverse idToPayloads is reversed
8323
- //
8324
- };var previousPayload = void 0;
8325
- var idToPayloads = void 0;
8326
- var inverseIdToPayloads = void 0;
8463
+ // start flushing this individual payload. The logic is the same whether
8464
+ // it's for the left hand side of the relationship or the right hand side,
8465
+ // except the role of primary and inverse idToPayloads is reversed
8466
+ //
8467
+ var previousPayload = void 0;
8468
+ var payloadMap = void 0;
8469
+ var inversePayloadMap = void 0;
8327
8470
  var inverseIsMany = void 0;
8471
+
8328
8472
  if (this._isLHS(modelName, relationshipName)) {
8329
- previousPayload = this._lhsPayloads[id];
8330
- idToPayloads = this._lhsPayloads;
8331
- inverseIdToPayloads = this._rhsPayloads;
8473
+ previousPayload = this.lhs_payloads.get(modelName, id);
8474
+ payloadMap = this.lhs_payloads;
8475
+ inversePayloadMap = this.rhs_payloads;
8332
8476
  inverseIsMany = this._rhsRelationshipIsMany;
8333
8477
  } else {
8334
- (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
8478
+ (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName)));
8335
8479
 
8336
- previousPayload = this._rhsPayloads[id];
8337
- idToPayloads = this._rhsPayloads;
8338
- inverseIdToPayloads = this._lhsPayloads;
8480
+ previousPayload = this.rhs_payloads.get(modelName, id);
8481
+ payloadMap = this.rhs_payloads;
8482
+ inversePayloadMap = this.lhs_payloads;
8339
8483
  inverseIsMany = this._lhsRelationshipIsMany;
8340
8484
  }
8341
8485
 
@@ -8379,14 +8523,14 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8379
8523
  // * undefined is NOT considered new information, we should keep original state
8380
8524
  // * anything else is considered new information, and it should win
8381
8525
  if (relationshipData.data !== undefined) {
8382
- this._removeInverse(id, previousPayload, inverseIdToPayloads);
8526
+ this._removeInverse(id, previousPayload, inversePayloadMap);
8383
8527
  }
8384
- idToPayloads[id] = relationshipData;
8385
- this._populateInverse(relationshipData, inverseRelationshipData, inverseIdToPayloads, inverseIsMany);
8528
+ payloadMap.set(modelName, id, relationshipData);
8529
+ this._populateInverse(relationshipData, inverseRelationshipData, inversePayloadMap, inverseIsMany);
8386
8530
  }
8387
8531
  };
8388
8532
 
8389
- RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inverseIdToPayloads, inverseIsMany) {
8533
+ RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inversePayloadMap, inverseIsMany) {
8390
8534
  if (!relationshipData.data) {
8391
8535
  // This id doesn't have an inverse, eg a belongsTo with a payload
8392
8536
  // { data: null }, so there's nothing to populate
@@ -8395,22 +8539,24 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8395
8539
 
8396
8540
  if (Array.isArray(relationshipData.data)) {
8397
8541
  for (var i = 0; i < relationshipData.data.length; ++i) {
8398
- var inverseId = relationshipData.data[i].id;
8399
- this._addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany);
8542
+ var resourceIdentifier = relationshipData.data[i];
8543
+ this._addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany);
8400
8544
  }
8401
8545
  } else {
8402
- var _inverseId = relationshipData.data.id;
8403
- this._addToInverse(inversePayload, _inverseId, inverseIdToPayloads, inverseIsMany);
8546
+ var _resourceIdentifier = relationshipData.data;
8547
+ this._addToInverse(inversePayload, _resourceIdentifier, inversePayloadMap, inverseIsMany);
8404
8548
  }
8405
8549
  };
8406
8550
 
8407
- RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany) {
8408
- if (this._isReflexive && inversePayload.data.id === inverseId) {
8551
+ RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany) {
8552
+ var relInfo = this._relInfo;
8553
+
8554
+ if (relInfo.isReflexive && inversePayload.data.id === resourceIdentifier.id) {
8409
8555
  // eg <user:1>.friends = [{ id: 1, type: 'user' }]
8410
8556
  return;
8411
8557
  }
8412
8558
 
8413
- var existingPayload = inverseIdToPayloads[inverseId];
8559
+ var existingPayload = inversePayloadMap.get(resourceIdentifier.type, resourceIdentifier.id);
8414
8560
  var existingData = existingPayload && existingPayload.data;
8415
8561
 
8416
8562
  if (existingData) {
@@ -8420,22 +8566,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8420
8566
  if (Array.isArray(existingData)) {
8421
8567
  existingData.push(inversePayload.data);
8422
8568
  } else {
8423
- inverseIdToPayloads[inverseId] = inversePayload;
8569
+ inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload);
8424
8570
  }
8425
8571
  } else {
8426
8572
  // first time we're populating the inverse side
8427
8573
  //
8428
8574
  if (inverseIsMany) {
8429
- inverseIdToPayloads[inverseId] = {
8575
+ inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, {
8430
8576
  data: [inversePayload.data]
8431
- };
8577
+ });
8432
8578
  } else {
8433
- inverseIdToPayloads[inverseId] = inversePayload;
8579
+ inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload);
8434
8580
  }
8435
8581
  }
8436
8582
  };
8437
8583
 
8438
- RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inverseIdToPayloads) {
8584
+ RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inversePayloadMap) {
8439
8585
  var data = previousPayload && previousPayload.data;
8440
8586
  if (!data) {
8441
8587
  // either this is the first time we've seen a payload for this id, or its
@@ -8450,15 +8596,16 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8450
8596
  if (Array.isArray(data)) {
8451
8597
  // TODO: diff rather than removeall addall?
8452
8598
  for (var i = 0; i < data.length; ++i) {
8453
- this._removeFromInverse(id, data[i].id, inverseIdToPayloads);
8599
+ var resourceIdentifier = data[i];
8600
+ this._removeFromInverse(id, resourceIdentifier, inversePayloadMap);
8454
8601
  }
8455
8602
  } else {
8456
- this._removeFromInverse(id, data.id, inverseIdToPayloads);
8603
+ this._removeFromInverse(id, data, inversePayloadMap);
8457
8604
  }
8458
8605
  };
8459
8606
 
8460
- RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, inverseId, inversePayloads) {
8461
- var inversePayload = inversePayloads[inverseId];
8607
+ RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, resourceIdentifier, inversePayloads) {
8608
+ var inversePayload = inversePayloads.get(resourceIdentifier.type, resourceIdentifier.id);
8462
8609
  var data = inversePayload && inversePayload.data;
8463
8610
 
8464
8611
  if (!data) {
@@ -8470,21 +8617,23 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8470
8617
  return x.id !== id;
8471
8618
  });
8472
8619
  } else {
8473
- inversePayloads[inverseId] = {
8620
+ inversePayloads.set(resourceIdentifier.type, resourceIdentifier.id, {
8474
8621
  data: null
8475
- };
8622
+ });
8476
8623
  }
8477
8624
  };
8478
8625
 
8479
8626
  _createClass(RelationshipPayloads, [{
8480
8627
  key: '_lhsRelationshipIsMany',
8481
8628
  get: function () {
8482
- return this._lhsRelationshipMeta && this._lhsRelationshipMeta.kind === 'hasMany';
8629
+ var meta = this._relInfo.lhs_relationshipMeta;
8630
+ return meta !== null && meta.kind === 'hasMany';
8483
8631
  }
8484
8632
  }, {
8485
8633
  key: '_rhsRelationshipIsMany',
8486
8634
  get: function () {
8487
- return this._rhsRelationshipMeta && this._rhsRelationshipMeta.kind === 'hasMany';
8635
+ var meta = this._relInfo.rhs_relationshipMeta;
8636
+ return meta !== null && meta.kind === 'hasMany';
8488
8637
  }
8489
8638
  }]);
8490
8639
 
@@ -18265,7 +18414,7 @@ define("ember-data/version", ["exports"], function (exports) {
18265
18414
  "use strict";
18266
18415
 
18267
18416
  exports.__esModule = true;
18268
- exports.default = "2.16.1";
18417
+ exports.default = "2.16.4";
18269
18418
  });
18270
18419
  define("ember-inflector", ["module", "exports", "ember", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (module, exports, _ember, _system) {
18271
18420
  "use strict";