dist/globals/ember-data.prod.js in ember-data-source-2.17.1 vs dist/globals/ember-data.prod.js in ember-data-source-2.18.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.17.1
+ * @version 2.18.0-beta.1
*/
var loader, define, requireModule, require, requirejs;
(function (global) {
@@ -496,11 +496,11 @@
Example:
```app/adapters/user.js
import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend({
urlForFindRecord(id, modelName, snapshot) {
- let baseUrl = this.buildURL();
+ let baseUrl = this.buildURL(modelName, id, snapshot);
return `${baseUrl}/users/${snapshot.adapterOptions.user_id}/playlists/${id}`;
}
});
```
@method urlForFindRecord
@@ -1663,11 +1663,11 @@
if (arguments.length < 2) {
// Legacy Ember.js < 1.13 support
var containerKey = modelClass._debugContainerKey;
if (containerKey) {
var match = containerKey.match(/model:(.*)/);
- if (match) {
+ if (match !== null) {
modelName = match[1];
}
}
}
(false && Ember.assert("Cannot find model name. Please upgrade to Ember.js >= 1.13 for Ember Inspector support", !!modelName));
@@ -4794,14 +4794,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;
}
}
});
}
@@ -7604,19 +7600,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-data/-private/system/normalize-model-name'], function (exports, _normalizeModelName) {
'use strict';
@@ -8022,18 +8024,17 @@
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
- var get = Ember.get;
+ var _get = Ember.get;
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
@@ -8050,194 +8051,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) {
- (false && Ember.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;
}();
@@ -8246,10 +8143,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;
@@ -8264,87 +8167,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]);
@@ -8352,44 +8233,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;
@@ -8406,32 +8267,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
//
@@ -8471,69 +8330,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 }
@@ -8544,20 +8401,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;
}
@@ -8565,27 +8421,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;
}();
@@ -15400,11 +15254,11 @@
return value;
}
}).meta(meta);
}
});
-define('ember-data', ['exports', 'ember-data/-private', 'ember-data/setup-container', 'ember-data/instance-initializers/initialize-store-service', 'ember-data/transforms/transform', 'ember-data/transforms/number', 'ember-data/transforms/date', 'ember-data/transforms/string', 'ember-data/transforms/boolean', 'ember-data/adapter', 'ember-data/adapters/json-api', 'ember-data/adapters/rest', 'ember-data/serializer', 'ember-data/serializers/json-api', 'ember-data/serializers/json', 'ember-data/serializers/rest', 'ember-data/serializers/embedded-records-mixin', 'ember-data/attr', 'ember-inflector'], function (exports, _private, _setupContainer, _initializeStoreService, _transform, _number, _date, _string, _boolean, _adapter, _jsonApi, _rest, _serializer, _jsonApi2, _json, _rest2, _embeddedRecordsMixin, _attr) {
+define('ember-data', ['exports', 'ember-data/-private', 'ember-data/setup-container', 'ember-data/initialize-store-service', 'ember-data/transforms/transform', 'ember-data/transforms/number', 'ember-data/transforms/date', 'ember-data/transforms/string', 'ember-data/transforms/boolean', 'ember-data/adapter', 'ember-data/adapters/json-api', 'ember-data/adapters/rest', 'ember-data/serializer', 'ember-data/serializers/json-api', 'ember-data/serializers/json', 'ember-data/serializers/rest', 'ember-data/serializers/embedded-records-mixin', 'ember-data/attr', 'ember-inflector'], function (exports, _private, _setupContainer, _initializeStoreService, _transform, _number, _date, _string, _boolean, _adapter, _jsonApi, _rest, _serializer, _jsonApi2, _json, _rest2, _embeddedRecordsMixin, _attr) {
'use strict';
exports.__esModule = true;
var EmberError = Ember.Error;
@@ -15502,72 +15356,14 @@
}
});
exports.default = _private.DS;
});
-define('ember-data/initializers/data-adapter', ['exports'], function (exports) {
+define('ember-data/initialize-store-service', ['exports'], function (exports) {
'use strict';
exports.__esModule = true;
- exports.default = {
- name: 'data-adapter',
- before: 'store',
- initialize: function () {}
- };
-});
-define('ember-data/initializers/ember-data', ['exports', 'ember-data/setup-container', 'ember-data'], function (exports, _setupContainer) {
- 'use strict';
-
- exports.__esModule = true;
- exports.default = {
- name: 'ember-data',
- initialize: _setupContainer.default
- };
-});
-define('ember-data/initializers/injectStore', ['exports'], function (exports) {
- 'use strict';
-
- exports.__esModule = true;
- exports.default = {
- name: 'injectStore',
- before: 'store',
- initialize: function () {}
- };
-});
-define('ember-data/initializers/store', ['exports'], function (exports) {
- 'use strict';
-
- exports.__esModule = true;
- exports.default = {
- name: 'store',
- after: 'ember-data',
- initialize: function () {}
- };
-});
-define('ember-data/initializers/transforms', ['exports'], function (exports) {
- 'use strict';
-
- exports.__esModule = true;
- exports.default = {
- name: 'transforms',
- before: 'store',
- initialize: function () {}
- };
-});
-define("ember-data/instance-initializers/ember-data", ["exports", "ember-data/instance-initializers/initialize-store-service"], function (exports, _initializeStoreService) {
- "use strict";
-
- exports.__esModule = true;
- exports.default = {
- name: "ember-data",
- initialize: _initializeStoreService.default
- };
-});
-define('ember-data/instance-initializers/initialize-store-service', ['exports'], function (exports) {
- 'use strict';
-
- exports.__esModule = true;
exports.default = initializeStoreService;
var deprecateOldEmberDataInitializers = void 0;
@@ -15628,10 +15424,68 @@
}
}
};
}
});
+define('ember-data/initializers/data-adapter', ['exports'], function (exports) {
+ 'use strict';
+
+ exports.__esModule = true;
+ exports.default = {
+ name: 'data-adapter',
+ before: 'store',
+ initialize: function () {}
+ };
+});
+define('ember-data/initializers/ember-data', ['exports', 'ember-data/setup-container', 'ember-data'], function (exports, _setupContainer) {
+ 'use strict';
+
+ exports.__esModule = true;
+ exports.default = {
+ name: 'ember-data',
+ initialize: _setupContainer.default
+ };
+});
+define('ember-data/initializers/injectStore', ['exports'], function (exports) {
+ 'use strict';
+
+ exports.__esModule = true;
+ exports.default = {
+ name: 'injectStore',
+ before: 'store',
+ initialize: function () {}
+ };
+});
+define('ember-data/initializers/store', ['exports'], function (exports) {
+ 'use strict';
+
+ exports.__esModule = true;
+ exports.default = {
+ name: 'store',
+ after: 'ember-data',
+ initialize: function () {}
+ };
+});
+define('ember-data/initializers/transforms', ['exports'], function (exports) {
+ 'use strict';
+
+ exports.__esModule = true;
+ exports.default = {
+ name: 'transforms',
+ before: 'store',
+ initialize: function () {}
+ };
+});
+define("ember-data/instance-initializers/ember-data", ["exports", "ember-data/initialize-store-service"], function (exports, _initializeStoreService) {
+ "use strict";
+
+ exports.__esModule = true;
+ exports.default = {
+ name: "ember-data",
+ initialize: _initializeStoreService.default
+ };
+});
define('ember-data/model', ['exports', 'ember-data/-private'], function (exports, _private) {
'use strict';
exports.__esModule = true;
Object.defineProperty(exports, 'default', {
@@ -18128,20 +17982,20 @@
exports.__esModule = true;
var isNone = Ember.isNone;
exports.default = _transform.default.extend({
deserialize: function (serialized, options) {
- var type = typeof serialized;
-
if (isNone(serialized) && options.allowNull === true) {
return null;
}
+ var type = typeof serialized;
if (type === "boolean") {
return serialized;
} else if (type === "string") {
- return serialized.match(/^true$|^t$|^1$/i) !== null;
+ return (/^(true|t|1)$/i.test(serialized)
+ );
} else if (type === "number") {
return serialized === 1;
} else {
return false;
}
@@ -18361,10 +18215,10 @@
});
define("ember-data/version", ["exports"], function (exports) {
"use strict";
exports.__esModule = true;
- exports.default = "2.17.1";
+ exports.default = "2.18.0-beta.1";
});
define("ember-inflector", ["module", "exports", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (module, exports, _system) {
"use strict";
exports.__esModule = true;