@ember-data/store 4.1.0-alpha.9 → 4.1.0-beta.0
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.
- package/addon/-private/identifiers/cache.ts +3 -5
- package/addon/-private/identifiers/utils/uuid-v4.ts +0 -13
- package/addon/-private/index.ts +0 -1
- package/addon/-private/system/core-store.ts +10 -46
- package/addon/-private/system/ds-model-store.ts +1 -2
- package/addon/-private/system/fetch-manager.ts +1 -2
- package/addon/-private/system/model/internal-model.ts +7 -12
- package/addon/-private/system/record-array-manager.js +2 -3
- package/addon/-private/system/record-arrays/adapter-populated-record-array.js +2 -3
- package/addon/-private/system/references/reference.ts +3 -25
- package/addon/-private/system/request-cache.ts +6 -7
- package/addon/-private/system/snapshot.ts +1 -2
- package/addon/-private/system/store/finders.js +4 -11
- package/addon/-private/ts-interfaces/identifier.ts +2 -3
- package/package.json +8 -8
- package/addon/-private/utils/symbol.ts +0 -33
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
@module @ember-data/store
|
|
3
3
|
*/
|
|
4
4
|
import { assert, warn } from '@ember/debug';
|
|
5
|
-
import { assign } from '@ember/polyfills';
|
|
6
5
|
import { DEBUG } from '@glimmer/env';
|
|
7
6
|
|
|
8
7
|
import coerceId from '../system/coerce-id';
|
|
@@ -23,7 +22,6 @@ import type {
|
|
|
23
22
|
import { DEBUG_CLIENT_ORIGINATED, DEBUG_IDENTIFIER_BUCKET } from '../ts-interfaces/identifier';
|
|
24
23
|
import type { ConfidentDict } from '../ts-interfaces/utils';
|
|
25
24
|
import isNonEmptyString from '../utils/is-non-empty-string';
|
|
26
|
-
import { addSymbol } from '../utils/symbol';
|
|
27
25
|
import isStableIdentifier, { markStableIdentifier, unmarkStableIdentifier } from './is-stable-identifier';
|
|
28
26
|
import uuidv4 from './utils/uuid-v4';
|
|
29
27
|
|
|
@@ -372,7 +370,7 @@ export class IdentifierCache {
|
|
|
372
370
|
// If the incoming type does not match the identifier type, we need to create an identifier for the incoming
|
|
373
371
|
// data so we can merge the incoming data with the existing identifier, see #7325 and #7363
|
|
374
372
|
if ('type' in data && data.type && identifier.type !== normalizeModelName(data.type)) {
|
|
375
|
-
let incomingDataResource =
|
|
373
|
+
let incomingDataResource = { ...data };
|
|
376
374
|
// Need to strip the lid from the incomingData in order force a new identifier creation
|
|
377
375
|
delete incomingDataResource.lid;
|
|
378
376
|
existingIdentifier = this.getOrCreateRecordIdentifier(incomingDataResource);
|
|
@@ -511,8 +509,8 @@ function makeStableRecordIdentifier(
|
|
|
511
509
|
return `${clientOriginated ? '[CLIENT_ORIGINATED] ' : ''}${type}:${id} (${lid})`;
|
|
512
510
|
},
|
|
513
511
|
};
|
|
514
|
-
|
|
515
|
-
|
|
512
|
+
wrapper[DEBUG_CLIENT_ORIGINATED] = clientOriginated;
|
|
513
|
+
wrapper[DEBUG_IDENTIFIER_BUCKET] = bucket;
|
|
516
514
|
wrapper = freeze(wrapper);
|
|
517
515
|
markStableIdentifier(wrapper);
|
|
518
516
|
DEBUG_MAP.set(wrapper, recordIdentifier);
|
|
@@ -2,13 +2,6 @@
|
|
|
2
2
|
@module @ember-data/store
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
// support IE11
|
|
6
|
-
declare global {
|
|
7
|
-
interface Window {
|
|
8
|
-
msCrypto: Crypto;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
5
|
const CRYPTO = (() => {
|
|
13
6
|
const hasWindow = typeof window !== 'undefined';
|
|
14
7
|
const isFastBoot = typeof FastBoot !== 'undefined';
|
|
@@ -27,12 +20,6 @@ const CRYPTO = (() => {
|
|
|
27
20
|
};
|
|
28
21
|
} else if (hasWindow && typeof window.crypto !== 'undefined') {
|
|
29
22
|
return window.crypto;
|
|
30
|
-
} else if (
|
|
31
|
-
hasWindow &&
|
|
32
|
-
typeof window.msCrypto !== 'undefined' &&
|
|
33
|
-
typeof window.msCrypto.getRandomValues === 'function'
|
|
34
|
-
) {
|
|
35
|
-
return window.msCrypto;
|
|
36
23
|
} else {
|
|
37
24
|
throw new Error('ember-data: Cannot find a valid way to generate local identifiers');
|
|
38
25
|
}
|
package/addon/-private/index.ts
CHANGED
|
@@ -25,7 +25,6 @@ export { default as RootState } from './system/model/states';
|
|
|
25
25
|
export { default as InternalModel } from './system/model/internal-model';
|
|
26
26
|
|
|
27
27
|
export { PromiseArray, PromiseObject } from './system/promise-proxies';
|
|
28
|
-
export { addSymbol, symbol } from './utils/symbol';
|
|
29
28
|
|
|
30
29
|
export { RecordArray, AdapterPopulatedRecordArray } from './system/record-arrays';
|
|
31
30
|
|
|
@@ -5,7 +5,6 @@ import { getOwner } from '@ember/application';
|
|
|
5
5
|
import { A } from '@ember/array';
|
|
6
6
|
import { assert, deprecate, inspect, warn } from '@ember/debug';
|
|
7
7
|
import { computed, defineProperty, get, set } from '@ember/object';
|
|
8
|
-
import { assign } from '@ember/polyfills';
|
|
9
8
|
import { _backburner as emberBackburner } from '@ember/runloop';
|
|
10
9
|
import type { Backburner } from '@ember/runloop/-private/backburner';
|
|
11
10
|
import Service from '@ember/service';
|
|
@@ -68,7 +67,6 @@ import type { FindOptions } from '../ts-interfaces/store';
|
|
|
68
67
|
import type { Dict } from '../ts-interfaces/utils';
|
|
69
68
|
import constructResource from '../utils/construct-resource';
|
|
70
69
|
import promiseRecord from '../utils/promise-record';
|
|
71
|
-
import { addSymbol } from '../utils/symbol';
|
|
72
70
|
import edBackburner from './backburner';
|
|
73
71
|
import coerceId, { ensureStringId } from './coerce-id';
|
|
74
72
|
import { errorsArrayToHash } from './errors-utils';
|
|
@@ -646,7 +644,7 @@ abstract class CoreStore extends Service {
|
|
|
646
644
|
return emberBackburner.join(() => {
|
|
647
645
|
return this._backburner.join(() => {
|
|
648
646
|
let normalizedModelName = normalizeModelName(modelName);
|
|
649
|
-
let properties =
|
|
647
|
+
let properties = { ...inputProperties };
|
|
650
648
|
|
|
651
649
|
// If the passed properties do not include a primary key,
|
|
652
650
|
// give the adapter an opportunity to generate one. Typically,
|
|
@@ -725,21 +723,6 @@ abstract class CoreStore extends Service {
|
|
|
725
723
|
if (internalModel) {
|
|
726
724
|
internalModel.deleteRecord();
|
|
727
725
|
}
|
|
728
|
-
} else {
|
|
729
|
-
deprecate(
|
|
730
|
-
`You passed a non ember-data managed record ${record} to store.deleteRecord. Ember Data store is not meant to manage non store records. This is not supported and will be removed`,
|
|
731
|
-
false,
|
|
732
|
-
{
|
|
733
|
-
id: 'ember-data:delete-record-non-store',
|
|
734
|
-
until: '4.0',
|
|
735
|
-
for: '@ember-data/store',
|
|
736
|
-
since: {
|
|
737
|
-
available: '3.28',
|
|
738
|
-
enabled: '3.28',
|
|
739
|
-
},
|
|
740
|
-
}
|
|
741
|
-
);
|
|
742
|
-
record.deleteRecord();
|
|
743
726
|
}
|
|
744
727
|
} else {
|
|
745
728
|
record.deleteRecord();
|
|
@@ -774,21 +757,6 @@ abstract class CoreStore extends Service {
|
|
|
774
757
|
if (internalModel) {
|
|
775
758
|
internalModel.unloadRecord();
|
|
776
759
|
}
|
|
777
|
-
} else {
|
|
778
|
-
deprecate(
|
|
779
|
-
`You passed a non ember-data managed record ${record} to store.unloadRecord. Ember Data store is not meant to manage non store records. This is not supported and will be removed`,
|
|
780
|
-
false,
|
|
781
|
-
{
|
|
782
|
-
id: 'ember-data:unload-record-non-store',
|
|
783
|
-
until: '4.0',
|
|
784
|
-
for: '@ember-data/store',
|
|
785
|
-
since: {
|
|
786
|
-
available: '3.28',
|
|
787
|
-
enabled: '3.28',
|
|
788
|
-
},
|
|
789
|
-
}
|
|
790
|
-
);
|
|
791
|
-
record.unloadRecord();
|
|
792
760
|
}
|
|
793
761
|
} else {
|
|
794
762
|
record.unloadRecord();
|
|
@@ -1601,18 +1569,14 @@ abstract class CoreStore extends Service {
|
|
|
1601
1569
|
groups = [snapshots];
|
|
1602
1570
|
}
|
|
1603
1571
|
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
var group = groups[i];
|
|
1610
|
-
var totalInGroup = groups[i].length;
|
|
1611
|
-
var ids = new Array(totalInGroup);
|
|
1612
|
-
var groupedInternalModels = new Array(totalInGroup);
|
|
1572
|
+
for (let i = 0, l = groups.length; i < l; i++) {
|
|
1573
|
+
let group = groups[i];
|
|
1574
|
+
let totalInGroup = groups[i].length;
|
|
1575
|
+
let ids = new Array(totalInGroup);
|
|
1576
|
+
let groupedInternalModels = new Array(totalInGroup);
|
|
1613
1577
|
|
|
1614
|
-
for (
|
|
1615
|
-
|
|
1578
|
+
for (let j = 0; j < totalInGroup; j++) {
|
|
1579
|
+
let internalModel = group[j]._internalModel;
|
|
1616
1580
|
|
|
1617
1581
|
groupedInternalModels[j] = internalModel;
|
|
1618
1582
|
ids[j] = internalModel.id;
|
|
@@ -1629,7 +1593,7 @@ abstract class CoreStore extends Service {
|
|
|
1629
1593
|
});
|
|
1630
1594
|
})(groupedInternalModels);
|
|
1631
1595
|
} else if (ids.length === 1) {
|
|
1632
|
-
|
|
1596
|
+
let pair = seeking[groupedInternalModels[0].id];
|
|
1633
1597
|
_fetchRecord(pair);
|
|
1634
1598
|
} else {
|
|
1635
1599
|
assert("You cannot return an empty array from adapter's method groupRecordsForFindMany");
|
|
@@ -2714,7 +2678,7 @@ abstract class CoreStore extends Service {
|
|
|
2714
2678
|
operation = 'deleteRecord';
|
|
2715
2679
|
}
|
|
2716
2680
|
|
|
2717
|
-
|
|
2681
|
+
options[SaveOp] = operation;
|
|
2718
2682
|
|
|
2719
2683
|
let fetchManagerPromise = this._fetchManager.scheduleSave(internalModel.identifier, options);
|
|
2720
2684
|
let promise = fetchManagerPromise.then(
|
|
@@ -2,7 +2,6 @@ import { getOwner, setOwner } from '@ember/application';
|
|
|
2
2
|
import { assert, deprecate } from '@ember/debug';
|
|
3
3
|
import EmberError from '@ember/error';
|
|
4
4
|
import { get } from '@ember/object';
|
|
5
|
-
import { assign } from '@ember/polyfills';
|
|
6
5
|
import { isPresent } from '@ember/utils';
|
|
7
6
|
import { DEBUG } from '@glimmer/env';
|
|
8
7
|
|
|
@@ -40,7 +39,7 @@ class Store extends CoreStore {
|
|
|
40
39
|
_internalModel: internalModel,
|
|
41
40
|
container: null,
|
|
42
41
|
};
|
|
43
|
-
assign(createOptions, createRecordArgs);
|
|
42
|
+
Object.assign(createOptions, createRecordArgs);
|
|
44
43
|
|
|
45
44
|
// ensure that `getOwner(this)` works inside a model instance
|
|
46
45
|
setOwner(createOptions, getOwner(this));
|
|
@@ -12,7 +12,6 @@ import type { CollectionResourceDocument, SingleResourceDocument } from '../ts-i
|
|
|
12
12
|
import type { FindRecordQuery, Request, SaveRecordMutation } from '../ts-interfaces/fetch-manager';
|
|
13
13
|
import type { ExistingRecordIdentifier, RecordIdentifier, StableRecordIdentifier } from '../ts-interfaces/identifier';
|
|
14
14
|
import type { Dict } from '../ts-interfaces/utils';
|
|
15
|
-
import { symbol } from '../utils/symbol';
|
|
16
15
|
import coerceId from './coerce-id';
|
|
17
16
|
import type CoreStore from './core-store';
|
|
18
17
|
import { errorsArrayToHash } from './errors-utils';
|
|
@@ -30,7 +29,7 @@ function payloadIsNotBlank(adapterPayload): boolean {
|
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
export const SaveOp: unique symbol =
|
|
32
|
+
export const SaveOp: unique symbol = Symbol('SaveOp');
|
|
34
33
|
|
|
35
34
|
interface PendingFetchItem {
|
|
36
35
|
identifier: ExistingRecordIdentifier;
|
|
@@ -3,7 +3,6 @@ import { A, default as EmberArray } from '@ember/array';
|
|
|
3
3
|
import { assert, inspect } from '@ember/debug';
|
|
4
4
|
import EmberError from '@ember/error';
|
|
5
5
|
import { get, set } from '@ember/object';
|
|
6
|
-
import { assign } from '@ember/polyfills';
|
|
7
6
|
import { _backburner as emberBackburner, cancel, run } from '@ember/runloop';
|
|
8
7
|
import { DEBUG } from '@glimmer/env';
|
|
9
8
|
|
|
@@ -354,7 +353,7 @@ export default class InternalModel {
|
|
|
354
353
|
}
|
|
355
354
|
|
|
356
355
|
let additionalCreateOptions = this._recordData._initRecordCreateOptions(properties);
|
|
357
|
-
assign(createOptions, additionalCreateOptions);
|
|
356
|
+
Object.assign(createOptions, additionalCreateOptions);
|
|
358
357
|
|
|
359
358
|
// ensure that `getOwner(this)` works inside a model instance
|
|
360
359
|
setOwner(createOptions, getOwner(store));
|
|
@@ -1456,15 +1455,11 @@ export function extractRecordDataFromRecord(recordOrPromiseRecord) {
|
|
|
1456
1455
|
}
|
|
1457
1456
|
|
|
1458
1457
|
function anyUnloaded(store: CoreStore, relationship: ManyRelationship) {
|
|
1459
|
-
// Can't use `find` because of IE11 and these arrays are potentially massive
|
|
1460
1458
|
let state = relationship.currentState;
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
return unloaded;
|
|
1459
|
+
const unloaded = state.find((s) => {
|
|
1460
|
+
let im = store._internalModelForResource(s);
|
|
1461
|
+
return im._isDematerializing || !im.currentState.isLoaded;
|
|
1462
|
+
});
|
|
1463
|
+
|
|
1464
|
+
return unloaded || false;
|
|
1470
1465
|
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import { A } from '@ember/array';
|
|
6
6
|
import { assert } from '@ember/debug';
|
|
7
7
|
import { get, set } from '@ember/object';
|
|
8
|
-
import { assign } from '@ember/polyfills';
|
|
9
8
|
import { _backburner as emberBackburner } from '@ember/runloop';
|
|
10
9
|
|
|
11
10
|
import { REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT } from '@ember-data/canary-features';
|
|
@@ -281,8 +280,8 @@ class RecordArrayManager {
|
|
|
281
280
|
manager: this,
|
|
282
281
|
isLoaded: true,
|
|
283
282
|
isUpdating: false,
|
|
284
|
-
meta:
|
|
285
|
-
links:
|
|
283
|
+
meta: { ...payload.meta },
|
|
284
|
+
links: { ...payload.links },
|
|
286
285
|
});
|
|
287
286
|
|
|
288
287
|
this._associateWithRecordArray(identifiers, array);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { A } from '@ember/array';
|
|
2
2
|
import { get } from '@ember/object';
|
|
3
|
-
import { assign } from '@ember/polyfills';
|
|
4
3
|
import { once } from '@ember/runloop';
|
|
5
4
|
import { DEBUG } from '@glimmer/env';
|
|
6
5
|
|
|
@@ -86,8 +85,8 @@ let AdapterPopulatedRecordArray = RecordArray.extend({
|
|
|
86
85
|
this.setProperties({
|
|
87
86
|
isLoaded: true,
|
|
88
87
|
isUpdating: false,
|
|
89
|
-
meta:
|
|
90
|
-
links:
|
|
88
|
+
meta: { ...payload.meta },
|
|
89
|
+
links: { ...payload.links },
|
|
91
90
|
});
|
|
92
91
|
|
|
93
92
|
this.manager._associateWithRecordArray(identifiersOrInternalModels, this);
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { deprecate } from '@ember/debug';
|
|
2
|
-
|
|
3
1
|
import type { Object as JSONObject, Value as JSONValue } from 'json-typescript';
|
|
4
2
|
|
|
5
|
-
import { DEPRECATE_REFERENCE_INTERNAL_MODEL } from '@ember-data/private-build-infra/deprecations';
|
|
6
|
-
|
|
7
3
|
import type { LinkObject, PaginationLinks } from '../../ts-interfaces/ember-data-json-api';
|
|
8
4
|
import type { StableRecordIdentifier } from '../../ts-interfaces/identifier';
|
|
9
5
|
import type { JsonApiRelationship } from '../../ts-interfaces/record-data-json-api';
|
|
@@ -185,9 +181,9 @@ abstract class Reference {
|
|
|
185
181
|
related: {
|
|
186
182
|
href: '/articles/1/author'
|
|
187
183
|
},
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
184
|
+
},
|
|
185
|
+
meta: {
|
|
186
|
+
lastUpdated: 1458014400000
|
|
191
187
|
}
|
|
192
188
|
}
|
|
193
189
|
}
|
|
@@ -213,22 +209,4 @@ abstract class Reference {
|
|
|
213
209
|
}
|
|
214
210
|
}
|
|
215
211
|
|
|
216
|
-
if (DEPRECATE_REFERENCE_INTERNAL_MODEL) {
|
|
217
|
-
Object.defineProperty(Reference.prototype, 'internalModel', {
|
|
218
|
-
get() {
|
|
219
|
-
deprecate('Accessing the internalModel property of Reference is deprecated', false, {
|
|
220
|
-
id: 'ember-data:reference-internal-model',
|
|
221
|
-
until: '3.21',
|
|
222
|
-
for: '@ember-data/store',
|
|
223
|
-
since: {
|
|
224
|
-
available: '3.19',
|
|
225
|
-
enabled: '3.19',
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
return REFERENCE_CACHE.get(this);
|
|
230
|
-
},
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
|
|
234
212
|
export default Reference;
|
|
@@ -7,10 +7,9 @@ import type {
|
|
|
7
7
|
} from '../ts-interfaces/fetch-manager';
|
|
8
8
|
import { RequestStateEnum } from '../ts-interfaces/fetch-manager';
|
|
9
9
|
import type { RecordIdentifier } from '../ts-interfaces/identifier';
|
|
10
|
-
import { addSymbol, symbol } from '../utils/symbol';
|
|
11
10
|
|
|
12
|
-
const Touching: unique symbol =
|
|
13
|
-
export const RequestPromise: unique symbol =
|
|
11
|
+
const Touching: unique symbol = Symbol('touching');
|
|
12
|
+
export const RequestPromise: unique symbol = Symbol('promise');
|
|
14
13
|
|
|
15
14
|
interface InternalRequest extends RequestState {
|
|
16
15
|
[Touching]: RecordIdentifier[];
|
|
@@ -41,8 +40,8 @@ export default class RequestCache {
|
|
|
41
40
|
request: queryRequest,
|
|
42
41
|
type,
|
|
43
42
|
} as InternalRequest;
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
request[Touching] = [query.recordIdentifier];
|
|
44
|
+
request[RequestPromise] = promise;
|
|
46
45
|
this._pending[lid].push(request);
|
|
47
46
|
this._triggerSubscriptions(request);
|
|
48
47
|
promise.then(
|
|
@@ -54,7 +53,7 @@ export default class RequestCache {
|
|
|
54
53
|
type,
|
|
55
54
|
response: { data: result },
|
|
56
55
|
} as InternalRequest;
|
|
57
|
-
|
|
56
|
+
finalizedRequest[Touching] = request[Touching];
|
|
58
57
|
this._addDone(finalizedRequest);
|
|
59
58
|
this._triggerSubscriptions(finalizedRequest);
|
|
60
59
|
},
|
|
@@ -66,7 +65,7 @@ export default class RequestCache {
|
|
|
66
65
|
type,
|
|
67
66
|
response: { data: error && error.error },
|
|
68
67
|
} as InternalRequest;
|
|
69
|
-
|
|
68
|
+
finalizedRequest[Touching] = request[Touching];
|
|
70
69
|
this._addDone(finalizedRequest);
|
|
71
70
|
this._triggerSubscriptions(finalizedRequest);
|
|
72
71
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { assert } from '@ember/debug';
|
|
5
5
|
import { get } from '@ember/object';
|
|
6
|
-
import { assign } from '@ember/polyfills';
|
|
7
6
|
|
|
8
7
|
import { CUSTOM_MODEL_CLASS } from '@ember-data/canary-features';
|
|
9
8
|
import { HAS_RECORD_DATA_PACKAGE } from '@ember-data/private-build-infra';
|
|
@@ -234,7 +233,7 @@ export default class Snapshot implements Snapshot {
|
|
|
234
233
|
@public
|
|
235
234
|
*/
|
|
236
235
|
attributes(): Dict<unknown> {
|
|
237
|
-
return
|
|
236
|
+
return { ...this._attributes };
|
|
238
237
|
}
|
|
239
238
|
|
|
240
239
|
/**
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { assert, deprecate, warn } from '@ember/debug';
|
|
2
|
-
import { assign } from '@ember/polyfills';
|
|
3
2
|
import { DEBUG } from '@glimmer/env';
|
|
4
3
|
|
|
5
4
|
import { Promise } from 'rsvp';
|
|
@@ -274,18 +273,12 @@ function fixRelationshipData(relationshipData, relationshipKind, { id, modelName
|
|
|
274
273
|
if (relationshipKind === 'hasMany') {
|
|
275
274
|
payload = relationshipData || [];
|
|
276
275
|
if (relationshipData) {
|
|
277
|
-
// IE11 does not support array.find
|
|
278
276
|
// these arrays could be massive so this is better than filter
|
|
279
277
|
// Note: this is potentially problematic if type/id are not in the
|
|
280
278
|
// same state of normalization.
|
|
281
|
-
let found =
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
if (v.type === parentRelationshipData.type && v.id === parentRelationshipData.id) {
|
|
285
|
-
found = true;
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
279
|
+
let found = relationshipData.find((v) => {
|
|
280
|
+
return v.type === parentRelationshipData.type && v.id === parentRelationshipData.id;
|
|
281
|
+
});
|
|
289
282
|
if (!found) {
|
|
290
283
|
payload.push(parentRelationshipData);
|
|
291
284
|
}
|
|
@@ -294,7 +287,7 @@ function fixRelationshipData(relationshipData, relationshipKind, { id, modelName
|
|
|
294
287
|
}
|
|
295
288
|
} else {
|
|
296
289
|
payload = relationshipData || {};
|
|
297
|
-
assign(payload, parentRelationshipData);
|
|
290
|
+
Object.assign(payload, parentRelationshipData);
|
|
298
291
|
}
|
|
299
292
|
|
|
300
293
|
return payload;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
@module @ember-data/store
|
|
3
3
|
*/
|
|
4
|
-
import { symbol } from '../utils/symbol';
|
|
5
4
|
import type { ExistingResourceObject, ResourceIdentifierObject } from './ember-data-json-api';
|
|
6
5
|
|
|
7
6
|
export type ResourceData = ResourceIdentifierObject | ExistingResourceObject;
|
|
8
7
|
export type IdentifierBucket = 'record';
|
|
9
8
|
|
|
10
9
|
// provided for additional debuggability
|
|
11
|
-
export const DEBUG_CLIENT_ORIGINATED: unique symbol =
|
|
12
|
-
export const DEBUG_IDENTIFIER_BUCKET: unique symbol =
|
|
10
|
+
export const DEBUG_CLIENT_ORIGINATED: unique symbol = Symbol('record-originated-on-client');
|
|
11
|
+
export const DEBUG_IDENTIFIER_BUCKET: unique symbol = Symbol('identifier-bucket');
|
|
13
12
|
|
|
14
13
|
export interface Identifier {
|
|
15
14
|
lid: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-data/store",
|
|
3
|
-
"version": "4.1.0-
|
|
3
|
+
"version": "4.1.0-beta.0",
|
|
4
4
|
"description": "The default blueprint for ember-cli addons.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -17,22 +17,22 @@
|
|
|
17
17
|
"start": "ember serve"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@ember-data/canary-features": "4.1.0-
|
|
21
|
-
"@ember-data/private-build-infra": "4.1.0-
|
|
20
|
+
"@ember-data/canary-features": "4.1.0-beta.0",
|
|
21
|
+
"@ember-data/private-build-infra": "4.1.0-beta.0",
|
|
22
22
|
"@ember/string": "^3.0.0",
|
|
23
23
|
"@glimmer/tracking": "^1.0.4",
|
|
24
|
+
"ember-auto-import": "^2.2.4",
|
|
24
25
|
"ember-cli-babel": "^7.26.6",
|
|
25
26
|
"ember-cli-path-utils": "^1.0.0",
|
|
26
27
|
"ember-cli-typescript": "^4.1.0"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"@ember-data/unpublished-test-infra": "4.1.0-
|
|
30
|
+
"@ember-data/unpublished-test-infra": "4.1.0-beta.0",
|
|
30
31
|
"@ember/optional-features": "^2.0.0",
|
|
31
|
-
"@ember/test-helpers": "^2.
|
|
32
|
+
"@ember/test-helpers": "^2.6.0",
|
|
32
33
|
"@types/ember": "^3.16.5",
|
|
33
34
|
"@types/rsvp": "^4.0.3",
|
|
34
35
|
"broccoli-asset-rev": "^3.0.0",
|
|
35
|
-
"ember-auto-import": "^2.0.0",
|
|
36
36
|
"ember-cli": "~3.26.1",
|
|
37
37
|
"ember-cli-dependency-checker": "^3.2.0",
|
|
38
38
|
"ember-cli-htmlbars": "^5.1.2",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"ember-export-application-global": "^2.0.1",
|
|
44
44
|
"ember-load-initializers": "^2.1.1",
|
|
45
45
|
"ember-maybe-import-regenerator": "^0.1.6",
|
|
46
|
-
"ember-qunit": "^5.1.
|
|
46
|
+
"ember-qunit": "^5.1.5",
|
|
47
47
|
"ember-resolver": "^8.0.0",
|
|
48
|
-
"ember-source": "~3.
|
|
48
|
+
"ember-source": "~3.28.6",
|
|
49
49
|
"ember-source-channel-url": "^3.0.0",
|
|
50
50
|
"ember-try": "^1.4.0",
|
|
51
51
|
"loader.js": "^4.7.0",
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
@module @ember-data/store
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* This symbol provides a Symbol replacement for browsers that do not have it
|
|
7
|
-
* (eg. IE 11).
|
|
8
|
-
*
|
|
9
|
-
* The replacement is different from the native Symbol in some ways. It is a
|
|
10
|
-
* function that produces an output:
|
|
11
|
-
* - iterable;
|
|
12
|
-
* - that is a string, not a symbol.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export const symbol =
|
|
17
|
-
typeof Symbol !== 'undefined'
|
|
18
|
-
? Symbol
|
|
19
|
-
: (key: string) => `__${key}${Math.floor(Math.random() * Date.now())}__` as any;
|
|
20
|
-
|
|
21
|
-
export function addSymbol(obj: object, symbol: Symbol | string, value: any): void {
|
|
22
|
-
if (typeof symbol === 'string') {
|
|
23
|
-
Object.defineProperty(obj, symbol, {
|
|
24
|
-
value,
|
|
25
|
-
configurable: false,
|
|
26
|
-
enumerable: false,
|
|
27
|
-
writable: false,
|
|
28
|
-
});
|
|
29
|
-
} else {
|
|
30
|
-
// Typescript doesn't allow Symbol as an index type
|
|
31
|
-
obj[symbol as unknown as string] = value;
|
|
32
|
-
}
|
|
33
|
-
}
|