dist/globals/ember-data.prod.js in ember-data-source-2.16.4 vs dist/globals/ember-data.prod.js in ember-data-source-2.17.0.beta.1

- old
+ new

@@ -4,11 +4,11 @@ /*! * @overview Ember Data * @copyright Copyright 2011-2017 Tilde Inc. and contributors. * Portions Copyright 2011 LivingSocial Inc. * @license Licensed under MIT license (see license.js) - * @version 2.16.4 + * @version 2.17.0-beta.1 */ var loader, define, requireModule, require, requirejs; (function (global) { @@ -4798,14 +4798,10 @@ // If it is, get the metadata for the relationship. This is // populated by the `DS.belongsTo` helper when it is creating // the computed property. var meta = value.meta(); - /* - This is buggy because if the parent has never been looked up - via `modelFor` it will not have `modelName` set. - */ meta.parentType = proto.constructor; } } }); } @@ -6833,11 +6829,10 @@ userRef.value(); // user }); ``` @method value - @param {Object|Promise} objectOrPromise a promise that resolves to a JSONAPI document object describing the new value of this relationship. @return {DS.Model} the record in this relationship */ BelongsToReference.prototype.value = function () { var inverseInternalModel = this.belongsToRelationship.inverseInternalModel; @@ -7585,19 +7580,25 @@ } return modelName; } function relationshipFromMeta(meta) { - return { + var result = { key: meta.key, kind: meta.kind, type: typeForRelationshipMeta(meta), options: meta.options, name: meta.name, parentType: meta.parentType, isRelationship: true }; + + if (false) { + result.parentType = meta.parentType; + } + + return result; } }); define('ember-data/-private/system/relationships/belongs-to', ['exports', 'ember', 'ember-data/-private/system/normalize-model-name'], function (exports, _ember, _normalizeModelName) { 'use strict'; @@ -7999,12 +8000,11 @@ if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var get = _ember.default.get; - var assert = _ember.default.assert; + var _get = _ember.default.get; /** Manages relationship payloads for a given store, for uninitialized relationships. Acts as a single source of truth (of payloads) for both sides of an uninitialized relationship so they can agree on the most up-to-date @@ -8061,11 +8061,10 @@ var RelationshipPayloadsManager = function () { function RelationshipPayloadsManager(store) { this._store = store; // cache of `RelationshipPayload`s this._cache = Object.create(null); - this._inverseLookupCache = new _relationshipPayloads.TypeCache(); } /** Find the payload for the given relationship of the given model. Returns the payload for the given relationship, whether raw or computed from @@ -8082,194 +8081,90 @@ @method */ RelationshipPayloadsManager.prototype.get = function get(modelName, id, relationshipName) { - var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, false); + var modelClass = this._store._modelFor(modelName); + var relationshipsByName = _get(modelClass, 'relationshipsByName'); + var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false); return relationshipPayloads && relationshipPayloads.get(modelName, id, relationshipName); }; RelationshipPayloadsManager.prototype.push = function push(modelName, id, relationshipsData) { var _this = this; if (!relationshipsData) { return; } + var modelClass = this._store._modelFor(modelName); + var relationshipsByName = _get(modelClass, 'relationshipsByName'); Object.keys(relationshipsData).forEach(function (key) { - var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, true); + var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, modelClass, relationshipsByName, true); if (relationshipPayloads) { relationshipPayloads.push(modelName, id, key, relationshipsData[key]); } }); }; RelationshipPayloadsManager.prototype.unload = function unload(modelName, id) { var _this2 = this; var modelClass = this._store._modelFor(modelName); - var relationshipsByName = get(modelClass, 'relationshipsByName'); + var relationshipsByName = _get(modelClass, 'relationshipsByName'); relationshipsByName.forEach(function (_, relationshipName) { - var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, false); + var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false); if (relationshipPayloads) { relationshipPayloads.unload(modelName, id, relationshipName); } }); }; - RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, init) { - var relInfo = this.getRelationshipInfo(modelName, relationshipName); - - if (relInfo === null) { + RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, init) { + if (!relationshipsByName.has(relationshipName)) { return; } - var cache = this._cache[relInfo.lhs_key]; - - if (!cache && init) { - return this._initializeRelationshipPayloads(relInfo); + var key = modelName + ':' + relationshipName; + if (!this._cache[key] && init) { + return this._initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName); } - return cache; + return this._cache[key]; }; - RelationshipPayloadsManager.prototype.getRelationshipInfo = function getRelationshipInfo(modelName, relationshipName) { - var inverseCache = this._inverseLookupCache; - var store = this._store; - var cached = inverseCache.get(modelName, relationshipName); - - // CASE: We have a cached resolution (null if no relationship exists) - if (cached !== undefined) { - return cached; - } - - var modelClass = store._modelFor(modelName); - var relationshipsByName = get(modelClass, 'relationshipsByName'); - - // CASE: We don't have a relationship at all - if (!relationshipsByName.has(relationshipName)) { - inverseCache.set(modelName, relationshipName, null); - return null; - } - - var inverseMeta = modelClass.inverseFor(relationshipName, store); + RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName) { var relationshipMeta = relationshipsByName.get(relationshipName); - var selfIsPolymorphic = relationshipMeta.options !== undefined && relationshipMeta.options.polymorphic === true; - var inverseBaseModelName = relationshipMeta.type; + var inverseMeta = modelClass.inverseFor(relationshipName, this._store); - // CASE: We have no inverse - if (!inverseMeta) { - var _info = { - lhs_key: modelName + ':' + relationshipName, - lhs_modelNames: [modelName], - lhs_baseModelName: modelName, - lhs_relationshipName: relationshipName, - lhs_relationshipMeta: relationshipMeta, - lhs_isPolymorphic: selfIsPolymorphic, - rhs_key: '', - rhs_modelNames: [], - rhs_baseModelName: inverseBaseModelName, - rhs_relationshipName: '', - rhs_relationshipMeta: null, - rhs_isPolymorphic: false, - hasInverse: false, - isSelfReferential: false, // modelName === inverseBaseModelName, - isReflexive: false - }; + var inverseModelName = void 0; + var inverseRelationshipName = void 0; + var inverseRelationshipMeta = void 0; - inverseCache.set(modelName, relationshipName, _info); - - return _info; + // figure out the inverse relationship; we need two things + // a) the inverse model name + //- b) the name of the inverse relationship + if (inverseMeta) { + inverseRelationshipName = inverseMeta.name; + inverseModelName = relationshipMeta.type; + inverseRelationshipMeta = _get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName); + } else { + // relationship has no inverse + inverseModelName = inverseRelationshipName = ''; + inverseRelationshipMeta = null; } - // CASE: We do have an inverse + var lhsKey = modelName + ':' + relationshipName; + var rhsKey = inverseModelName + ':' + inverseRelationshipName; - var inverseRelationshipName = inverseMeta.name; - var inverseRelationshipMeta = get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName); - var baseModelName = inverseRelationshipMeta.type; - var isSelfReferential = baseModelName === inverseBaseModelName; - - // TODO we want to assert this but this breaks all of our shoddily written tests - /* - if (DEBUG) { - let inverseDoubleCheck = inverseMeta.type.inverseFor(inverseRelationshipName, store); - assert(`The ${inverseBaseModelName}:${inverseRelationshipName} relationship declares 'inverse: null', but it was resolved as the inverse for ${baseModelName}:${relationshipName}.`, inverseDoubleCheck); - } - */ - - // CASE: We may have already discovered the inverse for the baseModelName - // CASE: We have already discovered the inverse - cached = inverseCache.get(baseModelName, relationshipName) || inverseCache.get(inverseBaseModelName, inverseRelationshipName); - if (cached) { - // TODO this assert can be removed if the above assert is enabled - assert('The ' + inverseBaseModelName + ':' + inverseRelationshipName + ' relationship declares \'inverse: null\', but it was resolved as the inverse for ' + baseModelName + ':' + relationshipName + '.', cached.hasInverse !== false); - - var isLHS = cached.lhs_baseModelName === baseModelName; - var modelNames = isLHS ? cached.lhs_modelNames : cached.rhs_modelNames; - // make this lookup easier in the future by caching the key - modelNames.push(modelName); - inverseCache.set(modelName, relationshipName, cached); - - return cached; - } - - var info = { - lhs_key: baseModelName + ':' + relationshipName, - lhs_modelNames: [modelName], - lhs_baseModelName: baseModelName, - lhs_relationshipName: relationshipName, - lhs_relationshipMeta: relationshipMeta, - lhs_isPolymorphic: selfIsPolymorphic, - rhs_key: inverseBaseModelName + ':' + inverseRelationshipName, - rhs_modelNames: [], - rhs_baseModelName: inverseBaseModelName, - rhs_relationshipName: inverseRelationshipName, - rhs_relationshipMeta: inverseRelationshipMeta, - rhs_isPolymorphic: inverseRelationshipMeta.options !== undefined && inverseRelationshipMeta.options.polymorphic === true, - hasInverse: true, - isSelfReferential: isSelfReferential, - isReflexive: isSelfReferential && relationshipName === inverseRelationshipName - }; - - // Create entries for the baseModelName as well as modelName to speed up - // inverse lookups - inverseCache.set(baseModelName, relationshipName, info); - inverseCache.set(modelName, relationshipName, info); - - // Greedily populate the inverse - inverseCache.set(inverseBaseModelName, inverseRelationshipName, info); - - return info; - }; - - RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(relInfo) { - var lhsKey = relInfo.lhs_key; - var rhsKey = relInfo.rhs_key; - var existingPayloads = this._cache[lhsKey]; - - if (relInfo.hasInverse === true && relInfo.rhs_isPolymorphic === true) { - existingPayloads = this._cache[rhsKey]; - - if (existingPayloads !== undefined) { - this._cache[lhsKey] = existingPayloads; - return existingPayloads; - } - } - // populate the cache for both sides of the relationship, as they both use // the same `RelationshipPayloads`. // // This works out better than creating a single common key, because to // compute that key we would need to do work to look up the inverse // - var cache = this._cache[lhsKey] = new _relationshipPayloads.default(relInfo); - - if (relInfo.hasInverse === true) { - this._cache[rhsKey] = cache; - } - - return cache; + return this._cache[lhsKey] = this._cache[rhsKey] = new _relationshipPayloads.default(this._store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta); }; return RelationshipPayloadsManager; }(); @@ -8278,10 +8173,16 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['exports'], function (exports) { 'use strict'; exports.__esModule = true; + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; @@ -8296,87 +8197,65 @@ if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - } + var RelationshipPayloads = function () { + function RelationshipPayloads(store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta) { + this._store = store; - var TypeCache = exports.TypeCache = function () { - function TypeCache() { - this.types = Object.create(null); - } + this._lhsModelName = modelName; + this._lhsRelationshipName = relationshipName; + this._lhsRelationshipMeta = relationshipMeta; - TypeCache.prototype.get = function get(modelName, id) { - var types = this.types; + this._rhsModelName = inverseModelName; + this._rhsRelationshipName = inverseRelationshipName; + this._rhsRelationshipMeta = inverseRelationshipMeta; - - if (types[modelName] !== undefined) { - return types[modelName][id]; + // a map of id -> payloads for the left hand side of the relationship. + this._lhsPayloads = Object.create(null); + if (modelName !== inverseModelName || relationshipName !== inverseRelationshipName) { + // The common case of a non-reflexive relationship, or a reflexive + // relationship whose inverse is not itself + this._rhsPayloads = Object.create(null); + this._isReflexive = false; + } else { + // Edge case when we have a reflexive relationship to itself + // eg user hasMany friends inverse friends + // + // In this case there aren't really two sides to the relationship, but + // we set `_rhsPayloads = _lhsPayloads` to make things easier to reason + // about + this._rhsPayloads = this._lhsPayloads; + this._isReflexive = true; } - }; - TypeCache.prototype.set = function set(modelName, id, payload) { - var types = this.types; - - var typeMap = types[modelName]; - - if (typeMap === undefined) { - typeMap = types[modelName] = Object.create(null); - } - - typeMap[id] = payload; - }; - - TypeCache.prototype.delete = function _delete(modelName, id) { - var types = this.types; - - - if (types[modelName] !== undefined) { - delete types[modelName][id]; - } - }; - - return TypeCache; - }(); - - var RelationshipPayloads = function () { - function RelationshipPayloads(relInfo) { - this._relInfo = relInfo; - - // a map of id -> payloads for the left hand side of the relationship. - this.lhs_payloads = new TypeCache(); - this.rhs_payloads = relInfo.isReflexive ? this.lhs_payloads : new TypeCache(); - // When we push relationship payloads, just stash them in a queue until // somebody actually asks for one of them. // // This is a queue of the relationship payloads that have been pushed for // either side of this relationship this._pendingPayloads = []; } /** - Get the payload for the relationship of an individual record. - This might return the raw payload as pushed into the store, or one computed - from the payload of the inverse relationship. - @method - */ + Get the payload for the relationship of an individual record. + This might return the raw payload as pushed into the store, or one computed + from the payload of the inverse relationship. + @method + */ RelationshipPayloads.prototype.get = function get(modelName, id, relationshipName) { this._flushPending(); if (this._isLHS(modelName, relationshipName)) { - return this.lhs_payloads.get(modelName, id); + return this._lhsPayloads[id]; } else { - (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName))); + (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName))); - return this.rhs_payloads.get(modelName, id); + return this._rhsPayloads[id]; } }; RelationshipPayloads.prototype.push = function push(modelName, id, relationshipName, relationshipData) { this._pendingPayloads.push([modelName, id, relationshipName, relationshipData]); @@ -8384,44 +8263,24 @@ RelationshipPayloads.prototype.unload = function unload(modelName, id, relationshipName) { this._flushPending(); if (this._isLHS(modelName, relationshipName)) { - delete this.lhs_payloads.delete(modelName, id); + delete this._lhsPayloads[id]; } else { - (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))); + (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName))); - delete this.rhs_payloads.delete(modelName, id); + delete this._rhsPayloads[id]; } }; RelationshipPayloads.prototype._isLHS = function _isLHS(modelName, relationshipName) { - var relInfo = this._relInfo; - var isSelfReferential = relInfo.isSelfReferential; - var isRelationship = relationshipName === relInfo.lhs_relationshipName; - - if (isRelationship === true) { - return isSelfReferential === true || // itself - modelName === relInfo.lhs_baseModelName || // base or non-polymorphic - relInfo.lhs_modelNames.indexOf(modelName) !== -1; // polymorphic - } - - return false; + return modelName === this._lhsModelName && relationshipName === this._lhsRelationshipName; }; RelationshipPayloads.prototype._isRHS = function _isRHS(modelName, relationshipName) { - var relInfo = this._relInfo; - var isSelfReferential = relInfo.isSelfReferential; - var isRelationship = relationshipName === relInfo.rhs_relationshipName; - - if (isRelationship === true) { - return isSelfReferential === true || // itself - modelName === relInfo.rhs_baseModelName || // base or non-polymorphic - relInfo.rhs_modelNames.indexOf(modelName) !== -1; // polymorphic - } - - return false; + return modelName === this._rhsModelName && relationshipName === this._rhsRelationshipName; }; RelationshipPayloads.prototype._flushPending = function _flushPending() { if (this._pendingPayloads.length === 0) { return; @@ -8438,32 +8297,30 @@ var inverseRelationshipData = { data: { id: id, type: modelName } - }; - // start flushing this individual payload. The logic is the same whether - // it's for the left hand side of the relationship or the right hand side, - // except the role of primary and inverse idToPayloads is reversed - // - var previousPayload = void 0; - var payloadMap = void 0; - var inversePayloadMap = void 0; + // start flushing this individual payload. The logic is the same whether + // it's for the left hand side of the relationship or the right hand side, + // except the role of primary and inverse idToPayloads is reversed + // + };var previousPayload = void 0; + var idToPayloads = void 0; + var inverseIdToPayloads = void 0; var inverseIsMany = void 0; - if (this._isLHS(modelName, relationshipName)) { - previousPayload = this.lhs_payloads.get(modelName, id); - payloadMap = this.lhs_payloads; - inversePayloadMap = this.rhs_payloads; + previousPayload = this._lhsPayloads[id]; + idToPayloads = this._lhsPayloads; + inverseIdToPayloads = this._rhsPayloads; inverseIsMany = this._rhsRelationshipIsMany; } else { - (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName))); + (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName))); - previousPayload = this.rhs_payloads.get(modelName, id); - payloadMap = this.rhs_payloads; - inversePayloadMap = this.lhs_payloads; + previousPayload = this._rhsPayloads[id]; + idToPayloads = this._rhsPayloads; + inverseIdToPayloads = this._lhsPayloads; inverseIsMany = this._lhsRelationshipIsMany; } // actually flush this individual payload // @@ -8503,69 +8360,67 @@ // only remove relationship information before adding if there is relationshipData.data // * null is considered new information "empty", and it should win // * undefined is NOT considered new information, we should keep original state // * anything else is considered new information, and it should win if (relationshipData.data !== undefined) { - this._removeInverse(id, previousPayload, inversePayloadMap); + this._removeInverse(id, previousPayload, inverseIdToPayloads); } - payloadMap.set(modelName, id, relationshipData); - this._populateInverse(relationshipData, inverseRelationshipData, inversePayloadMap, inverseIsMany); + idToPayloads[id] = relationshipData; + this._populateInverse(relationshipData, inverseRelationshipData, inverseIdToPayloads, inverseIsMany); } }; - RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inversePayloadMap, inverseIsMany) { + RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inverseIdToPayloads, inverseIsMany) { if (!relationshipData.data) { // This id doesn't have an inverse, eg a belongsTo with a payload // { data: null }, so there's nothing to populate return; } if (Array.isArray(relationshipData.data)) { for (var i = 0; i < relationshipData.data.length; ++i) { - var resourceIdentifier = relationshipData.data[i]; - this._addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany); + var inverseId = relationshipData.data[i].id; + this._addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany); } } else { - var _resourceIdentifier = relationshipData.data; - this._addToInverse(inversePayload, _resourceIdentifier, inversePayloadMap, inverseIsMany); + var _inverseId = relationshipData.data.id; + this._addToInverse(inversePayload, _inverseId, inverseIdToPayloads, inverseIsMany); } }; - RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany) { - var relInfo = this._relInfo; - - if (relInfo.isReflexive && inversePayload.data.id === resourceIdentifier.id) { + RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany) { + if (this._isReflexive && inversePayload.data.id === inverseId) { // eg <user:1>.friends = [{ id: 1, type: 'user' }] return; } - var existingPayload = inversePayloadMap.get(resourceIdentifier.type, resourceIdentifier.id); + var existingPayload = inverseIdToPayloads[inverseId]; var existingData = existingPayload && existingPayload.data; if (existingData) { // There already is an inverse, either add or overwrite depehnding on // whether the inverse is a many relationship or not // if (Array.isArray(existingData)) { existingData.push(inversePayload.data); } else { - inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload); + inverseIdToPayloads[inverseId] = inversePayload; } } else { // first time we're populating the inverse side // if (inverseIsMany) { - inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, { + inverseIdToPayloads[inverseId] = { data: [inversePayload.data] - }); + }; } else { - inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload); + inverseIdToPayloads[inverseId] = inversePayload; } } }; - RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inversePayloadMap) { + RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inverseIdToPayloads) { var data = previousPayload && previousPayload.data; if (!data) { // either this is the first time we've seen a payload for this id, or its // previous payload indicated that it had no inverse, eg a belongsTo // relationship with payload { data: null } @@ -8576,20 +8431,19 @@ } if (Array.isArray(data)) { // TODO: diff rather than removeall addall? for (var i = 0; i < data.length; ++i) { - var resourceIdentifier = data[i]; - this._removeFromInverse(id, resourceIdentifier, inversePayloadMap); + this._removeFromInverse(id, data[i].id, inverseIdToPayloads); } } else { - this._removeFromInverse(id, data, inversePayloadMap); + this._removeFromInverse(id, data.id, inverseIdToPayloads); } }; - RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, resourceIdentifier, inversePayloads) { - var inversePayload = inversePayloads.get(resourceIdentifier.type, resourceIdentifier.id); + RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, inverseId, inversePayloads) { + var inversePayload = inversePayloads[inverseId]; var data = inversePayload && inversePayload.data; if (!data) { return; } @@ -8597,27 +8451,25 @@ if (Array.isArray(data)) { inversePayload.data = data.filter(function (x) { return x.id !== id; }); } else { - inversePayloads.set(resourceIdentifier.type, resourceIdentifier.id, { + inversePayloads[inverseId] = { data: null - }); + }; } }; _createClass(RelationshipPayloads, [{ key: '_lhsRelationshipIsMany', get: function () { - var meta = this._relInfo.lhs_relationshipMeta; - return meta !== null && meta.kind === 'hasMany'; + return this._lhsRelationshipMeta && this._lhsRelationshipMeta.kind === 'hasMany'; } }, { key: '_rhsRelationshipIsMany', get: function () { - var meta = this._relInfo.rhs_relationshipMeta; - return meta !== null && meta.kind === 'hasMany'; + return this._rhsRelationshipMeta && this._rhsRelationshipMeta.kind === 'hasMany'; } }]); return RelationshipPayloads; }(); @@ -16444,15 +16296,18 @@ documentHash.data = ret; } if (Array.isArray(documentHash.included)) { - var _ret = new Array(documentHash.included.length); - + var _ret = new Array(); for (var _i = 0; _i < documentHash.included.length; _i++) { var included = documentHash.included[_i]; - _ret[_i] = this._normalizeResourceHelper(included); + var normalized = this._normalizeResourceHelper(included); + if (normalized !== null) { + // can be null when unknown type is encountered + _ret.push(normalized); + } } documentHash.included = _ret; } @@ -18377,10 +18232,10 @@ }); define("ember-data/version", ["exports"], function (exports) { "use strict"; exports.__esModule = true; - exports.default = "2.16.4"; + exports.default = "2.17.0-beta.1"; }); define("ember-inflector", ["module", "exports", "ember", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (module, exports, _ember, _system) { "use strict"; exports.__esModule = true;