houdini 1.2.2 → 1.2.3
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/build/cmd-cjs/index.js +106 -48
- package/build/cmd-esm/index.js +106 -48
- package/build/codegen-cjs/index.js +104 -46
- package/build/codegen-esm/index.js +104 -46
- package/build/lib-cjs/index.js +103 -45
- package/build/lib-esm/index.js +103 -45
- package/build/runtime/cache/cache.d.ts +3 -1
- package/build/runtime/cache/lists.d.ts +3 -3
- package/build/runtime/cache/storage.d.ts +2 -2
- package/build/runtime/cache/subscription.d.ts +1 -0
- package/build/runtime-cjs/cache/cache.d.ts +3 -1
- package/build/runtime-cjs/cache/cache.js +78 -27
- package/build/runtime-cjs/cache/lists.d.ts +3 -3
- package/build/runtime-cjs/cache/lists.js +7 -7
- package/build/runtime-cjs/cache/storage.d.ts +2 -2
- package/build/runtime-cjs/cache/storage.js +5 -5
- package/build/runtime-cjs/cache/subscription.d.ts +1 -0
- package/build/runtime-cjs/cache/subscription.js +3 -0
- package/build/runtime-cjs/client/plugins/mutation.js +10 -6
- package/build/runtime-esm/cache/cache.d.ts +3 -1
- package/build/runtime-esm/cache/cache.js +78 -27
- package/build/runtime-esm/cache/lists.d.ts +3 -3
- package/build/runtime-esm/cache/lists.js +7 -7
- package/build/runtime-esm/cache/storage.d.ts +2 -2
- package/build/runtime-esm/cache/storage.js +5 -5
- package/build/runtime-esm/cache/subscription.d.ts +1 -0
- package/build/runtime-esm/cache/subscription.js +3 -0
- package/build/runtime-esm/client/plugins/mutation.js +10 -6
- package/build/test-cjs/index.js +104 -46
- package/build/test-esm/index.js +104 -46
- package/build/vite-cjs/index.js +104 -46
- package/build/vite-esm/index.js +104 -46
- package/package.json +1 -1
|
@@ -54771,10 +54771,10 @@ var ListManager = class {
|
|
|
54771
54771
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
54772
54772
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
54773
54773
|
}
|
|
54774
|
-
removeIDFromAllLists(id) {
|
|
54774
|
+
removeIDFromAllLists(id, layer) {
|
|
54775
54775
|
for (const fieldMap of this.lists.values()) {
|
|
54776
54776
|
for (const list of fieldMap.values()) {
|
|
54777
|
-
list.removeID(id);
|
|
54777
|
+
list.removeID(id, void 0, layer);
|
|
54778
54778
|
}
|
|
54779
54779
|
}
|
|
54780
54780
|
}
|
|
@@ -54931,7 +54931,7 @@ var List = class {
|
|
|
54931
54931
|
layer: layer?.id
|
|
54932
54932
|
});
|
|
54933
54933
|
}
|
|
54934
|
-
removeID(id, variables = {}) {
|
|
54934
|
+
removeID(id, variables = {}, layer) {
|
|
54935
54935
|
if (!this.validateWhen()) {
|
|
54936
54936
|
return;
|
|
54937
54937
|
}
|
|
@@ -54978,7 +54978,7 @@ var List = class {
|
|
|
54978
54978
|
subscribers.map((sub) => sub[0]),
|
|
54979
54979
|
variables
|
|
54980
54980
|
);
|
|
54981
|
-
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
54981
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
54982
54982
|
for (const [spec] of subscribers) {
|
|
54983
54983
|
spec.set(
|
|
54984
54984
|
this.cache._internal_unstable.getSelection({
|
|
@@ -54991,12 +54991,12 @@ var List = class {
|
|
|
54991
54991
|
}
|
|
54992
54992
|
return true;
|
|
54993
54993
|
}
|
|
54994
|
-
remove(data, variables = {}) {
|
|
54994
|
+
remove(data, variables = {}, layer) {
|
|
54995
54995
|
const targetID = this.cache._internal_unstable.id(this.listType(data), data);
|
|
54996
54996
|
if (!targetID) {
|
|
54997
54997
|
return;
|
|
54998
54998
|
}
|
|
54999
|
-
return this.removeID(targetID, variables);
|
|
54999
|
+
return this.removeID(targetID, variables, layer);
|
|
55000
55000
|
}
|
|
55001
55001
|
listType(data) {
|
|
55002
55002
|
return data.__typename || this.type;
|
|
@@ -55028,7 +55028,7 @@ var List = class {
|
|
|
55028
55028
|
layer,
|
|
55029
55029
|
where
|
|
55030
55030
|
}) {
|
|
55031
|
-
if (!this.remove(data, variables)) {
|
|
55031
|
+
if (!this.remove(data, variables, layer)) {
|
|
55032
55032
|
this.addToList(selection, data, variables, where, layer);
|
|
55033
55033
|
}
|
|
55034
55034
|
}
|
|
@@ -55165,7 +55165,7 @@ var StaleManager = class {
|
|
|
55165
55165
|
// src/runtime/cache/storage.ts
|
|
55166
55166
|
var InMemoryStorage = class {
|
|
55167
55167
|
data;
|
|
55168
|
-
idCount =
|
|
55168
|
+
idCount = 1;
|
|
55169
55169
|
rank = 0;
|
|
55170
55170
|
constructor() {
|
|
55171
55171
|
this.data = [];
|
|
@@ -55185,11 +55185,11 @@ var InMemoryStorage = class {
|
|
|
55185
55185
|
insert(id, field, location, target) {
|
|
55186
55186
|
return this.topLayer.insert(id, field, location, target);
|
|
55187
55187
|
}
|
|
55188
|
-
remove(id, field, target) {
|
|
55189
|
-
return
|
|
55188
|
+
remove(id, field, target, layerToUser = this.topLayer) {
|
|
55189
|
+
return layerToUser.remove(id, field, target);
|
|
55190
55190
|
}
|
|
55191
|
-
delete(id) {
|
|
55192
|
-
return
|
|
55191
|
+
delete(id, layerToUser = this.topLayer) {
|
|
55192
|
+
return layerToUser.delete(id);
|
|
55193
55193
|
}
|
|
55194
55194
|
deleteField(id, field) {
|
|
55195
55195
|
return this.topLayer.deleteField(id, field);
|
|
@@ -55561,6 +55561,9 @@ var InMemorySubscriptions = class {
|
|
|
55561
55561
|
subscribers = {};
|
|
55562
55562
|
referenceCounts = {};
|
|
55563
55563
|
keyVersions = {};
|
|
55564
|
+
activeFields(parent2) {
|
|
55565
|
+
return Object.keys(this.subscribers[parent2] || {});
|
|
55566
|
+
}
|
|
55564
55567
|
add({
|
|
55565
55568
|
parent: parent2,
|
|
55566
55569
|
spec,
|
|
@@ -55829,20 +55832,7 @@ var Cache = class {
|
|
|
55829
55832
|
}) {
|
|
55830
55833
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
55831
55834
|
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
55832
|
-
|
|
55833
|
-
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
55834
|
-
if (!notified.includes(spec.set)) {
|
|
55835
|
-
notified.push(spec.set);
|
|
55836
|
-
spec.set(
|
|
55837
|
-
this._internal_unstable.getSelection({
|
|
55838
|
-
parent: spec.parentID || rootID,
|
|
55839
|
-
selection: spec.selection,
|
|
55840
|
-
variables: spec.variables?.() || {},
|
|
55841
|
-
ignoreMasking: false
|
|
55842
|
-
}).data
|
|
55843
|
-
);
|
|
55844
|
-
}
|
|
55845
|
-
}
|
|
55835
|
+
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
55846
55836
|
return subscribers;
|
|
55847
55837
|
}
|
|
55848
55838
|
read(...args) {
|
|
@@ -55881,10 +55871,10 @@ var Cache = class {
|
|
|
55881
55871
|
}
|
|
55882
55872
|
return handler;
|
|
55883
55873
|
}
|
|
55884
|
-
delete(id) {
|
|
55874
|
+
delete(id, layer) {
|
|
55885
55875
|
this._internal_unstable.subscriptions.removeAllSubscribers(id);
|
|
55886
|
-
this._internal_unstable.lists.removeIDFromAllLists(id);
|
|
55887
|
-
this._internal_unstable.storage.delete(id);
|
|
55876
|
+
this._internal_unstable.lists.removeIDFromAllLists(id, layer);
|
|
55877
|
+
this._internal_unstable.storage.delete(id, layer);
|
|
55888
55878
|
}
|
|
55889
55879
|
setConfig(config2) {
|
|
55890
55880
|
this._internal_unstable.setConfig(config2);
|
|
@@ -55916,6 +55906,70 @@ var Cache = class {
|
|
|
55916
55906
|
config() {
|
|
55917
55907
|
return this._internal_unstable.config;
|
|
55918
55908
|
}
|
|
55909
|
+
clearLayer(layerID) {
|
|
55910
|
+
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
55911
|
+
if (!layer) {
|
|
55912
|
+
throw new Error("Cannot find layer with id: " + layerID);
|
|
55913
|
+
}
|
|
55914
|
+
const toNotify = [];
|
|
55915
|
+
const allFields = [];
|
|
55916
|
+
for (const target of [layer.fields, layer.links]) {
|
|
55917
|
+
for (const [id, fields] of Object.entries(target)) {
|
|
55918
|
+
allFields.push(
|
|
55919
|
+
...Object.entries(fields).map(([field, value]) => ({ id, field, value }))
|
|
55920
|
+
);
|
|
55921
|
+
}
|
|
55922
|
+
}
|
|
55923
|
+
const displayFields = [];
|
|
55924
|
+
for (const pair of allFields) {
|
|
55925
|
+
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
55926
|
+
if (!displayLayers.includes(layerID)) {
|
|
55927
|
+
continue;
|
|
55928
|
+
}
|
|
55929
|
+
displayFields.push(pair);
|
|
55930
|
+
}
|
|
55931
|
+
for (const [id, operation] of Object.entries(layer.operations)) {
|
|
55932
|
+
if (operation.deleted) {
|
|
55933
|
+
displayFields.push(
|
|
55934
|
+
...this._internal_unstable.subscriptions.activeFields(id).map((field) => ({ id, field }))
|
|
55935
|
+
);
|
|
55936
|
+
}
|
|
55937
|
+
const fields = Object.keys(operation.fields ?? {});
|
|
55938
|
+
if (fields.length > 0) {
|
|
55939
|
+
displayFields.push(...fields.map((field) => ({ id, field })));
|
|
55940
|
+
}
|
|
55941
|
+
}
|
|
55942
|
+
layer.clear();
|
|
55943
|
+
for (const display of displayFields) {
|
|
55944
|
+
const { field, id } = display;
|
|
55945
|
+
const notify = !("value" in display) || this._internal_unstable.storage.get(id, field).value !== display.value;
|
|
55946
|
+
if (notify) {
|
|
55947
|
+
toNotify.push(
|
|
55948
|
+
...this._internal_unstable.subscriptions.get(id, field).map((sub) => sub[0])
|
|
55949
|
+
);
|
|
55950
|
+
}
|
|
55951
|
+
}
|
|
55952
|
+
this.#notifySubscribers(toNotify);
|
|
55953
|
+
}
|
|
55954
|
+
#notifySubscribers(subs) {
|
|
55955
|
+
if (subs.length === 0) {
|
|
55956
|
+
return;
|
|
55957
|
+
}
|
|
55958
|
+
const notified = [];
|
|
55959
|
+
for (const spec of subs) {
|
|
55960
|
+
if (!notified.includes(spec.set)) {
|
|
55961
|
+
notified.push(spec.set);
|
|
55962
|
+
spec.set(
|
|
55963
|
+
this._internal_unstable.getSelection({
|
|
55964
|
+
parent: spec.parentID || rootID,
|
|
55965
|
+
selection: spec.selection,
|
|
55966
|
+
variables: spec.variables?.() || {},
|
|
55967
|
+
ignoreMasking: false
|
|
55968
|
+
}).data
|
|
55969
|
+
);
|
|
55970
|
+
}
|
|
55971
|
+
}
|
|
55972
|
+
}
|
|
55919
55973
|
};
|
|
55920
55974
|
var CacheInternal = class {
|
|
55921
55975
|
_disabled = false;
|
|
@@ -56203,8 +56257,16 @@ var CacheInternal = class {
|
|
|
56203
56257
|
operation.position || "last",
|
|
56204
56258
|
layer
|
|
56205
56259
|
);
|
|
56260
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
56261
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
56262
|
+
selection: fieldSelection,
|
|
56263
|
+
data: target,
|
|
56264
|
+
variables,
|
|
56265
|
+
where: operation.position || "last",
|
|
56266
|
+
layer
|
|
56267
|
+
});
|
|
56206
56268
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
56207
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
56269
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
|
|
56208
56270
|
} else if (operation.action === "delete" && operation.type) {
|
|
56209
56271
|
if (typeof target !== "string") {
|
|
56210
56272
|
throw new Error("Cannot delete a record with a non-string ID");
|
|
@@ -56213,15 +56275,7 @@ var CacheInternal = class {
|
|
|
56213
56275
|
if (!targetID) {
|
|
56214
56276
|
continue;
|
|
56215
56277
|
}
|
|
56216
|
-
this.cache.delete(targetID);
|
|
56217
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
56218
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
56219
|
-
selection: fieldSelection,
|
|
56220
|
-
data: target,
|
|
56221
|
-
variables,
|
|
56222
|
-
where: operation.position || "last",
|
|
56223
|
-
layer
|
|
56224
|
-
});
|
|
56278
|
+
this.cache.delete(targetID, layer);
|
|
56225
56279
|
}
|
|
56226
56280
|
}
|
|
56227
56281
|
}
|
|
@@ -56756,7 +56810,7 @@ var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
|
56756
56810
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
56757
56811
|
return {
|
|
56758
56812
|
async start(ctx, { next, marshalVariables }) {
|
|
56759
|
-
const
|
|
56813
|
+
const layerOptimistic = cache_default._internal_unstable.storage.createLayer(true);
|
|
56760
56814
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
56761
56815
|
let toNotify = [];
|
|
56762
56816
|
if (optimisticResponse) {
|
|
@@ -56767,25 +56821,29 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
56767
56821
|
data: optimisticResponse
|
|
56768
56822
|
}),
|
|
56769
56823
|
variables: marshalVariables(ctx),
|
|
56770
|
-
layer:
|
|
56824
|
+
layer: layerOptimistic.id
|
|
56771
56825
|
});
|
|
56772
56826
|
}
|
|
56773
56827
|
ctx.cacheParams = {
|
|
56774
56828
|
...ctx.cacheParams,
|
|
56775
|
-
layer,
|
|
56829
|
+
layer: layerOptimistic,
|
|
56776
56830
|
notifySubscribers: toNotify,
|
|
56777
56831
|
forceNotify: true
|
|
56778
56832
|
};
|
|
56779
56833
|
next(ctx);
|
|
56780
56834
|
},
|
|
56781
56835
|
afterNetwork(ctx, { resolve: resolve2 }) {
|
|
56782
|
-
ctx.cacheParams?.layer
|
|
56836
|
+
if (ctx.cacheParams?.layer) {
|
|
56837
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
56838
|
+
}
|
|
56783
56839
|
resolve2(ctx);
|
|
56784
56840
|
},
|
|
56785
56841
|
end(ctx, { resolve: resolve2, value }) {
|
|
56786
56842
|
const hasErrors = value.errors && value.errors.length > 0;
|
|
56787
56843
|
if (hasErrors) {
|
|
56788
|
-
ctx.cacheParams?.layer
|
|
56844
|
+
if (ctx.cacheParams?.layer) {
|
|
56845
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
56846
|
+
}
|
|
56789
56847
|
}
|
|
56790
56848
|
if (ctx.cacheParams?.layer) {
|
|
56791
56849
|
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
@@ -56795,7 +56853,7 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
56795
56853
|
catch(ctx, { error }) {
|
|
56796
56854
|
if (ctx.cacheParams?.layer) {
|
|
56797
56855
|
const { layer } = ctx.cacheParams;
|
|
56798
|
-
layer.
|
|
56856
|
+
cache_default.clearLayer(layer.id);
|
|
56799
56857
|
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
56800
56858
|
}
|
|
56801
56859
|
throw error;
|
|
@@ -58410,7 +58468,7 @@ function operationObject({
|
|
|
58410
58468
|
if (operationKind === "insert" || operationKind === "toggle") {
|
|
58411
58469
|
operation.position = position;
|
|
58412
58470
|
}
|
|
58413
|
-
if (operationKind
|
|
58471
|
+
if (allLists && operationKind !== "delete") {
|
|
58414
58472
|
operation.target = "all";
|
|
58415
58473
|
}
|
|
58416
58474
|
if (parentID) {
|
|
@@ -54770,10 +54770,10 @@ var ListManager = class {
|
|
|
54770
54770
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
54771
54771
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
54772
54772
|
}
|
|
54773
|
-
removeIDFromAllLists(id) {
|
|
54773
|
+
removeIDFromAllLists(id, layer) {
|
|
54774
54774
|
for (const fieldMap of this.lists.values()) {
|
|
54775
54775
|
for (const list of fieldMap.values()) {
|
|
54776
|
-
list.removeID(id);
|
|
54776
|
+
list.removeID(id, void 0, layer);
|
|
54777
54777
|
}
|
|
54778
54778
|
}
|
|
54779
54779
|
}
|
|
@@ -54930,7 +54930,7 @@ var List = class {
|
|
|
54930
54930
|
layer: layer?.id
|
|
54931
54931
|
});
|
|
54932
54932
|
}
|
|
54933
|
-
removeID(id, variables = {}) {
|
|
54933
|
+
removeID(id, variables = {}, layer) {
|
|
54934
54934
|
if (!this.validateWhen()) {
|
|
54935
54935
|
return;
|
|
54936
54936
|
}
|
|
@@ -54977,7 +54977,7 @@ var List = class {
|
|
|
54977
54977
|
subscribers.map((sub) => sub[0]),
|
|
54978
54978
|
variables
|
|
54979
54979
|
);
|
|
54980
|
-
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
54980
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
54981
54981
|
for (const [spec] of subscribers) {
|
|
54982
54982
|
spec.set(
|
|
54983
54983
|
this.cache._internal_unstable.getSelection({
|
|
@@ -54990,12 +54990,12 @@ var List = class {
|
|
|
54990
54990
|
}
|
|
54991
54991
|
return true;
|
|
54992
54992
|
}
|
|
54993
|
-
remove(data, variables = {}) {
|
|
54993
|
+
remove(data, variables = {}, layer) {
|
|
54994
54994
|
const targetID = this.cache._internal_unstable.id(this.listType(data), data);
|
|
54995
54995
|
if (!targetID) {
|
|
54996
54996
|
return;
|
|
54997
54997
|
}
|
|
54998
|
-
return this.removeID(targetID, variables);
|
|
54998
|
+
return this.removeID(targetID, variables, layer);
|
|
54999
54999
|
}
|
|
55000
55000
|
listType(data) {
|
|
55001
55001
|
return data.__typename || this.type;
|
|
@@ -55027,7 +55027,7 @@ var List = class {
|
|
|
55027
55027
|
layer,
|
|
55028
55028
|
where
|
|
55029
55029
|
}) {
|
|
55030
|
-
if (!this.remove(data, variables)) {
|
|
55030
|
+
if (!this.remove(data, variables, layer)) {
|
|
55031
55031
|
this.addToList(selection, data, variables, where, layer);
|
|
55032
55032
|
}
|
|
55033
55033
|
}
|
|
@@ -55164,7 +55164,7 @@ var StaleManager = class {
|
|
|
55164
55164
|
// src/runtime/cache/storage.ts
|
|
55165
55165
|
var InMemoryStorage = class {
|
|
55166
55166
|
data;
|
|
55167
|
-
idCount =
|
|
55167
|
+
idCount = 1;
|
|
55168
55168
|
rank = 0;
|
|
55169
55169
|
constructor() {
|
|
55170
55170
|
this.data = [];
|
|
@@ -55184,11 +55184,11 @@ var InMemoryStorage = class {
|
|
|
55184
55184
|
insert(id, field, location, target) {
|
|
55185
55185
|
return this.topLayer.insert(id, field, location, target);
|
|
55186
55186
|
}
|
|
55187
|
-
remove(id, field, target) {
|
|
55188
|
-
return
|
|
55187
|
+
remove(id, field, target, layerToUser = this.topLayer) {
|
|
55188
|
+
return layerToUser.remove(id, field, target);
|
|
55189
55189
|
}
|
|
55190
|
-
delete(id) {
|
|
55191
|
-
return
|
|
55190
|
+
delete(id, layerToUser = this.topLayer) {
|
|
55191
|
+
return layerToUser.delete(id);
|
|
55192
55192
|
}
|
|
55193
55193
|
deleteField(id, field) {
|
|
55194
55194
|
return this.topLayer.deleteField(id, field);
|
|
@@ -55560,6 +55560,9 @@ var InMemorySubscriptions = class {
|
|
|
55560
55560
|
subscribers = {};
|
|
55561
55561
|
referenceCounts = {};
|
|
55562
55562
|
keyVersions = {};
|
|
55563
|
+
activeFields(parent2) {
|
|
55564
|
+
return Object.keys(this.subscribers[parent2] || {});
|
|
55565
|
+
}
|
|
55563
55566
|
add({
|
|
55564
55567
|
parent: parent2,
|
|
55565
55568
|
spec,
|
|
@@ -55828,20 +55831,7 @@ var Cache = class {
|
|
|
55828
55831
|
}) {
|
|
55829
55832
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
55830
55833
|
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
55831
|
-
|
|
55832
|
-
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
55833
|
-
if (!notified.includes(spec.set)) {
|
|
55834
|
-
notified.push(spec.set);
|
|
55835
|
-
spec.set(
|
|
55836
|
-
this._internal_unstable.getSelection({
|
|
55837
|
-
parent: spec.parentID || rootID,
|
|
55838
|
-
selection: spec.selection,
|
|
55839
|
-
variables: spec.variables?.() || {},
|
|
55840
|
-
ignoreMasking: false
|
|
55841
|
-
}).data
|
|
55842
|
-
);
|
|
55843
|
-
}
|
|
55844
|
-
}
|
|
55834
|
+
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
55845
55835
|
return subscribers;
|
|
55846
55836
|
}
|
|
55847
55837
|
read(...args) {
|
|
@@ -55880,10 +55870,10 @@ var Cache = class {
|
|
|
55880
55870
|
}
|
|
55881
55871
|
return handler;
|
|
55882
55872
|
}
|
|
55883
|
-
delete(id) {
|
|
55873
|
+
delete(id, layer) {
|
|
55884
55874
|
this._internal_unstable.subscriptions.removeAllSubscribers(id);
|
|
55885
|
-
this._internal_unstable.lists.removeIDFromAllLists(id);
|
|
55886
|
-
this._internal_unstable.storage.delete(id);
|
|
55875
|
+
this._internal_unstable.lists.removeIDFromAllLists(id, layer);
|
|
55876
|
+
this._internal_unstable.storage.delete(id, layer);
|
|
55887
55877
|
}
|
|
55888
55878
|
setConfig(config2) {
|
|
55889
55879
|
this._internal_unstable.setConfig(config2);
|
|
@@ -55915,6 +55905,70 @@ var Cache = class {
|
|
|
55915
55905
|
config() {
|
|
55916
55906
|
return this._internal_unstable.config;
|
|
55917
55907
|
}
|
|
55908
|
+
clearLayer(layerID) {
|
|
55909
|
+
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
55910
|
+
if (!layer) {
|
|
55911
|
+
throw new Error("Cannot find layer with id: " + layerID);
|
|
55912
|
+
}
|
|
55913
|
+
const toNotify = [];
|
|
55914
|
+
const allFields = [];
|
|
55915
|
+
for (const target of [layer.fields, layer.links]) {
|
|
55916
|
+
for (const [id, fields] of Object.entries(target)) {
|
|
55917
|
+
allFields.push(
|
|
55918
|
+
...Object.entries(fields).map(([field, value]) => ({ id, field, value }))
|
|
55919
|
+
);
|
|
55920
|
+
}
|
|
55921
|
+
}
|
|
55922
|
+
const displayFields = [];
|
|
55923
|
+
for (const pair of allFields) {
|
|
55924
|
+
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
55925
|
+
if (!displayLayers.includes(layerID)) {
|
|
55926
|
+
continue;
|
|
55927
|
+
}
|
|
55928
|
+
displayFields.push(pair);
|
|
55929
|
+
}
|
|
55930
|
+
for (const [id, operation] of Object.entries(layer.operations)) {
|
|
55931
|
+
if (operation.deleted) {
|
|
55932
|
+
displayFields.push(
|
|
55933
|
+
...this._internal_unstable.subscriptions.activeFields(id).map((field) => ({ id, field }))
|
|
55934
|
+
);
|
|
55935
|
+
}
|
|
55936
|
+
const fields = Object.keys(operation.fields ?? {});
|
|
55937
|
+
if (fields.length > 0) {
|
|
55938
|
+
displayFields.push(...fields.map((field) => ({ id, field })));
|
|
55939
|
+
}
|
|
55940
|
+
}
|
|
55941
|
+
layer.clear();
|
|
55942
|
+
for (const display of displayFields) {
|
|
55943
|
+
const { field, id } = display;
|
|
55944
|
+
const notify = !("value" in display) || this._internal_unstable.storage.get(id, field).value !== display.value;
|
|
55945
|
+
if (notify) {
|
|
55946
|
+
toNotify.push(
|
|
55947
|
+
...this._internal_unstable.subscriptions.get(id, field).map((sub) => sub[0])
|
|
55948
|
+
);
|
|
55949
|
+
}
|
|
55950
|
+
}
|
|
55951
|
+
this.#notifySubscribers(toNotify);
|
|
55952
|
+
}
|
|
55953
|
+
#notifySubscribers(subs) {
|
|
55954
|
+
if (subs.length === 0) {
|
|
55955
|
+
return;
|
|
55956
|
+
}
|
|
55957
|
+
const notified = [];
|
|
55958
|
+
for (const spec of subs) {
|
|
55959
|
+
if (!notified.includes(spec.set)) {
|
|
55960
|
+
notified.push(spec.set);
|
|
55961
|
+
spec.set(
|
|
55962
|
+
this._internal_unstable.getSelection({
|
|
55963
|
+
parent: spec.parentID || rootID,
|
|
55964
|
+
selection: spec.selection,
|
|
55965
|
+
variables: spec.variables?.() || {},
|
|
55966
|
+
ignoreMasking: false
|
|
55967
|
+
}).data
|
|
55968
|
+
);
|
|
55969
|
+
}
|
|
55970
|
+
}
|
|
55971
|
+
}
|
|
55918
55972
|
};
|
|
55919
55973
|
var CacheInternal = class {
|
|
55920
55974
|
_disabled = false;
|
|
@@ -56202,8 +56256,16 @@ var CacheInternal = class {
|
|
|
56202
56256
|
operation.position || "last",
|
|
56203
56257
|
layer
|
|
56204
56258
|
);
|
|
56259
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
56260
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
56261
|
+
selection: fieldSelection,
|
|
56262
|
+
data: target,
|
|
56263
|
+
variables,
|
|
56264
|
+
where: operation.position || "last",
|
|
56265
|
+
layer
|
|
56266
|
+
});
|
|
56205
56267
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
56206
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
56268
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
|
|
56207
56269
|
} else if (operation.action === "delete" && operation.type) {
|
|
56208
56270
|
if (typeof target !== "string") {
|
|
56209
56271
|
throw new Error("Cannot delete a record with a non-string ID");
|
|
@@ -56212,15 +56274,7 @@ var CacheInternal = class {
|
|
|
56212
56274
|
if (!targetID) {
|
|
56213
56275
|
continue;
|
|
56214
56276
|
}
|
|
56215
|
-
this.cache.delete(targetID);
|
|
56216
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
56217
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
56218
|
-
selection: fieldSelection,
|
|
56219
|
-
data: target,
|
|
56220
|
-
variables,
|
|
56221
|
-
where: operation.position || "last",
|
|
56222
|
-
layer
|
|
56223
|
-
});
|
|
56277
|
+
this.cache.delete(targetID, layer);
|
|
56224
56278
|
}
|
|
56225
56279
|
}
|
|
56226
56280
|
}
|
|
@@ -56755,7 +56809,7 @@ var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
|
56755
56809
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
56756
56810
|
return {
|
|
56757
56811
|
async start(ctx, { next, marshalVariables }) {
|
|
56758
|
-
const
|
|
56812
|
+
const layerOptimistic = cache_default._internal_unstable.storage.createLayer(true);
|
|
56759
56813
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
56760
56814
|
let toNotify = [];
|
|
56761
56815
|
if (optimisticResponse) {
|
|
@@ -56766,25 +56820,29 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
56766
56820
|
data: optimisticResponse
|
|
56767
56821
|
}),
|
|
56768
56822
|
variables: marshalVariables(ctx),
|
|
56769
|
-
layer:
|
|
56823
|
+
layer: layerOptimistic.id
|
|
56770
56824
|
});
|
|
56771
56825
|
}
|
|
56772
56826
|
ctx.cacheParams = {
|
|
56773
56827
|
...ctx.cacheParams,
|
|
56774
|
-
layer,
|
|
56828
|
+
layer: layerOptimistic,
|
|
56775
56829
|
notifySubscribers: toNotify,
|
|
56776
56830
|
forceNotify: true
|
|
56777
56831
|
};
|
|
56778
56832
|
next(ctx);
|
|
56779
56833
|
},
|
|
56780
56834
|
afterNetwork(ctx, { resolve: resolve2 }) {
|
|
56781
|
-
ctx.cacheParams?.layer
|
|
56835
|
+
if (ctx.cacheParams?.layer) {
|
|
56836
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
56837
|
+
}
|
|
56782
56838
|
resolve2(ctx);
|
|
56783
56839
|
},
|
|
56784
56840
|
end(ctx, { resolve: resolve2, value }) {
|
|
56785
56841
|
const hasErrors = value.errors && value.errors.length > 0;
|
|
56786
56842
|
if (hasErrors) {
|
|
56787
|
-
ctx.cacheParams?.layer
|
|
56843
|
+
if (ctx.cacheParams?.layer) {
|
|
56844
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
56845
|
+
}
|
|
56788
56846
|
}
|
|
56789
56847
|
if (ctx.cacheParams?.layer) {
|
|
56790
56848
|
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
@@ -56794,7 +56852,7 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
56794
56852
|
catch(ctx, { error }) {
|
|
56795
56853
|
if (ctx.cacheParams?.layer) {
|
|
56796
56854
|
const { layer } = ctx.cacheParams;
|
|
56797
|
-
layer.
|
|
56855
|
+
cache_default.clearLayer(layer.id);
|
|
56798
56856
|
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
56799
56857
|
}
|
|
56800
56858
|
throw error;
|
|
@@ -58408,7 +58466,7 @@ function operationObject({
|
|
|
58408
58466
|
if (operationKind === "insert" || operationKind === "toggle") {
|
|
58409
58467
|
operation.position = position;
|
|
58410
58468
|
}
|
|
58411
|
-
if (operationKind
|
|
58469
|
+
if (allLists && operationKind !== "delete") {
|
|
58412
58470
|
operation.target = "all";
|
|
58413
58471
|
}
|
|
58414
58472
|
if (parentID) {
|