ember-data-source 1.13.8 → 1.13.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/dist/ember-data-tests.js +4678 -4794
- data/dist/ember-data.js +824 -830
- data/dist/ember-data.js.map +1 -1
- data/dist/ember-data.min.js +4 -4
- data/dist/ember-data.prod.js +600 -606
- data/package.json +1 -1
- metadata +2 -2
data/dist/ember-data.js
CHANGED
@@ -4,12 +4,13 @@
|
|
4
4
|
var ember$data$lib$system$object$polyfills$$keysFunc = Object.keys || Ember.keys;
|
5
5
|
var ember$data$lib$system$object$polyfills$$create = Object.create || Ember.create;
|
6
6
|
|
7
|
-
|
8
|
-
var ember$data$lib$adapters$errors$$forEach = Ember.ArrayPolyfills.forEach;
|
9
|
-
var ember$data$lib$adapters$errors$$SOURCE_POINTER_REGEXP = /^\/?data\/(attributes|relationships)\/(.*)/;/**
|
7
|
+
/**
|
10
8
|
@class AdapterError
|
11
9
|
@namespace DS
|
12
10
|
*/
|
11
|
+
var ember$data$lib$adapters$errors$$EmberError = Ember.Error;
|
12
|
+
var ember$data$lib$adapters$errors$$forEach = Ember.ArrayPolyfills.forEach;
|
13
|
+
var ember$data$lib$adapters$errors$$SOURCE_POINTER_REGEXP = /^\/?data\/(attributes|relationships)\/(.*)/;
|
13
14
|
function ember$data$lib$adapters$errors$$AdapterError(errors, message) {
|
14
15
|
message = message || "Adapter operation failed";
|
15
16
|
|
@@ -81,9 +82,10 @@
|
|
81
82
|
@class InvalidError
|
82
83
|
@namespace DS
|
83
84
|
*/
|
85
|
+
|
84
86
|
function ember$data$lib$adapters$errors$$InvalidError(errors) {
|
85
87
|
if (!Ember.isArray(errors)) {
|
86
|
-
Ember.deprecate(
|
88
|
+
Ember.deprecate('`InvalidError` expects json-api formatted errors.', false, { id: 'ds.errors.invalid-error-expects-json-api-format', until: '2.0.0' });
|
87
89
|
errors = ember$data$lib$adapters$errors$$errorsHashToArray(errors);
|
88
90
|
}
|
89
91
|
ember$data$lib$adapters$errors$$AdapterError.call(this, errors, "The adapter rejected the commit because it was invalid");
|
@@ -95,6 +97,7 @@
|
|
95
97
|
@class TimeoutError
|
96
98
|
@namespace DS
|
97
99
|
*/
|
100
|
+
|
98
101
|
function ember$data$lib$adapters$errors$$TimeoutError() {
|
99
102
|
ember$data$lib$adapters$errors$$AdapterError.call(this, null, "The adapter operation timed out");
|
100
103
|
}
|
@@ -105,6 +108,7 @@
|
|
105
108
|
@class AbortError
|
106
109
|
@namespace DS
|
107
110
|
*/
|
111
|
+
|
108
112
|
function ember$data$lib$adapters$errors$$AbortError() {
|
109
113
|
ember$data$lib$adapters$errors$$AdapterError.call(this, null, "The adapter operation was aborted");
|
110
114
|
}
|
@@ -114,6 +118,7 @@
|
|
114
118
|
/**
|
115
119
|
@private
|
116
120
|
*/
|
121
|
+
|
117
122
|
function ember$data$lib$adapters$errors$$errorsHashToArray(errors) {
|
118
123
|
var out = [];
|
119
124
|
|
@@ -122,7 +127,7 @@
|
|
122
127
|
var messages = Ember.makeArray(errors[key]);
|
123
128
|
for (var i = 0; i < messages.length; i++) {
|
124
129
|
out.push({
|
125
|
-
title:
|
130
|
+
title: 'Invalid Attribute',
|
126
131
|
detail: messages[i],
|
127
132
|
source: {
|
128
133
|
pointer: "/data/attributes/" + key
|
@@ -888,16 +893,21 @@
|
|
888
893
|
if (path) {
|
889
894
|
// Protocol relative url
|
890
895
|
//jscs:disable disallowEmptyBlocks
|
891
|
-
if (/^\/\//.test(path)) {
|
892
|
-
//
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
896
|
+
if (/^\/\//.test(path)) {
|
897
|
+
// Do nothing, the full host is already included. This branch
|
898
|
+
// avoids the absolute path logic and the relative path logic.
|
899
|
+
|
900
|
+
// Absolute path
|
901
|
+
} else if (path.charAt(0) === '/') {
|
902
|
+
//jscs:enable disallowEmptyBlocks
|
903
|
+
if (host) {
|
904
|
+
path = path.slice(1);
|
905
|
+
url.push(host);
|
906
|
+
}
|
907
|
+
// Relative path
|
908
|
+
} else if (!/^http(s)?:\/\//.test(path)) {
|
909
|
+
url.push(parentURL);
|
910
|
+
}
|
901
911
|
} else {
|
902
912
|
if (host) {
|
903
913
|
url.push(host);
|
@@ -959,27 +969,25 @@
|
|
959
969
|
|
960
970
|
var ember$data$lib$adapters$build$url$mixin$$default = ember$data$lib$adapters$build$url$mixin$$BuildURLMixin;
|
961
971
|
|
962
|
-
|
963
|
-
var ember$data$lib$adapters$rest$adapter$$set = Ember.set;
|
964
|
-
var ember$data$lib$adapters$rest$adapter$$forEach = Ember.ArrayPolyfills.forEach;/**
|
972
|
+
/**
|
965
973
|
The REST adapter allows your store to communicate with an HTTP server by
|
966
974
|
transmitting JSON via XHR. Most Ember.js apps that consume a JSON API
|
967
975
|
should use the REST adapter.
|
968
|
-
|
976
|
+
|
969
977
|
This adapter is designed around the idea that the JSON exchanged with
|
970
978
|
the server should be conventional.
|
971
|
-
|
979
|
+
|
972
980
|
## JSON Structure
|
973
|
-
|
981
|
+
|
974
982
|
The REST adapter expects the JSON returned from your server to follow
|
975
983
|
these conventions.
|
976
|
-
|
984
|
+
|
977
985
|
### Object Root
|
978
|
-
|
986
|
+
|
979
987
|
The JSON payload should be an object that contains the record inside a
|
980
988
|
root property. For example, in response to a `GET` request for
|
981
989
|
`/posts/1`, the JSON should look like this:
|
982
|
-
|
990
|
+
|
983
991
|
```js
|
984
992
|
{
|
985
993
|
"post": {
|
@@ -989,10 +997,10 @@
|
|
989
997
|
}
|
990
998
|
}
|
991
999
|
```
|
992
|
-
|
1000
|
+
|
993
1001
|
Similarly, in response to a `GET` request for `/posts`, the JSON should
|
994
1002
|
look like this:
|
995
|
-
|
1003
|
+
|
996
1004
|
```js
|
997
1005
|
{
|
998
1006
|
"posts": [
|
@@ -1009,26 +1017,26 @@
|
|
1009
1017
|
]
|
1010
1018
|
}
|
1011
1019
|
```
|
1012
|
-
|
1020
|
+
|
1013
1021
|
### Conventional Names
|
1014
|
-
|
1022
|
+
|
1015
1023
|
Attribute names in your JSON payload should be the camelCased versions of
|
1016
1024
|
the attributes in your Ember.js models.
|
1017
|
-
|
1025
|
+
|
1018
1026
|
For example, if you have a `Person` model:
|
1019
|
-
|
1027
|
+
|
1020
1028
|
```app/models/person.js
|
1021
1029
|
import DS from 'ember-data';
|
1022
|
-
|
1030
|
+
|
1023
1031
|
export default DS.Model.extend({
|
1024
1032
|
firstName: DS.attr('string'),
|
1025
1033
|
lastName: DS.attr('string'),
|
1026
1034
|
occupation: DS.attr('string')
|
1027
1035
|
});
|
1028
1036
|
```
|
1029
|
-
|
1037
|
+
|
1030
1038
|
The JSON returned should look like this:
|
1031
|
-
|
1039
|
+
|
1032
1040
|
```js
|
1033
1041
|
{
|
1034
1042
|
"person": {
|
@@ -1039,45 +1047,45 @@
|
|
1039
1047
|
}
|
1040
1048
|
}
|
1041
1049
|
```
|
1042
|
-
|
1050
|
+
|
1043
1051
|
## Customization
|
1044
|
-
|
1052
|
+
|
1045
1053
|
### Endpoint path customization
|
1046
|
-
|
1054
|
+
|
1047
1055
|
Endpoint paths can be prefixed with a `namespace` by setting the namespace
|
1048
1056
|
property on the adapter:
|
1049
|
-
|
1057
|
+
|
1050
1058
|
```app/adapters/application.js
|
1051
1059
|
import DS from 'ember-data';
|
1052
|
-
|
1060
|
+
|
1053
1061
|
export default DS.RESTAdapter.extend({
|
1054
1062
|
namespace: 'api/1'
|
1055
1063
|
});
|
1056
1064
|
```
|
1057
1065
|
Requests for `App.Person` would now target `/api/1/people/1`.
|
1058
|
-
|
1066
|
+
|
1059
1067
|
### Host customization
|
1060
|
-
|
1068
|
+
|
1061
1069
|
An adapter can target other hosts by setting the `host` property.
|
1062
|
-
|
1070
|
+
|
1063
1071
|
```app/adapters/application.js
|
1064
1072
|
import DS from 'ember-data';
|
1065
|
-
|
1073
|
+
|
1066
1074
|
export default DS.RESTAdapter.extend({
|
1067
1075
|
host: 'https://api.example.com'
|
1068
1076
|
});
|
1069
1077
|
```
|
1070
|
-
|
1078
|
+
|
1071
1079
|
### Headers customization
|
1072
|
-
|
1080
|
+
|
1073
1081
|
Some APIs require HTTP headers, e.g. to provide an API key. Arbitrary
|
1074
1082
|
headers can be set as key/value pairs on the `RESTAdapter`'s `headers`
|
1075
1083
|
object and Ember Data will send them along with each ajax request.
|
1076
|
-
|
1077
|
-
|
1084
|
+
|
1085
|
+
|
1078
1086
|
```app/adapters/application.js
|
1079
1087
|
import DS from 'ember-data';
|
1080
|
-
|
1088
|
+
|
1081
1089
|
export default DS.RESTAdapter.extend({
|
1082
1090
|
headers: {
|
1083
1091
|
"API_KEY": "secret key",
|
@@ -1085,14 +1093,14 @@
|
|
1085
1093
|
}
|
1086
1094
|
});
|
1087
1095
|
```
|
1088
|
-
|
1096
|
+
|
1089
1097
|
`headers` can also be used as a computed property to support dynamic
|
1090
1098
|
headers. In the example below, the `session` object has been
|
1091
1099
|
injected into an adapter by Ember's container.
|
1092
|
-
|
1100
|
+
|
1093
1101
|
```app/adapters/application.js
|
1094
1102
|
import DS from 'ember-data';
|
1095
|
-
|
1103
|
+
|
1096
1104
|
export default DS.RESTAdapter.extend({
|
1097
1105
|
headers: function() {
|
1098
1106
|
return {
|
@@ -1102,17 +1110,17 @@
|
|
1102
1110
|
}.property("session.authToken")
|
1103
1111
|
});
|
1104
1112
|
```
|
1105
|
-
|
1113
|
+
|
1106
1114
|
In some cases, your dynamic headers may require data from some
|
1107
1115
|
object outside of Ember's observer system (for example
|
1108
1116
|
`document.cookie`). You can use the
|
1109
1117
|
[volatile](/api/classes/Ember.ComputedProperty.html#method_volatile)
|
1110
1118
|
function to set the property into a non-cached mode causing the headers to
|
1111
1119
|
be recomputed with every request.
|
1112
|
-
|
1120
|
+
|
1113
1121
|
```app/adapters/application.js
|
1114
1122
|
import DS from 'ember-data';
|
1115
|
-
|
1123
|
+
|
1116
1124
|
export default DS.RESTAdapter.extend({
|
1117
1125
|
headers: function() {
|
1118
1126
|
return {
|
@@ -1122,15 +1130,17 @@
|
|
1122
1130
|
}.property().volatile()
|
1123
1131
|
});
|
1124
1132
|
```
|
1125
|
-
|
1133
|
+
|
1126
1134
|
@class RESTAdapter
|
1127
1135
|
@constructor
|
1128
1136
|
@namespace DS
|
1129
1137
|
@extends DS.Adapter
|
1130
1138
|
@uses DS.BuildURLMixin
|
1131
1139
|
*/
|
1132
|
-
var ember$data$lib$adapters$rest$adapter$$
|
1133
|
-
|
1140
|
+
var ember$data$lib$adapters$rest$adapter$$get = Ember.get;
|
1141
|
+
var ember$data$lib$adapters$rest$adapter$$set = Ember.set;
|
1142
|
+
var ember$data$lib$adapters$rest$adapter$$forEach = Ember.ArrayPolyfills.forEach;var ember$data$lib$adapters$rest$adapter$$RestAdapter = ember$data$lib$system$adapter$$default.extend(ember$data$lib$adapters$build$url$mixin$$default, {
|
1143
|
+
defaultSerializer: '-rest',
|
1134
1144
|
|
1135
1145
|
/**
|
1136
1146
|
By default, the RESTAdapter will send the query params sorted alphabetically to the
|
@@ -1272,11 +1282,11 @@
|
|
1272
1282
|
@deprecated Use [findRecord](#method_findRecord) instead
|
1273
1283
|
*/
|
1274
1284
|
find: function (store, type, id, snapshot) {
|
1275
|
-
Ember.deprecate(
|
1276
|
-
id:
|
1277
|
-
until:
|
1285
|
+
Ember.deprecate('RestAdapter#find has been deprecated and renamed to `findRecord`.', false, {
|
1286
|
+
id: 'ds.adapter.find-renamed-to-find-record',
|
1287
|
+
until: '2.0.0'
|
1278
1288
|
});
|
1279
|
-
return this.ajax(this.buildURL(type.modelName, id, snapshot,
|
1289
|
+
return this.ajax(this.buildURL(type.modelName, id, snapshot, 'find'), 'GET');
|
1280
1290
|
},
|
1281
1291
|
|
1282
1292
|
/**
|
@@ -1295,13 +1305,13 @@
|
|
1295
1305
|
findRecord: function (store, type, id, snapshot) {
|
1296
1306
|
var find = ember$data$lib$adapters$rest$adapter$$RestAdapter.prototype.find;
|
1297
1307
|
if (find !== this.find) {
|
1298
|
-
Ember.deprecate(
|
1299
|
-
id:
|
1300
|
-
until:
|
1308
|
+
Ember.deprecate('RestAdapter#find has been deprecated and renamed to `findRecord`.', false, {
|
1309
|
+
id: 'ds.adapter.find-renamed-to-find-record',
|
1310
|
+
until: '2.0.0'
|
1301
1311
|
});
|
1302
1312
|
return this.find(store, type, id, snapshot);
|
1303
1313
|
}
|
1304
|
-
return this.ajax(this.buildURL(type.modelName, id, snapshot,
|
1314
|
+
return this.ajax(this.buildURL(type.modelName, id, snapshot, 'findRecord'), 'GET');
|
1305
1315
|
},
|
1306
1316
|
|
1307
1317
|
/**
|
@@ -1323,9 +1333,9 @@
|
|
1323
1333
|
query = { since: sinceToken };
|
1324
1334
|
}
|
1325
1335
|
|
1326
|
-
url = this.buildURL(type.modelName, null, null,
|
1336
|
+
url = this.buildURL(type.modelName, null, null, 'findAll');
|
1327
1337
|
|
1328
|
-
return this.ajax(url,
|
1338
|
+
return this.ajax(url, 'GET', { data: query });
|
1329
1339
|
},
|
1330
1340
|
|
1331
1341
|
/**
|
@@ -1344,17 +1354,17 @@
|
|
1344
1354
|
@deprecated Use [query](#method_query) instead
|
1345
1355
|
*/
|
1346
1356
|
findQuery: function (store, type, query) {
|
1347
|
-
Ember.deprecate(
|
1348
|
-
id:
|
1349
|
-
until:
|
1357
|
+
Ember.deprecate('RestAdapter#findQuery has been deprecated and renamed to `query`.', false, {
|
1358
|
+
id: 'ds.adapter.find-query-renamed-to-query',
|
1359
|
+
until: '2.0.0'
|
1350
1360
|
});
|
1351
|
-
var url = this.buildURL(type.modelName, null, null,
|
1361
|
+
var url = this.buildURL(type.modelName, null, null, 'findQuery', query);
|
1352
1362
|
|
1353
1363
|
if (this.sortQueryParams) {
|
1354
1364
|
query = this.sortQueryParams(query);
|
1355
1365
|
}
|
1356
1366
|
|
1357
|
-
return this.ajax(url,
|
1367
|
+
return this.ajax(url, 'GET', { data: query });
|
1358
1368
|
},
|
1359
1369
|
|
1360
1370
|
/**
|
@@ -1374,20 +1384,20 @@
|
|
1374
1384
|
query: function (store, type, query) {
|
1375
1385
|
var findQuery = ember$data$lib$adapters$rest$adapter$$RestAdapter.prototype.findQuery;
|
1376
1386
|
if (findQuery !== this.findQuery) {
|
1377
|
-
Ember.deprecate(
|
1378
|
-
id:
|
1379
|
-
until:
|
1387
|
+
Ember.deprecate('RestAdapter#findQuery has been deprecated and renamed to `query`.', false, {
|
1388
|
+
id: 'ds.adapter.find-query-renamed-to-query',
|
1389
|
+
until: '2.0.0'
|
1380
1390
|
});
|
1381
1391
|
return this.findQuery(store, type, query);
|
1382
1392
|
}
|
1383
1393
|
|
1384
|
-
var url = this.buildURL(type.modelName, null, null,
|
1394
|
+
var url = this.buildURL(type.modelName, null, null, 'query', query);
|
1385
1395
|
|
1386
1396
|
if (this.sortQueryParams) {
|
1387
1397
|
query = this.sortQueryParams(query);
|
1388
1398
|
}
|
1389
1399
|
|
1390
|
-
return this.ajax(url,
|
1400
|
+
return this.ajax(url, 'GET', { data: query });
|
1391
1401
|
},
|
1392
1402
|
|
1393
1403
|
/**
|
@@ -1406,13 +1416,13 @@
|
|
1406
1416
|
@return {Promise} promise
|
1407
1417
|
*/
|
1408
1418
|
queryRecord: function (store, type, query) {
|
1409
|
-
var url = this.buildURL(type.modelName, null, null,
|
1419
|
+
var url = this.buildURL(type.modelName, null, null, 'queryRecord', query);
|
1410
1420
|
|
1411
1421
|
if (this.sortQueryParams) {
|
1412
1422
|
query = this.sortQueryParams(query);
|
1413
1423
|
}
|
1414
1424
|
|
1415
|
-
return this.ajax(url,
|
1425
|
+
return this.ajax(url, 'GET', { data: query });
|
1416
1426
|
},
|
1417
1427
|
|
1418
1428
|
/**
|
@@ -1442,8 +1452,8 @@
|
|
1442
1452
|
@return {Promise} promise
|
1443
1453
|
*/
|
1444
1454
|
findMany: function (store, type, ids, snapshots) {
|
1445
|
-
var url = this.buildURL(type.modelName, ids, snapshots,
|
1446
|
-
return this.ajax(url,
|
1455
|
+
var url = this.buildURL(type.modelName, ids, snapshots, 'findMany');
|
1456
|
+
return this.ajax(url, 'GET', { data: { ids: ids } });
|
1447
1457
|
},
|
1448
1458
|
|
1449
1459
|
/**
|
@@ -1472,9 +1482,9 @@
|
|
1472
1482
|
var id = snapshot.id;
|
1473
1483
|
var type = snapshot.modelName;
|
1474
1484
|
|
1475
|
-
url = this.urlPrefix(url, this.buildURL(type, id, null,
|
1485
|
+
url = this.urlPrefix(url, this.buildURL(type, id, null, 'findHasMany'));
|
1476
1486
|
|
1477
|
-
return this.ajax(url,
|
1487
|
+
return this.ajax(url, 'GET');
|
1478
1488
|
},
|
1479
1489
|
|
1480
1490
|
/**
|
@@ -1503,8 +1513,8 @@
|
|
1503
1513
|
var id = snapshot.id;
|
1504
1514
|
var type = snapshot.modelName;
|
1505
1515
|
|
1506
|
-
url = this.urlPrefix(url, this.buildURL(type, id, null,
|
1507
|
-
return this.ajax(url,
|
1516
|
+
url = this.urlPrefix(url, this.buildURL(type, id, null, 'findBelongsTo'));
|
1517
|
+
return this.ajax(url, 'GET');
|
1508
1518
|
},
|
1509
1519
|
|
1510
1520
|
/**
|
@@ -1523,7 +1533,7 @@
|
|
1523
1533
|
createRecord: function (store, type, snapshot) {
|
1524
1534
|
var data = {};
|
1525
1535
|
var serializer = store.serializerFor(type.modelName);
|
1526
|
-
var url = this.buildURL(type.modelName, null, snapshot,
|
1536
|
+
var url = this.buildURL(type.modelName, null, snapshot, 'createRecord');
|
1527
1537
|
|
1528
1538
|
serializer.serializeIntoHash(data, type, snapshot, { includeId: true });
|
1529
1539
|
|
@@ -1550,7 +1560,7 @@
|
|
1550
1560
|
serializer.serializeIntoHash(data, type, snapshot);
|
1551
1561
|
|
1552
1562
|
var id = snapshot.id;
|
1553
|
-
var url = this.buildURL(type.modelName, id, snapshot,
|
1563
|
+
var url = this.buildURL(type.modelName, id, snapshot, 'updateRecord');
|
1554
1564
|
|
1555
1565
|
return this.ajax(url, "PUT", { data: data });
|
1556
1566
|
},
|
@@ -1567,24 +1577,24 @@
|
|
1567
1577
|
deleteRecord: function (store, type, snapshot) {
|
1568
1578
|
var id = snapshot.id;
|
1569
1579
|
|
1570
|
-
return this.ajax(this.buildURL(type.modelName, id, snapshot,
|
1580
|
+
return this.ajax(this.buildURL(type.modelName, id, snapshot, 'deleteRecord'), "DELETE");
|
1571
1581
|
},
|
1572
1582
|
|
1573
1583
|
_stripIDFromURL: function (store, snapshot) {
|
1574
1584
|
var url = this.buildURL(snapshot.modelName, snapshot.id, snapshot);
|
1575
1585
|
|
1576
|
-
var expandedURL = url.split(
|
1586
|
+
var expandedURL = url.split('/');
|
1577
1587
|
//Case when the url is of the format ...something/:id
|
1578
1588
|
var lastSegment = expandedURL[expandedURL.length - 1];
|
1579
1589
|
var id = snapshot.id;
|
1580
1590
|
if (lastSegment === id) {
|
1581
1591
|
expandedURL[expandedURL.length - 1] = "";
|
1582
|
-
} else if (ember$data$lib$adapters$rest$adapter$$endsWith(lastSegment,
|
1592
|
+
} else if (ember$data$lib$adapters$rest$adapter$$endsWith(lastSegment, '?id=' + id)) {
|
1583
1593
|
//Case when the url is of the format ...something?id=:id
|
1584
1594
|
expandedURL[expandedURL.length - 1] = lastSegment.substring(0, lastSegment.length - id.length - 1);
|
1585
1595
|
}
|
1586
1596
|
|
1587
|
-
return expandedURL.join(
|
1597
|
+
return expandedURL.join('/');
|
1588
1598
|
},
|
1589
1599
|
|
1590
1600
|
// http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
|
@@ -1643,7 +1653,7 @@
|
|
1643
1653
|
|
1644
1654
|
var groupsArray = [];
|
1645
1655
|
groups.forEach(function (group, key) {
|
1646
|
-
var paramNameLength =
|
1656
|
+
var paramNameLength = '&ids%5B%5D='.length;
|
1647
1657
|
var splitGroups = splitGroupToFitInUrl(group, maxURLLength, paramNameLength);
|
1648
1658
|
|
1649
1659
|
ember$data$lib$adapters$rest$adapter$$forEach.call(splitGroups, function (splitGroup) {
|
@@ -1764,8 +1774,8 @@
|
|
1764
1774
|
|
1765
1775
|
if (adapter.ajaxSuccess) {
|
1766
1776
|
Ember.deprecate("`ajaxSuccess` has been deprecated. Use `isSuccess`, `isInvalid` or `handleResponse` instead.", false, {
|
1767
|
-
id:
|
1768
|
-
until:
|
1777
|
+
id: 'ds.adapter.ajax-success-deprecated',
|
1778
|
+
until: '2.0.0'
|
1769
1779
|
});
|
1770
1780
|
response = adapter.ajaxSuccess(jqXHR, payload);
|
1771
1781
|
}
|
@@ -1786,8 +1796,8 @@
|
|
1786
1796
|
|
1787
1797
|
if (adapter.ajaxError) {
|
1788
1798
|
Ember.deprecate("`ajaxError` has been deprecated. Use `isSuccess`, `isInvalid` or `handleResponse` instead.", false, {
|
1789
|
-
id:
|
1790
|
-
until:
|
1799
|
+
id: 'ds.adapter.ajax-error-deprecated',
|
1800
|
+
until: '2.0.0'
|
1791
1801
|
});
|
1792
1802
|
error = adapter.ajaxError(jqXHR, textStatus, errorThrown);
|
1793
1803
|
}
|
@@ -1795,9 +1805,9 @@
|
|
1795
1805
|
if (!(error instanceof Error)) {
|
1796
1806
|
if (errorThrown instanceof Error) {
|
1797
1807
|
error = errorThrown;
|
1798
|
-
} else if (textStatus ===
|
1808
|
+
} else if (textStatus === 'timeout') {
|
1799
1809
|
error = new ember$data$lib$adapters$errors$$TimeoutError();
|
1800
|
-
} else if (textStatus ===
|
1810
|
+
} else if (textStatus === 'abort') {
|
1801
1811
|
error = new ember$data$lib$adapters$errors$$AbortError();
|
1802
1812
|
} else {
|
1803
1813
|
error = adapter.handleResponse(jqXHR.status, ember$data$lib$adapters$rest$adapter$$parseResponseHeaders(jqXHR.getAllResponseHeaders()), adapter.parseErrorResponse(jqXHR.responseText) || errorThrown);
|
@@ -1808,7 +1818,7 @@
|
|
1808
1818
|
};
|
1809
1819
|
|
1810
1820
|
Ember.$.ajax(hash);
|
1811
|
-
},
|
1821
|
+
}, 'DS: RESTAdapter#ajax ' + type + ' to ' + url);
|
1812
1822
|
},
|
1813
1823
|
|
1814
1824
|
/**
|
@@ -1823,15 +1833,15 @@
|
|
1823
1833
|
var hash = options || {};
|
1824
1834
|
hash.url = url;
|
1825
1835
|
hash.type = type;
|
1826
|
-
hash.dataType =
|
1836
|
+
hash.dataType = 'json';
|
1827
1837
|
hash.context = this;
|
1828
1838
|
|
1829
|
-
if (hash.data && type !==
|
1830
|
-
hash.contentType =
|
1839
|
+
if (hash.data && type !== 'GET') {
|
1840
|
+
hash.contentType = 'application/json; charset=utf-8';
|
1831
1841
|
hash.data = JSON.stringify(hash.data);
|
1832
1842
|
}
|
1833
1843
|
|
1834
|
-
var headers = ember$data$lib$adapters$rest$adapter$$get(this,
|
1844
|
+
var headers = ember$data$lib$adapters$rest$adapter$$get(this, 'headers');
|
1835
1845
|
if (headers !== undefined) {
|
1836
1846
|
hash.beforeSend = function (xhr) {
|
1837
1847
|
ember$data$lib$adapters$rest$adapter$$forEach.call(ember$data$lib$system$object$polyfills$$keysFunc(headers), function (key) {
|
@@ -1868,7 +1878,7 @@
|
|
1868
1878
|
@return {Object} errors payload
|
1869
1879
|
*/
|
1870
1880
|
normalizeErrorResponse: function (status, headers, payload) {
|
1871
|
-
if (payload && typeof payload ===
|
1881
|
+
if (payload && typeof payload === 'object' && payload.errors) {
|
1872
1882
|
return payload.errors;
|
1873
1883
|
} else {
|
1874
1884
|
return [{
|
@@ -1886,12 +1896,12 @@
|
|
1886
1896
|
return headers;
|
1887
1897
|
}
|
1888
1898
|
|
1889
|
-
var headerPairs = headerStr.split(
|
1899
|
+
var headerPairs = headerStr.split('\u000d\u000a');
|
1890
1900
|
for (var i = 0; i < headerPairs.length; i++) {
|
1891
1901
|
var headerPair = headerPairs[i];
|
1892
1902
|
// Can't use split() here because it does the wrong thing
|
1893
1903
|
// if the header value has the string ": " in it.
|
1894
|
-
var index = headerPair.indexOf(
|
1904
|
+
var index = headerPair.indexOf('\u003a\u0020');
|
1895
1905
|
if (index > 0) {
|
1896
1906
|
var key = headerPair.substring(0, index);
|
1897
1907
|
var val = headerPair.substring(index + 2);
|
@@ -1904,7 +1914,7 @@
|
|
1904
1914
|
|
1905
1915
|
//From http://stackoverflow.com/questions/280634/endswith-in-javascript
|
1906
1916
|
function ember$data$lib$adapters$rest$adapter$$endsWith(string, suffix) {
|
1907
|
-
if (typeof String.prototype.endsWith !==
|
1917
|
+
if (typeof String.prototype.endsWith !== 'function') {
|
1908
1918
|
return string.indexOf(suffix, string.length - suffix.length) !== -1;
|
1909
1919
|
} else {
|
1910
1920
|
return string.endsWith(suffix);
|
@@ -1912,22 +1922,22 @@
|
|
1912
1922
|
}
|
1913
1923
|
|
1914
1924
|
if (Ember.platform.hasPropertyAccessors) {
|
1915
|
-
Ember.defineProperty(ember$data$lib$adapters$rest$adapter$$RestAdapter.prototype,
|
1925
|
+
Ember.defineProperty(ember$data$lib$adapters$rest$adapter$$RestAdapter.prototype, 'maxUrlLength', {
|
1916
1926
|
enumerable: false,
|
1917
1927
|
get: function () {
|
1918
|
-
Ember.deprecate(
|
1919
|
-
id:
|
1920
|
-
until:
|
1928
|
+
Ember.deprecate('maxUrlLength has been deprecated (wrong casing). You should use maxURLLength instead.', false, {
|
1929
|
+
id: 'ds.adapter.max-url-length-deprecated-case',
|
1930
|
+
until: '2.0.0'
|
1921
1931
|
});
|
1922
1932
|
return this.maxURLLength;
|
1923
1933
|
},
|
1924
1934
|
|
1925
1935
|
set: function (value) {
|
1926
|
-
Ember.deprecate(
|
1927
|
-
id:
|
1928
|
-
until:
|
1936
|
+
Ember.deprecate('maxUrlLength has been deprecated (wrong casing). You should use maxURLLength instead.', false, {
|
1937
|
+
id: 'ds.adapter.max-url-length-deprecated-case',
|
1938
|
+
until: '2.0.0'
|
1929
1939
|
});
|
1930
|
-
ember$data$lib$adapters$rest$adapter$$set(this,
|
1940
|
+
ember$data$lib$adapters$rest$adapter$$set(this, 'maxURLLength', value);
|
1931
1941
|
}
|
1932
1942
|
});
|
1933
1943
|
}
|
@@ -2041,7 +2051,7 @@
|
|
2041
2051
|
}
|
2042
2052
|
|
2043
2053
|
if (!Object.create && !Object.create(null).hasOwnProperty) {
|
2044
|
-
throw new Error(
|
2054
|
+
throw new Error("This browser does not support Object.create(null), please polyfil with es5-sham: http://git.io/yBU2rg");
|
2045
2055
|
}
|
2046
2056
|
|
2047
2057
|
function ember$inflector$lib$lib$system$inflector$$makeDictionary() {
|
@@ -2177,12 +2187,12 @@
|
|
2177
2187
|
@param {Object} irregular
|
2178
2188
|
*/
|
2179
2189
|
inflect: function (word, typeRules, irregular) {
|
2180
|
-
var inflection, substitution, result, lowercase, wordSplit, firstPhrase, lastWord, isBlank, isCamelized,
|
2190
|
+
var inflection, substitution, result, lowercase, wordSplit, firstPhrase, lastWord, isBlank, isCamelized, rule;
|
2181
2191
|
|
2182
2192
|
isBlank = !word || ember$inflector$lib$lib$system$inflector$$BLANK_REGEX.test(word);
|
2183
2193
|
|
2184
2194
|
isCamelized = ember$inflector$lib$lib$system$inflector$$CAMELIZED_REGEX.test(word);
|
2185
|
-
firstPhrase =
|
2195
|
+
firstPhrase = "";
|
2186
2196
|
|
2187
2197
|
if (isBlank) {
|
2188
2198
|
return word;
|
@@ -2190,25 +2200,28 @@
|
|
2190
2200
|
|
2191
2201
|
lowercase = word.toLowerCase();
|
2192
2202
|
wordSplit = ember$inflector$lib$lib$system$inflector$$LAST_WORD_DASHED_REGEX.exec(word) || ember$inflector$lib$lib$system$inflector$$LAST_WORD_CAMELIZED_REGEX.exec(word);
|
2203
|
+
|
2193
2204
|
if (wordSplit) {
|
2194
2205
|
firstPhrase = wordSplit[1];
|
2195
2206
|
lastWord = wordSplit[2].toLowerCase();
|
2196
2207
|
}
|
2197
2208
|
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2209
|
+
for (rule in this.rules.uncountable) {
|
2210
|
+
if (lowercase.match(rule + "$")) {
|
2211
|
+
return word;
|
2212
|
+
}
|
2202
2213
|
}
|
2203
2214
|
|
2204
|
-
|
2215
|
+
for (rule in this.rules.irregular) {
|
2216
|
+
if (lowercase.match(rule + "$")) {
|
2217
|
+
substitution = irregular[rule];
|
2205
2218
|
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
return
|
2219
|
+
if (isCamelized && irregular[lastWord]) {
|
2220
|
+
substitution = ember$inflector$lib$lib$system$inflector$$capitalize(substitution);
|
2221
|
+
rule = ember$inflector$lib$lib$system$inflector$$capitalize(rule);
|
2222
|
+
}
|
2223
|
+
|
2224
|
+
return word.replace(rule, substitution);
|
2212
2225
|
}
|
2213
2226
|
}
|
2214
2227
|
|
@@ -2254,93 +2267,6 @@
|
|
2254
2267
|
|
2255
2268
|
ember$inflector$lib$lib$system$inflector$$default.inflector = new ember$inflector$lib$lib$system$inflector$$default(ember$inflector$lib$lib$system$inflections$$default);
|
2256
2269
|
|
2257
|
-
var ember$inflector$lib$lib$utils$register$helper$$default = ember$inflector$lib$lib$utils$register$helper$$registerHelper;
|
2258
|
-
|
2259
|
-
function ember$inflector$lib$lib$utils$register$helper$$registerHelperIteration1(name, helperFunction) {
|
2260
|
-
//earlier versions of ember with htmlbars used this
|
2261
|
-
ember$lib$main$$default.HTMLBars.helpers[name] = helperFunction;
|
2262
|
-
}
|
2263
|
-
|
2264
|
-
function ember$inflector$lib$lib$utils$register$helper$$registerHelperIteration2(name, helperFunction) {
|
2265
|
-
//registerHelper has been made private as _registerHelper
|
2266
|
-
//this is kept here if anyone is using it
|
2267
|
-
ember$lib$main$$default.HTMLBars.registerHelper(name, helperFunction);
|
2268
|
-
}
|
2269
|
-
|
2270
|
-
function ember$inflector$lib$lib$utils$register$helper$$registerHelperIteration3(name, helperFunction) {
|
2271
|
-
//latest versin of ember uses this
|
2272
|
-
ember$lib$main$$default.HTMLBars._registerHelper(name, helperFunction);
|
2273
|
-
}
|
2274
|
-
function ember$inflector$lib$lib$utils$register$helper$$registerHelper(name, helperFunction) {
|
2275
|
-
if (ember$lib$main$$default.HTMLBars) {
|
2276
|
-
var fn = ember$lib$main$$default.HTMLBars.makeBoundHelper(helperFunction);
|
2277
|
-
|
2278
|
-
if (ember$lib$main$$default.HTMLBars._registerHelper) {
|
2279
|
-
if (ember$lib$main$$default.HTMLBars.helpers) {
|
2280
|
-
ember$inflector$lib$lib$utils$register$helper$$registerHelperIteration1(name, fn);
|
2281
|
-
} else {
|
2282
|
-
ember$inflector$lib$lib$utils$register$helper$$registerHelperIteration3(name, fn);
|
2283
|
-
}
|
2284
|
-
} else if (ember$lib$main$$default.HTMLBars.registerHelper) {
|
2285
|
-
ember$inflector$lib$lib$utils$register$helper$$registerHelperIteration2(name, fn);
|
2286
|
-
}
|
2287
|
-
} else if (ember$lib$main$$default.Handlebars) {
|
2288
|
-
ember$lib$main$$default.Handlebars.helper(name, helperFunction);
|
2289
|
-
}
|
2290
|
-
}
|
2291
|
-
|
2292
|
-
/**
|
2293
|
-
*
|
2294
|
-
* If you have Ember Inflector (such as if Ember Data is present),
|
2295
|
-
* singularize a word. For example, turn "oxen" into "ox".
|
2296
|
-
*
|
2297
|
-
* Example:
|
2298
|
-
*
|
2299
|
-
* {{singularize myProperty}}
|
2300
|
-
* {{singularize "oxen"}}
|
2301
|
-
*
|
2302
|
-
* @for Ember.HTMLBars.helpers
|
2303
|
-
* @method singularize
|
2304
|
-
* @param {String|Property} word word to singularize
|
2305
|
-
*/
|
2306
|
-
ember$inflector$lib$lib$utils$register$helper$$default('singularize', function (params) {
|
2307
|
-
return ember$inflector$lib$lib$system$string$$singularize(params[0]);
|
2308
|
-
});
|
2309
|
-
|
2310
|
-
/**
|
2311
|
-
*
|
2312
|
-
* If you have Ember Inflector (such as if Ember Data is present),
|
2313
|
-
* pluralize a word. For example, turn "ox" into "oxen".
|
2314
|
-
*
|
2315
|
-
* Example:
|
2316
|
-
*
|
2317
|
-
* {{pluralize count myProperty}}
|
2318
|
-
* {{pluralize 1 "oxen"}}
|
2319
|
-
* {{pluralize myProperty}}
|
2320
|
-
* {{pluralize "ox"}}
|
2321
|
-
*
|
2322
|
-
* @for Ember.HTMLBars.helpers
|
2323
|
-
* @method pluralize
|
2324
|
-
* @param {Number|Property} [count] count of objects
|
2325
|
-
* @param {String|Property} word word to pluralize
|
2326
|
-
*/
|
2327
|
-
ember$inflector$lib$lib$utils$register$helper$$default('pluralize', function (params) {
|
2328
|
-
var count, word;
|
2329
|
-
|
2330
|
-
if (params.length === 1) {
|
2331
|
-
word = params[0];
|
2332
|
-
return ember$inflector$lib$lib$system$string$$pluralize(word);
|
2333
|
-
} else {
|
2334
|
-
count = params[0];
|
2335
|
-
word = params[1];
|
2336
|
-
|
2337
|
-
if (count !== 1) {
|
2338
|
-
word = ember$inflector$lib$lib$system$string$$pluralize(word);
|
2339
|
-
}
|
2340
|
-
return count + ' ' + word;
|
2341
|
-
}
|
2342
|
-
});
|
2343
|
-
|
2344
2270
|
if (ember$lib$main$$default.EXTEND_PROTOTYPES === true || ember$lib$main$$default.EXTEND_PROTOTYPES.String) {
|
2345
2271
|
/**
|
2346
2272
|
See {{#crossLink "Ember.String/pluralize"}}{{/crossLink}}
|
@@ -2368,13 +2294,13 @@
|
|
2368
2294
|
ember$lib$main$$default.String.singularize = ember$inflector$lib$lib$system$string$$singularize;
|
2369
2295
|
var ember$inflector$lib$main$$default = ember$inflector$lib$lib$system$inflector$$default;
|
2370
2296
|
|
2371
|
-
if (typeof define !==
|
2372
|
-
define(
|
2373
|
-
__exports__[
|
2297
|
+
if (typeof define !== 'undefined' && define.amd) {
|
2298
|
+
define('ember-inflector', ['exports'], function (__exports__) {
|
2299
|
+
__exports__['default'] = ember$inflector$lib$lib$system$inflector$$default;
|
2374
2300
|
return ember$inflector$lib$lib$system$inflector$$default;
|
2375
2301
|
});
|
2376
|
-
} else if (typeof module !==
|
2377
|
-
module[
|
2302
|
+
} else if (typeof module !== 'undefined' && module['exports']) {
|
2303
|
+
module['exports'] = ember$inflector$lib$lib$system$inflector$$default;
|
2378
2304
|
}
|
2379
2305
|
|
2380
2306
|
var activemodel$adapter$lib$system$active$model$adapter$$_Ember$String = ember$lib$main$$default.String;
|
@@ -2706,7 +2632,7 @@
|
|
2706
2632
|
@type {String}
|
2707
2633
|
@default 'id'
|
2708
2634
|
*/
|
2709
|
-
primaryKey:
|
2635
|
+
primaryKey: 'id',
|
2710
2636
|
|
2711
2637
|
/**
|
2712
2638
|
The `attrs` object can be used to declare a simple mapping between
|
@@ -2757,7 +2683,7 @@
|
|
2757
2683
|
@property attrs
|
2758
2684
|
@type {Object}
|
2759
2685
|
*/
|
2760
|
-
mergedProperties: [
|
2686
|
+
mergedProperties: ['attrs'],
|
2761
2687
|
|
2762
2688
|
/**
|
2763
2689
|
Given a subclass of `DS.Model` and a JSON object this method will
|
@@ -2813,25 +2739,25 @@
|
|
2813
2739
|
*/
|
2814
2740
|
normalizeResponse: function (store, primaryModelClass, payload, id, requestType) {
|
2815
2741
|
switch (requestType) {
|
2816
|
-
case
|
2742
|
+
case 'findRecord':
|
2817
2743
|
return this.normalizeFindRecordResponse.apply(this, arguments);
|
2818
|
-
case
|
2744
|
+
case 'queryRecord':
|
2819
2745
|
return this.normalizeQueryRecordResponse.apply(this, arguments);
|
2820
|
-
case
|
2746
|
+
case 'findAll':
|
2821
2747
|
return this.normalizeFindAllResponse.apply(this, arguments);
|
2822
|
-
case
|
2748
|
+
case 'findBelongsTo':
|
2823
2749
|
return this.normalizeFindBelongsToResponse.apply(this, arguments);
|
2824
|
-
case
|
2750
|
+
case 'findHasMany':
|
2825
2751
|
return this.normalizeFindHasManyResponse.apply(this, arguments);
|
2826
|
-
case
|
2752
|
+
case 'findMany':
|
2827
2753
|
return this.normalizeFindManyResponse.apply(this, arguments);
|
2828
|
-
case
|
2754
|
+
case 'query':
|
2829
2755
|
return this.normalizeQueryResponse.apply(this, arguments);
|
2830
|
-
case
|
2756
|
+
case 'createRecord':
|
2831
2757
|
return this.normalizeCreateRecordResponse.apply(this, arguments);
|
2832
|
-
case
|
2758
|
+
case 'deleteRecord':
|
2833
2759
|
return this.normalizeDeleteRecordResponse.apply(this, arguments);
|
2834
|
-
case
|
2760
|
+
case 'updateRecord':
|
2835
2761
|
return this.normalizeUpdateRecordResponse.apply(this, arguments);
|
2836
2762
|
}
|
2837
2763
|
},
|
@@ -3026,7 +2952,7 @@
|
|
3026
2952
|
|
3027
2953
|
var meta = this.extractMeta(store, primaryModelClass, payload);
|
3028
2954
|
if (meta) {
|
3029
|
-
Ember.assert(
|
2955
|
+
Ember.assert('The `meta` returned from `extractMeta` has to be an object, not "' + Ember.typeOf(meta) + '".', Ember.typeOf(meta) === 'object');
|
3030
2956
|
documentHash.meta = meta;
|
3031
2957
|
}
|
3032
2958
|
|
@@ -3090,7 +3016,7 @@
|
|
3090
3016
|
@return {Object}
|
3091
3017
|
*/
|
3092
3018
|
normalize: function (typeClass, hash) {
|
3093
|
-
if (this.get(
|
3019
|
+
if (this.get('isNewSerializerAPI')) {
|
3094
3020
|
return ember$data$lib$serializers$json$serializer$$_newNormalize.apply(this, arguments);
|
3095
3021
|
}
|
3096
3022
|
|
@@ -3115,7 +3041,7 @@
|
|
3115
3041
|
@return {String}
|
3116
3042
|
*/
|
3117
3043
|
extractId: function (modelClass, resourceHash) {
|
3118
|
-
var primaryKey = ember$data$lib$serializers$json$serializer$$get(this,
|
3044
|
+
var primaryKey = ember$data$lib$serializers$json$serializer$$get(this, 'primaryKey');
|
3119
3045
|
var id = resourceHash[primaryKey];
|
3120
3046
|
return ember$data$lib$system$coerce$id$$default(id);
|
3121
3047
|
},
|
@@ -3133,7 +3059,7 @@
|
|
3133
3059
|
var attributes = {};
|
3134
3060
|
|
3135
3061
|
modelClass.eachAttribute(function (key) {
|
3136
|
-
attributeKey = this.keyForAttribute(key,
|
3062
|
+
attributeKey = this.keyForAttribute(key, 'deserialize');
|
3137
3063
|
if (resourceHash.hasOwnProperty(attributeKey)) {
|
3138
3064
|
attributes[key] = resourceHash[attributeKey];
|
3139
3065
|
}
|
@@ -3159,7 +3085,7 @@
|
|
3159
3085
|
is polymorphic. It could however also be embedded resources that the
|
3160
3086
|
EmbeddedRecordsMixin has be able to process.
|
3161
3087
|
*/
|
3162
|
-
if (Ember.typeOf(relationshipHash) ===
|
3088
|
+
if (Ember.typeOf(relationshipHash) === 'object') {
|
3163
3089
|
if (relationshipHash.id) {
|
3164
3090
|
relationshipHash.id = ember$data$lib$system$coerce$id$$default(relationshipHash.id);
|
3165
3091
|
}
|
@@ -3184,13 +3110,13 @@
|
|
3184
3110
|
|
3185
3111
|
modelClass.eachRelationship(function (key, relationshipMeta) {
|
3186
3112
|
var relationship = null;
|
3187
|
-
var relationshipKey = this.keyForRelationship(key, relationshipMeta.kind,
|
3113
|
+
var relationshipKey = this.keyForRelationship(key, relationshipMeta.kind, 'deserialize');
|
3188
3114
|
if (resourceHash.hasOwnProperty(relationshipKey)) {
|
3189
3115
|
var data = null;
|
3190
3116
|
var relationshipHash = resourceHash[relationshipKey];
|
3191
|
-
if (relationshipMeta.kind ===
|
3117
|
+
if (relationshipMeta.kind === 'belongsTo') {
|
3192
3118
|
data = this.extractRelationship(relationshipMeta.type, relationshipHash);
|
3193
|
-
} else if (relationshipMeta.kind ===
|
3119
|
+
} else if (relationshipMeta.kind === 'hasMany') {
|
3194
3120
|
data = Ember.A(relationshipHash).map(function (item) {
|
3195
3121
|
return this.extractRelationship(relationshipMeta.type, item);
|
3196
3122
|
}, this);
|
@@ -3254,7 +3180,7 @@
|
|
3254
3180
|
|
3255
3181
|
if (this.keyForAttribute) {
|
3256
3182
|
typeClass.eachAttribute(function (key) {
|
3257
|
-
payloadKey = this.keyForAttribute(key,
|
3183
|
+
payloadKey = this.keyForAttribute(key, 'deserialize');
|
3258
3184
|
if (key === payloadKey) {
|
3259
3185
|
return;
|
3260
3186
|
}
|
@@ -3277,7 +3203,7 @@
|
|
3277
3203
|
|
3278
3204
|
if (this.keyForRelationship) {
|
3279
3205
|
typeClass.eachRelationship(function (key, relationship) {
|
3280
|
-
payloadKey = this.keyForRelationship(key, relationship.kind,
|
3206
|
+
payloadKey = this.keyForRelationship(key, relationship.kind, 'deserialize');
|
3281
3207
|
if (key === payloadKey) {
|
3282
3208
|
return;
|
3283
3209
|
}
|
@@ -3296,7 +3222,7 @@
|
|
3296
3222
|
@private
|
3297
3223
|
*/
|
3298
3224
|
normalizeUsingDeclaredMapping: function (typeClass, hash) {
|
3299
|
-
var attrs = ember$data$lib$serializers$json$serializer$$get(this,
|
3225
|
+
var attrs = ember$data$lib$serializers$json$serializer$$get(this, 'attrs');
|
3300
3226
|
var payloadKey, key;
|
3301
3227
|
|
3302
3228
|
if (attrs) {
|
@@ -3319,9 +3245,9 @@
|
|
3319
3245
|
@private
|
3320
3246
|
*/
|
3321
3247
|
normalizeId: function (hash) {
|
3322
|
-
var primaryKey = ember$data$lib$serializers$json$serializer$$get(this,
|
3248
|
+
var primaryKey = ember$data$lib$serializers$json$serializer$$get(this, 'primaryKey');
|
3323
3249
|
|
3324
|
-
if (primaryKey ===
|
3250
|
+
if (primaryKey === 'id') {
|
3325
3251
|
return;
|
3326
3252
|
}
|
3327
3253
|
|
@@ -3349,7 +3275,7 @@
|
|
3349
3275
|
@return {String} key
|
3350
3276
|
*/
|
3351
3277
|
_getMappedKey: function (key) {
|
3352
|
-
var attrs = ember$data$lib$serializers$json$serializer$$get(this,
|
3278
|
+
var attrs = ember$data$lib$serializers$json$serializer$$get(this, 'attrs');
|
3353
3279
|
var mappedKey;
|
3354
3280
|
if (attrs && attrs[key]) {
|
3355
3281
|
mappedKey = attrs[key];
|
@@ -3358,7 +3284,7 @@
|
|
3358
3284
|
if (mappedKey.key) {
|
3359
3285
|
mappedKey = mappedKey.key;
|
3360
3286
|
}
|
3361
|
-
if (typeof mappedKey ===
|
3287
|
+
if (typeof mappedKey === 'string') {
|
3362
3288
|
key = mappedKey;
|
3363
3289
|
}
|
3364
3290
|
}
|
@@ -3375,7 +3301,7 @@
|
|
3375
3301
|
@return {boolean} true if the key can be serialized
|
3376
3302
|
*/
|
3377
3303
|
_canSerialize: function (key) {
|
3378
|
-
var attrs = ember$data$lib$serializers$json$serializer$$get(this,
|
3304
|
+
var attrs = ember$data$lib$serializers$json$serializer$$get(this, 'attrs');
|
3379
3305
|
|
3380
3306
|
return !attrs || !attrs[key] || attrs[key].serialize !== false;
|
3381
3307
|
},
|
@@ -3390,7 +3316,7 @@
|
|
3390
3316
|
@return {boolean} true if the key must be serialized
|
3391
3317
|
*/
|
3392
3318
|
_mustSerialize: function (key) {
|
3393
|
-
var attrs = ember$data$lib$serializers$json$serializer$$get(this,
|
3319
|
+
var attrs = ember$data$lib$serializers$json$serializer$$get(this, 'attrs');
|
3394
3320
|
|
3395
3321
|
return attrs && attrs[key] && attrs[key].serialize === true;
|
3396
3322
|
},
|
@@ -3409,7 +3335,7 @@
|
|
3409
3335
|
if (this._mustSerialize(key)) {
|
3410
3336
|
return true;
|
3411
3337
|
}
|
3412
|
-
return this._canSerialize(key) && (relationshipType ===
|
3338
|
+
return this._canSerialize(key) && (relationshipType === 'manyToNone' || relationshipType === 'manyToMany');
|
3413
3339
|
},
|
3414
3340
|
|
3415
3341
|
// SERIALIZE
|
@@ -3533,7 +3459,7 @@
|
|
3533
3459
|
var id = snapshot.id;
|
3534
3460
|
|
3535
3461
|
if (id) {
|
3536
|
-
json[ember$data$lib$serializers$json$serializer$$get(this,
|
3462
|
+
json[ember$data$lib$serializers$json$serializer$$get(this, 'primaryKey')] = id;
|
3537
3463
|
}
|
3538
3464
|
}
|
3539
3465
|
|
@@ -3542,9 +3468,9 @@
|
|
3542
3468
|
}, this);
|
3543
3469
|
|
3544
3470
|
snapshot.eachRelationship(function (key, relationship) {
|
3545
|
-
if (relationship.kind ===
|
3471
|
+
if (relationship.kind === 'belongsTo') {
|
3546
3472
|
this.serializeBelongsTo(snapshot, json, relationship);
|
3547
|
-
} else if (relationship.kind ===
|
3473
|
+
} else if (relationship.kind === 'hasMany') {
|
3548
3474
|
this.serializeHasMany(snapshot, json, relationship);
|
3549
3475
|
}
|
3550
3476
|
}, this);
|
@@ -3614,7 +3540,7 @@
|
|
3614
3540
|
var payloadKey = this._getMappedKey(key);
|
3615
3541
|
|
3616
3542
|
if (payloadKey === key && this.keyForAttribute) {
|
3617
|
-
payloadKey = this.keyForAttribute(key,
|
3543
|
+
payloadKey = this.keyForAttribute(key, 'serialize');
|
3618
3544
|
}
|
3619
3545
|
|
3620
3546
|
json[payloadKey] = value;
|
@@ -3803,8 +3729,7 @@
|
|
3803
3729
|
return this.extractArray(store, typeClass, payload, id, requestType);
|
3804
3730
|
},
|
3805
3731
|
/**
|
3806
|
-
|
3807
|
-
`extractQueryRecord` is a hook into the extract method used when a
|
3732
|
+
`extractQueryRecord` is a hook into the extract method used when a
|
3808
3733
|
call is made to `DS.Store#queryRecord`. By default this method is an
|
3809
3734
|
alias for [extractSingle](#method_extractSingle).
|
3810
3735
|
@method extractQueryRecord
|
@@ -3965,11 +3890,11 @@
|
|
3965
3890
|
@return {Object} json The deserialized payload
|
3966
3891
|
*/
|
3967
3892
|
extractSingle: function (store, typeClass, payload, id, requestType) {
|
3968
|
-
if (!this.get(
|
3969
|
-
this.set(
|
3970
|
-
Ember.deprecate(
|
3971
|
-
id:
|
3972
|
-
until:
|
3893
|
+
if (!this.get('didDeprecateNormalizePayload')) {
|
3894
|
+
this.set('didDeprecateNormalizePayload', true);
|
3895
|
+
Ember.deprecate('`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.', this.normalizePayload === ember$data$lib$serializers$json$serializer$$JSONSerializer.prototype.normalizePayload, {
|
3896
|
+
id: 'ds.serializer.normalize-payload-deprecated',
|
3897
|
+
until: '2.0.0'
|
3973
3898
|
});
|
3974
3899
|
}
|
3975
3900
|
var normalizedPayload = this.normalizePayload(payload);
|
@@ -3999,11 +3924,11 @@
|
|
3999
3924
|
@return {Array} array An array of deserialized objects
|
4000
3925
|
*/
|
4001
3926
|
extractArray: function (store, typeClass, arrayPayload, id, requestType) {
|
4002
|
-
if (!this.get(
|
4003
|
-
this.set(
|
4004
|
-
Ember.deprecate(
|
4005
|
-
id:
|
4006
|
-
until:
|
3927
|
+
if (!this.get('didDeprecateNormalizePayload')) {
|
3928
|
+
this.set('didDeprecateNormalizePayload', true);
|
3929
|
+
Ember.deprecate('`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.', this.normalizePayload === ember$data$lib$serializers$json$serializer$$JSONSerializer.prototype.normalizePayload, {
|
3930
|
+
id: 'ds.serializer.normalize-payload-deprecated',
|
3931
|
+
until: '2.0.0'
|
4007
3932
|
});
|
4008
3933
|
}
|
4009
3934
|
var normalizedPayload = this.normalizePayload(arrayPayload);
|
@@ -4036,7 +3961,7 @@
|
|
4036
3961
|
@param {Object} payload
|
4037
3962
|
*/
|
4038
3963
|
extractMeta: function (store, typeClass, payload) {
|
4039
|
-
if (this.get(
|
3964
|
+
if (this.get('isNewSerializerAPI')) {
|
4040
3965
|
return ember$data$lib$serializers$json$serializer$$_newExtractMeta.apply(this, arguments);
|
4041
3966
|
}
|
4042
3967
|
|
@@ -4072,7 +3997,7 @@
|
|
4072
3997
|
@return {Object} json The deserialized errors
|
4073
3998
|
*/
|
4074
3999
|
extractErrors: function (store, typeClass, payload, id) {
|
4075
|
-
if (payload && typeof payload ===
|
4000
|
+
if (payload && typeof payload === 'object' && payload.errors) {
|
4076
4001
|
payload = ember$data$lib$adapters$errors$$errorsArrayToHash(payload.errors);
|
4077
4002
|
this.normalizeErrors(typeClass, payload);
|
4078
4003
|
}
|
@@ -4146,7 +4071,7 @@
|
|
4146
4071
|
@return {DS.Transform} transform
|
4147
4072
|
*/
|
4148
4073
|
transformFor: function (attributeType, skipAssertion) {
|
4149
|
-
var transform = this.container.lookup(
|
4074
|
+
var transform = this.container.lookup('transform:' + attributeType);
|
4150
4075
|
Ember.assert("Unable to find transform for '" + attributeType + "'", skipAssertion || !!transform);
|
4151
4076
|
return transform;
|
4152
4077
|
}
|
@@ -4187,7 +4112,7 @@
|
|
4187
4112
|
@private
|
4188
4113
|
*/
|
4189
4114
|
function ember$data$lib$serializers$json$serializer$$_newExtractMeta(store, modelClass, payload) {
|
4190
|
-
if (payload && payload.hasOwnProperty(
|
4115
|
+
if (payload && payload.hasOwnProperty('meta')) {
|
4191
4116
|
var meta = payload.meta;
|
4192
4117
|
delete payload.meta;
|
4193
4118
|
return meta;
|
@@ -4325,6 +4250,92 @@
|
|
4325
4250
|
});
|
4326
4251
|
};
|
4327
4252
|
|
4253
|
+
/**
|
4254
|
+
@module ember-data
|
4255
|
+
*/
|
4256
|
+
|
4257
|
+
/**
|
4258
|
+
Holds validation errors for a given record organized by attribute names.
|
4259
|
+
|
4260
|
+
Every DS.Model has an `errors` property that is an instance of
|
4261
|
+
`DS.Errors`. This can be used to display validation error
|
4262
|
+
messages returned from the server when a `record.save()` rejects.
|
4263
|
+
This works automatically with `DS.ActiveModelAdapter`, but you
|
4264
|
+
can implement [ajaxError](/api/data/classes/DS.RESTAdapter.html#method_ajaxError)
|
4265
|
+
in other adapters as well.
|
4266
|
+
|
4267
|
+
For Example, if you had an `User` model that looked like this:
|
4268
|
+
|
4269
|
+
```app/models/user.js
|
4270
|
+
import DS from 'ember-data';
|
4271
|
+
|
4272
|
+
export default DS.Model.extend({
|
4273
|
+
username: attr('string'),
|
4274
|
+
email: attr('string')
|
4275
|
+
});
|
4276
|
+
```
|
4277
|
+
And you attempted to save a record that did not validate on the backend.
|
4278
|
+
|
4279
|
+
```javascript
|
4280
|
+
var user = store.createRecord('user', {
|
4281
|
+
username: 'tomster',
|
4282
|
+
email: 'invalidEmail'
|
4283
|
+
});
|
4284
|
+
user.save();
|
4285
|
+
```
|
4286
|
+
|
4287
|
+
Your backend data store might return a response that looks like
|
4288
|
+
this. This response will be used to populate the error object.
|
4289
|
+
|
4290
|
+
```javascript
|
4291
|
+
{
|
4292
|
+
"errors": {
|
4293
|
+
"username": ["This username is already taken!"],
|
4294
|
+
"email": ["Doesn't look like a valid email."]
|
4295
|
+
}
|
4296
|
+
}
|
4297
|
+
```
|
4298
|
+
|
4299
|
+
Errors can be displayed to the user by accessing their property name
|
4300
|
+
to get an array of all the error objects for that property. Each
|
4301
|
+
error object is a JavaScript object with two keys:
|
4302
|
+
|
4303
|
+
- `message` A string containing the error message from the backend
|
4304
|
+
- `attribute` The name of the property associated with this error message
|
4305
|
+
|
4306
|
+
```handlebars
|
4307
|
+
<label>Username: {{input value=username}} </label>
|
4308
|
+
{{#each model.errors.username as |error|}}
|
4309
|
+
<div class="error">
|
4310
|
+
{{error.message}}
|
4311
|
+
</div>
|
4312
|
+
{{/each}}
|
4313
|
+
|
4314
|
+
<label>Email: {{input value=email}} </label>
|
4315
|
+
{{#each model.errors.email as |error|}}
|
4316
|
+
<div class="error">
|
4317
|
+
{{error.message}}
|
4318
|
+
</div>
|
4319
|
+
{{/each}}
|
4320
|
+
```
|
4321
|
+
|
4322
|
+
You can also access the special `messages` property on the error
|
4323
|
+
object to get an array of all the error strings.
|
4324
|
+
|
4325
|
+
```handlebars
|
4326
|
+
{{#each model.errors.messages as |message|}}
|
4327
|
+
<div class="error">
|
4328
|
+
{{message}}
|
4329
|
+
</div>
|
4330
|
+
{{/each}}
|
4331
|
+
```
|
4332
|
+
|
4333
|
+
@class Errors
|
4334
|
+
@namespace DS
|
4335
|
+
@extends Ember.Object
|
4336
|
+
@uses Ember.Enumerable
|
4337
|
+
@uses Ember.Evented
|
4338
|
+
*/
|
4328
4339
|
var ember$data$lib$system$model$errors$$get = Ember.get;
|
4329
4340
|
var ember$data$lib$system$model$errors$$set = Ember.set;
|
4330
4341
|
var ember$data$lib$system$model$errors$$isEmpty = Ember.isEmpty;
|
@@ -4654,9 +4665,9 @@
|
|
4654
4665
|
return result;
|
4655
4666
|
}
|
4656
4667
|
|
4657
|
-
var ember$data$lib$system$model$model$$RESERVED_MODEL_PROPS = [
|
4668
|
+
var ember$data$lib$system$model$model$$RESERVED_MODEL_PROPS = ['currentState', 'data', 'store'];
|
4658
4669
|
|
4659
|
-
var ember$data$lib$system$model$model$$retrieveFromCurrentState = Ember.computed(
|
4670
|
+
var ember$data$lib$system$model$model$$retrieveFromCurrentState = Ember.computed('currentState', function (key) {
|
4660
4671
|
return ember$data$lib$system$model$model$$get(this._internalModel.currentState, key);
|
4661
4672
|
}).readOnly();
|
4662
4673
|
|
@@ -4741,12 +4752,12 @@
|
|
4741
4752
|
@readOnly
|
4742
4753
|
@deprecated
|
4743
4754
|
*/
|
4744
|
-
isDirty: Ember.computed(
|
4745
|
-
Ember.deprecate(
|
4746
|
-
id:
|
4747
|
-
until:
|
4755
|
+
isDirty: Ember.computed('currentState.isDirty', function () {
|
4756
|
+
Ember.deprecate('DS.Model#isDirty has been deprecated please use hasDirtyAttributes instead', false, {
|
4757
|
+
id: 'ds.model.is-dirty-deprecated',
|
4758
|
+
until: '2.0.0'
|
4748
4759
|
});
|
4749
|
-
return this.get(
|
4760
|
+
return this.get('currentState.isDirty');
|
4750
4761
|
}),
|
4751
4762
|
|
4752
4763
|
/**
|
@@ -4754,13 +4765,13 @@
|
|
4754
4765
|
@type {Boolean}
|
4755
4766
|
@deprecated
|
4756
4767
|
*/
|
4757
|
-
error: ember$new$computed$lib$main$$default(
|
4768
|
+
error: ember$new$computed$lib$main$$default('adapterError', {
|
4758
4769
|
get: function () {
|
4759
4770
|
if (!ember$data$lib$system$model$model$$errorDeprecationShown) {
|
4760
|
-
Ember.deprecate(
|
4771
|
+
Ember.deprecate('DS.Model#error has been deprecated please use adapterError instead');
|
4761
4772
|
ember$data$lib$system$model$model$$errorDeprecationShown = true;
|
4762
4773
|
}
|
4763
|
-
return Ember.get(this,
|
4774
|
+
return Ember.get(this, 'adapterError');
|
4764
4775
|
}
|
4765
4776
|
}),
|
4766
4777
|
|
@@ -4783,8 +4794,8 @@
|
|
4783
4794
|
@type {Boolean}
|
4784
4795
|
@readOnly
|
4785
4796
|
*/
|
4786
|
-
hasDirtyAttributes: Ember.computed(
|
4787
|
-
return this.get(
|
4797
|
+
hasDirtyAttributes: Ember.computed('currentState.isDirty', function () {
|
4798
|
+
return this.get('currentState.isDirty');
|
4788
4799
|
}),
|
4789
4800
|
/**
|
4790
4801
|
If this property is `true` the record is in the `saving` state. A
|
@@ -4986,9 +4997,9 @@
|
|
4986
4997
|
var errors = ember$data$lib$system$model$errors$$default.create();
|
4987
4998
|
|
4988
4999
|
errors.registerHandlers(this._internalModel, function () {
|
4989
|
-
this.send(
|
5000
|
+
this.send('becameInvalid');
|
4990
5001
|
}, function () {
|
4991
|
-
this.send(
|
5002
|
+
this.send('becameValid');
|
4992
5003
|
});
|
4993
5004
|
|
4994
5005
|
return errors;
|
@@ -5030,7 +5041,7 @@
|
|
5030
5041
|
*/
|
5031
5042
|
toJSON: function (options) {
|
5032
5043
|
// container is for lazy transform lookups
|
5033
|
-
var serializer = this.store.serializerFor(
|
5044
|
+
var serializer = this.store.serializerFor('-default');
|
5034
5045
|
var snapshot = this._internalModel.createSnapshot();
|
5035
5046
|
|
5036
5047
|
return serializer.serialize(snapshot, options);
|
@@ -5090,7 +5101,7 @@
|
|
5090
5101
|
@private
|
5091
5102
|
@type {Object}
|
5092
5103
|
*/
|
5093
|
-
data: Ember.computed.readOnly(
|
5104
|
+
data: Ember.computed.readOnly('_internalModel._data'),
|
5094
5105
|
|
5095
5106
|
//TODO Do we want to deprecate these?
|
5096
5107
|
/**
|
@@ -5212,9 +5223,9 @@
|
|
5212
5223
|
and value is an [oldProp, newProp] array.
|
5213
5224
|
*/
|
5214
5225
|
changedAttributes: function () {
|
5215
|
-
var oldData = ember$data$lib$system$model$model$$get(this._internalModel,
|
5216
|
-
var currentData = ember$data$lib$system$model$model$$get(this._internalModel,
|
5217
|
-
var inFlightData = ember$data$lib$system$model$model$$get(this._internalModel,
|
5226
|
+
var oldData = ember$data$lib$system$model$model$$get(this._internalModel, '_data');
|
5227
|
+
var currentData = ember$data$lib$system$model$model$$get(this._internalModel, '_attributes');
|
5228
|
+
var inFlightData = ember$data$lib$system$model$model$$get(this._internalModel, '_inFlightAttributes');
|
5218
5229
|
var newData = ember$data$lib$system$model$model$$merge(ember$data$lib$system$model$model$$copy(inFlightData), currentData);
|
5219
5230
|
var diffData = ember$data$lib$system$object$polyfills$$create(null);
|
5220
5231
|
|
@@ -5260,9 +5271,9 @@
|
|
5260
5271
|
@deprecated Use `rollbackAttributes()` instead
|
5261
5272
|
*/
|
5262
5273
|
rollback: function () {
|
5263
|
-
Ember.deprecate(
|
5264
|
-
id:
|
5265
|
-
until:
|
5274
|
+
Ember.deprecate('Using model.rollback() has been deprecated. Use model.rollbackAttributes() to discard any unsaved changes to a model.', false, {
|
5275
|
+
id: 'ds.model.rollback-deprecated',
|
5276
|
+
until: '2.0.0'
|
5266
5277
|
});
|
5267
5278
|
this.rollbackAttributes();
|
5268
5279
|
},
|
@@ -5293,7 +5304,7 @@
|
|
5293
5304
|
},
|
5294
5305
|
|
5295
5306
|
toStringExtension: function () {
|
5296
|
-
return ember$data$lib$system$model$model$$get(this,
|
5307
|
+
return ember$data$lib$system$model$model$$get(this, 'id');
|
5297
5308
|
},
|
5298
5309
|
|
5299
5310
|
/**
|
@@ -5385,7 +5396,7 @@
|
|
5385
5396
|
// rely on the data property.
|
5386
5397
|
willMergeMixin: function (props) {
|
5387
5398
|
var constructor = this.constructor;
|
5388
|
-
Ember.assert(
|
5399
|
+
Ember.assert('`' + ember$data$lib$system$model$model$$intersection(ember$data$lib$system$object$polyfills$$keysFunc(props), ember$data$lib$system$model$model$$RESERVED_MODEL_PROPS)[0] + '` is a reserved property name on DS.Model objects. Please choose a different property name for ' + constructor.toString(), !ember$data$lib$system$model$model$$intersection(ember$data$lib$system$object$polyfills$$keysFunc(props), ember$data$lib$system$model$model$$RESERVED_MODEL_PROPS)[0]);
|
5389
5400
|
},
|
5390
5401
|
|
5391
5402
|
attr: function () {
|
@@ -5467,6 +5478,7 @@
|
|
5467
5478
|
@param {Object} doc JSON API document
|
5468
5479
|
@return {array} An array of errors found in the document structure
|
5469
5480
|
*/
|
5481
|
+
|
5470
5482
|
function ember$data$lib$system$store$serializer$response$$validateDocumentStructure(doc) {
|
5471
5483
|
var errors = [];
|
5472
5484
|
if (!doc || typeof doc !== 'object') {
|
@@ -5532,6 +5544,7 @@
|
|
5532
5544
|
@param {String} requestType
|
5533
5545
|
@return {Object} JSON-API Document
|
5534
5546
|
*/
|
5547
|
+
|
5535
5548
|
function ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, modelClass, payload, id, requestType) {
|
5536
5549
|
if (ember$data$lib$system$store$serializer$response$$get(serializer, 'isNewSerializerAPI')) {
|
5537
5550
|
var _ret = (function () {
|
@@ -5570,6 +5583,7 @@
|
|
5570
5583
|
@param {Object} payload
|
5571
5584
|
@return {Object} JSON-API Document
|
5572
5585
|
*/
|
5586
|
+
|
5573
5587
|
function ember$data$lib$system$store$serializer$response$$_normalizeSerializerPayload(modelClass, payload) {
|
5574
5588
|
var data = null;
|
5575
5589
|
|
@@ -5596,6 +5610,7 @@
|
|
5596
5610
|
@param {Object} payload
|
5597
5611
|
@return {Object} JSON-API Resource Object
|
5598
5612
|
*/
|
5613
|
+
|
5599
5614
|
function ember$data$lib$system$store$serializer$response$$_normalizeSerializerPayloadItem(modelClass, itemPayload) {
|
5600
5615
|
var item = {};
|
5601
5616
|
|
@@ -5635,7 +5650,7 @@
|
|
5635
5650
|
return value;
|
5636
5651
|
}
|
5637
5652
|
|
5638
|
-
Ember.assert(
|
5653
|
+
Ember.assert("A " + relationshipMeta.parentType + " record was pushed into the store with the value of " + key + " being " + Ember.inspect(value) + ", but " + key + " is a belongsTo relationship so the value must not be an array. You should probably check your data payload or serializer.", !Ember.isArray(value));
|
5639
5654
|
return { id: '' + value, type: relationshipMeta.type };
|
5640
5655
|
};
|
5641
5656
|
|
@@ -5647,7 +5662,7 @@
|
|
5647
5662
|
}
|
5648
5663
|
} else if (relationshipMeta.kind === 'hasMany') {
|
5649
5664
|
//|| [] because the hasMany could be === null
|
5650
|
-
Ember.assert(
|
5665
|
+
Ember.assert("A " + relationshipMeta.parentType + " record was pushed into the store with the value of " + key + " being '" + Ember.inspect(value) + "', but " + key + " is a hasMany relationship so the value must be an array. You should probably check your data payload or serializer.", Ember.isArray(value) || value === null);
|
5651
5666
|
|
5652
5667
|
relationshipData = Ember.A(value || []);
|
5653
5668
|
|
@@ -5687,6 +5702,7 @@
|
|
5687
5702
|
@param {Object} payload
|
5688
5703
|
@return {DS.Model|Array} one or multiple records from `data`
|
5689
5704
|
*/
|
5705
|
+
|
5690
5706
|
function ember$data$lib$system$store$serializer$response$$pushPayload(store, payload) {
|
5691
5707
|
var result = ember$data$lib$system$store$serializer$response$$pushPayloadData(store, payload);
|
5692
5708
|
ember$data$lib$system$store$serializer$response$$pushPayloadIncluded(store, payload);
|
@@ -5703,6 +5719,7 @@
|
|
5703
5719
|
@param {Object} payload
|
5704
5720
|
@return {DS.Model|Array} one or multiple records from `data`
|
5705
5721
|
*/
|
5722
|
+
|
5706
5723
|
function ember$data$lib$system$store$serializer$response$$pushPayloadData(store, payload) {
|
5707
5724
|
var result;
|
5708
5725
|
if (payload && payload.data) {
|
@@ -5727,6 +5744,7 @@
|
|
5727
5744
|
@param {Object} payload
|
5728
5745
|
@return {Array} an array containing zero or more records from `included`
|
5729
5746
|
*/
|
5747
|
+
|
5730
5748
|
function ember$data$lib$system$store$serializer$response$$pushPayloadIncluded(store, payload) {
|
5731
5749
|
var result;
|
5732
5750
|
if (payload && payload.included && Ember.isArray(payload.included)) {
|
@@ -5745,6 +5763,7 @@
|
|
5745
5763
|
@param {Object} resourceObject
|
5746
5764
|
@return {DS.Model} a record
|
5747
5765
|
*/
|
5766
|
+
|
5748
5767
|
function ember$data$lib$system$store$serializer$response$$_pushResourceObject(store, resourceObject) {
|
5749
5768
|
return store.push({ data: resourceObject });
|
5750
5769
|
}
|
@@ -5759,6 +5778,7 @@
|
|
5759
5778
|
@param {Object} payload
|
5760
5779
|
@return {Object} an object formatted the way DS.Store understands
|
5761
5780
|
*/
|
5781
|
+
|
5762
5782
|
function ember$data$lib$system$store$serializer$response$$convertResourceObject(payload) {
|
5763
5783
|
if (!payload) {
|
5764
5784
|
return payload;
|
@@ -5941,7 +5961,7 @@
|
|
5941
5961
|
@return {Object}
|
5942
5962
|
*/
|
5943
5963
|
normalize: function (typeClass, hash, prop) {
|
5944
|
-
if (this.get(
|
5964
|
+
if (this.get('isNewSerializerAPI')) {
|
5945
5965
|
ember$data$lib$serializers$rest$serializer$$_newNormalize.apply(this, arguments);
|
5946
5966
|
return this._super.apply(this, arguments);
|
5947
5967
|
}
|
@@ -5953,9 +5973,9 @@
|
|
5953
5973
|
this.normalizeUsingDeclaredMapping(typeClass, hash);
|
5954
5974
|
|
5955
5975
|
if (this.normalizeHash && this.normalizeHash[prop]) {
|
5956
|
-
Ember.deprecate(
|
5957
|
-
id:
|
5958
|
-
until:
|
5976
|
+
Ember.deprecate('`RESTSerializer.normalizeHash` has been deprecated. Please use `serializer.normalize` to modify the payload of single resources.', false, {
|
5977
|
+
id: 'ds.serializer.normalize-hash-deprecated',
|
5978
|
+
until: '2.0.0'
|
5959
5979
|
});
|
5960
5980
|
this.normalizeHash[prop](hash);
|
5961
5981
|
}
|
@@ -5983,7 +6003,7 @@
|
|
5983
6003
|
var modelClass = store.modelFor(modelName);
|
5984
6004
|
var serializer = store.serializerFor(modelName);
|
5985
6005
|
|
5986
|
-
Ember.assert(this.toString() + " has opted into the new serializer API and expects the " + serializer.toString() + " it collaborates with to also support the new serializer API by setting its `isNewSerializerAPI` property to true.", ember$data$lib$serializers$rest$serializer$$get(serializer,
|
6006
|
+
Ember.assert(this.toString() + " has opted into the new serializer API and expects the " + serializer.toString() + " it collaborates with to also support the new serializer API by setting its `isNewSerializerAPI` property to true.", ember$data$lib$serializers$rest$serializer$$get(serializer, 'isNewSerializerAPI'));
|
5987
6007
|
|
5988
6008
|
/*jshint loopfunc:true*/
|
5989
6009
|
ember$data$lib$serializers$rest$serializer$$forEach.call(arrayHash, function (hash) {
|
@@ -6022,7 +6042,7 @@
|
|
6022
6042
|
|
6023
6043
|
var meta = this.extractMeta(store, primaryModelClass, payload);
|
6024
6044
|
if (meta) {
|
6025
|
-
Ember.assert(
|
6045
|
+
Ember.assert('The `meta` returned from `extractMeta` has to be an object, not "' + Ember.typeOf(meta) + '".', Ember.typeOf(meta) === 'object');
|
6026
6046
|
documentHash.meta = meta;
|
6027
6047
|
}
|
6028
6048
|
|
@@ -6050,7 +6070,7 @@
|
|
6050
6070
|
```
|
6051
6071
|
This forces `_users` to be added to `included` instead of `data`.
|
6052
6072
|
*/
|
6053
|
-
if (prop.charAt(0) ===
|
6073
|
+
if (prop.charAt(0) === '_') {
|
6054
6074
|
forcedSecondary = true;
|
6055
6075
|
modelName = prop.substr(1);
|
6056
6076
|
}
|
@@ -6058,7 +6078,7 @@
|
|
6058
6078
|
var typeName = this.modelNameFromPayloadKey(modelName);
|
6059
6079
|
if (!store.modelFactoryFor(typeName)) {
|
6060
6080
|
Ember.warn(this.warnMessageNoModelForKey(modelName, typeName), false, {
|
6061
|
-
id:
|
6081
|
+
id: 'ds.serializer.model-for-key-missing'
|
6062
6082
|
});
|
6063
6083
|
continue;
|
6064
6084
|
}
|
@@ -6079,7 +6099,7 @@
|
|
6079
6099
|
}
|
6080
6100
|
```
|
6081
6101
|
*/
|
6082
|
-
if (isPrimary && Ember.typeOf(value) !==
|
6102
|
+
if (isPrimary && Ember.typeOf(value) !== 'array') {
|
6083
6103
|
var _normalize = this.normalize(primaryModelClass, value, prop);
|
6084
6104
|
|
6085
6105
|
var _data = _normalize.data;
|
@@ -6206,9 +6226,9 @@
|
|
6206
6226
|
@return {Object} the primary response to the original request
|
6207
6227
|
*/
|
6208
6228
|
extractSingle: function (store, primaryTypeClass, rawPayload, recordId) {
|
6209
|
-
Ember.deprecate(
|
6210
|
-
id:
|
6211
|
-
until:
|
6229
|
+
Ember.deprecate('`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.', this.normalizePayload === ember$data$lib$serializers$json$serializer$$default.prototype.normalizePayload, {
|
6230
|
+
id: 'ds.serializer.normalize-payload-deprecated',
|
6231
|
+
until: '2.0.0'
|
6212
6232
|
});
|
6213
6233
|
var payload = this.normalizePayload(rawPayload);
|
6214
6234
|
var primaryRecord;
|
@@ -6218,7 +6238,7 @@
|
|
6218
6238
|
|
6219
6239
|
if (!store.modelFactoryFor(modelName)) {
|
6220
6240
|
Ember.warn(this.warnMessageNoModelForKey(prop, modelName), false, {
|
6221
|
-
id:
|
6241
|
+
id: 'ds.serializer.model-for-key-missing'
|
6222
6242
|
});
|
6223
6243
|
continue;
|
6224
6244
|
}
|
@@ -6241,7 +6261,7 @@
|
|
6241
6261
|
var type = store.modelFor(typeName);
|
6242
6262
|
var typeSerializer = store.serializerFor(type.modelName);
|
6243
6263
|
|
6244
|
-
Ember.assert(this.toString() + " is using the " + (ember$data$lib$serializers$rest$serializer$$get(this,
|
6264
|
+
Ember.assert(this.toString() + " is using the " + (ember$data$lib$serializers$rest$serializer$$get(this, 'isNewSerializerAPI') ? 'new' : 'old') + " serializer API and expects " + typeSerializer.toString() + " it collaborates with to do the same. Make sure to set `isNewSerializerAPI: true` in your custom serializers if you want to use the new Serializer API.", ember$data$lib$serializers$rest$serializer$$get(this, 'isNewSerializerAPI') === ember$data$lib$serializers$rest$serializer$$get(typeSerializer, 'isNewSerializerAPI'));
|
6245
6265
|
|
6246
6266
|
hash = typeSerializer.normalize(type, hash, prop);
|
6247
6267
|
|
@@ -6351,9 +6371,9 @@
|
|
6351
6371
|
to the original query.
|
6352
6372
|
*/
|
6353
6373
|
extractArray: function (store, primaryTypeClass, rawPayload) {
|
6354
|
-
Ember.deprecate(
|
6355
|
-
id:
|
6356
|
-
until:
|
6374
|
+
Ember.deprecate('`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.', this.normalizePayload === ember$data$lib$serializers$json$serializer$$default.prototype.normalizePayload, {
|
6375
|
+
id: 'ds.serializer.normalize-payload-deprecated',
|
6376
|
+
until: '2.0.0'
|
6357
6377
|
});
|
6358
6378
|
var payload = this.normalizePayload(rawPayload);
|
6359
6379
|
var primaryArray;
|
@@ -6362,7 +6382,7 @@
|
|
6362
6382
|
var modelName = prop;
|
6363
6383
|
var forcedSecondary = false;
|
6364
6384
|
|
6365
|
-
if (prop.charAt(0) ===
|
6385
|
+
if (prop.charAt(0) === '_') {
|
6366
6386
|
forcedSecondary = true;
|
6367
6387
|
modelName = prop.substr(1);
|
6368
6388
|
}
|
@@ -6370,14 +6390,14 @@
|
|
6370
6390
|
var typeName = this.modelNameFromPayloadKey(modelName);
|
6371
6391
|
if (!store.modelFactoryFor(typeName)) {
|
6372
6392
|
Ember.warn(this.warnMessageNoModelForKey(prop, typeName), false, {
|
6373
|
-
id:
|
6393
|
+
id: 'ds.serializer.model-for-key-missing'
|
6374
6394
|
});
|
6375
6395
|
continue;
|
6376
6396
|
}
|
6377
6397
|
var type = store.modelFor(typeName);
|
6378
6398
|
var typeSerializer = store.serializerFor(type.modelName);
|
6379
6399
|
|
6380
|
-
Ember.assert(this.toString() + " is using the " + (ember$data$lib$serializers$rest$serializer$$get(this,
|
6400
|
+
Ember.assert(this.toString() + " is using the " + (ember$data$lib$serializers$rest$serializer$$get(this, 'isNewSerializerAPI') ? 'new' : 'old') + " serializer API and expects " + typeSerializer.toString() + " it collaborates with to do the same. Make sure to set `isNewSerializerAPI: true` in your custom serializers if you want to use the new Serializer API.", ember$data$lib$serializers$rest$serializer$$get(this, 'isNewSerializerAPI') === ember$data$lib$serializers$rest$serializer$$get(typeSerializer, 'isNewSerializerAPI'));
|
6381
6401
|
|
6382
6402
|
var isPrimary = !forcedSecondary && this.isPrimaryType(store, typeName, primaryTypeClass);
|
6383
6403
|
|
@@ -6430,14 +6450,14 @@
|
|
6430
6450
|
@param {Object} rawPayload
|
6431
6451
|
*/
|
6432
6452
|
pushPayload: function (store, rawPayload) {
|
6433
|
-
if (this.get(
|
6453
|
+
if (this.get('isNewSerializerAPI')) {
|
6434
6454
|
ember$data$lib$serializers$rest$serializer$$_newPushPayload.apply(this, arguments);
|
6435
6455
|
return;
|
6436
6456
|
}
|
6437
6457
|
|
6438
|
-
Ember.deprecate(
|
6439
|
-
id:
|
6440
|
-
until:
|
6458
|
+
Ember.deprecate('`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.', this.normalizePayload === ember$data$lib$serializers$json$serializer$$default.prototype.normalizePayload, {
|
6459
|
+
id: 'ds.serializer.normalize-payload-deprecated',
|
6460
|
+
until: '2.0.0'
|
6441
6461
|
});
|
6442
6462
|
var payload = this.normalizePayload(rawPayload);
|
6443
6463
|
|
@@ -6445,14 +6465,14 @@
|
|
6445
6465
|
var modelName = this.modelNameFromPayloadKey(prop);
|
6446
6466
|
if (!store.modelFactoryFor(modelName)) {
|
6447
6467
|
Ember.warn(this.warnMessageNoModelForKey(prop, modelName), false, {
|
6448
|
-
id:
|
6468
|
+
id: 'ds.serializer.model-for-key-missing'
|
6449
6469
|
});
|
6450
6470
|
continue;
|
6451
6471
|
}
|
6452
6472
|
var typeClass = store.modelFor(modelName);
|
6453
6473
|
var typeSerializer = store.serializerFor(modelName);
|
6454
6474
|
|
6455
|
-
Ember.assert(this.toString() + " is using the " + (ember$data$lib$serializers$rest$serializer$$get(this,
|
6475
|
+
Ember.assert(this.toString() + " is using the " + (ember$data$lib$serializers$rest$serializer$$get(this, 'isNewSerializerAPI') ? 'new' : 'old') + " serializer API and expects " + typeSerializer.toString() + " it collaborates with to do the same. Make sure to set `isNewSerializerAPI: true` in your custom serializers if you want to use the new Serializer API.", ember$data$lib$serializers$rest$serializer$$get(this, 'isNewSerializerAPI') === ember$data$lib$serializers$rest$serializer$$get(typeSerializer, 'isNewSerializerAPI'));
|
6456
6476
|
|
6457
6477
|
/*jshint loopfunc:true*/
|
6458
6478
|
var normalizedArray = ember$data$lib$serializers$rest$serializer$$map.call(Ember.makeArray(payload[prop]), function (hash) {
|
@@ -6708,8 +6728,8 @@
|
|
6708
6728
|
*/
|
6709
6729
|
typeForRoot: function (modelName) {
|
6710
6730
|
Ember.deprecate("typeForRoot is deprecated. Use modelNameFromPayloadKey instead.", false, {
|
6711
|
-
id:
|
6712
|
-
until:
|
6731
|
+
id: 'ds.serializer.type-for-root-deprecated',
|
6732
|
+
until: '2.0.0'
|
6713
6733
|
});
|
6714
6734
|
return this.modelNameFromPayloadKey(modelName);
|
6715
6735
|
},
|
@@ -6738,7 +6758,7 @@
|
|
6738
6758
|
Ember.runInDebug(function () {
|
6739
6759
|
ember$data$lib$serializers$rest$serializer$$RESTSerializer.reopen({
|
6740
6760
|
warnMessageNoModelForKey: function (prop, typeKey) {
|
6741
|
-
return
|
6761
|
+
return 'Encountered "' + prop + '" in payload, but no model was found for model name "' + typeKey + '" (resolved model name using ' + this.constructor.toString() + '.modelNameFromPayloadKey("' + prop + '"))';
|
6742
6762
|
}
|
6743
6763
|
});
|
6744
6764
|
});
|
@@ -6755,9 +6775,9 @@
|
|
6755
6775
|
*/
|
6756
6776
|
function ember$data$lib$serializers$rest$serializer$$_newNormalize(modelClass, resourceHash, prop) {
|
6757
6777
|
if (this.normalizeHash && this.normalizeHash[prop]) {
|
6758
|
-
Ember.deprecate(
|
6759
|
-
id:
|
6760
|
-
until:
|
6778
|
+
Ember.deprecate('`RESTSerializer.normalizeHash` has been deprecated. Please use `serializer.normalize` to modify the payload of single resources.', false, {
|
6779
|
+
id: 'ds.serializer.normalize-hash-deprecated',
|
6780
|
+
until: '2.0.0'
|
6761
6781
|
});
|
6762
6782
|
this.normalizeHash[prop](resourceHash);
|
6763
6783
|
}
|
@@ -6774,9 +6794,9 @@
|
|
6774
6794
|
included: []
|
6775
6795
|
};
|
6776
6796
|
|
6777
|
-
Ember.deprecate(
|
6778
|
-
id:
|
6779
|
-
until:
|
6797
|
+
Ember.deprecate('`serializer.normalizePayload` has been deprecated. Please use `serializer.normalizeResponse` with the new Serializer API to modify the payload.', this.normalizePayload === ember$data$lib$serializers$json$serializer$$default.prototype.normalizePayload, {
|
6798
|
+
id: 'ds.serializer.normalize-payload-deprecated',
|
6799
|
+
until: '2.0.0'
|
6780
6800
|
});
|
6781
6801
|
var payload = this.normalizePayload(rawPayload);
|
6782
6802
|
|
@@ -6784,14 +6804,14 @@
|
|
6784
6804
|
var modelName = this.modelNameFromPayloadKey(prop);
|
6785
6805
|
if (!store.modelFactoryFor(modelName)) {
|
6786
6806
|
Ember.warn(this.warnMessageNoModelForKey(prop, modelName), false, {
|
6787
|
-
id:
|
6807
|
+
id: 'ds.serializer.model-for-key-missing'
|
6788
6808
|
});
|
6789
6809
|
continue;
|
6790
6810
|
}
|
6791
6811
|
var type = store.modelFor(modelName);
|
6792
6812
|
var typeSerializer = store.serializerFor(type.modelName);
|
6793
6813
|
|
6794
|
-
Ember.assert(this.toString() + " is using the " + (ember$data$lib$serializers$rest$serializer$$get(this,
|
6814
|
+
Ember.assert(this.toString() + " is using the " + (ember$data$lib$serializers$rest$serializer$$get(this, 'isNewSerializerAPI') ? 'new' : 'old') + " serializer API and expects " + typeSerializer.toString() + " it collaborates with to do the same. Make sure to set `isNewSerializerAPI: true` in your custom serializers if you want to use the new Serializer API.", ember$data$lib$serializers$rest$serializer$$get(this, 'isNewSerializerAPI') === ember$data$lib$serializers$rest$serializer$$get(typeSerializer, 'isNewSerializerAPI'));
|
6795
6815
|
|
6796
6816
|
/*jshint loopfunc:true*/
|
6797
6817
|
ember$data$lib$serializers$rest$serializer$$forEach.call(Ember.makeArray(payload[prop]), function (hash) {
|
@@ -6933,10 +6953,10 @@
|
|
6933
6953
|
*/
|
6934
6954
|
keyForRelationship: function (relationshipModelName, kind) {
|
6935
6955
|
var key = activemodel$adapter$lib$system$active$model$serializer$$decamelize(relationshipModelName);
|
6936
|
-
if (kind ===
|
6937
|
-
return key +
|
6938
|
-
} else if (kind ===
|
6939
|
-
return activemodel$adapter$lib$system$active$model$serializer$$singularize(key) +
|
6956
|
+
if (kind === "belongsTo") {
|
6957
|
+
return key + "_id";
|
6958
|
+
} else if (kind === "hasMany") {
|
6959
|
+
return activemodel$adapter$lib$system$active$model$serializer$$singularize(key) + "_ids";
|
6940
6960
|
} else {
|
6941
6961
|
return key;
|
6942
6962
|
}
|
@@ -6979,7 +6999,7 @@
|
|
6979
6999
|
serializePolymorphicType: function (snapshot, json, relationship) {
|
6980
7000
|
var key = relationship.key;
|
6981
7001
|
var belongsTo = snapshot.belongsTo(key);
|
6982
|
-
var jsonKey = activemodel$adapter$lib$system$active$model$serializer$$underscore(key +
|
7002
|
+
var jsonKey = activemodel$adapter$lib$system$active$model$serializer$$underscore(key + "_type");
|
6983
7003
|
|
6984
7004
|
if (ember$lib$main$$default.isNone(belongsTo)) {
|
6985
7005
|
json[jsonKey] = null;
|
@@ -7070,18 +7090,18 @@
|
|
7070
7090
|
typeClass.eachRelationship(function (key, relationship) {
|
7071
7091
|
var payloadKey, payload;
|
7072
7092
|
if (relationship.options.polymorphic) {
|
7073
|
-
payloadKey = this.keyForAttribute(key,
|
7093
|
+
payloadKey = this.keyForAttribute(key, "deserialize");
|
7074
7094
|
payload = hash[payloadKey];
|
7075
7095
|
if (payload && payload.type) {
|
7076
7096
|
payload.type = this.modelNameFromPayloadKey(payload.type);
|
7077
|
-
} else if (payload && relationship.kind ===
|
7097
|
+
} else if (payload && relationship.kind === "hasMany") {
|
7078
7098
|
for (var i = 0, len = payload.length; i < len; i++) {
|
7079
7099
|
var single = payload[i];
|
7080
7100
|
single.type = this.modelNameFromPayloadKey(single.type);
|
7081
7101
|
}
|
7082
7102
|
}
|
7083
7103
|
} else {
|
7084
|
-
payloadKey = this.keyForRelationship(key, relationship.kind,
|
7104
|
+
payloadKey = this.keyForRelationship(key, relationship.kind, "deserialize");
|
7085
7105
|
if (!hash.hasOwnProperty(payloadKey)) {
|
7086
7106
|
return;
|
7087
7107
|
}
|
@@ -7099,7 +7119,7 @@
|
|
7099
7119
|
|
7100
7120
|
extractRelationships: function (modelClass, resourceHash) {
|
7101
7121
|
modelClass.eachRelationship(function (key, relationshipMeta) {
|
7102
|
-
var relationshipKey = this.keyForRelationship(key, relationshipMeta.kind,
|
7122
|
+
var relationshipKey = this.keyForRelationship(key, relationshipMeta.kind, "deserialize");
|
7103
7123
|
|
7104
7124
|
// prefer the format the AMS gem expects, e.g.:
|
7105
7125
|
// relationship: {id: id, type: type}
|
@@ -7138,23 +7158,23 @@
|
|
7138
7158
|
resourceHash[relationshipKey] = { id: id, type: type };
|
7139
7159
|
// otherwise hasMany
|
7140
7160
|
} else {
|
7141
|
-
|
7161
|
+
var hashes = resourceHash[polymorphicKey];
|
7142
7162
|
|
7143
|
-
|
7144
|
-
|
7145
|
-
|
7163
|
+
if (!hashes) {
|
7164
|
+
return;
|
7165
|
+
}
|
7146
7166
|
|
7147
|
-
|
7148
|
-
|
7149
|
-
|
7150
|
-
|
7151
|
-
|
7152
|
-
|
7167
|
+
// TODO: replace this with map when ActiveModelAdapter branches for Ember Data 2.0
|
7168
|
+
var array = [];
|
7169
|
+
for (var i = 0, _length = hashes.length; i < _length; i++) {
|
7170
|
+
var hash = hashes[i];
|
7171
|
+
var id = hash.id;
|
7172
|
+
var type = hash.type;
|
7153
7173
|
|
7154
|
-
|
7174
|
+
array.push({ id: id, type: type });
|
7175
|
+
}
|
7176
|
+
resourceHash[relationshipKey] = array;
|
7155
7177
|
}
|
7156
|
-
resourceHash[relationshipKey] = array;
|
7157
|
-
}
|
7158
7178
|
}
|
7159
7179
|
}
|
7160
7180
|
|
@@ -7210,12 +7230,29 @@
|
|
7210
7230
|
var activemodel$adapter$lib$setup$container$$default = activemodel$adapter$lib$setup$container$$setupActiveModelAdapter;
|
7211
7231
|
function activemodel$adapter$lib$setup$container$$setupActiveModelAdapter(registry, application) {
|
7212
7232
|
var proxy = new ember$data$lib$system$container$proxy$$default(registry);
|
7213
|
-
proxy.registerDeprecations([{ deprecated:
|
7233
|
+
proxy.registerDeprecations([{ deprecated: 'serializer:_ams', valid: 'serializer:-active-model' }, { deprecated: 'adapter:_ams', valid: 'adapter:-active-model' }]);
|
7214
7234
|
|
7215
|
-
registry.register(
|
7216
|
-
registry.register(
|
7235
|
+
registry.register('serializer:-active-model', activemodel$adapter$lib$system$active$model$serializer$$default.extend({ isNewSerializerAPI: true }));
|
7236
|
+
registry.register('adapter:-active-model', activemodel$adapter$lib$system$active$model$adapter$$default);
|
7217
7237
|
}
|
7218
7238
|
|
7239
|
+
/**
|
7240
|
+
`DS.FixtureAdapter` is an adapter that loads records from memory.
|
7241
|
+
It's primarily used for development and testing. You can also use
|
7242
|
+
`DS.FixtureAdapter` while working on the API but is not ready to
|
7243
|
+
integrate yet. It is a fully functioning adapter. All CRUD methods
|
7244
|
+
are implemented. You can also implement query logic that a remote
|
7245
|
+
system would do. It's possible to develop your entire application
|
7246
|
+
with `DS.FixtureAdapter`.
|
7247
|
+
|
7248
|
+
For information on how to use the `FixtureAdapter` in your
|
7249
|
+
application please see the [FixtureAdapter
|
7250
|
+
guide](/guides/models/the-fixture-adapter/).
|
7251
|
+
|
7252
|
+
@class FixtureAdapter
|
7253
|
+
@namespace DS
|
7254
|
+
@extends DS.Adapter
|
7255
|
+
*/
|
7219
7256
|
/**
|
7220
7257
|
@module ember-data
|
7221
7258
|
*/
|
@@ -7265,9 +7302,9 @@
|
|
7265
7302
|
return fixtures.map(function (fixture) {
|
7266
7303
|
var fixtureIdType = typeof fixture.id;
|
7267
7304
|
if (fixtureIdType !== "number" && fixtureIdType !== "string") {
|
7268
|
-
throw new Error(ember$data$lib$adapters$fixture$adapter$$fmt(
|
7305
|
+
throw new Error(ember$data$lib$adapters$fixture$adapter$$fmt('the id property must be defined as a number or string for fixture %@', [fixture]));
|
7269
7306
|
}
|
7270
|
-
fixture.id = fixture.id +
|
7307
|
+
fixture.id = fixture.id + '';
|
7271
7308
|
return fixture;
|
7272
7309
|
});
|
7273
7310
|
}
|
@@ -7283,7 +7320,7 @@
|
|
7283
7320
|
@return {(Promise|Array)}
|
7284
7321
|
*/
|
7285
7322
|
queryFixtures: function (fixtures, query, typeClass) {
|
7286
|
-
Ember.assert(
|
7323
|
+
Ember.assert('Not implemented: You must override the DS.FixtureAdapter::queryFixtures method to support querying the fixture store.');
|
7287
7324
|
},
|
7288
7325
|
|
7289
7326
|
/**
|
@@ -7338,7 +7375,7 @@
|
|
7338
7375
|
Ember.assert("Unable to find fixtures for model type " + typeClass.toString() + ". If you're defining your fixtures using `Model.FIXTURES = ...`, please change it to `Model.reopenClass({ FIXTURES: ... })`.", fixtures);
|
7339
7376
|
|
7340
7377
|
if (fixtures) {
|
7341
|
-
fixture = Ember.A(fixtures).findBy(
|
7378
|
+
fixture = Ember.A(fixtures).findBy('id', id);
|
7342
7379
|
}
|
7343
7380
|
|
7344
7381
|
if (fixture) {
|
@@ -7501,7 +7538,7 @@
|
|
7501
7538
|
*/
|
7502
7539
|
findFixtureById: function (fixtures, id) {
|
7503
7540
|
return Ember.A(fixtures).find(function (r) {
|
7504
|
-
if (
|
7541
|
+
if ('' + ember$data$lib$adapters$fixture$adapter$$get(r, 'id') === '' + id) {
|
7505
7542
|
return true;
|
7506
7543
|
} else {
|
7507
7544
|
return false;
|
@@ -7520,14 +7557,14 @@
|
|
7520
7557
|
|
7521
7558
|
return new Ember.RSVP.Promise(function (resolve) {
|
7522
7559
|
var value = Ember.copy(callback.call(context), true);
|
7523
|
-
if (ember$data$lib$adapters$fixture$adapter$$get(adapter,
|
7560
|
+
if (ember$data$lib$adapters$fixture$adapter$$get(adapter, 'simulateRemoteResponse')) {
|
7524
7561
|
// Schedule with setTimeout
|
7525
7562
|
Ember.run.later(function () {
|
7526
7563
|
resolve(value);
|
7527
|
-
}, ember$data$lib$adapters$fixture$adapter$$get(adapter,
|
7564
|
+
}, ember$data$lib$adapters$fixture$adapter$$get(adapter, 'latency'));
|
7528
7565
|
} else {
|
7529
7566
|
// Asynchronous, but at the of the runloop with zero latency
|
7530
|
-
Ember.run.schedule(
|
7567
|
+
Ember.run.schedule('actions', null, function () {
|
7531
7568
|
resolve(value);
|
7532
7569
|
});
|
7533
7570
|
}
|
@@ -7609,7 +7646,7 @@
|
|
7609
7646
|
});
|
7610
7647
|
|
7611
7648
|
var ember$data$lib$core$$DS = Ember.Namespace.create({
|
7612
|
-
VERSION: '1.13.
|
7649
|
+
VERSION: '1.13.9'
|
7613
7650
|
});
|
7614
7651
|
|
7615
7652
|
if (Ember.libraries) {
|
@@ -7623,6 +7660,7 @@
|
|
7623
7660
|
|
7624
7661
|
var ember$data$lib$core$$default = ember$data$lib$core$$DS;
|
7625
7662
|
var ember$data$lib$system$store$common$$get = Ember.get;
|
7663
|
+
|
7626
7664
|
function ember$data$lib$system$store$common$$_bind(fn) {
|
7627
7665
|
var args = Array.prototype.slice.call(arguments, 1);
|
7628
7666
|
|
@@ -7632,7 +7670,7 @@
|
|
7632
7670
|
}
|
7633
7671
|
|
7634
7672
|
function ember$data$lib$system$store$common$$_guard(promise, test) {
|
7635
|
-
var guarded = promise[
|
7673
|
+
var guarded = promise['finally'](function () {
|
7636
7674
|
if (!test()) {
|
7637
7675
|
guarded._subscribers.length = 0;
|
7638
7676
|
}
|
@@ -7670,13 +7708,14 @@
|
|
7670
7708
|
var ember$data$lib$system$store$finders$$Promise = Ember.RSVP.Promise;
|
7671
7709
|
var ember$data$lib$system$store$finders$$map = Ember.ArrayPolyfills.map;
|
7672
7710
|
var ember$data$lib$system$store$finders$$get = Ember.get;
|
7711
|
+
|
7673
7712
|
function ember$data$lib$system$store$finders$$_find(adapter, store, typeClass, id, internalModel, options) {
|
7674
7713
|
var snapshot = internalModel.createSnapshot(options);
|
7675
7714
|
var promise;
|
7676
7715
|
if (!adapter.findRecord) {
|
7677
|
-
Ember.deprecate(
|
7678
|
-
id:
|
7679
|
-
until:
|
7716
|
+
Ember.deprecate('Adapter#find has been deprecated and renamed to `findRecord`.', false, {
|
7717
|
+
id: 'ds.adapter.find-renamed-to-find-record',
|
7718
|
+
until: '2.0.0'
|
7680
7719
|
});
|
7681
7720
|
promise = adapter.find(store, typeClass, id, snapshot);
|
7682
7721
|
} else {
|
@@ -7691,7 +7730,7 @@
|
|
7691
7730
|
return promise.then(function (adapterPayload) {
|
7692
7731
|
Ember.assert("You made a request for a " + typeClass.typeClassKey + " with id " + id + ", but the adapter's response did not have any data", adapterPayload);
|
7693
7732
|
return store._adapterRun(function () {
|
7694
|
-
var requestType = ember$data$lib$system$store$finders$$get(serializer,
|
7733
|
+
var requestType = ember$data$lib$system$store$finders$$get(serializer, 'isNewSerializerAPI') ? 'findRecord' : 'find';
|
7695
7734
|
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, id, requestType);
|
7696
7735
|
//TODO Optimize
|
7697
7736
|
var record = ember$data$lib$system$store$serializer$response$$pushPayload(store, payload);
|
@@ -7708,13 +7747,13 @@
|
|
7708
7747
|
}
|
7709
7748
|
|
7710
7749
|
function ember$data$lib$system$store$finders$$_findMany(adapter, store, typeClass, ids, internalModels) {
|
7711
|
-
var snapshots = Ember.A(internalModels).invoke(
|
7750
|
+
var snapshots = Ember.A(internalModels).invoke('createSnapshot');
|
7712
7751
|
var promise = adapter.findMany(store, typeClass, ids, snapshots);
|
7713
7752
|
var serializer = ember$data$lib$system$store$serializers$$serializerForAdapter(store, adapter, typeClass.modelName);
|
7714
7753
|
var label = "DS: Handle Adapter#findMany of " + typeClass;
|
7715
7754
|
|
7716
7755
|
if (promise === undefined) {
|
7717
|
-
throw new Error(
|
7756
|
+
throw new Error('adapter.findMany returned undefined, this was very likely a mistake');
|
7718
7757
|
}
|
7719
7758
|
|
7720
7759
|
promise = ember$data$lib$system$store$finders$$Promise.cast(promise, label);
|
@@ -7722,7 +7761,7 @@
|
|
7722
7761
|
|
7723
7762
|
return promise.then(function (adapterPayload) {
|
7724
7763
|
return store._adapterRun(function () {
|
7725
|
-
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null,
|
7764
|
+
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null, 'findMany');
|
7726
7765
|
//TODO Optimize, no need to materialize here
|
7727
7766
|
var records = ember$data$lib$system$store$serializer$response$$pushPayload(store, payload);
|
7728
7767
|
return ember$data$lib$system$store$finders$$map.call(records, function (record) {
|
@@ -7745,13 +7784,13 @@
|
|
7745
7784
|
|
7746
7785
|
return promise.then(function (adapterPayload) {
|
7747
7786
|
return store._adapterRun(function () {
|
7748
|
-
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null,
|
7787
|
+
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null, 'findHasMany');
|
7749
7788
|
//TODO Use a non record creating push
|
7750
7789
|
var records = ember$data$lib$system$store$serializer$response$$pushPayload(store, payload);
|
7751
7790
|
var recordArray = ember$data$lib$system$store$finders$$map.call(records, function (record) {
|
7752
7791
|
return record._internalModel;
|
7753
7792
|
});
|
7754
|
-
if (ember$data$lib$system$store$finders$$get(serializer,
|
7793
|
+
if (ember$data$lib$system$store$finders$$get(serializer, 'isNewSerializerAPI')) {
|
7755
7794
|
recordArray.meta = payload.meta;
|
7756
7795
|
}
|
7757
7796
|
return recordArray;
|
@@ -7772,7 +7811,7 @@
|
|
7772
7811
|
|
7773
7812
|
return promise.then(function (adapterPayload) {
|
7774
7813
|
return store._adapterRun(function () {
|
7775
|
-
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null,
|
7814
|
+
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null, 'findBelongsTo');
|
7776
7815
|
|
7777
7816
|
if (!payload.data) {
|
7778
7817
|
return null;
|
@@ -7798,7 +7837,7 @@
|
|
7798
7837
|
|
7799
7838
|
return promise.then(function (adapterPayload) {
|
7800
7839
|
store._adapterRun(function () {
|
7801
|
-
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null,
|
7840
|
+
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null, 'findAll');
|
7802
7841
|
//TODO Optimize
|
7803
7842
|
ember$data$lib$system$store$serializer$response$$pushPayload(store, payload);
|
7804
7843
|
});
|
@@ -7813,9 +7852,9 @@
|
|
7813
7852
|
var promise;
|
7814
7853
|
|
7815
7854
|
if (!adapter.query) {
|
7816
|
-
Ember.deprecate(
|
7817
|
-
id:
|
7818
|
-
until:
|
7855
|
+
Ember.deprecate('Adapter#findQuery has been deprecated and renamed to `query`.', false, {
|
7856
|
+
id: 'ds.adapter.find-query-renamed-to-query',
|
7857
|
+
until: '2.0.0'
|
7819
7858
|
});
|
7820
7859
|
promise = adapter.findQuery(store, typeClass, query, recordArray);
|
7821
7860
|
} else {
|
@@ -7831,7 +7870,7 @@
|
|
7831
7870
|
return promise.then(function (adapterPayload) {
|
7832
7871
|
var records;
|
7833
7872
|
store._adapterRun(function () {
|
7834
|
-
var requestType = ember$data$lib$system$store$finders$$get(serializer,
|
7873
|
+
var requestType = ember$data$lib$system$store$finders$$get(serializer, 'isNewSerializerAPI') ? 'query' : 'findQuery';
|
7835
7874
|
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null, requestType);
|
7836
7875
|
//TODO Optimize
|
7837
7876
|
records = ember$data$lib$system$store$serializer$response$$pushPayload(store, payload);
|
@@ -7854,7 +7893,7 @@
|
|
7854
7893
|
return promise.then(function (adapterPayload) {
|
7855
7894
|
var record;
|
7856
7895
|
store._adapterRun(function () {
|
7857
|
-
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null,
|
7896
|
+
var payload = ember$data$lib$system$store$serializer$response$$normalizeResponseHelper(serializer, store, typeClass, adapterPayload, null, 'queryRecord');
|
7858
7897
|
//TODO Optimize
|
7859
7898
|
record = ember$data$lib$system$store$serializer$response$$pushPayload(store, payload);
|
7860
7899
|
});
|
@@ -7919,24 +7958,6 @@
|
|
7919
7958
|
};
|
7920
7959
|
|
7921
7960
|
var ember$data$lib$system$snapshot$record$array$$default = ember$data$lib$system$snapshot$record$array$$SnapshotRecordArray;
|
7922
|
-
var ember$data$lib$system$record$arrays$filtered$subset$$FilteredSubset = Ember.ArrayProxy.extend({
|
7923
|
-
init: function () {
|
7924
|
-
this._super.apply(this, arguments);
|
7925
|
-
|
7926
|
-
var _getProperties = this.getProperties('filterByArgs', 'recordArray');
|
7927
|
-
|
7928
|
-
var filterByArgs = _getProperties.filterByArgs;
|
7929
|
-
var recordArray = _getProperties.recordArray;
|
7930
|
-
var key = filterByArgs[0];
|
7931
|
-
|
7932
|
-
var path = 'recordArray.@each.' + key;
|
7933
|
-
Ember.defineProperty(this, 'content', Ember.computed(path, function () {
|
7934
|
-
return this.filterBy.apply(recordArray, filterByArgs);
|
7935
|
-
}));
|
7936
|
-
}
|
7937
|
-
});
|
7938
|
-
|
7939
|
-
var ember$data$lib$system$record$arrays$filtered$subset$$default = ember$data$lib$system$record$arrays$filtered$subset$$FilteredSubset;
|
7940
7961
|
|
7941
7962
|
var ember$data$lib$system$record$arrays$record$array$$get = Ember.get;
|
7942
7963
|
var ember$data$lib$system$record$arrays$record$array$$set = Ember.set;
|
@@ -8001,42 +8022,11 @@
|
|
8001
8022
|
@return {DS.Model} record
|
8002
8023
|
*/
|
8003
8024
|
objectAtContent: function (index) {
|
8004
|
-
var content = ember$data$lib$system$record$arrays$record$array$$get(this,
|
8025
|
+
var content = ember$data$lib$system$record$arrays$record$array$$get(this, 'content');
|
8005
8026
|
var internalModel = content.objectAt(index);
|
8006
8027
|
return internalModel && internalModel.getRecord();
|
8007
8028
|
},
|
8008
8029
|
|
8009
|
-
/**
|
8010
|
-
Get a filtered subset of the underlying `RecordArray`.
|
8011
|
-
The subset updates when a record would match or mismatch the
|
8012
|
-
specified filter parameters.
|
8013
|
-
Example
|
8014
|
-
```javascript
|
8015
|
-
var allToms = store.all('person').filterBy('name', 'Tom');
|
8016
|
-
allToms.get('length'); // 0, since no toms yet in store
|
8017
|
-
var tom = store.push('person', { id: 1, name: 'Tom' });
|
8018
|
-
allToms.get('length'); // Tom is added
|
8019
|
-
tom.set('name', 'Thomas');
|
8020
|
-
allToms.get('length'); // 0, since no more records with name === 'Tom'
|
8021
|
-
```
|
8022
|
-
@method filterBy
|
8023
|
-
@param {String} key property path
|
8024
|
-
@param {*} value optional
|
8025
|
-
*/
|
8026
|
-
filterBy: function (key, value) {
|
8027
|
-
// only pass value to the arguments if it is present; this mimics the same
|
8028
|
-
// behavior for `filterBy`: http://git.io/vIurH
|
8029
|
-
var filterByArgs = [key];
|
8030
|
-
if (arguments.length === 2) {
|
8031
|
-
filterByArgs.push(value);
|
8032
|
-
}
|
8033
|
-
|
8034
|
-
return ember$data$lib$system$record$arrays$filtered$subset$$default.create({
|
8035
|
-
filterByArgs: filterByArgs,
|
8036
|
-
recordArray: this
|
8037
|
-
});
|
8038
|
-
},
|
8039
|
-
|
8040
8030
|
/**
|
8041
8031
|
Used to get the latest version of all of the records in this array
|
8042
8032
|
from the adapter.
|
@@ -8050,12 +8040,12 @@
|
|
8050
8040
|
@method update
|
8051
8041
|
*/
|
8052
8042
|
update: function () {
|
8053
|
-
if (ember$data$lib$system$record$arrays$record$array$$get(this,
|
8043
|
+
if (ember$data$lib$system$record$arrays$record$array$$get(this, 'isUpdating')) {
|
8054
8044
|
return;
|
8055
8045
|
}
|
8056
8046
|
|
8057
|
-
var store = ember$data$lib$system$record$arrays$record$array$$get(this,
|
8058
|
-
var modelName = ember$data$lib$system$record$arrays$record$array$$get(this,
|
8047
|
+
var store = ember$data$lib$system$record$arrays$record$array$$get(this, 'store');
|
8048
|
+
var modelName = ember$data$lib$system$record$arrays$record$array$$get(this, 'type.modelName');
|
8059
8049
|
|
8060
8050
|
return store.findAll(modelName, { reload: true });
|
8061
8051
|
},
|
@@ -8068,7 +8058,7 @@
|
|
8068
8058
|
@param {number} an optional index to insert at
|
8069
8059
|
*/
|
8070
8060
|
addInternalModel: function (internalModel, idx) {
|
8071
|
-
var content = ember$data$lib$system$record$arrays$record$array$$get(this,
|
8061
|
+
var content = ember$data$lib$system$record$arrays$record$array$$get(this, 'content');
|
8072
8062
|
if (idx === undefined) {
|
8073
8063
|
content.addObject(internalModel);
|
8074
8064
|
} else if (!content.contains(internalModel)) {
|
@@ -8083,7 +8073,7 @@
|
|
8083
8073
|
@param {InternalModel} internalModel
|
8084
8074
|
*/
|
8085
8075
|
removeInternalModel: function (internalModel) {
|
8086
|
-
ember$data$lib$system$record$arrays$record$array$$get(this,
|
8076
|
+
ember$data$lib$system$record$arrays$record$array$$get(this, 'content').removeObject(internalModel);
|
8087
8077
|
},
|
8088
8078
|
|
8089
8079
|
/**
|
@@ -8101,7 +8091,7 @@
|
|
8101
8091
|
*/
|
8102
8092
|
save: function () {
|
8103
8093
|
var recordArray = this;
|
8104
|
-
var promiseLabel = "DS: RecordArray#save " + ember$data$lib$system$record$arrays$record$array$$get(this,
|
8094
|
+
var promiseLabel = "DS: RecordArray#save " + ember$data$lib$system$record$arrays$record$array$$get(this, 'type');
|
8105
8095
|
var promise = Ember.RSVP.all(this.invoke("save"), promiseLabel).then(function (array) {
|
8106
8096
|
return recordArray;
|
8107
8097
|
}, null, "DS: RecordArray#save return RecordArray");
|
@@ -8112,7 +8102,7 @@
|
|
8112
8102
|
_dissociateFromOwnRecords: function () {
|
8113
8103
|
var array = this;
|
8114
8104
|
|
8115
|
-
this.get(
|
8105
|
+
this.get('content').forEach(function (record) {
|
8116
8106
|
var recordArrays = record._recordArrays;
|
8117
8107
|
|
8118
8108
|
if (recordArrays) {
|
@@ -8126,20 +8116,20 @@
|
|
8126
8116
|
@private
|
8127
8117
|
*/
|
8128
8118
|
_unregisterFromManager: function () {
|
8129
|
-
var manager = ember$data$lib$system$record$arrays$record$array$$get(this,
|
8119
|
+
var manager = ember$data$lib$system$record$arrays$record$array$$get(this, 'manager');
|
8130
8120
|
manager.unregisterRecordArray(this);
|
8131
8121
|
},
|
8132
8122
|
|
8133
8123
|
willDestroy: function () {
|
8134
8124
|
this._unregisterFromManager();
|
8135
8125
|
this._dissociateFromOwnRecords();
|
8136
|
-
ember$data$lib$system$record$arrays$record$array$$set(this,
|
8126
|
+
ember$data$lib$system$record$arrays$record$array$$set(this, 'content', undefined);
|
8137
8127
|
this._super.apply(this, arguments);
|
8138
8128
|
},
|
8139
8129
|
|
8140
8130
|
createSnapshot: function (options) {
|
8141
8131
|
var adapterOptions = options && options.adapterOptions;
|
8142
|
-
var meta = this.get(
|
8132
|
+
var meta = this.get('meta');
|
8143
8133
|
return new ember$data$lib$system$snapshot$record$array$$default(this, meta, adapterOptions);
|
8144
8134
|
}
|
8145
8135
|
});
|
@@ -8176,7 +8166,7 @@
|
|
8176
8166
|
isLoaded: true,
|
8177
8167
|
|
8178
8168
|
replace: function () {
|
8179
|
-
var type = ember$data$lib$system$record$arrays$filtered$record$array$$get(this,
|
8169
|
+
var type = ember$data$lib$system$record$arrays$filtered$record$array$$get(this, 'type').toString();
|
8180
8170
|
throw new Error("The result of a client-side filter (on " + type + ") is immutable.");
|
8181
8171
|
},
|
8182
8172
|
|
@@ -8185,11 +8175,11 @@
|
|
8185
8175
|
@private
|
8186
8176
|
*/
|
8187
8177
|
_updateFilter: function () {
|
8188
|
-
var manager = ember$data$lib$system$record$arrays$filtered$record$array$$get(this,
|
8189
|
-
manager.updateFilter(this, ember$data$lib$system$record$arrays$filtered$record$array$$get(this,
|
8178
|
+
var manager = ember$data$lib$system$record$arrays$filtered$record$array$$get(this, 'manager');
|
8179
|
+
manager.updateFilter(this, ember$data$lib$system$record$arrays$filtered$record$array$$get(this, 'type'), ember$data$lib$system$record$arrays$filtered$record$array$$get(this, 'filterFunction'));
|
8190
8180
|
},
|
8191
8181
|
|
8192
|
-
updateFilter: Ember.observer(
|
8182
|
+
updateFilter: Ember.observer('filterFunction', function () {
|
8193
8183
|
Ember.run.once(this, this._updateFilter);
|
8194
8184
|
})
|
8195
8185
|
});
|
@@ -8213,7 +8203,7 @@
|
|
8213
8203
|
query: null,
|
8214
8204
|
|
8215
8205
|
replace: function () {
|
8216
|
-
var type = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this,
|
8206
|
+
var type = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this, 'type').toString();
|
8217
8207
|
throw new Error("The result of a server query (on " + type + ") is immutable.");
|
8218
8208
|
},
|
8219
8209
|
|
@@ -8223,8 +8213,8 @@
|
|
8223
8213
|
@param {Array} data
|
8224
8214
|
*/
|
8225
8215
|
load: function (data) {
|
8226
|
-
var store = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this,
|
8227
|
-
var type = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this,
|
8216
|
+
var store = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this, 'store');
|
8217
|
+
var type = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this, 'type');
|
8228
8218
|
var modelName = type.modelName;
|
8229
8219
|
var records = store.pushMany(modelName, data);
|
8230
8220
|
|
@@ -8237,13 +8227,13 @@
|
|
8237
8227
|
@private
|
8238
8228
|
*/
|
8239
8229
|
loadRecords: function (records) {
|
8240
|
-
var store = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this,
|
8241
|
-
var type = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this,
|
8230
|
+
var store = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this, 'store');
|
8231
|
+
var type = ember$data$lib$system$record$arrays$adapter$populated$record$array$$get(this, 'type');
|
8242
8232
|
var modelName = type.modelName;
|
8243
8233
|
var meta = store._metadataFor(modelName);
|
8244
8234
|
|
8245
8235
|
//TODO Optimize
|
8246
|
-
var internalModels = Ember.A(records).mapBy(
|
8236
|
+
var internalModels = Ember.A(records).mapBy('_internalModel');
|
8247
8237
|
this.setProperties({
|
8248
8238
|
content: Ember.A(internalModels),
|
8249
8239
|
isLoaded: true,
|
@@ -8255,7 +8245,7 @@
|
|
8255
8245
|
}, this);
|
8256
8246
|
|
8257
8247
|
// TODO: should triggering didLoad event be the last action of the runLoop?
|
8258
|
-
Ember.run.once(this,
|
8248
|
+
Ember.run.once(this, 'trigger', 'didLoad');
|
8259
8249
|
}
|
8260
8250
|
});
|
8261
8251
|
|
@@ -8327,7 +8317,7 @@
|
|
8327
8317
|
return;
|
8328
8318
|
}
|
8329
8319
|
|
8330
|
-
Ember.run.schedule(
|
8320
|
+
Ember.run.schedule('actions', this, this.updateRecordArrays);
|
8331
8321
|
},
|
8332
8322
|
|
8333
8323
|
recordArraysForRecord: function (record) {
|
@@ -8373,7 +8363,7 @@
|
|
8373
8363
|
var recordArrays = this.filteredRecordArrays.get(typeClass);
|
8374
8364
|
var filter;
|
8375
8365
|
ember$data$lib$system$record$array$manager$$forEach.call(recordArrays, function (array) {
|
8376
|
-
filter = ember$data$lib$system$record$array$manager$$get(array,
|
8366
|
+
filter = ember$data$lib$system$record$array$manager$$get(array, 'filterFunction');
|
8377
8367
|
this.updateFilterRecordArray(array, filter, typeClass, record);
|
8378
8368
|
}, this);
|
8379
8369
|
},
|
@@ -8385,7 +8375,7 @@
|
|
8385
8375
|
var filter;
|
8386
8376
|
|
8387
8377
|
ember$data$lib$system$record$array$manager$$forEach.call(recordArrays, function (array) {
|
8388
|
-
filter = ember$data$lib$system$record$array$manager$$get(array,
|
8378
|
+
filter = ember$data$lib$system$record$array$manager$$get(array, 'filterFunction');
|
8389
8379
|
this.updateFilterRecordArray(array, filter, typeClass, record);
|
8390
8380
|
}, this);
|
8391
8381
|
|
@@ -8566,11 +8556,11 @@
|
|
8566
8556
|
|
8567
8557
|
// unregister live record array
|
8568
8558
|
} else if (this.liveRecordArrays.has(typeClass)) {
|
8569
|
-
|
8570
|
-
|
8571
|
-
|
8559
|
+
var liveRecordArrayForType = this.liveRecordArrayFor(typeClass);
|
8560
|
+
if (array === liveRecordArrayForType) {
|
8561
|
+
this.liveRecordArrays["delete"](typeClass);
|
8562
|
+
}
|
8572
8563
|
}
|
8573
|
-
}
|
8574
8564
|
},
|
8575
8565
|
|
8576
8566
|
willDestroy: function () {
|
@@ -9142,7 +9132,7 @@
|
|
9142
9132
|
ember$data$lib$system$model$states$$createdState.uncommitted.propertyWasReset = Ember.K;
|
9143
9133
|
|
9144
9134
|
function ember$data$lib$system$model$states$$assertAgainstUnloadRecord(internalModel) {
|
9145
|
-
Ember.assert(
|
9135
|
+
Ember.assert("You can only unload a record which is not inFlight. `" + internalModel + "`", false);
|
9146
9136
|
}
|
9147
9137
|
|
9148
9138
|
ember$data$lib$system$model$states$$updatedState.inFlight.unloadRecord = ember$data$lib$system$model$states$$assertAgainstUnloadRecord;
|
@@ -9461,14 +9451,14 @@
|
|
9461
9451
|
continue;
|
9462
9452
|
}
|
9463
9453
|
if (typeof object[prop] === 'object') {
|
9464
|
-
object[prop] = ember$data$lib$system$model$states$$wireState(object[prop], object, name +
|
9454
|
+
object[prop] = ember$data$lib$system$model$states$$wireState(object[prop], object, name + "." + prop);
|
9465
9455
|
}
|
9466
9456
|
}
|
9467
9457
|
|
9468
9458
|
return object;
|
9469
9459
|
}
|
9470
9460
|
|
9471
|
-
ember$data$lib$system$model$states$$RootState = ember$data$lib$system$model$states$$wireState(ember$data$lib$system$model$states$$RootState, null,
|
9461
|
+
ember$data$lib$system$model$states$$RootState = ember$data$lib$system$model$states$$wireState(ember$data$lib$system$model$states$$RootState, null, "root");
|
9472
9462
|
|
9473
9463
|
var ember$data$lib$system$model$states$$default = ember$data$lib$system$model$states$$RootState;
|
9474
9464
|
|
@@ -9684,7 +9674,7 @@
|
|
9684
9674
|
Ember.warn('You have pushed a record of type \'' + this.record.type.modelName + '\' with \'' + this.key + '\' as a link, but the association is not an async relationship.', this.isAsync, {
|
9685
9675
|
id: 'ds.store.push-link-for-sync-relationship'
|
9686
9676
|
});
|
9687
|
-
Ember.assert(
|
9677
|
+
Ember.assert("You have pushed a record of type '" + this.record.type.modelName + "' with '" + this.key + "' as a link, but the value of that link is not a string.", typeof link === 'string' || link === null);
|
9688
9678
|
if (link !== this.link) {
|
9689
9679
|
this.link = link;
|
9690
9680
|
this.linkPromise = null;
|
@@ -9760,7 +9750,7 @@
|
|
9760
9750
|
toSet = toSet.concat(newRecords);
|
9761
9751
|
var oldLength = this.length;
|
9762
9752
|
this.arrayContentWillChange(0, this.length, toSet.length);
|
9763
|
-
this.set(
|
9753
|
+
this.set('length', toSet.length);
|
9764
9754
|
this.currentState = toSet;
|
9765
9755
|
this.arrayContentDidChange(0, oldLength, this.length);
|
9766
9756
|
//TODO Figure out to notify only on additions and maybe only if unloaded
|
@@ -9825,7 +9815,7 @@
|
|
9825
9815
|
}
|
9826
9816
|
this.arrayContentWillChange(idx, amt, objects.length);
|
9827
9817
|
this.currentState.splice.apply(this.currentState, [idx, amt].concat(objects));
|
9828
|
-
this.set(
|
9818
|
+
this.set('length', this.currentState.length);
|
9829
9819
|
this.arrayContentDidChange(idx, amt, objects.length);
|
9830
9820
|
if (objects) {
|
9831
9821
|
//TODO(Igor) probably needed only for unloaded records
|
@@ -9855,11 +9845,11 @@
|
|
9855
9845
|
var records;
|
9856
9846
|
if (amt > 0) {
|
9857
9847
|
records = this.currentState.slice(idx, idx + amt);
|
9858
|
-
this.get(
|
9848
|
+
this.get('relationship').removeRecords(records);
|
9859
9849
|
}
|
9860
9850
|
var map = objects.map || Ember.ArrayPolyfills.map;
|
9861
9851
|
if (objects) {
|
9862
|
-
this.get(
|
9852
|
+
this.get('relationship').addRecords(map.call(objects, function (obj) {
|
9863
9853
|
return obj._internalModel;
|
9864
9854
|
}), idx);
|
9865
9855
|
}
|
@@ -9888,8 +9878,8 @@
|
|
9888
9878
|
loadedRecord: function () {
|
9889
9879
|
this.loadingRecordsCount--;
|
9890
9880
|
if (this.loadingRecordsCount === 0) {
|
9891
|
-
ember$data$lib$system$many$array$$set(this,
|
9892
|
-
this.trigger(
|
9881
|
+
ember$data$lib$system$many$array$$set(this, 'isLoaded', true);
|
9882
|
+
this.trigger('didLoad');
|
9893
9883
|
}
|
9894
9884
|
},
|
9895
9885
|
|
@@ -9919,7 +9909,7 @@
|
|
9919
9909
|
*/
|
9920
9910
|
save: function () {
|
9921
9911
|
var manyArray = this;
|
9922
|
-
var promiseLabel = "DS: ManyArray#save " + ember$data$lib$system$many$array$$get(this,
|
9912
|
+
var promiseLabel = "DS: ManyArray#save " + ember$data$lib$system$many$array$$get(this, 'type');
|
9923
9913
|
var promise = Ember.RSVP.all(this.invoke("save"), promiseLabel).then(function (array) {
|
9924
9914
|
return manyArray;
|
9925
9915
|
}, null, "DS: ManyArray#save return ManyArray");
|
@@ -9935,11 +9925,11 @@
|
|
9935
9925
|
@return {DS.Model} record
|
9936
9926
|
*/
|
9937
9927
|
createRecord: function (hash) {
|
9938
|
-
var store = ember$data$lib$system$many$array$$get(this,
|
9939
|
-
var type = ember$data$lib$system$many$array$$get(this,
|
9928
|
+
var store = ember$data$lib$system$many$array$$get(this, 'store');
|
9929
|
+
var type = ember$data$lib$system$many$array$$get(this, 'type');
|
9940
9930
|
var record;
|
9941
9931
|
|
9942
|
-
Ember.assert("You cannot add '" + type.modelName + "' records to this polymorphic relationship.", !ember$data$lib$system$many$array$$get(this,
|
9932
|
+
Ember.assert("You cannot add '" + type.modelName + "' records to this polymorphic relationship.", !ember$data$lib$system$many$array$$get(this, 'isPolymorphic'));
|
9943
9933
|
|
9944
9934
|
record = store.createRecord(type.modelName, hash);
|
9945
9935
|
this.pushObject(record);
|
@@ -9953,9 +9943,9 @@
|
|
9953
9943
|
@deprecated Use `addObject()` instead
|
9954
9944
|
*/
|
9955
9945
|
addRecord: function (record) {
|
9956
|
-
Ember.deprecate(
|
9957
|
-
id:
|
9958
|
-
until:
|
9946
|
+
Ember.deprecate('Using manyArray.addRecord() has been deprecated. You should use manyArray.addObject() instead.', false, {
|
9947
|
+
id: 'ds.many-array.add-record-deprecated',
|
9948
|
+
until: '2.0.0'
|
9959
9949
|
});
|
9960
9950
|
this.addObject(record);
|
9961
9951
|
},
|
@@ -9966,39 +9956,11 @@
|
|
9966
9956
|
@deprecated Use `removeObject()` instead
|
9967
9957
|
*/
|
9968
9958
|
removeRecord: function (record) {
|
9969
|
-
Ember.deprecate(
|
9970
|
-
id:
|
9971
|
-
until:
|
9959
|
+
Ember.deprecate('Using manyArray.removeRecord() has been deprecated. You should use manyArray.removeObject() instead.', false, {
|
9960
|
+
id: 'ds.many-array.remove-record-deprecated',
|
9961
|
+
until: '2.0.0'
|
9972
9962
|
});
|
9973
9963
|
this.removeObject(record);
|
9974
|
-
},
|
9975
|
-
|
9976
|
-
/**
|
9977
|
-
Get a filtered subset of the underlying `ManyArray`.
|
9978
|
-
The subset updates when a record would match or mismatch the
|
9979
|
-
specified filter parameters.
|
9980
|
-
Example
|
9981
|
-
```javascript
|
9982
|
-
var post = store.peekRecord('post', 1)
|
9983
|
-
// All the comments that are deleted locally but not yet saved to the server.
|
9984
|
-
var deletedComments = post.get('comments').filterBy('isDeleted');
|
9985
|
-
```
|
9986
|
-
@method filterBy
|
9987
|
-
@param {String} key property path
|
9988
|
-
@param {*} value optional
|
9989
|
-
*/
|
9990
|
-
filterBy: function (key, value) {
|
9991
|
-
// only pass value to the arguments if it is present; this mimics the same
|
9992
|
-
// behavior for `filterBy`: http://git.io/vIurH
|
9993
|
-
var filterByArgs = [key];
|
9994
|
-
if (arguments.length === 2) {
|
9995
|
-
filterByArgs.push(value);
|
9996
|
-
}
|
9997
|
-
|
9998
|
-
return ember$data$lib$system$record$arrays$filtered$subset$$default.create({
|
9999
|
-
filterByArgs: filterByArgs,
|
10000
|
-
recordArray: this
|
10001
|
-
});
|
10002
9964
|
}
|
10003
9965
|
});
|
10004
9966
|
|
@@ -10072,7 +10034,7 @@
|
|
10072
10034
|
ember$data$lib$system$relationships$state$has$many$$ManyRelationship.prototype._super$updateMeta = ember$data$lib$system$relationships$state$relationship$$default.prototype.updateMeta;
|
10073
10035
|
ember$data$lib$system$relationships$state$has$many$$ManyRelationship.prototype.updateMeta = function (meta) {
|
10074
10036
|
this._super$updateMeta(meta);
|
10075
|
-
this.manyArray.set(
|
10037
|
+
this.manyArray.set('meta', meta);
|
10076
10038
|
};
|
10077
10039
|
|
10078
10040
|
ember$data$lib$system$relationships$state$has$many$$ManyRelationship.prototype._super$addCanonicalRecord = ember$data$lib$system$relationships$state$relationship$$default.prototype.addCanonicalRecord;
|
@@ -10145,7 +10107,7 @@
|
|
10145
10107
|
} else {
|
10146
10108
|
return this.store.scheduleFetchMany(this.manyArray.toArray()).then(function () {
|
10147
10109
|
//Goes away after the manyArray refactor
|
10148
|
-
self.manyArray.set(
|
10110
|
+
self.manyArray.set('isLoaded', true);
|
10149
10111
|
return self.manyArray;
|
10150
10112
|
});
|
10151
10113
|
}
|
@@ -10187,7 +10149,7 @@
|
|
10187
10149
|
var _this = this;
|
10188
10150
|
|
10189
10151
|
return this.store.findHasMany(this.record, this.link, this.relationshipMeta).then(function (records) {
|
10190
|
-
if (records.hasOwnProperty(
|
10152
|
+
if (records.hasOwnProperty('meta')) {
|
10191
10153
|
_this.updateMeta(records.meta);
|
10192
10154
|
}
|
10193
10155
|
_this.store._backburner.join(function () {
|
@@ -10204,7 +10166,7 @@
|
|
10204
10166
|
return rec._internalModel;
|
10205
10167
|
})).then(function () {
|
10206
10168
|
//Goes away after the manyArray refactor
|
10207
|
-
manyArray.set(
|
10169
|
+
manyArray.set('isLoaded', true);
|
10208
10170
|
return manyArray;
|
10209
10171
|
});
|
10210
10172
|
};
|
@@ -10229,11 +10191,11 @@
|
|
10229
10191
|
promise: promise
|
10230
10192
|
});
|
10231
10193
|
} else {
|
10232
|
-
Ember.assert("You looked up the '" + this.key + "' relationship on a '" + this.record.type.modelName + "' with id " + this.record.id + " but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.hasMany({ async: true })`)", this.manyArray.isEvery(
|
10194
|
+
Ember.assert("You looked up the '" + this.key + "' relationship on a '" + this.record.type.modelName + "' with id " + this.record.id + " but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.hasMany({ async: true })`)", this.manyArray.isEvery('isEmpty', false));
|
10233
10195
|
|
10234
10196
|
//TODO(Igor) WTF DO I DO HERE?
|
10235
|
-
if (!this.manyArray.get(
|
10236
|
-
this.manyArray.set(
|
10197
|
+
if (!this.manyArray.get('isDestroyed')) {
|
10198
|
+
this.manyArray.set('isLoaded', true);
|
10237
10199
|
}
|
10238
10200
|
return this.manyArray;
|
10239
10201
|
}
|
@@ -10327,7 +10289,7 @@
|
|
10327
10289
|
};
|
10328
10290
|
|
10329
10291
|
ember$data$lib$system$relationships$state$belongs$to$$BelongsToRelationship.prototype.setRecordPromise = function (newPromise) {
|
10330
|
-
var content = newPromise.get && newPromise.get(
|
10292
|
+
var content = newPromise.get && newPromise.get('content');
|
10331
10293
|
Ember.assert("You passed in a promise that did not originate from an EmberData relationship. You can only pass promises that come from a belongsTo or hasMany relationship to the get call.", content !== undefined);
|
10332
10294
|
this.setRecord(content ? content._internalModel : content);
|
10333
10295
|
};
|
@@ -10391,7 +10353,7 @@
|
|
10391
10353
|
return null;
|
10392
10354
|
}
|
10393
10355
|
var toReturn = this.inverseRecord.getRecord();
|
10394
|
-
Ember.assert("You looked up the '" + this.key + "' relationship on a '" + this.record.type.modelName + "' with id " + this.record.id + " but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.belongsTo({ async: true })`)", toReturn === null || !toReturn.get(
|
10356
|
+
Ember.assert("You looked up the '" + this.key + "' relationship on a '" + this.record.type.modelName + "' with id " + this.record.id + " but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.belongsTo({ async: true })`)", toReturn === null || !toReturn.get('isEmpty'));
|
10395
10357
|
return toReturn;
|
10396
10358
|
}
|
10397
10359
|
};
|
@@ -10408,7 +10370,7 @@
|
|
10408
10370
|
inverseKey = inverse.name;
|
10409
10371
|
}
|
10410
10372
|
|
10411
|
-
if (relationshipMeta.kind ===
|
10373
|
+
if (relationshipMeta.kind === 'hasMany') {
|
10412
10374
|
return new ember$data$lib$system$relationships$state$has$many$$default(store, record, inverseKey, relationshipMeta);
|
10413
10375
|
} else {
|
10414
10376
|
return new ember$data$lib$system$relationships$state$belongs$to$$default(store, record, inverseKey, relationshipMeta);
|
@@ -10426,7 +10388,7 @@
|
|
10426
10388
|
|
10427
10389
|
ember$data$lib$system$relationships$state$create$$Relationships.prototype.get = function (key) {
|
10428
10390
|
var relationships = this.initializedRelationships;
|
10429
|
-
var relationshipsByName = ember$data$lib$system$relationships$state$create$$get(this.record.type,
|
10391
|
+
var relationshipsByName = ember$data$lib$system$relationships$state$create$$get(this.record.type, 'relationshipsByName');
|
10430
10392
|
if (!relationships[key] && relationshipsByName.get(key)) {
|
10431
10393
|
relationships[key] = ember$data$lib$system$relationships$state$create$$createRelationshipFor(this.record, relationshipsByName.get(key), this.record.store);
|
10432
10394
|
}
|
@@ -10436,17 +10398,17 @@
|
|
10436
10398
|
var ember$data$lib$system$relationships$state$create$$default = ember$data$lib$system$relationships$state$create$$Relationships;
|
10437
10399
|
|
10438
10400
|
/**
|
10439
|
-
@module ember-data
|
10440
|
-
*/
|
10441
|
-
|
10442
|
-
var ember$data$lib$system$snapshot$$get = Ember.get;/**
|
10443
10401
|
@class Snapshot
|
10444
10402
|
@namespace DS
|
10445
10403
|
@private
|
10446
10404
|
@constructor
|
10447
10405
|
@param {DS.Model} internalModel The model to create a snapshot from
|
10448
10406
|
*/
|
10449
|
-
|
10407
|
+
/**
|
10408
|
+
@module ember-data
|
10409
|
+
*/
|
10410
|
+
|
10411
|
+
var ember$data$lib$system$snapshot$$get = Ember.get;function ember$data$lib$system$snapshot$$Snapshot(internalModel) {
|
10450
10412
|
this._attributes = ember$data$lib$system$object$polyfills$$create(null);
|
10451
10413
|
this._belongsToRelationships = ember$data$lib$system$object$polyfills$$create(null);
|
10452
10414
|
this._belongsToIds = ember$data$lib$system$object$polyfills$$create(null);
|
@@ -10556,7 +10518,7 @@
|
|
10556
10518
|
if (keyName in this._attributes) {
|
10557
10519
|
return this._attributes[keyName];
|
10558
10520
|
}
|
10559
|
-
throw new Ember.Error(
|
10521
|
+
throw new Ember.Error("Model '" + Ember.inspect(this.record) + "' has no attribute named '" + keyName + "' defined.");
|
10560
10522
|
},
|
10561
10523
|
|
10562
10524
|
/**
|
@@ -10638,7 +10600,7 @@
|
|
10638
10600
|
|
10639
10601
|
relationship = this._internalModel._relationships.get(keyName);
|
10640
10602
|
if (!(relationship && relationship.relationshipMeta.kind === 'belongsTo')) {
|
10641
|
-
throw new Ember.Error(
|
10603
|
+
throw new Ember.Error("Model '" + Ember.inspect(this.record) + "' has no belongsTo relationship named '" + keyName + "' defined.");
|
10642
10604
|
}
|
10643
10605
|
|
10644
10606
|
hasData = ember$data$lib$system$snapshot$$get(relationship, 'hasData');
|
@@ -10702,7 +10664,7 @@
|
|
10702
10664
|
|
10703
10665
|
relationship = this._internalModel._relationships.get(keyName);
|
10704
10666
|
if (!(relationship && relationship.relationshipMeta.kind === 'hasMany')) {
|
10705
|
-
throw new Ember.Error(
|
10667
|
+
throw new Ember.Error("Model '" + Ember.inspect(this.record) + "' has no hasMany relationship named '" + keyName + "' defined.");
|
10706
10668
|
}
|
10707
10669
|
|
10708
10670
|
hasData = ember$data$lib$system$snapshot$$get(relationship, 'hasData');
|
@@ -10820,7 +10782,7 @@
|
|
10820
10782
|
@private
|
10821
10783
|
*/
|
10822
10784
|
_createSnapshot: function () {
|
10823
|
-
Ember.deprecate(
|
10785
|
+
Ember.deprecate("You called _createSnapshot on what's already a DS.Snapshot. You shouldn't manually create snapshots in your adapter since the store passes snapshots to adapters by default.", false, {
|
10824
10786
|
id: 'ds.snapshot.create-snapshot-on-snapshot',
|
10825
10787
|
until: '2.0.0'
|
10826
10788
|
});
|
@@ -10854,7 +10816,7 @@
|
|
10854
10816
|
var ember$data$lib$system$model$internal$model$$_splitOnDotCache = ember$data$lib$system$object$polyfills$$create(null);
|
10855
10817
|
|
10856
10818
|
function ember$data$lib$system$model$internal$model$$splitOnDot(name) {
|
10857
|
-
return ember$data$lib$system$model$internal$model$$_splitOnDotCache[name] || (ember$data$lib$system$model$internal$model$$_splitOnDotCache[name] = name.split(
|
10819
|
+
return ember$data$lib$system$model$internal$model$$_splitOnDotCache[name] || (ember$data$lib$system$model$internal$model$$_splitOnDotCache[name] = name.split('.'));
|
10858
10820
|
}
|
10859
10821
|
|
10860
10822
|
function ember$data$lib$system$model$internal$model$$extractPivotName(name) {
|
@@ -10925,15 +10887,15 @@
|
|
10925
10887
|
};
|
10926
10888
|
|
10927
10889
|
ember$data$lib$system$model$internal$model$$InternalModel.prototype = {
|
10928
|
-
isEmpty: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
10929
|
-
isLoading: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
10930
|
-
isLoaded: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
10931
|
-
hasDirtyAttributes: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
10932
|
-
isSaving: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
10933
|
-
isDeleted: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
10934
|
-
isNew: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
10935
|
-
isValid: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
10936
|
-
dirtyType: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState(
|
10890
|
+
isEmpty: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('isEmpty'),
|
10891
|
+
isLoading: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('isLoading'),
|
10892
|
+
isLoaded: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('isLoaded'),
|
10893
|
+
hasDirtyAttributes: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('hasDirtyAttributes'),
|
10894
|
+
isSaving: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('isSaving'),
|
10895
|
+
isDeleted: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('isDeleted'),
|
10896
|
+
isNew: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('isNew'),
|
10897
|
+
isValid: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('isValid'),
|
10898
|
+
dirtyType: ember$data$lib$system$model$internal$model$$retrieveFromCurrentState('dirtyType'),
|
10937
10899
|
|
10938
10900
|
constructor: ember$data$lib$system$model$internal$model$$InternalModel,
|
10939
10901
|
materializeRecord: function () {
|
@@ -10945,7 +10907,7 @@
|
|
10945
10907
|
store: this.store,
|
10946
10908
|
container: this.container,
|
10947
10909
|
_internalModel: this,
|
10948
|
-
currentState: ember$data$lib$system$model$internal$model$$get(this,
|
10910
|
+
currentState: ember$data$lib$system$model$internal$model$$get(this, 'currentState'),
|
10949
10911
|
isError: this.isError,
|
10950
10912
|
adapterError: this.error
|
10951
10913
|
});
|
@@ -10957,7 +10919,7 @@
|
|
10957
10919
|
},
|
10958
10920
|
|
10959
10921
|
deleteRecord: function () {
|
10960
|
-
this.send(
|
10922
|
+
this.send('deleteRecord');
|
10961
10923
|
},
|
10962
10924
|
|
10963
10925
|
save: function (options) {
|
@@ -10971,14 +10933,14 @@
|
|
10971
10933
|
startedReloading: function () {
|
10972
10934
|
this.isReloading = true;
|
10973
10935
|
if (this.record) {
|
10974
|
-
ember$data$lib$system$model$internal$model$$set(this.record,
|
10936
|
+
ember$data$lib$system$model$internal$model$$set(this.record, 'isReloading', true);
|
10975
10937
|
}
|
10976
10938
|
},
|
10977
10939
|
|
10978
10940
|
finishedReloading: function () {
|
10979
10941
|
this.isReloading = false;
|
10980
10942
|
if (this.record) {
|
10981
|
-
ember$data$lib$system$model$internal$model$$set(this.record,
|
10943
|
+
ember$data$lib$system$model$internal$model$$set(this.record, 'isReloading', false);
|
10982
10944
|
}
|
10983
10945
|
},
|
10984
10946
|
|
@@ -10987,7 +10949,7 @@
|
|
10987
10949
|
var record = this;
|
10988
10950
|
var promiseLabel = "DS: Model#reload of " + this;
|
10989
10951
|
return new ember$data$lib$system$model$internal$model$$Promise(function (resolve) {
|
10990
|
-
record.send(
|
10952
|
+
record.send('reloadRecord', resolve);
|
10991
10953
|
}, promiseLabel).then(function () {
|
10992
10954
|
record.didCleanError();
|
10993
10955
|
return record;
|
@@ -11008,7 +10970,7 @@
|
|
11008
10970
|
},
|
11009
10971
|
|
11010
10972
|
unloadRecord: function () {
|
11011
|
-
this.send(
|
10973
|
+
this.send('unloadRecord');
|
11012
10974
|
},
|
11013
10975
|
|
11014
10976
|
eachRelationship: function (callback, binding) {
|
@@ -11034,7 +10996,7 @@
|
|
11034
10996
|
},
|
11035
10997
|
|
11036
10998
|
becameReady: function () {
|
11037
|
-
Ember.run.schedule(
|
10999
|
+
Ember.run.schedule('actions', this.store.recordArrayManager, this.store.recordArrayManager.recordWasLoaded, this);
|
11038
11000
|
},
|
11039
11001
|
|
11040
11002
|
didInitalizeData: function () {
|
@@ -11067,7 +11029,7 @@
|
|
11067
11029
|
@param {Promise} promise
|
11068
11030
|
*/
|
11069
11031
|
loadingData: function (promise) {
|
11070
|
-
this.send(
|
11032
|
+
this.send('loadingData', promise);
|
11071
11033
|
},
|
11072
11034
|
|
11073
11035
|
/**
|
@@ -11075,7 +11037,7 @@
|
|
11075
11037
|
@private
|
11076
11038
|
*/
|
11077
11039
|
loadedData: function () {
|
11078
|
-
this.send(
|
11040
|
+
this.send('loadedData');
|
11079
11041
|
this.didInitalizeData();
|
11080
11042
|
},
|
11081
11043
|
|
@@ -11084,7 +11046,7 @@
|
|
11084
11046
|
@private
|
11085
11047
|
*/
|
11086
11048
|
notFound: function () {
|
11087
|
-
this.send(
|
11049
|
+
this.send('notFound');
|
11088
11050
|
},
|
11089
11051
|
|
11090
11052
|
/**
|
@@ -11092,7 +11054,7 @@
|
|
11092
11054
|
@private
|
11093
11055
|
*/
|
11094
11056
|
pushedData: function () {
|
11095
|
-
this.send(
|
11057
|
+
this.send('pushedData');
|
11096
11058
|
},
|
11097
11059
|
|
11098
11060
|
flushChangedAttributes: function () {
|
@@ -11105,7 +11067,7 @@
|
|
11105
11067
|
@private
|
11106
11068
|
*/
|
11107
11069
|
adapterWillCommit: function () {
|
11108
|
-
this.send(
|
11070
|
+
this.send('willCommit');
|
11109
11071
|
},
|
11110
11072
|
|
11111
11073
|
/**
|
@@ -11113,7 +11075,7 @@
|
|
11113
11075
|
@private
|
11114
11076
|
*/
|
11115
11077
|
adapterDidDirty: function () {
|
11116
|
-
this.send(
|
11078
|
+
this.send('becomeDirty');
|
11117
11079
|
this.updateRecordArraysLater();
|
11118
11080
|
},
|
11119
11081
|
|
@@ -11124,7 +11086,7 @@
|
|
11124
11086
|
@param {Object} context
|
11125
11087
|
*/
|
11126
11088
|
send: function (name, context) {
|
11127
|
-
var currentState = ember$data$lib$system$model$internal$model$$get(this,
|
11089
|
+
var currentState = ember$data$lib$system$model$internal$model$$get(this, 'currentState');
|
11128
11090
|
|
11129
11091
|
if (!currentState[name]) {
|
11130
11092
|
this._unhandledEvent(currentState, name, context);
|
@@ -11162,7 +11124,7 @@
|
|
11162
11124
|
|
11163
11125
|
this._attributes = ember$data$lib$system$object$polyfills$$create(null);
|
11164
11126
|
|
11165
|
-
if (ember$data$lib$system$model$internal$model$$get(this,
|
11127
|
+
if (ember$data$lib$system$model$internal$model$$get(this, 'isError')) {
|
11166
11128
|
this._inFlightAttributes = ember$data$lib$system$object$polyfills$$create(null);
|
11167
11129
|
this.didCleanError();
|
11168
11130
|
}
|
@@ -11184,7 +11146,7 @@
|
|
11184
11146
|
this._inFlightAttributes = ember$data$lib$system$object$polyfills$$create(null);
|
11185
11147
|
}
|
11186
11148
|
|
11187
|
-
this.send(
|
11149
|
+
this.send('rolledBack');
|
11188
11150
|
|
11189
11151
|
this.record._notifyProperties(dirtyKeys);
|
11190
11152
|
},
|
@@ -11198,7 +11160,7 @@
|
|
11198
11160
|
// always having direct reference to state objects
|
11199
11161
|
|
11200
11162
|
var pivotName = ember$data$lib$system$model$internal$model$$extractPivotName(name);
|
11201
|
-
var currentState = ember$data$lib$system$model$internal$model$$get(this,
|
11163
|
+
var currentState = ember$data$lib$system$model$internal$model$$get(this, 'currentState');
|
11202
11164
|
var state = currentState;
|
11203
11165
|
|
11204
11166
|
do {
|
@@ -11228,10 +11190,10 @@
|
|
11228
11190
|
enters[i].enter(this);
|
11229
11191
|
}
|
11230
11192
|
|
11231
|
-
ember$data$lib$system$model$internal$model$$set(this,
|
11193
|
+
ember$data$lib$system$model$internal$model$$set(this, 'currentState', state);
|
11232
11194
|
//TODO Consider whether this is the best approach for keeping these two in sync
|
11233
11195
|
if (this.record) {
|
11234
|
-
ember$data$lib$system$model$internal$model$$set(this.record,
|
11196
|
+
ember$data$lib$system$model$internal$model$$set(this.record, 'currentState', state);
|
11235
11197
|
}
|
11236
11198
|
|
11237
11199
|
for (i = 0, l = setups.length; i < l; i++) {
|
@@ -11264,7 +11226,7 @@
|
|
11264
11226
|
if (this._deferredTriggers.push(args) !== 1) {
|
11265
11227
|
return;
|
11266
11228
|
}
|
11267
|
-
Ember.run.scheduleOnce(
|
11229
|
+
Ember.run.scheduleOnce('actions', this, '_triggerDeferredTriggers');
|
11268
11230
|
},
|
11269
11231
|
|
11270
11232
|
_triggerDeferredTriggers: function () {
|
@@ -11350,7 +11312,7 @@
|
|
11350
11312
|
_preloadRelationship: function (key, preloadValue) {
|
11351
11313
|
var relationshipMeta = this.type.metaForProperty(key);
|
11352
11314
|
var type = relationshipMeta.type;
|
11353
|
-
if (relationshipMeta.kind ===
|
11315
|
+
if (relationshipMeta.kind === 'hasMany') {
|
11354
11316
|
this._preloadHasMany(key, preloadValue, type);
|
11355
11317
|
} else {
|
11356
11318
|
this._preloadBelongsTo(key, preloadValue, type);
|
@@ -11378,7 +11340,7 @@
|
|
11378
11340
|
},
|
11379
11341
|
|
11380
11342
|
_convertStringOrNumberIntoInternalModel: function (value, type) {
|
11381
|
-
if (typeof value ===
|
11343
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
11382
11344
|
return this.store._internalModelForId(type, value);
|
11383
11345
|
}
|
11384
11346
|
if (value._internalModel) {
|
@@ -11399,7 +11361,7 @@
|
|
11399
11361
|
setId: function (id) {
|
11400
11362
|
this.id = id;
|
11401
11363
|
//TODO figure out whether maybe we should proxy
|
11402
|
-
ember$data$lib$system$model$internal$model$$set(this.record,
|
11364
|
+
ember$data$lib$system$model$internal$model$$set(this.record, 'id', id);
|
11403
11365
|
},
|
11404
11366
|
|
11405
11367
|
didError: function (error) {
|
@@ -11446,7 +11408,7 @@
|
|
11446
11408
|
|
11447
11409
|
this._inFlightAttributes = ember$data$lib$system$object$polyfills$$create(null);
|
11448
11410
|
|
11449
|
-
this.send(
|
11411
|
+
this.send('didCommit');
|
11450
11412
|
this.updateRecordArraysLater();
|
11451
11413
|
|
11452
11414
|
if (!data) {
|
@@ -11466,22 +11428,22 @@
|
|
11466
11428
|
return;
|
11467
11429
|
}
|
11468
11430
|
this._updatingRecordArraysLater = true;
|
11469
|
-
Ember.run.schedule(
|
11431
|
+
Ember.run.schedule('actions', this, this.updateRecordArrays);
|
11470
11432
|
},
|
11471
11433
|
|
11472
11434
|
addErrorMessageToAttribute: function (attribute, message) {
|
11473
11435
|
var record = this.getRecord();
|
11474
|
-
ember$data$lib$system$model$internal$model$$get(record,
|
11436
|
+
ember$data$lib$system$model$internal$model$$get(record, 'errors').add(attribute, message);
|
11475
11437
|
},
|
11476
11438
|
|
11477
11439
|
removeErrorMessageFromAttribute: function (attribute) {
|
11478
11440
|
var record = this.getRecord();
|
11479
|
-
ember$data$lib$system$model$internal$model$$get(record,
|
11441
|
+
ember$data$lib$system$model$internal$model$$get(record, 'errors').remove(attribute);
|
11480
11442
|
},
|
11481
11443
|
|
11482
11444
|
clearErrorMessages: function () {
|
11483
11445
|
var record = this.getRecord();
|
11484
|
-
ember$data$lib$system$model$internal$model$$get(record,
|
11446
|
+
ember$data$lib$system$model$internal$model$$get(record, 'errors').clear();
|
11485
11447
|
},
|
11486
11448
|
|
11487
11449
|
// FOR USE DURING COMMIT PROCESS
|
@@ -11507,7 +11469,7 @@
|
|
11507
11469
|
@private
|
11508
11470
|
*/
|
11509
11471
|
adapterDidError: function (error) {
|
11510
|
-
this.send(
|
11472
|
+
this.send('becameError');
|
11511
11473
|
this.didError(error);
|
11512
11474
|
this._saveWasRejected();
|
11513
11475
|
},
|
@@ -11597,15 +11559,15 @@
|
|
11597
11559
|
|
11598
11560
|
var ember$data$lib$system$model$internal$model$$default = ember$data$lib$system$model$internal$model$$InternalModel;
|
11599
11561
|
|
11600
|
-
var ember$data$lib$system$store$$Backburner = Ember._Backburner || Ember.Backburner || Ember.__loader.require(
|
11562
|
+
var ember$data$lib$system$store$$Backburner = Ember._Backburner || Ember.Backburner || Ember.__loader.require('backburner')['default'] || Ember.__loader.require('backburner')['Backburner'];
|
11601
11563
|
|
11602
11564
|
//Shim Backburner.join
|
11603
11565
|
if (!ember$data$lib$system$store$$Backburner.prototype.join) {
|
11604
11566
|
var ember$data$lib$system$store$$isString = function (suspect) {
|
11605
|
-
return typeof suspect ===
|
11567
|
+
return typeof suspect === 'string';
|
11606
11568
|
};
|
11607
11569
|
|
11608
|
-
ember$data$lib$system$store$$Backburner.prototype.join = function () {
|
11570
|
+
ember$data$lib$system$store$$Backburner.prototype.join = function () /*target, method, args */{
|
11609
11571
|
var method, target;
|
11610
11572
|
|
11611
11573
|
if (this.currentInstance) {
|
@@ -11760,7 +11722,7 @@
|
|
11760
11722
|
@private
|
11761
11723
|
*/
|
11762
11724
|
init: function () {
|
11763
|
-
this._backburner = new ember$data$lib$system$store$$Backburner([
|
11725
|
+
this._backburner = new ember$data$lib$system$store$$Backburner(['normalizeRelationships', 'syncRelationships', 'finished']);
|
11764
11726
|
// internal bookkeeping; not observable
|
11765
11727
|
this.typeMaps = {};
|
11766
11728
|
this.recordArrayManager = ember$data$lib$system$record$array$manager$$default.create({
|
@@ -11783,7 +11745,7 @@
|
|
11783
11745
|
@default DS.RESTAdapter
|
11784
11746
|
@type {(DS.Adapter|String)}
|
11785
11747
|
*/
|
11786
|
-
adapter:
|
11748
|
+
adapter: '-rest',
|
11787
11749
|
|
11788
11750
|
/**
|
11789
11751
|
Returns a JSON representation of the record using a custom
|
@@ -11813,12 +11775,12 @@
|
|
11813
11775
|
@private
|
11814
11776
|
@return DS.Adapter
|
11815
11777
|
*/
|
11816
|
-
defaultAdapter: Ember.computed(
|
11817
|
-
var adapter = ember$data$lib$system$store$$get(this,
|
11778
|
+
defaultAdapter: Ember.computed('adapter', function () {
|
11779
|
+
var adapter = ember$data$lib$system$store$$get(this, 'adapter');
|
11818
11780
|
|
11819
|
-
Ember.assert(
|
11781
|
+
Ember.assert('You tried to set `adapter` property to an instance of `DS.Adapter`, where it should be a name', typeof adapter === 'string');
|
11820
11782
|
|
11821
|
-
adapter = this.retrieveManagedInstance(
|
11783
|
+
adapter = this.retrieveManagedInstance('adapter', adapter);
|
11822
11784
|
|
11823
11785
|
return adapter;
|
11824
11786
|
}),
|
@@ -11851,7 +11813,7 @@
|
|
11851
11813
|
@return {DS.Model} record
|
11852
11814
|
*/
|
11853
11815
|
createRecord: function (modelName, inputProperties) {
|
11854
|
-
Ember.assert(
|
11816
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
11855
11817
|
var typeClass = this.modelFor(modelName);
|
11856
11818
|
var properties = ember$data$lib$system$store$$copy(inputProperties) || ember$data$lib$system$object$polyfills$$create(null);
|
11857
11819
|
|
@@ -11993,25 +11955,25 @@
|
|
11993
11955
|
find: function (modelName, id, preload) {
|
11994
11956
|
Ember.assert("You need to pass a type to the store's find method", arguments.length >= 1);
|
11995
11957
|
Ember.assert("You may not pass `" + id + "` as id to the store's find method", arguments.length === 1 || !Ember.isNone(id));
|
11996
|
-
Ember.assert(
|
11958
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
11997
11959
|
|
11998
11960
|
if (arguments.length === 1) {
|
11999
|
-
Ember.deprecate(
|
12000
|
-
id:
|
12001
|
-
until:
|
11961
|
+
Ember.deprecate('Using store.find(type) has been deprecated. Use store.findAll(type) to retrieve all records for a given type.', false, {
|
11962
|
+
id: 'ds.store.find-with-type-deprecated',
|
11963
|
+
until: '2.0.0'
|
12002
11964
|
});
|
12003
11965
|
return this.findAll(modelName);
|
12004
11966
|
}
|
12005
11967
|
|
12006
11968
|
// We are passed a query instead of an id.
|
12007
|
-
if (Ember.typeOf(id) ===
|
12008
|
-
Ember.deprecate(
|
12009
|
-
id:
|
12010
|
-
until:
|
11969
|
+
if (Ember.typeOf(id) === 'object') {
|
11970
|
+
Ember.deprecate('Calling store.find() with a query object is deprecated. Use store.query() instead.', false, {
|
11971
|
+
id: 'ds.store.find-with-type-deprecated',
|
11972
|
+
until: '2.0.0'
|
12011
11973
|
});
|
12012
11974
|
return this.query(modelName, id);
|
12013
11975
|
}
|
12014
|
-
var options = ember$data$lib$system$store$$deprecatePreload(preload, this.modelFor(modelName),
|
11976
|
+
var options = ember$data$lib$system$store$$deprecatePreload(preload, this.modelFor(modelName), 'find');
|
12015
11977
|
return this.findRecord(modelName, ember$data$lib$system$coerce$id$$default(id), options);
|
12016
11978
|
},
|
12017
11979
|
|
@@ -12025,11 +11987,11 @@
|
|
12025
11987
|
@return {Promise} promise
|
12026
11988
|
*/
|
12027
11989
|
fetchById: function (modelName, id, preload) {
|
12028
|
-
Ember.assert(
|
12029
|
-
var options = ember$data$lib$system$store$$deprecatePreload(preload, this.modelFor(modelName),
|
12030
|
-
Ember.deprecate(
|
12031
|
-
id:
|
12032
|
-
until:
|
11990
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
11991
|
+
var options = ember$data$lib$system$store$$deprecatePreload(preload, this.modelFor(modelName), 'fetchById');
|
11992
|
+
Ember.deprecate('Using store.fetchById(type, id) has been deprecated. Use store.findRecord(type, id, { reload: true }) to reload a record for a given type.', false, {
|
11993
|
+
id: 'ds.store.fetch-by-id-deprecated',
|
11994
|
+
until: '2.0.0'
|
12033
11995
|
});
|
12034
11996
|
if (this.hasRecordForId(modelName, id)) {
|
12035
11997
|
return this.peekRecord(modelName, id).reload();
|
@@ -12047,9 +12009,9 @@
|
|
12047
12009
|
@return {Promise} promise
|
12048
12010
|
*/
|
12049
12011
|
fetchAll: function (modelName) {
|
12050
|
-
Ember.deprecate(
|
12051
|
-
id:
|
12052
|
-
until:
|
12012
|
+
Ember.deprecate('Using store.fetchAll(type) has been deprecated. Use store.findAll(type, { reload: true }) to retrieve all records for a given type.', false, {
|
12013
|
+
id: 'ds.store.fetch-all-deprecated',
|
12014
|
+
until: '2.0.0'
|
12053
12015
|
});
|
12054
12016
|
return this.findAll(modelName, { reload: true });
|
12055
12017
|
},
|
@@ -12063,10 +12025,10 @@
|
|
12063
12025
|
@deprecated Use [findRecord](#method_findRecord) instead
|
12064
12026
|
*/
|
12065
12027
|
fetch: function (modelName, id, preload) {
|
12066
|
-
Ember.assert(
|
12067
|
-
Ember.deprecate(
|
12068
|
-
id:
|
12069
|
-
until:
|
12028
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
12029
|
+
Ember.deprecate('Using store.fetch() has been deprecated. Use store.findRecord for fetching individual records or store.findAll for collections', false, {
|
12030
|
+
id: 'ds.store.fetch-deprecated',
|
12031
|
+
until: '2.0.0'
|
12070
12032
|
});
|
12071
12033
|
return this.findRecord(modelName, id, { reload: true, preload: preload });
|
12072
12034
|
},
|
@@ -12081,11 +12043,11 @@
|
|
12081
12043
|
@return {Promise} promise
|
12082
12044
|
*/
|
12083
12045
|
findById: function (modelName, id, preload) {
|
12084
|
-
Ember.deprecate(
|
12085
|
-
id:
|
12086
|
-
until:
|
12046
|
+
Ember.deprecate('Using store.findById() has been deprecated. Use store.findRecord() to return a record for a given type and id combination.', false, {
|
12047
|
+
id: 'ds.store.find-by-id-deprecated',
|
12048
|
+
until: '2.0.0'
|
12087
12049
|
});
|
12088
|
-
var options = ember$data$lib$system$store$$deprecatePreload(preload, this.modelFor(modelName),
|
12050
|
+
var options = ember$data$lib$system$store$$deprecatePreload(preload, this.modelFor(modelName), 'findById');
|
12089
12051
|
return this.findRecord(modelName, id, options);
|
12090
12052
|
},
|
12091
12053
|
|
@@ -12124,7 +12086,7 @@
|
|
12124
12086
|
@return {Promise} promise
|
12125
12087
|
*/
|
12126
12088
|
findRecord: function (modelName, id, options) {
|
12127
|
-
Ember.assert(
|
12089
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
12128
12090
|
var internalModel = this._internalModelForId(modelName, id);
|
12129
12091
|
options = options || {};
|
12130
12092
|
|
@@ -12134,7 +12096,7 @@
|
|
12134
12096
|
|
12135
12097
|
var fetchedInternalModel = this._findRecord(internalModel, options);
|
12136
12098
|
|
12137
|
-
return ember$data$lib$system$store$$promiseRecord(fetchedInternalModel, "DS: Store#findRecord " + internalModel.typeKey + " with id: " + ember$data$lib$system$store$$get(internalModel,
|
12099
|
+
return ember$data$lib$system$store$$promiseRecord(fetchedInternalModel, "DS: Store#findRecord " + internalModel.typeKey + " with id: " + ember$data$lib$system$store$$get(internalModel, 'id'));
|
12138
12100
|
},
|
12139
12101
|
|
12140
12102
|
_findRecord: function (internalModel, options) {
|
@@ -12170,7 +12132,7 @@
|
|
12170
12132
|
|
12171
12133
|
var fetchedInternalModel = this._findEmptyInternalModel(internalModel, options);
|
12172
12134
|
|
12173
|
-
return ember$data$lib$system$store$$promiseRecord(fetchedInternalModel, "DS: Store#findRecord " + internalModel.typeKey + " with id: " + ember$data$lib$system$store$$get(internalModel,
|
12135
|
+
return ember$data$lib$system$store$$promiseRecord(fetchedInternalModel, "DS: Store#findRecord " + internalModel.typeKey + " with id: " + ember$data$lib$system$store$$get(internalModel, 'id'));
|
12174
12136
|
},
|
12175
12137
|
|
12176
12138
|
_findEmptyInternalModel: function (internalModel, options) {
|
@@ -12196,7 +12158,7 @@
|
|
12196
12158
|
@return {Promise} promise
|
12197
12159
|
*/
|
12198
12160
|
findByIds: function (modelName, ids) {
|
12199
|
-
Ember.assert(
|
12161
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
12200
12162
|
var store = this;
|
12201
12163
|
|
12202
12164
|
return ember$data$lib$system$promise$proxies$$promiseArray(Ember.RSVP.all(ember$data$lib$system$store$$map.call(ids, function (id) {
|
@@ -12220,7 +12182,7 @@
|
|
12220
12182
|
var adapter = this.adapterFor(typeClass.modelName);
|
12221
12183
|
|
12222
12184
|
Ember.assert("You tried to find a record but you have no adapter (for " + typeClass + ")", adapter);
|
12223
|
-
Ember.assert("You tried to find a record but your adapter (for " + typeClass + ") does not implement 'findRecord'", typeof adapter.findRecord ===
|
12185
|
+
Ember.assert("You tried to find a record but your adapter (for " + typeClass + ") does not implement 'findRecord'", typeof adapter.findRecord === 'function' || typeof adapter.find === 'function');
|
12224
12186
|
|
12225
12187
|
var promise = ember$data$lib$system$store$finders$$_find(adapter, this, typeClass, id, internalModel, options);
|
12226
12188
|
return promise;
|
@@ -12240,7 +12202,7 @@
|
|
12240
12202
|
return internalModel._loadingPromise;
|
12241
12203
|
}
|
12242
12204
|
|
12243
|
-
var resolver = Ember.RSVP.defer(
|
12205
|
+
var resolver = Ember.RSVP.defer('Fetching ' + typeClass + 'with id: ' + internalModel.id);
|
12244
12206
|
var pendingFetchItem = {
|
12245
12207
|
record: internalModel,
|
12246
12208
|
resolver: resolver,
|
@@ -12255,7 +12217,7 @@
|
|
12255
12217
|
} else {
|
12256
12218
|
this._pendingFetch.get(typeClass).push(pendingFetchItem);
|
12257
12219
|
}
|
12258
|
-
Ember.run.scheduleOnce(
|
12220
|
+
Ember.run.scheduleOnce('afterRender', this, this.flushAllPendingFetches);
|
12259
12221
|
|
12260
12222
|
return promise;
|
12261
12223
|
},
|
@@ -12273,7 +12235,7 @@
|
|
12273
12235
|
var store = this;
|
12274
12236
|
var adapter = store.adapterFor(typeClass.modelName);
|
12275
12237
|
var shouldCoalesce = !!adapter.findMany && adapter.coalesceFindRequests;
|
12276
|
-
var records = Ember.A(pendingFetchItems).mapBy(
|
12238
|
+
var records = Ember.A(pendingFetchItems).mapBy('record');
|
12277
12239
|
|
12278
12240
|
function _fetchRecord(recordResolverPair) {
|
12279
12241
|
recordResolverPair.resolver.resolve(store.fetchRecord(recordResolverPair.record, recordResolverPair.options)); // TODO adapter options
|
@@ -12281,7 +12243,7 @@
|
|
12281
12243
|
|
12282
12244
|
function resolveFoundRecords(records) {
|
12283
12245
|
ember$data$lib$system$store$$forEach.call(records, function (record) {
|
12284
|
-
var pair = Ember.A(pendingFetchItems).findBy(
|
12246
|
+
var pair = Ember.A(pendingFetchItems).findBy('record', record);
|
12285
12247
|
if (pair) {
|
12286
12248
|
var resolver = pair.resolver;
|
12287
12249
|
resolver.resolve(record);
|
@@ -12297,8 +12259,8 @@
|
|
12297
12259
|
return resolvedRecords.contains(record);
|
12298
12260
|
});
|
12299
12261
|
if (missingRecords.length) {
|
12300
|
-
Ember.warn(
|
12301
|
-
id:
|
12262
|
+
Ember.warn('Ember Data expected to find records with the following ids in the adapter response but they were missing: ' + Ember.inspect(Ember.A(missingRecords).mapBy('id')), false, {
|
12263
|
+
id: 'ds.store.missing-records-from-adapter'
|
12302
12264
|
});
|
12303
12265
|
}
|
12304
12266
|
rejectRecords(missingRecords);
|
@@ -12313,7 +12275,7 @@
|
|
12313
12275
|
|
12314
12276
|
function rejectRecords(records, error) {
|
12315
12277
|
ember$data$lib$system$store$$forEach.call(records, function (record) {
|
12316
|
-
var pair = Ember.A(pendingFetchItems).findBy(
|
12278
|
+
var pair = Ember.A(pendingFetchItems).findBy('record', record);
|
12317
12279
|
if (pair) {
|
12318
12280
|
var resolver = pair.resolver;
|
12319
12281
|
resolver.reject(error);
|
@@ -12336,16 +12298,16 @@
|
|
12336
12298
|
// records from the grouped snapshots even though the _findMany() finder
|
12337
12299
|
// will once again convert the records to snapshots for adapter.findMany()
|
12338
12300
|
|
12339
|
-
var snapshots = Ember.A(records).invoke(
|
12301
|
+
var snapshots = Ember.A(records).invoke('createSnapshot');
|
12340
12302
|
var groups = adapter.groupRecordsForFindMany(this, snapshots);
|
12341
12303
|
ember$data$lib$system$store$$forEach.call(groups, function (groupOfSnapshots) {
|
12342
|
-
var groupOfRecords = Ember.A(groupOfSnapshots).mapBy(
|
12304
|
+
var groupOfRecords = Ember.A(groupOfSnapshots).mapBy('_internalModel');
|
12343
12305
|
var requestedRecords = Ember.A(groupOfRecords);
|
12344
|
-
var ids = requestedRecords.mapBy(
|
12306
|
+
var ids = requestedRecords.mapBy('id');
|
12345
12307
|
if (ids.length > 1) {
|
12346
12308
|
ember$data$lib$system$store$finders$$_findMany(adapter, store, typeClass, ids, requestedRecords).then(resolveFoundRecords).then(makeMissingRecordsRejector(requestedRecords)).then(null, makeRecordsRejector(requestedRecords));
|
12347
12309
|
} else if (ids.length === 1) {
|
12348
|
-
var pair = Ember.A(pendingFetchItems).findBy(
|
12310
|
+
var pair = Ember.A(pendingFetchItems).findBy('record', groupOfRecords[0]);
|
12349
12311
|
_fetchRecord(pair);
|
12350
12312
|
} else {
|
12351
12313
|
Ember.assert("You cannot return an empty array from adapter's method groupRecordsForFindMany", false);
|
@@ -12372,9 +12334,9 @@
|
|
12372
12334
|
@return {DS.Model|null} record
|
12373
12335
|
*/
|
12374
12336
|
getById: function (modelName, id) {
|
12375
|
-
Ember.deprecate(
|
12376
|
-
id:
|
12377
|
-
until:
|
12337
|
+
Ember.deprecate('Using store.getById() has been deprecated. Use store.peekRecord to get a record by a given type and ID without triggering a fetch.', false, {
|
12338
|
+
id: 'ds.store.get-by-id-deprecated',
|
12339
|
+
until: '2.0.0'
|
12378
12340
|
});
|
12379
12341
|
return this.peekRecord(modelName, id);
|
12380
12342
|
},
|
@@ -12395,7 +12357,7 @@
|
|
12395
12357
|
@return {DS.Model|null} record
|
12396
12358
|
*/
|
12397
12359
|
peekRecord: function (modelName, id) {
|
12398
|
-
Ember.assert(
|
12360
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
12399
12361
|
if (this.hasRecordForId(modelName, id)) {
|
12400
12362
|
return this._internalModelForId(modelName, id).getRecord();
|
12401
12363
|
} else {
|
@@ -12420,7 +12382,7 @@
|
|
12420
12382
|
|
12421
12383
|
Ember.assert("You cannot reload a record without an ID", id);
|
12422
12384
|
Ember.assert("You tried to reload a record but you have no adapter (for " + modelName + ")", adapter);
|
12423
|
-
Ember.assert("You tried to reload a record but your adapter does not implement `findRecord`", typeof adapter.findRecord ===
|
12385
|
+
Ember.assert("You tried to reload a record but your adapter does not implement `findRecord`", typeof adapter.findRecord === 'function' || typeof adapter.find === 'function');
|
12424
12386
|
|
12425
12387
|
return this.scheduleFetch(internalModel);
|
12426
12388
|
},
|
@@ -12433,7 +12395,7 @@
|
|
12433
12395
|
@return {Boolean}
|
12434
12396
|
*/
|
12435
12397
|
hasRecordForId: function (modelName, inputId) {
|
12436
|
-
Ember.assert(
|
12398
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
12437
12399
|
var typeClass = this.modelFor(modelName);
|
12438
12400
|
var id = ember$data$lib$system$coerce$id$$default(inputId);
|
12439
12401
|
var internalModel = this.typeMapFor(typeClass).idToRecord[id];
|
@@ -12450,7 +12412,7 @@
|
|
12450
12412
|
@return {DS.Model} record
|
12451
12413
|
*/
|
12452
12414
|
recordForId: function (modelName, id) {
|
12453
|
-
Ember.assert(
|
12415
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
12454
12416
|
return this._internalModelForId(modelName, id).getRecord();
|
12455
12417
|
},
|
12456
12418
|
|
@@ -12499,7 +12461,7 @@
|
|
12499
12461
|
var adapter = this.adapterFor(owner.type.modelName);
|
12500
12462
|
|
12501
12463
|
Ember.assert("You tried to load a hasMany relationship but you have no adapter (for " + owner.type + ")", adapter);
|
12502
|
-
Ember.assert("You tried to load a hasMany relationship from a specified `link` in the original payload but your adapter does not implement `findHasMany`", typeof adapter.findHasMany ===
|
12464
|
+
Ember.assert("You tried to load a hasMany relationship from a specified `link` in the original payload but your adapter does not implement `findHasMany`", typeof adapter.findHasMany === 'function');
|
12503
12465
|
|
12504
12466
|
return ember$data$lib$system$store$finders$$_findHasMany(adapter, this, owner, link, relationship);
|
12505
12467
|
},
|
@@ -12516,7 +12478,7 @@
|
|
12516
12478
|
var adapter = this.adapterFor(owner.type.modelName);
|
12517
12479
|
|
12518
12480
|
Ember.assert("You tried to load a belongsTo relationship but you have no adapter (for " + owner.type + ")", adapter);
|
12519
|
-
Ember.assert("You tried to load a belongsTo relationship from a specified `link` in the original payload but your adapter does not implement `findBelongsTo`", typeof adapter.findBelongsTo ===
|
12481
|
+
Ember.assert("You tried to load a belongsTo relationship from a specified `link` in the original payload but your adapter does not implement `findBelongsTo`", typeof adapter.findBelongsTo === 'function');
|
12520
12482
|
|
12521
12483
|
return ember$data$lib$system$store$finders$$_findBelongsTo(adapter, this, owner, link, relationship);
|
12522
12484
|
},
|
@@ -12557,14 +12519,14 @@
|
|
12557
12519
|
@return {Promise} promise
|
12558
12520
|
*/
|
12559
12521
|
query: function (modelName, query) {
|
12560
|
-
Ember.assert(
|
12522
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
12561
12523
|
var typeClass = this.modelFor(modelName);
|
12562
12524
|
var array = this.recordArrayManager.createAdapterPopulatedRecordArray(typeClass, query);
|
12563
12525
|
|
12564
12526
|
var adapter = this.adapterFor(modelName);
|
12565
12527
|
|
12566
12528
|
Ember.assert("You tried to load a query but you have no adapter (for " + typeClass + ")", adapter);
|
12567
|
-
Ember.assert("You tried to load a query but your adapter does not implement `query`", typeof adapter.query ===
|
12529
|
+
Ember.assert("You tried to load a query but your adapter does not implement `query`", typeof adapter.query === 'function' || typeof adapter.findQuery === 'function');
|
12568
12530
|
|
12569
12531
|
return ember$data$lib$system$promise$proxies$$promiseArray(ember$data$lib$system$store$finders$$_query(adapter, this, typeClass, query, array));
|
12570
12532
|
},
|
@@ -12585,13 +12547,13 @@
|
|
12585
12547
|
queryRecord: function (modelName, query) {
|
12586
12548
|
Ember.assert("You need to pass a type to the store's queryRecord method", modelName);
|
12587
12549
|
Ember.assert("You need to pass a query hash to the store's queryRecord method", query);
|
12588
|
-
Ember.assert(
|
12550
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
12589
12551
|
|
12590
12552
|
var typeClass = this.modelFor(modelName);
|
12591
12553
|
var adapter = this.adapterFor(modelName);
|
12592
12554
|
|
12593
12555
|
Ember.assert("You tried to make a query but you have no adapter (for " + typeClass + ")", adapter);
|
12594
|
-
Ember.assert("You tried to make a query but your adapter does not implement `queryRecord`", typeof adapter.queryRecord ===
|
12556
|
+
Ember.assert("You tried to make a query but your adapter does not implement `queryRecord`", typeof adapter.queryRecord === 'function');
|
12595
12557
|
|
12596
12558
|
return ember$data$lib$system$promise$proxies$$promiseObject(ember$data$lib$system$store$finders$$_queryRecord(adapter, this, typeClass, query));
|
12597
12559
|
},
|
@@ -12611,9 +12573,9 @@
|
|
12611
12573
|
@deprecated Use `store.query instead`
|
12612
12574
|
*/
|
12613
12575
|
findQuery: function (modelName, query) {
|
12614
|
-
Ember.deprecate(
|
12615
|
-
id:
|
12616
|
-
until:
|
12576
|
+
Ember.deprecate('store#findQuery is deprecated. You should use store#query instead.', false, {
|
12577
|
+
id: 'ds.store.find-query-deprecated',
|
12578
|
+
until: '2.0.0'
|
12617
12579
|
});
|
12618
12580
|
return this.query(modelName, query);
|
12619
12581
|
},
|
@@ -12638,7 +12600,7 @@
|
|
12638
12600
|
@return {DS.AdapterPopulatedRecordArray}
|
12639
12601
|
*/
|
12640
12602
|
findAll: function (modelName, options) {
|
12641
|
-
Ember.assert(
|
12603
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
12642
12604
|
var typeClass = this.modelFor(modelName);
|
12643
12605
|
|
12644
12606
|
return this._fetchAll(typeClass, this.peekAll(modelName), options);
|
@@ -12656,10 +12618,10 @@
|
|
12656
12618
|
var adapter = this.adapterFor(typeClass.modelName);
|
12657
12619
|
var sinceToken = this.typeMapFor(typeClass).metadata.since;
|
12658
12620
|
|
12659
|
-
ember$data$lib$system$store$$set(array,
|
12621
|
+
ember$data$lib$system$store$$set(array, 'isUpdating', true);
|
12660
12622
|
|
12661
12623
|
Ember.assert("You tried to load all records but you have no adapter (for " + typeClass + ")", adapter);
|
12662
|
-
Ember.assert("You tried to load all records but your adapter does not implement `findAll`", typeof adapter.findAll ===
|
12624
|
+
Ember.assert("You tried to load all records but your adapter does not implement `findAll`", typeof adapter.findAll === 'function');
|
12663
12625
|
if (options.reload) {
|
12664
12626
|
return ember$data$lib$system$promise$proxies$$promiseArray(ember$data$lib$system$store$finders$$_findAll(adapter, this, typeClass, sinceToken, options));
|
12665
12627
|
}
|
@@ -12680,7 +12642,7 @@
|
|
12680
12642
|
*/
|
12681
12643
|
didUpdateAll: function (typeClass) {
|
12682
12644
|
var liveRecordArray = this.recordArrayManager.liveRecordArrayFor(typeClass);
|
12683
|
-
ember$data$lib$system$store$$set(liveRecordArray,
|
12645
|
+
ember$data$lib$system$store$$set(liveRecordArray, 'isUpdating', false);
|
12684
12646
|
},
|
12685
12647
|
|
12686
12648
|
/**
|
@@ -12702,9 +12664,9 @@
|
|
12702
12664
|
@return {DS.RecordArray}
|
12703
12665
|
*/
|
12704
12666
|
all: function (modelName) {
|
12705
|
-
Ember.deprecate(
|
12706
|
-
id:
|
12707
|
-
until:
|
12667
|
+
Ember.deprecate('Using store.all() has been deprecated. Use store.peekAll() to get all records by a given type without triggering a fetch.', false, {
|
12668
|
+
id: 'ds.store.all-renamed-deprecated',
|
12669
|
+
until: '2.0.0'
|
12708
12670
|
});
|
12709
12671
|
return this.peekAll(modelName);
|
12710
12672
|
},
|
@@ -12728,7 +12690,7 @@
|
|
12728
12690
|
@return {DS.RecordArray}
|
12729
12691
|
*/
|
12730
12692
|
peekAll: function (modelName) {
|
12731
|
-
Ember.assert(
|
12693
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
12732
12694
|
var typeClass = this.modelFor(modelName);
|
12733
12695
|
|
12734
12696
|
var liveRecordArray = this.recordArrayManager.liveRecordArrayFor(typeClass);
|
@@ -12748,7 +12710,7 @@
|
|
12748
12710
|
@param {String=} modelName
|
12749
12711
|
*/
|
12750
12712
|
unloadAll: function (modelName) {
|
12751
|
-
Ember.assert(
|
12713
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), !modelName || typeof modelName === 'string');
|
12752
12714
|
if (arguments.length === 0) {
|
12753
12715
|
var typeMaps = this.typeMaps;
|
12754
12716
|
var keys = ember$data$lib$system$object$polyfills$$keysFunc(typeMaps);
|
@@ -12772,7 +12734,7 @@
|
|
12772
12734
|
}
|
12773
12735
|
|
12774
12736
|
function byType(entry) {
|
12775
|
-
return typeMaps[entry][
|
12737
|
+
return typeMaps[entry]['type'].modelName;
|
12776
12738
|
}
|
12777
12739
|
},
|
12778
12740
|
|
@@ -12819,13 +12781,13 @@
|
|
12819
12781
|
@return {DS.PromiseArray}
|
12820
12782
|
*/
|
12821
12783
|
filter: function (modelName, query, filter) {
|
12822
|
-
Ember.assert(
|
12784
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
12823
12785
|
|
12824
12786
|
if (!Ember.ENV.ENABLE_DS_FILTER) {
|
12825
|
-
Ember.deprecate(
|
12826
|
-
url:
|
12827
|
-
id:
|
12828
|
-
until:
|
12787
|
+
Ember.deprecate('The filter API will be moved into a plugin soon. To enable store.filter using an environment flag, or to use an alternative, you can visit the ember-data-filter addon page', false, {
|
12788
|
+
url: 'https://github.com/ember-data/ember-data-filter',
|
12789
|
+
id: 'ds.store.filter-deprecated',
|
12790
|
+
until: '2.0.0'
|
12829
12791
|
});
|
12830
12792
|
}
|
12831
12793
|
|
@@ -12873,7 +12835,7 @@
|
|
12873
12835
|
@return {boolean}
|
12874
12836
|
*/
|
12875
12837
|
recordIsLoaded: function (modelName, id) {
|
12876
|
-
Ember.assert(
|
12838
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
12877
12839
|
return this.hasRecordForId(modelName, id);
|
12878
12840
|
},
|
12879
12841
|
|
@@ -12886,8 +12848,8 @@
|
|
12886
12848
|
*/
|
12887
12849
|
metadataFor: function (modelName) {
|
12888
12850
|
Ember.deprecate("`store.metadataFor()` has been deprecated. You can use `.get('meta')` on relationships and arrays returned from `store.query()`.", false, {
|
12889
|
-
id:
|
12890
|
-
until:
|
12851
|
+
id: 'ds.store.metadata-for-deprecated',
|
12852
|
+
until: '2.0.0'
|
12891
12853
|
});
|
12892
12854
|
return this._metadataFor(modelName);
|
12893
12855
|
},
|
@@ -12899,7 +12861,7 @@
|
|
12899
12861
|
@private
|
12900
12862
|
*/
|
12901
12863
|
_metadataFor: function (modelName) {
|
12902
|
-
Ember.assert(
|
12864
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
12903
12865
|
var typeClass = this.modelFor(modelName);
|
12904
12866
|
return this.typeMapFor(typeClass).metadata;
|
12905
12867
|
},
|
@@ -12914,8 +12876,8 @@
|
|
12914
12876
|
*/
|
12915
12877
|
setMetadataFor: function (modelName, metadata) {
|
12916
12878
|
Ember.deprecate("`store.setMetadataFor()` has been deprecated. Please return meta from your serializer's `extractMeta` hook.", false, {
|
12917
|
-
id:
|
12918
|
-
until:
|
12879
|
+
id: 'ds.store.set-metadata-for-deprecated',
|
12880
|
+
until: '2.0.0'
|
12919
12881
|
});
|
12920
12882
|
this._setMetadataFor(modelName, metadata);
|
12921
12883
|
},
|
@@ -12927,7 +12889,7 @@
|
|
12927
12889
|
@private
|
12928
12890
|
*/
|
12929
12891
|
_setMetadataFor: function (modelName, metadata) {
|
12930
|
-
Ember.assert(
|
12892
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
12931
12893
|
var typeClass = this.modelFor(modelName);
|
12932
12894
|
Ember.merge(this.typeMapFor(typeClass).metadata, metadata);
|
12933
12895
|
},
|
@@ -12972,7 +12934,7 @@
|
|
12972
12934
|
snapshot: snapshot,
|
12973
12935
|
resolver: resolver
|
12974
12936
|
});
|
12975
|
-
ember$data$lib$system$store$$once(this,
|
12937
|
+
ember$data$lib$system$store$$once(this, 'flushPendingSave');
|
12976
12938
|
},
|
12977
12939
|
|
12978
12940
|
/**
|
@@ -12992,14 +12954,14 @@
|
|
12992
12954
|
var adapter = this.adapterFor(record.type.modelName);
|
12993
12955
|
var operation;
|
12994
12956
|
|
12995
|
-
if (ember$data$lib$system$store$$get(record,
|
12957
|
+
if (ember$data$lib$system$store$$get(record, 'currentState.stateName') === 'root.deleted.saved') {
|
12996
12958
|
return resolver.resolve();
|
12997
12959
|
} else if (record.isNew()) {
|
12998
|
-
operation =
|
12960
|
+
operation = 'createRecord';
|
12999
12961
|
} else if (record.isDeleted()) {
|
13000
|
-
operation =
|
12962
|
+
operation = 'deleteRecord';
|
13001
12963
|
} else {
|
13002
|
-
operation =
|
12964
|
+
operation = 'updateRecord';
|
13003
12965
|
}
|
13004
12966
|
|
13005
12967
|
resolver.resolve(ember$data$lib$system$store$$_commit(adapter, this, operation, snapshot));
|
@@ -13024,7 +12986,7 @@
|
|
13024
12986
|
}
|
13025
12987
|
if (data) {
|
13026
12988
|
// normalize relationship IDs into records
|
13027
|
-
this._backburner.schedule(
|
12989
|
+
this._backburner.schedule('normalizeRelationships', this, '_setupRelationships', internalModel, internalModel.type, data);
|
13028
12990
|
this.updateId(internalModel, data);
|
13029
12991
|
}
|
13030
12992
|
|
@@ -13087,7 +13049,7 @@
|
|
13087
13049
|
@return {Object} typeMap
|
13088
13050
|
*/
|
13089
13051
|
typeMapFor: function (typeClass) {
|
13090
|
-
var typeMaps = ember$data$lib$system$store$$get(this,
|
13052
|
+
var typeMaps = ember$data$lib$system$store$$get(this, 'typeMaps');
|
13091
13053
|
var guid = Ember.guidFor(typeClass);
|
13092
13054
|
var typeMap = typeMaps[guid];
|
13093
13055
|
|
@@ -13148,10 +13110,10 @@
|
|
13148
13110
|
_modelForMixin: function (modelName) {
|
13149
13111
|
var normalizedModelName = ember$data$lib$system$normalize$model$name$$default(modelName);
|
13150
13112
|
var registry = this.container._registry ? this.container._registry : this.container;
|
13151
|
-
var mixin = registry.resolve(
|
13113
|
+
var mixin = registry.resolve('mixin:' + normalizedModelName);
|
13152
13114
|
if (mixin) {
|
13153
13115
|
//Cache the class as a model
|
13154
|
-
registry.register(
|
13116
|
+
registry.register('model:' + normalizedModelName, DS.Model.extend(mixin));
|
13155
13117
|
}
|
13156
13118
|
var factory = this.modelFactoryFor(normalizedModelName);
|
13157
13119
|
if (factory) {
|
@@ -13171,7 +13133,7 @@
|
|
13171
13133
|
@return {DS.Model}
|
13172
13134
|
*/
|
13173
13135
|
modelFor: function (modelName) {
|
13174
|
-
Ember.assert(
|
13136
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
13175
13137
|
|
13176
13138
|
var factory = this.modelFactoryFor(modelName);
|
13177
13139
|
if (!factory) {
|
@@ -13184,14 +13146,14 @@
|
|
13184
13146
|
factory.modelName = factory.modelName || ember$data$lib$system$normalize$model$name$$default(modelName);
|
13185
13147
|
|
13186
13148
|
// deprecate typeKey
|
13187
|
-
if (!(
|
13188
|
-
Ember.defineProperty(factory,
|
13149
|
+
if (!('typeKey' in factory)) {
|
13150
|
+
Ember.defineProperty(factory, 'typeKey', {
|
13189
13151
|
enumerable: true,
|
13190
13152
|
configurable: false,
|
13191
13153
|
get: function () {
|
13192
|
-
Ember.deprecate(
|
13193
|
-
id:
|
13194
|
-
until:
|
13154
|
+
Ember.deprecate('Usage of `typeKey` has been deprecated and will be removed in Ember Data 2.0. It has been replaced by `modelName` on the model class.', false, {
|
13155
|
+
id: 'ds.model.type-key-replace-by-model-name',
|
13156
|
+
until: '2.0.0'
|
13195
13157
|
});
|
13196
13158
|
var typeKey = this.modelName;
|
13197
13159
|
if (typeKey) {
|
@@ -13200,7 +13162,7 @@
|
|
13200
13162
|
return typeKey;
|
13201
13163
|
},
|
13202
13164
|
set: function () {
|
13203
|
-
Ember.assert(
|
13165
|
+
Ember.assert('Setting typeKey is not supported. In addition, typeKey has also been deprecated in favor of modelName. Setting modelName is also not supported.');
|
13204
13166
|
}
|
13205
13167
|
});
|
13206
13168
|
}
|
@@ -13209,9 +13171,9 @@
|
|
13209
13171
|
},
|
13210
13172
|
|
13211
13173
|
modelFactoryFor: function (modelName) {
|
13212
|
-
Ember.assert(
|
13174
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
13213
13175
|
var normalizedKey = ember$data$lib$system$normalize$model$name$$default(modelName);
|
13214
|
-
return this.container.lookupFactory(
|
13176
|
+
return this.container.lookupFactory('model:' + normalizedKey);
|
13215
13177
|
},
|
13216
13178
|
|
13217
13179
|
/**
|
@@ -13274,18 +13236,18 @@
|
|
13274
13236
|
|
13275
13237
|
var data, modelName;
|
13276
13238
|
|
13277
|
-
if (Ember.typeOf(modelNameArg) ===
|
13239
|
+
if (Ember.typeOf(modelNameArg) === 'object' && Ember.typeOf(dataArg) === 'undefined') {
|
13278
13240
|
data = modelNameArg;
|
13279
13241
|
} else {
|
13280
|
-
Ember.deprecate(
|
13281
|
-
id:
|
13282
|
-
until:
|
13242
|
+
Ember.deprecate('store.push(type, data) has been deprecated. Please provide a JSON-API document object as the first and only argument to store.push.', false, {
|
13243
|
+
id: 'ds.store.push-with-type-and-data-deprecated',
|
13244
|
+
until: '2.0.0'
|
13283
13245
|
});
|
13284
|
-
Ember.assert("Expected an object as `data` in a call to `push` for " + modelNameArg + " , but was " + Ember.typeOf(dataArg), Ember.typeOf(dataArg) ===
|
13285
|
-
Ember.assert("You must include an `id` for " + modelNameArg + " in an object passed to `push`", dataArg.id != null && dataArg.id !==
|
13246
|
+
Ember.assert("Expected an object as `data` in a call to `push` for " + modelNameArg + " , but was " + Ember.typeOf(dataArg), Ember.typeOf(dataArg) === 'object');
|
13247
|
+
Ember.assert("You must include an `id` for " + modelNameArg + " in an object passed to `push`", dataArg.id != null && dataArg.id !== '');
|
13286
13248
|
data = ember$data$lib$system$store$serializer$response$$_normalizeSerializerPayload(this.modelFor(modelNameArg), dataArg);
|
13287
13249
|
modelName = modelNameArg;
|
13288
|
-
Ember.assert(
|
13250
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string' || typeof data === 'undefined');
|
13289
13251
|
}
|
13290
13252
|
|
13291
13253
|
if (data.included) {
|
@@ -13294,7 +13256,7 @@
|
|
13294
13256
|
});
|
13295
13257
|
}
|
13296
13258
|
|
13297
|
-
if (Ember.typeOf(data.data) ===
|
13259
|
+
if (Ember.typeOf(data.data) === 'array') {
|
13298
13260
|
var internalModels = ember$data$lib$system$store$$map.call(data.data, function (recordData) {
|
13299
13261
|
return _this._pushInternalModel(recordData);
|
13300
13262
|
});
|
@@ -13314,8 +13276,8 @@
|
|
13314
13276
|
|
13315
13277
|
_pushInternalModel: function (data) {
|
13316
13278
|
var modelName = data.type;
|
13317
|
-
Ember.assert("Expected an object as 'data' in a call to 'push' for " + modelName + ", but was " + Ember.typeOf(data), Ember.typeOf(data) ===
|
13318
|
-
Ember.assert("You must include an 'id' for " + modelName + " in an object passed to 'push'", data.id != null && data.id !==
|
13279
|
+
Ember.assert("Expected an object as 'data' in a call to 'push' for " + modelName + ", but was " + Ember.typeOf(data), Ember.typeOf(data) === 'object');
|
13280
|
+
Ember.assert("You must include an 'id' for " + modelName + " in an object passed to 'push'", data.id != null && data.id !== '');
|
13319
13281
|
Ember.assert("You tried to push data with a type '" + modelName + "' but no model could be found with that name.", this._hasModelFor(modelName));
|
13320
13282
|
|
13321
13283
|
var type = this.modelFor(modelName);
|
@@ -13326,10 +13288,10 @@
|
|
13326
13288
|
|
13327
13289
|
if (Ember.ENV.DS_WARN_ON_UNKNOWN_KEYS) {
|
13328
13290
|
Ember.warn("The payload for '" + type.modelName + "' contains these unknown keys: " + Ember.inspect(filter.call(ember$data$lib$system$object$polyfills$$keysFunc(data), function (key) {
|
13329
|
-
return !(key ===
|
13291
|
+
return !(key === 'id' || key === 'links' || ember$data$lib$system$store$$get(type, 'fields').has(key) || key.match(/Type$/));
|
13330
13292
|
})) + ". Make sure they've been defined in your model.", filter.call(ember$data$lib$system$object$polyfills$$keysFunc(data), function (key) {
|
13331
|
-
return !(key ===
|
13332
|
-
}).length === 0, { id:
|
13293
|
+
return !(key === 'id' || key === 'links' || ember$data$lib$system$store$$get(type, 'fields').has(key) || key.match(/Type$/));
|
13294
|
+
}).length === 0, { id: 'ds.store.unknown-keys-in-payload' });
|
13333
13295
|
}
|
13334
13296
|
|
13335
13297
|
// Actually load the record into the store.
|
@@ -13338,7 +13300,7 @@
|
|
13338
13300
|
var store = this;
|
13339
13301
|
|
13340
13302
|
this._backburner.join(function () {
|
13341
|
-
store._backburner.schedule(
|
13303
|
+
store._backburner.schedule('normalizeRelationships', store, '_setupRelationships', internalModel, type, data);
|
13342
13304
|
});
|
13343
13305
|
|
13344
13306
|
return internalModel;
|
@@ -13409,10 +13371,10 @@
|
|
13409
13371
|
if (!inputPayload) {
|
13410
13372
|
payload = modelName;
|
13411
13373
|
serializer = ember$data$lib$system$store$$defaultSerializer(this);
|
13412
|
-
Ember.assert("You cannot use `store#pushPayload` without a modelName unless your default serializer defines `pushPayload`", typeof serializer.pushPayload ===
|
13374
|
+
Ember.assert("You cannot use `store#pushPayload` without a modelName unless your default serializer defines `pushPayload`", typeof serializer.pushPayload === 'function');
|
13413
13375
|
} else {
|
13414
13376
|
payload = inputPayload;
|
13415
|
-
Ember.assert(
|
13377
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
13416
13378
|
serializer = this.serializerFor(modelName);
|
13417
13379
|
}
|
13418
13380
|
var store = this;
|
@@ -13438,7 +13400,7 @@
|
|
13438
13400
|
@return {Object} The normalized payload
|
13439
13401
|
*/
|
13440
13402
|
normalize: function (modelName, payload) {
|
13441
|
-
Ember.assert(
|
13403
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
13442
13404
|
var serializer = this.serializerFor(modelName);
|
13443
13405
|
var model = this.modelFor(modelName);
|
13444
13406
|
return serializer.normalize(model, payload);
|
@@ -13452,10 +13414,10 @@
|
|
13452
13414
|
@deprecated Use [push](#method_push) instead
|
13453
13415
|
*/
|
13454
13416
|
update: function (modelName, data) {
|
13455
|
-
Ember.assert(
|
13456
|
-
Ember.deprecate(
|
13457
|
-
id:
|
13458
|
-
until:
|
13417
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
13418
|
+
Ember.deprecate('Using store.update() has been deprecated since store.push() now handles partial updates. You should use store.push() instead.', false, {
|
13419
|
+
id: 'ds.store.update-deprecated',
|
13420
|
+
until: '2.0.0'
|
13459
13421
|
});
|
13460
13422
|
return this.push(modelName, data);
|
13461
13423
|
},
|
@@ -13470,10 +13432,10 @@
|
|
13470
13432
|
@return {Array}
|
13471
13433
|
*/
|
13472
13434
|
pushMany: function (modelName, datas) {
|
13473
|
-
Ember.assert(
|
13474
|
-
Ember.deprecate(
|
13475
|
-
id:
|
13476
|
-
until:
|
13435
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
13436
|
+
Ember.deprecate('Using store.pushMany() has been deprecated since store.push() now handles multiple items. You should use store.push() instead.', false, {
|
13437
|
+
id: 'ds.store.push-many-deprecated',
|
13438
|
+
until: '2.0.0'
|
13477
13439
|
});
|
13478
13440
|
var length = datas.length;
|
13479
13441
|
var result = new Array(length);
|
@@ -13492,10 +13454,10 @@
|
|
13492
13454
|
@deprecated Use [setMetadataFor](#method_setMetadataFor) instead
|
13493
13455
|
*/
|
13494
13456
|
metaForType: function (modelName, metadata) {
|
13495
|
-
Ember.assert(
|
13496
|
-
Ember.deprecate(
|
13497
|
-
id:
|
13498
|
-
until:
|
13457
|
+
Ember.assert('Passing classes to store methods has been removed. Please pass a dasherized string instead of ' + Ember.inspect(modelName), typeof modelName === 'string');
|
13458
|
+
Ember.deprecate('Using store.metaForType() has been deprecated. Use store.setMetadataFor() to set metadata for a specific type.', false, {
|
13459
|
+
id: 'ds.store.meta-for-type-deprecated',
|
13460
|
+
until: '2.0.0'
|
13499
13461
|
});
|
13500
13462
|
this.setMetadataFor(modelName, metadata);
|
13501
13463
|
},
|
@@ -13514,8 +13476,8 @@
|
|
13514
13476
|
var typeMap = this.typeMapFor(type);
|
13515
13477
|
var idToRecord = typeMap.idToRecord;
|
13516
13478
|
|
13517
|
-
Ember.assert(
|
13518
|
-
Ember.assert("`" + Ember.inspect(type) + "` does not appear to be an ember-data model", typeof type._create ===
|
13479
|
+
Ember.assert('The id ' + id + ' has already been used with another record of type ' + type.toString() + '.', !id || !idToRecord[id]);
|
13480
|
+
Ember.assert("`" + Ember.inspect(type) + "` does not appear to be an ember-data model", typeof type._create === 'function');
|
13519
13481
|
|
13520
13482
|
// lookupFactory should really return an object that creates
|
13521
13483
|
// instances with the injections applied
|
@@ -13548,9 +13510,9 @@
|
|
13548
13510
|
@deprecated Use [unloadRecord](#method_unloadRecord) instead
|
13549
13511
|
*/
|
13550
13512
|
dematerializeRecord: function (record) {
|
13551
|
-
Ember.deprecate(
|
13552
|
-
id:
|
13553
|
-
until:
|
13513
|
+
Ember.deprecate('Using store.dematerializeRecord() has been deprecated since it was intended for private use only. You should use store.unloadRecord() instead.', false, {
|
13514
|
+
id: 'ds.store.dematerialize-record-deprecated',
|
13515
|
+
until: '2.0.0'
|
13554
13516
|
});
|
13555
13517
|
this._dematerializeRecord(record);
|
13556
13518
|
},
|
@@ -13598,10 +13560,10 @@
|
|
13598
13560
|
adapterFor: function (modelOrClass) {
|
13599
13561
|
var modelName;
|
13600
13562
|
|
13601
|
-
if (typeof modelOrClass ===
|
13563
|
+
if (typeof modelOrClass === 'string') {
|
13602
13564
|
modelName = modelOrClass;
|
13603
13565
|
} else {
|
13604
|
-
Ember.deprecate("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), false, { id:
|
13566
|
+
Ember.deprecate("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), false, { id: 'ds.store.passing-classes-deprecated', until: '2.0.0' });
|
13605
13567
|
modelName = modelOrClass.modelName;
|
13606
13568
|
}
|
13607
13569
|
|
@@ -13636,14 +13598,14 @@
|
|
13636
13598
|
serializerFor: function (modelOrClass) {
|
13637
13599
|
var modelName;
|
13638
13600
|
|
13639
|
-
if (typeof modelOrClass ===
|
13601
|
+
if (typeof modelOrClass === 'string') {
|
13640
13602
|
modelName = modelOrClass;
|
13641
13603
|
} else {
|
13642
|
-
Ember.deprecate("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), false, { id:
|
13604
|
+
Ember.deprecate("Passing classes to store methods has been removed. Please pass a dasherized string instead of " + Ember.inspect(modelName), false, { id: 'ds.store.passing-classes-deprecated', until: '2.0.0' });
|
13643
13605
|
modelName = modelOrClass.modelName;
|
13644
13606
|
}
|
13645
13607
|
|
13646
|
-
var fallbacks = [
|
13608
|
+
var fallbacks = ['application', this.adapterFor(modelName).get('defaultSerializer'), '-default'];
|
13647
13609
|
|
13648
13610
|
var serializer = this.lookupSerializer(modelName, fallbacks);
|
13649
13611
|
return serializer;
|
@@ -13666,21 +13628,21 @@
|
|
13666
13628
|
var normalizedModelName = ember$data$lib$system$normalize$model$name$$default(modelName);
|
13667
13629
|
|
13668
13630
|
var instance = this._instanceCache.get(type, normalizedModelName, fallbacks);
|
13669
|
-
ember$data$lib$system$store$$set(instance,
|
13631
|
+
ember$data$lib$system$store$$set(instance, 'store', this);
|
13670
13632
|
return instance;
|
13671
13633
|
},
|
13672
13634
|
|
13673
13635
|
lookupAdapter: function (name) {
|
13674
|
-
return this.retrieveManagedInstance(
|
13636
|
+
return this.retrieveManagedInstance('adapter', name, this.get('_adapterFallbacks'));
|
13675
13637
|
},
|
13676
13638
|
|
13677
|
-
_adapterFallbacks: Ember.computed(
|
13678
|
-
var adapter = this.get(
|
13679
|
-
return [
|
13639
|
+
_adapterFallbacks: Ember.computed('adapter', function () {
|
13640
|
+
var adapter = this.get('adapter');
|
13641
|
+
return ['application', adapter, '-rest'];
|
13680
13642
|
}),
|
13681
13643
|
|
13682
13644
|
lookupSerializer: function (name, fallbacks) {
|
13683
|
-
return this.retrieveManagedInstance(
|
13645
|
+
return this.retrieveManagedInstance('serializer', name, fallbacks);
|
13684
13646
|
},
|
13685
13647
|
|
13686
13648
|
willDestroy: function () {
|
@@ -13705,9 +13667,9 @@
|
|
13705
13667
|
var value;
|
13706
13668
|
if (data.relationships[key] && data.relationships[key].data) {
|
13707
13669
|
value = data.relationships[key].data;
|
13708
|
-
if (kind ===
|
13670
|
+
if (kind === 'belongsTo') {
|
13709
13671
|
data.relationships[key].data = ember$data$lib$system$store$$deserializeRecordId(store, key, relationship, value);
|
13710
|
-
} else if (kind ===
|
13672
|
+
} else if (kind === 'hasMany') {
|
13711
13673
|
data.relationships[key].data = ember$data$lib$system$store$$deserializeRecordIds(store, key, relationship, value);
|
13712
13674
|
}
|
13713
13675
|
}
|
@@ -13741,7 +13703,7 @@
|
|
13741
13703
|
// Delegation to the adapter and promise management
|
13742
13704
|
|
13743
13705
|
function ember$data$lib$system$store$$defaultSerializer(store) {
|
13744
|
-
return store.serializerFor(
|
13706
|
+
return store.serializerFor('application');
|
13745
13707
|
}
|
13746
13708
|
|
13747
13709
|
function ember$data$lib$system$store$$_commit(adapter, store, operation, snapshot) {
|
@@ -13810,10 +13772,10 @@
|
|
13810
13772
|
var value = data.relationships[key].data;
|
13811
13773
|
|
13812
13774
|
if (value !== undefined) {
|
13813
|
-
if (kind ===
|
13775
|
+
if (kind === 'belongsTo') {
|
13814
13776
|
relationship = record._relationships.get(key);
|
13815
13777
|
relationship.setCanonicalRecord(value);
|
13816
|
-
} else if (kind ===
|
13778
|
+
} else if (kind === 'hasMany') {
|
13817
13779
|
relationship = record._relationships.get(key);
|
13818
13780
|
relationship.updateRecordsFromAdapter(value);
|
13819
13781
|
}
|
@@ -13824,7 +13786,7 @@
|
|
13824
13786
|
function ember$data$lib$system$store$$deprecatePreload(preloadOrOptions, type, methodName) {
|
13825
13787
|
if (preloadOrOptions) {
|
13826
13788
|
var modelProperties = [];
|
13827
|
-
var fields = Ember.get(type,
|
13789
|
+
var fields = Ember.get(type, 'fields');
|
13828
13790
|
fields.forEach(function (fieldType, key) {
|
13829
13791
|
modelProperties.push(key);
|
13830
13792
|
});
|
@@ -13832,7 +13794,7 @@
|
|
13832
13794
|
var preloadDetected = false;
|
13833
13795
|
for (var i = 0, _length = modelProperties.length; i < _length; i++) {
|
13834
13796
|
var key = modelProperties[i];
|
13835
|
-
if (typeof preloadOrOptions[key] !==
|
13797
|
+
if (typeof preloadOrOptions[key] !== 'undefined') {
|
13836
13798
|
preloadDetected = true;
|
13837
13799
|
break;
|
13838
13800
|
}
|
@@ -13840,8 +13802,8 @@
|
|
13840
13802
|
|
13841
13803
|
if (preloadDetected) {
|
13842
13804
|
Ember.deprecate("Passing a preload argument to `store." + methodName + "` is deprecated. Please move it to the preload key on the " + methodName + " `options` argument.", false, {
|
13843
|
-
id:
|
13844
|
-
until:
|
13805
|
+
id: 'ds.store.preload-outside-options',
|
13806
|
+
until: '2.0.0'
|
13845
13807
|
});
|
13846
13808
|
var preload = preloadOrOptions;
|
13847
13809
|
return {
|
@@ -14234,50 +14196,50 @@
|
|
14234
14196
|
@param {Object} [application] an application namespace
|
14235
14197
|
*/
|
14236
14198
|
function ember$data$lib$initializers$store$$initializeStore(registry, application) {
|
14237
|
-
Ember.deprecate(
|
14199
|
+
Ember.deprecate('Specifying a custom Store for Ember Data on your global namespace as `App.Store` ' + 'has been deprecated. Please use `App.ApplicationStore` instead.', !(application && application.Store), { id: 'ds.initializer.specifying-custom-store-on-global-namespace-deprecated', until: '2.0.0' });
|
14238
14200
|
|
14239
|
-
registry.optionsForType(
|
14240
|
-
registry.optionsForType(
|
14201
|
+
registry.optionsForType('serializer', { singleton: false });
|
14202
|
+
registry.optionsForType('adapter', { singleton: false });
|
14241
14203
|
|
14242
14204
|
// allow older names to be looked up
|
14243
14205
|
var proxy = new ember$data$lib$system$container$proxy$$default(registry);
|
14244
|
-
proxy.registerDeprecations([{ deprecated:
|
14206
|
+
proxy.registerDeprecations([{ deprecated: 'serializer:_default', valid: 'serializer:-default' }, { deprecated: 'serializer:_rest', valid: 'serializer:-rest' }, { deprecated: 'adapter:_rest', valid: 'adapter:-rest' }]);
|
14245
14207
|
|
14246
14208
|
// new go forward paths
|
14247
|
-
registry.register(
|
14248
|
-
registry.register(
|
14249
|
-
registry.register(
|
14209
|
+
registry.register('serializer:-default', ember$data$lib$serializers$json$serializer$$default.extend({ isNewSerializerAPI: true }));
|
14210
|
+
registry.register('serializer:-rest', ember$data$lib$serializers$rest$serializer$$default.extend({ isNewSerializerAPI: true }));
|
14211
|
+
registry.register('adapter:-rest', ember$data$lib$adapters$rest$adapter$$default);
|
14250
14212
|
|
14251
|
-
registry.register(
|
14252
|
-
registry.register(
|
14213
|
+
registry.register('adapter:-json-api', ember$data$lib$adapters$json$api$adapter$$default);
|
14214
|
+
registry.register('serializer:-json-api', ember$data$lib$serializers$json$api$serializer$$default);
|
14253
14215
|
|
14254
14216
|
var store;
|
14255
|
-
if (registry.has(
|
14256
|
-
Ember.deprecate(
|
14257
|
-
id:
|
14258
|
-
until:
|
14217
|
+
if (registry.has('store:main')) {
|
14218
|
+
Ember.deprecate('Registering a custom store as `store:main` or defining a store in app/store.js has been deprecated. Please move you store to `service:store` or define your custom store in `app/services/store.js`', false, {
|
14219
|
+
id: 'ds.initializer.custom-store-as-store-main-deprecated',
|
14220
|
+
until: '2.0.0'
|
14259
14221
|
});
|
14260
|
-
store = registry.lookup(
|
14222
|
+
store = registry.lookup('store:main');
|
14261
14223
|
} else {
|
14262
14224
|
var storeMainProxy = new ember$data$lib$system$container$proxy$$default(registry);
|
14263
|
-
storeMainProxy.registerDeprecations([{ deprecated:
|
14225
|
+
storeMainProxy.registerDeprecations([{ deprecated: 'store:main', valid: 'service:store' }]);
|
14264
14226
|
}
|
14265
14227
|
|
14266
|
-
if (registry.has(
|
14267
|
-
Ember.deprecate(
|
14268
|
-
id:
|
14269
|
-
until:
|
14228
|
+
if (registry.has('store:application')) {
|
14229
|
+
Ember.deprecate('Registering a custom store as `store:main` or defining a store in app/store.js has been deprecated. Please move you store to `service:store` or define your custom store in `app/services/store.js`', false, {
|
14230
|
+
id: 'ds.initializer.custom-store-as-store-main-deprecated',
|
14231
|
+
until: '2.0.0'
|
14270
14232
|
});
|
14271
|
-
store = registry.lookup(
|
14233
|
+
store = registry.lookup('store:application');
|
14272
14234
|
} else {
|
14273
14235
|
var storeApplicationProxy = new ember$data$lib$system$container$proxy$$default(registry);
|
14274
|
-
storeApplicationProxy.registerDeprecations([{ deprecated:
|
14236
|
+
storeApplicationProxy.registerDeprecations([{ deprecated: 'store:application', valid: 'service:store' }]);
|
14275
14237
|
}
|
14276
14238
|
|
14277
14239
|
if (store) {
|
14278
|
-
registry.register(
|
14279
|
-
} else if (!registry.has(
|
14280
|
-
registry.register(
|
14240
|
+
registry.register('service:store', store, { instantiate: false });
|
14241
|
+
} else if (!registry.has('service:store')) {
|
14242
|
+
registry.register('service:store', application && application.Store || ember$data$lib$system$store$$default);
|
14281
14243
|
}
|
14282
14244
|
}
|
14283
14245
|
|
@@ -14368,9 +14330,9 @@
|
|
14368
14330
|
deserialize: function (serialized) {
|
14369
14331
|
var type = typeof serialized;
|
14370
14332
|
|
14371
|
-
if (type ===
|
14333
|
+
if (type === "string") {
|
14372
14334
|
return new Date(Ember.Date.parse(serialized));
|
14373
|
-
} else if (type ===
|
14335
|
+
} else if (type === "number") {
|
14374
14336
|
return new Date(serialized);
|
14375
14337
|
} else if (serialized === null || serialized === undefined) {
|
14376
14338
|
// if the value is null return null
|
@@ -14497,7 +14459,7 @@
|
|
14497
14459
|
|
14498
14460
|
this.eachComputedProperty(function (name, meta) {
|
14499
14461
|
if (meta.isAttribute) {
|
14500
|
-
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 " + this.toString(), name !==
|
14462
|
+
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 " + this.toString(), name !== 'id');
|
14501
14463
|
|
14502
14464
|
meta.name = name;
|
14503
14465
|
map.set(name, meta);
|
@@ -14583,7 +14545,7 @@
|
|
14583
14545
|
@static
|
14584
14546
|
*/
|
14585
14547
|
eachAttribute: function (callback, binding) {
|
14586
|
-
ember$data$lib$system$model$attributes$$get(this,
|
14548
|
+
ember$data$lib$system$model$attributes$$get(this, 'attributes').forEach(function (meta, name) {
|
14587
14549
|
callback.call(binding, name, meta);
|
14588
14550
|
}, binding);
|
14589
14551
|
},
|
@@ -14623,7 +14585,7 @@
|
|
14623
14585
|
@static
|
14624
14586
|
*/
|
14625
14587
|
eachTransformedAttribute: function (callback, binding) {
|
14626
|
-
ember$data$lib$system$model$attributes$$get(this,
|
14588
|
+
ember$data$lib$system$model$attributes$$get(this, 'transformedAttributes').forEach(function (type, name) {
|
14627
14589
|
callback.call(binding, name, type);
|
14628
14590
|
});
|
14629
14591
|
}
|
@@ -14708,7 +14670,7 @@
|
|
14708
14670
|
@return {Attribute}
|
14709
14671
|
*/
|
14710
14672
|
function ember$data$lib$system$model$attributes$$attr(type, options) {
|
14711
|
-
if (typeof type ===
|
14673
|
+
if (typeof type === 'object') {
|
14712
14674
|
options = type;
|
14713
14675
|
type = undefined;
|
14714
14676
|
} else {
|
@@ -14731,7 +14693,7 @@
|
|
14731
14693
|
}
|
14732
14694
|
},
|
14733
14695
|
set: function (key, value) {
|
14734
|
-
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 " + this.constructor.toString(), key !==
|
14696
|
+
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 " + this.constructor.toString(), key !== 'id');
|
14735
14697
|
var internalModel = this._internalModel;
|
14736
14698
|
var oldValue = ember$data$lib$system$model$attributes$$getValue(internalModel, key);
|
14737
14699
|
|
@@ -14740,7 +14702,7 @@
|
|
14740
14702
|
// the 'didSetProperty' handler if it is no different from the original value
|
14741
14703
|
internalModel._attributes[key] = value;
|
14742
14704
|
|
14743
|
-
this._internalModel.send(
|
14705
|
+
this._internalModel.send('didSetProperty', {
|
14744
14706
|
name: key,
|
14745
14707
|
oldValue: oldValue,
|
14746
14708
|
originalValue: internalModel._data[key],
|
@@ -14796,7 +14758,7 @@
|
|
14796
14758
|
}
|
14797
14759
|
}
|
14798
14760
|
}
|
14799
|
-
ember$data$lib$system$debug$debug$adapter$$assert(
|
14761
|
+
ember$data$lib$system$debug$debug$adapter$$assert("Cannot find model name. Please upgrade to Ember.js >= 1.13 for Ember Inspector support", !!modelName);
|
14800
14762
|
return this.get('store').peekAll(modelName);
|
14801
14763
|
},
|
14802
14764
|
|
@@ -14885,7 +14847,7 @@
|
|
14885
14847
|
@param {Ember.Registry} registry
|
14886
14848
|
*/
|
14887
14849
|
function ember$data$lib$initializers$data$adapter$$initializeDebugAdapter(registry) {
|
14888
|
-
registry.register(
|
14850
|
+
registry.register('data-adapter:main', ember$data$lib$system$debug$debug$adapter$$default);
|
14889
14851
|
}
|
14890
14852
|
var ember$data$lib$instance$initializers$initialize$store$service$$default = ember$data$lib$instance$initializers$initialize$store$service$$initializeStoreService;
|
14891
14853
|
/**
|
@@ -14979,51 +14941,51 @@
|
|
14979
14941
|
Ember.onLoad('Ember.Application', function (Application) {
|
14980
14942
|
|
14981
14943
|
Application.initializer({
|
14982
|
-
name:
|
14944
|
+
name: "ember-data",
|
14983
14945
|
initialize: ember$data$lib$setup$container$$initializeInjects
|
14984
14946
|
});
|
14985
14947
|
|
14986
14948
|
if (Application.instanceInitializer) {
|
14987
14949
|
Application.instanceInitializer({
|
14988
|
-
name:
|
14950
|
+
name: "ember-data",
|
14989
14951
|
initialize: ember$data$lib$instance$initializers$initialize$store$service$$default
|
14990
14952
|
});
|
14991
14953
|
} else {
|
14992
14954
|
Application.initializer({
|
14993
|
-
name:
|
14994
|
-
after:
|
14955
|
+
name: "ember-data-store-service",
|
14956
|
+
after: "ember-data",
|
14995
14957
|
initialize: ember$data$lib$instance$initializers$initialize$store$service$$default
|
14996
14958
|
});
|
14997
14959
|
}
|
14998
14960
|
|
14999
14961
|
// Deprecated initializers to satisfy old code that depended on them
|
15000
14962
|
Application.initializer({
|
15001
|
-
name:
|
15002
|
-
after:
|
14963
|
+
name: "store",
|
14964
|
+
after: "ember-data",
|
15003
14965
|
initialize: ember$data$lib$ember$initializer$$K
|
15004
14966
|
});
|
15005
14967
|
|
15006
14968
|
Application.initializer({
|
15007
|
-
name:
|
15008
|
-
before:
|
14969
|
+
name: "activeModelAdapter",
|
14970
|
+
before: "store",
|
15009
14971
|
initialize: ember$data$lib$ember$initializer$$K
|
15010
14972
|
});
|
15011
14973
|
|
15012
14974
|
Application.initializer({
|
15013
|
-
name:
|
15014
|
-
before:
|
14975
|
+
name: "transforms",
|
14976
|
+
before: "store",
|
15015
14977
|
initialize: ember$data$lib$ember$initializer$$K
|
15016
14978
|
});
|
15017
14979
|
|
15018
14980
|
Application.initializer({
|
15019
|
-
name:
|
15020
|
-
before:
|
14981
|
+
name: "data-adapter",
|
14982
|
+
before: "store",
|
15021
14983
|
initialize: ember$data$lib$ember$initializer$$K
|
15022
14984
|
});
|
15023
14985
|
|
15024
14986
|
Application.initializer({
|
15025
|
-
name:
|
15026
|
-
before:
|
14987
|
+
name: "injectStore",
|
14988
|
+
before: "store",
|
15027
14989
|
initialize: ember$data$lib$ember$initializer$$K
|
15028
14990
|
});
|
15029
14991
|
});
|
@@ -15519,14 +15481,14 @@
|
|
15519
15481
|
typeClass.eachRelationship(function (key, relationship) {
|
15520
15482
|
if (serializer.hasDeserializeRecordsOption(key)) {
|
15521
15483
|
var embeddedTypeClass = store.modelFor(relationship.type);
|
15522
|
-
if (relationship.kind ===
|
15484
|
+
if (relationship.kind === "hasMany") {
|
15523
15485
|
if (relationship.options.polymorphic) {
|
15524
15486
|
this._extractEmbeddedHasManyPolymorphic(store, key, partial);
|
15525
15487
|
} else {
|
15526
15488
|
this._extractEmbeddedHasMany(store, key, embeddedTypeClass, partial);
|
15527
15489
|
}
|
15528
15490
|
}
|
15529
|
-
if (relationship.kind ===
|
15491
|
+
if (relationship.kind === "belongsTo") {
|
15530
15492
|
if (relationship.options.polymorphic) {
|
15531
15493
|
this._extractEmbeddedBelongsToPolymorphic(store, key, partial);
|
15532
15494
|
} else {
|
@@ -15679,10 +15641,10 @@
|
|
15679
15641
|
|
15680
15642
|
typeClass.eachRelationship(function (key, relationship) {
|
15681
15643
|
if (serializer.hasDeserializeRecordsOption(key)) {
|
15682
|
-
if (relationship.kind ===
|
15644
|
+
if (relationship.kind === "hasMany") {
|
15683
15645
|
_this2._extractEmbeddedHasMany(store, key, partial, relationship);
|
15684
15646
|
}
|
15685
|
-
if (relationship.kind ===
|
15647
|
+
if (relationship.kind === "belongsTo") {
|
15686
15648
|
_this2._extractEmbeddedBelongsTo(store, key, partial, relationship);
|
15687
15649
|
}
|
15688
15650
|
}
|
@@ -15826,7 +15788,7 @@
|
|
15826
15788
|
*/
|
15827
15789
|
function ember$data$lib$system$relationships$belongs$to$$belongsTo(modelName, options) {
|
15828
15790
|
var opts, userEnteredModelName;
|
15829
|
-
if (typeof modelName ===
|
15791
|
+
if (typeof modelName === 'object') {
|
15830
15792
|
opts = modelName;
|
15831
15793
|
userEnteredModelName = undefined;
|
15832
15794
|
} else {
|
@@ -15834,16 +15796,16 @@
|
|
15834
15796
|
userEnteredModelName = modelName;
|
15835
15797
|
}
|
15836
15798
|
|
15837
|
-
if (typeof userEnteredModelName ===
|
15799
|
+
if (typeof userEnteredModelName === 'string') {
|
15838
15800
|
userEnteredModelName = ember$data$lib$system$normalize$model$name$$default(userEnteredModelName);
|
15839
15801
|
}
|
15840
15802
|
|
15841
|
-
Ember.assert("The first argument to DS.belongsTo must be a string representing a model type key, not an instance of " + Ember.inspect(userEnteredModelName) + ". E.g., to define a relation to the Person model, use DS.belongsTo('person')", typeof userEnteredModelName ===
|
15803
|
+
Ember.assert("The first argument to DS.belongsTo must be a string representing a model type key, not an instance of " + Ember.inspect(userEnteredModelName) + ". E.g., to define a relation to the Person model, use DS.belongsTo('person')", typeof userEnteredModelName === 'string' || typeof userEnteredModelName === 'undefined');
|
15842
15804
|
|
15843
15805
|
opts = opts || {};
|
15844
15806
|
|
15845
15807
|
var shouldWarnAsync = false;
|
15846
|
-
if (typeof opts.async ===
|
15808
|
+
if (typeof opts.async === 'undefined') {
|
15847
15809
|
shouldWarnAsync = true;
|
15848
15810
|
}
|
15849
15811
|
|
@@ -15851,31 +15813,31 @@
|
|
15851
15813
|
type: userEnteredModelName,
|
15852
15814
|
isRelationship: true,
|
15853
15815
|
options: opts,
|
15854
|
-
kind:
|
15816
|
+
kind: 'belongsTo',
|
15855
15817
|
key: null,
|
15856
15818
|
shouldWarnAsync: shouldWarnAsync
|
15857
15819
|
};
|
15858
15820
|
|
15859
15821
|
return ember$new$computed$lib$main$$default({
|
15860
15822
|
get: function (key) {
|
15861
|
-
if (opts.hasOwnProperty(
|
15823
|
+
if (opts.hasOwnProperty('serialize')) {
|
15862
15824
|
Ember.warn("You provided a serialize option on the \"" + key + "\" property in the \"" + this._internalModel.modelName + "\" class, this belongs in the serializer. See DS.Serializer and it's implementations http://emberjs.com/api/data/classes/DS.Serializer.html", false, {
|
15863
|
-
id:
|
15825
|
+
id: 'ds.model.serialize-option-in-belongs-to'
|
15864
15826
|
});
|
15865
15827
|
}
|
15866
15828
|
|
15867
|
-
if (opts.hasOwnProperty(
|
15829
|
+
if (opts.hasOwnProperty('embedded')) {
|
15868
15830
|
Ember.warn("You provided an embedded option on the \"" + key + "\" property in the \"" + this._internalModel.modelName + "\" class, this belongs in the serializer. See DS.EmbeddedRecordsMixin http://emberjs.com/api/data/classes/DS.EmbeddedRecordsMixin.html", false, {
|
15869
|
-
id:
|
15831
|
+
id: 'ds.model.embedded-option-in-belongs-to'
|
15870
15832
|
});
|
15871
15833
|
}
|
15872
15834
|
|
15873
15835
|
if (meta.shouldWarnAsync) {
|
15874
15836
|
Ember.deprecate("In Ember Data 2.0, relationships will be asynchronous by default. You must set `" + key + ": DS.belongsTo('" + modelName + "', { async: false })` if you wish for a relationship remain synchronous.", false, {
|
15875
|
-
id:
|
15876
|
-
until:
|
15837
|
+
id: 'ds.model.relationship-changing-to-asynchrounous-by-default',
|
15838
|
+
until: '2.0.0'
|
15877
15839
|
});
|
15878
|
-
meta.
|
15840
|
+
meta.shouldWarnAsync = false;
|
15879
15841
|
}
|
15880
15842
|
|
15881
15843
|
return this._internalModel._relationships.get(key).getRecord();
|
@@ -16016,21 +15978,21 @@
|
|
16016
15978
|
@return {Ember.computed} relationship
|
16017
15979
|
*/
|
16018
15980
|
function ember$data$lib$system$relationships$has$many$$hasMany(type, options) {
|
16019
|
-
if (typeof type ===
|
15981
|
+
if (typeof type === 'object') {
|
16020
15982
|
options = type;
|
16021
15983
|
type = undefined;
|
16022
15984
|
}
|
16023
15985
|
|
16024
|
-
Ember.assert("The first argument to DS.hasMany must be a string representing a model type key, not an instance of " + Ember.inspect(type) + ". E.g., to define a relation to the Comment model, use DS.hasMany('comment')", typeof type ===
|
15986
|
+
Ember.assert("The first argument to DS.hasMany must be a string representing a model type key, not an instance of " + Ember.inspect(type) + ". E.g., to define a relation to the Comment model, use DS.hasMany('comment')", typeof type === 'string' || typeof type === 'undefined');
|
16025
15987
|
|
16026
15988
|
options = options || {};
|
16027
15989
|
|
16028
15990
|
var shouldWarnAsync = false;
|
16029
|
-
if (typeof options.async ===
|
15991
|
+
if (typeof options.async === 'undefined') {
|
16030
15992
|
shouldWarnAsync = true;
|
16031
15993
|
}
|
16032
15994
|
|
16033
|
-
if (typeof type ===
|
15995
|
+
if (typeof type === 'string') {
|
16034
15996
|
type = ember$data$lib$system$normalize$model$name$$default(type);
|
16035
15997
|
}
|
16036
15998
|
|
@@ -16042,7 +16004,7 @@
|
|
16042
16004
|
type: type,
|
16043
16005
|
isRelationship: true,
|
16044
16006
|
options: options,
|
16045
|
-
kind:
|
16007
|
+
kind: 'hasMany',
|
16046
16008
|
key: null,
|
16047
16009
|
shouldWarnAsync: shouldWarnAsync
|
16048
16010
|
};
|
@@ -16051,8 +16013,8 @@
|
|
16051
16013
|
get: function (key) {
|
16052
16014
|
if (meta.shouldWarnAsync) {
|
16053
16015
|
Ember.deprecate("In Ember Data 2.0, relationships will be asynchronous by default. You must set `" + key + ": DS.hasMany('" + type + "', { async: false })` if you wish for a relationship remain synchronous.", false, {
|
16054
|
-
id:
|
16055
|
-
until:
|
16016
|
+
id: 'ds.model.relationship-changing-to-asynchrounous-by-default',
|
16017
|
+
until: '2.0.0'
|
16056
16018
|
});
|
16057
16019
|
meta.shouldWarnAsync = false;
|
16058
16020
|
}
|
@@ -16063,7 +16025,7 @@
|
|
16063
16025
|
var relationship = this._internalModel._relationships.get(key);
|
16064
16026
|
relationship.clear();
|
16065
16027
|
Ember.assert("You must pass an array of records to set a hasMany relationship", Ember.isArray(records));
|
16066
|
-
relationship.addRecords(Ember.A(records).mapBy(
|
16028
|
+
relationship.addRecords(Ember.A(records).mapBy('_internalModel'));
|
16067
16029
|
return relationship.getRecords();
|
16068
16030
|
}
|
16069
16031
|
}).meta(meta);
|
@@ -16081,6 +16043,7 @@
|
|
16081
16043
|
});
|
16082
16044
|
|
16083
16045
|
var ember$data$lib$system$relationships$has$many$$default = ember$data$lib$system$relationships$has$many$$hasMany;
|
16046
|
+
|
16084
16047
|
function ember$data$lib$system$relationship$meta$$typeForRelationshipMeta(meta) {
|
16085
16048
|
var modelName;
|
16086
16049
|
|
@@ -16267,7 +16230,7 @@
|
|
16267
16230
|
@return {DS.Model} the type of the relationship, or undefined
|
16268
16231
|
*/
|
16269
16232
|
typeForRelationship: function (name, store) {
|
16270
|
-
var relationship = ember$data$lib$system$relationships$ext$$get(this,
|
16233
|
+
var relationship = ember$data$lib$system$relationships$ext$$get(this, 'relationshipsByName').get(name);
|
16271
16234
|
return relationship && store.modelFor(relationship.type);
|
16272
16235
|
},
|
16273
16236
|
|
@@ -16298,7 +16261,7 @@
|
|
16298
16261
|
@return {Object} the inverse relationship, or null
|
16299
16262
|
*/
|
16300
16263
|
inverseFor: function (name, store) {
|
16301
|
-
var inverseMap = ember$data$lib$system$relationships$ext$$get(this,
|
16264
|
+
var inverseMap = ember$data$lib$system$relationships$ext$$get(this, 'inverseMap');
|
16302
16265
|
if (inverseMap[name]) {
|
16303
16266
|
return inverseMap[name];
|
16304
16267
|
} else {
|
@@ -16328,7 +16291,7 @@
|
|
16328
16291
|
//If inverse is specified manually, return the inverse
|
16329
16292
|
if (options.inverse) {
|
16330
16293
|
inverseName = options.inverse;
|
16331
|
-
inverse = Ember.get(inverseType,
|
16294
|
+
inverse = Ember.get(inverseType, 'relationshipsByName').get(inverseName);
|
16332
16295
|
|
16333
16296
|
Ember.assert("We found no inverse relationships by the name of '" + inverseName + "' on the '" + inverseType.modelName + "' model. This is most likely due to a missing attribute on your model definition.", !Ember.isNone(inverse));
|
16334
16297
|
|
@@ -16337,7 +16300,7 @@
|
|
16337
16300
|
//No inverse was specified manually, we need to use a heuristic to guess one
|
16338
16301
|
if (propertyMeta.type === propertyMeta.parentType.modelName) {
|
16339
16302
|
Ember.warn("Detected a reflexive relationship by the name of '" + name + "' without an inverse option. Look at http://emberjs.com/guides/models/defining-models/#toc_reflexive-relation for how to explicitly specify inverses.", false, {
|
16340
|
-
id:
|
16303
|
+
id: 'ds.model.reflexive-relationship-without-inverse'
|
16341
16304
|
});
|
16342
16305
|
}
|
16343
16306
|
|
@@ -16367,7 +16330,7 @@
|
|
16367
16330
|
function findPossibleInverses(type, inverseType, relationshipsSoFar) {
|
16368
16331
|
var possibleRelationships = relationshipsSoFar || [];
|
16369
16332
|
|
16370
|
-
var relationshipMap = ember$data$lib$system$relationships$ext$$get(inverseType,
|
16333
|
+
var relationshipMap = ember$data$lib$system$relationships$ext$$get(inverseType, 'relationships');
|
16371
16334
|
if (!relationshipMap) {
|
16372
16335
|
return possibleRelationships;
|
16373
16336
|
}
|
@@ -16575,7 +16538,7 @@
|
|
16575
16538
|
if (meta.isRelationship) {
|
16576
16539
|
map.set(name, meta.kind);
|
16577
16540
|
} else if (meta.isAttribute) {
|
16578
|
-
map.set(name,
|
16541
|
+
map.set(name, 'attribute');
|
16579
16542
|
}
|
16580
16543
|
});
|
16581
16544
|
|
@@ -16592,7 +16555,7 @@
|
|
16592
16555
|
@param {any} binding the value to which the callback's `this` should be bound
|
16593
16556
|
*/
|
16594
16557
|
eachRelationship: function (callback, binding) {
|
16595
|
-
ember$data$lib$system$relationships$ext$$get(this,
|
16558
|
+
ember$data$lib$system$relationships$ext$$get(this, 'relationshipsByName').forEach(function (relationship, name) {
|
16596
16559
|
callback.call(binding, name, relationship);
|
16597
16560
|
});
|
16598
16561
|
},
|
@@ -16608,7 +16571,7 @@
|
|
16608
16571
|
@param {any} binding the value to which the callback's `this` should be bound
|
16609
16572
|
*/
|
16610
16573
|
eachRelatedType: function (callback, binding) {
|
16611
|
-
ember$data$lib$system$relationships$ext$$get(this,
|
16574
|
+
ember$data$lib$system$relationships$ext$$get(this, 'relatedTypes').forEach(function (type) {
|
16612
16575
|
callback.call(binding, type);
|
16613
16576
|
});
|
16614
16577
|
},
|
@@ -16620,16 +16583,16 @@
|
|
16620
16583
|
var key, otherKind;
|
16621
16584
|
|
16622
16585
|
if (!inverse) {
|
16623
|
-
return knownKind ===
|
16586
|
+
return knownKind === 'belongsTo' ? 'oneToNone' : 'manyToNone';
|
16624
16587
|
}
|
16625
16588
|
|
16626
16589
|
key = inverse.name;
|
16627
16590
|
otherKind = inverse.kind;
|
16628
16591
|
|
16629
|
-
if (otherKind ===
|
16630
|
-
return knownKind ===
|
16592
|
+
if (otherKind === 'belongsTo') {
|
16593
|
+
return knownKind === 'belongsTo' ? 'oneToOne' : 'manyToOne';
|
16631
16594
|
} else {
|
16632
|
-
return knownKind ===
|
16595
|
+
return knownKind === 'belongsTo' ? 'oneToMany' : 'manyToMany';
|
16633
16596
|
}
|
16634
16597
|
}
|
16635
16598
|
|
@@ -16680,7 +16643,7 @@
|
|
16680
16643
|
},
|
16681
16644
|
|
16682
16645
|
relationshipFor: function (name) {
|
16683
|
-
return ember$data$lib$system$relationships$ext$$get(this.constructor,
|
16646
|
+
return ember$data$lib$system$relationships$ext$$get(this.constructor, 'relationshipsByName').get(name);
|
16684
16647
|
},
|
16685
16648
|
|
16686
16649
|
inverseFor: function (key) {
|
@@ -16758,13 +16721,13 @@
|
|
16758
16721
|
var ember$data$lib$main$$_ActiveModelSerializer = activemodel$adapter$lib$system$active$model$serializer$$default;
|
16759
16722
|
|
16760
16723
|
if (Ember.platform.hasPropertyAccessors) {
|
16761
|
-
Ember.defineProperty(ember$data$lib$core$$default,
|
16724
|
+
Ember.defineProperty(ember$data$lib$core$$default, 'ActiveModelAdapter', {
|
16762
16725
|
get: function () {
|
16763
16726
|
if (ember$data$lib$main$$_ActiveModelSerializer === activemodel$adapter$lib$system$active$model$adapter$$default) {
|
16764
|
-
Ember.deprecate(
|
16765
|
-
url:
|
16766
|
-
id:
|
16767
|
-
until:
|
16727
|
+
Ember.deprecate('The ActiveModelAdapter has been moved into a plugin. It will not be bundled with Ember Data in 2.0', false, {
|
16728
|
+
url: 'https://github.com/ember-data/active-model-adapter',
|
16729
|
+
id: 'ds.adapter.active-model-adapter-deprecated',
|
16730
|
+
until: '2.0.0'
|
16768
16731
|
});
|
16769
16732
|
}
|
16770
16733
|
return ember$data$lib$main$$_ActiveModelAdapter;
|
@@ -16773,13 +16736,13 @@
|
|
16773
16736
|
ember$data$lib$main$$_ActiveModelAdapter = ActiveModelAdapter;
|
16774
16737
|
}
|
16775
16738
|
});
|
16776
|
-
Ember.defineProperty(ember$data$lib$core$$default,
|
16739
|
+
Ember.defineProperty(ember$data$lib$core$$default, 'ActiveModelSerializer', {
|
16777
16740
|
get: function () {
|
16778
16741
|
if (ember$data$lib$main$$_ActiveModelSerializer === activemodel$adapter$lib$system$active$model$serializer$$default) {
|
16779
|
-
Ember.deprecate(
|
16780
|
-
url:
|
16781
|
-
id:
|
16782
|
-
until:
|
16742
|
+
Ember.deprecate('The ActiveModelSerializer has been moved into a plugin. It will not be bundled with Ember Data in 2.0', false, {
|
16743
|
+
url: 'https://github.com/ember-data/active-model-adapter',
|
16744
|
+
id: 'ds.serializer.active-model-serializer-deprecated',
|
16745
|
+
until: '2.0.0'
|
16783
16746
|
});
|
16784
16747
|
}
|
16785
16748
|
return ember$data$lib$main$$_ActiveModelSerializer;
|
@@ -16803,7 +16766,7 @@
|
|
16803
16766
|
|
16804
16767
|
ember$data$lib$core$$default._setupContainer = ember$data$lib$setup$container$$default;
|
16805
16768
|
|
16806
|
-
Ember.defineProperty(ember$data$lib$core$$default,
|
16769
|
+
Ember.defineProperty(ember$data$lib$core$$default, 'normalizeModelName', {
|
16807
16770
|
enumerable: true,
|
16808
16771
|
writable: false,
|
16809
16772
|
configurable: false,
|
@@ -16813,12 +16776,12 @@
|
|
16813
16776
|
var ember$data$lib$main$$_FixtureAdapter = ember$data$lib$adapters$fixture$adapter$$default;
|
16814
16777
|
|
16815
16778
|
if (Ember.platform.hasPropertyAccessors) {
|
16816
|
-
Ember.defineProperty(ember$data$lib$core$$default,
|
16779
|
+
Ember.defineProperty(ember$data$lib$core$$default, 'FixtureAdapter', {
|
16817
16780
|
get: function () {
|
16818
16781
|
if (ember$data$lib$main$$_FixtureAdapter === ember$data$lib$adapters$fixture$adapter$$default) {
|
16819
|
-
Ember.deprecate(
|
16820
|
-
id:
|
16821
|
-
until:
|
16782
|
+
Ember.deprecate('DS.FixtureAdapter has been deprecated and moved into an unsupported addon: https://github.com/emberjs/ember-data-fixture-adapter/tree/master', false, {
|
16783
|
+
id: 'ds.adapter.fixture-adapter-deprecated',
|
16784
|
+
until: '2.0.0'
|
16822
16785
|
});
|
16823
16786
|
}
|
16824
16787
|
return ember$data$lib$main$$_FixtureAdapter;
|
@@ -16834,6 +16797,37 @@
|
|
16834
16797
|
Ember.lookup.DS = ember$data$lib$core$$default;
|
16835
16798
|
|
16836
16799
|
var ember$data$lib$main$$default = ember$data$lib$core$$default;
|
16800
|
+
var ember$inflector$lib$lib$utils$make$helper$$default = ember$inflector$lib$lib$utils$make$helper$$makeHelper;
|
16801
|
+
function ember$inflector$lib$lib$utils$make$helper$$makeHelper(helperFunction) {
|
16802
|
+
if (ember$lib$main$$default.Helper) {
|
16803
|
+
return ember$lib$main$$default.Helper.helper(helperFunction);
|
16804
|
+
}
|
16805
|
+
if (ember$lib$main$$default.HTMLBars) {
|
16806
|
+
return ember$lib$main$$default.HTMLBars.makeBoundHelper(helperFunction);
|
16807
|
+
}
|
16808
|
+
return ember$lib$main$$default.Handlebars.makeBoundHelper(helperFunction);
|
16809
|
+
}
|
16810
|
+
|
16811
|
+
var ember$inflector$lib$lib$helpers$pluralize$$default = ember$inflector$lib$lib$utils$make$helper$$default(function (params) {
|
16812
|
+
var count, word;
|
16813
|
+
|
16814
|
+
if (params.length === 1) {
|
16815
|
+
word = params[0];
|
16816
|
+
return ember$inflector$lib$lib$system$string$$pluralize(word);
|
16817
|
+
} else {
|
16818
|
+
count = params[0];
|
16819
|
+
word = params[1];
|
16820
|
+
|
16821
|
+
if ((count | 0) !== 1) {
|
16822
|
+
word = ember$inflector$lib$lib$system$string$$pluralize(word);
|
16823
|
+
}
|
16824
|
+
return count + " " + word;
|
16825
|
+
}
|
16826
|
+
});
|
16827
|
+
|
16828
|
+
var ember$inflector$lib$lib$helpers$singularize$$default = ember$inflector$lib$lib$utils$make$helper$$default(function (params) {
|
16829
|
+
return ember$inflector$lib$lib$system$string$$singularize(params[0]);
|
16830
|
+
});
|
16837
16831
|
}).call(this);
|
16838
16832
|
|
16839
16833
|
//# sourceMappingURL=ember-data.js.map
|