ember-data-source 2.17.1 → 2.18.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4574a31748687aa7ebae8d3617103105219a4540
4
- data.tar.gz: 55782e6526a409427b5f98aef12c813da5ce648f
3
+ metadata.gz: f82d81c672e79c8ec32b3d83a251842236724c6b
4
+ data.tar.gz: 19cd427812c5efd2379bbfc2219abdf7f9b4c7b3
5
5
  SHA512:
6
- metadata.gz: 15e8aa24026fa58124c18e6ca74360e8d7ef0a5da6edb9cc07cb54383502a7fcf231faf09cafb8677141642455287cd799ef639224372698ee13312d9b807cc2
7
- data.tar.gz: bb8aafb9ddcf131b6b8d7ca165c0e2277e72329b36c7800b41d4e06c72289f67f7c149b35a8c81dc9cf8758cb21b0b127d2b220047fcb05430f9672f1ceeceeb
6
+ metadata.gz: a1bb0fad5eae6a410f0811317b2526a18a544451b83b4f051d3945ed306c33e0d1560f0249dc7c4febadeffd5a59fae3e1b193ba848544733ffacc8a9da0d15a
7
+ data.tar.gz: 83bafeed0b4b68641b535ed3e79e722a83c3707a98b0e695dda16e1ef18e0f206b4c4f2bf8ccfd26d34ce283348baf7968f7a18e7a66e018c487cb542e848a82
@@ -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.17.1
9
+ * @version 2.18.0-beta.1
10
10
  */
11
11
 
12
12
  var loader, define, requireModule, require, requirejs;
@@ -498,7 +498,7 @@ define('ember-data/-private/adapters/build-url-mixin', ['exports', 'ember-inflec
498
498
  import DS from 'ember-data';
499
499
  export default DS.JSONAPIAdapter.extend({
500
500
  urlForFindRecord(id, modelName, snapshot) {
501
- let baseUrl = this.buildURL();
501
+ let baseUrl = this.buildURL(modelName, id, snapshot);
502
502
  return `${baseUrl}/users/${snapshot.adapterOptions.user_id}/playlists/${id}`;
503
503
  }
504
504
  });
@@ -1665,7 +1665,7 @@ define('ember-data/-private/system/debug/debug-adapter', ['exports', 'ember-data
1665
1665
  var containerKey = modelClass._debugContainerKey;
1666
1666
  if (containerKey) {
1667
1667
  var match = containerKey.match(/model:(.*)/);
1668
- if (match) {
1668
+ if (match !== null) {
1669
1669
  modelName = match[1];
1670
1670
  }
1671
1671
  }
@@ -4802,10 +4802,6 @@ define('ember-data/-private/system/model/model', ['exports', 'ember-data/-privat
4802
4802
  // the computed property.
4803
4803
  var meta = value.meta();
4804
4804
 
4805
- /*
4806
- This is buggy because if the parent has never been looked up
4807
- via `modelFor` it will not have `modelName` set.
4808
- */
4809
4805
  meta.parentType = proto.constructor;
4810
4806
  }
4811
4807
  }
@@ -7618,7 +7614,7 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
7618
7614
  }
7619
7615
 
7620
7616
  function relationshipFromMeta(meta) {
7621
- return {
7617
+ var result = {
7622
7618
  key: meta.key,
7623
7619
  kind: meta.kind,
7624
7620
  type: typeForRelationshipMeta(meta),
@@ -7627,6 +7623,12 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
7627
7623
  parentType: meta.parentType,
7628
7624
  isRelationship: true
7629
7625
  };
7626
+
7627
+ if (false) {
7628
+ result.parentType = meta.parentType;
7629
+ }
7630
+
7631
+ return result;
7630
7632
  }
7631
7633
  });
7632
7634
  define('ember-data/-private/system/relationships/belongs-to', ['exports', 'ember-data/-private/system/normalize-model-name'], function (exports, _normalizeModelName) {
@@ -8036,7 +8038,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8036
8038
  }
8037
8039
  }
8038
8040
 
8039
- var get = Ember.get;
8041
+ var _get = Ember.get;
8040
8042
 
8041
8043
  var RelationshipPayloadsManager = function () {
8042
8044
  function RelationshipPayloadsManager(store) {
@@ -8045,7 +8047,6 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8045
8047
  this._store = store;
8046
8048
  // cache of `RelationshipPayload`s
8047
8049
  this._cache = Object.create(null);
8048
- this._inverseLookupCache = new _relationshipPayloads.TypeCache();
8049
8050
  }
8050
8051
 
8051
8052
  /**
@@ -8066,7 +8067,9 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8066
8067
 
8067
8068
 
8068
8069
  RelationshipPayloadsManager.prototype.get = function get(modelName, id, relationshipName) {
8069
- var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, false);
8070
+ var modelClass = this._store._modelFor(modelName);
8071
+ var relationshipsByName = _get(modelClass, 'relationshipsByName');
8072
+ var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
8070
8073
  return relationshipPayloads && relationshipPayloads.get(modelName, id, relationshipName);
8071
8074
  };
8072
8075
 
@@ -8077,8 +8080,10 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8077
8080
  return;
8078
8081
  }
8079
8082
 
8083
+ var modelClass = this._store._modelFor(modelName);
8084
+ var relationshipsByName = _get(modelClass, 'relationshipsByName');
8080
8085
  Object.keys(relationshipsData).forEach(function (key) {
8081
- var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, true);
8086
+ var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, modelClass, relationshipsByName, true);
8082
8087
  if (relationshipPayloads) {
8083
8088
  relationshipPayloads.push(modelName, id, key, relationshipsData[key]);
8084
8089
  }
@@ -8089,153 +8094,51 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8089
8094
  var _this2 = this;
8090
8095
 
8091
8096
  var modelClass = this._store._modelFor(modelName);
8092
- var relationshipsByName = get(modelClass, 'relationshipsByName');
8097
+ var relationshipsByName = _get(modelClass, 'relationshipsByName');
8093
8098
  relationshipsByName.forEach(function (_, relationshipName) {
8094
- var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, false);
8099
+ var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
8095
8100
  if (relationshipPayloads) {
8096
8101
  relationshipPayloads.unload(modelName, id, relationshipName);
8097
8102
  }
8098
8103
  });
8099
8104
  };
8100
8105
 
8101
- RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, init) {
8102
- var relInfo = this.getRelationshipInfo(modelName, relationshipName);
8103
-
8104
- if (relInfo === null) {
8106
+ RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, init) {
8107
+ if (!relationshipsByName.has(relationshipName)) {
8105
8108
  return;
8106
8109
  }
8107
8110
 
8108
- var cache = this._cache[relInfo.lhs_key];
8109
-
8110
- if (!cache && init) {
8111
- return this._initializeRelationshipPayloads(relInfo);
8111
+ var key = modelName + ':' + relationshipName;
8112
+ if (!this._cache[key] && init) {
8113
+ return this._initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName);
8112
8114
  }
8113
8115
 
8114
- return cache;
8116
+ return this._cache[key];
8115
8117
  };
8116
8118
 
8117
- RelationshipPayloadsManager.prototype.getRelationshipInfo = function getRelationshipInfo(modelName, relationshipName) {
8118
- var inverseCache = this._inverseLookupCache;
8119
- var store = this._store;
8120
- var cached = inverseCache.get(modelName, relationshipName);
8121
-
8122
- // CASE: We have a cached resolution (null if no relationship exists)
8123
- if (cached !== undefined) {
8124
- return cached;
8125
- }
8126
-
8127
- var modelClass = store._modelFor(modelName);
8128
- var relationshipsByName = get(modelClass, 'relationshipsByName');
8129
-
8130
- // CASE: We don't have a relationship at all
8131
- if (!relationshipsByName.has(relationshipName)) {
8132
- inverseCache.set(modelName, relationshipName, null);
8133
- return null;
8134
- }
8135
-
8136
- var inverseMeta = modelClass.inverseFor(relationshipName, store);
8119
+ RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName) {
8137
8120
  var relationshipMeta = relationshipsByName.get(relationshipName);
8138
- var selfIsPolymorphic = relationshipMeta.options !== undefined && relationshipMeta.options.polymorphic === true;
8139
- var inverseBaseModelName = relationshipMeta.type;
8140
-
8141
- // CASE: We have no inverse
8142
- if (!inverseMeta) {
8143
- var _info = {
8144
- lhs_key: modelName + ':' + relationshipName,
8145
- lhs_modelNames: [modelName],
8146
- lhs_baseModelName: modelName,
8147
- lhs_relationshipName: relationshipName,
8148
- lhs_relationshipMeta: relationshipMeta,
8149
- lhs_isPolymorphic: selfIsPolymorphic,
8150
- rhs_key: '',
8151
- rhs_modelNames: [],
8152
- rhs_baseModelName: inverseBaseModelName,
8153
- rhs_relationshipName: '',
8154
- rhs_relationshipMeta: null,
8155
- rhs_isPolymorphic: false,
8156
- hasInverse: false,
8157
- isSelfReferential: false, // modelName === inverseBaseModelName,
8158
- isReflexive: false
8159
- };
8160
-
8161
- inverseCache.set(modelName, relationshipName, _info);
8162
-
8163
- return _info;
8164
- }
8165
-
8166
- // CASE: We do have an inverse
8167
-
8168
- var inverseRelationshipName = inverseMeta.name;
8169
- var inverseRelationshipMeta = get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
8170
- var baseModelName = inverseRelationshipMeta.type;
8171
- var isSelfReferential = baseModelName === inverseBaseModelName;
8172
-
8173
- // TODO we want to assert this but this breaks all of our shoddily written tests
8174
- /*
8175
- if (DEBUG) {
8176
- let inverseDoubleCheck = inverseMeta.type.inverseFor(inverseRelationshipName, store);
8177
- assert(`The ${inverseBaseModelName}:${inverseRelationshipName} relationship declares 'inverse: null', but it was resolved as the inverse for ${baseModelName}:${relationshipName}.`, inverseDoubleCheck);
8121
+ var inverseMeta = modelClass.inverseFor(relationshipName, this._store);
8122
+
8123
+ var inverseModelName = void 0;
8124
+ var inverseRelationshipName = void 0;
8125
+ var inverseRelationshipMeta = void 0;
8126
+
8127
+ // figure out the inverse relationship; we need two things
8128
+ // a) the inverse model name
8129
+ //- b) the name of the inverse relationship
8130
+ if (inverseMeta) {
8131
+ inverseRelationshipName = inverseMeta.name;
8132
+ inverseModelName = relationshipMeta.type;
8133
+ inverseRelationshipMeta = _get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
8134
+ } else {
8135
+ // relationship has no inverse
8136
+ inverseModelName = inverseRelationshipName = '';
8137
+ inverseRelationshipMeta = null;
8178
8138
  }
8179
- */
8180
-
8181
- // CASE: We may have already discovered the inverse for the baseModelName
8182
- // CASE: We have already discovered the inverse
8183
- cached = inverseCache.get(baseModelName, relationshipName) || inverseCache.get(inverseBaseModelName, inverseRelationshipName);
8184
- if (cached) {
8185
- (false && Ember.assert('The ' + inverseBaseModelName + ':' + inverseRelationshipName + ' relationship declares \'inverse: null\', but it was resolved as the inverse for ' + baseModelName + ':' + relationshipName + '.', cached.hasInverse !== false));
8186
-
8187
-
8188
- var isLHS = cached.lhs_baseModelName === baseModelName;
8189
- var modelNames = isLHS ? cached.lhs_modelNames : cached.rhs_modelNames;
8190
- // make this lookup easier in the future by caching the key
8191
- modelNames.push(modelName);
8192
- inverseCache.set(modelName, relationshipName, cached);
8193
-
8194
- return cached;
8195
- }
8196
-
8197
- var info = {
8198
- lhs_key: baseModelName + ':' + relationshipName,
8199
- lhs_modelNames: [modelName],
8200
- lhs_baseModelName: baseModelName,
8201
- lhs_relationshipName: relationshipName,
8202
- lhs_relationshipMeta: relationshipMeta,
8203
- lhs_isPolymorphic: selfIsPolymorphic,
8204
- rhs_key: inverseBaseModelName + ':' + inverseRelationshipName,
8205
- rhs_modelNames: [],
8206
- rhs_baseModelName: inverseBaseModelName,
8207
- rhs_relationshipName: inverseRelationshipName,
8208
- rhs_relationshipMeta: inverseRelationshipMeta,
8209
- rhs_isPolymorphic: inverseRelationshipMeta.options !== undefined && inverseRelationshipMeta.options.polymorphic === true,
8210
- hasInverse: true,
8211
- isSelfReferential: isSelfReferential,
8212
- isReflexive: isSelfReferential && relationshipName === inverseRelationshipName
8213
- };
8214
-
8215
- // Create entries for the baseModelName as well as modelName to speed up
8216
- // inverse lookups
8217
- inverseCache.set(baseModelName, relationshipName, info);
8218
- inverseCache.set(modelName, relationshipName, info);
8219
8139
 
8220
- // Greedily populate the inverse
8221
- inverseCache.set(inverseBaseModelName, inverseRelationshipName, info);
8222
-
8223
- return info;
8224
- };
8225
-
8226
- RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(relInfo) {
8227
- var lhsKey = relInfo.lhs_key;
8228
- var rhsKey = relInfo.rhs_key;
8229
- var existingPayloads = this._cache[lhsKey];
8230
-
8231
- if (relInfo.hasInverse === true && relInfo.rhs_isPolymorphic === true) {
8232
- existingPayloads = this._cache[rhsKey];
8233
-
8234
- if (existingPayloads !== undefined) {
8235
- this._cache[lhsKey] = existingPayloads;
8236
- return existingPayloads;
8237
- }
8238
- }
8140
+ var lhsKey = modelName + ':' + relationshipName;
8141
+ var rhsKey = inverseModelName + ':' + inverseRelationshipName;
8239
8142
 
8240
8143
  // populate the cache for both sides of the relationship, as they both use
8241
8144
  // the same `RelationshipPayloads`.
@@ -8243,13 +8146,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8243
8146
  // This works out better than creating a single common key, because to
8244
8147
  // compute that key we would need to do work to look up the inverse
8245
8148
  //
8246
- var cache = this._cache[lhsKey] = new _relationshipPayloads.default(relInfo);
8247
-
8248
- if (relInfo.hasInverse === true) {
8249
- this._cache[rhsKey] = cache;
8250
- }
8251
-
8252
- return cache;
8149
+ return this._cache[lhsKey] = this._cache[rhsKey] = new _relationshipPayloads.default(this._store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta);
8253
8150
  };
8254
8151
 
8255
8152
  return RelationshipPayloadsManager;
@@ -8262,6 +8159,12 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8262
8159
 
8263
8160
  exports.__esModule = true;
8264
8161
 
8162
+ function _classCallCheck(instance, Constructor) {
8163
+ if (!(instance instanceof Constructor)) {
8164
+ throw new TypeError("Cannot call a class as a function");
8165
+ }
8166
+ }
8167
+
8265
8168
  var _createClass = function () {
8266
8169
  function defineProperties(target, props) {
8267
8170
  for (var i = 0; i < props.length; i++) {
@@ -8280,61 +8183,37 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8280
8183
  };
8281
8184
  }();
8282
8185
 
8283
- function _classCallCheck(instance, Constructor) {
8284
- if (!(instance instanceof Constructor)) {
8285
- throw new TypeError("Cannot call a class as a function");
8286
- }
8287
- }
8288
-
8289
- var TypeCache = exports.TypeCache = function () {
8290
- function TypeCache() {
8291
- _classCallCheck(this, TypeCache);
8292
-
8293
- this.types = Object.create(null);
8294
- }
8295
-
8296
- TypeCache.prototype.get = function get(modelName, id) {
8297
- var types = this.types;
8298
-
8299
-
8300
- if (types[modelName] !== undefined) {
8301
- return types[modelName][id];
8302
- }
8303
- };
8304
-
8305
- TypeCache.prototype.set = function set(modelName, id, payload) {
8306
- var types = this.types;
8307
-
8308
- var typeMap = types[modelName];
8309
-
8310
- if (typeMap === undefined) {
8311
- typeMap = types[modelName] = Object.create(null);
8312
- }
8313
-
8314
- typeMap[id] = payload;
8315
- };
8316
-
8317
- TypeCache.prototype.delete = function _delete(modelName, id) {
8318
- var types = this.types;
8319
-
8320
-
8321
- if (types[modelName] !== undefined) {
8322
- delete types[modelName][id];
8323
- }
8324
- };
8325
-
8326
- return TypeCache;
8327
- }();
8328
-
8329
8186
  var RelationshipPayloads = function () {
8330
- function RelationshipPayloads(relInfo) {
8187
+ function RelationshipPayloads(store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta) {
8331
8188
  _classCallCheck(this, RelationshipPayloads);
8332
8189
 
8333
- this._relInfo = relInfo;
8190
+ this._store = store;
8191
+
8192
+ this._lhsModelName = modelName;
8193
+ this._lhsRelationshipName = relationshipName;
8194
+ this._lhsRelationshipMeta = relationshipMeta;
8195
+
8196
+ this._rhsModelName = inverseModelName;
8197
+ this._rhsRelationshipName = inverseRelationshipName;
8198
+ this._rhsRelationshipMeta = inverseRelationshipMeta;
8334
8199
 
8335
8200
  // a map of id -> payloads for the left hand side of the relationship.
8336
- this.lhs_payloads = new TypeCache();
8337
- this.rhs_payloads = relInfo.isReflexive ? this.lhs_payloads : new TypeCache();
8201
+ this._lhsPayloads = Object.create(null);
8202
+ if (modelName !== inverseModelName || relationshipName !== inverseRelationshipName) {
8203
+ // The common case of a non-reflexive relationship, or a reflexive
8204
+ // relationship whose inverse is not itself
8205
+ this._rhsPayloads = Object.create(null);
8206
+ this._isReflexive = false;
8207
+ } else {
8208
+ // Edge case when we have a reflexive relationship to itself
8209
+ // eg user hasMany friends inverse friends
8210
+ //
8211
+ // In this case there aren't really two sides to the relationship, but
8212
+ // we set `_rhsPayloads = _lhsPayloads` to make things easier to reason
8213
+ // about
8214
+ this._rhsPayloads = this._lhsPayloads;
8215
+ this._isReflexive = true;
8216
+ }
8338
8217
 
8339
8218
  // When we push relationship payloads, just stash them in a queue until
8340
8219
  // somebody actually asks for one of them.
@@ -8345,22 +8224,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8345
8224
  }
8346
8225
 
8347
8226
  /**
8348
- Get the payload for the relationship of an individual record.
8349
- This might return the raw payload as pushed into the store, or one computed
8350
- from the payload of the inverse relationship.
8351
- @method
8352
- */
8227
+ Get the payload for the relationship of an individual record.
8228
+ This might return the raw payload as pushed into the store, or one computed
8229
+ from the payload of the inverse relationship.
8230
+ @method
8231
+ */
8353
8232
 
8354
8233
 
8355
8234
  RelationshipPayloads.prototype.get = function get(modelName, id, relationshipName) {
8356
8235
  this._flushPending();
8357
8236
 
8358
8237
  if (this._isLHS(modelName, relationshipName)) {
8359
- return this.lhs_payloads.get(modelName, id);
8238
+ return this._lhsPayloads[id];
8360
8239
  } else {
8361
- (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName)));
8240
+ (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
8362
8241
 
8363
- return this.rhs_payloads.get(modelName, id);
8242
+ return this._rhsPayloads[id];
8364
8243
  }
8365
8244
  };
8366
8245
 
@@ -8372,40 +8251,20 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8372
8251
  this._flushPending();
8373
8252
 
8374
8253
  if (this._isLHS(modelName, relationshipName)) {
8375
- delete this.lhs_payloads.delete(modelName, id);
8254
+ delete this._lhsPayloads[id];
8376
8255
  } else {
8377
- (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)));
8256
+ (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
8378
8257
 
8379
- delete this.rhs_payloads.delete(modelName, id);
8258
+ delete this._rhsPayloads[id];
8380
8259
  }
8381
8260
  };
8382
8261
 
8383
8262
  RelationshipPayloads.prototype._isLHS = function _isLHS(modelName, relationshipName) {
8384
- var relInfo = this._relInfo;
8385
- var isSelfReferential = relInfo.isSelfReferential;
8386
- var isRelationship = relationshipName === relInfo.lhs_relationshipName;
8387
-
8388
- if (isRelationship === true) {
8389
- return isSelfReferential === true || // itself
8390
- modelName === relInfo.lhs_baseModelName || // base or non-polymorphic
8391
- relInfo.lhs_modelNames.indexOf(modelName) !== -1; // polymorphic
8392
- }
8393
-
8394
- return false;
8263
+ return modelName === this._lhsModelName && relationshipName === this._lhsRelationshipName;
8395
8264
  };
8396
8265
 
8397
8266
  RelationshipPayloads.prototype._isRHS = function _isRHS(modelName, relationshipName) {
8398
- var relInfo = this._relInfo;
8399
- var isSelfReferential = relInfo.isSelfReferential;
8400
- var isRelationship = relationshipName === relInfo.rhs_relationshipName;
8401
-
8402
- if (isRelationship === true) {
8403
- return isSelfReferential === true || // itself
8404
- modelName === relInfo.rhs_baseModelName || // base or non-polymorphic
8405
- relInfo.rhs_modelNames.indexOf(modelName) !== -1; // polymorphic
8406
- }
8407
-
8408
- return false;
8267
+ return modelName === this._rhsModelName && relationshipName === this._rhsRelationshipName;
8409
8268
  };
8410
8269
 
8411
8270
  RelationshipPayloads.prototype._flushPending = function _flushPending() {
@@ -8426,28 +8285,26 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8426
8285
  id: id,
8427
8286
  type: modelName
8428
8287
  }
8429
- };
8430
8288
 
8431
- // start flushing this individual payload. The logic is the same whether
8432
- // it's for the left hand side of the relationship or the right hand side,
8433
- // except the role of primary and inverse idToPayloads is reversed
8434
- //
8435
- var previousPayload = void 0;
8436
- var payloadMap = void 0;
8437
- var inversePayloadMap = void 0;
8289
+ // start flushing this individual payload. The logic is the same whether
8290
+ // it's for the left hand side of the relationship or the right hand side,
8291
+ // except the role of primary and inverse idToPayloads is reversed
8292
+ //
8293
+ };var previousPayload = void 0;
8294
+ var idToPayloads = void 0;
8295
+ var inverseIdToPayloads = void 0;
8438
8296
  var inverseIsMany = void 0;
8439
-
8440
8297
  if (this._isLHS(modelName, relationshipName)) {
8441
- previousPayload = this.lhs_payloads.get(modelName, id);
8442
- payloadMap = this.lhs_payloads;
8443
- inversePayloadMap = this.rhs_payloads;
8298
+ previousPayload = this._lhsPayloads[id];
8299
+ idToPayloads = this._lhsPayloads;
8300
+ inverseIdToPayloads = this._rhsPayloads;
8444
8301
  inverseIsMany = this._rhsRelationshipIsMany;
8445
8302
  } else {
8446
- (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName)));
8303
+ (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
8447
8304
 
8448
- previousPayload = this.rhs_payloads.get(modelName, id);
8449
- payloadMap = this.rhs_payloads;
8450
- inversePayloadMap = this.lhs_payloads;
8305
+ previousPayload = this._rhsPayloads[id];
8306
+ idToPayloads = this._rhsPayloads;
8307
+ inverseIdToPayloads = this._lhsPayloads;
8451
8308
  inverseIsMany = this._lhsRelationshipIsMany;
8452
8309
  }
8453
8310
 
@@ -8491,14 +8348,14 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8491
8348
  // * undefined is NOT considered new information, we should keep original state
8492
8349
  // * anything else is considered new information, and it should win
8493
8350
  if (relationshipData.data !== undefined) {
8494
- this._removeInverse(id, previousPayload, inversePayloadMap);
8351
+ this._removeInverse(id, previousPayload, inverseIdToPayloads);
8495
8352
  }
8496
- payloadMap.set(modelName, id, relationshipData);
8497
- this._populateInverse(relationshipData, inverseRelationshipData, inversePayloadMap, inverseIsMany);
8353
+ idToPayloads[id] = relationshipData;
8354
+ this._populateInverse(relationshipData, inverseRelationshipData, inverseIdToPayloads, inverseIsMany);
8498
8355
  }
8499
8356
  };
8500
8357
 
8501
- RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inversePayloadMap, inverseIsMany) {
8358
+ RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inverseIdToPayloads, inverseIsMany) {
8502
8359
  if (!relationshipData.data) {
8503
8360
  // This id doesn't have an inverse, eg a belongsTo with a payload
8504
8361
  // { data: null }, so there's nothing to populate
@@ -8507,24 +8364,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8507
8364
 
8508
8365
  if (Array.isArray(relationshipData.data)) {
8509
8366
  for (var i = 0; i < relationshipData.data.length; ++i) {
8510
- var resourceIdentifier = relationshipData.data[i];
8511
- this._addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany);
8367
+ var inverseId = relationshipData.data[i].id;
8368
+ this._addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany);
8512
8369
  }
8513
8370
  } else {
8514
- var _resourceIdentifier = relationshipData.data;
8515
- this._addToInverse(inversePayload, _resourceIdentifier, inversePayloadMap, inverseIsMany);
8371
+ var _inverseId = relationshipData.data.id;
8372
+ this._addToInverse(inversePayload, _inverseId, inverseIdToPayloads, inverseIsMany);
8516
8373
  }
8517
8374
  };
8518
8375
 
8519
- RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany) {
8520
- var relInfo = this._relInfo;
8521
-
8522
- if (relInfo.isReflexive && inversePayload.data.id === resourceIdentifier.id) {
8376
+ RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany) {
8377
+ if (this._isReflexive && inversePayload.data.id === inverseId) {
8523
8378
  // eg <user:1>.friends = [{ id: 1, type: 'user' }]
8524
8379
  return;
8525
8380
  }
8526
8381
 
8527
- var existingPayload = inversePayloadMap.get(resourceIdentifier.type, resourceIdentifier.id);
8382
+ var existingPayload = inverseIdToPayloads[inverseId];
8528
8383
  var existingData = existingPayload && existingPayload.data;
8529
8384
 
8530
8385
  if (existingData) {
@@ -8534,22 +8389,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8534
8389
  if (Array.isArray(existingData)) {
8535
8390
  existingData.push(inversePayload.data);
8536
8391
  } else {
8537
- inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload);
8392
+ inverseIdToPayloads[inverseId] = inversePayload;
8538
8393
  }
8539
8394
  } else {
8540
8395
  // first time we're populating the inverse side
8541
8396
  //
8542
8397
  if (inverseIsMany) {
8543
- inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, {
8398
+ inverseIdToPayloads[inverseId] = {
8544
8399
  data: [inversePayload.data]
8545
- });
8400
+ };
8546
8401
  } else {
8547
- inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload);
8402
+ inverseIdToPayloads[inverseId] = inversePayload;
8548
8403
  }
8549
8404
  }
8550
8405
  };
8551
8406
 
8552
- RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inversePayloadMap) {
8407
+ RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inverseIdToPayloads) {
8553
8408
  var data = previousPayload && previousPayload.data;
8554
8409
  if (!data) {
8555
8410
  // either this is the first time we've seen a payload for this id, or its
@@ -8564,16 +8419,15 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8564
8419
  if (Array.isArray(data)) {
8565
8420
  // TODO: diff rather than removeall addall?
8566
8421
  for (var i = 0; i < data.length; ++i) {
8567
- var resourceIdentifier = data[i];
8568
- this._removeFromInverse(id, resourceIdentifier, inversePayloadMap);
8422
+ this._removeFromInverse(id, data[i].id, inverseIdToPayloads);
8569
8423
  }
8570
8424
  } else {
8571
- this._removeFromInverse(id, data, inversePayloadMap);
8425
+ this._removeFromInverse(id, data.id, inverseIdToPayloads);
8572
8426
  }
8573
8427
  };
8574
8428
 
8575
- RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, resourceIdentifier, inversePayloads) {
8576
- var inversePayload = inversePayloads.get(resourceIdentifier.type, resourceIdentifier.id);
8429
+ RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, inverseId, inversePayloads) {
8430
+ var inversePayload = inversePayloads[inverseId];
8577
8431
  var data = inversePayload && inversePayload.data;
8578
8432
 
8579
8433
  if (!data) {
@@ -8585,23 +8439,21 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8585
8439
  return x.id !== id;
8586
8440
  });
8587
8441
  } else {
8588
- inversePayloads.set(resourceIdentifier.type, resourceIdentifier.id, {
8442
+ inversePayloads[inverseId] = {
8589
8443
  data: null
8590
- });
8444
+ };
8591
8445
  }
8592
8446
  };
8593
8447
 
8594
8448
  _createClass(RelationshipPayloads, [{
8595
8449
  key: '_lhsRelationshipIsMany',
8596
8450
  get: function () {
8597
- var meta = this._relInfo.lhs_relationshipMeta;
8598
- return meta !== null && meta.kind === 'hasMany';
8451
+ return this._lhsRelationshipMeta && this._lhsRelationshipMeta.kind === 'hasMany';
8599
8452
  }
8600
8453
  }, {
8601
8454
  key: '_rhsRelationshipIsMany',
8602
8455
  get: function () {
8603
- var meta = this._relInfo.rhs_relationshipMeta;
8604
- return meta !== null && meta.kind === 'hasMany';
8456
+ return this._rhsRelationshipMeta && this._rhsRelationshipMeta.kind === 'hasMany';
8605
8457
  }
8606
8458
  }]);
8607
8459
 
@@ -15437,7 +15289,7 @@ define('ember-data/attr', ['exports'], function (exports) {
15437
15289
  }).meta(meta);
15438
15290
  }
15439
15291
  });
15440
- define('ember-data', ['exports', 'ember-data/-private', 'ember-data/setup-container', 'ember-data/instance-initializers/initialize-store-service', 'ember-data/transforms/transform', 'ember-data/transforms/number', 'ember-data/transforms/date', 'ember-data/transforms/string', 'ember-data/transforms/boolean', 'ember-data/adapter', 'ember-data/adapters/json-api', 'ember-data/adapters/rest', 'ember-data/serializer', 'ember-data/serializers/json-api', 'ember-data/serializers/json', 'ember-data/serializers/rest', 'ember-data/serializers/embedded-records-mixin', 'ember-data/attr', 'ember-inflector'], function (exports, _private, _setupContainer, _initializeStoreService, _transform, _number, _date, _string, _boolean, _adapter, _jsonApi, _rest, _serializer, _jsonApi2, _json, _rest2, _embeddedRecordsMixin, _attr) {
15292
+ define('ember-data', ['exports', 'ember-data/-private', 'ember-data/setup-container', 'ember-data/initialize-store-service', 'ember-data/transforms/transform', 'ember-data/transforms/number', 'ember-data/transforms/date', 'ember-data/transforms/string', 'ember-data/transforms/boolean', 'ember-data/adapter', 'ember-data/adapters/json-api', 'ember-data/adapters/rest', 'ember-data/serializer', 'ember-data/serializers/json-api', 'ember-data/serializers/json', 'ember-data/serializers/rest', 'ember-data/serializers/embedded-records-mixin', 'ember-data/attr', 'ember-inflector'], function (exports, _private, _setupContainer, _initializeStoreService, _transform, _number, _date, _string, _boolean, _adapter, _jsonApi, _rest, _serializer, _jsonApi2, _json, _rest2, _embeddedRecordsMixin, _attr) {
15441
15293
  'use strict';
15442
15294
 
15443
15295
  exports.__esModule = true;
@@ -15539,65 +15391,7 @@ define('ember-data', ['exports', 'ember-data/-private', 'ember-data/setup-contai
15539
15391
 
15540
15392
  exports.default = _private.DS;
15541
15393
  });
15542
- define('ember-data/initializers/data-adapter', ['exports'], function (exports) {
15543
- 'use strict';
15544
-
15545
- exports.__esModule = true;
15546
- exports.default = {
15547
- name: 'data-adapter',
15548
- before: 'store',
15549
- initialize: function () {}
15550
- };
15551
- });
15552
- define('ember-data/initializers/ember-data', ['exports', 'ember-data/setup-container', 'ember-data'], function (exports, _setupContainer) {
15553
- 'use strict';
15554
-
15555
- exports.__esModule = true;
15556
- exports.default = {
15557
- name: 'ember-data',
15558
- initialize: _setupContainer.default
15559
- };
15560
- });
15561
- define('ember-data/initializers/injectStore', ['exports'], function (exports) {
15562
- 'use strict';
15563
-
15564
- exports.__esModule = true;
15565
- exports.default = {
15566
- name: 'injectStore',
15567
- before: 'store',
15568
- initialize: function () {}
15569
- };
15570
- });
15571
- define('ember-data/initializers/store', ['exports'], function (exports) {
15572
- 'use strict';
15573
-
15574
- exports.__esModule = true;
15575
- exports.default = {
15576
- name: 'store',
15577
- after: 'ember-data',
15578
- initialize: function () {}
15579
- };
15580
- });
15581
- define('ember-data/initializers/transforms', ['exports'], function (exports) {
15582
- 'use strict';
15583
-
15584
- exports.__esModule = true;
15585
- exports.default = {
15586
- name: 'transforms',
15587
- before: 'store',
15588
- initialize: function () {}
15589
- };
15590
- });
15591
- define("ember-data/instance-initializers/ember-data", ["exports", "ember-data/instance-initializers/initialize-store-service"], function (exports, _initializeStoreService) {
15592
- "use strict";
15593
-
15594
- exports.__esModule = true;
15595
- exports.default = {
15596
- name: "ember-data",
15597
- initialize: _initializeStoreService.default
15598
- };
15599
- });
15600
- define('ember-data/instance-initializers/initialize-store-service', ['exports'], function (exports) {
15394
+ define('ember-data/initialize-store-service', ['exports'], function (exports) {
15601
15395
  'use strict';
15602
15396
 
15603
15397
  exports.__esModule = true;
@@ -15665,6 +15459,64 @@ define('ember-data/instance-initializers/initialize-store-service', ['exports'],
15665
15459
  };
15666
15460
  }
15667
15461
  });
15462
+ define('ember-data/initializers/data-adapter', ['exports'], function (exports) {
15463
+ 'use strict';
15464
+
15465
+ exports.__esModule = true;
15466
+ exports.default = {
15467
+ name: 'data-adapter',
15468
+ before: 'store',
15469
+ initialize: function () {}
15470
+ };
15471
+ });
15472
+ define('ember-data/initializers/ember-data', ['exports', 'ember-data/setup-container', 'ember-data'], function (exports, _setupContainer) {
15473
+ 'use strict';
15474
+
15475
+ exports.__esModule = true;
15476
+ exports.default = {
15477
+ name: 'ember-data',
15478
+ initialize: _setupContainer.default
15479
+ };
15480
+ });
15481
+ define('ember-data/initializers/injectStore', ['exports'], function (exports) {
15482
+ 'use strict';
15483
+
15484
+ exports.__esModule = true;
15485
+ exports.default = {
15486
+ name: 'injectStore',
15487
+ before: 'store',
15488
+ initialize: function () {}
15489
+ };
15490
+ });
15491
+ define('ember-data/initializers/store', ['exports'], function (exports) {
15492
+ 'use strict';
15493
+
15494
+ exports.__esModule = true;
15495
+ exports.default = {
15496
+ name: 'store',
15497
+ after: 'ember-data',
15498
+ initialize: function () {}
15499
+ };
15500
+ });
15501
+ define('ember-data/initializers/transforms', ['exports'], function (exports) {
15502
+ 'use strict';
15503
+
15504
+ exports.__esModule = true;
15505
+ exports.default = {
15506
+ name: 'transforms',
15507
+ before: 'store',
15508
+ initialize: function () {}
15509
+ };
15510
+ });
15511
+ define("ember-data/instance-initializers/ember-data", ["exports", "ember-data/initialize-store-service"], function (exports, _initializeStoreService) {
15512
+ "use strict";
15513
+
15514
+ exports.__esModule = true;
15515
+ exports.default = {
15516
+ name: "ember-data",
15517
+ initialize: _initializeStoreService.default
15518
+ };
15519
+ });
15668
15520
  define('ember-data/model', ['exports', 'ember-data/-private'], function (exports, _private) {
15669
15521
  'use strict';
15670
15522
 
@@ -18165,16 +18017,16 @@ define('ember-data/transforms/boolean', ['exports', 'ember-data/transforms/trans
18165
18017
  var isNone = Ember.isNone;
18166
18018
  exports.default = _transform.default.extend({
18167
18019
  deserialize: function (serialized, options) {
18168
- var type = typeof serialized;
18169
-
18170
18020
  if (isNone(serialized) && options.allowNull === true) {
18171
18021
  return null;
18172
18022
  }
18173
18023
 
18024
+ var type = typeof serialized;
18174
18025
  if (type === "boolean") {
18175
18026
  return serialized;
18176
18027
  } else if (type === "string") {
18177
- return serialized.match(/^true$|^t$|^1$/i) !== null;
18028
+ return (/^(true|t|1)$/i.test(serialized)
18029
+ );
18178
18030
  } else if (type === "number") {
18179
18031
  return serialized === 1;
18180
18032
  } else {
@@ -18398,7 +18250,7 @@ define("ember-data/version", ["exports"], function (exports) {
18398
18250
  "use strict";
18399
18251
 
18400
18252
  exports.__esModule = true;
18401
- exports.default = "2.17.1";
18253
+ exports.default = "2.18.0-beta.1";
18402
18254
  });
18403
18255
  define("ember-inflector", ["module", "exports", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (module, exports, _system) {
18404
18256
  "use strict";