ember-data-source 2.18.3 → 3.0.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: 8ffd9f195e427b53c183deb8f18fcb97d5107f28
4
- data.tar.gz: c0d2df0734c55c6b5a486971e6975d7d2fcfdb48
3
+ metadata.gz: f3b39a85eecd96cc962a815fba3e24a1b0da2bfe
4
+ data.tar.gz: 835bc6f1e348d3b46a3565e5783c003550c03ebb
5
5
  SHA512:
6
- metadata.gz: afdce781175c680b00068a0b57cea9332385198577c0be7a2e2fc1412f23c9970b16596b0ead953177e7fabba76f6ff82abfe2e84007b2a50ffdddbf5c7f1b8a
7
- data.tar.gz: 459ef1002b3506aac24e902c3824dadcf10be5cbf4b0094d243fdfc7d4e4f84cf053f1ad95dd33be15f4cf5620866e790759e4b44ae564cab29800503e9a4069
6
+ metadata.gz: b97a394a8c8e7b8dc94a5f6a1e1c28870a4883ab9be3e1c266bd9368160da43546122774556978e34099c86d5f2933853a37bca5a19aa0884b3c592f0d96bc49
7
+ data.tar.gz: b59b72f42b907cbfacbf9bbd8751f16822e62b13b8c3056a8d11b4f052055e682b18911b84a11951928a1574496249338f9d33bb98b765ea5c352c7759d190bf
@@ -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.18.3
9
+ * @version 3.0.0-beta.1
10
10
  */
11
11
 
12
12
  var loader, define, requireModule, require, requirejs;
@@ -1328,7 +1328,7 @@ define('ember-data/-private/global', ['exports'], function (exports) {
1328
1328
  // export real global
1329
1329
  exports.default = checkGlobal(checkElementIdShadowing(typeof global === 'object' && global)) || checkGlobal(typeof self === 'object' && self) || checkGlobal(typeof window === 'object' && window) || new Function('return this')();
1330
1330
  });
1331
- define('ember-data/-private', ['exports', 'ember-data/-private/system/model/model', 'ember-data/-private/system/model/errors', 'ember-data/-private/system/store', 'ember-data/-private/core', 'ember-data/-private/system/relationships/belongs-to', 'ember-data/-private/system/relationships/has-many', 'ember-data/-private/adapters/build-url-mixin', 'ember-data/-private/system/snapshot', 'ember-data/-private/adapters/errors', 'ember-data/-private/system/normalize-model-name', 'ember-data/-private/utils', 'ember-data/-private/system/coerce-id', 'ember-data/-private/utils/parse-response-headers', 'ember-data/-private/global', 'ember-data/-private/features', 'ember-data/-private/system/model/states', 'ember-data/-private/system/model/internal-model', 'ember-data/-private/system/store/container-instance-cache', 'ember-data/-private/system/promise-proxies', 'ember-data/-private/system/record-arrays', 'ember-data/-private/system/many-array', 'ember-data/-private/system/record-array-manager', 'ember-data/-private/system/relationships/state/relationship', 'ember-data/-private/system/debug/debug-adapter', 'ember-data/-private/system/diff-array', 'ember-data/-private/system/relationships/relationship-payloads-manager', 'ember-data/-private/system/relationships/relationship-payloads', 'ember-data/-private/system/snapshot-record-array'], function (exports, _model, _errors, _store, _core, _belongsTo, _hasMany, _buildUrlMixin, _snapshot, _errors2, _normalizeModelName, _utils, _coerceId, _parseResponseHeaders, _global, _features, _states, _internalModel, _containerInstanceCache, _promiseProxies, _recordArrays, _manyArray, _recordArrayManager, _relationship, _debugAdapter, _diffArray, _relationshipPayloadsManager, _relationshipPayloads, _snapshotRecordArray) {
1331
+ define('ember-data/-private', ['exports', 'ember-data/-private/system/model/model', 'ember-data/-private/system/model/errors', 'ember-data/-private/system/store', 'ember-data/-private/core', 'ember-data/-private/system/relationships/belongs-to', 'ember-data/-private/system/relationships/has-many', 'ember-data/-private/adapters/build-url-mixin', 'ember-data/-private/system/snapshot', 'ember-data/-private/adapters/errors', 'ember-data/-private/system/normalize-model-name', 'ember-data/-private/utils', 'ember-data/-private/system/coerce-id', 'ember-data/-private/utils/parse-response-headers', 'ember-data/-private/global', 'ember-data/-private/features', 'ember-data/-private/system/model/states', 'ember-data/-private/system/model/internal-model', 'ember-data/-private/system/promise-proxies', 'ember-data/-private/system/record-arrays', 'ember-data/-private/system/many-array', 'ember-data/-private/system/record-array-manager', 'ember-data/-private/system/relationships/state/relationship', 'ember-data/-private/system/debug/debug-adapter', 'ember-data/-private/system/diff-array', 'ember-data/-private/system/relationships/relationship-payloads-manager', 'ember-data/-private/system/relationships/relationship-payloads', 'ember-data/-private/system/snapshot-record-array'], function (exports, _model, _errors, _store, _core, _belongsTo, _hasMany, _buildUrlMixin, _snapshot, _errors2, _normalizeModelName, _utils, _coerceId, _parseResponseHeaders, _global, _features, _states, _internalModel, _promiseProxies, _recordArrays, _manyArray, _recordArrayManager, _relationship, _debugAdapter, _diffArray, _relationshipPayloadsManager, _relationshipPayloads, _snapshotRecordArray) {
1332
1332
  'use strict';
1333
1333
 
1334
1334
  exports.__esModule = true;
@@ -1500,12 +1500,6 @@ define('ember-data/-private', ['exports', 'ember-data/-private/system/model/mode
1500
1500
  return _internalModel.default;
1501
1501
  }
1502
1502
  });
1503
- Object.defineProperty(exports, 'ContainerInstanceCache', {
1504
- enumerable: true,
1505
- get: function () {
1506
- return _containerInstanceCache.default;
1507
- }
1508
- });
1509
1503
  Object.defineProperty(exports, 'PromiseArray', {
1510
1504
  enumerable: true,
1511
1505
  get: function () {
@@ -2693,24 +2687,12 @@ define('ember-data/-private/system/model/internal-model', ['exports', 'ember-dat
2693
2687
  return true;
2694
2688
  }
2695
2689
 
2696
- // Handle dematerialization for relationship `rel`. In all cases, notify the
2697
- // relatinoship of the dematerialization: this is done so the relationship can
2698
- // notify its inverse which needs to update state
2699
- //
2700
- // If the inverse is sync, unloading this record is treated as a client-side
2701
- // delete, so we remove the inverse records from this relationship to
2702
- // disconnect the graph. Because it's not async, we don't need to keep around
2703
- // the internalModel as an id-wrapper for references and because the graph is
2704
- // disconnected we can actually destroy the internalModel when checking for
2705
- // orphaned models.
2706
2690
  function destroyRelationship(rel) {
2707
- rel.internalModelDidDematerialize();
2708
-
2709
- if (rel._inverseIsSync()) {
2710
- // disconnect the graph so that the sync inverse relationship does not
2711
- // prevent us from cleaning up during `_cleanupOrphanedInternalModels`
2712
- rel.removeAllInternalModelsFromOwn();
2713
- rel.removeAllCanonicalInternalModelsFromOwn();
2691
+ if (rel._inverseIsAsync()) {
2692
+ rel.removeInternalModelFromInverse(rel.inverseInternalModel);
2693
+ rel.removeInverseRelationships();
2694
+ } else {
2695
+ rel.removeCompletelyFromInverse();
2714
2696
  }
2715
2697
  }
2716
2698
  // this (and all heimdall instrumentation) will be stripped by a babel transform
@@ -2929,7 +2911,6 @@ define('ember-data/-private/system/model/internal-model', ['exports', 'ember-dat
2929
2911
 
2930
2912
  InternalModel.prototype._directlyRelatedInternalModels = function _directlyRelatedInternalModels() {
2931
2913
  var array = [];
2932
-
2933
2914
  this._relationships.forEach(function (name, rel) {
2934
2915
  array = array.concat(rel.members.list, rel.canonicalMembers.list);
2935
2916
  });
@@ -3178,7 +3159,7 @@ define('ember-data/-private/system/model/internal-model', ['exports', 'ember-dat
3178
3159
  }
3179
3160
 
3180
3161
  if (this.isNew()) {
3181
- this.removeFromInverseRelationships(true);
3162
+ this.removeFromInverseRelationships();
3182
3163
  }
3183
3164
 
3184
3165
  if (this.isValid()) {
@@ -3295,13 +3276,9 @@ define('ember-data/-private/system/model/internal-model', ['exports', 'ember-dat
3295
3276
  };
3296
3277
 
3297
3278
  InternalModel.prototype.removeFromInverseRelationships = function removeFromInverseRelationships() {
3298
- var isNew = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
3299
-
3300
3279
  this._relationships.forEach(function (name, rel) {
3301
3280
  rel.removeCompletelyFromInverse();
3302
- if (isNew === true) {
3303
- rel.clear();
3304
- }
3281
+ rel.clear();
3305
3282
  });
3306
3283
 
3307
3284
  var implicitRelationships = this._implicitRelationships;
@@ -3311,9 +3288,7 @@ define('ember-data/-private/system/model/internal-model', ['exports', 'ember-dat
3311
3288
  var rel = implicitRelationships[key];
3312
3289
 
3313
3290
  rel.removeCompletelyFromInverse();
3314
- if (isNew === true) {
3315
- rel.clear();
3316
- }
3291
+ rel.clear();
3317
3292
  });
3318
3293
  };
3319
3294
 
@@ -3327,7 +3302,10 @@ define('ember-data/-private/system/model/internal-model', ['exports', 'ember-dat
3327
3302
  this.__implicitRelationships = null;
3328
3303
  Object.keys(implicitRelationships).forEach(function (key) {
3329
3304
  var rel = implicitRelationships[key];
3305
+
3330
3306
  destroyRelationship(rel);
3307
+
3308
+ rel.destroy();
3331
3309
  });
3332
3310
  };
3333
3311
 
@@ -3732,7 +3710,7 @@ define('ember-data/-private/system/model/model', ['exports', 'ember-data/-privat
3732
3710
  var relationships = relationshipMap.get(type.modelName).filter(function (relationship) {
3733
3711
  var optionsForRelationship = inverseType.metaForProperty(relationship.name).options;
3734
3712
 
3735
- if (!optionsForRelationship.inverse) {
3713
+ if (!optionsForRelationship.inverse && optionsForRelationship.inverse !== null) {
3736
3714
  return true;
3737
3715
  }
3738
3716
 
@@ -4812,10 +4790,6 @@ define('ember-data/-private/system/model/model', ['exports', 'ember-data/-privat
4812
4790
  // the computed property.
4813
4791
  var meta = value.meta();
4814
4792
 
4815
- /*
4816
- This is buggy because if the parent has never been looked up
4817
- via `modelFor` it will not have `modelName` set.
4818
- */
4819
4793
  meta.parentType = proto.constructor;
4820
4794
  }
4821
4795
  }
@@ -6213,7 +6187,7 @@ define('ember-data/-private/system/record-arrays/adapter-populated-record-array'
6213
6187
 
6214
6188
  this._super.apply(this, arguments);
6215
6189
  this.query = this.query || null;
6216
- this.links = null;
6190
+ this.links = this.links || null;
6217
6191
  },
6218
6192
  replace: function () {
6219
6193
  throw new Error('The result of a server query (on ' + this.modelName + ') is immutable.');
@@ -6811,7 +6785,7 @@ define('ember-data/-private/system/references/belongs-to', ['exports', 'ember-da
6811
6785
  if ((0, _features.default)('ds-overhaul-references')) {
6812
6786
  (false && !(false) && Ember.deprecate("BelongsToReference#push(DS.Model) is deprecated. Update relationship via `model.set('relationshipName', value)` instead.", false, {
6813
6787
  id: 'ds.references.belongs-to.push-record',
6814
- until: '3.0'
6788
+ until: '4.0.0'
6815
6789
  }));
6816
6790
  }
6817
6791
  record = data;
@@ -7228,7 +7202,7 @@ define('ember-data/-private/system/references/has-many', ['exports', 'ember-data
7228
7202
  if ((0, _features.default)("ds-overhaul-references")) {
7229
7203
  (false && !(!Array.isArray(payload)) && Ember.deprecate("HasManyReference#push(array) is deprecated. Push a JSON-API document instead.", !Array.isArray(payload), {
7230
7204
  id: 'ds.references.has-many.push-array',
7231
- until: '3.0'
7205
+ until: '4.0.0'
7232
7206
  }));
7233
7207
  }
7234
7208
 
@@ -7240,7 +7214,7 @@ define('ember-data/-private/system/references/has-many', ['exports', 'ember-data
7240
7214
  if ((0, _features.default)('ds-overhaul-references')) {
7241
7215
  (false && !(!useLegacyArrayPush) && Ember.deprecate("HasManyReference#push() expects a valid JSON-API document.", !useLegacyArrayPush, {
7242
7216
  id: 'ds.references.has-many.push-invalid-json-api',
7243
- until: '3.0'
7217
+ until: '4.0.0'
7244
7218
  }));
7245
7219
  }
7246
7220
  }
@@ -7628,7 +7602,7 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
7628
7602
  }
7629
7603
 
7630
7604
  function relationshipFromMeta(meta) {
7631
- return {
7605
+ var result = {
7632
7606
  key: meta.key,
7633
7607
  kind: meta.kind,
7634
7608
  type: typeForRelationshipMeta(meta),
@@ -7637,6 +7611,12 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
7637
7611
  parentType: meta.parentType,
7638
7612
  isRelationship: true
7639
7613
  };
7614
+
7615
+ if (false) {
7616
+ result.parentType = meta.parentType;
7617
+ }
7618
+
7619
+ return result;
7640
7620
  }
7641
7621
  });
7642
7622
  define('ember-data/-private/system/relationships/belongs-to', ['exports', 'ember-data/-private/system/normalize-model-name'], function (exports, _normalizeModelName) {
@@ -8046,7 +8026,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8046
8026
  }
8047
8027
  }
8048
8028
 
8049
- var get = Ember.get;
8029
+ var _get = Ember.get;
8050
8030
 
8051
8031
  var RelationshipPayloadsManager = function () {
8052
8032
  function RelationshipPayloadsManager(store) {
@@ -8055,7 +8035,6 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8055
8035
  this._store = store;
8056
8036
  // cache of `RelationshipPayload`s
8057
8037
  this._cache = Object.create(null);
8058
- this._inverseLookupCache = new _relationshipPayloads.TypeCache();
8059
8038
  }
8060
8039
 
8061
8040
  /**
@@ -8076,7 +8055,9 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8076
8055
 
8077
8056
 
8078
8057
  RelationshipPayloadsManager.prototype.get = function get(modelName, id, relationshipName) {
8079
- var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, false);
8058
+ var modelClass = this._store._modelFor(modelName);
8059
+ var relationshipsByName = _get(modelClass, 'relationshipsByName');
8060
+ var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
8080
8061
  return relationshipPayloads && relationshipPayloads.get(modelName, id, relationshipName);
8081
8062
  };
8082
8063
 
@@ -8087,8 +8068,10 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8087
8068
  return;
8088
8069
  }
8089
8070
 
8071
+ var modelClass = this._store._modelFor(modelName);
8072
+ var relationshipsByName = _get(modelClass, 'relationshipsByName');
8090
8073
  Object.keys(relationshipsData).forEach(function (key) {
8091
- var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, true);
8074
+ var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, modelClass, relationshipsByName, true);
8092
8075
  if (relationshipPayloads) {
8093
8076
  relationshipPayloads.push(modelName, id, key, relationshipsData[key]);
8094
8077
  }
@@ -8099,153 +8082,51 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8099
8082
  var _this2 = this;
8100
8083
 
8101
8084
  var modelClass = this._store._modelFor(modelName);
8102
- var relationshipsByName = get(modelClass, 'relationshipsByName');
8085
+ var relationshipsByName = _get(modelClass, 'relationshipsByName');
8103
8086
  relationshipsByName.forEach(function (_, relationshipName) {
8104
- var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, false);
8087
+ var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
8105
8088
  if (relationshipPayloads) {
8106
8089
  relationshipPayloads.unload(modelName, id, relationshipName);
8107
8090
  }
8108
8091
  });
8109
8092
  };
8110
8093
 
8111
- RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, init) {
8112
- var relInfo = this.getRelationshipInfo(modelName, relationshipName);
8113
-
8114
- if (relInfo === null) {
8094
+ RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, init) {
8095
+ if (!relationshipsByName.has(relationshipName)) {
8115
8096
  return;
8116
8097
  }
8117
8098
 
8118
- var cache = this._cache[relInfo.lhs_key];
8119
-
8120
- if (!cache && init) {
8121
- return this._initializeRelationshipPayloads(relInfo);
8099
+ var key = modelName + ':' + relationshipName;
8100
+ if (!this._cache[key] && init) {
8101
+ return this._initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName);
8122
8102
  }
8123
8103
 
8124
- return cache;
8104
+ return this._cache[key];
8125
8105
  };
8126
8106
 
8127
- RelationshipPayloadsManager.prototype.getRelationshipInfo = function getRelationshipInfo(modelName, relationshipName) {
8128
- var inverseCache = this._inverseLookupCache;
8129
- var store = this._store;
8130
- var cached = inverseCache.get(modelName, relationshipName);
8131
-
8132
- // CASE: We have a cached resolution (null if no relationship exists)
8133
- if (cached !== undefined) {
8134
- return cached;
8135
- }
8136
-
8137
- var modelClass = store._modelFor(modelName);
8138
- var relationshipsByName = get(modelClass, 'relationshipsByName');
8139
-
8140
- // CASE: We don't have a relationship at all
8141
- if (!relationshipsByName.has(relationshipName)) {
8142
- inverseCache.set(modelName, relationshipName, null);
8143
- return null;
8144
- }
8145
-
8146
- var inverseMeta = modelClass.inverseFor(relationshipName, store);
8107
+ RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName) {
8147
8108
  var relationshipMeta = relationshipsByName.get(relationshipName);
8148
- var selfIsPolymorphic = relationshipMeta.options !== undefined && relationshipMeta.options.polymorphic === true;
8149
- var inverseBaseModelName = relationshipMeta.type;
8150
-
8151
- // CASE: We have no inverse
8152
- if (!inverseMeta) {
8153
- var _info = {
8154
- lhs_key: modelName + ':' + relationshipName,
8155
- lhs_modelNames: [modelName],
8156
- lhs_baseModelName: modelName,
8157
- lhs_relationshipName: relationshipName,
8158
- lhs_relationshipMeta: relationshipMeta,
8159
- lhs_isPolymorphic: selfIsPolymorphic,
8160
- rhs_key: '',
8161
- rhs_modelNames: [],
8162
- rhs_baseModelName: inverseBaseModelName,
8163
- rhs_relationshipName: '',
8164
- rhs_relationshipMeta: null,
8165
- rhs_isPolymorphic: false,
8166
- hasInverse: false,
8167
- isSelfReferential: false, // modelName === inverseBaseModelName,
8168
- isReflexive: false
8169
- };
8170
-
8171
- inverseCache.set(modelName, relationshipName, _info);
8172
-
8173
- return _info;
8109
+ var inverseMeta = modelClass.inverseFor(relationshipName, this._store);
8110
+
8111
+ var inverseModelName = void 0;
8112
+ var inverseRelationshipName = void 0;
8113
+ var inverseRelationshipMeta = void 0;
8114
+
8115
+ // figure out the inverse relationship; we need two things
8116
+ // a) the inverse model name
8117
+ //- b) the name of the inverse relationship
8118
+ if (inverseMeta) {
8119
+ inverseRelationshipName = inverseMeta.name;
8120
+ inverseModelName = relationshipMeta.type;
8121
+ inverseRelationshipMeta = _get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
8122
+ } else {
8123
+ // relationship has no inverse
8124
+ inverseModelName = inverseRelationshipName = '';
8125
+ inverseRelationshipMeta = null;
8174
8126
  }
8175
8127
 
8176
- // CASE: We do have an inverse
8177
-
8178
- var inverseRelationshipName = inverseMeta.name;
8179
- var inverseRelationshipMeta = get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
8180
- var baseModelName = inverseRelationshipMeta.type;
8181
- var isSelfReferential = baseModelName === inverseBaseModelName;
8182
-
8183
- // TODO we want to assert this but this breaks all of our shoddily written tests
8184
- /*
8185
- if (DEBUG) {
8186
- let inverseDoubleCheck = inverseMeta.type.inverseFor(inverseRelationshipName, store);
8187
- assert(`The ${inverseBaseModelName}:${inverseRelationshipName} relationship declares 'inverse: null', but it was resolved as the inverse for ${baseModelName}:${relationshipName}.`, inverseDoubleCheck);
8188
- }
8189
- */
8190
-
8191
- // CASE: We may have already discovered the inverse for the baseModelName
8192
- // CASE: We have already discovered the inverse
8193
- cached = inverseCache.get(baseModelName, relationshipName) || inverseCache.get(inverseBaseModelName, inverseRelationshipName);
8194
- if (cached) {
8195
- (false && Ember.assert('The ' + inverseBaseModelName + ':' + inverseRelationshipName + ' relationship declares \'inverse: null\', but it was resolved as the inverse for ' + baseModelName + ':' + relationshipName + '.', cached.hasInverse !== false));
8196
-
8197
-
8198
- var isLHS = cached.lhs_baseModelName === baseModelName;
8199
- var modelNames = isLHS ? cached.lhs_modelNames : cached.rhs_modelNames;
8200
- // make this lookup easier in the future by caching the key
8201
- modelNames.push(modelName);
8202
- inverseCache.set(modelName, relationshipName, cached);
8203
-
8204
- return cached;
8205
- }
8206
-
8207
- var info = {
8208
- lhs_key: baseModelName + ':' + relationshipName,
8209
- lhs_modelNames: [modelName],
8210
- lhs_baseModelName: baseModelName,
8211
- lhs_relationshipName: relationshipName,
8212
- lhs_relationshipMeta: relationshipMeta,
8213
- lhs_isPolymorphic: selfIsPolymorphic,
8214
- rhs_key: inverseBaseModelName + ':' + inverseRelationshipName,
8215
- rhs_modelNames: [],
8216
- rhs_baseModelName: inverseBaseModelName,
8217
- rhs_relationshipName: inverseRelationshipName,
8218
- rhs_relationshipMeta: inverseRelationshipMeta,
8219
- rhs_isPolymorphic: inverseRelationshipMeta.options !== undefined && inverseRelationshipMeta.options.polymorphic === true,
8220
- hasInverse: true,
8221
- isSelfReferential: isSelfReferential,
8222
- isReflexive: isSelfReferential && relationshipName === inverseRelationshipName
8223
- };
8224
-
8225
- // Create entries for the baseModelName as well as modelName to speed up
8226
- // inverse lookups
8227
- inverseCache.set(baseModelName, relationshipName, info);
8228
- inverseCache.set(modelName, relationshipName, info);
8229
-
8230
- // Greedily populate the inverse
8231
- inverseCache.set(inverseBaseModelName, inverseRelationshipName, info);
8232
-
8233
- return info;
8234
- };
8235
-
8236
- RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(relInfo) {
8237
- var lhsKey = relInfo.lhs_key;
8238
- var rhsKey = relInfo.rhs_key;
8239
- var existingPayloads = this._cache[lhsKey];
8240
-
8241
- if (relInfo.hasInverse === true && relInfo.rhs_isPolymorphic === true) {
8242
- existingPayloads = this._cache[rhsKey];
8243
-
8244
- if (existingPayloads !== undefined) {
8245
- this._cache[lhsKey] = existingPayloads;
8246
- return existingPayloads;
8247
- }
8248
- }
8128
+ var lhsKey = modelName + ':' + relationshipName;
8129
+ var rhsKey = inverseModelName + ':' + inverseRelationshipName;
8249
8130
 
8250
8131
  // populate the cache for both sides of the relationship, as they both use
8251
8132
  // the same `RelationshipPayloads`.
@@ -8253,13 +8134,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
8253
8134
  // This works out better than creating a single common key, because to
8254
8135
  // compute that key we would need to do work to look up the inverse
8255
8136
  //
8256
- var cache = this._cache[lhsKey] = new _relationshipPayloads.default(relInfo);
8257
-
8258
- if (relInfo.hasInverse === true) {
8259
- this._cache[rhsKey] = cache;
8260
- }
8261
-
8262
- return cache;
8137
+ return this._cache[lhsKey] = this._cache[rhsKey] = new _relationshipPayloads.default(this._store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta);
8263
8138
  };
8264
8139
 
8265
8140
  return RelationshipPayloadsManager;
@@ -8272,6 +8147,12 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8272
8147
 
8273
8148
  exports.__esModule = true;
8274
8149
 
8150
+ function _classCallCheck(instance, Constructor) {
8151
+ if (!(instance instanceof Constructor)) {
8152
+ throw new TypeError("Cannot call a class as a function");
8153
+ }
8154
+ }
8155
+
8275
8156
  var _createClass = function () {
8276
8157
  function defineProperties(target, props) {
8277
8158
  for (var i = 0; i < props.length; i++) {
@@ -8290,61 +8171,37 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8290
8171
  };
8291
8172
  }();
8292
8173
 
8293
- function _classCallCheck(instance, Constructor) {
8294
- if (!(instance instanceof Constructor)) {
8295
- throw new TypeError("Cannot call a class as a function");
8296
- }
8297
- }
8298
-
8299
- var TypeCache = exports.TypeCache = function () {
8300
- function TypeCache() {
8301
- _classCallCheck(this, TypeCache);
8302
-
8303
- this.types = Object.create(null);
8304
- }
8305
-
8306
- TypeCache.prototype.get = function get(modelName, id) {
8307
- var types = this.types;
8308
-
8309
-
8310
- if (types[modelName] !== undefined) {
8311
- return types[modelName][id];
8312
- }
8313
- };
8314
-
8315
- TypeCache.prototype.set = function set(modelName, id, payload) {
8316
- var types = this.types;
8317
-
8318
- var typeMap = types[modelName];
8319
-
8320
- if (typeMap === undefined) {
8321
- typeMap = types[modelName] = Object.create(null);
8322
- }
8323
-
8324
- typeMap[id] = payload;
8325
- };
8326
-
8327
- TypeCache.prototype.delete = function _delete(modelName, id) {
8328
- var types = this.types;
8329
-
8330
-
8331
- if (types[modelName] !== undefined) {
8332
- delete types[modelName][id];
8333
- }
8334
- };
8335
-
8336
- return TypeCache;
8337
- }();
8338
-
8339
8174
  var RelationshipPayloads = function () {
8340
- function RelationshipPayloads(relInfo) {
8175
+ function RelationshipPayloads(store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta) {
8341
8176
  _classCallCheck(this, RelationshipPayloads);
8342
8177
 
8343
- this._relInfo = relInfo;
8178
+ this._store = store;
8179
+
8180
+ this._lhsModelName = modelName;
8181
+ this._lhsRelationshipName = relationshipName;
8182
+ this._lhsRelationshipMeta = relationshipMeta;
8183
+
8184
+ this._rhsModelName = inverseModelName;
8185
+ this._rhsRelationshipName = inverseRelationshipName;
8186
+ this._rhsRelationshipMeta = inverseRelationshipMeta;
8344
8187
 
8345
8188
  // a map of id -> payloads for the left hand side of the relationship.
8346
- this.lhs_payloads = new TypeCache();
8347
- this.rhs_payloads = relInfo.isReflexive ? this.lhs_payloads : new TypeCache();
8189
+ this._lhsPayloads = Object.create(null);
8190
+ if (modelName !== inverseModelName || relationshipName !== inverseRelationshipName) {
8191
+ // The common case of a non-reflexive relationship, or a reflexive
8192
+ // relationship whose inverse is not itself
8193
+ this._rhsPayloads = Object.create(null);
8194
+ this._isReflexive = false;
8195
+ } else {
8196
+ // Edge case when we have a reflexive relationship to itself
8197
+ // eg user hasMany friends inverse friends
8198
+ //
8199
+ // In this case there aren't really two sides to the relationship, but
8200
+ // we set `_rhsPayloads = _lhsPayloads` to make things easier to reason
8201
+ // about
8202
+ this._rhsPayloads = this._lhsPayloads;
8203
+ this._isReflexive = true;
8204
+ }
8348
8205
 
8349
8206
  // When we push relationship payloads, just stash them in a queue until
8350
8207
  // somebody actually asks for one of them.
@@ -8355,22 +8212,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8355
8212
  }
8356
8213
 
8357
8214
  /**
8358
- Get the payload for the relationship of an individual record.
8359
- This might return the raw payload as pushed into the store, or one computed
8360
- from the payload of the inverse relationship.
8361
- @method
8362
- */
8215
+ Get the payload for the relationship of an individual record.
8216
+ This might return the raw payload as pushed into the store, or one computed
8217
+ from the payload of the inverse relationship.
8218
+ @method
8219
+ */
8363
8220
 
8364
8221
 
8365
8222
  RelationshipPayloads.prototype.get = function get(modelName, id, relationshipName) {
8366
8223
  this._flushPending();
8367
8224
 
8368
8225
  if (this._isLHS(modelName, relationshipName)) {
8369
- return this.lhs_payloads.get(modelName, id);
8226
+ return this._lhsPayloads[id];
8370
8227
  } else {
8371
- (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName)));
8228
+ (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
8372
8229
 
8373
- return this.rhs_payloads.get(modelName, id);
8230
+ return this._rhsPayloads[id];
8374
8231
  }
8375
8232
  };
8376
8233
 
@@ -8382,40 +8239,20 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8382
8239
  this._flushPending();
8383
8240
 
8384
8241
  if (this._isLHS(modelName, relationshipName)) {
8385
- delete this.lhs_payloads.delete(modelName, id);
8242
+ delete this._lhsPayloads[id];
8386
8243
  } else {
8387
- (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)));
8244
+ (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
8388
8245
 
8389
- delete this.rhs_payloads.delete(modelName, id);
8246
+ delete this._rhsPayloads[id];
8390
8247
  }
8391
8248
  };
8392
8249
 
8393
8250
  RelationshipPayloads.prototype._isLHS = function _isLHS(modelName, relationshipName) {
8394
- var relInfo = this._relInfo;
8395
- var isSelfReferential = relInfo.isSelfReferential;
8396
- var isRelationship = relationshipName === relInfo.lhs_relationshipName;
8397
-
8398
- if (isRelationship === true) {
8399
- return isSelfReferential === true || // itself
8400
- modelName === relInfo.lhs_baseModelName || // base or non-polymorphic
8401
- relInfo.lhs_modelNames.indexOf(modelName) !== -1; // polymorphic
8402
- }
8403
-
8404
- return false;
8251
+ return modelName === this._lhsModelName && relationshipName === this._lhsRelationshipName;
8405
8252
  };
8406
8253
 
8407
8254
  RelationshipPayloads.prototype._isRHS = function _isRHS(modelName, relationshipName) {
8408
- var relInfo = this._relInfo;
8409
- var isSelfReferential = relInfo.isSelfReferential;
8410
- var isRelationship = relationshipName === relInfo.rhs_relationshipName;
8411
-
8412
- if (isRelationship === true) {
8413
- return isSelfReferential === true || // itself
8414
- modelName === relInfo.rhs_baseModelName || // base or non-polymorphic
8415
- relInfo.rhs_modelNames.indexOf(modelName) !== -1; // polymorphic
8416
- }
8417
-
8418
- return false;
8255
+ return modelName === this._rhsModelName && relationshipName === this._rhsRelationshipName;
8419
8256
  };
8420
8257
 
8421
8258
  RelationshipPayloads.prototype._flushPending = function _flushPending() {
@@ -8436,28 +8273,26 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8436
8273
  id: id,
8437
8274
  type: modelName
8438
8275
  }
8439
- };
8440
8276
 
8441
- // start flushing this individual payload. The logic is the same whether
8442
- // it's for the left hand side of the relationship or the right hand side,
8443
- // except the role of primary and inverse idToPayloads is reversed
8444
- //
8445
- var previousPayload = void 0;
8446
- var payloadMap = void 0;
8447
- var inversePayloadMap = void 0;
8277
+ // start flushing this individual payload. The logic is the same whether
8278
+ // it's for the left hand side of the relationship or the right hand side,
8279
+ // except the role of primary and inverse idToPayloads is reversed
8280
+ //
8281
+ };var previousPayload = void 0;
8282
+ var idToPayloads = void 0;
8283
+ var inverseIdToPayloads = void 0;
8448
8284
  var inverseIsMany = void 0;
8449
-
8450
8285
  if (this._isLHS(modelName, relationshipName)) {
8451
- previousPayload = this.lhs_payloads.get(modelName, id);
8452
- payloadMap = this.lhs_payloads;
8453
- inversePayloadMap = this.rhs_payloads;
8286
+ previousPayload = this._lhsPayloads[id];
8287
+ idToPayloads = this._lhsPayloads;
8288
+ inverseIdToPayloads = this._rhsPayloads;
8454
8289
  inverseIsMany = this._rhsRelationshipIsMany;
8455
8290
  } else {
8456
- (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName)));
8291
+ (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
8457
8292
 
8458
- previousPayload = this.rhs_payloads.get(modelName, id);
8459
- payloadMap = this.rhs_payloads;
8460
- inversePayloadMap = this.lhs_payloads;
8293
+ previousPayload = this._rhsPayloads[id];
8294
+ idToPayloads = this._rhsPayloads;
8295
+ inverseIdToPayloads = this._lhsPayloads;
8461
8296
  inverseIsMany = this._lhsRelationshipIsMany;
8462
8297
  }
8463
8298
 
@@ -8501,14 +8336,14 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8501
8336
  // * undefined is NOT considered new information, we should keep original state
8502
8337
  // * anything else is considered new information, and it should win
8503
8338
  if (relationshipData.data !== undefined) {
8504
- this._removeInverse(id, previousPayload, inversePayloadMap);
8339
+ this._removeInverse(id, previousPayload, inverseIdToPayloads);
8505
8340
  }
8506
- payloadMap.set(modelName, id, relationshipData);
8507
- this._populateInverse(relationshipData, inverseRelationshipData, inversePayloadMap, inverseIsMany);
8341
+ idToPayloads[id] = relationshipData;
8342
+ this._populateInverse(relationshipData, inverseRelationshipData, inverseIdToPayloads, inverseIsMany);
8508
8343
  }
8509
8344
  };
8510
8345
 
8511
- RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inversePayloadMap, inverseIsMany) {
8346
+ RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inverseIdToPayloads, inverseIsMany) {
8512
8347
  if (!relationshipData.data) {
8513
8348
  // This id doesn't have an inverse, eg a belongsTo with a payload
8514
8349
  // { data: null }, so there's nothing to populate
@@ -8517,24 +8352,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8517
8352
 
8518
8353
  if (Array.isArray(relationshipData.data)) {
8519
8354
  for (var i = 0; i < relationshipData.data.length; ++i) {
8520
- var resourceIdentifier = relationshipData.data[i];
8521
- this._addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany);
8355
+ var inverseId = relationshipData.data[i].id;
8356
+ this._addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany);
8522
8357
  }
8523
8358
  } else {
8524
- var _resourceIdentifier = relationshipData.data;
8525
- this._addToInverse(inversePayload, _resourceIdentifier, inversePayloadMap, inverseIsMany);
8359
+ var _inverseId = relationshipData.data.id;
8360
+ this._addToInverse(inversePayload, _inverseId, inverseIdToPayloads, inverseIsMany);
8526
8361
  }
8527
8362
  };
8528
8363
 
8529
- RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany) {
8530
- var relInfo = this._relInfo;
8531
-
8532
- if (relInfo.isReflexive && inversePayload.data.id === resourceIdentifier.id) {
8364
+ RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany) {
8365
+ if (this._isReflexive && inversePayload.data.id === inverseId) {
8533
8366
  // eg <user:1>.friends = [{ id: 1, type: 'user' }]
8534
8367
  return;
8535
8368
  }
8536
8369
 
8537
- var existingPayload = inversePayloadMap.get(resourceIdentifier.type, resourceIdentifier.id);
8370
+ var existingPayload = inverseIdToPayloads[inverseId];
8538
8371
  var existingData = existingPayload && existingPayload.data;
8539
8372
 
8540
8373
  if (existingData) {
@@ -8544,22 +8377,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8544
8377
  if (Array.isArray(existingData)) {
8545
8378
  existingData.push(inversePayload.data);
8546
8379
  } else {
8547
- inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload);
8380
+ inverseIdToPayloads[inverseId] = inversePayload;
8548
8381
  }
8549
8382
  } else {
8550
8383
  // first time we're populating the inverse side
8551
8384
  //
8552
8385
  if (inverseIsMany) {
8553
- inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, {
8386
+ inverseIdToPayloads[inverseId] = {
8554
8387
  data: [inversePayload.data]
8555
- });
8388
+ };
8556
8389
  } else {
8557
- inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload);
8390
+ inverseIdToPayloads[inverseId] = inversePayload;
8558
8391
  }
8559
8392
  }
8560
8393
  };
8561
8394
 
8562
- RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inversePayloadMap) {
8395
+ RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inverseIdToPayloads) {
8563
8396
  var data = previousPayload && previousPayload.data;
8564
8397
  if (!data) {
8565
8398
  // either this is the first time we've seen a payload for this id, or its
@@ -8574,16 +8407,15 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8574
8407
  if (Array.isArray(data)) {
8575
8408
  // TODO: diff rather than removeall addall?
8576
8409
  for (var i = 0; i < data.length; ++i) {
8577
- var resourceIdentifier = data[i];
8578
- this._removeFromInverse(id, resourceIdentifier, inversePayloadMap);
8410
+ this._removeFromInverse(id, data[i].id, inverseIdToPayloads);
8579
8411
  }
8580
8412
  } else {
8581
- this._removeFromInverse(id, data, inversePayloadMap);
8413
+ this._removeFromInverse(id, data.id, inverseIdToPayloads);
8582
8414
  }
8583
8415
  };
8584
8416
 
8585
- RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, resourceIdentifier, inversePayloads) {
8586
- var inversePayload = inversePayloads.get(resourceIdentifier.type, resourceIdentifier.id);
8417
+ RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, inverseId, inversePayloads) {
8418
+ var inversePayload = inversePayloads[inverseId];
8587
8419
  var data = inversePayload && inversePayload.data;
8588
8420
 
8589
8421
  if (!data) {
@@ -8595,23 +8427,21 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
8595
8427
  return x.id !== id;
8596
8428
  });
8597
8429
  } else {
8598
- inversePayloads.set(resourceIdentifier.type, resourceIdentifier.id, {
8430
+ inversePayloads[inverseId] = {
8599
8431
  data: null
8600
- });
8432
+ };
8601
8433
  }
8602
8434
  };
8603
8435
 
8604
8436
  _createClass(RelationshipPayloads, [{
8605
8437
  key: '_lhsRelationshipIsMany',
8606
8438
  get: function () {
8607
- var meta = this._relInfo.lhs_relationshipMeta;
8608
- return meta !== null && meta.kind === 'hasMany';
8439
+ return this._lhsRelationshipMeta && this._lhsRelationshipMeta.kind === 'hasMany';
8609
8440
  }
8610
8441
  }, {
8611
8442
  key: '_rhsRelationshipIsMany',
8612
8443
  get: function () {
8613
- var meta = this._relInfo.rhs_relationshipMeta;
8614
- return meta !== null && meta.kind === 'hasMany';
8444
+ return this._rhsRelationshipMeta && this._rhsRelationshipMeta.kind === 'hasMany';
8615
8445
  }
8616
8446
  }]);
8617
8447
 
@@ -8720,7 +8550,6 @@ define('ember-data/-private/system/relationships/state/belongs-to', ['exports',
8720
8550
  };
8721
8551
 
8722
8552
  BelongsToRelationship.prototype.inverseDidDematerialize = function inverseDidDematerialize() {
8723
- _Relationship.prototype.inverseDidDematerialize.call(this, this.inverseInternalModel);
8724
8553
  this.notifyBelongsToChanged();
8725
8554
  };
8726
8555
 
@@ -8737,12 +8566,6 @@ define('ember-data/-private/system/relationships/state/belongs-to', ['exports',
8737
8566
  }
8738
8567
  };
8739
8568
 
8740
- BelongsToRelationship.prototype.removeCompletelyFromInverse = function removeCompletelyFromInverse() {
8741
- _Relationship.prototype.removeCompletelyFromInverse.call(this);
8742
-
8743
- this.inverseInternalModel = null;
8744
- };
8745
-
8746
8569
  BelongsToRelationship.prototype.flushCanonical = function flushCanonical() {
8747
8570
  //temporary fix to not remove newly created records if server returned null.
8748
8571
  //TODO remove once we have proper diffing
@@ -8789,12 +8612,6 @@ define('ember-data/-private/system/relationships/state/belongs-to', ['exports',
8789
8612
  this.notifyBelongsToChanged();
8790
8613
  };
8791
8614
 
8792
- BelongsToRelationship.prototype.removeAllInternalModelsFromOwn = function removeAllInternalModelsFromOwn() {
8793
- _Relationship.prototype.removeAllInternalModelsFromOwn.call(this);
8794
- this.inverseInternalModel = null;
8795
- this.notifyBelongsToChanged();
8796
- };
8797
-
8798
8615
  BelongsToRelationship.prototype.notifyBelongsToChanged = function notifyBelongsToChanged() {
8799
8616
  this.internalModel.notifyBelongsToChanged(this.key);
8800
8617
  };
@@ -8807,11 +8624,6 @@ define('ember-data/-private/system/relationships/state/belongs-to', ['exports',
8807
8624
  _Relationship.prototype.removeCanonicalInternalModelFromOwn.call(this, internalModel);
8808
8625
  };
8809
8626
 
8810
- BelongsToRelationship.prototype.removeAllCanonicalInternalModelsFromOwn = function removeAllCanonicalInternalModelsFromOwn() {
8811
- _Relationship.prototype.removeAllCanonicalInternalModelsFromOwn.call(this);
8812
- this.canonicalState = null;
8813
- };
8814
-
8815
8627
  BelongsToRelationship.prototype.findRecord = function findRecord() {
8816
8628
  if (this.inverseInternalModel) {
8817
8629
  return this.store._findByInternalModel(this.inverseInternalModel);
@@ -9076,12 +8888,7 @@ define('ember-data/-private/system/relationships/state/has-many', ['exports', 'e
9076
8888
  _this.belongsToType = relationshipMeta.type;
9077
8889
  _this.canonicalState = [];
9078
8890
  _this.isPolymorphic = relationshipMeta.options.polymorphic;
9079
- // The ManyArray for this relationship
9080
8891
  _this._manyArray = null;
9081
- // The previous ManyArray for this relationship. It will be destroyed when
9082
- // we create a new many array, but in the interim it will be updated if
9083
- // inverse internal models are unloaded.
9084
- _this._retainedManyArray = null;
9085
8892
  _this.__loadingPromise = null;
9086
8893
  return _this;
9087
8894
  }
@@ -9133,14 +8940,10 @@ define('ember-data/-private/system/relationships/state/has-many', ['exports', 'e
9133
8940
  _Relationship.prototype.addCanonicalInternalModel.call(this, internalModel, idx);
9134
8941
  };
9135
8942
 
9136
- ManyRelationship.prototype.inverseDidDematerialize = function inverseDidDematerialize(inverseInternalModel) {
9137
- _Relationship.prototype.inverseDidDematerialize.call(this, inverseInternalModel);
9138
- if (this.isAsync) {
9139
- if (this._manyArray) {
9140
- this._retainedManyArray = this._manyArray;
9141
- this._manyArray = null;
9142
- }
9143
- this._removeInternalModelFromManyArray(this._retainedManyArray, inverseInternalModel);
8943
+ ManyRelationship.prototype.inverseDidDematerialize = function inverseDidDematerialize() {
8944
+ if (this._manyArray) {
8945
+ this._manyArray.destroy();
8946
+ this._manyArray = null;
9144
8947
  }
9145
8948
  this.notifyHasManyChanged();
9146
8949
  };
@@ -9170,12 +8973,6 @@ define('ember-data/-private/system/relationships/state/has-many', ['exports', 'e
9170
8973
  _Relationship.prototype.removeCanonicalInternalModelFromOwn.call(this, internalModel, idx);
9171
8974
  };
9172
8975
 
9173
- ManyRelationship.prototype.removeAllCanonicalInternalModelsFromOwn = function removeAllCanonicalInternalModelsFromOwn() {
9174
- _Relationship.prototype.removeAllCanonicalInternalModelsFromOwn.call(this);
9175
- this.canonicalMembers.clear();
9176
- this.canonicalState.splice(0, this.canonicalState.length);
9177
- };
9178
-
9179
8976
  ManyRelationship.prototype.removeCompletelyFromOwn = function removeCompletelyFromOwn(internalModel) {
9180
8977
  _Relationship.prototype.removeCompletelyFromOwn.call(this, internalModel);
9181
8978
 
@@ -9208,33 +9005,7 @@ define('ember-data/-private/system/relationships/state/has-many', ['exports', 'e
9208
9005
  return;
9209
9006
  }
9210
9007
  _Relationship.prototype.removeInternalModelFromOwn.call(this, internalModel, idx);
9211
- // note that ensuring the many array is created, via `this.manyArray`
9212
- // (instead of `this._manyArray`) is intentional.
9213
- //
9214
- // Because we're removing from local, and not canonical, state, it is
9215
- // important that the many array is initialized now with those changes,
9216
- // otherwise it will be initialized with canonical state and we'll have
9217
- // lost the fact that this internalModel was removed.
9218
- this._removeInternalModelFromManyArray(this.manyArray, internalModel, idx);
9219
- this._removeInternalModelFromManyArray(this._retainedManyArray, internalModel, idx);
9220
- };
9221
-
9222
- ManyRelationship.prototype.removeAllInternalModelsFromOwn = function removeAllInternalModelsFromOwn() {
9223
- _Relationship.prototype.removeAllInternalModelsFromOwn.call(this);
9224
- // as with removeInternalModelFromOwn, we make sure the many array is
9225
- // instantiated, or we'll lose local removals, as we're not updating
9226
- // canonical state here.
9227
- this.manyArray.clear();
9228
- if (this._retainedManyArray) {
9229
- this._retainedManyArray.clear();
9230
- }
9231
- };
9232
-
9233
- ManyRelationship.prototype._removeInternalModelFromManyArray = function _removeInternalModelFromManyArray(manyArray, internalModel, idx) {
9234
- if (manyArray === null) {
9235
- return;
9236
- }
9237
-
9008
+ var manyArray = this.manyArray;
9238
9009
  if (idx !== undefined) {
9239
9010
  //TODO(Igor) not used currently, fix
9240
9011
  manyArray.currentState.removeAt(idx);
@@ -9396,14 +9167,12 @@ define('ember-data/-private/system/relationships/state/has-many', ['exports', 'e
9396
9167
  var manyArray = this._manyArray;
9397
9168
  if (manyArray) {
9398
9169
  manyArray.destroy();
9399
- this._manyArray = null;
9400
9170
  }
9401
9171
 
9402
9172
  var proxy = this.__loadingPromise;
9403
9173
 
9404
9174
  if (proxy) {
9405
9175
  proxy.destroy();
9406
- this.__loadingPromise = null;
9407
9176
  }
9408
9177
  };
9409
9178
 
@@ -9415,9 +9184,6 @@ define('ember-data/-private/system/relationships/state/has-many', ['exports', 'e
9415
9184
  }, {
9416
9185
  key: 'manyArray',
9417
9186
  get: function () {
9418
- (false && Ember.assert('Error: relationship ' + this.parentType + ':' + this.key + ' has both many array and retained many array', this._manyArray === null || this._retainedManyArray === null));
9419
-
9420
-
9421
9187
  if (!this._manyArray) {
9422
9188
  this._manyArray = _manyArray.default.create({
9423
9189
  canonicalState: this.canonicalState,
@@ -9428,13 +9194,7 @@ define('ember-data/-private/system/relationships/state/has-many', ['exports', 'e
9428
9194
  meta: this.meta,
9429
9195
  isPolymorphic: this.isPolymorphic
9430
9196
  });
9431
-
9432
- if (this._retainedManyArray !== null) {
9433
- this._retainedManyArray.destroy();
9434
- this._retainedManyArray = null;
9435
- }
9436
9197
  }
9437
-
9438
9198
  return this._manyArray;
9439
9199
  }
9440
9200
  }]);
@@ -9487,7 +9247,6 @@ define('ember-data/-private/system/relationships/state/relationship', ['exports'
9487
9247
  }();
9488
9248
 
9489
9249
  var guidFor = Ember.guidFor;
9490
- var get = Ember.get;
9491
9250
 
9492
9251
  var Relationship = function () {
9493
9252
  function Relationship(store, internalModel, inverseKey, relationshipMeta) {
@@ -9511,52 +9270,34 @@ define('ember-data/-private/system/relationships/state/relationship', ['exports'
9511
9270
  this.meta = null;
9512
9271
  this.hasData = false;
9513
9272
  this.hasLoaded = false;
9514
- this.__inverseMeta = undefined;
9515
9273
  }
9516
9274
 
9517
9275
  Relationship.prototype._inverseIsAsync = function _inverseIsAsync() {
9518
- var inverseMeta = this._inverseMeta;
9519
- if (!inverseMeta) {
9276
+ if (!this.inverseKey || !this.inverseInternalModel) {
9520
9277
  return false;
9521
9278
  }
9522
-
9523
- var inverseAsync = inverseMeta.options.async;
9524
- return typeof inverseAsync === 'undefined' ? true : inverseAsync;
9279
+ return this.inverseInternalModel._relationships.get(this.inverseKey).isAsync;
9525
9280
  };
9526
9281
 
9527
- Relationship.prototype._inverseIsSync = function _inverseIsSync() {
9528
- var inverseMeta = this._inverseMeta;
9529
- if (!inverseMeta) {
9530
- return false;
9531
- }
9532
-
9533
- var inverseAsync = inverseMeta.options.async;
9534
- return typeof inverseAsync === 'undefined' ? false : !inverseAsync;
9535
- };
9536
-
9537
- Relationship.prototype.internalModelDidDematerialize = function internalModelDidDematerialize() {
9538
- var _this = this;
9539
-
9282
+ Relationship.prototype.removeInverseRelationships = function removeInverseRelationships() {
9540
9283
  if (!this.inverseKey) {
9541
9284
  return;
9542
9285
  }
9543
9286
 
9544
- this.forAllMembers(function (inverseInternalModel) {
9545
- var relationship = inverseInternalModel._relationships.get(_this.inverseKey);
9546
- relationship.inverseDidDematerialize(_this.internalModel);
9547
- });
9548
- };
9287
+ var allMembers =
9288
+ // we actually want a union of members and canonicalMembers
9289
+ // they should be disjoint but currently are not due to a bug
9290
+ this.members.list.concat(this.canonicalMembers.list);
9549
9291
 
9550
- Relationship.prototype.inverseDidDematerialize = function inverseDidDematerialize(inverseInternalModel) {
9551
- if (!this.isAsync) {
9552
- // unloading inverse of a sync relationship is treated as a client-side
9553
- // delete, so actually remove the models don't merely invalidate the cp
9554
- // cache.
9555
- this.removeInternalModelFromOwn(inverseInternalModel);
9556
- this.removeCanonicalInternalModelFromOwn(inverseInternalModel);
9292
+ for (var i = 0; i < allMembers.length; i++) {
9293
+ var inverseInternalModel = allMembers[i];
9294
+ var relationship = inverseInternalModel._relationships.get(this.inverseKey);
9295
+ relationship.inverseDidDematerialize();
9557
9296
  }
9558
9297
  };
9559
9298
 
9299
+ Relationship.prototype.inverseDidDematerialize = function inverseDidDematerialize() {};
9300
+
9560
9301
  Relationship.prototype.updateMeta = function updateMeta(meta) {
9561
9302
  this.meta = meta;
9562
9303
  };
@@ -9576,29 +9317,19 @@ define('ember-data/-private/system/relationships/state/relationship', ['exports'
9576
9317
  }
9577
9318
  };
9578
9319
 
9579
- Relationship.prototype.removeAllInternalModelsFromOwn = function removeAllInternalModelsFromOwn() {
9580
- this.members.clear();
9581
- this.internalModel.updateRecordArrays();
9582
- };
9583
-
9584
- Relationship.prototype.removeAllCanonicalInternalModelsFromOwn = function removeAllCanonicalInternalModelsFromOwn() {
9585
- this.canonicalMembers.clear();
9586
- this.flushCanonicalLater();
9587
- };
9588
-
9589
9320
  Relationship.prototype.removeInternalModels = function removeInternalModels(internalModels) {
9590
- var _this2 = this;
9321
+ var _this = this;
9591
9322
 
9592
9323
  internalModels.forEach(function (internalModel) {
9593
- return _this2.removeInternalModel(internalModel);
9324
+ return _this.removeInternalModel(internalModel);
9594
9325
  });
9595
9326
  };
9596
9327
 
9597
9328
  Relationship.prototype.addInternalModels = function addInternalModels(internalModels, idx) {
9598
- var _this3 = this;
9329
+ var _this2 = this;
9599
9330
 
9600
9331
  internalModels.forEach(function (internalModel) {
9601
- _this3.addInternalModel(internalModel, idx);
9332
+ _this2.addInternalModel(internalModel, idx);
9602
9333
  if (idx !== undefined) {
9603
9334
  idx++;
9604
9335
  }
@@ -9641,7 +9372,7 @@ define('ember-data/-private/system/relationships/state/relationship', ['exports'
9641
9372
  var _relationships = internalModel._implicitRelationships;
9642
9373
  var _relationship = _relationships[this.inverseKeyForImplicit];
9643
9374
  if (!_relationship) {
9644
- _relationship = _relationships[this.inverseKeyForImplicit] = new Relationship(this.store, internalModel, this.key, { options: { async: this.isAsync }, type: this.parentType });
9375
+ _relationship = _relationships[this.inverseKeyForImplicit] = new Relationship(this.store, internalModel, this.key, { options: { async: this.isAsync } });
9645
9376
  }
9646
9377
  _relationship.addCanonicalInternalModel(this.internalModel);
9647
9378
  }
@@ -9679,7 +9410,7 @@ define('ember-data/-private/system/relationships/state/relationship', ['exports'
9679
9410
  internalModel._relationships.get(this.inverseKey).addInternalModel(this.internalModel);
9680
9411
  } else {
9681
9412
  if (!internalModel._implicitRelationships[this.inverseKeyForImplicit]) {
9682
- internalModel._implicitRelationships[this.inverseKeyForImplicit] = new Relationship(this.store, internalModel, this.key, { options: { async: this.isAsync }, type: this.parentType });
9413
+ internalModel._implicitRelationships[this.inverseKeyForImplicit] = new Relationship(this.store, internalModel, this.key, { options: { async: this.isAsync } });
9683
9414
  }
9684
9415
  internalModel._implicitRelationships[this.inverseKeyForImplicit].addInternalModel(this.internalModel);
9685
9416
  }
@@ -9728,7 +9459,7 @@ define('ember-data/-private/system/relationships/state/relationship', ['exports'
9728
9459
  };
9729
9460
 
9730
9461
  Relationship.prototype.removeCompletelyFromInverse = function removeCompletelyFromInverse() {
9731
- var _this4 = this;
9462
+ var _this3 = this;
9732
9463
 
9733
9464
  if (!this.inverseKey) {
9734
9465
  return;
@@ -9743,7 +9474,7 @@ define('ember-data/-private/system/relationships/state/relationship', ['exports'
9743
9474
  var id = guidFor(inverseInternalModel);
9744
9475
 
9745
9476
  if (seen[id] === undefined) {
9746
- var relationship = inverseInternalModel._relationships.get(_this4.inverseKey);
9477
+ var relationship = inverseInternalModel._relationships.get(_this3.inverseKey);
9747
9478
  relationship.removeCompletelyFromOwn(internalModel);
9748
9479
  seen[id] = true;
9749
9480
  }
@@ -9751,32 +9482,6 @@ define('ember-data/-private/system/relationships/state/relationship', ['exports'
9751
9482
 
9752
9483
  this.members.forEach(unload);
9753
9484
  this.canonicalMembers.forEach(unload);
9754
-
9755
- if (!this.isAsync) {
9756
- this.clear();
9757
- }
9758
- };
9759
-
9760
- Relationship.prototype.forAllMembers = function forAllMembers(callback) {
9761
- var seen = Object.create(null);
9762
-
9763
- for (var i = 0; i < this.members.list.length; i++) {
9764
- var inverseInternalModel = this.members.list[i];
9765
- var id = guidFor(inverseInternalModel);
9766
- if (!seen[id]) {
9767
- seen[id] = true;
9768
- callback(inverseInternalModel);
9769
- }
9770
- }
9771
-
9772
- for (var _i = 0; _i < this.canonicalMembers.list.length; _i++) {
9773
- var _inverseInternalModel = this.canonicalMembers.list[_i];
9774
- var _id = guidFor(_inverseInternalModel);
9775
- if (!seen[_id]) {
9776
- seen[_id] = true;
9777
- callback(_inverseInternalModel);
9778
- }
9779
- }
9780
9485
  };
9781
9486
 
9782
9487
  Relationship.prototype.removeCompletelyFromOwn = function removeCompletelyFromOwn(internalModel) {
@@ -9799,8 +9504,8 @@ define('ember-data/-private/system/relationships/state/relationship', ['exports'
9799
9504
 
9800
9505
  //TODO(Igor) make this less abysmally slow
9801
9506
  this.members = this.canonicalMembers.copy();
9802
- for (var _i2 = 0; _i2 < newInternalModels.length; _i2++) {
9803
- this.members.add(newInternalModels[_i2]);
9507
+ for (var _i = 0; _i < newInternalModels.length; _i++) {
9508
+ this.members.add(newInternalModels[_i]);
9804
9509
  }
9805
9510
  };
9806
9511
 
@@ -9901,23 +9606,6 @@ define('ember-data/-private/system/relationships/state/relationship', ['exports'
9901
9606
  Relationship.prototype.destroy = function destroy() {};
9902
9607
 
9903
9608
  _createClass(Relationship, [{
9904
- key: '_inverseMeta',
9905
- get: function () {
9906
- if (this.__inverseMeta === undefined) {
9907
- var inverseMeta = null;
9908
-
9909
- if (this.inverseKey) {
9910
- var inverseModelClass = this.store.modelFor(this.relationshipMeta.type);
9911
- var inverseRelationships = get(inverseModelClass, 'relationshipsByName');
9912
- inverseMeta = inverseRelationships.get(this.inverseKey);
9913
- }
9914
-
9915
- this.__inverseMeta = inverseMeta;
9916
- }
9917
-
9918
- return this.__inverseMeta;
9919
- }
9920
- }, {
9921
9609
  key: 'parentType',
9922
9610
  get: function () {
9923
9611
  return this.internalModel.modelName;
@@ -10323,7 +10011,7 @@ define('ember-data/-private/system/snapshot', ['exports'], function (exports) {
10323
10011
 
10324
10012
  exports.default = Snapshot;
10325
10013
  });
10326
- define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adapters/errors', 'ember-data/-private/system/model/model', 'ember-data/-private/system/normalize-model-name', 'ember-data/-private/system/identity-map', 'ember-data/-private/system/promise-proxies', 'ember-data/-private/system/store/common', 'ember-data/-private/system/store/serializer-response', 'ember-data/-private/system/store/serializers', 'ember-data/-private/system/relationships/relationship-payloads-manager', 'ember-data/-private/system/store/finders', 'ember-data/-private/utils', 'ember-data/-private/system/coerce-id', 'ember-data/-private/system/record-array-manager', 'ember-data/-private/system/store/container-instance-cache', 'ember-data/-private/system/model/internal-model', 'ember-data/-private/features'], function (exports, _errors, _model, _normalizeModelName, _identityMap, _promiseProxies, _common, _serializerResponse, _serializers, _relationshipPayloadsManager, _finders, _utils, _coerceId, _recordArrayManager, _containerInstanceCache, _internalModel5, _features) {
10014
+ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adapters/errors', 'ember-data/-private/system/model/model', 'ember-data/-private/system/normalize-model-name', 'ember-data/-private/system/identity-map', 'ember-data/-private/system/promise-proxies', 'ember-data/-private/system/store/common', 'ember-data/-private/system/store/serializer-response', 'ember-data/-private/system/store/serializers', 'ember-data/-private/system/relationships/relationship-payloads-manager', 'ember-data/-private/system/store/finders', 'ember-data/-private/utils', 'ember-data/-private/system/coerce-id', 'ember-data/-private/system/record-array-manager', 'ember-data/-private/system/model/internal-model', 'ember-data/-private/features'], function (exports, _errors, _model, _normalizeModelName, _identityMap, _promiseProxies, _common, _serializerResponse, _serializers, _relationshipPayloadsManager, _finders, _utils, _coerceId, _recordArrayManager, _internalModel5, _features) {
10327
10015
  'use strict';
10328
10016
 
10329
10017
  exports.__esModule = true;
@@ -10465,7 +10153,6 @@ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adap
10465
10153
  this.recordArrayManager = new _recordArrayManager.default({ store: this });
10466
10154
  this._identityMap = new _identityMap.default();
10467
10155
  this._pendingSave = [];
10468
- this._instanceCache = new _containerInstanceCache.default((0, _utils.getOwner)(this), this);
10469
10156
  this._modelFactoryCache = Object.create(null);
10470
10157
  this._relationshipsPayloads = new _relationshipPayloadsManager.default(this);
10471
10158
 
@@ -10491,7 +10178,8 @@ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adap
10491
10178
  }
10492
10179
  });
10493
10180
 
10494
- this._instanceCache = new _containerInstanceCache.default((0, _utils.getOwner)(this), this);
10181
+ this._adapterCache = Object.create(null);
10182
+ this._serializerCache = Object.create(null);
10495
10183
  },
10496
10184
 
10497
10185
 
@@ -12703,7 +12391,49 @@ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adap
12703
12391
 
12704
12392
  var normalizedModelName = (0, _normalizeModelName.default)(modelName);
12705
12393
 
12706
- return this._instanceCache.get('adapter', normalizedModelName);
12394
+ var _adapterCache = this._adapterCache;
12395
+
12396
+ var adapter = _adapterCache[normalizedModelName];
12397
+ if (adapter) {
12398
+ return adapter;
12399
+ }
12400
+
12401
+ var owner = (0, _utils.getOwner)(this);
12402
+
12403
+ adapter = owner.lookup('adapter:' + normalizedModelName);
12404
+ if (adapter !== undefined) {
12405
+ set(adapter, 'store', this);
12406
+ _adapterCache[normalizedModelName] = adapter;
12407
+ return adapter;
12408
+ }
12409
+
12410
+ // no adapter found for the specific model, fallback and check for application adapter
12411
+ adapter = _adapterCache.application || owner.lookup('adapter:application');
12412
+ if (adapter !== undefined) {
12413
+ set(adapter, 'store', this);
12414
+ _adapterCache[normalizedModelName] = adapter;
12415
+ _adapterCache.application = adapter;
12416
+ return adapter;
12417
+ }
12418
+
12419
+ // no model specific adapter or application adapter, check for an `adapter`
12420
+ // property defined on the store
12421
+ var adapterName = this.get('adapter');
12422
+ adapter = _adapterCache[adapterName] || owner.lookup('adapter:' + adapterName);
12423
+ if (adapter !== undefined) {
12424
+ set(adapter, 'store', this);
12425
+ _adapterCache[normalizedModelName] = adapter;
12426
+ _adapterCache[adapterName] = adapter;
12427
+ return adapter;
12428
+ }
12429
+
12430
+ // final fallback, no model specific adapter, no application adapter, no
12431
+ // `adapter` property on store: use json-api adapter
12432
+ adapter = _adapterCache['-json-api'] || owner.lookup('adapter:-json-api');
12433
+ set(adapter, 'store', this);
12434
+ _adapterCache[normalizedModelName] = adapter;
12435
+ _adapterCache['-json-api'] = adapter;
12436
+ return adapter;
12707
12437
  },
12708
12438
 
12709
12439
 
@@ -12734,7 +12464,51 @@ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adap
12734
12464
 
12735
12465
  var normalizedModelName = (0, _normalizeModelName.default)(modelName);
12736
12466
 
12737
- return this._instanceCache.get('serializer', normalizedModelName);
12467
+ var _serializerCache = this._serializerCache;
12468
+
12469
+ var serializer = _serializerCache[normalizedModelName];
12470
+ if (serializer) {
12471
+ return serializer;
12472
+ }
12473
+
12474
+ var owner = (0, _utils.getOwner)(this);
12475
+
12476
+ serializer = owner.lookup('serializer:' + normalizedModelName);
12477
+ if (serializer !== undefined) {
12478
+ set(serializer, 'store', this);
12479
+ _serializerCache[normalizedModelName] = serializer;
12480
+ return serializer;
12481
+ }
12482
+
12483
+ // no serializer found for the specific model, fallback and check for application serializer
12484
+ serializer = _serializerCache.application || owner.lookup('serializer:application');
12485
+ if (serializer !== undefined) {
12486
+ set(serializer, 'store', this);
12487
+ _serializerCache[normalizedModelName] = serializer;
12488
+ _serializerCache.application = serializer;
12489
+ return serializer;
12490
+ }
12491
+
12492
+ // no model specific serializer or application serializer, check for the `defaultSerializer`
12493
+ // property defined on the adapter
12494
+ var adapter = this.adapterFor(modelName);
12495
+ var serializerName = get(adapter, 'defaultSerializer');
12496
+ serializer = _serializerCache[serializerName] || owner.lookup('serializer:' + serializerName);
12497
+ if (serializer !== undefined) {
12498
+ set(serializer, 'store', this);
12499
+ _serializerCache[normalizedModelName] = serializer;
12500
+ _serializerCache[serializerName] = serializer;
12501
+ return serializer;
12502
+ }
12503
+
12504
+ // final fallback, no model specific serializer, no application serializer, no
12505
+ // `serializer` property on store: use json-api serializer
12506
+ serializer = _serializerCache['-default'] || owner.lookup('serializer:-default');
12507
+ set(serializer, 'store', this);
12508
+ _serializerCache[normalizedModelName] = serializer;
12509
+ _serializerCache['-default'] = serializer;
12510
+
12511
+ return serializer;
12738
12512
  },
12739
12513
  lookupAdapter: function (name) {
12740
12514
  (false && !(false) && Ember.deprecate('Use of lookupAdapter is deprecated, use adapterFor instead.', false, {
@@ -12756,7 +12530,9 @@ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adap
12756
12530
  this._super.apply(this, arguments);
12757
12531
  this._pushedInternalModels = null;
12758
12532
  this.recordArrayManager.destroy();
12759
- this._instanceCache.destroy();
12533
+
12534
+ this._adapterCache = null;
12535
+ this._serializerCache = null;
12760
12536
 
12761
12537
  this.unloadAll();
12762
12538
  },
@@ -12993,112 +12769,6 @@ define('ember-data/-private/system/store/common', ['exports'], function (exports
12993
12769
  return !(get(object, "isDestroyed") || get(object, "isDestroying"));
12994
12770
  }
12995
12771
  });
12996
- define('ember-data/-private/system/store/container-instance-cache', ['exports'], function (exports) {
12997
- 'use strict';
12998
-
12999
- exports.__esModule = true;
13000
-
13001
- function _classCallCheck(instance, Constructor) {
13002
- if (!(instance instanceof Constructor)) {
13003
- throw new TypeError("Cannot call a class as a function");
13004
- }
13005
- }
13006
-
13007
- var set = Ember.set;
13008
-
13009
- var ContainerInstanceCache = function () {
13010
- function ContainerInstanceCache(owner, store) {
13011
- _classCallCheck(this, ContainerInstanceCache);
13012
-
13013
- this.isDestroying = false;
13014
- this.isDestroyed = false;
13015
- this._owner = owner;
13016
- this._store = store;
13017
- this._namespaces = {
13018
- adapter: Object.create(null),
13019
- serializer: Object.create(null)
13020
- };
13021
- }
13022
-
13023
- ContainerInstanceCache.prototype.get = function get(namespace, preferredKey) {
13024
- var cache = this._namespaces[namespace];
13025
-
13026
- if (cache[preferredKey]) {
13027
- return cache[preferredKey];
13028
- }
13029
-
13030
- var preferredLookupKey = namespace + ':' + preferredKey;
13031
-
13032
- var instance = this._instanceFor(preferredLookupKey) || this._findInstance(namespace, this._fallbacksFor(namespace, preferredKey));
13033
- if (instance) {
13034
- cache[preferredKey] = instance;
13035
- set(instance, 'store', this._store);
13036
- }
13037
-
13038
- return cache[preferredKey];
13039
- };
13040
-
13041
- ContainerInstanceCache.prototype._fallbacksFor = function _fallbacksFor(namespace, preferredKey) {
13042
- if (namespace === 'adapter') {
13043
- return ['application', this._store.get('adapter'), '-json-api'];
13044
- }
13045
-
13046
- // serializer
13047
- return ['application', this.get('adapter', preferredKey).get('defaultSerializer'), '-default'];
13048
- };
13049
-
13050
- ContainerInstanceCache.prototype._findInstance = function _findInstance(namespace, fallbacks) {
13051
- var cache = this._namespaces[namespace];
13052
-
13053
- for (var i = 0, length = fallbacks.length; i < length; i++) {
13054
- var fallback = fallbacks[i];
13055
-
13056
- if (cache[fallback]) {
13057
- return cache[fallback];
13058
- }
13059
-
13060
- var lookupKey = namespace + ':' + fallback;
13061
- var instance = this._instanceFor(lookupKey);
13062
-
13063
- if (instance) {
13064
- cache[fallback] = instance;
13065
- return instance;
13066
- }
13067
- }
13068
- };
13069
-
13070
- ContainerInstanceCache.prototype._instanceFor = function _instanceFor(key) {
13071
- return this._owner.lookup(key);
13072
- };
13073
-
13074
- ContainerInstanceCache.prototype.destroyCache = function destroyCache(cache) {
13075
- var cacheEntries = Object.keys(cache);
13076
-
13077
- for (var i = 0, length = cacheEntries.length; i < length; i++) {
13078
- var cacheKey = cacheEntries[i];
13079
- var cacheEntry = cache[cacheKey];
13080
- if (cacheEntry) {
13081
- cacheEntry.destroy();
13082
- }
13083
- }
13084
- };
13085
-
13086
- ContainerInstanceCache.prototype.destroy = function destroy() {
13087
- this.isDestroying = true;
13088
- this.destroyCache(this._namespaces.adapter);
13089
- this.destroyCache(this._namespaces.serializer);
13090
- this.isDestroyed = true;
13091
- };
13092
-
13093
- ContainerInstanceCache.prototype.toString = function toString() {
13094
- return 'ContainerInstanceCache';
13095
- };
13096
-
13097
- return ContainerInstanceCache;
13098
- }();
13099
-
13100
- exports.default = ContainerInstanceCache;
13101
- });
13102
12772
  define('ember-data/-private/system/store/finders', ['exports', 'ember-data/-private/system/store/common', 'ember-data/-private/system/store/serializer-response', 'ember-data/-private/system/store/serializers'], function (exports, _common, _serializerResponse, _serializers) {
13103
12773
  'use strict';
13104
12774
 
@@ -15429,10 +15099,7 @@ define('ember-data/attr', ['exports'], function (exports) {
15429
15099
  return options.defaultValue.apply(null, arguments);
15430
15100
  } else {
15431
15101
  var defaultValue = options.defaultValue;
15432
- (false && !(typeof defaultValue !== 'object' || defaultValue === null) && Ember.deprecate('Non primitive defaultValues are deprecated because they are shared between all instances. If you would like to use a complex object as a default value please provide a function that returns the complex object.', typeof defaultValue !== 'object' || defaultValue === null, {
15433
- id: 'ds.defaultValue.complex-object',
15434
- until: '3.0.0'
15435
- }));
15102
+ (false && Ember.assert('Non primitive defaultValues are not supported because they are shared between all instances. If you would like to use a complex object as a default value please provide a function that returns the complex object.', typeof defaultValue !== 'object' || defaultValue === null));
15436
15103
 
15437
15104
  return defaultValue;
15438
15105
  }
@@ -15696,10 +15363,6 @@ define('ember-data/initialize-store-service', ['exports'], function (exports) {
15696
15363
 
15697
15364
  exports.__esModule = true;
15698
15365
  exports.default = initializeStoreService;
15699
-
15700
-
15701
- var deprecateOldEmberDataInitializers = void 0;
15702
-
15703
15366
  /*
15704
15367
  Configures a registry for use with an Ember-Data
15705
15368
  store.
@@ -15714,60 +15377,7 @@ define('ember-data/initialize-store-service', ['exports'], function (exports) {
15714
15377
 
15715
15378
  // Eagerly generate the store so defaultStore is populated.
15716
15379
  container.lookup('service:store');
15717
-
15718
- if (false) {
15719
- // In Ember 2.4+ instance.base is the `Ember.Application` or `Ember.Engine` instance
15720
- // In Ember 1.11 - 2.3 we fallback to `instance.application`
15721
- var base = instance.base || instance.application;
15722
- deprecateOldEmberDataInitializers(base.constructor.initializers);
15723
- }
15724
15380
  }
15725
-
15726
- if (false) {
15727
- var DEPRECATED_INITIALIZER_NAMES = ['data-adapter', 'injectStore', 'transforms', 'store'];
15728
-
15729
- var matchesDeprecatedInititalizer = function matchesDeprecatedInititalizer(name) {
15730
- return DEPRECATED_INITIALIZER_NAMES.indexOf(name) !== -1;
15731
- };
15732
-
15733
- var warnForDeprecatedInitializers = function warnForDeprecatedInitializers(initializer) {
15734
- var deprecatedBeforeInitializer = matchesDeprecatedInititalizer(initializer.before);
15735
- var deprecatedAfterInitializer = matchesDeprecatedInititalizer(initializer.after);
15736
- var deprecatedProp = deprecatedBeforeInitializer ? 'before' : 'after';
15737
-
15738
- (false && !(!(deprecatedBeforeInitializer || deprecatedAfterInitializer)) && Ember.deprecate('The initializer `' + initializer[deprecatedProp] + '` has been deprecated. Please update your `' + initializer.name + '` initializer to use use `' + deprecatedProp + ': \'ember-data\'` instead.', !(deprecatedBeforeInitializer || deprecatedAfterInitializer), {
15739
- id: 'ds.deprecated-initializers',
15740
- until: '3.0.0'
15741
- }));
15742
- };
15743
-
15744
- deprecateOldEmberDataInitializers = function deprecateOldEmberDataInitializers(initializers) {
15745
- // collect all of the initializers
15746
- var keys = Object.keys(initializers);
15747
-
15748
- for (var i = 0; i < keys.length; i++) {
15749
- var name = keys[i];
15750
-
15751
- // filter out all of the Ember Data initializer. We have some
15752
- // deprecated initializers that depend on other deprecated
15753
- // initializers which may trigger the deprecation warning
15754
- // unintentionally.
15755
- if (!matchesDeprecatedInititalizer(name)) {
15756
- warnForDeprecatedInitializers(initializers[name]);
15757
- }
15758
- }
15759
- };
15760
- }
15761
- });
15762
- define('ember-data/initializers/data-adapter', ['exports'], function (exports) {
15763
- 'use strict';
15764
-
15765
- exports.__esModule = true;
15766
- exports.default = {
15767
- name: 'data-adapter',
15768
- before: 'store',
15769
- initialize: function () {}
15770
- };
15771
15381
  });
15772
15382
  define('ember-data/initializers/ember-data', ['exports', 'ember-data/setup-container', 'ember-data'], function (exports, _setupContainer) {
15773
15383
  'use strict';
@@ -15778,36 +15388,6 @@ define('ember-data/initializers/ember-data', ['exports', 'ember-data/setup-conta
15778
15388
  initialize: _setupContainer.default
15779
15389
  };
15780
15390
  });
15781
- define('ember-data/initializers/injectStore', ['exports'], function (exports) {
15782
- 'use strict';
15783
-
15784
- exports.__esModule = true;
15785
- exports.default = {
15786
- name: 'injectStore',
15787
- before: 'store',
15788
- initialize: function () {}
15789
- };
15790
- });
15791
- define('ember-data/initializers/store', ['exports'], function (exports) {
15792
- 'use strict';
15793
-
15794
- exports.__esModule = true;
15795
- exports.default = {
15796
- name: 'store',
15797
- after: 'ember-data',
15798
- initialize: function () {}
15799
- };
15800
- });
15801
- define('ember-data/initializers/transforms', ['exports'], function (exports) {
15802
- 'use strict';
15803
-
15804
- exports.__esModule = true;
15805
- exports.default = {
15806
- name: 'transforms',
15807
- before: 'store',
15808
- initialize: function () {}
15809
- };
15810
- });
15811
15391
  define("ember-data/instance-initializers/ember-data", ["exports", "ember-data/initialize-store-service"], function (exports, _initializeStoreService) {
15812
15392
  "use strict";
15813
15393
 
@@ -16652,7 +16232,7 @@ define('ember-data/serializers/json-api', ['exports', 'ember-inflector', 'ember-
16652
16232
  if (modelName !== deprecatedModelNameLookup && this._hasCustomModelNameFromPayloadKey()) {
16653
16233
  (false && !(false) && Ember.deprecate("You are using modelNameFromPayloadKey to normalize the type for a relationship. This has been deprecated in favor of modelNameFromPayloadType", false, {
16654
16234
  id: 'ds.json-api-serializer.deprecated-model-name-for-relationship',
16655
- until: '3.0.0'
16235
+ until: '4.0.0'
16656
16236
  }));
16657
16237
 
16658
16238
 
@@ -16684,7 +16264,7 @@ define('ember-data/serializers/json-api', ['exports', 'ember-inflector', 'ember-
16684
16264
  if (modelName !== deprecatedModelNameLookup && this._hasCustomModelNameFromPayloadKey()) {
16685
16265
  (false && !(false) && Ember.deprecate("You are using modelNameFromPayloadKey to normalize the type for a resource. This has been deprecated in favor of modelNameFromPayloadType", false, {
16686
16266
  id: 'ds.json-api-serializer.deprecated-model-name-for-resource',
16687
- until: '3.0.0'
16267
+ until: '4.0.0'
16688
16268
  }));
16689
16269
 
16690
16270
 
@@ -16860,7 +16440,7 @@ define('ember-data/serializers/json-api', ['exports', 'ember-inflector', 'ember-
16860
16440
  if (payloadType !== deprecatedPayloadTypeLookup && this._hasCustomPayloadKeyFromModelName()) {
16861
16441
  (false && !(false) && Ember.deprecate("You used payloadKeyFromModelName to customize how a type is serialized. Use payloadTypeFromModelName instead.", false, {
16862
16442
  id: 'ds.json-api-serializer.deprecated-payload-type-for-model',
16863
- until: '3.0.0'
16443
+ until: '4.0.0'
16864
16444
  }));
16865
16445
 
16866
16446
 
@@ -16919,7 +16499,7 @@ define('ember-data/serializers/json-api', ['exports', 'ember-inflector', 'ember-
16919
16499
  if (payloadType !== deprecatedPayloadTypeLookup && this._hasCustomPayloadKeyFromModelName()) {
16920
16500
  (false && !(false) && Ember.deprecate("You used payloadKeyFromModelName to serialize type for belongs-to relationship. Use payloadTypeFromModelName instead.", false, {
16921
16501
  id: 'ds.json-api-serializer.deprecated-payload-type-for-belongs-to',
16922
- until: '3.0.0'
16502
+ until: '4.0.0'
16923
16503
  }));
16924
16504
 
16925
16505
 
@@ -16941,12 +16521,8 @@ define('ember-data/serializers/json-api', ['exports', 'ember-inflector', 'ember-
16941
16521
  },
16942
16522
  serializeHasMany: function (snapshot, json, relationship) {
16943
16523
  var key = relationship.key;
16944
- var shouldSerializeHasMany = '_shouldSerializeHasMany';
16945
- if ((0, _private.isEnabled)("ds-check-should-serialize-relationships")) {
16946
- shouldSerializeHasMany = 'shouldSerializeHasMany';
16947
- }
16948
16524
 
16949
- if (this[shouldSerializeHasMany](snapshot, key, relationship)) {
16525
+ if (this.shouldSerializeHasMany(snapshot, key, relationship)) {
16950
16526
  var hasMany = snapshot.hasMany(key);
16951
16527
  if (hasMany !== undefined) {
16952
16528
 
@@ -16971,7 +16547,7 @@ define('ember-data/serializers/json-api', ['exports', 'ember-inflector', 'ember-
16971
16547
  if (payloadType !== deprecatedPayloadTypeLookup && this._hasCustomPayloadKeyFromModelName()) {
16972
16548
  (false && !(false) && Ember.deprecate("You used payloadKeyFromModelName to serialize type for belongs-to relationship. Use payloadTypeFromModelName instead.", false, {
16973
16549
  id: 'ds.json-api-serializer.deprecated-payload-type-for-has-many',
16974
- until: '3.0.0'
16550
+ until: '4.0.0'
16975
16551
  }));
16976
16552
 
16977
16553
 
@@ -17537,16 +17113,6 @@ define('ember-data/serializers/json', ['exports', 'ember-data/serializer', 'embe
17537
17113
  return attrs && attrs[key] && attrs[key].serialize === true;
17538
17114
  },
17539
17115
  shouldSerializeHasMany: function (snapshot, key, relationship) {
17540
- if (this._shouldSerializeHasMany !== JSONSerializer.prototype._shouldSerializeHasMany) {
17541
- (false && !(false) && Ember.deprecate('The private method _shouldSerializeHasMany has been promoted to the public API. Please remove the underscore to use the public shouldSerializeHasMany method.', false, {
17542
- id: 'ds.serializer.private-should-serialize-has-many',
17543
- until: '3.0.0'
17544
- }));
17545
- }
17546
-
17547
- return this._shouldSerializeHasMany(snapshot, key, relationship);
17548
- },
17549
- _shouldSerializeHasMany: function (snapshot, key, relationship) {
17550
17116
  var relationshipType = snapshot.type.determineRelationshipType(relationship, this.store);
17551
17117
  if (this._mustSerialize(key)) {
17552
17118
  return true;
@@ -17634,12 +17200,8 @@ define('ember-data/serializers/json', ['exports', 'ember-data/serializer', 'embe
17634
17200
  },
17635
17201
  serializeHasMany: function (snapshot, json, relationship) {
17636
17202
  var key = relationship.key;
17637
- var shouldSerializeHasMany = '_shouldSerializeHasMany';
17638
- if ((0, _private.isEnabled)("ds-check-should-serialize-relationships")) {
17639
- shouldSerializeHasMany = 'shouldSerializeHasMany';
17640
- }
17641
17203
 
17642
- if (this[shouldSerializeHasMany](snapshot, key, relationship)) {
17204
+ if (this.shouldSerializeHasMany(snapshot, key, relationship)) {
17643
17205
  var hasMany = snapshot.hasMany(key, { ids: true });
17644
17206
  if (hasMany !== undefined) {
17645
17207
  // if provided, use the mapping provided by `attrs` in
@@ -18072,25 +17634,6 @@ define('ember-data/serializers/rest', ['exports', 'ember-inflector', 'ember-data
18072
17634
  var typeKey = this.keyForPolymorphicType(key, relationship.type, 'serialize');
18073
17635
  var belongsTo = snapshot.belongsTo(key);
18074
17636
 
18075
- // old way of getting the key for the polymorphic type
18076
- key = this.keyForAttribute ? this.keyForAttribute(key, "serialize") : key;
18077
- key = key + 'Type';
18078
-
18079
- // The old way of serializing the type of a polymorphic record used
18080
- // `keyForAttribute`, which is not correct. The next code checks if the old
18081
- // way is used and if it differs from the new way of using
18082
- // `keyForPolymorphicType`. If this is the case, a deprecation warning is
18083
- // logged and the old way is restored (so nothing breaks).
18084
- if (key !== typeKey && this.keyForPolymorphicType === RESTSerializer.prototype.keyForPolymorphicType) {
18085
- (false && !(false) && Ember.deprecate("The key to serialize the type of a polymorphic record is created via keyForAttribute which has been deprecated. Use the keyForPolymorphicType hook instead.", false, {
18086
- id: 'ds.rest-serializer.deprecated-key-for-polymorphic-type',
18087
- until: '3.0.0'
18088
- }));
18089
-
18090
-
18091
- typeKey = key;
18092
- }
18093
-
18094
17637
  if (isNone(belongsTo)) {
18095
17638
  json[typeKey] = null;
18096
17639
  } else {
@@ -18222,12 +17765,9 @@ define('ember-data/setup-container', ['exports', 'ember-data/-private', 'ember-d
18222
17765
  @param {Ember.Registry} registry
18223
17766
  */
18224
17767
  function initializeStore(registry) {
18225
- // registry.optionsForType for Ember < 2.1.0
18226
- // application.registerOptionsForType for Ember 2.1.0+
18227
17768
  var registerOptionsForType = registry.registerOptionsForType || registry.optionsForType;
18228
17769
  registerOptionsForType.call(registry, 'serializer', { singleton: false });
18229
17770
  registerOptionsForType.call(registry, 'adapter', { singleton: false });
18230
-
18231
17771
  registry.register('serializer:-default', _json.default);
18232
17772
  registry.register('serializer:-rest', _rest.default);
18233
17773
  registry.register('adapter:-rest', _rest2.default);
@@ -18346,54 +17886,6 @@ define('ember-data/transforms/date', ['exports', 'ember-data/transforms/transfor
18346
17886
  'use strict';
18347
17887
 
18348
17888
  exports.__esModule = true;
18349
-
18350
-
18351
- Ember.Date = Ember.Date || {};
18352
-
18353
- /**
18354
- Date.parse with progressive enhancement for ISO 8601 <https://github.com/csnover/js-iso8601>
18355
-
18356
- © 2011 Colin Snover <http://zetafleet.com>
18357
-
18358
- Released under MIT license.
18359
-
18360
- @class Date
18361
- @namespace Ember
18362
- @static
18363
- @deprecated
18364
- */
18365
- Ember.Date.parse = function (date) {
18366
- (false && !(false) && Ember.deprecate('Ember.Date.parse is deprecated because Safari 5-, IE8-, and\n Firefox 3.6- are no longer supported (see\n https://github.com/csnover/js-iso8601 for the history of this issue).\n Please use Date.parse instead', false, {
18367
- id: 'ds.ember.date.parse-deprecate',
18368
- until: '3.0.0'
18369
- }));
18370
-
18371
-
18372
- return Date.parse(date);
18373
- };
18374
-
18375
- /**
18376
- The `DS.DateTransform` class is used to serialize and deserialize
18377
- date attributes on Ember Data record objects. This transform is used
18378
- when `date` is passed as the type parameter to the
18379
- [DS.attr](../../data#method_attr) function. It uses the [`ISO 8601`](https://en.wikipedia.org/wiki/ISO_8601)
18380
- standard.
18381
-
18382
- ```app/models/score.js
18383
- import DS from 'ember-data';
18384
-
18385
- export default DS.Model.extend({
18386
- value: DS.attr('number'),
18387
- player: DS.belongsTo('player'),
18388
- date: DS.attr('date')
18389
- });
18390
- ```
18391
-
18392
- @class DateTransform
18393
- @extends DS.Transform
18394
- @namespace DS
18395
- */
18396
-
18397
17889
  exports.default = _transform.default.extend({
18398
17890
  deserialize: function (serialized) {
18399
17891
  var type = typeof serialized;
@@ -18401,16 +17893,7 @@ define('ember-data/transforms/date', ['exports', 'ember-data/transforms/transfor
18401
17893
  if (type === "string") {
18402
17894
  var offset = serialized.indexOf('+');
18403
17895
 
18404
- if (offset !== -1 && serialized.length - 3 === offset) {
18405
- (false && !(false) && Ember.deprecate('The ECMA2015 Spec for ISO 8601 dates does not allow for shorthand timezone offsets such as +00.\n Ember Data\'s normalization of date\'s allowing for this shorthand has been deprecated, please update your API to return\n UTC dates formatted with \xB1hh:mm timezone offsets or implement a custom UTC transform.', false, {
18406
- id: 'ds.attr.date.normalize-utc',
18407
- until: '3.0.0'
18408
- }));
18409
-
18410
- return new Date(serialized + ':00');
18411
-
18412
- // this is a phantom specific bug fix in which +0000 is not supported
18413
- } else if (offset !== -1 && serialized.length - 5 === offset) {
17896
+ if (offset !== -1 && serialized.length - 5 === offset) {
18414
17897
  offset += 3;
18415
17898
  return new Date(serialized.slice(0, offset) + ':' + serialized.slice(offset));
18416
17899
  }
@@ -18550,7 +18033,7 @@ define("ember-data/version", ["exports"], function (exports) {
18550
18033
  "use strict";
18551
18034
 
18552
18035
  exports.__esModule = true;
18553
- exports.default = "2.18.3";
18036
+ exports.default = "3.0.0-beta.1";
18554
18037
  });
18555
18038
  define("ember-inflector", ["module", "exports", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (module, exports, _system) {
18556
18039
  "use strict";