ember-data-source 3.0.2 → 3.1.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 +136 -285
- data/dist/globals/ember-data.min.js +6 -6
- data/dist/globals/ember-data.prod.js +135 -282
- data/package.json +14 -12
- 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: 442c4caf0795074faa3d43e249d038608d8e8ea8
|
4
|
+
data.tar.gz: 7d1278741187c5cb9b30825a8725704a3d5cb2d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d0820aaa6d2bedc1a98d2543ed176bb6122252efb9acc454158e13c522a69a769476fb964e1e35bc4d9be9fbda86ef73885c9348d3f01da996f640dd7310e60
|
7
|
+
data.tar.gz: 447a16f2a0c9aa740f9c1814470751a432d0b738228b9fed637f97f3b7f52823ad59b1f9a90ec7ff18aba5b624089e80f3e4ed97a9d40a0e2f3553db75f10fb9
|
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 3.0.
|
9
|
+
* @version 3.1.0-beta.1
|
10
10
|
*/
|
11
11
|
|
12
12
|
var loader, define, requireModule, require, requirejs;
|
@@ -1799,7 +1799,7 @@ define('ember-data/-private/system/identity-map', ['exports', 'ember-data/-priva
|
|
1799
1799
|
similar to `getWithDefault` or `get` on a `MapWithDefault`
|
1800
1800
|
@method retrieve
|
1801
1801
|
@param modelName a previously normalized modelName
|
1802
|
-
@
|
1802
|
+
@return {InternalModelMap} the InternalModelMap for the given modelName
|
1803
1803
|
*/
|
1804
1804
|
|
1805
1805
|
|
@@ -1868,9 +1868,9 @@ define('ember-data/-private/system/internal-model-map', ['exports', 'ember-data/
|
|
1868
1868
|
}
|
1869
1869
|
|
1870
1870
|
/**
|
1871
|
-
*
|
1872
|
-
* @param id
|
1873
|
-
* @
|
1871
|
+
* @method get
|
1872
|
+
* @param id {String}
|
1873
|
+
* @return {InternalModel}
|
1874
1874
|
*/
|
1875
1875
|
|
1876
1876
|
|
@@ -4754,10 +4754,6 @@ define('ember-data/-private/system/model/model', ['exports', 'ember-data/-privat
|
|
4754
4754
|
// the computed property.
|
4755
4755
|
var meta = value.meta();
|
4756
4756
|
|
4757
|
-
/*
|
4758
|
-
This is buggy because if the parent has never been looked up
|
4759
|
-
via `modelFor` it will not have `modelName` set.
|
4760
|
-
*/
|
4761
4757
|
meta.parentType = proto.constructor;
|
4762
4758
|
}
|
4763
4759
|
}
|
@@ -7457,7 +7453,7 @@ define('ember-data/-private/system/references/record', ['exports', 'ember-data/-
|
|
7457
7453
|
```
|
7458
7454
|
|
7459
7455
|
@method push
|
7460
|
-
@param {Promise|Object}
|
7456
|
+
@param objectOrPromise {Promise|Object}
|
7461
7457
|
@return Promise<record> a promise for the value (record or relationship)
|
7462
7458
|
*/
|
7463
7459
|
RecordReference.prototype.push = function (objectOrPromise) {
|
@@ -7570,7 +7566,7 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
|
|
7570
7566
|
}
|
7571
7567
|
|
7572
7568
|
function relationshipFromMeta(meta) {
|
7573
|
-
|
7569
|
+
var result = {
|
7574
7570
|
key: meta.key,
|
7575
7571
|
kind: meta.kind,
|
7576
7572
|
type: typeForRelationshipMeta(meta),
|
@@ -7579,6 +7575,12 @@ define('ember-data/-private/system/relationship-meta', ['exports', 'ember-inflec
|
|
7579
7575
|
parentType: meta.parentType,
|
7580
7576
|
isRelationship: true
|
7581
7577
|
};
|
7578
|
+
|
7579
|
+
if (false) {
|
7580
|
+
result.parentType = meta.parentType;
|
7581
|
+
}
|
7582
|
+
|
7583
|
+
return result;
|
7582
7584
|
}
|
7583
7585
|
});
|
7584
7586
|
define('ember-data/-private/system/relationships/belongs-to', ['exports', 'ember-data/-private/system/normalize-model-name'], function (exports, _normalizeModelName) {
|
@@ -7980,7 +7982,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
7980
7982
|
}
|
7981
7983
|
}
|
7982
7984
|
|
7983
|
-
var
|
7985
|
+
var _get = Ember.get;
|
7984
7986
|
|
7985
7987
|
var RelationshipPayloadsManager = function () {
|
7986
7988
|
function RelationshipPayloadsManager(store) {
|
@@ -7989,7 +7991,6 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
7989
7991
|
this._store = store;
|
7990
7992
|
// cache of `RelationshipPayload`s
|
7991
7993
|
this._cache = Object.create(null);
|
7992
|
-
this._inverseLookupCache = new _relationshipPayloads.TypeCache();
|
7993
7994
|
}
|
7994
7995
|
|
7995
7996
|
/**
|
@@ -8010,7 +8011,9 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8010
8011
|
|
8011
8012
|
|
8012
8013
|
RelationshipPayloadsManager.prototype.get = function get(modelName, id, relationshipName) {
|
8013
|
-
var
|
8014
|
+
var modelClass = this._store._modelFor(modelName);
|
8015
|
+
var relationshipsByName = _get(modelClass, 'relationshipsByName');
|
8016
|
+
var relationshipPayloads = this._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
|
8014
8017
|
return relationshipPayloads && relationshipPayloads.get(modelName, id, relationshipName);
|
8015
8018
|
};
|
8016
8019
|
|
@@ -8021,8 +8024,10 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8021
8024
|
return;
|
8022
8025
|
}
|
8023
8026
|
|
8027
|
+
var modelClass = this._store._modelFor(modelName);
|
8028
|
+
var relationshipsByName = _get(modelClass, 'relationshipsByName');
|
8024
8029
|
Object.keys(relationshipsData).forEach(function (key) {
|
8025
|
-
var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, true);
|
8030
|
+
var relationshipPayloads = _this._getRelationshipPayloads(modelName, key, modelClass, relationshipsByName, true);
|
8026
8031
|
if (relationshipPayloads) {
|
8027
8032
|
relationshipPayloads.push(modelName, id, key, relationshipsData[key]);
|
8028
8033
|
}
|
@@ -8033,153 +8038,51 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8033
8038
|
var _this2 = this;
|
8034
8039
|
|
8035
8040
|
var modelClass = this._store._modelFor(modelName);
|
8036
|
-
var relationshipsByName =
|
8041
|
+
var relationshipsByName = _get(modelClass, 'relationshipsByName');
|
8037
8042
|
relationshipsByName.forEach(function (_, relationshipName) {
|
8038
|
-
var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, false);
|
8043
|
+
var relationshipPayloads = _this2._getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, false);
|
8039
8044
|
if (relationshipPayloads) {
|
8040
8045
|
relationshipPayloads.unload(modelName, id, relationshipName);
|
8041
8046
|
}
|
8042
8047
|
});
|
8043
8048
|
};
|
8044
8049
|
|
8045
|
-
RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, init) {
|
8046
|
-
|
8047
|
-
|
8048
|
-
if (relInfo === null) {
|
8050
|
+
RelationshipPayloadsManager.prototype._getRelationshipPayloads = function _getRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName, init) {
|
8051
|
+
if (!relationshipsByName.has(relationshipName)) {
|
8049
8052
|
return;
|
8050
8053
|
}
|
8051
8054
|
|
8052
|
-
var
|
8053
|
-
|
8054
|
-
|
8055
|
-
return this._initializeRelationshipPayloads(relInfo);
|
8055
|
+
var key = modelName + ':' + relationshipName;
|
8056
|
+
if (!this._cache[key] && init) {
|
8057
|
+
return this._initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName);
|
8056
8058
|
}
|
8057
8059
|
|
8058
|
-
return
|
8060
|
+
return this._cache[key];
|
8059
8061
|
};
|
8060
8062
|
|
8061
|
-
RelationshipPayloadsManager.prototype.
|
8062
|
-
var inverseCache = this._inverseLookupCache;
|
8063
|
-
var store = this._store;
|
8064
|
-
var cached = inverseCache.get(modelName, relationshipName);
|
8065
|
-
|
8066
|
-
// CASE: We have a cached resolution (null if no relationship exists)
|
8067
|
-
if (cached !== undefined) {
|
8068
|
-
return cached;
|
8069
|
-
}
|
8070
|
-
|
8071
|
-
var modelClass = store._modelFor(modelName);
|
8072
|
-
var relationshipsByName = get(modelClass, 'relationshipsByName');
|
8073
|
-
|
8074
|
-
// CASE: We don't have a relationship at all
|
8075
|
-
if (!relationshipsByName.has(relationshipName)) {
|
8076
|
-
inverseCache.set(modelName, relationshipName, null);
|
8077
|
-
return null;
|
8078
|
-
}
|
8079
|
-
|
8080
|
-
var inverseMeta = modelClass.inverseFor(relationshipName, store);
|
8063
|
+
RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(modelName, relationshipName, modelClass, relationshipsByName) {
|
8081
8064
|
var relationshipMeta = relationshipsByName.get(relationshipName);
|
8082
|
-
var
|
8083
|
-
|
8084
|
-
|
8085
|
-
|
8086
|
-
|
8087
|
-
|
8088
|
-
|
8089
|
-
|
8090
|
-
|
8091
|
-
|
8092
|
-
|
8093
|
-
|
8094
|
-
|
8095
|
-
|
8096
|
-
|
8097
|
-
|
8098
|
-
|
8099
|
-
rhs_isPolymorphic: false,
|
8100
|
-
hasInverse: false,
|
8101
|
-
isSelfReferential: false, // modelName === inverseBaseModelName,
|
8102
|
-
isReflexive: false
|
8103
|
-
};
|
8104
|
-
|
8105
|
-
inverseCache.set(modelName, relationshipName, _info);
|
8106
|
-
|
8107
|
-
return _info;
|
8108
|
-
}
|
8109
|
-
|
8110
|
-
// CASE: We do have an inverse
|
8111
|
-
|
8112
|
-
var inverseRelationshipName = inverseMeta.name;
|
8113
|
-
var inverseRelationshipMeta = get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
|
8114
|
-
var baseModelName = inverseRelationshipMeta.type;
|
8115
|
-
var isSelfReferential = baseModelName === inverseBaseModelName;
|
8116
|
-
|
8117
|
-
// TODO we want to assert this but this breaks all of our shoddily written tests
|
8118
|
-
/*
|
8119
|
-
if (DEBUG) {
|
8120
|
-
let inverseDoubleCheck = inverseMeta.type.inverseFor(inverseRelationshipName, store);
|
8121
|
-
assert(`The ${inverseBaseModelName}:${inverseRelationshipName} relationship declares 'inverse: null', but it was resolved as the inverse for ${baseModelName}:${relationshipName}.`, inverseDoubleCheck);
|
8065
|
+
var inverseMeta = modelClass.inverseFor(relationshipName, this._store);
|
8066
|
+
|
8067
|
+
var inverseModelName = void 0;
|
8068
|
+
var inverseRelationshipName = void 0;
|
8069
|
+
var inverseRelationshipMeta = void 0;
|
8070
|
+
|
8071
|
+
// figure out the inverse relationship; we need two things
|
8072
|
+
// a) the inverse model name
|
8073
|
+
//- b) the name of the inverse relationship
|
8074
|
+
if (inverseMeta) {
|
8075
|
+
inverseRelationshipName = inverseMeta.name;
|
8076
|
+
inverseModelName = relationshipMeta.type;
|
8077
|
+
inverseRelationshipMeta = _get(inverseMeta.type, 'relationshipsByName').get(inverseRelationshipName);
|
8078
|
+
} else {
|
8079
|
+
// relationship has no inverse
|
8080
|
+
inverseModelName = inverseRelationshipName = '';
|
8081
|
+
inverseRelationshipMeta = null;
|
8122
8082
|
}
|
8123
|
-
*/
|
8124
|
-
|
8125
|
-
// CASE: We may have already discovered the inverse for the baseModelName
|
8126
|
-
// CASE: We have already discovered the inverse
|
8127
|
-
cached = inverseCache.get(baseModelName, relationshipName) || inverseCache.get(inverseBaseModelName, inverseRelationshipName);
|
8128
|
-
if (cached) {
|
8129
|
-
(false && Ember.assert('The ' + inverseBaseModelName + ':' + inverseRelationshipName + ' relationship declares \'inverse: null\', but it was resolved as the inverse for ' + baseModelName + ':' + relationshipName + '.', cached.hasInverse !== false));
|
8130
|
-
|
8131
|
-
|
8132
|
-
var isLHS = cached.lhs_baseModelName === baseModelName;
|
8133
|
-
var modelNames = isLHS ? cached.lhs_modelNames : cached.rhs_modelNames;
|
8134
|
-
// make this lookup easier in the future by caching the key
|
8135
|
-
modelNames.push(modelName);
|
8136
|
-
inverseCache.set(modelName, relationshipName, cached);
|
8137
|
-
|
8138
|
-
return cached;
|
8139
|
-
}
|
8140
|
-
|
8141
|
-
var info = {
|
8142
|
-
lhs_key: baseModelName + ':' + relationshipName,
|
8143
|
-
lhs_modelNames: [modelName],
|
8144
|
-
lhs_baseModelName: baseModelName,
|
8145
|
-
lhs_relationshipName: relationshipName,
|
8146
|
-
lhs_relationshipMeta: relationshipMeta,
|
8147
|
-
lhs_isPolymorphic: selfIsPolymorphic,
|
8148
|
-
rhs_key: inverseBaseModelName + ':' + inverseRelationshipName,
|
8149
|
-
rhs_modelNames: [],
|
8150
|
-
rhs_baseModelName: inverseBaseModelName,
|
8151
|
-
rhs_relationshipName: inverseRelationshipName,
|
8152
|
-
rhs_relationshipMeta: inverseRelationshipMeta,
|
8153
|
-
rhs_isPolymorphic: inverseRelationshipMeta.options !== undefined && inverseRelationshipMeta.options.polymorphic === true,
|
8154
|
-
hasInverse: true,
|
8155
|
-
isSelfReferential: isSelfReferential,
|
8156
|
-
isReflexive: isSelfReferential && relationshipName === inverseRelationshipName
|
8157
|
-
};
|
8158
|
-
|
8159
|
-
// Create entries for the baseModelName as well as modelName to speed up
|
8160
|
-
// inverse lookups
|
8161
|
-
inverseCache.set(baseModelName, relationshipName, info);
|
8162
|
-
inverseCache.set(modelName, relationshipName, info);
|
8163
|
-
|
8164
|
-
// Greedily populate the inverse
|
8165
|
-
inverseCache.set(inverseBaseModelName, inverseRelationshipName, info);
|
8166
|
-
|
8167
|
-
return info;
|
8168
|
-
};
|
8169
|
-
|
8170
|
-
RelationshipPayloadsManager.prototype._initializeRelationshipPayloads = function _initializeRelationshipPayloads(relInfo) {
|
8171
|
-
var lhsKey = relInfo.lhs_key;
|
8172
|
-
var rhsKey = relInfo.rhs_key;
|
8173
|
-
var existingPayloads = this._cache[lhsKey];
|
8174
8083
|
|
8175
|
-
|
8176
|
-
|
8177
|
-
|
8178
|
-
if (existingPayloads !== undefined) {
|
8179
|
-
this._cache[lhsKey] = existingPayloads;
|
8180
|
-
return existingPayloads;
|
8181
|
-
}
|
8182
|
-
}
|
8084
|
+
var lhsKey = modelName + ':' + relationshipName;
|
8085
|
+
var rhsKey = inverseModelName + ':' + inverseRelationshipName;
|
8183
8086
|
|
8184
8087
|
// populate the cache for both sides of the relationship, as they both use
|
8185
8088
|
// the same `RelationshipPayloads`.
|
@@ -8187,13 +8090,7 @@ define('ember-data/-private/system/relationships/relationship-payloads-manager',
|
|
8187
8090
|
// This works out better than creating a single common key, because to
|
8188
8091
|
// compute that key we would need to do work to look up the inverse
|
8189
8092
|
//
|
8190
|
-
|
8191
|
-
|
8192
|
-
if (relInfo.hasInverse === true) {
|
8193
|
-
this._cache[rhsKey] = cache;
|
8194
|
-
}
|
8195
|
-
|
8196
|
-
return cache;
|
8093
|
+
return this._cache[lhsKey] = this._cache[rhsKey] = new _relationshipPayloads.default(this._store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta);
|
8197
8094
|
};
|
8198
8095
|
|
8199
8096
|
return RelationshipPayloadsManager;
|
@@ -8206,6 +8103,12 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8206
8103
|
|
8207
8104
|
exports.__esModule = true;
|
8208
8105
|
|
8106
|
+
function _classCallCheck(instance, Constructor) {
|
8107
|
+
if (!(instance instanceof Constructor)) {
|
8108
|
+
throw new TypeError("Cannot call a class as a function");
|
8109
|
+
}
|
8110
|
+
}
|
8111
|
+
|
8209
8112
|
var _createClass = function () {
|
8210
8113
|
function defineProperties(target, props) {
|
8211
8114
|
for (var i = 0; i < props.length; i++) {
|
@@ -8224,61 +8127,37 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8224
8127
|
};
|
8225
8128
|
}();
|
8226
8129
|
|
8227
|
-
function _classCallCheck(instance, Constructor) {
|
8228
|
-
if (!(instance instanceof Constructor)) {
|
8229
|
-
throw new TypeError("Cannot call a class as a function");
|
8230
|
-
}
|
8231
|
-
}
|
8232
|
-
|
8233
|
-
var TypeCache = exports.TypeCache = function () {
|
8234
|
-
function TypeCache() {
|
8235
|
-
_classCallCheck(this, TypeCache);
|
8236
|
-
|
8237
|
-
this.types = Object.create(null);
|
8238
|
-
}
|
8239
|
-
|
8240
|
-
TypeCache.prototype.get = function get(modelName, id) {
|
8241
|
-
var types = this.types;
|
8242
|
-
|
8243
|
-
|
8244
|
-
if (types[modelName] !== undefined) {
|
8245
|
-
return types[modelName][id];
|
8246
|
-
}
|
8247
|
-
};
|
8248
|
-
|
8249
|
-
TypeCache.prototype.set = function set(modelName, id, payload) {
|
8250
|
-
var types = this.types;
|
8251
|
-
|
8252
|
-
var typeMap = types[modelName];
|
8253
|
-
|
8254
|
-
if (typeMap === undefined) {
|
8255
|
-
typeMap = types[modelName] = Object.create(null);
|
8256
|
-
}
|
8257
|
-
|
8258
|
-
typeMap[id] = payload;
|
8259
|
-
};
|
8260
|
-
|
8261
|
-
TypeCache.prototype.delete = function _delete(modelName, id) {
|
8262
|
-
var types = this.types;
|
8263
|
-
|
8264
|
-
|
8265
|
-
if (types[modelName] !== undefined) {
|
8266
|
-
delete types[modelName][id];
|
8267
|
-
}
|
8268
|
-
};
|
8269
|
-
|
8270
|
-
return TypeCache;
|
8271
|
-
}();
|
8272
|
-
|
8273
8130
|
var RelationshipPayloads = function () {
|
8274
|
-
function RelationshipPayloads(
|
8131
|
+
function RelationshipPayloads(store, modelName, relationshipName, relationshipMeta, inverseModelName, inverseRelationshipName, inverseRelationshipMeta) {
|
8275
8132
|
_classCallCheck(this, RelationshipPayloads);
|
8276
8133
|
|
8277
|
-
this.
|
8134
|
+
this._store = store;
|
8135
|
+
|
8136
|
+
this._lhsModelName = modelName;
|
8137
|
+
this._lhsRelationshipName = relationshipName;
|
8138
|
+
this._lhsRelationshipMeta = relationshipMeta;
|
8139
|
+
|
8140
|
+
this._rhsModelName = inverseModelName;
|
8141
|
+
this._rhsRelationshipName = inverseRelationshipName;
|
8142
|
+
this._rhsRelationshipMeta = inverseRelationshipMeta;
|
8278
8143
|
|
8279
8144
|
// a map of id -> payloads for the left hand side of the relationship.
|
8280
|
-
this.
|
8281
|
-
|
8145
|
+
this._lhsPayloads = Object.create(null);
|
8146
|
+
if (modelName !== inverseModelName || relationshipName !== inverseRelationshipName) {
|
8147
|
+
// The common case of a non-reflexive relationship, or a reflexive
|
8148
|
+
// relationship whose inverse is not itself
|
8149
|
+
this._rhsPayloads = Object.create(null);
|
8150
|
+
this._isReflexive = false;
|
8151
|
+
} else {
|
8152
|
+
// Edge case when we have a reflexive relationship to itself
|
8153
|
+
// eg user hasMany friends inverse friends
|
8154
|
+
//
|
8155
|
+
// In this case there aren't really two sides to the relationship, but
|
8156
|
+
// we set `_rhsPayloads = _lhsPayloads` to make things easier to reason
|
8157
|
+
// about
|
8158
|
+
this._rhsPayloads = this._lhsPayloads;
|
8159
|
+
this._isReflexive = true;
|
8160
|
+
}
|
8282
8161
|
|
8283
8162
|
// When we push relationship payloads, just stash them in a queue until
|
8284
8163
|
// somebody actually asks for one of them.
|
@@ -8289,22 +8168,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8289
8168
|
}
|
8290
8169
|
|
8291
8170
|
/**
|
8292
|
-
|
8293
|
-
|
8294
|
-
|
8295
|
-
|
8296
|
-
|
8171
|
+
Get the payload for the relationship of an individual record.
|
8172
|
+
This might return the raw payload as pushed into the store, or one computed
|
8173
|
+
from the payload of the inverse relationship.
|
8174
|
+
@method
|
8175
|
+
*/
|
8297
8176
|
|
8298
8177
|
|
8299
8178
|
RelationshipPayloads.prototype.get = function get(modelName, id, relationshipName) {
|
8300
8179
|
this._flushPending();
|
8301
8180
|
|
8302
8181
|
if (this._isLHS(modelName, relationshipName)) {
|
8303
|
-
return this.
|
8182
|
+
return this._lhsPayloads[id];
|
8304
8183
|
} else {
|
8305
|
-
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this.
|
8184
|
+
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
|
8306
8185
|
|
8307
|
-
return this.
|
8186
|
+
return this._rhsPayloads[id];
|
8308
8187
|
}
|
8309
8188
|
};
|
8310
8189
|
|
@@ -8316,40 +8195,20 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8316
8195
|
this._flushPending();
|
8317
8196
|
|
8318
8197
|
if (this._isLHS(modelName, relationshipName)) {
|
8319
|
-
delete this.
|
8198
|
+
delete this._lhsPayloads[id];
|
8320
8199
|
} else {
|
8321
|
-
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this.
|
8200
|
+
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
|
8322
8201
|
|
8323
|
-
delete this.
|
8202
|
+
delete this._rhsPayloads[id];
|
8324
8203
|
}
|
8325
8204
|
};
|
8326
8205
|
|
8327
8206
|
RelationshipPayloads.prototype._isLHS = function _isLHS(modelName, relationshipName) {
|
8328
|
-
|
8329
|
-
var isSelfReferential = relInfo.isSelfReferential;
|
8330
|
-
var isRelationship = relationshipName === relInfo.lhs_relationshipName;
|
8331
|
-
|
8332
|
-
if (isRelationship === true) {
|
8333
|
-
return isSelfReferential === true || // itself
|
8334
|
-
modelName === relInfo.lhs_baseModelName || // base or non-polymorphic
|
8335
|
-
relInfo.lhs_modelNames.indexOf(modelName) !== -1; // polymorphic
|
8336
|
-
}
|
8337
|
-
|
8338
|
-
return false;
|
8207
|
+
return modelName === this._lhsModelName && relationshipName === this._lhsRelationshipName;
|
8339
8208
|
};
|
8340
8209
|
|
8341
8210
|
RelationshipPayloads.prototype._isRHS = function _isRHS(modelName, relationshipName) {
|
8342
|
-
|
8343
|
-
var isSelfReferential = relInfo.isSelfReferential;
|
8344
|
-
var isRelationship = relationshipName === relInfo.rhs_relationshipName;
|
8345
|
-
|
8346
|
-
if (isRelationship === true) {
|
8347
|
-
return isSelfReferential === true || // itself
|
8348
|
-
modelName === relInfo.rhs_baseModelName || // base or non-polymorphic
|
8349
|
-
relInfo.rhs_modelNames.indexOf(modelName) !== -1; // polymorphic
|
8350
|
-
}
|
8351
|
-
|
8352
|
-
return false;
|
8211
|
+
return modelName === this._rhsModelName && relationshipName === this._rhsRelationshipName;
|
8353
8212
|
};
|
8354
8213
|
|
8355
8214
|
RelationshipPayloads.prototype._flushPending = function _flushPending() {
|
@@ -8370,28 +8229,26 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8370
8229
|
id: id,
|
8371
8230
|
type: modelName
|
8372
8231
|
}
|
8373
|
-
};
|
8374
8232
|
|
8375
|
-
|
8376
|
-
|
8377
|
-
|
8378
|
-
|
8379
|
-
var previousPayload = void 0;
|
8380
|
-
var
|
8381
|
-
var
|
8233
|
+
// start flushing this individual payload. The logic is the same whether
|
8234
|
+
// it's for the left hand side of the relationship or the right hand side,
|
8235
|
+
// except the role of primary and inverse idToPayloads is reversed
|
8236
|
+
//
|
8237
|
+
};var previousPayload = void 0;
|
8238
|
+
var idToPayloads = void 0;
|
8239
|
+
var inverseIdToPayloads = void 0;
|
8382
8240
|
var inverseIsMany = void 0;
|
8383
|
-
|
8384
8241
|
if (this._isLHS(modelName, relationshipName)) {
|
8385
|
-
previousPayload = this.
|
8386
|
-
|
8387
|
-
|
8242
|
+
previousPayload = this._lhsPayloads[id];
|
8243
|
+
idToPayloads = this._lhsPayloads;
|
8244
|
+
inverseIdToPayloads = this._rhsPayloads;
|
8388
8245
|
inverseIsMany = this._rhsRelationshipIsMany;
|
8389
8246
|
} else {
|
8390
|
-
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this.
|
8247
|
+
(false && Ember.assert(modelName + ':' + relationshipName + ' is not either side of this relationship, ' + this._lhsModelName + ':' + this._lhsRelationshipName + '<->' + this._rhsModelName + ':' + this._rhsRelationshipName, this._isRHS(modelName, relationshipName)));
|
8391
8248
|
|
8392
|
-
previousPayload = this.
|
8393
|
-
|
8394
|
-
|
8249
|
+
previousPayload = this._rhsPayloads[id];
|
8250
|
+
idToPayloads = this._rhsPayloads;
|
8251
|
+
inverseIdToPayloads = this._lhsPayloads;
|
8395
8252
|
inverseIsMany = this._lhsRelationshipIsMany;
|
8396
8253
|
}
|
8397
8254
|
|
@@ -8435,14 +8292,14 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8435
8292
|
// * undefined is NOT considered new information, we should keep original state
|
8436
8293
|
// * anything else is considered new information, and it should win
|
8437
8294
|
if (relationshipData.data !== undefined) {
|
8438
|
-
this._removeInverse(id, previousPayload,
|
8295
|
+
this._removeInverse(id, previousPayload, inverseIdToPayloads);
|
8439
8296
|
}
|
8440
|
-
|
8441
|
-
this._populateInverse(relationshipData, inverseRelationshipData,
|
8297
|
+
idToPayloads[id] = relationshipData;
|
8298
|
+
this._populateInverse(relationshipData, inverseRelationshipData, inverseIdToPayloads, inverseIsMany);
|
8442
8299
|
}
|
8443
8300
|
};
|
8444
8301
|
|
8445
|
-
RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload,
|
8302
|
+
RelationshipPayloads.prototype._populateInverse = function _populateInverse(relationshipData, inversePayload, inverseIdToPayloads, inverseIsMany) {
|
8446
8303
|
if (!relationshipData.data) {
|
8447
8304
|
// This id doesn't have an inverse, eg a belongsTo with a payload
|
8448
8305
|
// { data: null }, so there's nothing to populate
|
@@ -8451,24 +8308,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8451
8308
|
|
8452
8309
|
if (Array.isArray(relationshipData.data)) {
|
8453
8310
|
for (var i = 0; i < relationshipData.data.length; ++i) {
|
8454
|
-
var
|
8455
|
-
this._addToInverse(inversePayload,
|
8311
|
+
var inverseId = relationshipData.data[i].id;
|
8312
|
+
this._addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany);
|
8456
8313
|
}
|
8457
8314
|
} else {
|
8458
|
-
var
|
8459
|
-
this._addToInverse(inversePayload,
|
8315
|
+
var _inverseId = relationshipData.data.id;
|
8316
|
+
this._addToInverse(inversePayload, _inverseId, inverseIdToPayloads, inverseIsMany);
|
8460
8317
|
}
|
8461
8318
|
};
|
8462
8319
|
|
8463
|
-
RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload,
|
8464
|
-
|
8465
|
-
|
8466
|
-
if (relInfo.isReflexive && inversePayload.data.id === resourceIdentifier.id) {
|
8320
|
+
RelationshipPayloads.prototype._addToInverse = function _addToInverse(inversePayload, inverseId, inverseIdToPayloads, inverseIsMany) {
|
8321
|
+
if (this._isReflexive && inversePayload.data.id === inverseId) {
|
8467
8322
|
// eg <user:1>.friends = [{ id: 1, type: 'user' }]
|
8468
8323
|
return;
|
8469
8324
|
}
|
8470
8325
|
|
8471
|
-
var existingPayload =
|
8326
|
+
var existingPayload = inverseIdToPayloads[inverseId];
|
8472
8327
|
var existingData = existingPayload && existingPayload.data;
|
8473
8328
|
|
8474
8329
|
if (existingData) {
|
@@ -8478,22 +8333,22 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8478
8333
|
if (Array.isArray(existingData)) {
|
8479
8334
|
existingData.push(inversePayload.data);
|
8480
8335
|
} else {
|
8481
|
-
|
8336
|
+
inverseIdToPayloads[inverseId] = inversePayload;
|
8482
8337
|
}
|
8483
8338
|
} else {
|
8484
8339
|
// first time we're populating the inverse side
|
8485
8340
|
//
|
8486
8341
|
if (inverseIsMany) {
|
8487
|
-
|
8342
|
+
inverseIdToPayloads[inverseId] = {
|
8488
8343
|
data: [inversePayload.data]
|
8489
|
-
}
|
8344
|
+
};
|
8490
8345
|
} else {
|
8491
|
-
|
8346
|
+
inverseIdToPayloads[inverseId] = inversePayload;
|
8492
8347
|
}
|
8493
8348
|
}
|
8494
8349
|
};
|
8495
8350
|
|
8496
|
-
RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload,
|
8351
|
+
RelationshipPayloads.prototype._removeInverse = function _removeInverse(id, previousPayload, inverseIdToPayloads) {
|
8497
8352
|
var data = previousPayload && previousPayload.data;
|
8498
8353
|
if (!data) {
|
8499
8354
|
// either this is the first time we've seen a payload for this id, or its
|
@@ -8508,16 +8363,15 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8508
8363
|
if (Array.isArray(data)) {
|
8509
8364
|
// TODO: diff rather than removeall addall?
|
8510
8365
|
for (var i = 0; i < data.length; ++i) {
|
8511
|
-
|
8512
|
-
this._removeFromInverse(id, resourceIdentifier, inversePayloadMap);
|
8366
|
+
this._removeFromInverse(id, data[i].id, inverseIdToPayloads);
|
8513
8367
|
}
|
8514
8368
|
} else {
|
8515
|
-
this._removeFromInverse(id, data,
|
8369
|
+
this._removeFromInverse(id, data.id, inverseIdToPayloads);
|
8516
8370
|
}
|
8517
8371
|
};
|
8518
8372
|
|
8519
|
-
RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id,
|
8520
|
-
var inversePayload = inversePayloads
|
8373
|
+
RelationshipPayloads.prototype._removeFromInverse = function _removeFromInverse(id, inverseId, inversePayloads) {
|
8374
|
+
var inversePayload = inversePayloads[inverseId];
|
8521
8375
|
var data = inversePayload && inversePayload.data;
|
8522
8376
|
|
8523
8377
|
if (!data) {
|
@@ -8529,23 +8383,21 @@ define('ember-data/-private/system/relationships/relationship-payloads', ['expor
|
|
8529
8383
|
return x.id !== id;
|
8530
8384
|
});
|
8531
8385
|
} else {
|
8532
|
-
inversePayloads
|
8386
|
+
inversePayloads[inverseId] = {
|
8533
8387
|
data: null
|
8534
|
-
}
|
8388
|
+
};
|
8535
8389
|
}
|
8536
8390
|
};
|
8537
8391
|
|
8538
8392
|
_createClass(RelationshipPayloads, [{
|
8539
8393
|
key: '_lhsRelationshipIsMany',
|
8540
8394
|
get: function () {
|
8541
|
-
|
8542
|
-
return meta !== null && meta.kind === 'hasMany';
|
8395
|
+
return this._lhsRelationshipMeta && this._lhsRelationshipMeta.kind === 'hasMany';
|
8543
8396
|
}
|
8544
8397
|
}, {
|
8545
8398
|
key: '_rhsRelationshipIsMany',
|
8546
8399
|
get: function () {
|
8547
|
-
|
8548
|
-
return meta !== null && meta.kind === 'hasMany';
|
8400
|
+
return this._rhsRelationshipMeta && this._rhsRelationshipMeta.kind === 'hasMany';
|
8549
8401
|
}
|
8550
8402
|
}]);
|
8551
8403
|
|
@@ -10634,9 +10486,7 @@ define('ember-data/-private/system/store', ['exports', 'ember-data/-private/adap
|
|
10634
10486
|
(false && Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + modelName, typeof modelName === 'string'));
|
10635
10487
|
|
10636
10488
|
|
10637
|
-
|
10638
|
-
|
10639
|
-
return this.findRecord(normalizedModelName, id);
|
10489
|
+
return this.findRecord(modelName, id);
|
10640
10490
|
},
|
10641
10491
|
|
10642
10492
|
|
@@ -16718,8 +16568,9 @@ define('ember-data/serializers/json-api', ['exports', 'ember-inflector', 'ember-
|
|
16718
16568
|
|
16719
16569
|
if (this._canSerialize(key)) {
|
16720
16570
|
var belongsTo = snapshot.belongsTo(key);
|
16721
|
-
|
16571
|
+
var belongsToIsNotNew = belongsTo && belongsTo.record && !belongsTo.record.get('isNew');
|
16722
16572
|
|
16573
|
+
if (belongsTo === null || belongsToIsNotNew) {
|
16723
16574
|
json.relationships = json.relationships || {};
|
16724
16575
|
|
16725
16576
|
var payloadKey = this._getMappedKey(key, snapshot.type);
|
@@ -18261,7 +18112,7 @@ define("ember-data/version", ["exports"], function (exports) {
|
|
18261
18112
|
"use strict";
|
18262
18113
|
|
18263
18114
|
exports.__esModule = true;
|
18264
|
-
exports.default = "3.0.
|
18115
|
+
exports.default = "3.1.0-beta.1";
|
18265
18116
|
});
|
18266
18117
|
define("ember-inflector", ["module", "exports", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (module, exports, _system) {
|
18267
18118
|
"use strict";
|