dist/globals/ember-data.prod.js in ember-data-source-3.1.0.beta.1 vs dist/globals/ember-data.prod.js in ember-data-source-3.1.0.beta.2

- 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 3.1.0-beta.1 + * @version 3.1.0-beta.2 */ var loader, define, requireModule, require, requirejs; (function (global) { @@ -1305,11 +1305,11 @@ var _Ember$FEATURES; return (_Ember$FEATURES = Ember.FEATURES).isEnabled.apply(_Ember$FEATURES, arguments); } }); -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/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, _features, _states, _internalModel, _promiseProxies, _recordArrays, _manyArray, _recordArrayManager, _relationship, _debugAdapter, _diffArray, _relationshipPayloadsManager, _relationshipPayloads, _snapshotRecordArray) { +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/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/map', 'ember-data/-private/system/map-with-default', '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, _features, _states, _internalModel, _promiseProxies, _recordArrays, _manyArray, _recordArrayManager, _relationship, _map, _mapWithDefault, _debugAdapter, _diffArray, _relationshipPayloadsManager, _relationshipPayloads, _snapshotRecordArray) { 'use strict'; exports.__esModule = true; Object.defineProperty(exports, 'Model', { enumerable: true, @@ -1525,10 +1525,22 @@ enumerable: true, get: function () { return _relationship.default; } }); + Object.defineProperty(exports, 'Map', { + enumerable: true, + get: function () { + return _map.default; + } + }); + Object.defineProperty(exports, 'MapWithDefault', { + enumerable: true, + get: function () { + return _mapWithDefault.default; + } + }); Object.defineProperty(exports, 'DebugAdapter', { enumerable: true, get: function () { return _debugAdapter.default; } @@ -2224,25 +2236,206 @@ return record; } }); }); -define('ember-data/-private/system/model/errors', ['exports'], function (exports) { +define('ember-data/-private/system/map-with-default', ['exports', 'ember-data/-private/system/map'], function (exports, _map) { 'use strict'; exports.__esModule = true; + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + var MapWithDefault = function (_Map) { + _inherits(MapWithDefault, _Map); + + function MapWithDefault(options) { + var _this = _possibleConstructorReturn(this, _Map.call(this)); + + _this.defaultValue = options.defaultValue; + return _this; + } + + MapWithDefault.prototype.get = function get(key) { + var hasValue = this.has(key); + + if (hasValue) { + return _Map.prototype.get.call(this, key); + } else { + var defaultValue = this.defaultValue(key); + this.set(key, defaultValue); + return defaultValue; + } + }; + + return MapWithDefault; + }(_map.default); + + exports.default = MapWithDefault; +}); +define('ember-data/-private/system/map', ['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; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + var MapWithDeprecations = function () { + function MapWithDeprecations(options) { + this._map = new Map(); + } + + MapWithDeprecations.prototype.copy = function copy() { + (false && !(false) && Ember.deprecate('Calling `.copy()` on a map generated by ember-data is deprecated, please migrate to using native Map functionality only.', false, { id: 'ember-data.map.copy', until: '3.5.0' })); + + + // can't just pass `this._map` here because IE11 doesn't accept + // constructor args with its `Map` + var newMap = new MapWithDeprecations(); + this._map.forEach(function (value, key) { + newMap.set(key, value); + }); + + return newMap; + }; + + MapWithDeprecations.prototype.isEmpty = function isEmpty() { + (false && !(false) && Ember.deprecate('Calling `.isEmpty()` on a map generated by ember-data is deprecated, please migrate to using native Map functionality only.', false, { id: 'ember-data.map.isEmpty', until: '3.5.0' })); + + + return this.size === 0; + }; + + MapWithDeprecations.prototype.clear = function clear() { + var _map; + + return (_map = this._map).clear.apply(_map, arguments); + }; + + MapWithDeprecations.prototype.delete = function _delete() { + var _map2; + + return (_map2 = this._map).delete.apply(_map2, arguments); + }; + + MapWithDeprecations.prototype.entries = function entries() { + var _map3; + + return (_map3 = this._map).entries.apply(_map3, arguments); + }; + + MapWithDeprecations.prototype.forEach = function forEach() { + var _map4; + + return (_map4 = this._map).forEach.apply(_map4, arguments); + }; + + MapWithDeprecations.prototype.get = function get() { + var _map5; + + return (_map5 = this._map).get.apply(_map5, arguments); + }; + + MapWithDeprecations.prototype.has = function has() { + var _map6; + + return (_map6 = this._map).has.apply(_map6, arguments); + }; + + MapWithDeprecations.prototype.keys = function keys() { + var _map7; + + return (_map7 = this._map).keys.apply(_map7, arguments); + }; + + MapWithDeprecations.prototype.set = function set() { + var _map8; + + return (_map8 = this._map).set.apply(_map8, arguments); + }; + + MapWithDeprecations.prototype.values = function values() { + var _map9; + + return (_map9 = this._map).values.apply(_map9, arguments); + }; + + _createClass(MapWithDeprecations, [{ + key: 'size', + get: function () { + return this._map.size; + } + }]); + + return MapWithDeprecations; + }(); + + exports.default = MapWithDeprecations; +}); +define('ember-data/-private/system/model/errors', ['exports', 'ember-data/-private/system/map-with-default'], function (exports, _mapWithDefault) { + 'use strict'; + + exports.__esModule = true; var mapBy = Ember.computed.mapBy; var not = Ember.computed.not; var Evented = Ember.Evented; var ArrayProxy = Ember.ArrayProxy; var set = Ember.set; var get = Ember.get; var computed = Ember.computed; - var isEmpty = Ember.isEmpty; var makeArray = Ember.makeArray; var A = Ember.A; - var MapWithDefault = Ember.MapWithDefault; exports.default = ArrayProxy.extend(Evented, { /** Register with target handler @method registerHandlers @param {Object} target @@ -2272,15 +2465,15 @@ }, /** @property errorsByAttributeName - @type {Ember.MapWithDefault} + @type {MapWithDefault} @private */ errorsByAttributeName: computed(function () { - return MapWithDefault.create({ + return new _mapWithDefault.default({ defaultValue: function () { return A(); } }); }), @@ -2334,11 +2527,11 @@ @method unknownProperty @private */ unknownProperty: function (attribute) { var errors = this.errorsFor(attribute); - if (isEmpty(errors)) { + if (errors.length === 0) { return undefined; } return errors; }, @@ -2571,11 +2764,11 @@ @method has @param {String} attribute @return {Boolean} true if there some errors on given attribute */ has: function (attribute) { - return !isEmpty(this.errorsFor(attribute)); + return this.errorsFor(attribute).length > 0; } }); }); define('ember-data/-private/system/model/internal-model', ['exports', 'ember-data/-private/system/model/states', 'ember-data/-private/system/relationships/state/create', 'ember-data/-private/system/snapshot', 'ember-data/-private/features', 'ember-data/-private/system/ordered-set', 'ember-data/-private/utils', 'ember-data/-private/system/references'], function (exports, _states, _create, _snapshot, _features, _orderedSet, _utils, _references) { 'use strict'; @@ -2611,11 +2804,10 @@ var set = Ember.set; var get = Ember.get; var copy = Ember.copy; var EmberError = Ember.Error; var isEqual = Ember.isEqual; - var isEmpty = Ember.isEmpty; var setOwner = Ember.setOwner; var run = Ember.run; var RSVP = Ember.RSVP; var Promise = Ember.RSVP.Promise; var inspect = Ember.inspect; @@ -3421,11 +3613,11 @@ }; InternalModel.prototype.hasErrors = function hasErrors() { var errors = get(this.getRecord(), 'errors'); - return !isEmpty(errors); + return errors.get('length') > 0; }; InternalModel.prototype.adapterDidInvalidate = function adapterDidInvalidate(errors) { var attribute = void 0; @@ -3654,11 +3846,11 @@ return this._data[key]; } }; } }); -define('ember-data/-private/system/model/model', ['exports', 'ember-data/-private/system/promise-proxies', 'ember-data/-private/system/model/errors', 'ember-data/-private/features', 'ember-data/-private/system/model/states', 'ember-data/-private/system/relationships/ext'], function (exports, _promiseProxies, _errors, _features, _states, _ext) { +define('ember-data/-private/system/model/model', ['exports', 'ember-data/-private/system/map', 'ember-data/-private/system/promise-proxies', 'ember-data/-private/system/model/errors', 'ember-data/-private/features', 'ember-data/-private/system/model/states', 'ember-data/-private/system/relationships/ext'], function (exports, _map, _promiseProxies, _errors, _features, _states, _ext) { 'use strict'; exports.__esModule = true; var ComputedProperty = Ember.ComputedProperty; var isNone = Ember.isNone; @@ -3666,11 +3858,10 @@ var Evented = Ember.Evented; var EmberObject = Ember.Object; var computed = Ember.computed; var get = Ember.get; var observer = Ember.observer; - var Map = Ember.Map; /** @module ember-data */ @@ -4432,11 +4623,11 @@ relationships.get(Post); //=> [ { name: 'posts', kind: 'hasMany' } ] ``` @property relationships @static - @type Ember.Map + @type Map @readOnly */ relationships: _ext.relationshipsDescriptor, @@ -4532,11 +4723,11 @@ relationshipsByName.get('owner'); //=> { key: 'owner', kind: 'belongsTo', type: 'user', options: Object, isRelationship: true } ``` @property relationshipsByName @static - @type Ember.Map + @type Map @readOnly */ relationshipsByName: _ext.relationshipsByNameDescriptor, /** @@ -4566,15 +4757,15 @@ // posts, hasMany // title, attribute ``` @property fields @static - @type Ember.Map + @type Map @readOnly */ fields: computed(function () { - var map = Map.create(); + var map = new _map.default(); this.eachComputedProperty(function (name, meta) { if (meta.isRelationship) { map.set(name, meta.kind); } else if (meta.isAttribute) { @@ -4645,17 +4836,17 @@ // lastName {type: "string", isAttribute: true, options: Object, parentType: function, name: "lastName"} // birthday {type: "date", isAttribute: true, options: Object, parentType: function, name: "birthday"} ``` @property attributes @static - @type {Ember.Map} + @type {Map} @readOnly */ attributes: computed(function () { var _this3 = this; - var map = Map.create(); + var map = new _map.default(); this.eachComputedProperty(function (name, meta) { if (meta.isAttribute) { (false && Ember.assert("You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from " + _this3.toString(), name !== 'id')); @@ -4693,15 +4884,15 @@ // lastName string // birthday date ``` @property transformedAttributes @static - @type {Ember.Map} + @type {Map} @readOnly */ transformedAttributes: computed(function () { - var map = Map.create(); + var map = new _map.default(); this.eachAttribute(function (key, meta) { if (meta.type) { map.set(key, meta.type); } @@ -4746,10 +4937,14 @@ // 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; } } }); } @@ -5505,32 +5700,28 @@ */ function normalizeModelName(modelName) { return dasherize(modelName); } }); -define('ember-data/-private/system/ordered-set', ['exports'], function (exports) { +define('ember-data/-private/system/ordered-set', ['exports', '@ember/ordered-set'], function (exports, _orderedSet) { 'use strict'; exports.__esModule = true; exports.default = OrderedSet; var guidFor = Ember.guidFor; - - - var EmberOrderedSet = Ember.OrderedSet; - function OrderedSet() { this._super$constructor(); } OrderedSet.create = function () { var Constructor = this; return new Constructor(); }; - OrderedSet.prototype = Object.create(EmberOrderedSet.prototype); + OrderedSet.prototype = Object.create(_orderedSet.default.prototype); OrderedSet.prototype.constructor = OrderedSet; - OrderedSet.prototype._super$constructor = EmberOrderedSet; + OrderedSet.prototype._super$constructor = _orderedSet.default; OrderedSet.prototype.addWithIndex = function (obj, idx) { var guid = guidFor(obj); var presenceSet = this.presenceSet; var list = this.list; @@ -7552,25 +7743,19 @@ } return modelName; } function relationshipFromMeta(meta) { - var result = { + return { 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'; @@ -7712,21 +7897,19 @@ return this._internalModel._relationships.get(key).getRecord(); } }).meta(meta); } }); -define('ember-data/-private/system/relationships/ext', ['exports', 'ember-data/-private/system/relationship-meta'], function (exports, _relationshipMeta) { +define('ember-data/-private/system/relationships/ext', ['exports', 'ember-data/-private/system/map-with-default', 'ember-data/-private/system/map', 'ember-data/-private/system/relationship-meta'], function (exports, _mapWithDefault, _map, _relationshipMeta) { 'use strict'; exports.__esModule = true; exports.relationshipsByNameDescriptor = exports.relatedTypesDescriptor = exports.relationshipsDescriptor = undefined; var A = Ember.A; var computed = Ember.computed; - var MapWithDefault = Ember.MapWithDefault; - var Map = Ember.Map; var relationshipsDescriptor = exports.relationshipsDescriptor = computed(function () { - var map = new MapWithDefault({ + var map = new _mapWithDefault.default({ defaultValue: function () { return []; } }); @@ -7775,11 +7958,11 @@ return types; }).readOnly(); var relationshipsByNameDescriptor = exports.relationshipsByNameDescriptor = computed(function () { - var map = Map.create(); + var map = new _map.default(); this.eachComputedProperty(function (name, meta) { if (meta.isRelationship) { meta.key = name; var relationship = (0, _relationshipMeta.relationshipFromMeta)(meta); @@ -7968,17 +8151,18 @@ 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 @@ -7995,90 +8179,194 @@ @method */ RelationshipPayloadsManager.prototype.get = function get(modelName, id, relationshipName) { - var modelClass = this._store._modelFor(modelName); - var relationshipsByName = _get(modelClass, 'relationshipsByName'); - var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false); + var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, 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, modelClass, relationshipsByName, true); + var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, 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, modelClass, relationshipsByName, false); + var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, false); if (relationshipPayloads) { relationshipPayloads.unload(modelName, id, relationshipName); } }); }; - RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, init) { - if (!relationshipsByName.has(relationshipName)) { + RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, init) { + var relInfo = this.getRelationshipInfo(modelName, relationshipName); + + if (relInfo === null) { return; } - var key = modelName + ':' + relationshipName; - if (!this._cache[key] && init) { - return this._initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName); + var cache = this._cache[relInfo.lhs_key]; + + if (!cache && init) { + return this._initializeRelationshipPayloads(relInfo); } - return this._cache[key]; + return cache; }; - RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName) { + 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); var relationshipMeta = relationshipsByName.get(relationshipName); - var inverseMeta = modelClass.inverseFor(relationshipName, this._store); + var selfIsPolymorphic = relationshipMeta.options !== undefined && relationshipMeta.options.polymorphic === true; + var inverseBaseModelName = relationshipMeta.type; - var inverseModelName = void 0; - var inverseRelationshipName = void 0; - var inverseRelationshipMeta = void 0; + // 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 + }; - // 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; + inverseCache.set(modelName, relationshipName, _info); + + return _info; } - var lhsKey = modelName + ':' + relationshipName; - var rhsKey = inverseModelName + ':' + inverseRelationshipName; + // CASE: We do have an inverse + 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 // - return this._cache[lhsKey] = this._cache[rhsKey] = new _relationshipPayloads.default(this._store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta); + var cache = this._cache[lhsKey] = new _relationshipPayloads.default(relInfo); + + if (relInfo.hasInverse === true) { + this._cache[rhsKey] = cache; + } + + return cache; }; return RelationshipPayloadsManager; }(); @@ -8087,16 +8375,10 @@ 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; @@ -8111,65 +8393,87 @@ if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var RelationshipPayloads = function () { - function RelationshipPayloads(store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta) { - this._store = store; + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } - this._lhsModelName = modelName; - this._lhsRelationshipName = relationshipName; - this._lhsRelationshipMeta = relationshipMeta; + var TypeCache = exports.TypeCache = function () { + function TypeCache() { + this.types = Object.create(null); + } - this._rhsModelName = inverseModelName; - this._rhsRelationshipName = inverseRelationshipName; - this._rhsRelationshipMeta = inverseRelationshipMeta; + TypeCache.prototype.get = function get(modelName, id) { + var types = this.types; - // 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; + + if (types[modelName] !== undefined) { + return types[modelName][id]; } + }; + 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._lhsPayloads[id]; + return this.lhs_payloads.get(modelName, id); } else { - (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName))); + (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName))); - return this._rhsPayloads[id]; + return this.rhs_payloads.get(modelName, id); } }; RelationshipPayloads.prototype.push = function push(modelName, id, relationshipName, relationshipData) { this._pendingPayloads.push([modelName, id, relationshipName, relationshipData]); @@ -8177,24 +8481,44 @@ RelationshipPayloads.prototype.unload = function unload(modelName, id, relationshipName) { this._flushPending(); if (this._isLHS(modelName, relationshipName)) { - delete this._lhsPayloads[id]; + delete this.lhs_payloads.delete(modelName, id); } else { - (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName))); + (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))); - delete this._rhsPayloads[id]; + delete this.rhs_payloads.delete(modelName, id); } }; RelationshipPayloads.prototype._isLHS = function _isLHS(modelName, relationshipName) { - return modelName === this._lhsModelName && relationshipName === this._lhsRelationshipName; + 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; }; RelationshipPayloads.prototype._isRHS = function _isRHS(modelName, relationshipName) { - return modelName === this._rhsModelName && relationshipName === this._rhsRelationshipName; + 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; }; RelationshipPayloads.prototype._flushPending = function _flushPending() { if (this._pendingPayloads.length === 0) { return; @@ -8211,30 +8535,32 @@ 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 idToPayloads = void 0; - var inverseIdToPayloads = 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 payloadMap = void 0; + var inversePayloadMap = void 0; var inverseIsMany = void 0; + if (this._isLHS(modelName, relationshipName)) { - previousPayload = this._lhsPayloads[id]; - idToPayloads = this._lhsPayloads; - inverseIdToPayloads = this._rhsPayloads; + previousPayload = this.lhs_payloads.get(modelName, id); + payloadMap = this.lhs_payloads; + inversePayloadMap = this.rhs_payloads; inverseIsMany = this._rhsRelationshipIsMany; } else { - (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName))); + (false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName))); - previousPayload = this._rhsPayloads[id]; - idToPayloads = this._rhsPayloads; - inverseIdToPayloads = this._lhsPayloads; + previousPayload = this.rhs_payloads.get(modelName, id); + payloadMap = this.rhs_payloads; + inversePayloadMap = this.lhs_payloads; inverseIsMany = this._lhsRelationshipIsMany; } // actually flush this individual payload // @@ -8274,67 +8600,69 @@ // 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, inverseIdToPayloads); + this._removeInverse(id, previousPayload, inversePayloadMap); } - idToPayloads[id] = relationshipData; - this._populateInverse(relationshipData, inverseRelationshipData, inverseIdToPayloads, inverseIsMany); + payloadMap.set(modelName, id, relationshipData); + this._populateInverse(relationshipData, inverseRelationshipData, inversePayloadMap, inverseIsMany); } }; - RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inverseIdToPayloads, inverseIsMany) { + RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inversePayloadMap, 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 inverseId = relationshipData.data[i].id; - this._addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany); + var resourceIdentifier = relationshipData.data[i]; + this._addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany); } } else { - var _inverseId = relationshipData.data.id; - this._addToInverse(inversePayload, _inverseId, inverseIdToPayloads, inverseIsMany); + var _resourceIdentifier = relationshipData.data; + this._addToInverse(inversePayload, _resourceIdentifier, inversePayloadMap, inverseIsMany); } }; - RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany) { - if (this._isReflexive && inversePayload.data.id === inverseId) { + RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany) { + var relInfo = this._relInfo; + + if (relInfo.isReflexive && inversePayload.data.id === resourceIdentifier.id) { // eg <user:1>.friends = [{ id: 1, type: 'user' }] return; } - var existingPayload = inverseIdToPayloads[inverseId]; + var existingPayload = inversePayloadMap.get(resourceIdentifier.type, resourceIdentifier.id); 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 { - inverseIdToPayloads[inverseId] = inversePayload; + inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload); } } else { // first time we're populating the inverse side // if (inverseIsMany) { - inverseIdToPayloads[inverseId] = { + inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, { data: [inversePayload.data] - }; + }); } else { - inverseIdToPayloads[inverseId] = inversePayload; + inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload); } } }; - RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inverseIdToPayloads) { + RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inversePayloadMap) { 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 } @@ -8345,19 +8673,20 @@ } if (Array.isArray(data)) { // TODO: diff rather than removeall addall? for (var i = 0; i < data.length; ++i) { - this._removeFromInverse(id, data[i].id, inverseIdToPayloads); + var resourceIdentifier = data[i]; + this._removeFromInverse(id, resourceIdentifier, inversePayloadMap); } } else { - this._removeFromInverse(id, data.id, inverseIdToPayloads); + this._removeFromInverse(id, data, inversePayloadMap); } }; - RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, inverseId, inversePayloads) { - var inversePayload = inversePayloads[inverseId]; + RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, resourceIdentifier, inversePayloads) { + var inversePayload = inversePayloads.get(resourceIdentifier.type, resourceIdentifier.id); var data = inversePayload && inversePayload.data; if (!data) { return; } @@ -8365,25 +8694,27 @@ if (Array.isArray(data)) { inversePayload.data = data.filter(function (x) { return x.id !== id; }); } else { - inversePayloads[inverseId] = { + inversePayloads.set(resourceIdentifier.type, resourceIdentifier.id, { data: null - }; + }); } }; _createClass(RelationshipPayloads, [{ key: '_lhsRelationshipIsMany', get: function () { - return this._lhsRelationshipMeta && this._lhsRelationshipMeta.kind === 'hasMany'; + var meta = this._relInfo.lhs_relationshipMeta; + return meta !== null && meta.kind === 'hasMany'; } }, { key: '_rhsRelationshipIsMany', get: function () { - return this._rhsRelationshipMeta && this._rhsRelationshipMeta.kind === 'hasMany'; + var meta = this._relInfo.rhs_relationshipMeta; + return meta !== null && meta.kind === 'hasMany'; } }]); return RelationshipPayloads; }(); @@ -9305,10 +9636,11 @@ relationship.inverseDidDematerialize(_this.internalModel); }); }; Relationship.prototype.inverseDidDematerialize = function inverseDidDematerialize(inverseInternalModel) { + this.linkPromise = null; if (!this.isAsync) { // unloading inverse of a sync relationship is treated as a client-side // delete, so actually remove the models don't merely invalidate the cp // cache. this.removeInternalModelFromOwn(inverseInternalModel); @@ -10076,19 +10408,18 @@ return Snapshot; }(); exports.default = Snapshot; }); -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) { +define('ember-data/-private/system/store', ['exports', 'ember-data/-private/system/map-with-default', '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, _mapWithDefault, _errors, _model, _normalizeModelName, _identityMap, _promiseProxies, _common, _serializerResponse, _serializers, _relationshipPayloadsManager, _finders, _utils, _coerceId, _recordArrayManager, _internalModel6, _features) { 'use strict'; exports.__esModule = true; exports.Store = undefined; var A = Ember.A; var copy = Ember.copy; var EmberError = Ember.Error; - var MapWithDefault = Ember.MapWithDefault; var emberRun = Ember.run; var set = Ember.set; var get = Ember.get; var computed = Ember.computed; var RSVP = Ember.RSVP; @@ -10237,11 +10568,11 @@ this._pushedInternalModels = []; // used for coalescing internal model updates this._updatedInternalModels = []; // used to keep track of all the find requests that need to be coalesced - this._pendingFetch = MapWithDefault.create({ + this._pendingFetch = new _mapWithDefault.default({ defaultValue: function () { return []; } }); @@ -10803,38 +11134,50 @@ var _internalModel = pendingItem.internalModel; internalModels[_i] = _internalModel; seeking[_internalModel.id] = pendingItem; } + for (var _i2 = 0; _i2 < totalItems; _i2++) { + var _internalModel2 = internalModels[_i2]; + // We may have unloaded the record after scheduling this fetch, in which + // case we must cancel the destory. This is because we require a record + // to build a snapshot. This is not fundamental: this cancelation code + // can be removed when snapshots can be created for internal models that + // have no records. + if (_internalModel2.hasScheduledDestroy()) { + internalModels[_i2].cancelDestroy(); + } + } + function _fetchRecord(recordResolverPair) { var recordFetch = store._fetchRecord(recordResolverPair.internalModel, recordResolverPair.options); // TODO adapter options recordResolverPair.resolver.resolve(recordFetch); } function handleFoundRecords(foundInternalModels, expectedInternalModels) { // resolve found records var found = Object.create(null); - for (var _i2 = 0, _l = foundInternalModels.length; _i2 < _l; _i2++) { - var _internalModel2 = foundInternalModels[_i2]; - var _pair = seeking[_internalModel2.id]; - found[_internalModel2.id] = _internalModel2; + for (var _i3 = 0, _l = foundInternalModels.length; _i3 < _l; _i3++) { + var _internalModel3 = foundInternalModels[_i3]; + var _pair = seeking[_internalModel3.id]; + found[_internalModel3.id] = _internalModel3; if (_pair) { var resolver = _pair.resolver; - resolver.resolve(_internalModel2); + resolver.resolve(_internalModel3); } } // reject missing records var missingInternalModels = []; - for (var _i3 = 0, _l2 = expectedInternalModels.length; _i3 < _l2; _i3++) { - var _internalModel3 = expectedInternalModels[_i3]; + for (var _i4 = 0, _l2 = expectedInternalModels.length; _i4 < _l2; _i4++) { + var _internalModel4 = expectedInternalModels[_i4]; - if (!found[_internalModel3.id]) { - missingInternalModels.push(_internalModel3); + if (!found[_internalModel4.id]) { + missingInternalModels.push(_internalModel4); } } if (missingInternalModels.length) { (false && Ember.warn('Ember Data expected to find records with the following ids in the adapter response but they were missing: ' + inspect(missingInternalModels.map(function (r) { @@ -10846,16 +11189,16 @@ rejectInternalModels(missingInternalModels); } } function rejectInternalModels(internalModels, error) { - for (var _i4 = 0, _l3 = internalModels.length; _i4 < _l3; _i4++) { - var _internalModel4 = internalModels[_i4]; - var _pair2 = seeking[_internalModel4.id]; + for (var _i5 = 0, _l3 = internalModels.length; _i5 < _l3; _i5++) { + var _internalModel5 = internalModels[_i5]; + var _pair2 = seeking[_internalModel5.id]; if (_pair2) { - _pair2.resolver.reject(error || new Error('Expected: \'' + _internalModel4 + '\' to be present in the adapter provided payload, but it was not found.')); + _pair2.resolver.reject(error || new Error('Expected: \'' + _internalModel5 + '\' to be present in the adapter provided payload, but it was not found.')); } } } if (shouldCoalesce) { @@ -10868,12 +11211,12 @@ // // But since the _findMany() finder is a store method we need to get the // records from the grouped snapshots even though the _findMany() finder // will once again convert the records to snapshots for adapter.findMany() var snapshots = new Array(totalItems); - for (var _i5 = 0; _i5 < totalItems; _i5++) { - snapshots[_i5] = internalModels[_i5].createSnapshot(); + for (var _i6 = 0; _i6 < totalItems; _i6++) { + snapshots[_i6] = internalModels[_i6].createSnapshot(); } var groups = adapter.groupRecordsForFindMany(this, snapshots); for (var i = 0, l = groups.length; i < l; i++) { @@ -10903,12 +11246,12 @@ } else { (false && Ember.assert("You cannot return an empty array from adapter's method groupRecordsForFindMany", false)); } } } else { - for (var _i6 = 0; _i6 < totalItems; _i6++) { - _fetchRecord(pendingFetchItems[_i6]); + for (var _i7 = 0; _i7 < totalItems; _i7++) { + _fetchRecord(pendingFetchItems[_i7]); } } }, @@ -12381,11 +12724,11 @@ (false && Ember.assert('The id ' + id + ' has already been used with another record for modelClass \'' + modelName + '\'.', !existingInternalModel)); // lookupFactory should really return an object that creates // instances with the injections applied - var internalModel = new _internalModel5.default(modelName, id, this, data); + var internalModel = new _internalModel6.default(modelName, id, this, data); this._internalModelsFor(modelName).add(internalModel, id); return internalModel; }, @@ -13038,11 +13381,10 @@ 'use strict'; exports.__esModule = true; exports.validateDocumentStructure = validateDocumentStructure; exports.normalizeResponseHelper = normalizeResponseHelper; - var isEmpty = Ember.isEmpty; /* This is a helper method that validates a JSON API top-level document @@ -13116,11 +13458,11 @@ var normalizedResponse = serializer.normalizeResponse(store, modelClass, payload, id, requestType); var validationErrors = []; if (false) { validationErrors = validateDocumentStructure(normalizedResponse); } - (false && Ember.assert('normalizeResponse must return a valid JSON API document:\n\t* ' + validationErrors.join('\n\t* '), isEmpty(validationErrors))); + (false && Ember.assert('normalizeResponse must return a valid JSON API document:\n\t* ' + validationErrors.join('\n\t* '), validationErrors.length === 0)); return normalizedResponse; } }); @@ -14174,11 +14516,10 @@ 'use strict'; exports.__esModule = true; var $ = Ember.$; var EmberPromise = Ember.RSVP.Promise; - var MapWithDefault = Ember.MapWithDefault; var get = Ember.get; var run = Ember.run; var Promise = EmberPromise; @@ -14695,11 +15036,11 @@ // http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers maxURLLength: 2048, groupRecordsForFindMany: function (store, snapshots) { - var groups = MapWithDefault.create({ + var groups = new _private.MapWithDefault({ defaultValue: function () { return []; } }); var adapter = this; @@ -17967,11 +18308,10 @@ }); define('ember-data/transforms/number', ['exports', 'ember-data/transforms/transform'], function (exports, _transform) { 'use strict'; exports.__esModule = true; - var empty = Ember.isEmpty; function isNumber(value) { return value === value && value !== Infinity && value !== -Infinity; } @@ -18000,22 +18340,22 @@ */ exports.default = _transform.default.extend({ deserialize: function (serialized) { var transformed = void 0; - if (empty(serialized)) { + if (serialized === '' || serialized === null || serialized === undefined) { return null; } else { transformed = Number(serialized); return isNumber(transformed) ? transformed : null; } }, serialize: function (deserialized) { var transformed = void 0; - if (empty(deserialized)) { + if (deserialized === '' || deserialized === null || deserialized === undefined) { return null; } else { transformed = Number(deserialized); return isNumber(transformed) ? transformed : null; @@ -18079,10 +18419,10 @@ }); define("ember-data/version", ["exports"], function (exports) { "use strict"; exports.__esModule = true; - exports.default = "3.1.0-beta.1"; + exports.default = "3.1.0-beta.2"; }); define("ember-inflector", ["module", "exports", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (module, exports, _system) { "use strict"; exports.__esModule = true;