@warp-drive/schema-record 5.5.0-alpha.20 → 5.5.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/dist/-private.js +1 -1
- package/dist/index.js +69 -77
- package/dist/index.js.map +1 -1
- package/dist/{symbols-DqoS4ybV.js → symbols-B_60yPO2.js} +1 -4
- package/dist/symbols-B_60yPO2.js.map +1 -0
- package/package.json +13 -16
- package/unstable-preview-types/-private/fields/compute.d.ts.map +1 -1
- package/unstable-preview-types/-private/fields/managed-array.d.ts +5 -5
- package/unstable-preview-types/-private/fields/managed-array.d.ts.map +1 -1
- package/unstable-preview-types/-private/fields/managed-object.d.ts +4 -4
- package/unstable-preview-types/-private/fields/managed-object.d.ts.map +1 -1
- package/unstable-preview-types/-private/record.d.ts +0 -2
- package/unstable-preview-types/-private/record.d.ts.map +1 -1
- package/unstable-preview-types/-private/schema.d.ts.map +1 -1
- package/unstable-preview-types/-private/symbols.d.ts +0 -3
- package/unstable-preview-types/-private/symbols.d.ts.map +1 -1
- package/dist/symbols-DqoS4ybV.js.map +0 -1
package/dist/-private.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { E as Editable, L as Legacy } from "./symbols-
|
|
1
|
+
export { E as Editable, L as Legacy } from "./symbols-B_60yPO2.js";
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { isResourceSchema } from '@warp-drive/core-types/schema/fields';
|
|
2
2
|
import { macroCondition, getGlobalConfig, dependencySatisfies, importSync } from '@embroider/macros';
|
|
3
|
-
import { SOURCE as SOURCE$1, fastPush, RelatedCollection, setRecordIdentifier, recordIdentifierFor } from '@ember-data/store/-private';
|
|
4
|
-
import { createSignal, subscribe, defineSignal, peekSignal, getSignal, Signals, addToTransaction, entangleSignal } from '@ember-data/tracking/-private';
|
|
3
|
+
import { withSignalStore, entangleSignal, ARRAY_SIGNAL, consumeInternalSignal, OBJECT_SIGNAL, SOURCE as SOURCE$1, fastPush, defineSignal, RelatedCollection, getOrCreateInternalSignal, notifyInternalSignal, Signals, setRecordIdentifier, recordIdentifierFor, createMemo } from '@ember-data/store/-private';
|
|
5
4
|
import { EnableHydration, STRUCTURED } from '@warp-drive/core-types/request';
|
|
6
5
|
import { RecordStore, Type } from '@warp-drive/core-types/symbols';
|
|
7
6
|
import { getOrSetGlobal } from '@warp-drive/core-types/-private';
|
|
8
|
-
import { S as SOURCE,
|
|
7
|
+
import { S as SOURCE, E as Editable, L as Legacy, I as Identifier, P as Parent, a as EmbeddedPath, D as Destroy, C as Checkout, b as EmbeddedType } from "./symbols-B_60yPO2.js";
|
|
9
8
|
import { deprecate } from '@ember/debug';
|
|
10
9
|
import { recordIdentifierFor as recordIdentifierFor$1 } from '@ember-data/store';
|
|
11
|
-
import { createCache, getValue } from '@ember-data/tracking';
|
|
12
10
|
const ARRAY_GETTER_METHODS = new Set([Symbol.iterator, 'concat', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'map', 'reduce', 'reduceRight', 'slice', 'some', 'values']);
|
|
13
11
|
// const ARRAY_SETTER_METHODS = new Set<KeyType>(['push', 'pop', 'unshift', 'shift', 'splice', 'sort']);
|
|
14
12
|
const SYNC_PROPS = new Set(['[]', 'length']);
|
|
@@ -59,10 +57,13 @@ class ManagedArray {
|
|
|
59
57
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
60
58
|
const self = this;
|
|
61
59
|
this[SOURCE] = data?.slice();
|
|
62
|
-
this[ARRAY_SIGNAL] = createSignal(this, 'length');
|
|
63
60
|
const IS_EDITABLE = this[Editable] = editable ?? false;
|
|
64
61
|
this[Legacy] = legacy;
|
|
65
|
-
|
|
62
|
+
|
|
63
|
+
// FIXME probably can get rid of the manual ARRAY_SIGNAL storage
|
|
64
|
+
// FIXME probably the storage should be on the proxy/receiver not this class
|
|
65
|
+
const signals = withSignalStore(this);
|
|
66
|
+
const _SIGNAL = this[ARRAY_SIGNAL] = entangleSignal(signals, this, ARRAY_SIGNAL, undefined);
|
|
66
67
|
const boundFns = new Map();
|
|
67
68
|
this.identifier = identifier;
|
|
68
69
|
this.path = path;
|
|
@@ -90,9 +91,8 @@ class ManagedArray {
|
|
|
90
91
|
return self.owner;
|
|
91
92
|
}
|
|
92
93
|
const index = convertToInt(prop);
|
|
93
|
-
if (_SIGNAL.
|
|
94
|
-
_SIGNAL.
|
|
95
|
-
_SIGNAL.shouldReset = false;
|
|
94
|
+
if (_SIGNAL.isStale && (index !== null || SYNC_PROPS.has(prop) || isArrayGetter(prop))) {
|
|
95
|
+
_SIGNAL.isStale = false;
|
|
96
96
|
const newData = cache.getAttr(identifier, path);
|
|
97
97
|
if (newData && newData !== self[SOURCE]) {
|
|
98
98
|
self[SOURCE].length = 0;
|
|
@@ -139,7 +139,7 @@ class ManagedArray {
|
|
|
139
139
|
}
|
|
140
140
|
if (isSchemaArray) {
|
|
141
141
|
if (!transaction) {
|
|
142
|
-
|
|
142
|
+
consumeInternalSignal(_SIGNAL);
|
|
143
143
|
}
|
|
144
144
|
if (val) {
|
|
145
145
|
const recordRef = ManagedRecordRefs.get(val);
|
|
@@ -171,7 +171,7 @@ class ManagedArray {
|
|
|
171
171
|
return val;
|
|
172
172
|
}
|
|
173
173
|
if (!transaction) {
|
|
174
|
-
|
|
174
|
+
consumeInternalSignal(_SIGNAL);
|
|
175
175
|
}
|
|
176
176
|
if (field.type) {
|
|
177
177
|
const transform = schema.transformation(field);
|
|
@@ -184,7 +184,7 @@ class ManagedArray {
|
|
|
184
184
|
if (fn === undefined) {
|
|
185
185
|
if (prop === 'forEach') {
|
|
186
186
|
fn = function () {
|
|
187
|
-
|
|
187
|
+
consumeInternalSignal(_SIGNAL);
|
|
188
188
|
transaction = true;
|
|
189
189
|
const result = safeForEach(receiver, target, store, arguments[0], arguments[1]);
|
|
190
190
|
transaction = false;
|
|
@@ -192,7 +192,7 @@ class ManagedArray {
|
|
|
192
192
|
};
|
|
193
193
|
} else {
|
|
194
194
|
fn = function () {
|
|
195
|
-
|
|
195
|
+
consumeInternalSignal(_SIGNAL);
|
|
196
196
|
// array functions must run through Reflect to work properly
|
|
197
197
|
// binding via other means will not work.
|
|
198
198
|
transaction = true;
|
|
@@ -212,7 +212,7 @@ class ManagedArray {
|
|
|
212
212
|
if (!IS_EDITABLE) {
|
|
213
213
|
throw new Error(`Mutating this array via ${String(prop)} is not allowed because the record is not editable`);
|
|
214
214
|
}
|
|
215
|
-
|
|
215
|
+
consumeInternalSignal(_SIGNAL);
|
|
216
216
|
transaction = true;
|
|
217
217
|
const result = Reflect.apply(target[prop], receiver, arguments);
|
|
218
218
|
transaction = false;
|
|
@@ -246,7 +246,7 @@ class ManagedArray {
|
|
|
246
246
|
if (reflect) {
|
|
247
247
|
if (!field.type) {
|
|
248
248
|
cache.setAttr(identifier, path, self[SOURCE]);
|
|
249
|
-
_SIGNAL.
|
|
249
|
+
_SIGNAL.isStale = true;
|
|
250
250
|
return true;
|
|
251
251
|
}
|
|
252
252
|
let rawValue = self[SOURCE];
|
|
@@ -258,7 +258,7 @@ class ManagedArray {
|
|
|
258
258
|
rawValue = self[SOURCE].map(item => transform.serialize(item, field.options ?? null, self.owner));
|
|
259
259
|
}
|
|
260
260
|
cache.setAttr(identifier, path, rawValue);
|
|
261
|
-
_SIGNAL.
|
|
261
|
+
_SIGNAL.isStale = true;
|
|
262
262
|
}
|
|
263
263
|
return reflect;
|
|
264
264
|
},
|
|
@@ -283,12 +283,12 @@ class ManagedObject {
|
|
|
283
283
|
this[SOURCE] = {
|
|
284
284
|
...data
|
|
285
285
|
};
|
|
286
|
-
|
|
286
|
+
const signals = withSignalStore(this);
|
|
287
|
+
const _SIGNAL = this[OBJECT_SIGNAL] = entangleSignal(signals, this, OBJECT_SIGNAL, undefined);
|
|
287
288
|
this[Editable] = editable;
|
|
288
289
|
this[Legacy] = legacy;
|
|
289
290
|
this[Parent] = identifier;
|
|
290
291
|
this[EmbeddedPath] = path;
|
|
291
|
-
const _SIGNAL = this[OBJECT_SIGNAL];
|
|
292
292
|
const proxy = new Proxy(this[SOURCE], {
|
|
293
293
|
ownKeys() {
|
|
294
294
|
return Object.keys(self[SOURCE]);
|
|
@@ -331,9 +331,8 @@ class ManagedObject {
|
|
|
331
331
|
return structuredClone(self[SOURCE]);
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
|
-
if (_SIGNAL.
|
|
335
|
-
_SIGNAL.
|
|
336
|
-
_SIGNAL.shouldReset = false;
|
|
334
|
+
if (_SIGNAL.isStale) {
|
|
335
|
+
_SIGNAL.isStale = false;
|
|
337
336
|
let newData = cache.getAttr(identifier, path);
|
|
338
337
|
if (newData && newData !== self[SOURCE]) {
|
|
339
338
|
if (field.type) {
|
|
@@ -346,7 +345,7 @@ class ManagedObject {
|
|
|
346
345
|
}
|
|
347
346
|
}
|
|
348
347
|
if (prop in self[SOURCE]) {
|
|
349
|
-
|
|
348
|
+
consumeInternalSignal(_SIGNAL);
|
|
350
349
|
return self[SOURCE][prop];
|
|
351
350
|
}
|
|
352
351
|
return Reflect.get(target, prop, receiver);
|
|
@@ -368,7 +367,7 @@ class ManagedObject {
|
|
|
368
367
|
const val = transform.serialize(self[SOURCE], field.options ?? null, owner);
|
|
369
368
|
cache.setAttr(identifier, path, val);
|
|
370
369
|
}
|
|
371
|
-
_SIGNAL.
|
|
370
|
+
_SIGNAL.isStale = true;
|
|
372
371
|
return true;
|
|
373
372
|
}
|
|
374
373
|
});
|
|
@@ -455,12 +454,10 @@ function extractCacheOptions(options) {
|
|
|
455
454
|
const ManagedArrayMap = getOrSetGlobal('ManagedArrayMap', new Map());
|
|
456
455
|
const ManagedObjectMap = getOrSetGlobal('ManagedObjectMap', new Map());
|
|
457
456
|
function computeLocal(record, field, prop) {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
return signal.lastValue;
|
|
457
|
+
const signals = withSignalStore(record);
|
|
458
|
+
const signal = getOrCreateInternalSignal(signals, record, prop, field.options?.defaultValue ?? null);
|
|
459
|
+
consumeInternalSignal(signal);
|
|
460
|
+
return signal.value;
|
|
464
461
|
}
|
|
465
462
|
function peekManagedArray(record, field) {
|
|
466
463
|
const managedArrayMapForRecord = ManagedArrayMap.get(record);
|
|
@@ -604,9 +601,9 @@ class ResourceRelationship {
|
|
|
604
601
|
return this[RecordStore].request(request);
|
|
605
602
|
}
|
|
606
603
|
}
|
|
607
|
-
defineSignal(ResourceRelationship.prototype, 'data');
|
|
608
|
-
defineSignal(ResourceRelationship.prototype, 'links');
|
|
609
|
-
defineSignal(ResourceRelationship.prototype, 'meta');
|
|
604
|
+
defineSignal(ResourceRelationship.prototype, 'data', null);
|
|
605
|
+
defineSignal(ResourceRelationship.prototype, 'links', null);
|
|
606
|
+
defineSignal(ResourceRelationship.prototype, 'meta', null);
|
|
610
607
|
function getHref(link) {
|
|
611
608
|
if (!link) {
|
|
612
609
|
return null;
|
|
@@ -672,7 +669,7 @@ function computeHasMany(store, schema, cache, record, identifier, field, path, e
|
|
|
672
669
|
const HAS_MODEL_PACKAGE = dependencySatisfies('@ember-data/model', '*');
|
|
673
670
|
const getLegacySupport = macroCondition(dependencySatisfies('@ember-data/model', '*')) ? importSync('@ember-data/model/-private').lookupLegacySupport : null;
|
|
674
671
|
const IgnoredGlobalFields = new Set(['length', 'nodeType', 'then', 'setInterval', 'document', STRUCTURED]);
|
|
675
|
-
const symbolList = [Destroy, RecordStore, Identifier, Editable, Parent, Checkout, Legacy,
|
|
672
|
+
const symbolList = [Destroy, RecordStore, Identifier, Editable, Parent, Checkout, Legacy, EmbeddedPath, EmbeddedType];
|
|
676
673
|
const RecordSymbols = new Set(symbolList);
|
|
677
674
|
function isPathMatch(a, b) {
|
|
678
675
|
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
@@ -704,8 +701,7 @@ class SchemaRecord {
|
|
|
704
701
|
const fields = isEmbedded ? schema.fields({
|
|
705
702
|
type: embeddedType
|
|
706
703
|
}) : schema.fields(identifier);
|
|
707
|
-
const signals =
|
|
708
|
-
this[Signals] = signals;
|
|
704
|
+
const signals = withSignalStore(this);
|
|
709
705
|
const proxy = new Proxy(this, {
|
|
710
706
|
ownKeys() {
|
|
711
707
|
const identityKey = identityField?.name;
|
|
@@ -777,6 +773,9 @@ class SchemaRecord {
|
|
|
777
773
|
if (RecordSymbols.has(prop)) {
|
|
778
774
|
return target[prop];
|
|
779
775
|
}
|
|
776
|
+
if (prop === Signals) {
|
|
777
|
+
return signals;
|
|
778
|
+
}
|
|
780
779
|
|
|
781
780
|
// TODO make this a symbol
|
|
782
781
|
if (prop === '___notifications') {
|
|
@@ -805,7 +804,7 @@ class SchemaRecord {
|
|
|
805
804
|
let fn = BoundFns.get('toString');
|
|
806
805
|
if (!fn) {
|
|
807
806
|
fn = function () {
|
|
808
|
-
entangleSignal(signals, receiver, '@identity');
|
|
807
|
+
entangleSignal(signals, receiver, '@identity', null);
|
|
809
808
|
return `Record<${identifier.type}:${identifier.id} (${identifier.lid})>`;
|
|
810
809
|
};
|
|
811
810
|
BoundFns.set(prop, fn);
|
|
@@ -816,7 +815,7 @@ class SchemaRecord {
|
|
|
816
815
|
let fn = BoundFns.get('toHTML');
|
|
817
816
|
if (!fn) {
|
|
818
817
|
fn = function () {
|
|
819
|
-
entangleSignal(signals, receiver, '@identity');
|
|
818
|
+
entangleSignal(signals, receiver, '@identity', null);
|
|
820
819
|
return `<span>Record<${identifier.type}:${identifier.id} (${identifier.lid})></span>`;
|
|
821
820
|
};
|
|
822
821
|
BoundFns.set(prop, fn);
|
|
@@ -876,42 +875,40 @@ class SchemaRecord {
|
|
|
876
875
|
|
|
877
876
|
switch (field.kind) {
|
|
878
877
|
case '@id':
|
|
879
|
-
entangleSignal(signals, receiver, '@identity');
|
|
878
|
+
entangleSignal(signals, receiver, '@identity', null);
|
|
880
879
|
return identifier.id;
|
|
881
880
|
case '@hash':
|
|
882
881
|
// TODO pass actual cache value not {}
|
|
883
882
|
return schema.hashFn(field)({}, field.options ?? null, field.name ?? null);
|
|
884
883
|
case '@local':
|
|
885
884
|
{
|
|
886
|
-
|
|
887
|
-
entangleSignal(signals, receiver, prop);
|
|
888
|
-
return lastValue;
|
|
885
|
+
return computeLocal(receiver, field, prop);
|
|
889
886
|
}
|
|
890
887
|
case 'field':
|
|
891
|
-
entangleSignal(signals, receiver, field.name);
|
|
888
|
+
entangleSignal(signals, receiver, field.name, null);
|
|
892
889
|
return computeField(schema, cache, target, identifier, field, propArray, IS_EDITABLE);
|
|
893
890
|
case 'attribute':
|
|
894
|
-
entangleSignal(signals, receiver, field.name);
|
|
891
|
+
entangleSignal(signals, receiver, field.name, null);
|
|
895
892
|
return computeAttribute(cache, identifier, prop, IS_EDITABLE);
|
|
896
893
|
case 'resource':
|
|
897
|
-
entangleSignal(signals, receiver, field.name);
|
|
894
|
+
entangleSignal(signals, receiver, field.name, null);
|
|
898
895
|
return computeResource(store, cache, target, identifier, field, prop, IS_EDITABLE);
|
|
899
896
|
case 'derived':
|
|
900
897
|
return computeDerivation(schema, receiver, identifier, field, prop);
|
|
901
898
|
case 'schema-array':
|
|
902
899
|
case 'array':
|
|
903
|
-
entangleSignal(signals, receiver, field.name);
|
|
900
|
+
entangleSignal(signals, receiver, field.name, null);
|
|
904
901
|
return computeArray(store, schema, cache, target, identifier, field, propArray, Mode[Editable], Mode[Legacy]);
|
|
905
902
|
case 'object':
|
|
906
|
-
entangleSignal(signals, receiver, field.name);
|
|
903
|
+
entangleSignal(signals, receiver, field.name, null);
|
|
907
904
|
return computeObject(schema, cache, target, identifier, field, propArray, Mode[Editable], Mode[Legacy]);
|
|
908
905
|
case 'schema-object':
|
|
909
|
-
entangleSignal(signals, receiver, field.name);
|
|
906
|
+
entangleSignal(signals, receiver, field.name, null);
|
|
910
907
|
// run transform, then use that value as the object to manage
|
|
911
908
|
return computeSchemaObject(store, cache, target, identifier, field, propArray, Mode[Legacy], Mode[Editable]);
|
|
912
909
|
case 'belongsTo':
|
|
913
910
|
if (field.options.linksMode) {
|
|
914
|
-
entangleSignal(signals, receiver, field.name);
|
|
911
|
+
entangleSignal(signals, receiver, field.name, null);
|
|
915
912
|
const rawValue = IS_EDITABLE ? cache.getRelationship(identifier, field.name) : cache.getRemoteRelationship(identifier, field.name);
|
|
916
913
|
|
|
917
914
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
@@ -934,11 +931,11 @@ class SchemaRecord {
|
|
|
934
931
|
throw new Error(`Can only use belongsTo fields when the resource is in legacy mode`);
|
|
935
932
|
}
|
|
936
933
|
})(Mode[Legacy]) : {};
|
|
937
|
-
entangleSignal(signals, receiver, field.name);
|
|
934
|
+
entangleSignal(signals, receiver, field.name, null);
|
|
938
935
|
return getLegacySupport(receiver).getBelongsTo(field.name);
|
|
939
936
|
case 'hasMany':
|
|
940
937
|
if (field.options.linksMode) {
|
|
941
|
-
entangleSignal(signals, receiver, field.name);
|
|
938
|
+
entangleSignal(signals, receiver, field.name, null);
|
|
942
939
|
return computeHasMany(store, schema, cache, target, identifier, field, propArray, Mode[Editable], Mode[Legacy]);
|
|
943
940
|
}
|
|
944
941
|
if (!HAS_MODEL_PACKAGE) {
|
|
@@ -958,7 +955,7 @@ class SchemaRecord {
|
|
|
958
955
|
throw new Error(`Can only use hasMany fields when the resource is in legacy mode`);
|
|
959
956
|
}
|
|
960
957
|
})(Mode[Legacy]) : {};
|
|
961
|
-
entangleSignal(signals, receiver, field.name);
|
|
958
|
+
entangleSignal(signals, receiver, field.name, null);
|
|
962
959
|
return getLegacySupport(receiver).getHasMany(field.name);
|
|
963
960
|
default:
|
|
964
961
|
throw new Error(`Field '${String(prop)}' on '${identifier.type}' has the unknown kind '${field.kind}'`);
|
|
@@ -1009,10 +1006,10 @@ class SchemaRecord {
|
|
|
1009
1006
|
}
|
|
1010
1007
|
case '@local':
|
|
1011
1008
|
{
|
|
1012
|
-
const signal =
|
|
1013
|
-
if (signal.
|
|
1014
|
-
signal.
|
|
1015
|
-
|
|
1009
|
+
const signal = getOrCreateInternalSignal(signals, receiver, prop, field.options?.defaultValue ?? null);
|
|
1010
|
+
if (signal.value !== value) {
|
|
1011
|
+
signal.value = value;
|
|
1012
|
+
notifyInternalSignal(signal);
|
|
1016
1013
|
}
|
|
1017
1014
|
return true;
|
|
1018
1015
|
}
|
|
@@ -1044,7 +1041,7 @@ class SchemaRecord {
|
|
|
1044
1041
|
}
|
|
1045
1042
|
})(ARRAY_SIGNAL in peeked) : {};
|
|
1046
1043
|
const arrSignal = peeked[ARRAY_SIGNAL];
|
|
1047
|
-
arrSignal.
|
|
1044
|
+
arrSignal.isStale = true;
|
|
1048
1045
|
}
|
|
1049
1046
|
if (!Array.isArray(value)) {
|
|
1050
1047
|
ManagedArrayMap.delete(target);
|
|
@@ -1062,7 +1059,7 @@ class SchemaRecord {
|
|
|
1062
1059
|
}
|
|
1063
1060
|
})(ARRAY_SIGNAL in peeked) : {};
|
|
1064
1061
|
const arrSignal = peeked[ARRAY_SIGNAL];
|
|
1065
|
-
arrSignal.
|
|
1062
|
+
arrSignal.isStale = true;
|
|
1066
1063
|
}
|
|
1067
1064
|
return true;
|
|
1068
1065
|
}
|
|
@@ -1081,7 +1078,7 @@ class SchemaRecord {
|
|
|
1081
1078
|
}
|
|
1082
1079
|
})(ARRAY_SIGNAL in peeked) : {};
|
|
1083
1080
|
const arrSignal = peeked[ARRAY_SIGNAL];
|
|
1084
|
-
arrSignal.
|
|
1081
|
+
arrSignal.isStale = true;
|
|
1085
1082
|
}
|
|
1086
1083
|
if (!Array.isArray(value)) {
|
|
1087
1084
|
ManagedArrayMap.delete(target);
|
|
@@ -1103,7 +1100,7 @@ class SchemaRecord {
|
|
|
1103
1100
|
const peeked = peekManagedObject(self, field);
|
|
1104
1101
|
if (peeked) {
|
|
1105
1102
|
const objSignal = peeked[OBJECT_SIGNAL];
|
|
1106
|
-
objSignal.
|
|
1103
|
+
objSignal.isStale = true;
|
|
1107
1104
|
}
|
|
1108
1105
|
return true;
|
|
1109
1106
|
}
|
|
@@ -1115,7 +1112,7 @@ class SchemaRecord {
|
|
|
1115
1112
|
const peeked = peekManagedObject(self, field);
|
|
1116
1113
|
if (peeked) {
|
|
1117
1114
|
const objSignal = peeked[OBJECT_SIGNAL];
|
|
1118
|
-
objSignal.
|
|
1115
|
+
objSignal.isStale = true;
|
|
1119
1116
|
}
|
|
1120
1117
|
return true;
|
|
1121
1118
|
}
|
|
@@ -1146,7 +1143,7 @@ class SchemaRecord {
|
|
|
1146
1143
|
// const peeked = peekManagedObject(self, field);
|
|
1147
1144
|
// if (peeked) {
|
|
1148
1145
|
// const objSignal = peeked[OBJECT_SIGNAL];
|
|
1149
|
-
// objSignal.
|
|
1146
|
+
// objSignal.isStale = true;
|
|
1150
1147
|
// }
|
|
1151
1148
|
return true;
|
|
1152
1149
|
}
|
|
@@ -1221,7 +1218,7 @@ class SchemaRecord {
|
|
|
1221
1218
|
if (identityField.name && identityField.kind === '@id') {
|
|
1222
1219
|
const signal = signals.get('@identity');
|
|
1223
1220
|
if (signal) {
|
|
1224
|
-
|
|
1221
|
+
notifyInternalSignal(signal);
|
|
1225
1222
|
}
|
|
1226
1223
|
}
|
|
1227
1224
|
break;
|
|
@@ -1251,7 +1248,7 @@ class SchemaRecord {
|
|
|
1251
1248
|
// console.log(`Notification for ${key} on ${identifier.type}`, self);
|
|
1252
1249
|
const signal = signals.get(key);
|
|
1253
1250
|
if (signal) {
|
|
1254
|
-
|
|
1251
|
+
notifyInternalSignal(signal);
|
|
1255
1252
|
}
|
|
1256
1253
|
const field = fields.get(key);
|
|
1257
1254
|
if (field?.kind === 'array' || field?.kind === 'schema-array') {
|
|
@@ -1263,16 +1260,14 @@ class SchemaRecord {
|
|
|
1263
1260
|
}
|
|
1264
1261
|
})(ARRAY_SIGNAL in peeked) : {};
|
|
1265
1262
|
const arrSignal = peeked[ARRAY_SIGNAL];
|
|
1266
|
-
arrSignal
|
|
1267
|
-
addToTransaction(arrSignal);
|
|
1263
|
+
notifyInternalSignal(arrSignal);
|
|
1268
1264
|
}
|
|
1269
1265
|
}
|
|
1270
1266
|
if (field?.kind === 'object') {
|
|
1271
1267
|
const peeked = peekManagedObject(self, field);
|
|
1272
1268
|
if (peeked) {
|
|
1273
1269
|
const objSignal = peeked[OBJECT_SIGNAL];
|
|
1274
|
-
objSignal
|
|
1275
|
-
addToTransaction(objSignal);
|
|
1270
|
+
notifyInternalSignal(objSignal);
|
|
1276
1271
|
}
|
|
1277
1272
|
}
|
|
1278
1273
|
}
|
|
@@ -1294,17 +1289,14 @@ class SchemaRecord {
|
|
|
1294
1289
|
// console.log(`Notification for ${key} on ${identifier.type}`, self);
|
|
1295
1290
|
const signal = signals.get(key);
|
|
1296
1291
|
if (signal) {
|
|
1297
|
-
|
|
1292
|
+
notifyInternalSignal(signal);
|
|
1298
1293
|
}
|
|
1299
1294
|
// FIXME
|
|
1300
1295
|
} else if (field.kind === 'resource') ;else if (field.kind === 'hasMany') {
|
|
1301
1296
|
if (field.options.linksMode) {
|
|
1302
1297
|
const peeked = peekManagedArray(self, field);
|
|
1303
1298
|
if (peeked) {
|
|
1304
|
-
|
|
1305
|
-
// arrSignal.shouldReset = true;
|
|
1306
|
-
// addToTransaction(arrSignal);
|
|
1307
|
-
peeked.notify();
|
|
1299
|
+
notifyInternalSignal(peeked[ARRAY_SIGNAL]);
|
|
1308
1300
|
}
|
|
1309
1301
|
return;
|
|
1310
1302
|
}
|
|
@@ -1327,7 +1319,7 @@ class SchemaRecord {
|
|
|
1327
1319
|
return;
|
|
1328
1320
|
}
|
|
1329
1321
|
if (manyArray) {
|
|
1330
|
-
manyArray
|
|
1322
|
+
notifyInternalSignal(manyArray[ARRAY_SIGNAL]);
|
|
1331
1323
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
1332
1324
|
if (!test) {
|
|
1333
1325
|
throw new Error(`Expected options to exist on relationship meta`);
|
|
@@ -1341,7 +1333,7 @@ class SchemaRecord {
|
|
|
1341
1333
|
if (field.options.async) {
|
|
1342
1334
|
const signal = signals.get(key);
|
|
1343
1335
|
if (signal) {
|
|
1344
|
-
|
|
1336
|
+
notifyInternalSignal(signal);
|
|
1345
1337
|
}
|
|
1346
1338
|
}
|
|
1347
1339
|
}
|
|
@@ -1554,15 +1546,15 @@ function registerDerivations(schema) {
|
|
|
1554
1546
|
*/
|
|
1555
1547
|
function makeCachedDerivation(derivation) {
|
|
1556
1548
|
const memoizedDerivation = (record, options, prop) => {
|
|
1557
|
-
const signals = record
|
|
1549
|
+
const signals = withSignalStore(record);
|
|
1558
1550
|
let signal = signals.get(prop);
|
|
1559
1551
|
if (!signal) {
|
|
1560
|
-
signal =
|
|
1552
|
+
signal = createMemo(record, prop, () => {
|
|
1561
1553
|
return derivation(record, options, prop);
|
|
1562
1554
|
}); // a total lie, for convenience of reusing the storage
|
|
1563
1555
|
signals.set(prop, signal);
|
|
1564
1556
|
}
|
|
1565
|
-
return
|
|
1557
|
+
return signal();
|
|
1566
1558
|
};
|
|
1567
1559
|
memoizedDerivation[Type] = derivation[Type];
|
|
1568
1560
|
return memoizedDerivation;
|