ember-data-source 2.18.1 → 2.18.2
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 +276 -128
- data/dist/globals/ember-data.min.js +4 -4
- data/dist/globals/ember-data.prod.js +273 -127
- data/package.json +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e40c1c5b49407ec723edf964a6f29dd0acde967
|
4
|
+
data.tar.gz: '0994b6b252c0dc06894606223ca5f2c1a2f4bb95'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cce3ecea3cdcd775f6c646ae58d05aacc0790dfec52b72f02e31067b2b6707d0dccf4450180ef6efe5af079cdaa02cbb766f8dd6e29663e22dde6dd54460b46a
|
7
|
+
data.tar.gz: 644ecfb024ed6423bac3c2faa38ecfcb6f668982a13444a71537ef3bbbdf9adf29e73c44fb7b296272ac822e76f7f673e9bd79ccc9243b55308fc2ba5a0a1eb9
|
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.18.
|
9
|
+
* @version 2.18.2
|
10
10
|
*/
|
11
11
|
|
12
12
|
var loader, define, requireModule, require, requirejs;
|
@@ -4812,6 +4812,10 @@ define('ember-data/-private/system/model/model', ['exports', 'ember-data/-privat
|
|
4812
4812
|
// the computed property.
|
4813
4813
|
var meta = value.meta();
|
4814
4814
|
|
4815
|
+
/*
|
4816
|
+
This is buggy because if the parent has never been looked up
|
4817
|
+
via `modelFor` it will not have `modelName` set.
|
4818
|
+
*/
|
4815
4819
|
meta.parentType = proto.constructor;
|
4816
4820
|
}
|
4817
4821
|
}
|
@@ -7624,7 +7628,7 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
|
|
7624
7628
|
}
|
7625
7629
|
|
7626
7630
|
function relationshipFromMeta(meta) {
|
7627
|
-
|
7631
|
+
return {
|
7628
7632
|
key: meta.key,
|
7629
7633
|
kind: meta.kind,
|
7630
7634
|
type: typeForRelationshipMeta(meta),
|
@@ -7633,12 +7637,6 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
|
|
7633
7637
|
parentType: meta.parentType,
|
7634
7638
|
isRelationship: true
|
7635
7639
|
};
|
7636
|
-
|
7637
|
-
if (false) {
|
7638
|
-
result.parentType = meta.parentType;
|
7639
|
-
}
|
7640
|
-
|
7641
|
-
return result;
|
7642
7640
|
}
|
7643
7641
|
});
|
7644
7642
|
define('ember-data/-private/system/relationships/belongs-to', ['exports', 'ember-data/-private/system/normalize-model-name'], function (exports, _normalizeModelName) {
|
@@ -8048,7 +8046,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8048
8046
|
}
|
8049
8047
|
}
|
8050
8048
|
|
8051
|
-
var
|
8049
|
+
var get = Ember.get;
|
8052
8050
|
|
8053
8051
|
var RelationshipPayloadsManager = function () {
|
8054
8052
|
function RelationshipPayloadsManager(store) {
|
@@ -8057,6 +8055,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8057
8055
|
this._store = store;
|
8058
8056
|
// cache of `RelationshipPayload`s
|
8059
8057
|
this._cache = Object.create(null);
|
8058
|
+
this._inverseLookupCache = new _relationshipPayloads.TypeCache();
|
8060
8059
|
}
|
8061
8060
|
|
8062
8061
|
/**
|
@@ -8077,9 +8076,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8077
8076
|
|
8078
8077
|
|
8079
8078
|
RelationshipPayloadsManager.prototype.get = function get(modelName, id, relationshipName) {
|
8080
|
-
var
|
8081
|
-
var relationshipsByName = _get(modelClass, 'relationshipsByName');
|
8082
|
-
var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
|
8079
|
+
var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, false);
|
8083
8080
|
return relationshipPayloads && relationshipPayloads.get(modelName, id, relationshipName);
|
8084
8081
|
};
|
8085
8082
|
|
@@ -8090,10 +8087,8 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8090
8087
|
return;
|
8091
8088
|
}
|
8092
8089
|
|
8093
|
-
var modelClass = this._store._modelFor(modelName);
|
8094
|
-
var relationshipsByName = _get(modelClass, 'relationshipsByName');
|
8095
8090
|
Object.keys(relationshipsData).forEach(function (key) {
|
8096
|
-
var relationshipPayloads = _this._getRelationshipPayloads(modelName, key,
|
8091
|
+
var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, true);
|
8097
8092
|
if (relationshipPayloads) {
|
8098
8093
|
relationshipPayloads.push(modelName, id, key, relationshipsData[key]);
|
8099
8094
|
}
|
@@ -8104,51 +8099,153 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8104
8099
|
var _this2 = this;
|
8105
8100
|
|
8106
8101
|
var modelClass = this._store._modelFor(modelName);
|
8107
|
-
var relationshipsByName =
|
8102
|
+
var relationshipsByName = get(modelClass, 'relationshipsByName');
|
8108
8103
|
relationshipsByName.forEach(function (_, relationshipName) {
|
8109
|
-
var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName,
|
8104
|
+
var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, false);
|
8110
8105
|
if (relationshipPayloads) {
|
8111
8106
|
relationshipPayloads.unload(modelName, id, relationshipName);
|
8112
8107
|
}
|
8113
8108
|
});
|
8114
8109
|
};
|
8115
8110
|
|
8116
|
-
RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName,
|
8117
|
-
|
8111
|
+
RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, init) {
|
8112
|
+
var relInfo = this.getRelationshipInfo(modelName, relationshipName);
|
8113
|
+
|
8114
|
+
if (relInfo === null) {
|
8118
8115
|
return;
|
8119
8116
|
}
|
8120
8117
|
|
8121
|
-
var
|
8122
|
-
|
8123
|
-
|
8118
|
+
var cache = this._cache[relInfo.lhs_key];
|
8119
|
+
|
8120
|
+
if (!cache && init) {
|
8121
|
+
return this._initializeRelationshipPayloads(relInfo);
|
8124
8122
|
}
|
8125
8123
|
|
8126
|
-
return
|
8124
|
+
return cache;
|
8127
8125
|
};
|
8128
8126
|
|
8129
|
-
RelationshipPayloadsManager.prototype.
|
8127
|
+
RelationshipPayloadsManager.prototype.getRelationshipInfo = function getRelationshipInfo(modelName, relationshipName) {
|
8128
|
+
var inverseCache = this._inverseLookupCache;
|
8129
|
+
var store = this._store;
|
8130
|
+
var cached = inverseCache.get(modelName, relationshipName);
|
8131
|
+
|
8132
|
+
// CASE: We have a cached resolution (null if no relationship exists)
|
8133
|
+
if (cached !== undefined) {
|
8134
|
+
return cached;
|
8135
|
+
}
|
8136
|
+
|
8137
|
+
var modelClass = store._modelFor(modelName);
|
8138
|
+
var relationshipsByName = get(modelClass, 'relationshipsByName');
|
8139
|
+
|
8140
|
+
// CASE: We don't have a relationship at all
|
8141
|
+
if (!relationshipsByName.has(relationshipName)) {
|
8142
|
+
inverseCache.set(modelName, relationshipName, null);
|
8143
|
+
return null;
|
8144
|
+
}
|
8145
|
+
|
8146
|
+
var inverseMeta = modelClass.inverseFor(relationshipName, store);
|
8130
8147
|
var relationshipMeta = relationshipsByName.get(relationshipName);
|
8131
|
-
var
|
8132
|
-
|
8133
|
-
|
8134
|
-
|
8135
|
-
|
8136
|
-
|
8137
|
-
|
8138
|
-
|
8139
|
-
|
8140
|
-
|
8141
|
-
|
8142
|
-
|
8143
|
-
|
8144
|
-
|
8145
|
-
|
8146
|
-
|
8147
|
-
|
8148
|
+
var selfIsPolymorphic = relationshipMeta.options !== undefined && relationshipMeta.options.polymorphic === true;
|
8149
|
+
var inverseBaseModelName = relationshipMeta.type;
|
8150
|
+
|
8151
|
+
// CASE: We have no inverse
|
8152
|
+
if (!inverseMeta) {
|
8153
|
+
var _info = {
|
8154
|
+
lhs_key: modelName + ':' + relationshipName,
|
8155
|
+
lhs_modelNames: [modelName],
|
8156
|
+
lhs_baseModelName: modelName,
|
8157
|
+
lhs_relationshipName: relationshipName,
|
8158
|
+
lhs_relationshipMeta: relationshipMeta,
|
8159
|
+
lhs_isPolymorphic: selfIsPolymorphic,
|
8160
|
+
rhs_key: '',
|
8161
|
+
rhs_modelNames: [],
|
8162
|
+
rhs_baseModelName: inverseBaseModelName,
|
8163
|
+
rhs_relationshipName: '',
|
8164
|
+
rhs_relationshipMeta: null,
|
8165
|
+
rhs_isPolymorphic: false,
|
8166
|
+
hasInverse: false,
|
8167
|
+
isSelfReferential: false, // modelName === inverseBaseModelName,
|
8168
|
+
isReflexive: false
|
8169
|
+
};
|
8170
|
+
|
8171
|
+
inverseCache.set(modelName, relationshipName, _info);
|
8172
|
+
|
8173
|
+
return _info;
|
8148
8174
|
}
|
8149
8175
|
|
8150
|
-
|
8151
|
-
|
8176
|
+
// CASE: We do have an inverse
|
8177
|
+
|
8178
|
+
var inverseRelationshipName = inverseMeta.name;
|
8179
|
+
var inverseRelationshipMeta = get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
|
8180
|
+
var baseModelName = inverseRelationshipMeta.type;
|
8181
|
+
var isSelfReferential = baseModelName === inverseBaseModelName;
|
8182
|
+
|
8183
|
+
// TODO we want to assert this but this breaks all of our shoddily written tests
|
8184
|
+
/*
|
8185
|
+
if (DEBUG) {
|
8186
|
+
let inverseDoubleCheck = inverseMeta.type.inverseFor(inverseRelationshipName, store);
|
8187
|
+
assert(`The ${inverseBaseModelName}:${inverseRelationshipName} relationship declares 'inverse: null', but it was resolved as the inverse for ${baseModelName}:${relationshipName}.`, inverseDoubleCheck);
|
8188
|
+
}
|
8189
|
+
*/
|
8190
|
+
|
8191
|
+
// CASE: We may have already discovered the inverse for the baseModelName
|
8192
|
+
// CASE: We have already discovered the inverse
|
8193
|
+
cached = inverseCache.get(baseModelName, relationshipName) || inverseCache.get(inverseBaseModelName, inverseRelationshipName);
|
8194
|
+
if (cached) {
|
8195
|
+
(false && Ember.assert('The ' + inverseBaseModelName + ':' + inverseRelationshipName + ' relationship declares \'inverse: null\', but it was resolved as the inverse for ' + baseModelName + ':' + relationshipName + '.', cached.hasInverse !== false));
|
8196
|
+
|
8197
|
+
|
8198
|
+
var isLHS = cached.lhs_baseModelName === baseModelName;
|
8199
|
+
var modelNames = isLHS ? cached.lhs_modelNames : cached.rhs_modelNames;
|
8200
|
+
// make this lookup easier in the future by caching the key
|
8201
|
+
modelNames.push(modelName);
|
8202
|
+
inverseCache.set(modelName, relationshipName, cached);
|
8203
|
+
|
8204
|
+
return cached;
|
8205
|
+
}
|
8206
|
+
|
8207
|
+
var info = {
|
8208
|
+
lhs_key: baseModelName + ':' + relationshipName,
|
8209
|
+
lhs_modelNames: [modelName],
|
8210
|
+
lhs_baseModelName: baseModelName,
|
8211
|
+
lhs_relationshipName: relationshipName,
|
8212
|
+
lhs_relationshipMeta: relationshipMeta,
|
8213
|
+
lhs_isPolymorphic: selfIsPolymorphic,
|
8214
|
+
rhs_key: inverseBaseModelName + ':' + inverseRelationshipName,
|
8215
|
+
rhs_modelNames: [],
|
8216
|
+
rhs_baseModelName: inverseBaseModelName,
|
8217
|
+
rhs_relationshipName: inverseRelationshipName,
|
8218
|
+
rhs_relationshipMeta: inverseRelationshipMeta,
|
8219
|
+
rhs_isPolymorphic: inverseRelationshipMeta.options !== undefined && inverseRelationshipMeta.options.polymorphic === true,
|
8220
|
+
hasInverse: true,
|
8221
|
+
isSelfReferential: isSelfReferential,
|
8222
|
+
isReflexive: isSelfReferential && relationshipName === inverseRelationshipName
|
8223
|
+
};
|
8224
|
+
|
8225
|
+
// Create entries for the baseModelName as well as modelName to speed up
|
8226
|
+
// inverse lookups
|
8227
|
+
inverseCache.set(baseModelName, relationshipName, info);
|
8228
|
+
inverseCache.set(modelName, relationshipName, info);
|
8229
|
+
|
8230
|
+
// Greedily populate the inverse
|
8231
|
+
inverseCache.set(inverseBaseModelName, inverseRelationshipName, info);
|
8232
|
+
|
8233
|
+
return info;
|
8234
|
+
};
|
8235
|
+
|
8236
|
+
RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(relInfo) {
|
8237
|
+
var lhsKey = relInfo.lhs_key;
|
8238
|
+
var rhsKey = relInfo.rhs_key;
|
8239
|
+
var existingPayloads = this._cache[lhsKey];
|
8240
|
+
|
8241
|
+
if (relInfo.hasInverse === true && relInfo.rhs_isPolymorphic === true) {
|
8242
|
+
existingPayloads = this._cache[rhsKey];
|
8243
|
+
|
8244
|
+
if (existingPayloads !== undefined) {
|
8245
|
+
this._cache[lhsKey] = existingPayloads;
|
8246
|
+
return existingPayloads;
|
8247
|
+
}
|
8248
|
+
}
|
8152
8249
|
|
8153
8250
|
// populate the cache for both sides of the relationship, as they both use
|
8154
8251
|
// the same `RelationshipPayloads`.
|
@@ -8156,7 +8253,13 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8156
8253
|
// This works out better than creating a single common key, because to
|
8157
8254
|
// compute that key we would need to do work to look up the inverse
|
8158
8255
|
//
|
8159
|
-
|
8256
|
+
var cache = this._cache[lhsKey] = new _relationshipPayloads.default(relInfo);
|
8257
|
+
|
8258
|
+
if (relInfo.hasInverse === true) {
|
8259
|
+
this._cache[rhsKey] = cache;
|
8260
|
+
}
|
8261
|
+
|
8262
|
+
return cache;
|
8160
8263
|
};
|
8161
8264
|
|
8162
8265
|
return RelationshipPayloadsManager;
|
@@ -8169,12 +8272,6 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8169
8272
|
|
8170
8273
|
exports.__esModule = true;
|
8171
8274
|
|
8172
|
-
function _classCallCheck(instance, Constructor) {
|
8173
|
-
if (!(instance instanceof Constructor)) {
|
8174
|
-
throw new TypeError("Cannot call a class as a function");
|
8175
|
-
}
|
8176
|
-
}
|
8177
|
-
|
8178
8275
|
var _createClass = function () {
|
8179
8276
|
function defineProperties(target, props) {
|
8180
8277
|
for (var i = 0; i < props.length; i++) {
|
@@ -8193,37 +8290,61 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8193
8290
|
};
|
8194
8291
|
}();
|
8195
8292
|
|
8196
|
-
|
8197
|
-
|
8198
|
-
|
8293
|
+
function _classCallCheck(instance, Constructor) {
|
8294
|
+
if (!(instance instanceof Constructor)) {
|
8295
|
+
throw new TypeError("Cannot call a class as a function");
|
8296
|
+
}
|
8297
|
+
}
|
8199
8298
|
|
8200
|
-
|
8299
|
+
var TypeCache = exports.TypeCache = function () {
|
8300
|
+
function TypeCache() {
|
8301
|
+
_classCallCheck(this, TypeCache);
|
8201
8302
|
|
8202
|
-
this.
|
8203
|
-
|
8204
|
-
this._lhsRelationshipMeta = relationshipMeta;
|
8303
|
+
this.types = Object.create(null);
|
8304
|
+
}
|
8205
8305
|
|
8206
|
-
|
8207
|
-
|
8208
|
-
this._rhsRelationshipMeta = inverseRelationshipMeta;
|
8306
|
+
TypeCache.prototype.get = function get(modelName, id) {
|
8307
|
+
var types = this.types;
|
8209
8308
|
|
8210
|
-
|
8211
|
-
|
8212
|
-
|
8213
|
-
// The common case of a non-reflexive relationship, or a reflexive
|
8214
|
-
// relationship whose inverse is not itself
|
8215
|
-
this._rhsPayloads = Object.create(null);
|
8216
|
-
this._isReflexive = false;
|
8217
|
-
} else {
|
8218
|
-
// Edge case when we have a reflexive relationship to itself
|
8219
|
-
// eg user hasMany friends inverse friends
|
8220
|
-
//
|
8221
|
-
// In this case there aren't really two sides to the relationship, but
|
8222
|
-
// we set `_rhsPayloads = _lhsPayloads` to make things easier to reason
|
8223
|
-
// about
|
8224
|
-
this._rhsPayloads = this._lhsPayloads;
|
8225
|
-
this._isReflexive = true;
|
8309
|
+
|
8310
|
+
if (types[modelName] !== undefined) {
|
8311
|
+
return types[modelName][id];
|
8226
8312
|
}
|
8313
|
+
};
|
8314
|
+
|
8315
|
+
TypeCache.prototype.set = function set(modelName, id, payload) {
|
8316
|
+
var types = this.types;
|
8317
|
+
|
8318
|
+
var typeMap = types[modelName];
|
8319
|
+
|
8320
|
+
if (typeMap === undefined) {
|
8321
|
+
typeMap = types[modelName] = Object.create(null);
|
8322
|
+
}
|
8323
|
+
|
8324
|
+
typeMap[id] = payload;
|
8325
|
+
};
|
8326
|
+
|
8327
|
+
TypeCache.prototype.delete = function _delete(modelName, id) {
|
8328
|
+
var types = this.types;
|
8329
|
+
|
8330
|
+
|
8331
|
+
if (types[modelName] !== undefined) {
|
8332
|
+
delete types[modelName][id];
|
8333
|
+
}
|
8334
|
+
};
|
8335
|
+
|
8336
|
+
return TypeCache;
|
8337
|
+
}();
|
8338
|
+
|
8339
|
+
var RelationshipPayloads = function () {
|
8340
|
+
function RelationshipPayloads(relInfo) {
|
8341
|
+
_classCallCheck(this, RelationshipPayloads);
|
8342
|
+
|
8343
|
+
this._relInfo = relInfo;
|
8344
|
+
|
8345
|
+
// a map of id -> payloads for the left hand side of the relationship.
|
8346
|
+
this.lhs_payloads = new TypeCache();
|
8347
|
+
this.rhs_payloads = relInfo.isReflexive ? this.lhs_payloads : new TypeCache();
|
8227
8348
|
|
8228
8349
|
// When we push relationship payloads, just stash them in a queue until
|
8229
8350
|
// somebody actually asks for one of them.
|
@@ -8234,22 +8355,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8234
8355
|
}
|
8235
8356
|
|
8236
8357
|
/**
|
8237
|
-
|
8238
|
-
|
8239
|
-
|
8240
|
-
|
8241
|
-
|
8358
|
+
Get the payload for the relationship of an individual record.
|
8359
|
+
This might return the raw payload as pushed into the store, or one computed
|
8360
|
+
from the payload of the inverse relationship.
|
8361
|
+
@method
|
8362
|
+
*/
|
8242
8363
|
|
8243
8364
|
|
8244
8365
|
RelationshipPayloads.prototype.get = function get(modelName, id, relationshipName) {
|
8245
8366
|
this._flushPending();
|
8246
8367
|
|
8247
8368
|
if (this._isLHS(modelName, relationshipName)) {
|
8248
|
-
return this.
|
8369
|
+
return this.lhs_payloads.get(modelName, id);
|
8249
8370
|
} else {
|
8250
|
-
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this.
|
8371
|
+
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName)));
|
8251
8372
|
|
8252
|
-
return this.
|
8373
|
+
return this.rhs_payloads.get(modelName, id);
|
8253
8374
|
}
|
8254
8375
|
};
|
8255
8376
|
|
@@ -8261,20 +8382,40 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8261
8382
|
this._flushPending();
|
8262
8383
|
|
8263
8384
|
if (this._isLHS(modelName, relationshipName)) {
|
8264
|
-
delete this.
|
8385
|
+
delete this.lhs_payloads.delete(modelName, id);
|
8265
8386
|
} else {
|
8266
|
-
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this.
|
8387
|
+
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_baseModelName + ':' + this._relInfo.lhs_relationshipName + '<->' + this._relInfo.rhs_baseModelName + ':' + this._relInfo.rhs_relationshipName, this._isRHS(modelName, relationshipName)));
|
8267
8388
|
|
8268
|
-
delete this.
|
8389
|
+
delete this.rhs_payloads.delete(modelName, id);
|
8269
8390
|
}
|
8270
8391
|
};
|
8271
8392
|
|
8272
8393
|
RelationshipPayloads.prototype._isLHS = function _isLHS(modelName, relationshipName) {
|
8273
|
-
|
8394
|
+
var relInfo = this._relInfo;
|
8395
|
+
var isSelfReferential = relInfo.isSelfReferential;
|
8396
|
+
var isRelationship = relationshipName === relInfo.lhs_relationshipName;
|
8397
|
+
|
8398
|
+
if (isRelationship === true) {
|
8399
|
+
return isSelfReferential === true || // itself
|
8400
|
+
modelName === relInfo.lhs_baseModelName || // base or non-polymorphic
|
8401
|
+
relInfo.lhs_modelNames.indexOf(modelName) !== -1; // polymorphic
|
8402
|
+
}
|
8403
|
+
|
8404
|
+
return false;
|
8274
8405
|
};
|
8275
8406
|
|
8276
8407
|
RelationshipPayloads.prototype._isRHS = function _isRHS(modelName, relationshipName) {
|
8277
|
-
|
8408
|
+
var relInfo = this._relInfo;
|
8409
|
+
var isSelfReferential = relInfo.isSelfReferential;
|
8410
|
+
var isRelationship = relationshipName === relInfo.rhs_relationshipName;
|
8411
|
+
|
8412
|
+
if (isRelationship === true) {
|
8413
|
+
return isSelfReferential === true || // itself
|
8414
|
+
modelName === relInfo.rhs_baseModelName || // base or non-polymorphic
|
8415
|
+
relInfo.rhs_modelNames.indexOf(modelName) !== -1; // polymorphic
|
8416
|
+
}
|
8417
|
+
|
8418
|
+
return false;
|
8278
8419
|
};
|
8279
8420
|
|
8280
8421
|
RelationshipPayloads.prototype._flushPending = function _flushPending() {
|
@@ -8295,26 +8436,28 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8295
8436
|
id: id,
|
8296
8437
|
type: modelName
|
8297
8438
|
}
|
8439
|
+
};
|
8298
8440
|
|
8299
|
-
|
8300
|
-
|
8301
|
-
|
8302
|
-
|
8303
|
-
|
8304
|
-
var
|
8305
|
-
var
|
8441
|
+
// start flushing this individual payload. The logic is the same whether
|
8442
|
+
// it's for the left hand side of the relationship or the right hand side,
|
8443
|
+
// except the role of primary and inverse idToPayloads is reversed
|
8444
|
+
//
|
8445
|
+
var previousPayload = void 0;
|
8446
|
+
var payloadMap = void 0;
|
8447
|
+
var inversePayloadMap = void 0;
|
8306
8448
|
var inverseIsMany = void 0;
|
8449
|
+
|
8307
8450
|
if (this._isLHS(modelName, relationshipName)) {
|
8308
|
-
previousPayload = this.
|
8309
|
-
|
8310
|
-
|
8451
|
+
previousPayload = this.lhs_payloads.get(modelName, id);
|
8452
|
+
payloadMap = this.lhs_payloads;
|
8453
|
+
inversePayloadMap = this.rhs_payloads;
|
8311
8454
|
inverseIsMany = this._rhsRelationshipIsMany;
|
8312
8455
|
} else {
|
8313
|
-
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this.
|
8456
|
+
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._relInfo.lhs_key + '<->' + this._relInfo.rhs_key, this._isRHS(modelName, relationshipName)));
|
8314
8457
|
|
8315
|
-
previousPayload = this.
|
8316
|
-
|
8317
|
-
|
8458
|
+
previousPayload = this.rhs_payloads.get(modelName, id);
|
8459
|
+
payloadMap = this.rhs_payloads;
|
8460
|
+
inversePayloadMap = this.lhs_payloads;
|
8318
8461
|
inverseIsMany = this._lhsRelationshipIsMany;
|
8319
8462
|
}
|
8320
8463
|
|
@@ -8358,14 +8501,14 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8358
8501
|
// * undefined is NOT considered new information, we should keep original state
|
8359
8502
|
// * anything else is considered new information, and it should win
|
8360
8503
|
if (relationshipData.data !== undefined) {
|
8361
|
-
this._removeInverse(id, previousPayload,
|
8504
|
+
this._removeInverse(id, previousPayload, inversePayloadMap);
|
8362
8505
|
}
|
8363
|
-
|
8364
|
-
this._populateInverse(relationshipData, inverseRelationshipData,
|
8506
|
+
payloadMap.set(modelName, id, relationshipData);
|
8507
|
+
this._populateInverse(relationshipData, inverseRelationshipData, inversePayloadMap, inverseIsMany);
|
8365
8508
|
}
|
8366
8509
|
};
|
8367
8510
|
|
8368
|
-
RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload,
|
8511
|
+
RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inversePayloadMap, inverseIsMany) {
|
8369
8512
|
if (!relationshipData.data) {
|
8370
8513
|
// This id doesn't have an inverse, eg a belongsTo with a payload
|
8371
8514
|
// { data: null }, so there's nothing to populate
|
@@ -8374,22 +8517,24 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8374
8517
|
|
8375
8518
|
if (Array.isArray(relationshipData.data)) {
|
8376
8519
|
for (var i = 0; i < relationshipData.data.length; ++i) {
|
8377
|
-
var
|
8378
|
-
this._addToInverse(inversePayload,
|
8520
|
+
var resourceIdentifier = relationshipData.data[i];
|
8521
|
+
this._addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany);
|
8379
8522
|
}
|
8380
8523
|
} else {
|
8381
|
-
var
|
8382
|
-
this._addToInverse(inversePayload,
|
8524
|
+
var _resourceIdentifier = relationshipData.data;
|
8525
|
+
this._addToInverse(inversePayload, _resourceIdentifier, inversePayloadMap, inverseIsMany);
|
8383
8526
|
}
|
8384
8527
|
};
|
8385
8528
|
|
8386
|
-
RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload,
|
8387
|
-
|
8529
|
+
RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, resourceIdentifier, inversePayloadMap, inverseIsMany) {
|
8530
|
+
var relInfo = this._relInfo;
|
8531
|
+
|
8532
|
+
if (relInfo.isReflexive && inversePayload.data.id === resourceIdentifier.id) {
|
8388
8533
|
// eg <user:1>.friends = [{ id: 1, type: 'user' }]
|
8389
8534
|
return;
|
8390
8535
|
}
|
8391
8536
|
|
8392
|
-
var existingPayload =
|
8537
|
+
var existingPayload = inversePayloadMap.get(resourceIdentifier.type, resourceIdentifier.id);
|
8393
8538
|
var existingData = existingPayload && existingPayload.data;
|
8394
8539
|
|
8395
8540
|
if (existingData) {
|
@@ -8399,22 +8544,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8399
8544
|
if (Array.isArray(existingData)) {
|
8400
8545
|
existingData.push(inversePayload.data);
|
8401
8546
|
} else {
|
8402
|
-
|
8547
|
+
inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload);
|
8403
8548
|
}
|
8404
8549
|
} else {
|
8405
8550
|
// first time we're populating the inverse side
|
8406
8551
|
//
|
8407
8552
|
if (inverseIsMany) {
|
8408
|
-
|
8553
|
+
inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, {
|
8409
8554
|
data: [inversePayload.data]
|
8410
|
-
};
|
8555
|
+
});
|
8411
8556
|
} else {
|
8412
|
-
|
8557
|
+
inversePayloadMap.set(resourceIdentifier.type, resourceIdentifier.id, inversePayload);
|
8413
8558
|
}
|
8414
8559
|
}
|
8415
8560
|
};
|
8416
8561
|
|
8417
|
-
RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload,
|
8562
|
+
RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inversePayloadMap) {
|
8418
8563
|
var data = previousPayload && previousPayload.data;
|
8419
8564
|
if (!data) {
|
8420
8565
|
// either this is the first time we've seen a payload for this id, or its
|
@@ -8429,15 +8574,16 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8429
8574
|
if (Array.isArray(data)) {
|
8430
8575
|
// TODO: diff rather than removeall addall?
|
8431
8576
|
for (var i = 0; i < data.length; ++i) {
|
8432
|
-
|
8577
|
+
var resourceIdentifier = data[i];
|
8578
|
+
this._removeFromInverse(id, resourceIdentifier, inversePayloadMap);
|
8433
8579
|
}
|
8434
8580
|
} else {
|
8435
|
-
this._removeFromInverse(id, data
|
8581
|
+
this._removeFromInverse(id, data, inversePayloadMap);
|
8436
8582
|
}
|
8437
8583
|
};
|
8438
8584
|
|
8439
|
-
RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id,
|
8440
|
-
var inversePayload = inversePayloads
|
8585
|
+
RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, resourceIdentifier, inversePayloads) {
|
8586
|
+
var inversePayload = inversePayloads.get(resourceIdentifier.type, resourceIdentifier.id);
|
8441
8587
|
var data = inversePayload && inversePayload.data;
|
8442
8588
|
|
8443
8589
|
if (!data) {
|
@@ -8449,21 +8595,23 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8449
8595
|
return x.id !== id;
|
8450
8596
|
});
|
8451
8597
|
} else {
|
8452
|
-
inversePayloads
|
8598
|
+
inversePayloads.set(resourceIdentifier.type, resourceIdentifier.id, {
|
8453
8599
|
data: null
|
8454
|
-
};
|
8600
|
+
});
|
8455
8601
|
}
|
8456
8602
|
};
|
8457
8603
|
|
8458
8604
|
_createClass(RelationshipPayloads, [{
|
8459
8605
|
key: '_lhsRelationshipIsMany',
|
8460
8606
|
get: function () {
|
8461
|
-
|
8607
|
+
var meta = this._relInfo.lhs_relationshipMeta;
|
8608
|
+
return meta !== null && meta.kind === 'hasMany';
|
8462
8609
|
}
|
8463
8610
|
}, {
|
8464
8611
|
key: '_rhsRelationshipIsMany',
|
8465
8612
|
get: function () {
|
8466
|
-
|
8613
|
+
var meta = this._relInfo.rhs_relationshipMeta;
|
8614
|
+
return meta !== null && meta.kind === 'hasMany';
|
8467
8615
|
}
|
8468
8616
|
}]);
|
8469
8617
|
|
@@ -18402,7 +18550,7 @@ define("ember-data/version", ["exports"], function (exports) {
|
|
18402
18550
|
"use strict";
|
18403
18551
|
|
18404
18552
|
exports.__esModule = true;
|
18405
|
-
exports.default = "2.18.
|
18553
|
+
exports.default = "2.18.2";
|
18406
18554
|
});
|
18407
18555
|
define("ember-inflector", ["module", "exports", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (module, exports, _system) {
|
18408
18556
|
"use strict";
|