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
package/build/test-cjs/index.js
CHANGED
|
@@ -54775,10 +54775,10 @@ var ListManager = class {
|
|
|
54775
54775
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
54776
54776
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
54777
54777
|
}
|
|
54778
|
-
removeIDFromAllLists(id) {
|
|
54778
|
+
removeIDFromAllLists(id, layer) {
|
|
54779
54779
|
for (const fieldMap of this.lists.values()) {
|
|
54780
54780
|
for (const list of fieldMap.values()) {
|
|
54781
|
-
list.removeID(id);
|
|
54781
|
+
list.removeID(id, void 0, layer);
|
|
54782
54782
|
}
|
|
54783
54783
|
}
|
|
54784
54784
|
}
|
|
@@ -54935,7 +54935,7 @@ var List = class {
|
|
|
54935
54935
|
layer: layer?.id
|
|
54936
54936
|
});
|
|
54937
54937
|
}
|
|
54938
|
-
removeID(id, variables = {}) {
|
|
54938
|
+
removeID(id, variables = {}, layer) {
|
|
54939
54939
|
if (!this.validateWhen()) {
|
|
54940
54940
|
return;
|
|
54941
54941
|
}
|
|
@@ -54982,7 +54982,7 @@ var List = class {
|
|
|
54982
54982
|
subscribers.map((sub) => sub[0]),
|
|
54983
54983
|
variables
|
|
54984
54984
|
);
|
|
54985
|
-
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
54985
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
54986
54986
|
for (const [spec] of subscribers) {
|
|
54987
54987
|
spec.set(
|
|
54988
54988
|
this.cache._internal_unstable.getSelection({
|
|
@@ -54995,12 +54995,12 @@ var List = class {
|
|
|
54995
54995
|
}
|
|
54996
54996
|
return true;
|
|
54997
54997
|
}
|
|
54998
|
-
remove(data, variables = {}) {
|
|
54998
|
+
remove(data, variables = {}, layer) {
|
|
54999
54999
|
const targetID = this.cache._internal_unstable.id(this.listType(data), data);
|
|
55000
55000
|
if (!targetID) {
|
|
55001
55001
|
return;
|
|
55002
55002
|
}
|
|
55003
|
-
return this.removeID(targetID, variables);
|
|
55003
|
+
return this.removeID(targetID, variables, layer);
|
|
55004
55004
|
}
|
|
55005
55005
|
listType(data) {
|
|
55006
55006
|
return data.__typename || this.type;
|
|
@@ -55032,7 +55032,7 @@ var List = class {
|
|
|
55032
55032
|
layer,
|
|
55033
55033
|
where
|
|
55034
55034
|
}) {
|
|
55035
|
-
if (!this.remove(data, variables)) {
|
|
55035
|
+
if (!this.remove(data, variables, layer)) {
|
|
55036
55036
|
this.addToList(selection, data, variables, where, layer);
|
|
55037
55037
|
}
|
|
55038
55038
|
}
|
|
@@ -55169,7 +55169,7 @@ var StaleManager = class {
|
|
|
55169
55169
|
// src/runtime/cache/storage.ts
|
|
55170
55170
|
var InMemoryStorage = class {
|
|
55171
55171
|
data;
|
|
55172
|
-
idCount =
|
|
55172
|
+
idCount = 1;
|
|
55173
55173
|
rank = 0;
|
|
55174
55174
|
constructor() {
|
|
55175
55175
|
this.data = [];
|
|
@@ -55189,11 +55189,11 @@ var InMemoryStorage = class {
|
|
|
55189
55189
|
insert(id, field, location, target) {
|
|
55190
55190
|
return this.topLayer.insert(id, field, location, target);
|
|
55191
55191
|
}
|
|
55192
|
-
remove(id, field, target) {
|
|
55193
|
-
return
|
|
55192
|
+
remove(id, field, target, layerToUser = this.topLayer) {
|
|
55193
|
+
return layerToUser.remove(id, field, target);
|
|
55194
55194
|
}
|
|
55195
|
-
delete(id) {
|
|
55196
|
-
return
|
|
55195
|
+
delete(id, layerToUser = this.topLayer) {
|
|
55196
|
+
return layerToUser.delete(id);
|
|
55197
55197
|
}
|
|
55198
55198
|
deleteField(id, field) {
|
|
55199
55199
|
return this.topLayer.deleteField(id, field);
|
|
@@ -55565,6 +55565,9 @@ var InMemorySubscriptions = class {
|
|
|
55565
55565
|
subscribers = {};
|
|
55566
55566
|
referenceCounts = {};
|
|
55567
55567
|
keyVersions = {};
|
|
55568
|
+
activeFields(parent2) {
|
|
55569
|
+
return Object.keys(this.subscribers[parent2] || {});
|
|
55570
|
+
}
|
|
55568
55571
|
add({
|
|
55569
55572
|
parent: parent2,
|
|
55570
55573
|
spec,
|
|
@@ -55833,20 +55836,7 @@ var Cache = class {
|
|
|
55833
55836
|
}) {
|
|
55834
55837
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
55835
55838
|
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
55836
|
-
|
|
55837
|
-
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
55838
|
-
if (!notified.includes(spec.set)) {
|
|
55839
|
-
notified.push(spec.set);
|
|
55840
|
-
spec.set(
|
|
55841
|
-
this._internal_unstable.getSelection({
|
|
55842
|
-
parent: spec.parentID || rootID,
|
|
55843
|
-
selection: spec.selection,
|
|
55844
|
-
variables: spec.variables?.() || {},
|
|
55845
|
-
ignoreMasking: false
|
|
55846
|
-
}).data
|
|
55847
|
-
);
|
|
55848
|
-
}
|
|
55849
|
-
}
|
|
55839
|
+
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
55850
55840
|
return subscribers;
|
|
55851
55841
|
}
|
|
55852
55842
|
read(...args) {
|
|
@@ -55885,10 +55875,10 @@ var Cache = class {
|
|
|
55885
55875
|
}
|
|
55886
55876
|
return handler;
|
|
55887
55877
|
}
|
|
55888
|
-
delete(id) {
|
|
55878
|
+
delete(id, layer) {
|
|
55889
55879
|
this._internal_unstable.subscriptions.removeAllSubscribers(id);
|
|
55890
|
-
this._internal_unstable.lists.removeIDFromAllLists(id);
|
|
55891
|
-
this._internal_unstable.storage.delete(id);
|
|
55880
|
+
this._internal_unstable.lists.removeIDFromAllLists(id, layer);
|
|
55881
|
+
this._internal_unstable.storage.delete(id, layer);
|
|
55892
55882
|
}
|
|
55893
55883
|
setConfig(config2) {
|
|
55894
55884
|
this._internal_unstable.setConfig(config2);
|
|
@@ -55920,6 +55910,70 @@ var Cache = class {
|
|
|
55920
55910
|
config() {
|
|
55921
55911
|
return this._internal_unstable.config;
|
|
55922
55912
|
}
|
|
55913
|
+
clearLayer(layerID) {
|
|
55914
|
+
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
55915
|
+
if (!layer) {
|
|
55916
|
+
throw new Error("Cannot find layer with id: " + layerID);
|
|
55917
|
+
}
|
|
55918
|
+
const toNotify = [];
|
|
55919
|
+
const allFields = [];
|
|
55920
|
+
for (const target of [layer.fields, layer.links]) {
|
|
55921
|
+
for (const [id, fields] of Object.entries(target)) {
|
|
55922
|
+
allFields.push(
|
|
55923
|
+
...Object.entries(fields).map(([field, value]) => ({ id, field, value }))
|
|
55924
|
+
);
|
|
55925
|
+
}
|
|
55926
|
+
}
|
|
55927
|
+
const displayFields = [];
|
|
55928
|
+
for (const pair of allFields) {
|
|
55929
|
+
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
55930
|
+
if (!displayLayers.includes(layerID)) {
|
|
55931
|
+
continue;
|
|
55932
|
+
}
|
|
55933
|
+
displayFields.push(pair);
|
|
55934
|
+
}
|
|
55935
|
+
for (const [id, operation] of Object.entries(layer.operations)) {
|
|
55936
|
+
if (operation.deleted) {
|
|
55937
|
+
displayFields.push(
|
|
55938
|
+
...this._internal_unstable.subscriptions.activeFields(id).map((field) => ({ id, field }))
|
|
55939
|
+
);
|
|
55940
|
+
}
|
|
55941
|
+
const fields = Object.keys(operation.fields ?? {});
|
|
55942
|
+
if (fields.length > 0) {
|
|
55943
|
+
displayFields.push(...fields.map((field) => ({ id, field })));
|
|
55944
|
+
}
|
|
55945
|
+
}
|
|
55946
|
+
layer.clear();
|
|
55947
|
+
for (const display of displayFields) {
|
|
55948
|
+
const { field, id } = display;
|
|
55949
|
+
const notify = !("value" in display) || this._internal_unstable.storage.get(id, field).value !== display.value;
|
|
55950
|
+
if (notify) {
|
|
55951
|
+
toNotify.push(
|
|
55952
|
+
...this._internal_unstable.subscriptions.get(id, field).map((sub) => sub[0])
|
|
55953
|
+
);
|
|
55954
|
+
}
|
|
55955
|
+
}
|
|
55956
|
+
this.#notifySubscribers(toNotify);
|
|
55957
|
+
}
|
|
55958
|
+
#notifySubscribers(subs) {
|
|
55959
|
+
if (subs.length === 0) {
|
|
55960
|
+
return;
|
|
55961
|
+
}
|
|
55962
|
+
const notified = [];
|
|
55963
|
+
for (const spec of subs) {
|
|
55964
|
+
if (!notified.includes(spec.set)) {
|
|
55965
|
+
notified.push(spec.set);
|
|
55966
|
+
spec.set(
|
|
55967
|
+
this._internal_unstable.getSelection({
|
|
55968
|
+
parent: spec.parentID || rootID,
|
|
55969
|
+
selection: spec.selection,
|
|
55970
|
+
variables: spec.variables?.() || {},
|
|
55971
|
+
ignoreMasking: false
|
|
55972
|
+
}).data
|
|
55973
|
+
);
|
|
55974
|
+
}
|
|
55975
|
+
}
|
|
55976
|
+
}
|
|
55923
55977
|
};
|
|
55924
55978
|
var CacheInternal = class {
|
|
55925
55979
|
_disabled = false;
|
|
@@ -56207,8 +56261,16 @@ var CacheInternal = class {
|
|
|
56207
56261
|
operation.position || "last",
|
|
56208
56262
|
layer
|
|
56209
56263
|
);
|
|
56264
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
56265
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
56266
|
+
selection: fieldSelection,
|
|
56267
|
+
data: target,
|
|
56268
|
+
variables,
|
|
56269
|
+
where: operation.position || "last",
|
|
56270
|
+
layer
|
|
56271
|
+
});
|
|
56210
56272
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
56211
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
56273
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
|
|
56212
56274
|
} else if (operation.action === "delete" && operation.type) {
|
|
56213
56275
|
if (typeof target !== "string") {
|
|
56214
56276
|
throw new Error("Cannot delete a record with a non-string ID");
|
|
@@ -56217,15 +56279,7 @@ var CacheInternal = class {
|
|
|
56217
56279
|
if (!targetID) {
|
|
56218
56280
|
continue;
|
|
56219
56281
|
}
|
|
56220
|
-
this.cache.delete(targetID);
|
|
56221
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
56222
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
56223
|
-
selection: fieldSelection,
|
|
56224
|
-
data: target,
|
|
56225
|
-
variables,
|
|
56226
|
-
where: operation.position || "last",
|
|
56227
|
-
layer
|
|
56228
|
-
});
|
|
56282
|
+
this.cache.delete(targetID, layer);
|
|
56229
56283
|
}
|
|
56230
56284
|
}
|
|
56231
56285
|
}
|
|
@@ -56760,7 +56814,7 @@ var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
|
56760
56814
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
56761
56815
|
return {
|
|
56762
56816
|
async start(ctx, { next, marshalVariables }) {
|
|
56763
|
-
const
|
|
56817
|
+
const layerOptimistic = cache_default._internal_unstable.storage.createLayer(true);
|
|
56764
56818
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
56765
56819
|
let toNotify = [];
|
|
56766
56820
|
if (optimisticResponse) {
|
|
@@ -56771,25 +56825,29 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
56771
56825
|
data: optimisticResponse
|
|
56772
56826
|
}),
|
|
56773
56827
|
variables: marshalVariables(ctx),
|
|
56774
|
-
layer:
|
|
56828
|
+
layer: layerOptimistic.id
|
|
56775
56829
|
});
|
|
56776
56830
|
}
|
|
56777
56831
|
ctx.cacheParams = {
|
|
56778
56832
|
...ctx.cacheParams,
|
|
56779
|
-
layer,
|
|
56833
|
+
layer: layerOptimistic,
|
|
56780
56834
|
notifySubscribers: toNotify,
|
|
56781
56835
|
forceNotify: true
|
|
56782
56836
|
};
|
|
56783
56837
|
next(ctx);
|
|
56784
56838
|
},
|
|
56785
56839
|
afterNetwork(ctx, { resolve: resolve2 }) {
|
|
56786
|
-
ctx.cacheParams?.layer
|
|
56840
|
+
if (ctx.cacheParams?.layer) {
|
|
56841
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
56842
|
+
}
|
|
56787
56843
|
resolve2(ctx);
|
|
56788
56844
|
},
|
|
56789
56845
|
end(ctx, { resolve: resolve2, value }) {
|
|
56790
56846
|
const hasErrors = value.errors && value.errors.length > 0;
|
|
56791
56847
|
if (hasErrors) {
|
|
56792
|
-
ctx.cacheParams?.layer
|
|
56848
|
+
if (ctx.cacheParams?.layer) {
|
|
56849
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
56850
|
+
}
|
|
56793
56851
|
}
|
|
56794
56852
|
if (ctx.cacheParams?.layer) {
|
|
56795
56853
|
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
@@ -56799,7 +56857,7 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
56799
56857
|
catch(ctx, { error }) {
|
|
56800
56858
|
if (ctx.cacheParams?.layer) {
|
|
56801
56859
|
const { layer } = ctx.cacheParams;
|
|
56802
|
-
layer.
|
|
56860
|
+
cache_default.clearLayer(layer.id);
|
|
56803
56861
|
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
56804
56862
|
}
|
|
56805
56863
|
throw error;
|
|
@@ -58817,7 +58875,7 @@ function operationObject({
|
|
|
58817
58875
|
if (operationKind === "insert" || operationKind === "toggle") {
|
|
58818
58876
|
operation.position = position;
|
|
58819
58877
|
}
|
|
58820
|
-
if (operationKind
|
|
58878
|
+
if (allLists && operationKind !== "delete") {
|
|
58821
58879
|
operation.target = "all";
|
|
58822
58880
|
}
|
|
58823
58881
|
if (parentID) {
|
package/build/test-esm/index.js
CHANGED
|
@@ -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;
|
|
@@ -58812,7 +58870,7 @@ function operationObject({
|
|
|
58812
58870
|
if (operationKind === "insert" || operationKind === "toggle") {
|
|
58813
58871
|
operation.position = position;
|
|
58814
58872
|
}
|
|
58815
|
-
if (operationKind
|
|
58873
|
+
if (allLists && operationKind !== "delete") {
|
|
58816
58874
|
operation.target = "all";
|
|
58817
58875
|
}
|
|
58818
58876
|
if (parentID) {
|