@warp-drive/legacy 5.7.0-alpha.2 → 5.7.0-alpha.21
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/declarations/compat/builders/find-all.d.ts +2 -2
- package/declarations/compat/builders/query.d.ts +2 -2
- package/declarations/compat/builders/save-record.d.ts +3 -3
- package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +10 -10
- package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -2
- package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +5 -5
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +3 -3
- package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +2 -2
- package/declarations/compat/legacy-network-handler/snapshot.d.ts +72 -44
- package/declarations/model/-private/attr.d.ts +1 -1
- package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +2 -2
- package/declarations/model/-private/hooks.d.ts +2 -2
- package/declarations/model/-private/legacy-relationships-support.d.ts +16 -17
- package/declarations/model/-private/model.d.ts +4 -5
- package/declarations/model/-private/notify-changes.d.ts +2 -2
- package/declarations/model/-private/record-state.d.ts +2 -2
- package/declarations/model/-private/references/belongs-to.d.ts +6 -6
- package/declarations/model/-private/references/has-many.d.ts +6 -6
- package/declarations/model/-private/schema-provider.d.ts +6 -6
- package/declarations/model/-private.d.ts +2 -1
- package/declarations/model/migration-support.d.ts +10 -10
- package/declarations/store/-private.d.ts +12 -12
- package/dist/{-private-CKrP0ogQ.js → -private-CVsFOW1k.js} +94 -96
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/json-api.js +1 -1
- package/dist/adapter/rest.js +1 -1
- package/dist/compat/-private.js +1 -1
- package/dist/compat/builders.js +1 -1
- package/dist/compat.js +2 -1
- package/dist/{errors-BX5wowuz.js → errors-VSxXZooE.js} +33 -36
- package/dist/model/-private.js +1 -2
- package/dist/model/migration-support.js +12 -6
- package/dist/model.js +10 -11
- package/dist/{schema-provider-Cbnf6sKm.js → schema-provider-BgBPZFfc.js} +20 -16
- package/dist/{serialize-into-hash-Bp58npke.js → serialize-into-hash-B59laYa4.js} +2 -2
- package/dist/store.js +3 -3
- package/package.json +6 -6
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from '@warp-drive/core/reactive/-private';
|
|
2
|
+
import { memoized, defineSignal, defineNonEnumerableSignal, isResourceKey, recordIdentifierFor, storeFor, fastPush, createLegacyManyArray, notifyInternalSignal } from '@warp-drive/core/store/-private';
|
|
2
3
|
import { getOrSetGlobal } from '@warp-drive/core/types/-private';
|
|
3
4
|
import { EnableHydration } from '@warp-drive/core/types/request';
|
|
4
|
-
import { u as upgradeStore } from "./-private-
|
|
5
|
+
import { u as upgradeStore } from "./-private-CVsFOW1k.js";
|
|
5
6
|
import { computed, get } from '@ember/object';
|
|
6
7
|
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
|
|
7
8
|
import ObjectProxy from '@ember/object/proxy';
|
|
@@ -420,7 +421,7 @@ class HasManyReference {
|
|
|
420
421
|
* An array of identifiers for the records that this reference refers to.
|
|
421
422
|
*
|
|
422
423
|
* @property identifiers
|
|
423
|
-
* @type {
|
|
424
|
+
* @type {ResourceKey[]}
|
|
424
425
|
* @public
|
|
425
426
|
*/
|
|
426
427
|
get identifiers() {
|
|
@@ -432,7 +433,7 @@ class HasManyReference {
|
|
|
432
433
|
this.___relatedTokenMap = new Map();
|
|
433
434
|
if (resource && resource.data) {
|
|
434
435
|
return resource.data.map(resourceIdentifier => {
|
|
435
|
-
const identifier = this.store.
|
|
436
|
+
const identifier = this.store.cacheKeyManager.getOrCreateRecordIdentifier(resourceIdentifier);
|
|
436
437
|
let token = map.get(identifier);
|
|
437
438
|
if (token) {
|
|
438
439
|
map.delete(identifier);
|
|
@@ -724,7 +725,7 @@ class HasManyReference {
|
|
|
724
725
|
throw new Error(`You must provide at least one of 'links', 'meta' or 'data' when calling hasManyReference.push`);
|
|
725
726
|
}
|
|
726
727
|
})('links' in dataDoc || 'meta' in dataDoc || 'data' in dataDoc) : {};
|
|
727
|
-
const identifiers = !Array.isArray(dataDoc.data) ? [] : isResourceData ? store._push(dataDoc, true) : dataDoc.data.map(i => store.
|
|
728
|
+
const identifiers = !Array.isArray(dataDoc.data) ? [] : isResourceData ? store._push(dataDoc, true) : dataDoc.data.map(i => store.cacheKeyManager.getOrCreateRecordIdentifier(i));
|
|
728
729
|
const {
|
|
729
730
|
identifier
|
|
730
731
|
} = this.hasManyRelationship;
|
|
@@ -1022,7 +1023,7 @@ class BelongsToReference {
|
|
|
1022
1023
|
* `null` if no related record is known.
|
|
1023
1024
|
*
|
|
1024
1025
|
* @property identifier
|
|
1025
|
-
* @type {
|
|
1026
|
+
* @type {ResourceKey | null}
|
|
1026
1027
|
* @public
|
|
1027
1028
|
*/
|
|
1028
1029
|
get identifier() {
|
|
@@ -1032,7 +1033,7 @@ class BelongsToReference {
|
|
|
1032
1033
|
}
|
|
1033
1034
|
const resource = this._resource();
|
|
1034
1035
|
if (resource && resource.data) {
|
|
1035
|
-
const identifier = this.store.
|
|
1036
|
+
const identifier = this.store.cacheKeyManager.getOrCreateRecordIdentifier(resource.data);
|
|
1036
1037
|
this.___relatedToken = this.store.notifications.subscribe(identifier, (_, bucket, notifiedKey) => {
|
|
1037
1038
|
if (bucket === 'identity' || bucket === 'attributes' && notifiedKey === 'id') {
|
|
1038
1039
|
this._ref++;
|
|
@@ -1309,7 +1310,7 @@ class BelongsToReference {
|
|
|
1309
1310
|
store
|
|
1310
1311
|
} = this;
|
|
1311
1312
|
const isResourceData = doc.data && isMaybeResource(doc.data);
|
|
1312
|
-
const added = isResourceData ? store._push(doc, true) : doc.data ? store.
|
|
1313
|
+
const added = isResourceData ? store._push(doc, true) : doc.data ? store.cacheKeyManager.getOrCreateRecordIdentifier(doc.data) : null;
|
|
1313
1314
|
const {
|
|
1314
1315
|
identifier
|
|
1315
1316
|
} = this.belongsToRelationship;
|
|
@@ -1508,18 +1509,17 @@ function lookupLegacySupport(record) {
|
|
|
1508
1509
|
throw new Error(`Memory Leak Detected`);
|
|
1509
1510
|
}
|
|
1510
1511
|
})(!record.isDestroyed && !record.isDestroying) : {};
|
|
1511
|
-
support = new LegacySupport(record);
|
|
1512
|
+
support = new LegacySupport(record, identifier);
|
|
1512
1513
|
LEGACY_SUPPORT.set(identifier, support);
|
|
1513
|
-
LEGACY_SUPPORT.set(record, support);
|
|
1514
1514
|
}
|
|
1515
1515
|
return support;
|
|
1516
1516
|
}
|
|
1517
1517
|
class LegacySupport {
|
|
1518
|
-
constructor(record) {
|
|
1518
|
+
constructor(record, identifier) {
|
|
1519
1519
|
this.record = record;
|
|
1520
|
-
this.store = storeFor(record);
|
|
1521
|
-
this.identifier =
|
|
1522
|
-
this.cache =
|
|
1520
|
+
this.store = storeFor(record, false);
|
|
1521
|
+
this.identifier = identifier;
|
|
1522
|
+
this.cache = this.store.cache;
|
|
1523
1523
|
if (this.store._graph) {
|
|
1524
1524
|
this.graph = this.store._graph;
|
|
1525
1525
|
}
|
|
@@ -1534,7 +1534,7 @@ class LegacySupport {
|
|
|
1534
1534
|
if (this.isDestroyed || this.isDestroying) {
|
|
1535
1535
|
return;
|
|
1536
1536
|
}
|
|
1537
|
-
const currentState = array[
|
|
1537
|
+
const currentState = array[Context].source;
|
|
1538
1538
|
const identifier = this.identifier;
|
|
1539
1539
|
const [identifiers, jsonApi] = this._getCurrentState(identifier, array.key);
|
|
1540
1540
|
if (jsonApi.meta) {
|
|
@@ -1588,7 +1588,7 @@ class LegacySupport {
|
|
|
1588
1588
|
if (!test) {
|
|
1589
1589
|
throw new Error(`Expected a stable identifier`);
|
|
1590
1590
|
}
|
|
1591
|
-
})(!relatedIdentifier ||
|
|
1591
|
+
})(!relatedIdentifier || isResourceKey(relatedIdentifier)) : {};
|
|
1592
1592
|
const store = this.store;
|
|
1593
1593
|
const relationship = this.graph.get(this.identifier, key);
|
|
1594
1594
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
@@ -1648,7 +1648,7 @@ class LegacySupport {
|
|
|
1648
1648
|
if (!test) {
|
|
1649
1649
|
throw new Error(`Expected a stable identifier`);
|
|
1650
1650
|
}
|
|
1651
|
-
})(
|
|
1651
|
+
})(isResourceKey(relatedIdentifier)) : {};
|
|
1652
1652
|
if (cache.recordIsLoaded(relatedIdentifier, true)) {
|
|
1653
1653
|
identifiers.push(relatedIdentifier);
|
|
1654
1654
|
}
|
|
@@ -1664,23 +1664,20 @@ class LegacySupport {
|
|
|
1664
1664
|
}
|
|
1665
1665
|
if (!manyArray) {
|
|
1666
1666
|
const [identifiers, doc] = this._getCurrentState(this.identifier, key);
|
|
1667
|
-
manyArray =
|
|
1667
|
+
manyArray = createLegacyManyArray({
|
|
1668
1668
|
store: this.store,
|
|
1669
|
-
type: definition.type,
|
|
1670
|
-
identifier: this.identifier,
|
|
1671
|
-
cache: this.cache,
|
|
1672
|
-
field: this.store.schema.fields(this.identifier).get(key),
|
|
1673
|
-
identifiers,
|
|
1674
|
-
key,
|
|
1675
|
-
meta: doc.meta || null,
|
|
1676
|
-
links: doc.links || null,
|
|
1677
|
-
isPolymorphic: definition.isPolymorphic,
|
|
1678
|
-
isAsync: definition.isAsync,
|
|
1679
|
-
_inverseIsAsync: definition.inverseIsAsync,
|
|
1680
1669
|
// @ts-expect-error Typescript doesn't have a way for us to thread the generic backwards so it infers unknown instead of T
|
|
1681
1670
|
manager: this,
|
|
1671
|
+
source: identifiers,
|
|
1672
|
+
type: definition.type,
|
|
1682
1673
|
isLoaded: !definition.isAsync,
|
|
1683
|
-
|
|
1674
|
+
editable: true,
|
|
1675
|
+
isAsync: definition.isAsync,
|
|
1676
|
+
isPolymorphic: definition.isPolymorphic,
|
|
1677
|
+
field: this.store.schema.fields(this.identifier).get(key),
|
|
1678
|
+
identifier: this.identifier,
|
|
1679
|
+
links: doc.links || null,
|
|
1680
|
+
meta: doc.meta || null
|
|
1684
1681
|
});
|
|
1685
1682
|
this._manyArrayCache[key] = manyArray;
|
|
1686
1683
|
}
|
|
@@ -1901,7 +1898,7 @@ class LegacySupport {
|
|
|
1901
1898
|
if (!test) {
|
|
1902
1899
|
throw new Error(`Expected stable identifiers`);
|
|
1903
1900
|
}
|
|
1904
|
-
})(!identifiers || identifiers.every(
|
|
1901
|
+
})(!identifiers || identifiers.every(isResourceKey)) : {};
|
|
1905
1902
|
const req = field.options.linksMode ? {
|
|
1906
1903
|
url: getRelatedLink(resource),
|
|
1907
1904
|
op: 'findHasMany',
|
|
@@ -1936,7 +1933,7 @@ class LegacySupport {
|
|
|
1936
1933
|
if (!test) {
|
|
1937
1934
|
throw new Error(`Expected stable identifiers`);
|
|
1938
1935
|
}
|
|
1939
|
-
})(identifiers.every(
|
|
1936
|
+
})(identifiers.every(isResourceKey)) : {};
|
|
1940
1937
|
options.reload = options.reload || !attemptLocalCache || undefined;
|
|
1941
1938
|
return this.store.request({
|
|
1942
1939
|
op: 'findHasMany',
|
|
@@ -1975,7 +1972,7 @@ class LegacySupport {
|
|
|
1975
1972
|
if (!test) {
|
|
1976
1973
|
throw new Error(`Expected a stable identifier`);
|
|
1977
1974
|
}
|
|
1978
|
-
})(!identifier ||
|
|
1975
|
+
})(!identifier || isResourceKey(identifier)) : {};
|
|
1979
1976
|
const {
|
|
1980
1977
|
isStale,
|
|
1981
1978
|
hasDematerializedInverse,
|
|
@@ -2104,7 +2101,7 @@ function handleCompletedRelationshipRequest(recordExt, key, relationship, value,
|
|
|
2104
2101
|
if (isHasMany) {
|
|
2105
2102
|
// we don't notify the record property here to avoid refetch
|
|
2106
2103
|
// only the many array
|
|
2107
|
-
notifyInternalSignal(value[
|
|
2104
|
+
notifyInternalSignal(value[Context].signal);
|
|
2108
2105
|
}
|
|
2109
2106
|
if (error) {
|
|
2110
2107
|
relationship.state.hasFailedLoadAttempt = true;
|
|
@@ -2165,7 +2162,7 @@ function areAllInverseRecordsLoaded(store, resource) {
|
|
|
2165
2162
|
if (!test) {
|
|
2166
2163
|
throw new Error(`Expected stable identifiers`);
|
|
2167
2164
|
}
|
|
2168
|
-
})(identifiers.every(
|
|
2165
|
+
})(identifiers.every(isResourceKey)) : {};
|
|
2169
2166
|
// treat as collection
|
|
2170
2167
|
// check for unloaded records
|
|
2171
2168
|
return identifiers.every(identifier => instanceCache.recordIsLoaded(identifier));
|
|
@@ -2177,7 +2174,7 @@ function areAllInverseRecordsLoaded(store, resource) {
|
|
|
2177
2174
|
if (!test) {
|
|
2178
2175
|
throw new Error(`Expected stable identifiers`);
|
|
2179
2176
|
}
|
|
2180
|
-
})(
|
|
2177
|
+
})(isResourceKey(identifiers)) : {};
|
|
2181
2178
|
return instanceCache.recordIsLoaded(identifiers);
|
|
2182
2179
|
}
|
|
2183
2180
|
function isBelongsTo(relationship) {
|
package/dist/model/-private.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { E as Errors, L as LEGACY_SUPPORT, P as PromiseBelongsTo, a as PromiseManyArray, l as lookupLegacySupport } from "../errors-
|
|
2
|
-
export { RelatedCollection as ManyArray } from '@warp-drive/core/store/-private';
|
|
1
|
+
export { E as Errors, L as LEGACY_SUPPORT, P as PromiseBelongsTo, a as PromiseManyArray, l as lookupLegacySupport } from "../errors-VSxXZooE.js";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { deprecate } from '@ember/debug';
|
|
2
2
|
import { recordIdentifierFor } from '@warp-drive/core';
|
|
3
|
-
import {
|
|
3
|
+
import { Context } from '@warp-drive/core/reactive/-private';
|
|
4
|
+
import { notifyInternalSignal } from '@warp-drive/core/store/-private';
|
|
4
5
|
import { getOrSetGlobal } from '@warp-drive/core/types/-private';
|
|
5
6
|
import { Type } from '@warp-drive/core/types/symbols';
|
|
6
|
-
import { l as lookupLegacySupport, E as Errors } from "../errors-
|
|
7
|
-
import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, g as deleteRecord, R as RecordState, i as changedAttributes, j as belongsTo, k as createSnapshot } from "../schema-provider-
|
|
7
|
+
import { l as lookupLegacySupport, E as Errors } from "../errors-VSxXZooE.js";
|
|
8
|
+
import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, g as deleteRecord, R as RecordState, i as changedAttributes, j as belongsTo, k as createSnapshot } from "../schema-provider-BgBPZFfc.js";
|
|
8
9
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -310,27 +311,32 @@ function registerDerivations(schema) {
|
|
|
310
311
|
schema._registerMode('@legacy', {
|
|
311
312
|
belongsTo: {
|
|
312
313
|
get(store, record, cacheKey, field) {
|
|
314
|
+
// FIXME field.name here should likely be field.sourceKey || field.name
|
|
313
315
|
return lookupLegacySupport(record).getBelongsTo(field.name);
|
|
314
316
|
},
|
|
315
317
|
set(store, record, cacheKey, field, value) {
|
|
316
318
|
store._join(() => {
|
|
319
|
+
// FIXME field.name here should likely be field.sourceKey || field.name
|
|
317
320
|
lookupLegacySupport(record).setDirtyBelongsTo(field.name, value);
|
|
318
321
|
});
|
|
319
322
|
}
|
|
320
323
|
},
|
|
321
324
|
hasMany: {
|
|
322
325
|
get(store, record, cacheKey, field) {
|
|
326
|
+
// FIXME field.name here should likely be field.sourceKey || field.name
|
|
323
327
|
return lookupLegacySupport(record).getHasMany(field.name);
|
|
324
328
|
},
|
|
325
329
|
set(store, record, cacheKey, field, value) {
|
|
326
330
|
store._join(() => {
|
|
327
331
|
const support = lookupLegacySupport(record);
|
|
332
|
+
// FIXME field.name here should likely be field.sourceKey || field.name
|
|
328
333
|
const manyArray = support.getManyArray(field.name);
|
|
329
334
|
manyArray.splice(0, manyArray.length, ...value);
|
|
330
335
|
});
|
|
331
336
|
},
|
|
332
337
|
notify(store, record, cacheKey, field) {
|
|
333
338
|
const support = lookupLegacySupport(record);
|
|
339
|
+
// FIXME field.name here should likely be field.sourceKey || field.name
|
|
334
340
|
const manyArray = support && support._manyArrayCache[field.name];
|
|
335
341
|
const hasPromise = support && support._relationshipPromisesCache[field.name];
|
|
336
342
|
if (manyArray && hasPromise) {
|
|
@@ -339,7 +345,7 @@ function registerDerivations(schema) {
|
|
|
339
345
|
return false;
|
|
340
346
|
}
|
|
341
347
|
if (manyArray) {
|
|
342
|
-
notifyInternalSignal(manyArray[
|
|
348
|
+
notifyInternalSignal(manyArray[Context].signal);
|
|
343
349
|
return true;
|
|
344
350
|
}
|
|
345
351
|
return false;
|
|
@@ -480,8 +486,8 @@ class DelegatingSchemaService {
|
|
|
480
486
|
CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource) {
|
|
481
487
|
return this._preferred.CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource);
|
|
482
488
|
}
|
|
483
|
-
CAUTION_MEGA_DANGER_ZONE_objectExtensions(field) {
|
|
484
|
-
return this._preferred.CAUTION_MEGA_DANGER_ZONE_objectExtensions(field);
|
|
489
|
+
CAUTION_MEGA_DANGER_ZONE_objectExtensions(field, resolvedType) {
|
|
490
|
+
return this._preferred.CAUTION_MEGA_DANGER_ZONE_objectExtensions(field, resolvedType);
|
|
485
491
|
}
|
|
486
492
|
CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field) {
|
|
487
493
|
return this._preferred.CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field);
|
package/dist/model.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { computed } from '@ember/object';
|
|
2
2
|
import { recordIdentifierFor } from '@warp-drive/core';
|
|
3
|
-
import {
|
|
3
|
+
import { RecordStore } from '@warp-drive/core/types/symbols';
|
|
4
4
|
import { i as isElementDescriptor, n as normalizeModelName } from "./util-Dul6TZts.js";
|
|
5
5
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
6
|
import { warn, deprecate } from '@ember/debug';
|
|
7
|
-
import {
|
|
8
|
-
import { l as lookupLegacySupport } from "./errors-BX5wowuz.js";
|
|
7
|
+
import { l as lookupLegacySupport } from "./errors-VSxXZooE.js";
|
|
9
8
|
import { singularize, dasherize } from '@warp-drive/utilities/string';
|
|
10
|
-
import { l as getModelFactory } from "./schema-provider-
|
|
11
|
-
export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-
|
|
9
|
+
import { l as getModelFactory } from "./schema-provider-BgBPZFfc.js";
|
|
10
|
+
export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-BgBPZFfc.js";
|
|
12
11
|
import { setOwner, getOwner } from '@ember/application';
|
|
12
|
+
import { setRecordIdentifier, StoreMap } from '@warp-drive/core/store/-private';
|
|
13
13
|
function _attr(type, options) {
|
|
14
14
|
if (typeof type === 'object') {
|
|
15
15
|
options = type;
|
|
@@ -34,7 +34,8 @@ function _attr(type, options) {
|
|
|
34
34
|
if (this.isDestroyed || this.isDestroying) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
const cache = this[RecordStore].cache;
|
|
38
|
+
return cache.getAttr(recordIdentifierFor(this), key);
|
|
38
39
|
},
|
|
39
40
|
set(key, value) {
|
|
40
41
|
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
@@ -48,7 +49,7 @@ function _attr(type, options) {
|
|
|
48
49
|
throw new Error(`Attempted to set '${key}' on the deleted record ${identifier.type}:${identifier.id} (${identifier.lid})`);
|
|
49
50
|
}
|
|
50
51
|
})(!this.currentState.isDeleted) : {};
|
|
51
|
-
const cache =
|
|
52
|
+
const cache = this[RecordStore].cache;
|
|
52
53
|
const currentValue = cache.getAttr(identifier, key);
|
|
53
54
|
if (currentValue !== value) {
|
|
54
55
|
cache.setAttr(identifier, key, value);
|
|
@@ -667,14 +668,13 @@ function hasMany(type, options) {
|
|
|
667
668
|
}
|
|
668
669
|
function instantiateRecord(identifier, createRecordArgs) {
|
|
669
670
|
const type = identifier.type;
|
|
670
|
-
|
|
671
|
+
|
|
671
672
|
// TODO deprecate allowing unknown args setting
|
|
672
673
|
const createOptions = {
|
|
673
674
|
_createProps: createRecordArgs,
|
|
674
675
|
// TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
|
|
675
676
|
_secretInit: {
|
|
676
677
|
identifier,
|
|
677
|
-
cache,
|
|
678
678
|
store: this,
|
|
679
679
|
cb: secretInit
|
|
680
680
|
}
|
|
@@ -729,9 +729,8 @@ function modelFor(modelName) {
|
|
|
729
729
|
type
|
|
730
730
|
})) : {};
|
|
731
731
|
}
|
|
732
|
-
function secretInit(record,
|
|
732
|
+
function secretInit(record, identifier, store) {
|
|
733
733
|
setRecordIdentifier(record, identifier);
|
|
734
734
|
StoreMap.set(record, store);
|
|
735
|
-
setCacheFor(record, cache);
|
|
736
735
|
}
|
|
737
736
|
export { attr, belongsTo, hasMany, instantiateRecord, modelFor, teardownRecord };
|
|
@@ -2,12 +2,13 @@ import { getOwner } from '@ember/application';
|
|
|
2
2
|
import { deprecate } from '@ember/debug';
|
|
3
3
|
import EmberObject from '@ember/object';
|
|
4
4
|
import { recordIdentifierFor, storeFor } from '@warp-drive/core';
|
|
5
|
-
import {
|
|
5
|
+
import { notifyInternalSignal, peekInternalSignal, withSignalStore, recordIdentifierFor as recordIdentifierFor$1, gate, memoized, defineSignal, coerceId, entangleSignal, defineGate } from '@warp-drive/core/store/-private';
|
|
6
6
|
import { RecordStore } from '@warp-drive/core/types/symbols';
|
|
7
|
-
import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-
|
|
8
|
-
import { u as upgradeStore, F as FetchManager } from "./-private-
|
|
7
|
+
import { l as lookupLegacySupport, L as LEGACY_SUPPORT, E as Errors } from "./errors-VSxXZooE.js";
|
|
8
|
+
import { u as upgradeStore, F as FetchManager } from "./-private-CVsFOW1k.js";
|
|
9
9
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
10
10
|
import { cacheFor } from '@ember/object/internals';
|
|
11
|
+
import { Context } from '@warp-drive/core/reactive/-private';
|
|
11
12
|
import { d as decorateMethodV2 } from "./runtime-BPCpkOf1-BKOwiRJp.js";
|
|
12
13
|
import { n as normalizeModelName } from "./util-Dul6TZts.js";
|
|
13
14
|
function rollbackAttributes() {
|
|
@@ -17,8 +18,9 @@ function rollbackAttributes() {
|
|
|
17
18
|
const {
|
|
18
19
|
isNew
|
|
19
20
|
} = currentState;
|
|
20
|
-
this[RecordStore]
|
|
21
|
-
|
|
21
|
+
const store = this[RecordStore];
|
|
22
|
+
store._join(() => {
|
|
23
|
+
store.cache.rollbackAttrs(recordIdentifierFor(this));
|
|
22
24
|
this.errors.clear();
|
|
23
25
|
currentState.cleanErrorRequests();
|
|
24
26
|
if (isNew) {
|
|
@@ -84,7 +86,7 @@ function _reload(options = {}) {
|
|
|
84
86
|
return promise;
|
|
85
87
|
}
|
|
86
88
|
function changedAttributes() {
|
|
87
|
-
return
|
|
89
|
+
return this[RecordStore].cache.changedAttrs(recordIdentifierFor(this));
|
|
88
90
|
}
|
|
89
91
|
function serialize(options) {
|
|
90
92
|
upgradeStore(this[RecordStore]);
|
|
@@ -215,7 +217,7 @@ function notifyRelationship(identifier, key, record, meta) {
|
|
|
215
217
|
return;
|
|
216
218
|
}
|
|
217
219
|
if (manyArray) {
|
|
218
|
-
notifyInternalSignal(manyArray[
|
|
220
|
+
notifyInternalSignal(manyArray[Context].signal);
|
|
219
221
|
|
|
220
222
|
//We need to notifyPropertyChange in the adding case because we need to make sure
|
|
221
223
|
//we fetch the newly added record in case it is unloaded
|
|
@@ -291,7 +293,7 @@ root
|
|
|
291
293
|
*/
|
|
292
294
|
class RecordState {
|
|
293
295
|
constructor(record) {
|
|
294
|
-
const store = storeFor(record);
|
|
296
|
+
const store = storeFor(record, false);
|
|
295
297
|
const identity = recordIdentifierFor$1(record);
|
|
296
298
|
this.identifier = identity;
|
|
297
299
|
this.record = record;
|
|
@@ -382,7 +384,7 @@ class RecordState {
|
|
|
382
384
|
|
|
383
385
|
/** @internal */
|
|
384
386
|
destroy() {
|
|
385
|
-
storeFor(this.record).notifications.unsubscribe(this.handler);
|
|
387
|
+
storeFor(this.record, false).notifications.unsubscribe(this.handler);
|
|
386
388
|
}
|
|
387
389
|
|
|
388
390
|
/** @internal */
|
|
@@ -719,7 +721,7 @@ class Model extends EmberObject {
|
|
|
719
721
|
super.init(options);
|
|
720
722
|
this[RecordStore] = store;
|
|
721
723
|
const identity = _secretInit.identifier;
|
|
722
|
-
_secretInit.cb(this,
|
|
724
|
+
_secretInit.cb(this, identity, _secretInit.store);
|
|
723
725
|
this.___recordState = macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? new RecordState(this) : null;
|
|
724
726
|
this.setProperties(createProps);
|
|
725
727
|
const notifications = store.notifications;
|
|
@@ -733,11 +735,13 @@ class Model extends EmberObject {
|
|
|
733
735
|
destroy() {
|
|
734
736
|
const identifier = recordIdentifierFor(this);
|
|
735
737
|
this.___recordState?.destroy();
|
|
736
|
-
const store = storeFor(this);
|
|
738
|
+
const store = storeFor(this, false);
|
|
737
739
|
store.notifications.unsubscribe(this.___private_notifications);
|
|
738
|
-
LEGACY_SUPPORT.get(
|
|
739
|
-
|
|
740
|
-
|
|
740
|
+
const support = LEGACY_SUPPORT.get(identifier);
|
|
741
|
+
if (support) {
|
|
742
|
+
support.destroy();
|
|
743
|
+
LEGACY_SUPPORT.delete(identifier);
|
|
744
|
+
}
|
|
741
745
|
super.destroy();
|
|
742
746
|
}
|
|
743
747
|
|
|
@@ -1034,7 +1038,7 @@ class Model extends EmberObject {
|
|
|
1034
1038
|
})(!didChange || identifier.id === null) : {};
|
|
1035
1039
|
if (normalizedId !== null && didChange) {
|
|
1036
1040
|
this.store._instanceCache.setRecordId(identifier, normalizedId);
|
|
1037
|
-
this.store.notifications.notify(identifier, 'identity');
|
|
1041
|
+
this.store.notifications.notify(identifier, 'identity', null);
|
|
1038
1042
|
}
|
|
1039
1043
|
}
|
|
1040
1044
|
toString() {
|
|
@@ -1212,7 +1216,7 @@ class Model extends EmberObject {
|
|
|
1212
1216
|
return this.constructor.relationshipsByName.get(name);
|
|
1213
1217
|
}
|
|
1214
1218
|
inverseFor(name) {
|
|
1215
|
-
return this.constructor.inverseFor(name, storeFor(this));
|
|
1219
|
+
return this.constructor.inverseFor(name, storeFor(this, false));
|
|
1216
1220
|
}
|
|
1217
1221
|
eachAttribute(callback, binding) {
|
|
1218
1222
|
this.constructor.eachAttribute(callback, binding);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { warn } from '@ember/debug';
|
|
2
2
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
3
|
-
import '@warp-drive/core/
|
|
4
|
-
import "./-private-
|
|
3
|
+
import '@warp-drive/core/reactive/-private';
|
|
4
|
+
import "./-private-CVsFOW1k.js";
|
|
5
5
|
const newline = /\r?\n/;
|
|
6
6
|
function parseResponseHeaders(headersString) {
|
|
7
7
|
const headers = Object.create(null);
|
package/dist/store.js
CHANGED
|
@@ -399,7 +399,7 @@ function restoreDeprecatedStoreBehaviors(StoreKlass) {
|
|
|
399
399
|
const normalizedId = ensureStringId(id);
|
|
400
400
|
resource = constructResource(type, normalizedId);
|
|
401
401
|
}
|
|
402
|
-
const identifier = this.
|
|
402
|
+
const identifier = this.cacheKeyManager.getOrCreateRecordIdentifier(resource);
|
|
403
403
|
options = options || {};
|
|
404
404
|
if (options.preload) {
|
|
405
405
|
// force reload if we preload to ensure we don't resolve the promise
|
|
@@ -543,7 +543,7 @@ function restoreDeprecatedStoreBehaviors(StoreKlass) {
|
|
|
543
543
|
throw new Error('getReference expected to receive either a resource identifier or type and id as arguments');
|
|
544
544
|
}
|
|
545
545
|
})(isMaybeIdentifier(resourceIdentifier)) : {};
|
|
546
|
-
const identifier = this.
|
|
546
|
+
const identifier = this.cacheKeyManager.getOrCreateRecordIdentifier(resourceIdentifier);
|
|
547
547
|
const cache = upgradeInstanceCaches(this._instanceCache.__instances).reference;
|
|
548
548
|
let reference = cache.get(identifier);
|
|
549
549
|
if (!reference) {
|
|
@@ -582,7 +582,7 @@ function restoreDeprecatedStoreBehaviors(StoreKlass) {
|
|
|
582
582
|
if (!test) {
|
|
583
583
|
throw new Error(`Unable to initiate save for a record in a disconnected state`);
|
|
584
584
|
}
|
|
585
|
-
})(storeFor(record)) : {};
|
|
585
|
+
})(storeFor(record, true)) : {};
|
|
586
586
|
const identifier = recordIdentifierFor(record);
|
|
587
587
|
const cache = this.cache;
|
|
588
588
|
if (!identifier) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warp-drive/legacy",
|
|
3
|
-
"version": "5.7.0-alpha.
|
|
3
|
+
"version": "5.7.0-alpha.21",
|
|
4
4
|
"description": "Decommissioned Packages for WarpDrive | Things your app might still want to maintain use of for a little longer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@warp-drive/core": "5.7.0-alpha.
|
|
36
|
-
"@warp-drive/utilities": "5.7.0-alpha.
|
|
35
|
+
"@warp-drive/core": "5.7.0-alpha.21",
|
|
36
|
+
"@warp-drive/utilities": "5.7.0-alpha.21"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@embroider/macros": "^1.16.12"
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"@babel/plugin-transform-typescript": "^7.27.0",
|
|
44
44
|
"@babel/preset-typescript": "^7.27.0",
|
|
45
45
|
"@types/jquery": "^3.5.32",
|
|
46
|
-
"@warp-drive/internal-config": "5.7.0-alpha.
|
|
47
|
-
"@warp-drive/core": "5.7.0-alpha.
|
|
48
|
-
"@warp-drive/utilities": "5.7.0-alpha.
|
|
46
|
+
"@warp-drive/internal-config": "5.7.0-alpha.21",
|
|
47
|
+
"@warp-drive/core": "5.7.0-alpha.21",
|
|
48
|
+
"@warp-drive/utilities": "5.7.0-alpha.21",
|
|
49
49
|
"ember-source": "~6.3.0",
|
|
50
50
|
"decorator-transforms": "^2.3.0",
|
|
51
51
|
"expect-type": "^1.2.1",
|