@ember-data-mirror/store 5.4.0-alpha.129 → 5.4.0-alpha.130
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/dist/handler-CW2kp6Ua.js +149 -149
- package/package.json +11 -11
package/dist/handler-CW2kp6Ua.js
CHANGED
|
@@ -13,7 +13,7 @@ import { compat } from '@ember-data-mirror/tracking';
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
function coerceId(id) {
|
|
16
|
-
if (macroCondition(getGlobalConfig().
|
|
16
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.deprecations.DEPRECATE_NON_STRICT_ID)) {
|
|
17
17
|
let normalized;
|
|
18
18
|
if (id === null || id === undefined || id === '') {
|
|
19
19
|
normalized = null;
|
|
@@ -31,7 +31,7 @@ function coerceId(id) {
|
|
|
31
31
|
});
|
|
32
32
|
return normalized;
|
|
33
33
|
}
|
|
34
|
-
macroCondition(getGlobalConfig().
|
|
34
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
35
35
|
if (!test) {
|
|
36
36
|
throw new Error(`Resource IDs must be a non-empty string or null. Received '${String(id)}'.`);
|
|
37
37
|
}
|
|
@@ -45,7 +45,7 @@ function ensureStringId(id) {
|
|
|
45
45
|
} else if (typeof id === 'number' && !isNaN(id)) {
|
|
46
46
|
normalized = String(id);
|
|
47
47
|
}
|
|
48
|
-
macroCondition(getGlobalConfig().
|
|
48
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
49
49
|
if (!test) {
|
|
50
50
|
throw new Error(`Expected id to be a string or number, received ${String(id)}`);
|
|
51
51
|
}
|
|
@@ -53,7 +53,7 @@ function ensureStringId(id) {
|
|
|
53
53
|
return normalized;
|
|
54
54
|
}
|
|
55
55
|
function normalizeModelName(type) {
|
|
56
|
-
if (macroCondition(getGlobalConfig().
|
|
56
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.deprecations.DEPRECATE_NON_STRICT_TYPES)) {
|
|
57
57
|
const result = dasherize(type);
|
|
58
58
|
deprecate(`The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`, result === type, {
|
|
59
59
|
id: 'ember-data-mirror:deprecate-non-strict-types',
|
|
@@ -139,11 +139,11 @@ function isDocumentIdentifier(identifier) {
|
|
|
139
139
|
}
|
|
140
140
|
const isFastBoot = typeof FastBoot !== 'undefined';
|
|
141
141
|
const _crypto = isFastBoot ? FastBoot.require('crypto') : globalThis.crypto;
|
|
142
|
-
if (macroCondition(getGlobalConfig().
|
|
142
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.polyfillUUID)) {
|
|
143
143
|
installPolyfill();
|
|
144
144
|
}
|
|
145
145
|
function uuidv4() {
|
|
146
|
-
macroCondition(getGlobalConfig().
|
|
146
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
147
147
|
if (!test) {
|
|
148
148
|
throw new Error('crypto.randomUUID needs to be avaliable. Some browsers incorrectly disallow it in insecure contexts. You maybe want to enable the polyfill: https://github.com/emberjs/data#randomuuid-polyfill');
|
|
149
149
|
}
|
|
@@ -192,7 +192,7 @@ function updateTypeIdMapping(typeMap, identifier, id) {
|
|
|
192
192
|
}
|
|
193
193
|
function defaultUpdateMethod(identifier, data, bucket) {
|
|
194
194
|
if (bucket === 'record') {
|
|
195
|
-
macroCondition(getGlobalConfig().
|
|
195
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
196
196
|
if (!test) {
|
|
197
197
|
throw new Error(`Expected identifier to be a StableRecordIdentifier`);
|
|
198
198
|
}
|
|
@@ -206,7 +206,7 @@ function defaultKeyInfoMethod(resource, known) {
|
|
|
206
206
|
// TODO RFC something to make this configurable
|
|
207
207
|
const id = hasId(resource) ? coerceId(resource.id) : null;
|
|
208
208
|
const type = hasType(resource) ? normalizeModelName(resource.type) : known ? known.type : null;
|
|
209
|
-
macroCondition(getGlobalConfig().
|
|
209
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
210
210
|
if (!test) {
|
|
211
211
|
throw new Error(`Expected keyInfoForResource to provide a type for the resource`);
|
|
212
212
|
}
|
|
@@ -221,7 +221,7 @@ function defaultGenerationMethod(data, bucket) {
|
|
|
221
221
|
if (hasLid(data)) {
|
|
222
222
|
return data.lid;
|
|
223
223
|
}
|
|
224
|
-
macroCondition(getGlobalConfig().
|
|
224
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
225
225
|
if (!test) {
|
|
226
226
|
throw new Error(`Cannot generate an identifier for a resource without a type`);
|
|
227
227
|
}
|
|
@@ -241,7 +241,7 @@ function defaultGenerationMethod(data, bucket) {
|
|
|
241
241
|
}
|
|
242
242
|
return null;
|
|
243
243
|
}
|
|
244
|
-
macroCondition(getGlobalConfig().
|
|
244
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
245
245
|
{
|
|
246
246
|
throw new Error(`Unknown bucket ${bucket}`);
|
|
247
247
|
}
|
|
@@ -252,7 +252,7 @@ function defaultMergeMethod(a, _b, _c) {
|
|
|
252
252
|
return a;
|
|
253
253
|
}
|
|
254
254
|
let DEBUG_MAP;
|
|
255
|
-
if (macroCondition(getGlobalConfig().
|
|
255
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
256
256
|
DEBUG_MAP = getOrSetGlobal('DEBUG_MAP', new WeakMap());
|
|
257
257
|
}
|
|
258
258
|
|
|
@@ -310,19 +310,19 @@ class IdentifierCache {
|
|
|
310
310
|
*/
|
|
311
311
|
|
|
312
312
|
_getRecordIdentifier(resource, shouldGenerate) {
|
|
313
|
-
if (macroCondition(getGlobalConfig().
|
|
313
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_IDENTIFIERS)) {
|
|
314
314
|
// eslint-disable-next-line no-console
|
|
315
315
|
console.groupCollapsed(`Identifiers: ${shouldGenerate ? 'Generating' : 'Peeking'} Identifier`, resource);
|
|
316
316
|
}
|
|
317
317
|
// short circuit if we're already the stable version
|
|
318
318
|
if (isStableIdentifier(resource)) {
|
|
319
|
-
if (macroCondition(getGlobalConfig().
|
|
319
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
320
320
|
// TODO should we instead just treat this case as a new generation skipping the short circuit?
|
|
321
321
|
if (!this._cache.resources.has(resource.lid) || this._cache.resources.get(resource.lid) !== resource) {
|
|
322
322
|
throw new Error(`The supplied identifier ${JSON.stringify(resource)} does not belong to this store instance`);
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
|
-
if (macroCondition(getGlobalConfig().
|
|
325
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_IDENTIFIERS)) {
|
|
326
326
|
// eslint-disable-next-line no-console
|
|
327
327
|
console.log(`Identifiers: cache HIT - Stable ${resource.lid}`);
|
|
328
328
|
// eslint-disable-next-line no-console
|
|
@@ -333,20 +333,20 @@ class IdentifierCache {
|
|
|
333
333
|
|
|
334
334
|
// the resource is unknown, ask the application to identify this data for us
|
|
335
335
|
const lid = this._generate(resource, 'record');
|
|
336
|
-
if (macroCondition(getGlobalConfig().
|
|
336
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_IDENTIFIERS)) {
|
|
337
337
|
// eslint-disable-next-line no-console
|
|
338
338
|
console.log(`Identifiers: ${lid ? 'no ' : ''}lid ${lid ? lid + ' ' : ''}determined for resource`, resource);
|
|
339
339
|
}
|
|
340
340
|
let identifier = /*#__NOINLINE__*/getIdentifierFromLid(this._cache, lid, resource);
|
|
341
341
|
if (identifier !== null) {
|
|
342
|
-
if (macroCondition(getGlobalConfig().
|
|
342
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_IDENTIFIERS)) {
|
|
343
343
|
// eslint-disable-next-line no-console
|
|
344
344
|
console.groupEnd();
|
|
345
345
|
}
|
|
346
346
|
return identifier;
|
|
347
347
|
}
|
|
348
348
|
if (shouldGenerate === 0) {
|
|
349
|
-
if (macroCondition(getGlobalConfig().
|
|
349
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_IDENTIFIERS)) {
|
|
350
350
|
// eslint-disable-next-line no-console
|
|
351
351
|
console.groupEnd();
|
|
352
352
|
}
|
|
@@ -366,7 +366,7 @@ class IdentifierCache {
|
|
|
366
366
|
identifier = /*#__NOINLINE__*/makeStableRecordIdentifier(keyInfo, 'record', false);
|
|
367
367
|
}
|
|
368
368
|
addResourceToCache(this._cache, identifier);
|
|
369
|
-
if (macroCondition(getGlobalConfig().
|
|
369
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_IDENTIFIERS)) {
|
|
370
370
|
// eslint-disable-next-line no-console
|
|
371
371
|
console.groupEnd();
|
|
372
372
|
}
|
|
@@ -408,7 +408,7 @@ class IdentifierCache {
|
|
|
408
408
|
identifier = {
|
|
409
409
|
lid: cacheKey
|
|
410
410
|
};
|
|
411
|
-
if (macroCondition(getGlobalConfig().
|
|
411
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
412
412
|
Object.freeze(identifier);
|
|
413
413
|
}
|
|
414
414
|
DOCUMENTS.add(identifier);
|
|
@@ -454,7 +454,7 @@ class IdentifierCache {
|
|
|
454
454
|
}, 'record', true);
|
|
455
455
|
|
|
456
456
|
// populate our unique table
|
|
457
|
-
if (macroCondition(getGlobalConfig().
|
|
457
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
458
458
|
if (this._cache.resources.has(identifier.lid)) {
|
|
459
459
|
throw new Error(`The lid generated for the new record is not unique as it matches an existing identifier`);
|
|
460
460
|
}
|
|
@@ -462,7 +462,7 @@ class IdentifierCache {
|
|
|
462
462
|
|
|
463
463
|
/*#__NOINLINE__*/
|
|
464
464
|
addResourceToCache(this._cache, identifier);
|
|
465
|
-
if (macroCondition(getGlobalConfig().
|
|
465
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_IDENTIFIERS)) {
|
|
466
466
|
// eslint-disable-next-line no-console
|
|
467
467
|
console.log(`Identifiers: created identifier ${String(identifier)} for newly generated resource`, data);
|
|
468
468
|
}
|
|
@@ -511,7 +511,7 @@ class IdentifierCache {
|
|
|
511
511
|
if (hadLid) {
|
|
512
512
|
data.lid = identifier.lid;
|
|
513
513
|
}
|
|
514
|
-
if (macroCondition(getGlobalConfig().
|
|
514
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_IDENTIFIERS)) {
|
|
515
515
|
// eslint-disable-next-line no-console
|
|
516
516
|
console.log(`Identifiers: merged identifiers ${generatedIdentifier.lid} and ${existingIdentifier.lid} for resource into ${identifier.lid}`, data);
|
|
517
517
|
}
|
|
@@ -523,12 +523,12 @@ class IdentifierCache {
|
|
|
523
523
|
|
|
524
524
|
// add to our own secondary lookup table
|
|
525
525
|
if (id !== newId && newId !== null) {
|
|
526
|
-
if (macroCondition(getGlobalConfig().
|
|
526
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_IDENTIFIERS)) {
|
|
527
527
|
// eslint-disable-next-line no-console
|
|
528
528
|
console.log(`Identifiers: updated id for identifier ${identifier.lid} from '${String(id)}' to '${String(newId)}' for resource`, data);
|
|
529
529
|
}
|
|
530
530
|
const typeSet = this._cache.resourcesByType[identifier.type];
|
|
531
|
-
macroCondition(getGlobalConfig().
|
|
531
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
532
532
|
if (!test) {
|
|
533
533
|
throw new Error(`Expected to find a typeSet for ${identifier.type}`);
|
|
534
534
|
}
|
|
@@ -537,7 +537,7 @@ class IdentifierCache {
|
|
|
537
537
|
if (id !== null) {
|
|
538
538
|
typeSet.id.delete(id);
|
|
539
539
|
}
|
|
540
|
-
} else if (macroCondition(getGlobalConfig().
|
|
540
|
+
} else if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_IDENTIFIERS)) {
|
|
541
541
|
// eslint-disable-next-line no-console
|
|
542
542
|
console.log(`Identifiers: updated identifier ${identifier.lid} resource`, data);
|
|
543
543
|
}
|
|
@@ -549,7 +549,7 @@ class IdentifierCache {
|
|
|
549
549
|
* @private
|
|
550
550
|
*/
|
|
551
551
|
_mergeRecordIdentifiers(keyInfo, identifier, existingIdentifier, data) {
|
|
552
|
-
macroCondition(getGlobalConfig().
|
|
552
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
553
553
|
if (!test) {
|
|
554
554
|
throw new Error(`Expected keyInfo to contain an id`);
|
|
555
555
|
}
|
|
@@ -600,7 +600,7 @@ class IdentifierCache {
|
|
|
600
600
|
forgetRecordIdentifier(identifierObject) {
|
|
601
601
|
const identifier = this.getOrCreateRecordIdentifier(identifierObject);
|
|
602
602
|
const typeSet = this._cache.resourcesByType[identifier.type];
|
|
603
|
-
macroCondition(getGlobalConfig().
|
|
603
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
604
604
|
if (!test) {
|
|
605
605
|
throw new Error(`Expected to find a typeSet for ${identifier.type}`);
|
|
606
606
|
}
|
|
@@ -617,13 +617,13 @@ class IdentifierCache {
|
|
|
617
617
|
});
|
|
618
618
|
this._cache.polymorphicLidBackMap.delete(identifier.lid);
|
|
619
619
|
}
|
|
620
|
-
if (macroCondition(getGlobalConfig().
|
|
620
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
621
621
|
identifier[DEBUG_STALE_CACHE_OWNER] = identifier[CACHE_OWNER];
|
|
622
622
|
}
|
|
623
623
|
identifier[CACHE_OWNER] = undefined;
|
|
624
624
|
IDENTIFIERS.delete(identifier);
|
|
625
625
|
this._forget(identifier, 'record');
|
|
626
|
-
if (macroCondition(getGlobalConfig().
|
|
626
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_IDENTIFIERS)) {
|
|
627
627
|
// eslint-disable-next-line no-console
|
|
628
628
|
console.log(`Identifiers: released identifier ${identifierObject.lid}`);
|
|
629
629
|
}
|
|
@@ -638,7 +638,7 @@ class IdentifierCache {
|
|
|
638
638
|
}
|
|
639
639
|
function makeStableRecordIdentifier(recordIdentifier, bucket, clientOriginated) {
|
|
640
640
|
IDENTIFIERS.add(recordIdentifier);
|
|
641
|
-
if (macroCondition(getGlobalConfig().
|
|
641
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
642
642
|
// we enforce immutability in dev
|
|
643
643
|
// but preserve our ability to do controlled updates to the reference
|
|
644
644
|
let wrapper = {
|
|
@@ -700,7 +700,7 @@ function makeStableRecordIdentifier(recordIdentifier, bucket, clientOriginated)
|
|
|
700
700
|
return recordIdentifier;
|
|
701
701
|
}
|
|
702
702
|
function performRecordIdentifierUpdate(identifier, keyInfo, data, updateFn) {
|
|
703
|
-
if (macroCondition(getGlobalConfig().
|
|
703
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
704
704
|
const {
|
|
705
705
|
id,
|
|
706
706
|
type
|
|
@@ -775,7 +775,7 @@ function detectMerge(cache, keyInfo, identifier, data) {
|
|
|
775
775
|
}
|
|
776
776
|
function getIdentifierFromLid(cache, lid, resource) {
|
|
777
777
|
const identifier = cache.resources.get(lid);
|
|
778
|
-
if (macroCondition(getGlobalConfig().
|
|
778
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_IDENTIFIERS)) {
|
|
779
779
|
// eslint-disable-next-line no-console
|
|
780
780
|
console.log(`Identifiers: cache ${identifier ? 'HIT' : 'MISS'} - Non-Stable ${lid}`, resource);
|
|
781
781
|
}
|
|
@@ -956,7 +956,7 @@ class RecordReference {
|
|
|
956
956
|
if (id !== null) {
|
|
957
957
|
return this.store.findRecord(this.type, id);
|
|
958
958
|
}
|
|
959
|
-
macroCondition(getGlobalConfig().
|
|
959
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
960
960
|
{
|
|
961
961
|
throw new Error(`Unable to fetch record of type ${this.type} without an id`);
|
|
962
962
|
}
|
|
@@ -983,7 +983,7 @@ class RecordReference {
|
|
|
983
983
|
reload: true
|
|
984
984
|
});
|
|
985
985
|
}
|
|
986
|
-
macroCondition(getGlobalConfig().
|
|
986
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
987
987
|
{
|
|
988
988
|
throw new Error(`Unable to fetch record of type ${this.type} without an id`);
|
|
989
989
|
}
|
|
@@ -1039,7 +1039,7 @@ class CacheCapabilitiesManager {
|
|
|
1039
1039
|
});
|
|
1040
1040
|
}
|
|
1041
1041
|
notifyChange(identifier, namespace, key) {
|
|
1042
|
-
macroCondition(getGlobalConfig().
|
|
1042
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
1043
1043
|
if (!test) {
|
|
1044
1044
|
throw new Error(`Expected a stable identifier`);
|
|
1045
1045
|
}
|
|
@@ -1058,7 +1058,7 @@ class CacheCapabilitiesManager {
|
|
|
1058
1058
|
return this._store.schema;
|
|
1059
1059
|
}
|
|
1060
1060
|
setRecordId(identifier, id) {
|
|
1061
|
-
macroCondition(getGlobalConfig().
|
|
1061
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
1062
1062
|
if (!test) {
|
|
1063
1063
|
throw new Error(`Expected a stable identifier`);
|
|
1064
1064
|
}
|
|
@@ -1069,7 +1069,7 @@ class CacheCapabilitiesManager {
|
|
|
1069
1069
|
return Boolean(this._store._instanceCache.peek(identifier));
|
|
1070
1070
|
}
|
|
1071
1071
|
disconnectRecord(identifier) {
|
|
1072
|
-
macroCondition(getGlobalConfig().
|
|
1072
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
1073
1073
|
if (!test) {
|
|
1074
1074
|
throw new Error(`Expected a stable identifier`);
|
|
1075
1075
|
}
|
|
@@ -1078,7 +1078,7 @@ class CacheCapabilitiesManager {
|
|
|
1078
1078
|
this._pendingNotifies.delete(identifier);
|
|
1079
1079
|
}
|
|
1080
1080
|
}
|
|
1081
|
-
if (macroCondition(getGlobalConfig().
|
|
1081
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.deprecations.ENABLE_LEGACY_SCHEMA_SERVICE)) {
|
|
1082
1082
|
CacheCapabilitiesManager.prototype.getSchemaDefinitionService = function () {
|
|
1083
1083
|
// FIXME add deprecation for this
|
|
1084
1084
|
return this._store.schema;
|
|
@@ -1092,7 +1092,7 @@ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_SCHEMA
|
|
|
1092
1092
|
|
|
1093
1093
|
const CacheForIdentifierCache = getOrSetGlobal('CacheForIdentifierCache', new Map());
|
|
1094
1094
|
function setCacheFor(identifier, cache) {
|
|
1095
|
-
macroCondition(getGlobalConfig().
|
|
1095
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
1096
1096
|
if (!test) {
|
|
1097
1097
|
throw new Error(`Illegal set of identifier`);
|
|
1098
1098
|
}
|
|
@@ -1142,7 +1142,7 @@ function peekRecordIdentifier(record) {
|
|
|
1142
1142
|
*/
|
|
1143
1143
|
|
|
1144
1144
|
function recordIdentifierFor(record) {
|
|
1145
|
-
macroCondition(getGlobalConfig().
|
|
1145
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
1146
1146
|
if (!test) {
|
|
1147
1147
|
throw new Error(`${String(record)} is not a record instantiated by @ember-data-mirror/store`);
|
|
1148
1148
|
}
|
|
@@ -1150,7 +1150,7 @@ function recordIdentifierFor(record) {
|
|
|
1150
1150
|
return RecordCache.get(record);
|
|
1151
1151
|
}
|
|
1152
1152
|
function setRecordIdentifier(record, identifier) {
|
|
1153
|
-
if (macroCondition(getGlobalConfig().
|
|
1153
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
1154
1154
|
if (RecordCache.has(record) && RecordCache.get(record) !== identifier) {
|
|
1155
1155
|
throw new Error(`${String(record)} was already assigned an identifier`);
|
|
1156
1156
|
}
|
|
@@ -1169,7 +1169,7 @@ function setRecordIdentifier(record, identifier) {
|
|
|
1169
1169
|
const StoreMap = getOrSetGlobal('StoreMap', new Map());
|
|
1170
1170
|
function storeFor(record) {
|
|
1171
1171
|
const store = StoreMap.get(record);
|
|
1172
|
-
macroCondition(getGlobalConfig().
|
|
1172
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
1173
1173
|
if (!test) {
|
|
1174
1174
|
throw new Error(`A record in a disconnected state cannot utilize the store. This typically means the record has been destroyed, most commonly by unloading it.`);
|
|
1175
1175
|
}
|
|
@@ -1211,7 +1211,7 @@ class InstanceCache {
|
|
|
1211
1211
|
if ('id' in resourceData) {
|
|
1212
1212
|
throw new Error(`Failed to update the 'id' for the RecordIdentifier '${identifier.type}:${String(identifier.id)} (${identifier.lid})' to '${String(resourceData.id)}', because that id is already in use by '${matchedIdentifier.type}:${String(matchedIdentifier.id)} (${matchedIdentifier.lid})'`);
|
|
1213
1213
|
}
|
|
1214
|
-
macroCondition(getGlobalConfig().
|
|
1214
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
1215
1215
|
{
|
|
1216
1216
|
throw new Error(`Failed to update the RecordIdentifier '${identifier.type}:${String(identifier.id)} (${identifier.lid})' to merge with the detected duplicate identifier '${matchedIdentifier.type}:${String(matchedIdentifier.id)} (${String(matchedIdentifier.lid)})'`);
|
|
1217
1217
|
}
|
|
@@ -1240,7 +1240,7 @@ class InstanceCache {
|
|
|
1240
1240
|
getRecord(identifier, properties) {
|
|
1241
1241
|
let record = this.__instances.record.get(identifier);
|
|
1242
1242
|
if (!record) {
|
|
1243
|
-
macroCondition(getGlobalConfig().
|
|
1243
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
1244
1244
|
if (!test) {
|
|
1245
1245
|
throw new Error(`Cannot create a new record instance while the store is being destroyed`);
|
|
1246
1246
|
}
|
|
@@ -1252,7 +1252,7 @@ class InstanceCache {
|
|
|
1252
1252
|
setCacheFor(record, cache);
|
|
1253
1253
|
StoreMap.set(record, this.store);
|
|
1254
1254
|
this.__instances.record.set(identifier, record);
|
|
1255
|
-
if (macroCondition(getGlobalConfig().
|
|
1255
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_INSTANCE_CACHE)) {
|
|
1256
1256
|
// eslint-disable-next-line no-console
|
|
1257
1257
|
console.log(`InstanceCache: created Record for ${String(identifier)}`, properties);
|
|
1258
1258
|
}
|
|
@@ -1291,7 +1291,7 @@ class InstanceCache {
|
|
|
1291
1291
|
}
|
|
1292
1292
|
disconnect(identifier) {
|
|
1293
1293
|
const record = this.__instances.record.get(identifier);
|
|
1294
|
-
macroCondition(getGlobalConfig().
|
|
1294
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
1295
1295
|
if (!test) {
|
|
1296
1296
|
throw new Error('Cannot destroy record while it is still materialized');
|
|
1297
1297
|
}
|
|
@@ -1300,25 +1300,25 @@ class InstanceCache {
|
|
|
1300
1300
|
this.store.identifierCache.forgetRecordIdentifier(identifier);
|
|
1301
1301
|
removeRecordDataFor(identifier);
|
|
1302
1302
|
this.store._requestCache._clearEntries(identifier);
|
|
1303
|
-
if (macroCondition(getGlobalConfig().
|
|
1303
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_INSTANCE_CACHE)) {
|
|
1304
1304
|
// eslint-disable-next-line no-console
|
|
1305
1305
|
console.log(`InstanceCache: disconnected ${String(identifier)}`);
|
|
1306
1306
|
}
|
|
1307
1307
|
}
|
|
1308
1308
|
unloadRecord(identifier) {
|
|
1309
|
-
if (macroCondition(getGlobalConfig().
|
|
1309
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
1310
1310
|
const requests = this.store.getRequestStateService().getPendingRequestsForRecord(identifier);
|
|
1311
1311
|
if (requests.some(req => {
|
|
1312
1312
|
return req.type === 'mutation';
|
|
1313
1313
|
})) {
|
|
1314
|
-
macroCondition(getGlobalConfig().
|
|
1314
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
1315
1315
|
{
|
|
1316
1316
|
throw new Error(`You can only unload a record which is not inFlight. '${String(identifier)}'`);
|
|
1317
1317
|
}
|
|
1318
1318
|
})() : {};
|
|
1319
1319
|
}
|
|
1320
1320
|
}
|
|
1321
|
-
if (macroCondition(getGlobalConfig().
|
|
1321
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_INSTANCE_CACHE)) {
|
|
1322
1322
|
// eslint-disable-next-line no-console
|
|
1323
1323
|
console.groupCollapsed(`InstanceCache: unloading record for ${String(identifier)}`);
|
|
1324
1324
|
}
|
|
@@ -1333,7 +1333,7 @@ class InstanceCache {
|
|
|
1333
1333
|
StoreMap.delete(record);
|
|
1334
1334
|
RecordCache.delete(record);
|
|
1335
1335
|
removeRecordDataFor(record);
|
|
1336
|
-
if (macroCondition(getGlobalConfig().
|
|
1336
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_INSTANCE_CACHE)) {
|
|
1337
1337
|
// eslint-disable-next-line no-console
|
|
1338
1338
|
console.log(`InstanceCache: destroyed record for ${String(identifier)}`);
|
|
1339
1339
|
}
|
|
@@ -1341,7 +1341,7 @@ class InstanceCache {
|
|
|
1341
1341
|
if (cache) {
|
|
1342
1342
|
cache.unloadRecord(identifier);
|
|
1343
1343
|
removeRecordDataFor(identifier);
|
|
1344
|
-
if (macroCondition(getGlobalConfig().
|
|
1344
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_INSTANCE_CACHE)) {
|
|
1345
1345
|
// eslint-disable-next-line no-console
|
|
1346
1346
|
console.log(`InstanceCache: destroyed cache for ${String(identifier)}`);
|
|
1347
1347
|
}
|
|
@@ -1349,7 +1349,7 @@ class InstanceCache {
|
|
|
1349
1349
|
this.disconnect(identifier);
|
|
1350
1350
|
}
|
|
1351
1351
|
this.store._requestCache._clearEntries(identifier);
|
|
1352
|
-
if (macroCondition(getGlobalConfig().
|
|
1352
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_INSTANCE_CACHE)) {
|
|
1353
1353
|
// eslint-disable-next-line no-console
|
|
1354
1354
|
console.log(`InstanceCache: unloaded RecordData for ${String(identifier)}`);
|
|
1355
1355
|
// eslint-disable-next-line no-console
|
|
@@ -1388,7 +1388,7 @@ class InstanceCache {
|
|
|
1388
1388
|
const oldId = identifier.id;
|
|
1389
1389
|
|
|
1390
1390
|
// ID absolutely can't be missing if the oldID is empty (missing Id in response for a new record)
|
|
1391
|
-
macroCondition(getGlobalConfig().
|
|
1391
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
1392
1392
|
if (!test) {
|
|
1393
1393
|
throw new Error(`'${type}' was saved to the server, but the response does not have an id and your record does not either.`);
|
|
1394
1394
|
}
|
|
@@ -1396,7 +1396,7 @@ class InstanceCache {
|
|
|
1396
1396
|
|
|
1397
1397
|
// ID absolutely can't be different than oldID if oldID is not null
|
|
1398
1398
|
// TODO this assertion and restriction may not strictly be needed in the identifiers world
|
|
1399
|
-
macroCondition(getGlobalConfig().
|
|
1399
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
1400
1400
|
if (!test) {
|
|
1401
1401
|
throw new Error(`Cannot update the id for '${type}:${lid}' from '${String(oldId)}' to '${id}'.`);
|
|
1402
1402
|
}
|
|
@@ -1408,7 +1408,7 @@ class InstanceCache {
|
|
|
1408
1408
|
warn(`Your ${type} record was saved to the server, but the response does not have an id.`, !(oldId !== null && id === null));
|
|
1409
1409
|
return;
|
|
1410
1410
|
}
|
|
1411
|
-
if (macroCondition(getGlobalConfig().
|
|
1411
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_INSTANCE_CACHE)) {
|
|
1412
1412
|
// eslint-disable-next-line no-console
|
|
1413
1413
|
console.log(`InstanceCache: updating id to '${id}' for record ${String(identifier)}`);
|
|
1414
1414
|
}
|
|
@@ -1416,7 +1416,7 @@ class InstanceCache {
|
|
|
1416
1416
|
type,
|
|
1417
1417
|
id
|
|
1418
1418
|
});
|
|
1419
|
-
macroCondition(getGlobalConfig().
|
|
1419
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
1420
1420
|
if (!test) {
|
|
1421
1421
|
throw new Error(`'${type}' was saved to the server, but the response returned the new id '${id}', which has already been used with another record.'`);
|
|
1422
1422
|
}
|
|
@@ -1481,7 +1481,7 @@ function preloadData(store, identifier, preload) {
|
|
|
1481
1481
|
function preloadRelationship(schema, preloadValue) {
|
|
1482
1482
|
const relatedType = schema.type;
|
|
1483
1483
|
if (schema.kind === 'hasMany') {
|
|
1484
|
-
macroCondition(getGlobalConfig().
|
|
1484
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
1485
1485
|
if (!test) {
|
|
1486
1486
|
throw new Error('You need to pass in an array to set a hasMany property on a record');
|
|
1487
1487
|
}
|
|
@@ -1490,7 +1490,7 @@ function preloadRelationship(schema, preloadValue) {
|
|
|
1490
1490
|
data: preloadValue.map(value => _convertPreloadRelationshipToJSON(value, relatedType))
|
|
1491
1491
|
};
|
|
1492
1492
|
}
|
|
1493
|
-
macroCondition(getGlobalConfig().
|
|
1493
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
1494
1494
|
if (!test) {
|
|
1495
1495
|
throw new Error('You should not pass in an array to set a belongsTo property on a record');
|
|
1496
1496
|
}
|
|
@@ -2169,7 +2169,7 @@ function runLoopIsFlushing() {
|
|
|
2169
2169
|
}
|
|
2170
2170
|
function _unsubscribe(tokens, token, cache) {
|
|
2171
2171
|
const identifier = tokens.get(token);
|
|
2172
|
-
if (macroCondition(getGlobalConfig().
|
|
2172
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_NOTIFICATIONS)) {
|
|
2173
2173
|
if (!identifier) {
|
|
2174
2174
|
// eslint-disable-next-line no-console
|
|
2175
2175
|
console.log('Passed unknown unsubscribe token to unsubscribe', identifier);
|
|
@@ -2231,7 +2231,7 @@ class NotificationManager {
|
|
|
2231
2231
|
*/
|
|
2232
2232
|
|
|
2233
2233
|
subscribe(identifier, callback) {
|
|
2234
|
-
macroCondition(getGlobalConfig().
|
|
2234
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
2235
2235
|
if (!test) {
|
|
2236
2236
|
throw new Error(`Expected to receive a stable Identifier to subscribe to`);
|
|
2237
2237
|
}
|
|
@@ -2241,7 +2241,7 @@ class NotificationManager {
|
|
|
2241
2241
|
map = new Map();
|
|
2242
2242
|
this._cache.set(identifier, map);
|
|
2243
2243
|
}
|
|
2244
|
-
const unsubToken = macroCondition(getGlobalConfig().
|
|
2244
|
+
const unsubToken = macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? {
|
|
2245
2245
|
_tokenRef: tokenId++
|
|
2246
2246
|
} : {};
|
|
2247
2247
|
map.set(unsubToken, callback);
|
|
@@ -2274,19 +2274,19 @@ class NotificationManager {
|
|
|
2274
2274
|
*/
|
|
2275
2275
|
|
|
2276
2276
|
notify(identifier, value, key) {
|
|
2277
|
-
macroCondition(getGlobalConfig().
|
|
2277
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
2278
2278
|
if (!test) {
|
|
2279
2279
|
throw new Error(`Notify does not accept a key argument for the namespace '${value}'. Received key '${key || ''}'.`);
|
|
2280
2280
|
}
|
|
2281
2281
|
})(!key || value === 'attributes' || value === 'relationships') : {};
|
|
2282
2282
|
if (!isStableIdentifier(identifier) && !isDocumentIdentifier(identifier)) {
|
|
2283
|
-
if (macroCondition(getGlobalConfig().
|
|
2283
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_NOTIFICATIONS)) {
|
|
2284
2284
|
// eslint-disable-next-line no-console
|
|
2285
2285
|
console.log(`Notifying: Expected to receive a stable Identifier to notify '${value}' '${key || ''}' with, but ${String(identifier)} is not in the cache`, identifier);
|
|
2286
2286
|
}
|
|
2287
2287
|
return false;
|
|
2288
2288
|
}
|
|
2289
|
-
if (macroCondition(getGlobalConfig().
|
|
2289
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_NOTIFICATIONS)) {
|
|
2290
2290
|
// eslint-disable-next-line no-console
|
|
2291
2291
|
console.log(`Buffering Notify: ${String(identifier.lid)}\t${value}\t${key || ''}`);
|
|
2292
2292
|
}
|
|
@@ -2334,7 +2334,7 @@ class NotificationManager {
|
|
|
2334
2334
|
this._onFlushCB = undefined;
|
|
2335
2335
|
}
|
|
2336
2336
|
_flushNotification(identifier, value, key) {
|
|
2337
|
-
if (macroCondition(getGlobalConfig().
|
|
2337
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_NOTIFICATIONS)) {
|
|
2338
2338
|
// eslint-disable-next-line no-console
|
|
2339
2339
|
console.log(`Notifying: ${String(identifier)}\t${value}\t${key || ''}`);
|
|
2340
2340
|
}
|
|
@@ -2424,7 +2424,7 @@ function safeForEach(instance, arr, store, callback, target) {
|
|
|
2424
2424
|
}
|
|
2425
2425
|
// clone to prevent mutation
|
|
2426
2426
|
arr = arr.slice();
|
|
2427
|
-
macroCondition(getGlobalConfig().
|
|
2427
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
2428
2428
|
if (!test) {
|
|
2429
2429
|
throw new Error('`forEach` expects a function as first argument.');
|
|
2430
2430
|
}
|
|
@@ -2578,7 +2578,7 @@ class IdentifierArray {
|
|
|
2578
2578
|
// array functions must run through Reflect to work properly
|
|
2579
2579
|
// binding via other means will not work.
|
|
2580
2580
|
if (!options.allowMutation) {
|
|
2581
|
-
macroCondition(getGlobalConfig().
|
|
2581
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
2582
2582
|
if (!test) {
|
|
2583
2583
|
throw new Error(`Mutating this array of records via ${String(prop)} is not allowed.`);
|
|
2584
2584
|
}
|
|
@@ -2586,7 +2586,7 @@ class IdentifierArray {
|
|
|
2586
2586
|
return;
|
|
2587
2587
|
}
|
|
2588
2588
|
const args = Array.prototype.slice.call(arguments);
|
|
2589
|
-
macroCondition(getGlobalConfig().
|
|
2589
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
2590
2590
|
if (!test) {
|
|
2591
2591
|
throw new Error(`Cannot start a new array transaction while a previous transaction is underway`);
|
|
2592
2592
|
}
|
|
@@ -2632,7 +2632,7 @@ class IdentifierArray {
|
|
|
2632
2632
|
} else if (transaction) {
|
|
2633
2633
|
return Reflect.set(target, prop, value);
|
|
2634
2634
|
} else {
|
|
2635
|
-
macroCondition(getGlobalConfig().
|
|
2635
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
2636
2636
|
{
|
|
2637
2637
|
throw new Error(`unexpected length set`);
|
|
2638
2638
|
}
|
|
@@ -2659,7 +2659,7 @@ class IdentifierArray {
|
|
|
2659
2659
|
if (index === null || index > target.length) {
|
|
2660
2660
|
if (index !== null && transaction) {
|
|
2661
2661
|
const identifier = recordIdentifierFor(value);
|
|
2662
|
-
macroCondition(getGlobalConfig().
|
|
2662
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
2663
2663
|
if (!test) {
|
|
2664
2664
|
throw new Error(`Cannot set index ${index} past the end of the array.`);
|
|
2665
2665
|
}
|
|
@@ -2674,7 +2674,7 @@ class IdentifierArray {
|
|
|
2674
2674
|
return false;
|
|
2675
2675
|
}
|
|
2676
2676
|
if (!options.allowMutation) {
|
|
2677
|
-
macroCondition(getGlobalConfig().
|
|
2677
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
2678
2678
|
if (!test) {
|
|
2679
2679
|
throw new Error(`Mutating ${String(prop)} on this Array is not allowed.`);
|
|
2680
2680
|
}
|
|
@@ -2683,7 +2683,7 @@ class IdentifierArray {
|
|
|
2683
2683
|
}
|
|
2684
2684
|
const original = target[index];
|
|
2685
2685
|
const newIdentifier = extractIdentifierFromRecord$1(value);
|
|
2686
|
-
macroCondition(getGlobalConfig().
|
|
2686
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
2687
2687
|
if (!test) {
|
|
2688
2688
|
throw new Error(`Expected a record`);
|
|
2689
2689
|
}
|
|
@@ -2712,7 +2712,7 @@ class IdentifierArray {
|
|
|
2712
2712
|
return true;
|
|
2713
2713
|
},
|
|
2714
2714
|
deleteProperty(target, prop) {
|
|
2715
|
-
macroCondition(getGlobalConfig().
|
|
2715
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
2716
2716
|
if (!test) {
|
|
2717
2717
|
throw new Error(`Deleting keys on managed arrays is disallowed`);
|
|
2718
2718
|
}
|
|
@@ -2768,7 +2768,7 @@ class IdentifierArray {
|
|
|
2768
2768
|
is finished.
|
|
2769
2769
|
*/
|
|
2770
2770
|
_update() {
|
|
2771
|
-
macroCondition(getGlobalConfig().
|
|
2771
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
2772
2772
|
if (!test) {
|
|
2773
2773
|
throw new Error(`_update cannot be used with this array`);
|
|
2774
2774
|
}
|
|
@@ -2813,7 +2813,7 @@ const desc = {
|
|
|
2813
2813
|
get: function () {
|
|
2814
2814
|
// here to support computed chains
|
|
2815
2815
|
// and {{#each}}
|
|
2816
|
-
if (macroCondition(getGlobalConfig().
|
|
2816
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.deprecations.DEPRECATE_COMPUTED_CHAINS)) {
|
|
2817
2817
|
return this;
|
|
2818
2818
|
}
|
|
2819
2819
|
}
|
|
@@ -2835,12 +2835,12 @@ class Collection extends IdentifierArray {
|
|
|
2835
2835
|
} = this;
|
|
2836
2836
|
|
|
2837
2837
|
// TODO save options from initial request?
|
|
2838
|
-
macroCondition(getGlobalConfig().
|
|
2838
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
2839
2839
|
if (!test) {
|
|
2840
2840
|
throw new Error(`update cannot be used with this array`);
|
|
2841
2841
|
}
|
|
2842
2842
|
})(this.modelName) : {};
|
|
2843
|
-
macroCondition(getGlobalConfig().
|
|
2843
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
2844
2844
|
if (!test) {
|
|
2845
2845
|
throw new Error(`update cannot be used with no query`);
|
|
2846
2846
|
}
|
|
@@ -2867,7 +2867,7 @@ Collection.prototype.query = null;
|
|
|
2867
2867
|
// Object.setPrototypeOf(IdentifierArray.prototype, Array.prototype);
|
|
2868
2868
|
|
|
2869
2869
|
function assertRecordPassedToHasMany(record) {
|
|
2870
|
-
macroCondition(getGlobalConfig().
|
|
2870
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
2871
2871
|
if (!test) {
|
|
2872
2872
|
throw new Error(`All elements of a hasMany relationship must be instances of Model, you passed $${typeof record}`);
|
|
2873
2873
|
}
|
|
@@ -3242,7 +3242,7 @@ function sync(array, changes, arraySet) {
|
|
|
3242
3242
|
|
|
3243
3243
|
const Touching = getOrSetGlobal('Touching', Symbol('touching'));
|
|
3244
3244
|
const RequestPromise = getOrSetGlobal('RequestPromise', Symbol('promise'));
|
|
3245
|
-
const EMPTY_ARR = macroCondition(getGlobalConfig().
|
|
3245
|
+
const EMPTY_ARR = macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? Object.freeze([]) : [];
|
|
3246
3246
|
function hasRecordIdentifier(op) {
|
|
3247
3247
|
return 'recordIdentifier' in op;
|
|
3248
3248
|
}
|
|
@@ -3313,7 +3313,7 @@ class RequestStateService {
|
|
|
3313
3313
|
throw error;
|
|
3314
3314
|
});
|
|
3315
3315
|
}
|
|
3316
|
-
macroCondition(getGlobalConfig().
|
|
3316
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
3317
3317
|
{
|
|
3318
3318
|
throw new Error(`Expected a well formed query`);
|
|
3319
3319
|
}
|
|
@@ -3450,12 +3450,12 @@ function constructResource(type, id, lid) {
|
|
|
3450
3450
|
if ('id' in resource) {
|
|
3451
3451
|
resource.id = coerceId(resource.id);
|
|
3452
3452
|
}
|
|
3453
|
-
macroCondition(getGlobalConfig().
|
|
3453
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
3454
3454
|
if (!test) {
|
|
3455
3455
|
throw new Error('Expected either id or lid to be a valid string');
|
|
3456
3456
|
}
|
|
3457
3457
|
})('id' in resource && isNonEmptyString(resource.id) || isNonEmptyString(resource.lid)) : {};
|
|
3458
|
-
macroCondition(getGlobalConfig().
|
|
3458
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
3459
3459
|
if (!test) {
|
|
3460
3460
|
throw new Error('if id is present, the type must be a string');
|
|
3461
3461
|
}
|
|
@@ -3471,7 +3471,7 @@ function constructResource(type, id, lid) {
|
|
|
3471
3471
|
}
|
|
3472
3472
|
throw new Error('Expected either id or lid to be a valid string');
|
|
3473
3473
|
}
|
|
3474
|
-
macroCondition(getGlobalConfig().
|
|
3474
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
3475
3475
|
if (!test) {
|
|
3476
3476
|
throw new Error('type must be a string');
|
|
3477
3477
|
}
|
|
@@ -3539,7 +3539,7 @@ const EmptyClass = class {
|
|
|
3539
3539
|
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
3540
3540
|
constructor(args) {}
|
|
3541
3541
|
};
|
|
3542
|
-
const _BaseClass = macroCondition(dependencySatisfies('ember-source', '*')) ? macroCondition(getGlobalConfig().
|
|
3542
|
+
const _BaseClass = macroCondition(dependencySatisfies('ember-source', '*')) ? macroCondition(getGlobalConfig().WarpDriveMirror.deprecations.DEPRECATE_STORE_EXTENDS_EMBER_OBJECT) ? importSync('@ember/object') : EmptyClass : EmptyClass;
|
|
3543
3543
|
const BaseClass = _BaseClass.default ? _BaseClass.default : _BaseClass;
|
|
3544
3544
|
if (BaseClass !== EmptyClass) {
|
|
3545
3545
|
deprecate(`The Store class extending from EmberObject is deprecated.
|
|
@@ -3716,13 +3716,13 @@ class Store extends BaseClass {
|
|
|
3716
3716
|
this.isDestroyed = false;
|
|
3717
3717
|
}
|
|
3718
3718
|
_run(cb) {
|
|
3719
|
-
macroCondition(getGlobalConfig().
|
|
3719
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
3720
3720
|
if (!test) {
|
|
3721
3721
|
throw new Error(`EmberData should never encounter a nested run`);
|
|
3722
3722
|
}
|
|
3723
3723
|
})(!this._cbs) : {};
|
|
3724
3724
|
const _cbs = this._cbs = {};
|
|
3725
|
-
if (macroCondition(getGlobalConfig().
|
|
3725
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
3726
3726
|
try {
|
|
3727
3727
|
cb();
|
|
3728
3728
|
if (_cbs.coalesce) {
|
|
@@ -3769,12 +3769,12 @@ class Store extends BaseClass {
|
|
|
3769
3769
|
}
|
|
3770
3770
|
}
|
|
3771
3771
|
_schedule(name, cb) {
|
|
3772
|
-
macroCondition(getGlobalConfig().
|
|
3772
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
3773
3773
|
if (!test) {
|
|
3774
3774
|
throw new Error(`EmberData expects to schedule only when there is an active run`);
|
|
3775
3775
|
}
|
|
3776
3776
|
})(!!this._cbs) : {};
|
|
3777
|
-
macroCondition(getGlobalConfig().
|
|
3777
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
3778
3778
|
if (!test) {
|
|
3779
3779
|
throw new Error(`EmberData expects only one flush per queue name, cannot schedule ${name}`);
|
|
3780
3780
|
}
|
|
@@ -3797,7 +3797,7 @@ class Store extends BaseClass {
|
|
|
3797
3797
|
return this._requestCache;
|
|
3798
3798
|
}
|
|
3799
3799
|
_getAllPending() {
|
|
3800
|
-
if (macroCondition(getGlobalConfig().
|
|
3800
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.TESTING)) {
|
|
3801
3801
|
const all = [];
|
|
3802
3802
|
const pending = this._requestCache._pending;
|
|
3803
3803
|
pending.forEach(requests => {
|
|
@@ -3875,12 +3875,12 @@ class Store extends BaseClass {
|
|
|
3875
3875
|
const identifierCache = this.identifierCache;
|
|
3876
3876
|
opts.records = requestConfig.records.map(r => identifierCache.getOrCreateRecordIdentifier(r));
|
|
3877
3877
|
}
|
|
3878
|
-
if (macroCondition(getGlobalConfig().
|
|
3878
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.TESTING)) {
|
|
3879
3879
|
if (this.DISABLE_WAITER) {
|
|
3880
3880
|
opts.disableTestWaiter = typeof requestConfig.disableTestWaiter === 'boolean' ? requestConfig.disableTestWaiter : true;
|
|
3881
3881
|
}
|
|
3882
3882
|
}
|
|
3883
|
-
if (macroCondition(getGlobalConfig().
|
|
3883
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_REQUESTS)) {
|
|
3884
3884
|
let options;
|
|
3885
3885
|
try {
|
|
3886
3886
|
options = JSON.parse(JSON.stringify(requestConfig));
|
|
@@ -3893,7 +3893,7 @@ class Store extends BaseClass {
|
|
|
3893
3893
|
const request = Object.assign({}, requestConfig, opts);
|
|
3894
3894
|
const future = this.requestManager.request(request);
|
|
3895
3895
|
future.onFinalize(() => {
|
|
3896
|
-
if (macroCondition(getGlobalConfig().
|
|
3896
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_REQUESTS)) {
|
|
3897
3897
|
// eslint-disable-next-line no-console
|
|
3898
3898
|
console.log(`request: [[FINALIZE]] ${requestConfig.op && !requestConfig.url ? '(LEGACY) ' : ''}${requestConfig.op || '<unknown operation>'} ${requestConfig.url || '<empty url>'} ${requestConfig.method || '<empty method>'}`);
|
|
3899
3899
|
}
|
|
@@ -3958,15 +3958,15 @@ class Store extends BaseClass {
|
|
|
3958
3958
|
modelFor(type) {
|
|
3959
3959
|
// FIXME add deprecation and deprecation stripping
|
|
3960
3960
|
// FIXME/TODO update RFC to remove this method
|
|
3961
|
-
if (macroCondition(getGlobalConfig().
|
|
3961
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
3962
3962
|
assertDestroyedStoreOnly(this, 'modelFor');
|
|
3963
3963
|
}
|
|
3964
|
-
macroCondition(getGlobalConfig().
|
|
3964
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
3965
3965
|
if (!test) {
|
|
3966
3966
|
throw new Error(`You need to pass <type> to the store's modelFor method`);
|
|
3967
3967
|
}
|
|
3968
3968
|
})(typeof type === 'string' && type.length) : {};
|
|
3969
|
-
macroCondition(getGlobalConfig().
|
|
3969
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
3970
3970
|
if (!test) {
|
|
3971
3971
|
throw new Error(`No model was found for '${type}' and no schema handles the type`);
|
|
3972
3972
|
}
|
|
@@ -4002,15 +4002,15 @@ class Store extends BaseClass {
|
|
|
4002
4002
|
*/
|
|
4003
4003
|
|
|
4004
4004
|
createRecord(type, inputProperties) {
|
|
4005
|
-
if (macroCondition(getGlobalConfig().
|
|
4005
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
4006
4006
|
assertDestroyingStore(this, 'createRecord');
|
|
4007
4007
|
}
|
|
4008
|
-
macroCondition(getGlobalConfig().
|
|
4008
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4009
4009
|
if (!test) {
|
|
4010
4010
|
throw new Error(`You need to pass a model name to the store's createRecord method`);
|
|
4011
4011
|
}
|
|
4012
4012
|
})(type) : {};
|
|
4013
|
-
macroCondition(getGlobalConfig().
|
|
4013
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4014
4014
|
if (!test) {
|
|
4015
4015
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
4016
4016
|
}
|
|
@@ -4049,7 +4049,7 @@ class Store extends BaseClass {
|
|
|
4049
4049
|
};
|
|
4050
4050
|
if (resource.id) {
|
|
4051
4051
|
const identifier = this.identifierCache.peekRecordIdentifier(resource);
|
|
4052
|
-
macroCondition(getGlobalConfig().
|
|
4052
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4053
4053
|
if (!test) {
|
|
4054
4054
|
throw new Error(`The id ${String(properties.id)} has already been used with another '${normalizedModelName}' record.`);
|
|
4055
4055
|
}
|
|
@@ -4078,12 +4078,12 @@ class Store extends BaseClass {
|
|
|
4078
4078
|
@param {unknown} record
|
|
4079
4079
|
*/
|
|
4080
4080
|
deleteRecord(record) {
|
|
4081
|
-
if (macroCondition(getGlobalConfig().
|
|
4081
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
4082
4082
|
assertDestroyingStore(this, 'deleteRecord');
|
|
4083
4083
|
}
|
|
4084
4084
|
const identifier = peekRecordIdentifier(record);
|
|
4085
4085
|
const cache = this.cache;
|
|
4086
|
-
macroCondition(getGlobalConfig().
|
|
4086
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4087
4087
|
if (!test) {
|
|
4088
4088
|
throw new Error(`expected the record to be connected to a cache`);
|
|
4089
4089
|
}
|
|
@@ -4110,7 +4110,7 @@ class Store extends BaseClass {
|
|
|
4110
4110
|
@param {Model} record
|
|
4111
4111
|
*/
|
|
4112
4112
|
unloadRecord(record) {
|
|
4113
|
-
if (macroCondition(getGlobalConfig().
|
|
4113
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
4114
4114
|
assertDestroyingStore(this, 'unloadRecord');
|
|
4115
4115
|
}
|
|
4116
4116
|
const identifier = peekRecordIdentifier(record);
|
|
@@ -4398,10 +4398,10 @@ class Store extends BaseClass {
|
|
|
4398
4398
|
*/
|
|
4399
4399
|
|
|
4400
4400
|
findRecord(resource, id, options) {
|
|
4401
|
-
if (macroCondition(getGlobalConfig().
|
|
4401
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
4402
4402
|
assertDestroyingStore(this, 'findRecord');
|
|
4403
4403
|
}
|
|
4404
|
-
macroCondition(getGlobalConfig().
|
|
4404
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4405
4405
|
if (!test) {
|
|
4406
4406
|
throw new Error(`You need to pass a modelName or resource identifier as the first argument to the store's findRecord method`);
|
|
4407
4407
|
}
|
|
@@ -4409,7 +4409,7 @@ class Store extends BaseClass {
|
|
|
4409
4409
|
if (isMaybeIdentifier(resource)) {
|
|
4410
4410
|
options = id;
|
|
4411
4411
|
} else {
|
|
4412
|
-
macroCondition(getGlobalConfig().
|
|
4412
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4413
4413
|
if (!test) {
|
|
4414
4414
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${resource}`);
|
|
4415
4415
|
}
|
|
@@ -4477,7 +4477,7 @@ class Store extends BaseClass {
|
|
|
4477
4477
|
*/
|
|
4478
4478
|
// TODO @deprecate getReference (and references generally)
|
|
4479
4479
|
getReference(resource, id) {
|
|
4480
|
-
if (macroCondition(getGlobalConfig().
|
|
4480
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
4481
4481
|
assertDestroyingStore(this, 'getReference');
|
|
4482
4482
|
}
|
|
4483
4483
|
let resourceIdentifier;
|
|
@@ -4488,7 +4488,7 @@ class Store extends BaseClass {
|
|
|
4488
4488
|
const normalizedId = ensureStringId(id);
|
|
4489
4489
|
resourceIdentifier = constructResource(type, normalizedId);
|
|
4490
4490
|
}
|
|
4491
|
-
macroCondition(getGlobalConfig().
|
|
4491
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4492
4492
|
if (!test) {
|
|
4493
4493
|
throw new Error('getReference expected to receive either a resource identifier or type and id as arguments');
|
|
4494
4494
|
}
|
|
@@ -4540,15 +4540,15 @@ class Store extends BaseClass {
|
|
|
4540
4540
|
// this is basically an "are we not empty" query.
|
|
4541
4541
|
return isLoaded ? this._instanceCache.getRecord(stableIdentifier) : null;
|
|
4542
4542
|
}
|
|
4543
|
-
if (macroCondition(getGlobalConfig().
|
|
4543
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
4544
4544
|
assertDestroyingStore(this, 'peekRecord');
|
|
4545
4545
|
}
|
|
4546
|
-
macroCondition(getGlobalConfig().
|
|
4546
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4547
4547
|
if (!test) {
|
|
4548
4548
|
throw new Error(`You need to pass a model name to the store's peekRecord method`);
|
|
4549
4549
|
}
|
|
4550
4550
|
})(identifier) : {};
|
|
4551
|
-
macroCondition(getGlobalConfig().
|
|
4551
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4552
4552
|
if (!test) {
|
|
4553
4553
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${String(identifier)}`);
|
|
4554
4554
|
}
|
|
@@ -4603,20 +4603,20 @@ class Store extends BaseClass {
|
|
|
4603
4603
|
*/
|
|
4604
4604
|
|
|
4605
4605
|
query(type, query, options = {}) {
|
|
4606
|
-
if (macroCondition(getGlobalConfig().
|
|
4606
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
4607
4607
|
assertDestroyingStore(this, 'query');
|
|
4608
4608
|
}
|
|
4609
|
-
macroCondition(getGlobalConfig().
|
|
4609
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4610
4610
|
if (!test) {
|
|
4611
4611
|
throw new Error(`You need to pass a model name to the store's query method`);
|
|
4612
4612
|
}
|
|
4613
4613
|
})(type) : {};
|
|
4614
|
-
macroCondition(getGlobalConfig().
|
|
4614
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4615
4615
|
if (!test) {
|
|
4616
4616
|
throw new Error(`You need to pass a query hash to the store's query method`);
|
|
4617
4617
|
}
|
|
4618
4618
|
})(query) : {};
|
|
4619
|
-
macroCondition(getGlobalConfig().
|
|
4619
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4620
4620
|
if (!test) {
|
|
4621
4621
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
4622
4622
|
}
|
|
@@ -4718,20 +4718,20 @@ class Store extends BaseClass {
|
|
|
4718
4718
|
*/
|
|
4719
4719
|
|
|
4720
4720
|
queryRecord(type, query, options) {
|
|
4721
|
-
if (macroCondition(getGlobalConfig().
|
|
4721
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
4722
4722
|
assertDestroyingStore(this, 'queryRecord');
|
|
4723
4723
|
}
|
|
4724
|
-
macroCondition(getGlobalConfig().
|
|
4724
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4725
4725
|
if (!test) {
|
|
4726
4726
|
throw new Error(`You need to pass a model name to the store's queryRecord method`);
|
|
4727
4727
|
}
|
|
4728
4728
|
})(type) : {};
|
|
4729
|
-
macroCondition(getGlobalConfig().
|
|
4729
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4730
4730
|
if (!test) {
|
|
4731
4731
|
throw new Error(`You need to pass a query hash to the store's queryRecord method`);
|
|
4732
4732
|
}
|
|
4733
4733
|
})(query) : {};
|
|
4734
|
-
macroCondition(getGlobalConfig().
|
|
4734
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4735
4735
|
if (!test) {
|
|
4736
4736
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
4737
4737
|
}
|
|
@@ -4898,15 +4898,15 @@ class Store extends BaseClass {
|
|
|
4898
4898
|
*/
|
|
4899
4899
|
|
|
4900
4900
|
findAll(type, options = {}) {
|
|
4901
|
-
if (macroCondition(getGlobalConfig().
|
|
4901
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
4902
4902
|
assertDestroyingStore(this, 'findAll');
|
|
4903
4903
|
}
|
|
4904
|
-
macroCondition(getGlobalConfig().
|
|
4904
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4905
4905
|
if (!test) {
|
|
4906
4906
|
throw new Error(`You need to pass a model name to the store's findAll method`);
|
|
4907
4907
|
}
|
|
4908
4908
|
})(type) : {};
|
|
4909
|
-
macroCondition(getGlobalConfig().
|
|
4909
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4910
4910
|
if (!test) {
|
|
4911
4911
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
4912
4912
|
}
|
|
@@ -4946,15 +4946,15 @@ class Store extends BaseClass {
|
|
|
4946
4946
|
*/
|
|
4947
4947
|
|
|
4948
4948
|
peekAll(type) {
|
|
4949
|
-
if (macroCondition(getGlobalConfig().
|
|
4949
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
4950
4950
|
assertDestroyingStore(this, 'peekAll');
|
|
4951
4951
|
}
|
|
4952
|
-
macroCondition(getGlobalConfig().
|
|
4952
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4953
4953
|
if (!test) {
|
|
4954
4954
|
throw new Error(`You need to pass a model name to the store's peekAll method`);
|
|
4955
4955
|
}
|
|
4956
4956
|
})(type) : {};
|
|
4957
|
-
macroCondition(getGlobalConfig().
|
|
4957
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4958
4958
|
if (!test) {
|
|
4959
4959
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
4960
4960
|
}
|
|
@@ -4976,10 +4976,10 @@ class Store extends BaseClass {
|
|
|
4976
4976
|
*/
|
|
4977
4977
|
|
|
4978
4978
|
unloadAll(type) {
|
|
4979
|
-
if (macroCondition(getGlobalConfig().
|
|
4979
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
4980
4980
|
assertDestroyedStoreOnly(this, 'unloadAll');
|
|
4981
4981
|
}
|
|
4982
|
-
macroCondition(getGlobalConfig().
|
|
4982
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
4983
4983
|
if (!test) {
|
|
4984
4984
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${String(type)}`);
|
|
4985
4985
|
}
|
|
@@ -5130,7 +5130,7 @@ class Store extends BaseClass {
|
|
|
5130
5130
|
*/
|
|
5131
5131
|
|
|
5132
5132
|
push(data) {
|
|
5133
|
-
if (macroCondition(getGlobalConfig().
|
|
5133
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
5134
5134
|
assertDestroyingStore(this, 'push');
|
|
5135
5135
|
}
|
|
5136
5136
|
const pushed = this._push(data, false);
|
|
@@ -5152,10 +5152,10 @@ class Store extends BaseClass {
|
|
|
5152
5152
|
@return {StableRecordIdentifier|Array<StableRecordIdentifier>|null} identifiers for the primary records that had data loaded
|
|
5153
5153
|
*/
|
|
5154
5154
|
_push(jsonApiDoc, asyncFlush) {
|
|
5155
|
-
if (macroCondition(getGlobalConfig().
|
|
5155
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
5156
5156
|
assertDestroyingStore(this, '_push');
|
|
5157
5157
|
}
|
|
5158
|
-
if (macroCondition(getGlobalConfig().
|
|
5158
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.debug.LOG_PAYLOADS)) {
|
|
5159
5159
|
try {
|
|
5160
5160
|
const data = JSON.parse(JSON.stringify(jsonApiDoc));
|
|
5161
5161
|
// eslint-disable-next-line no-console
|
|
@@ -5190,10 +5190,10 @@ class Store extends BaseClass {
|
|
|
5190
5190
|
* @return {Promise<record>}
|
|
5191
5191
|
*/
|
|
5192
5192
|
saveRecord(record, options = {}) {
|
|
5193
|
-
if (macroCondition(getGlobalConfig().
|
|
5193
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
5194
5194
|
assertDestroyingStore(this, 'saveRecord');
|
|
5195
5195
|
}
|
|
5196
|
-
macroCondition(getGlobalConfig().
|
|
5196
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
5197
5197
|
if (!test) {
|
|
5198
5198
|
throw new Error(`Unable to initiate save for a record in a disconnected state`);
|
|
5199
5199
|
}
|
|
@@ -5205,7 +5205,7 @@ class Store extends BaseClass {
|
|
|
5205
5205
|
// but just in case we reject here to prevent bad things.
|
|
5206
5206
|
return Promise.reject(new Error(`Record Is Disconnected`));
|
|
5207
5207
|
}
|
|
5208
|
-
macroCondition(getGlobalConfig().
|
|
5208
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
5209
5209
|
if (!test) {
|
|
5210
5210
|
throw new Error(`Cannot initiate a save request for an unloaded record: ${identifier.lid}`);
|
|
5211
5211
|
}
|
|
@@ -5262,7 +5262,7 @@ class Store extends BaseClass {
|
|
|
5262
5262
|
} = this._instanceCache;
|
|
5263
5263
|
if (!cache) {
|
|
5264
5264
|
cache = this._instanceCache.cache = this.createCache(this._instanceCache._storeWrapper);
|
|
5265
|
-
if (macroCondition(getGlobalConfig().
|
|
5265
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
5266
5266
|
cache = new CacheManager(cache);
|
|
5267
5267
|
}
|
|
5268
5268
|
}
|
|
@@ -5286,9 +5286,9 @@ class Store extends BaseClass {
|
|
|
5286
5286
|
return new this(args);
|
|
5287
5287
|
}
|
|
5288
5288
|
}
|
|
5289
|
-
if (macroCondition(getGlobalConfig().
|
|
5289
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.deprecations.ENABLE_LEGACY_SCHEMA_SERVICE)) {
|
|
5290
5290
|
Store.prototype.getSchemaDefinitionService = function () {
|
|
5291
|
-
macroCondition(getGlobalConfig().
|
|
5291
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
5292
5292
|
if (!test) {
|
|
5293
5293
|
throw new Error(`You must registerSchemaDefinitionService with the store to use custom model classes`);
|
|
5294
5294
|
}
|
|
@@ -5331,10 +5331,10 @@ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_SCHEMA
|
|
|
5331
5331
|
}
|
|
5332
5332
|
let assertDestroyingStore;
|
|
5333
5333
|
let assertDestroyedStoreOnly;
|
|
5334
|
-
if (macroCondition(getGlobalConfig().
|
|
5334
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
5335
5335
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
5336
5336
|
assertDestroyingStore = function assertDestroyingStore(store, method) {
|
|
5337
|
-
macroCondition(getGlobalConfig().
|
|
5337
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
5338
5338
|
if (!test) {
|
|
5339
5339
|
throw new Error(`Attempted to call store.${method}(), but the store instance has already been destroyed.`);
|
|
5340
5340
|
}
|
|
@@ -5342,7 +5342,7 @@ if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
|
5342
5342
|
};
|
|
5343
5343
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
5344
5344
|
assertDestroyedStoreOnly = function assertDestroyedStoreOnly(store, method) {
|
|
5345
|
-
macroCondition(getGlobalConfig().
|
|
5345
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
5346
5346
|
if (!test) {
|
|
5347
5347
|
throw new Error(`Attempted to call store.${method}(), but the store instance has already been destroyed.`);
|
|
5348
5348
|
}
|
|
@@ -5356,13 +5356,13 @@ function normalizeProperties(store, identifier, properties) {
|
|
|
5356
5356
|
// assert here
|
|
5357
5357
|
if (properties !== undefined) {
|
|
5358
5358
|
if ('id' in properties) {
|
|
5359
|
-
macroCondition(getGlobalConfig().
|
|
5359
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
5360
5360
|
if (!test) {
|
|
5361
5361
|
throw new Error(`expected id to be a string or null`);
|
|
5362
5362
|
}
|
|
5363
5363
|
})(properties.id !== undefined) : {};
|
|
5364
5364
|
}
|
|
5365
|
-
macroCondition(getGlobalConfig().
|
|
5365
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
5366
5366
|
if (!test) {
|
|
5367
5367
|
throw new Error(`You passed '${typeof properties}' as properties for record creation instead of an object.`);
|
|
5368
5368
|
}
|
|
@@ -5382,7 +5382,7 @@ function normalizeProperties(store, identifier, properties) {
|
|
|
5382
5382
|
const field = defs.get(prop);
|
|
5383
5383
|
if (!field) continue;
|
|
5384
5384
|
if (field.kind === 'hasMany') {
|
|
5385
|
-
if (macroCondition(getGlobalConfig().
|
|
5385
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
|
|
5386
5386
|
assertRecordsPassedToHasMany(properties[prop]);
|
|
5387
5387
|
}
|
|
5388
5388
|
properties[prop] = extractIdentifiersFromRecords(properties[prop]);
|
|
@@ -5395,12 +5395,12 @@ function normalizeProperties(store, identifier, properties) {
|
|
|
5395
5395
|
return properties;
|
|
5396
5396
|
}
|
|
5397
5397
|
function assertRecordsPassedToHasMany(records) {
|
|
5398
|
-
macroCondition(getGlobalConfig().
|
|
5398
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
5399
5399
|
if (!test) {
|
|
5400
5400
|
throw new Error(`You must pass an array of records to set a hasMany relationship`);
|
|
5401
5401
|
}
|
|
5402
5402
|
})(Array.isArray(records)) : {};
|
|
5403
|
-
macroCondition(getGlobalConfig().
|
|
5403
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
5404
5404
|
if (!test) {
|
|
5405
5405
|
throw new Error(`All elements of a hasMany relationship must be instances of Model, you passed ${records.map(r => `${typeof r}`).join(', ')}`);
|
|
5406
5406
|
}
|
|
@@ -5530,7 +5530,7 @@ class Document {
|
|
|
5530
5530
|
* @return Promise<Document>
|
|
5531
5531
|
*/
|
|
5532
5532
|
fetch(options = {}) {
|
|
5533
|
-
macroCondition(getGlobalConfig().
|
|
5533
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
5534
5534
|
if (!test) {
|
|
5535
5535
|
throw new Error(`No self or related link`);
|
|
5536
5536
|
}
|
|
@@ -5809,7 +5809,7 @@ const CacheHandler = {
|
|
|
5809
5809
|
}
|
|
5810
5810
|
store.requestManager._pending.set(context.id, promise);
|
|
5811
5811
|
}
|
|
5812
|
-
macroCondition(getGlobalConfig().
|
|
5812
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
5813
5813
|
if (!test) {
|
|
5814
5814
|
throw new Error(`Expected a peeked request to be present`);
|
|
5815
5815
|
}
|
|
@@ -5837,7 +5837,7 @@ function maybeUpdateUiObjects(store, request, options, document, isFromCache) {
|
|
|
5837
5837
|
identifier
|
|
5838
5838
|
} = options;
|
|
5839
5839
|
if (!document) {
|
|
5840
|
-
macroCondition(getGlobalConfig().
|
|
5840
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
5841
5841
|
if (!test) {
|
|
5842
5842
|
throw new Error(`The CacheHandler expected response content but none was found`);
|
|
5843
5843
|
}
|
|
@@ -6029,7 +6029,7 @@ function fetchContentAndHydrate(next, context, identifier, priority) {
|
|
|
6029
6029
|
isMut = true;
|
|
6030
6030
|
// TODO should we handle multiple records in request.records by iteratively calling willCommit for each
|
|
6031
6031
|
const record = context.request.data?.record || context.request.records?.[0];
|
|
6032
|
-
macroCondition(getGlobalConfig().
|
|
6032
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
6033
6033
|
if (!test) {
|
|
6034
6034
|
throw new Error(`Expected to receive a list of records included in the ${context.request.op} request`);
|
|
6035
6035
|
}
|
|
@@ -6049,7 +6049,7 @@ function fetchContentAndHydrate(next, context, identifier, priority) {
|
|
|
6049
6049
|
if (!isMut) {
|
|
6050
6050
|
return promise;
|
|
6051
6051
|
}
|
|
6052
|
-
macroCondition(getGlobalConfig().
|
|
6052
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
6053
6053
|
if (!test) {
|
|
6054
6054
|
throw new Error(`Expected a mutation`);
|
|
6055
6055
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-data-mirror/store",
|
|
3
|
-
"version": "5.4.0-alpha.
|
|
3
|
+
"version": "5.4.0-alpha.130",
|
|
4
4
|
"description": "The core of EmberData. Provides the Store service which coordinates the cache with the network and presentation layers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -48,26 +48,26 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@embroider/macros": "^1.16.6",
|
|
51
|
-
"@warp-drive-mirror/build-config": "5.4.0-alpha.
|
|
51
|
+
"@warp-drive-mirror/build-config": "5.4.0-alpha.130"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"ember-source": "3.28.12 || ^4.0.4 || ^5.0.0 || ^6.0.0",
|
|
55
|
-
"@ember-data-mirror/request": "5.4.0-alpha.
|
|
56
|
-
"@ember-data-mirror/request-utils": "5.4.0-alpha.
|
|
57
|
-
"@ember-data-mirror/tracking": "5.4.0-alpha.
|
|
58
|
-
"@warp-drive-mirror/core-types": "5.4.0-alpha.
|
|
55
|
+
"@ember-data-mirror/request": "5.4.0-alpha.130",
|
|
56
|
+
"@ember-data-mirror/request-utils": "5.4.0-alpha.130",
|
|
57
|
+
"@ember-data-mirror/tracking": "5.4.0-alpha.130",
|
|
58
|
+
"@warp-drive-mirror/core-types": "5.4.0-alpha.130"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@babel/core": "^7.24.5",
|
|
62
62
|
"@babel/plugin-transform-typescript": "^7.24.5",
|
|
63
63
|
"@babel/preset-env": "^7.24.5",
|
|
64
64
|
"@babel/preset-typescript": "^7.24.1",
|
|
65
|
-
"@ember-data-mirror/request": "5.4.0-alpha.
|
|
66
|
-
"@ember-data-mirror/request-utils": "5.4.0-alpha.
|
|
67
|
-
"@ember-data-mirror/tracking": "5.4.0-alpha.
|
|
65
|
+
"@ember-data-mirror/request": "5.4.0-alpha.130",
|
|
66
|
+
"@ember-data-mirror/request-utils": "5.4.0-alpha.130",
|
|
67
|
+
"@ember-data-mirror/tracking": "5.4.0-alpha.130",
|
|
68
68
|
"@glimmer/component": "^1.1.2",
|
|
69
|
-
"@warp-drive-mirror/core-types": "5.4.0-alpha.
|
|
70
|
-
"@warp-drive/internal-config": "5.4.0-alpha.
|
|
69
|
+
"@warp-drive-mirror/core-types": "5.4.0-alpha.130",
|
|
70
|
+
"@warp-drive/internal-config": "5.4.0-alpha.130",
|
|
71
71
|
"decorator-transforms": "^2.2.2",
|
|
72
72
|
"ember-source": "~5.12.0",
|
|
73
73
|
"expect-type": "^0.20.0",
|