ember-data-source 2.16.4 → 2.17.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dist/globals/ember-data.js +134 -281
- data/dist/globals/ember-data.min.js +5 -5
- data/dist/globals/ember-data.prod.js +133 -278
- data/package.json +11 -9
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb8ec817c8395383752e1e1397d6581a9596f4b3
|
4
|
+
data.tar.gz: 93e81cf51390ab4538275bf51cf83123474e1c1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55ab633c0d123c1f66da19ac8aa5551f7de53d240195a8f406f09bc002f41ed5f58fbecd8dacc66a392cdebd9709040efcead49a653191b8a355adffc3cf40ee
|
7
|
+
data.tar.gz: 42d78817cca4233b92e6179be7f90131a23789b2fe44404f6d1859a78daded567b19997c89b82925d4f55115ac556bebcea36ef6f1915b4abb9e1afd39f92f63
|
data/dist/globals/ember-data.js
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
* @copyright Copyright 2011-2017 Tilde Inc. and contributors.
|
7
7
|
* Portions Copyright 2011 LivingSocial Inc.
|
8
8
|
* @license Licensed under MIT license (see license.js)
|
9
|
-
* @version 2.
|
9
|
+
* @version 2.17.0-beta.1
|
10
10
|
*/
|
11
11
|
|
12
12
|
var loader, define, requireModule, require, requirejs;
|
@@ -4806,10 +4806,6 @@ define('ember-data/-private/system/model/model', ['exports', 'ember', 'ember-dat
|
|
4806
4806
|
// the computed property.
|
4807
4807
|
var meta = value.meta();
|
4808
4808
|
|
4809
|
-
/*
|
4810
|
-
This is buggy because if the parent has never been looked up
|
4811
|
-
via `modelFor` it will not have `modelName` set.
|
4812
|
-
*/
|
4813
4809
|
meta.parentType = proto.constructor;
|
4814
4810
|
}
|
4815
4811
|
}
|
@@ -6845,7 +6841,6 @@ define('ember-data/-private/system/references/belongs-to', ['exports', 'ember-da
|
|
6845
6841
|
```
|
6846
6842
|
|
6847
6843
|
@method value
|
6848
|
-
@param {Object|Promise} objectOrPromise a promise that resolves to a JSONAPI document object describing the new value of this relationship.
|
6849
6844
|
@return {DS.Model} the record in this relationship
|
6850
6845
|
*/
|
6851
6846
|
BelongsToReference.prototype.value = function () {
|
@@ -7599,7 +7594,7 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
|
|
7599
7594
|
}
|
7600
7595
|
|
7601
7596
|
function relationshipFromMeta(meta) {
|
7602
|
-
|
7597
|
+
var result = {
|
7603
7598
|
key: meta.key,
|
7604
7599
|
kind: meta.kind,
|
7605
7600
|
type: typeForRelationshipMeta(meta),
|
@@ -7608,6 +7603,12 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
|
|
7608
7603
|
parentType: meta.parentType,
|
7609
7604
|
isRelationship: true
|
7610
7605
|
};
|
7606
|
+
|
7607
|
+
if (false) {
|
7608
|
+
result.parentType = meta.parentType;
|
7609
|
+
}
|
7610
|
+
|
7611
|
+
return result;
|
7611
7612
|
}
|
7612
7613
|
});
|
7613
7614
|
define('ember-data/-private/system/relationships/belongs-to', ['exports', 'ember', 'ember-data/-private/system/normalize-model-name'], function (exports, _ember, _normalizeModelName) {
|
@@ -8013,8 +8014,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8013
8014
|
}
|
8014
8015
|
}
|
8015
8016
|
|
8016
|
-
var
|
8017
|
-
var assert = _ember.default.assert;
|
8017
|
+
var _get = _ember.default.get;
|
8018
8018
|
|
8019
8019
|
/**
|
8020
8020
|
Manages relationship payloads for a given store, for uninitialized
|
@@ -8077,7 +8077,6 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8077
8077
|
this._store = store;
|
8078
8078
|
// cache of `RelationshipPayload`s
|
8079
8079
|
this._cache = Object.create(null);
|
8080
|
-
this._inverseLookupCache = new _relationshipPayloads.TypeCache();
|
8081
8080
|
}
|
8082
8081
|
|
8083
8082
|
/**
|
@@ -8098,7 +8097,9 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8098
8097
|
|
8099
8098
|
|
8100
8099
|
RelationshipPayloadsManager.prototype.get = function get(modelName, id, relationshipName) {
|
8101
|
-
var
|
8100
|
+
var modelClass = this._store._modelFor(modelName);
|
8101
|
+
var relationshipsByName = _get(modelClass, 'relationshipsByName');
|
8102
|
+
var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
|
8102
8103
|
return relationshipPayloads && relationshipPayloads.get(modelName, id, relationshipName);
|
8103
8104
|
};
|
8104
8105
|
|
@@ -8109,8 +8110,10 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8109
8110
|
return;
|
8110
8111
|
}
|
8111
8112
|
|
8113
|
+
var modelClass = this._store._modelFor(modelName);
|
8114
|
+
var relationshipsByName = _get(modelClass, 'relationshipsByName');
|
8112
8115
|
Object.keys(relationshipsData).forEach(function (key) {
|
8113
|
-
var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, true);
|
8116
|
+
var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, modelClass, relationshipsByName, true);
|
8114
8117
|
if (relationshipPayloads) {
|
8115
8118
|
relationshipPayloads.push(modelName, id, key, relationshipsData[key]);
|
8116
8119
|
}
|
@@ -8121,153 +8124,51 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8121
8124
|
var _this2 = this;
|
8122
8125
|
|
8123
8126
|
var modelClass = this._store._modelFor(modelName);
|
8124
|
-
var relationshipsByName =
|
8127
|
+
var relationshipsByName = _get(modelClass, 'relationshipsByName');
|
8125
8128
|
relationshipsByName.forEach(function (_, relationshipName) {
|
8126
|
-
var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, false);
|
8129
|
+
var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
|
8127
8130
|
if (relationshipPayloads) {
|
8128
8131
|
relationshipPayloads.unload(modelName, id, relationshipName);
|
8129
8132
|
}
|
8130
8133
|
});
|
8131
8134
|
};
|
8132
8135
|
|
8133
|
-
RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, init) {
|
8134
|
-
|
8135
|
-
|
8136
|
-
if (relInfo === null) {
|
8136
|
+
RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, init) {
|
8137
|
+
if (!relationshipsByName.has(relationshipName)) {
|
8137
8138
|
return;
|
8138
8139
|
}
|
8139
8140
|
|
8140
|
-
var
|
8141
|
-
|
8142
|
-
|
8143
|
-
return this._initializeRelationshipPayloads(relInfo);
|
8141
|
+
var key = modelName + ':' + relationshipName;
|
8142
|
+
if (!this._cache[key] && init) {
|
8143
|
+
return this._initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName);
|
8144
8144
|
}
|
8145
8145
|
|
8146
|
-
return
|
8146
|
+
return this._cache[key];
|
8147
8147
|
};
|
8148
8148
|
|
8149
|
-
RelationshipPayloadsManager.prototype.
|
8150
|
-
var inverseCache = this._inverseLookupCache;
|
8151
|
-
var store = this._store;
|
8152
|
-
var cached = inverseCache.get(modelName, relationshipName);
|
8153
|
-
|
8154
|
-
// CASE: We have a cached resolution (null if no relationship exists)
|
8155
|
-
if (cached !== undefined) {
|
8156
|
-
return cached;
|
8157
|
-
}
|
8158
|
-
|
8159
|
-
var modelClass = store._modelFor(modelName);
|
8160
|
-
var relationshipsByName = get(modelClass, 'relationshipsByName');
|
8161
|
-
|
8162
|
-
// CASE: We don't have a relationship at all
|
8163
|
-
if (!relationshipsByName.has(relationshipName)) {
|
8164
|
-
inverseCache.set(modelName, relationshipName, null);
|
8165
|
-
return null;
|
8166
|
-
}
|
8167
|
-
|
8168
|
-
var inverseMeta = modelClass.inverseFor(relationshipName, store);
|
8149
|
+
RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName) {
|
8169
8150
|
var relationshipMeta = relationshipsByName.get(relationshipName);
|
8170
|
-
var
|
8171
|
-
|
8172
|
-
|
8173
|
-
|
8174
|
-
|
8175
|
-
|
8176
|
-
|
8177
|
-
|
8178
|
-
|
8179
|
-
|
8180
|
-
|
8181
|
-
|
8182
|
-
|
8183
|
-
|
8184
|
-
|
8185
|
-
|
8186
|
-
|
8187
|
-
rhs_isPolymorphic: false,
|
8188
|
-
hasInverse: false,
|
8189
|
-
isSelfReferential: false, // modelName === inverseBaseModelName,
|
8190
|
-
isReflexive: false
|
8191
|
-
};
|
8192
|
-
|
8193
|
-
inverseCache.set(modelName, relationshipName, _info);
|
8194
|
-
|
8195
|
-
return _info;
|
8196
|
-
}
|
8197
|
-
|
8198
|
-
// CASE: We do have an inverse
|
8199
|
-
|
8200
|
-
var inverseRelationshipName = inverseMeta.name;
|
8201
|
-
var inverseRelationshipMeta = get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
|
8202
|
-
var baseModelName = inverseRelationshipMeta.type;
|
8203
|
-
var isSelfReferential = baseModelName === inverseBaseModelName;
|
8204
|
-
|
8205
|
-
// TODO we want to assert this but this breaks all of our shoddily written tests
|
8206
|
-
/*
|
8207
|
-
if (DEBUG) {
|
8208
|
-
let inverseDoubleCheck = inverseMeta.type.inverseFor(inverseRelationshipName, store);
|
8209
|
-
assert(`The ${inverseBaseModelName}:${inverseRelationshipName} relationship declares 'inverse: null', but it was resolved as the inverse for ${baseModelName}:${relationshipName}.`, inverseDoubleCheck);
|
8151
|
+
var inverseMeta = modelClass.inverseFor(relationshipName, this._store);
|
8152
|
+
|
8153
|
+
var inverseModelName = void 0;
|
8154
|
+
var inverseRelationshipName = void 0;
|
8155
|
+
var inverseRelationshipMeta = void 0;
|
8156
|
+
|
8157
|
+
// figure out the inverse relationship; we need two things
|
8158
|
+
// a) the inverse model name
|
8159
|
+
//- b) the name of the inverse relationship
|
8160
|
+
if (inverseMeta) {
|
8161
|
+
inverseRelationshipName = inverseMeta.name;
|
8162
|
+
inverseModelName = relationshipMeta.type;
|
8163
|
+
inverseRelationshipMeta = _get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
|
8164
|
+
} else {
|
8165
|
+
// relationship has no inverse
|
8166
|
+
inverseModelName = inverseRelationshipName = '';
|
8167
|
+
inverseRelationshipMeta = null;
|
8210
8168
|
}
|
8211
|
-
*/
|
8212
|
-
|
8213
|
-
// CASE: We may have already discovered the inverse for the baseModelName
|
8214
|
-
// CASE: We have already discovered the inverse
|
8215
|
-
cached = inverseCache.get(baseModelName, relationshipName) || inverseCache.get(inverseBaseModelName, inverseRelationshipName);
|
8216
|
-
if (cached) {
|
8217
|
-
// TODO this assert can be removed if the above assert is enabled
|
8218
|
-
assert('The ' + inverseBaseModelName + ':' + inverseRelationshipName + ' relationship declares \'inverse: null\', but it was resolved as the inverse for ' + baseModelName + ':' + relationshipName + '.', cached.hasInverse !== false);
|
8219
|
-
|
8220
|
-
var isLHS = cached.lhs_baseModelName === baseModelName;
|
8221
|
-
var modelNames = isLHS ? cached.lhs_modelNames : cached.rhs_modelNames;
|
8222
|
-
// make this lookup easier in the future by caching the key
|
8223
|
-
modelNames.push(modelName);
|
8224
|
-
inverseCache.set(modelName, relationshipName, cached);
|
8225
|
-
|
8226
|
-
return cached;
|
8227
|
-
}
|
8228
|
-
|
8229
|
-
var info = {
|
8230
|
-
lhs_key: baseModelName + ':' + relationshipName,
|
8231
|
-
lhs_modelNames: [modelName],
|
8232
|
-
lhs_baseModelName: baseModelName,
|
8233
|
-
lhs_relationshipName: relationshipName,
|
8234
|
-
lhs_relationshipMeta: relationshipMeta,
|
8235
|
-
lhs_isPolymorphic: selfIsPolymorphic,
|
8236
|
-
rhs_key: inverseBaseModelName + ':' + inverseRelationshipName,
|
8237
|
-
rhs_modelNames: [],
|
8238
|
-
rhs_baseModelName: inverseBaseModelName,
|
8239
|
-
rhs_relationshipName: inverseRelationshipName,
|
8240
|
-
rhs_relationshipMeta: inverseRelationshipMeta,
|
8241
|
-
rhs_isPolymorphic: inverseRelationshipMeta.options !== undefined && inverseRelationshipMeta.options.polymorphic === true,
|
8242
|
-
hasInverse: true,
|
8243
|
-
isSelfReferential: isSelfReferential,
|
8244
|
-
isReflexive: isSelfReferential && relationshipName === inverseRelationshipName
|
8245
|
-
};
|
8246
|
-
|
8247
|
-
// Create entries for the baseModelName as well as modelName to speed up
|
8248
|
-
// inverse lookups
|
8249
|
-
inverseCache.set(baseModelName, relationshipName, info);
|
8250
|
-
inverseCache.set(modelName, relationshipName, info);
|
8251
|
-
|
8252
|
-
// Greedily populate the inverse
|
8253
|
-
inverseCache.set(inverseBaseModelName, inverseRelationshipName, info);
|
8254
|
-
|
8255
|
-
return info;
|
8256
|
-
};
|
8257
|
-
|
8258
|
-
RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(relInfo) {
|
8259
|
-
var lhsKey = relInfo.lhs_key;
|
8260
|
-
var rhsKey = relInfo.rhs_key;
|
8261
|
-
var existingPayloads = this._cache[lhsKey];
|
8262
|
-
|
8263
|
-
if (relInfo.hasInverse === true && relInfo.rhs_isPolymorphic === true) {
|
8264
|
-
existingPayloads = this._cache[rhsKey];
|
8265
8169
|
|
8266
|
-
|
8267
|
-
|
8268
|
-
return existingPayloads;
|
8269
|
-
}
|
8270
|
-
}
|
8170
|
+
var lhsKey = modelName + ':' + relationshipName;
|
8171
|
+
var rhsKey = inverseModelName + ':' + inverseRelationshipName;
|
8271
8172
|
|
8272
8173
|
// populate the cache for both sides of the relationship, as they both use
|
8273
8174
|
// the same `RelationshipPayloads`.
|
@@ -8275,13 +8176,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8275
8176
|
// This works out better than creating a single common key, because to
|
8276
8177
|
// compute that key we would need to do work to look up the inverse
|
8277
8178
|
//
|
8278
|
-
|
8279
|
-
|
8280
|
-
if (relInfo.hasInverse === true) {
|
8281
|
-
this._cache[rhsKey] = cache;
|
8282
|
-
}
|
8283
|
-
|
8284
|
-
return cache;
|
8179
|
+
return this._cache[lhsKey] = this._cache[rhsKey] = new _relationshipPayloads.default(this._store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta);
|
8285
8180
|
};
|
8286
8181
|
|
8287
8182
|
return RelationshipPayloadsManager;
|
@@ -8294,6 +8189,12 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8294
8189
|
|
8295
8190
|
exports.__esModule = true;
|
8296
8191
|
|
8192
|
+
function _classCallCheck(instance, Constructor) {
|
8193
|
+
if (!(instance instanceof Constructor)) {
|
8194
|
+
throw new TypeError("Cannot call a class as a function");
|
8195
|
+
}
|
8196
|
+
}
|
8197
|
+
|
8297
8198
|
var _createClass = function () {
|
8298
8199
|
function defineProperties(target, props) {
|
8299
8200
|
for (var i = 0; i < props.length; i++) {
|
@@ -8312,61 +8213,37 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8312
8213
|
};
|
8313
8214
|
}();
|
8314
8215
|
|
8315
|
-
function _classCallCheck(instance, Constructor) {
|
8316
|
-
if (!(instance instanceof Constructor)) {
|
8317
|
-
throw new TypeError("Cannot call a class as a function");
|
8318
|
-
}
|
8319
|
-
}
|
8320
|
-
|
8321
|
-
var TypeCache = exports.TypeCache = function () {
|
8322
|
-
function TypeCache() {
|
8323
|
-
_classCallCheck(this, TypeCache);
|
8324
|
-
|
8325
|
-
this.types = Object.create(null);
|
8326
|
-
}
|
8327
|
-
|
8328
|
-
TypeCache.prototype.get = function get(modelName, id) {
|
8329
|
-
var types = this.types;
|
8330
|
-
|
8331
|
-
|
8332
|
-
if (types[modelName] !== undefined) {
|
8333
|
-
return types[modelName][id];
|
8334
|
-
}
|
8335
|
-
};
|
8336
|
-
|
8337
|
-
TypeCache.prototype.set = function set(modelName, id, payload) {
|
8338
|
-
var types = this.types;
|
8339
|
-
|
8340
|
-
var typeMap = types[modelName];
|
8341
|
-
|
8342
|
-
if (typeMap === undefined) {
|
8343
|
-
typeMap = types[modelName] = Object.create(null);
|
8344
|
-
}
|
8345
|
-
|
8346
|
-
typeMap[id] = payload;
|
8347
|
-
};
|
8348
|
-
|
8349
|
-
TypeCache.prototype.delete = function _delete(modelName, id) {
|
8350
|
-
var types = this.types;
|
8351
|
-
|
8352
|
-
|
8353
|
-
if (types[modelName] !== undefined) {
|
8354
|
-
delete types[modelName][id];
|
8355
|
-
}
|
8356
|
-
};
|
8357
|
-
|
8358
|
-
return TypeCache;
|
8359
|
-
}();
|
8360
|
-
|
8361
8216
|
var RelationshipPayloads = function () {
|
8362
|
-
function RelationshipPayloads(
|
8217
|
+
function RelationshipPayloads(store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta) {
|
8363
8218
|
_classCallCheck(this, RelationshipPayloads);
|
8364
8219
|
|
8365
|
-
this.
|
8220
|
+
this._store = store;
|
8221
|
+
|
8222
|
+
this._lhsModelName = modelName;
|
8223
|
+
this._lhsRelationshipName = relationshipName;
|
8224
|
+
this._lhsRelationshipMeta = relationshipMeta;
|
8225
|
+
|
8226
|
+
this._rhsModelName = inverseModelName;
|
8227
|
+
this._rhsRelationshipName = inverseRelationshipName;
|
8228
|
+
this._rhsRelationshipMeta = inverseRelationshipMeta;
|
8366
8229
|
|
8367
8230
|
// a map of id -> payloads for the left hand side of the relationship.
|
8368
|
-
this.
|
8369
|
-
|
8231
|
+
this._lhsPayloads = Object.create(null);
|
8232
|
+
if (modelName !== inverseModelName || relationshipName !== inverseRelationshipName) {
|
8233
|
+
// The common case of a non-reflexive relationship, or a reflexive
|
8234
|
+
// relationship whose inverse is not itself
|
8235
|
+
this._rhsPayloads = Object.create(null);
|
8236
|
+
this._isReflexive = false;
|
8237
|
+
} else {
|
8238
|
+
// Edge case when we have a reflexive relationship to itself
|
8239
|
+
// eg user hasMany friends inverse friends
|
8240
|
+
//
|
8241
|
+
// In this case there aren't really two sides to the relationship, but
|
8242
|
+
// we set `_rhsPayloads = _lhsPayloads` to make things easier to reason
|
8243
|
+
// about
|
8244
|
+
this._rhsPayloads = this._lhsPayloads;
|
8245
|
+
this._isReflexive = true;
|
8246
|
+
}
|
8370
8247
|
|
8371
8248
|
// When we push relationship payloads, just stash them in a queue until
|
8372
8249
|
// somebody actually asks for one of them.
|
@@ -8377,22 +8254,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8377
8254
|
}
|
8378
8255
|
|
8379
8256
|
/**
|
8380
|
-
|
8381
|
-
|
8382
|
-
|
8383
|
-
|
8384
|
-
|
8257
|
+
Get the payload for the relationship of an individual record.
|
8258
|
+
This might return the raw payload as pushed into the store, or one computed
|
8259
|
+
from the payload of the inverse relationship.
|
8260
|
+
@method
|
8261
|
+
*/
|
8385
8262
|
|
8386
8263
|
|
8387
8264
|
RelationshipPayloads.prototype.get = function get(modelName, id, relationshipName) {
|
8388
8265
|
this._flushPending();
|
8389
8266
|
|
8390
8267
|
if (this._isLHS(modelName, relationshipName)) {
|
8391
|
-
return this.
|
8268
|
+
return this._lhsPayloads[id];
|
8392
8269
|
} else {
|
8393
|
-
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this.
|
8270
|
+
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
|
8394
8271
|
|
8395
|
-
return this.
|
8272
|
+
return this._rhsPayloads[id];
|
8396
8273
|
}
|
8397
8274
|
};
|
8398
8275
|
|
@@ -8404,40 +8281,20 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8404
8281
|
this._flushPending();
|
8405
8282
|
|
8406
8283
|
if (this._isLHS(modelName, relationshipName)) {
|
8407
|
-
delete this.
|
8284
|
+
delete this._lhsPayloads[id];
|
8408
8285
|
} else {
|
8409
|
-
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this.
|
8286
|
+
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
|
8410
8287
|
|
8411
|
-
delete this.
|
8288
|
+
delete this._rhsPayloads[id];
|
8412
8289
|
}
|
8413
8290
|
};
|
8414
8291
|
|
8415
8292
|
RelationshipPayloads.prototype._isLHS = function _isLHS(modelName, relationshipName) {
|
8416
|
-
|
8417
|
-
var isSelfReferential = relInfo.isSelfReferential;
|
8418
|
-
var isRelationship = relationshipName === relInfo.lhs_relationshipName;
|
8419
|
-
|
8420
|
-
if (isRelationship === true) {
|
8421
|
-
return isSelfReferential === true || // itself
|
8422
|
-
modelName === relInfo.lhs_baseModelName || // base or non-polymorphic
|
8423
|
-
relInfo.lhs_modelNames.indexOf(modelName) !== -1; // polymorphic
|
8424
|
-
}
|
8425
|
-
|
8426
|
-
return false;
|
8293
|
+
return modelName === this._lhsModelName && relationshipName === this._lhsRelationshipName;
|
8427
8294
|
};
|
8428
8295
|
|
8429
8296
|
RelationshipPayloads.prototype._isRHS = function _isRHS(modelName, relationshipName) {
|
8430
|
-
|
8431
|
-
var isSelfReferential = relInfo.isSelfReferential;
|
8432
|
-
var isRelationship = relationshipName === relInfo.rhs_relationshipName;
|
8433
|
-
|
8434
|
-
if (isRelationship === true) {
|
8435
|
-
return isSelfReferential === true || // itself
|
8436
|
-
modelName === relInfo.rhs_baseModelName || // base or non-polymorphic
|
8437
|
-
relInfo.rhs_modelNames.indexOf(modelName) !== -1; // polymorphic
|
8438
|
-
}
|
8439
|
-
|
8440
|
-
return false;
|
8297
|
+
return modelName === this._rhsModelName && relationshipName === this._rhsRelationshipName;
|
8441
8298
|
};
|
8442
8299
|
|
8443
8300
|
RelationshipPayloads.prototype._flushPending = function _flushPending() {
|
@@ -8458,28 +8315,26 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8458
8315
|
id: id,
|
8459
8316
|
type: modelName
|
8460
8317
|
}
|
8461
|
-
};
|
8462
8318
|
|
8463
|
-
|
8464
|
-
|
8465
|
-
|
8466
|
-
|
8467
|
-
var previousPayload = void 0;
|
8468
|
-
var
|
8469
|
-
var
|
8319
|
+
// start flushing this individual payload. The logic is the same whether
|
8320
|
+
// it's for the left hand side of the relationship or the right hand side,
|
8321
|
+
// except the role of primary and inverse idToPayloads is reversed
|
8322
|
+
//
|
8323
|
+
};var previousPayload = void 0;
|
8324
|
+
var idToPayloads = void 0;
|
8325
|
+
var inverseIdToPayloads = void 0;
|
8470
8326
|
var inverseIsMany = void 0;
|
8471
|
-
|
8472
8327
|
if (this._isLHS(modelName, relationshipName)) {
|
8473
|
-
previousPayload = this.
|
8474
|
-
|
8475
|
-
|
8328
|
+
previousPayload = this._lhsPayloads[id];
|
8329
|
+
idToPayloads = this._lhsPayloads;
|
8330
|
+
inverseIdToPayloads = this._rhsPayloads;
|
8476
8331
|
inverseIsMany = this._rhsRelationshipIsMany;
|
8477
8332
|
} else {
|
8478
|
-
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this.
|
8333
|
+
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
|
8479
8334
|
|
8480
|
-
previousPayload = this.
|
8481
|
-
|
8482
|
-
|
8335
|
+
previousPayload = this._rhsPayloads[id];
|
8336
|
+
idToPayloads = this._rhsPayloads;
|
8337
|
+
inverseIdToPayloads = this._lhsPayloads;
|
8483
8338
|
inverseIsMany = this._lhsRelationshipIsMany;
|
8484
8339
|
}
|
8485
8340
|
|
@@ -8523,14 +8378,14 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8523
8378
|
// * undefined is NOT considered new information, we should keep original state
|
8524
8379
|
// * anything else is considered new information, and it should win
|
8525
8380
|
if (relationshipData.data !== undefined) {
|
8526
|
-
this._removeInverse(id, previousPayload,
|
8381
|
+
this._removeInverse(id, previousPayload, inverseIdToPayloads);
|
8527
8382
|
}
|
8528
|
-
|
8529
|
-
this._populateInverse(relationshipData, inverseRelationshipData,
|
8383
|
+
idToPayloads[id] = relationshipData;
|
8384
|
+
this._populateInverse(relationshipData, inverseRelationshipData, inverseIdToPayloads, inverseIsMany);
|
8530
8385
|
}
|
8531
8386
|
};
|
8532
8387
|
|
8533
|
-
RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload,
|
8388
|
+
RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inverseIdToPayloads, inverseIsMany) {
|
8534
8389
|
if (!relationshipData.data) {
|
8535
8390
|
// This id doesn't have an inverse, eg a belongsTo with a payload
|
8536
8391
|
// { data: null }, so there's nothing to populate
|
@@ -8539,24 +8394,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8539
8394
|
|
8540
8395
|
if (Array.isArray(relationshipData.data)) {
|
8541
8396
|
for (var i = 0; i < relationshipData.data.length; ++i) {
|
8542
|
-
var
|
8543
|
-
this._addToInverse(inversePayload,
|
8397
|
+
var inverseId = relationshipData.data[i].id;
|
8398
|
+
this._addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany);
|
8544
8399
|
}
|
8545
8400
|
} else {
|
8546
|
-
var
|
8547
|
-
this._addToInverse(inversePayload,
|
8401
|
+
var _inverseId = relationshipData.data.id;
|
8402
|
+
this._addToInverse(inversePayload, _inverseId, inverseIdToPayloads, inverseIsMany);
|
8548
8403
|
}
|
8549
8404
|
};
|
8550
8405
|
|
8551
|
-
RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload,
|
8552
|
-
|
8553
|
-
|
8554
|
-
if (relInfo.isReflexive && inversePayload.data.id === resourceIdentifier.id) {
|
8406
|
+
RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany) {
|
8407
|
+
if (this._isReflexive && inversePayload.data.id === inverseId) {
|
8555
8408
|
// eg <user:1>.friends = [{ id: 1, type: 'user' }]
|
8556
8409
|
return;
|
8557
8410
|
}
|
8558
8411
|
|
8559
|
-
var existingPayload =
|
8412
|
+
var existingPayload = inverseIdToPayloads[inverseId];
|
8560
8413
|
var existingData = existingPayload && existingPayload.data;
|
8561
8414
|
|
8562
8415
|
if (existingData) {
|
@@ -8566,22 +8419,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8566
8419
|
if (Array.isArray(existingData)) {
|
8567
8420
|
existingData.push(inversePayload.data);
|
8568
8421
|
} else {
|
8569
|
-
|
8422
|
+
inverseIdToPayloads[inverseId] = inversePayload;
|
8570
8423
|
}
|
8571
8424
|
} else {
|
8572
8425
|
// first time we're populating the inverse side
|
8573
8426
|
//
|
8574
8427
|
if (inverseIsMany) {
|
8575
|
-
|
8428
|
+
inverseIdToPayloads[inverseId] = {
|
8576
8429
|
data: [inversePayload.data]
|
8577
|
-
}
|
8430
|
+
};
|
8578
8431
|
} else {
|
8579
|
-
|
8432
|
+
inverseIdToPayloads[inverseId] = inversePayload;
|
8580
8433
|
}
|
8581
8434
|
}
|
8582
8435
|
};
|
8583
8436
|
|
8584
|
-
RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload,
|
8437
|
+
RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inverseIdToPayloads) {
|
8585
8438
|
var data = previousPayload && previousPayload.data;
|
8586
8439
|
if (!data) {
|
8587
8440
|
// either this is the first time we've seen a payload for this id, or its
|
@@ -8596,16 +8449,15 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8596
8449
|
if (Array.isArray(data)) {
|
8597
8450
|
// TODO: diff rather than removeall addall?
|
8598
8451
|
for (var i = 0; i < data.length; ++i) {
|
8599
|
-
|
8600
|
-
this._removeFromInverse(id, resourceIdentifier, inversePayloadMap);
|
8452
|
+
this._removeFromInverse(id, data[i].id, inverseIdToPayloads);
|
8601
8453
|
}
|
8602
8454
|
} else {
|
8603
|
-
this._removeFromInverse(id, data,
|
8455
|
+
this._removeFromInverse(id, data.id, inverseIdToPayloads);
|
8604
8456
|
}
|
8605
8457
|
};
|
8606
8458
|
|
8607
|
-
RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id,
|
8608
|
-
var inversePayload = inversePayloads
|
8459
|
+
RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, inverseId, inversePayloads) {
|
8460
|
+
var inversePayload = inversePayloads[inverseId];
|
8609
8461
|
var data = inversePayload && inversePayload.data;
|
8610
8462
|
|
8611
8463
|
if (!data) {
|
@@ -8617,23 +8469,21 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8617
8469
|
return x.id !== id;
|
8618
8470
|
});
|
8619
8471
|
} else {
|
8620
|
-
inversePayloads
|
8472
|
+
inversePayloads[inverseId] = {
|
8621
8473
|
data: null
|
8622
|
-
}
|
8474
|
+
};
|
8623
8475
|
}
|
8624
8476
|
};
|
8625
8477
|
|
8626
8478
|
_createClass(RelationshipPayloads, [{
|
8627
8479
|
key: '_lhsRelationshipIsMany',
|
8628
8480
|
get: function () {
|
8629
|
-
|
8630
|
-
return meta !== null && meta.kind === 'hasMany';
|
8481
|
+
return this._lhsRelationshipMeta && this._lhsRelationshipMeta.kind === 'hasMany';
|
8631
8482
|
}
|
8632
8483
|
}, {
|
8633
8484
|
key: '_rhsRelationshipIsMany',
|
8634
8485
|
get: function () {
|
8635
|
-
|
8636
|
-
return meta !== null && meta.kind === 'hasMany';
|
8486
|
+
return this._rhsRelationshipMeta && this._rhsRelationshipMeta.kind === 'hasMany';
|
8637
8487
|
}
|
8638
8488
|
}]);
|
8639
8489
|
|
@@ -16481,11 +16331,14 @@ define('ember-data/serializers/json-api', ['exports', 'ember', 'ember-inflector'
|
|
16481
16331
|
}
|
16482
16332
|
|
16483
16333
|
if (Array.isArray(documentHash.included)) {
|
16484
|
-
var _ret = new Array(
|
16485
|
-
|
16334
|
+
var _ret = new Array();
|
16486
16335
|
for (var _i = 0; _i < documentHash.included.length; _i++) {
|
16487
16336
|
var included = documentHash.included[_i];
|
16488
|
-
|
16337
|
+
var normalized = this._normalizeResourceHelper(included);
|
16338
|
+
if (normalized !== null) {
|
16339
|
+
// can be null when unknown type is encountered
|
16340
|
+
_ret.push(normalized);
|
16341
|
+
}
|
16489
16342
|
}
|
16490
16343
|
|
16491
16344
|
documentHash.included = _ret;
|
@@ -18414,7 +18267,7 @@ define("ember-data/version", ["exports"], function (exports) {
|
|
18414
18267
|
"use strict";
|
18415
18268
|
|
18416
18269
|
exports.__esModule = true;
|
18417
|
-
exports.default = "2.
|
18270
|
+
exports.default = "2.17.0-beta.1";
|
18418
18271
|
});
|
18419
18272
|
define("ember-inflector", ["module", "exports", "ember", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (module, exports, _ember, _system) {
|
18420
18273
|
"use strict";
|