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/vite-cjs/index.js
CHANGED
|
@@ -67158,10 +67158,10 @@ var ListManager = class {
|
|
|
67158
67158
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
67159
67159
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
67160
67160
|
}
|
|
67161
|
-
removeIDFromAllLists(id) {
|
|
67161
|
+
removeIDFromAllLists(id, layer) {
|
|
67162
67162
|
for (const fieldMap of this.lists.values()) {
|
|
67163
67163
|
for (const list of fieldMap.values()) {
|
|
67164
|
-
list.removeID(id);
|
|
67164
|
+
list.removeID(id, void 0, layer);
|
|
67165
67165
|
}
|
|
67166
67166
|
}
|
|
67167
67167
|
}
|
|
@@ -67318,7 +67318,7 @@ var List = class {
|
|
|
67318
67318
|
layer: layer?.id
|
|
67319
67319
|
});
|
|
67320
67320
|
}
|
|
67321
|
-
removeID(id, variables = {}) {
|
|
67321
|
+
removeID(id, variables = {}, layer) {
|
|
67322
67322
|
if (!this.validateWhen()) {
|
|
67323
67323
|
return;
|
|
67324
67324
|
}
|
|
@@ -67365,7 +67365,7 @@ var List = class {
|
|
|
67365
67365
|
subscribers.map((sub) => sub[0]),
|
|
67366
67366
|
variables
|
|
67367
67367
|
);
|
|
67368
|
-
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
67368
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
67369
67369
|
for (const [spec] of subscribers) {
|
|
67370
67370
|
spec.set(
|
|
67371
67371
|
this.cache._internal_unstable.getSelection({
|
|
@@ -67378,12 +67378,12 @@ var List = class {
|
|
|
67378
67378
|
}
|
|
67379
67379
|
return true;
|
|
67380
67380
|
}
|
|
67381
|
-
remove(data, variables = {}) {
|
|
67381
|
+
remove(data, variables = {}, layer) {
|
|
67382
67382
|
const targetID = this.cache._internal_unstable.id(this.listType(data), data);
|
|
67383
67383
|
if (!targetID) {
|
|
67384
67384
|
return;
|
|
67385
67385
|
}
|
|
67386
|
-
return this.removeID(targetID, variables);
|
|
67386
|
+
return this.removeID(targetID, variables, layer);
|
|
67387
67387
|
}
|
|
67388
67388
|
listType(data) {
|
|
67389
67389
|
return data.__typename || this.type;
|
|
@@ -67415,7 +67415,7 @@ var List = class {
|
|
|
67415
67415
|
layer,
|
|
67416
67416
|
where
|
|
67417
67417
|
}) {
|
|
67418
|
-
if (!this.remove(data, variables)) {
|
|
67418
|
+
if (!this.remove(data, variables, layer)) {
|
|
67419
67419
|
this.addToList(selection, data, variables, where, layer);
|
|
67420
67420
|
}
|
|
67421
67421
|
}
|
|
@@ -67552,7 +67552,7 @@ var StaleManager = class {
|
|
|
67552
67552
|
// src/runtime/cache/storage.ts
|
|
67553
67553
|
var InMemoryStorage = class {
|
|
67554
67554
|
data;
|
|
67555
|
-
idCount =
|
|
67555
|
+
idCount = 1;
|
|
67556
67556
|
rank = 0;
|
|
67557
67557
|
constructor() {
|
|
67558
67558
|
this.data = [];
|
|
@@ -67572,11 +67572,11 @@ var InMemoryStorage = class {
|
|
|
67572
67572
|
insert(id, field, location, target) {
|
|
67573
67573
|
return this.topLayer.insert(id, field, location, target);
|
|
67574
67574
|
}
|
|
67575
|
-
remove(id, field, target) {
|
|
67576
|
-
return
|
|
67575
|
+
remove(id, field, target, layerToUser = this.topLayer) {
|
|
67576
|
+
return layerToUser.remove(id, field, target);
|
|
67577
67577
|
}
|
|
67578
|
-
delete(id) {
|
|
67579
|
-
return
|
|
67578
|
+
delete(id, layerToUser = this.topLayer) {
|
|
67579
|
+
return layerToUser.delete(id);
|
|
67580
67580
|
}
|
|
67581
67581
|
deleteField(id, field) {
|
|
67582
67582
|
return this.topLayer.deleteField(id, field);
|
|
@@ -67948,6 +67948,9 @@ var InMemorySubscriptions = class {
|
|
|
67948
67948
|
subscribers = {};
|
|
67949
67949
|
referenceCounts = {};
|
|
67950
67950
|
keyVersions = {};
|
|
67951
|
+
activeFields(parent2) {
|
|
67952
|
+
return Object.keys(this.subscribers[parent2] || {});
|
|
67953
|
+
}
|
|
67951
67954
|
add({
|
|
67952
67955
|
parent: parent2,
|
|
67953
67956
|
spec,
|
|
@@ -68216,20 +68219,7 @@ var Cache = class {
|
|
|
68216
68219
|
}) {
|
|
68217
68220
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
68218
68221
|
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
68219
|
-
|
|
68220
|
-
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
68221
|
-
if (!notified.includes(spec.set)) {
|
|
68222
|
-
notified.push(spec.set);
|
|
68223
|
-
spec.set(
|
|
68224
|
-
this._internal_unstable.getSelection({
|
|
68225
|
-
parent: spec.parentID || rootID,
|
|
68226
|
-
selection: spec.selection,
|
|
68227
|
-
variables: spec.variables?.() || {},
|
|
68228
|
-
ignoreMasking: false
|
|
68229
|
-
}).data
|
|
68230
|
-
);
|
|
68231
|
-
}
|
|
68232
|
-
}
|
|
68222
|
+
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
68233
68223
|
return subscribers;
|
|
68234
68224
|
}
|
|
68235
68225
|
read(...args) {
|
|
@@ -68268,10 +68258,10 @@ var Cache = class {
|
|
|
68268
68258
|
}
|
|
68269
68259
|
return handler;
|
|
68270
68260
|
}
|
|
68271
|
-
delete(id) {
|
|
68261
|
+
delete(id, layer) {
|
|
68272
68262
|
this._internal_unstable.subscriptions.removeAllSubscribers(id);
|
|
68273
|
-
this._internal_unstable.lists.removeIDFromAllLists(id);
|
|
68274
|
-
this._internal_unstable.storage.delete(id);
|
|
68263
|
+
this._internal_unstable.lists.removeIDFromAllLists(id, layer);
|
|
68264
|
+
this._internal_unstable.storage.delete(id, layer);
|
|
68275
68265
|
}
|
|
68276
68266
|
setConfig(config4) {
|
|
68277
68267
|
this._internal_unstable.setConfig(config4);
|
|
@@ -68303,6 +68293,70 @@ var Cache = class {
|
|
|
68303
68293
|
config() {
|
|
68304
68294
|
return this._internal_unstable.config;
|
|
68305
68295
|
}
|
|
68296
|
+
clearLayer(layerID) {
|
|
68297
|
+
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
68298
|
+
if (!layer) {
|
|
68299
|
+
throw new Error("Cannot find layer with id: " + layerID);
|
|
68300
|
+
}
|
|
68301
|
+
const toNotify = [];
|
|
68302
|
+
const allFields = [];
|
|
68303
|
+
for (const target of [layer.fields, layer.links]) {
|
|
68304
|
+
for (const [id, fields] of Object.entries(target)) {
|
|
68305
|
+
allFields.push(
|
|
68306
|
+
...Object.entries(fields).map(([field, value]) => ({ id, field, value }))
|
|
68307
|
+
);
|
|
68308
|
+
}
|
|
68309
|
+
}
|
|
68310
|
+
const displayFields = [];
|
|
68311
|
+
for (const pair of allFields) {
|
|
68312
|
+
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
68313
|
+
if (!displayLayers.includes(layerID)) {
|
|
68314
|
+
continue;
|
|
68315
|
+
}
|
|
68316
|
+
displayFields.push(pair);
|
|
68317
|
+
}
|
|
68318
|
+
for (const [id, operation] of Object.entries(layer.operations)) {
|
|
68319
|
+
if (operation.deleted) {
|
|
68320
|
+
displayFields.push(
|
|
68321
|
+
...this._internal_unstable.subscriptions.activeFields(id).map((field) => ({ id, field }))
|
|
68322
|
+
);
|
|
68323
|
+
}
|
|
68324
|
+
const fields = Object.keys(operation.fields ?? {});
|
|
68325
|
+
if (fields.length > 0) {
|
|
68326
|
+
displayFields.push(...fields.map((field) => ({ id, field })));
|
|
68327
|
+
}
|
|
68328
|
+
}
|
|
68329
|
+
layer.clear();
|
|
68330
|
+
for (const display of displayFields) {
|
|
68331
|
+
const { field, id } = display;
|
|
68332
|
+
const notify = !("value" in display) || this._internal_unstable.storage.get(id, field).value !== display.value;
|
|
68333
|
+
if (notify) {
|
|
68334
|
+
toNotify.push(
|
|
68335
|
+
...this._internal_unstable.subscriptions.get(id, field).map((sub) => sub[0])
|
|
68336
|
+
);
|
|
68337
|
+
}
|
|
68338
|
+
}
|
|
68339
|
+
this.#notifySubscribers(toNotify);
|
|
68340
|
+
}
|
|
68341
|
+
#notifySubscribers(subs) {
|
|
68342
|
+
if (subs.length === 0) {
|
|
68343
|
+
return;
|
|
68344
|
+
}
|
|
68345
|
+
const notified = [];
|
|
68346
|
+
for (const spec of subs) {
|
|
68347
|
+
if (!notified.includes(spec.set)) {
|
|
68348
|
+
notified.push(spec.set);
|
|
68349
|
+
spec.set(
|
|
68350
|
+
this._internal_unstable.getSelection({
|
|
68351
|
+
parent: spec.parentID || rootID,
|
|
68352
|
+
selection: spec.selection,
|
|
68353
|
+
variables: spec.variables?.() || {},
|
|
68354
|
+
ignoreMasking: false
|
|
68355
|
+
}).data
|
|
68356
|
+
);
|
|
68357
|
+
}
|
|
68358
|
+
}
|
|
68359
|
+
}
|
|
68306
68360
|
};
|
|
68307
68361
|
var CacheInternal = class {
|
|
68308
68362
|
_disabled = false;
|
|
@@ -68590,8 +68644,16 @@ var CacheInternal = class {
|
|
|
68590
68644
|
operation.position || "last",
|
|
68591
68645
|
layer
|
|
68592
68646
|
);
|
|
68647
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
68648
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
68649
|
+
selection: fieldSelection,
|
|
68650
|
+
data: target,
|
|
68651
|
+
variables,
|
|
68652
|
+
where: operation.position || "last",
|
|
68653
|
+
layer
|
|
68654
|
+
});
|
|
68593
68655
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
68594
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
68656
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
|
|
68595
68657
|
} else if (operation.action === "delete" && operation.type) {
|
|
68596
68658
|
if (typeof target !== "string") {
|
|
68597
68659
|
throw new Error("Cannot delete a record with a non-string ID");
|
|
@@ -68600,15 +68662,7 @@ var CacheInternal = class {
|
|
|
68600
68662
|
if (!targetID) {
|
|
68601
68663
|
continue;
|
|
68602
68664
|
}
|
|
68603
|
-
this.cache.delete(targetID);
|
|
68604
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
68605
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
68606
|
-
selection: fieldSelection,
|
|
68607
|
-
data: target,
|
|
68608
|
-
variables,
|
|
68609
|
-
where: operation.position || "last",
|
|
68610
|
-
layer
|
|
68611
|
-
});
|
|
68665
|
+
this.cache.delete(targetID, layer);
|
|
68612
68666
|
}
|
|
68613
68667
|
}
|
|
68614
68668
|
}
|
|
@@ -69143,7 +69197,7 @@ var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
|
69143
69197
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
69144
69198
|
return {
|
|
69145
69199
|
async start(ctx, { next, marshalVariables }) {
|
|
69146
|
-
const
|
|
69200
|
+
const layerOptimistic = cache_default._internal_unstable.storage.createLayer(true);
|
|
69147
69201
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
69148
69202
|
let toNotify = [];
|
|
69149
69203
|
if (optimisticResponse) {
|
|
@@ -69154,25 +69208,29 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
69154
69208
|
data: optimisticResponse
|
|
69155
69209
|
}),
|
|
69156
69210
|
variables: marshalVariables(ctx),
|
|
69157
|
-
layer:
|
|
69211
|
+
layer: layerOptimistic.id
|
|
69158
69212
|
});
|
|
69159
69213
|
}
|
|
69160
69214
|
ctx.cacheParams = {
|
|
69161
69215
|
...ctx.cacheParams,
|
|
69162
|
-
layer,
|
|
69216
|
+
layer: layerOptimistic,
|
|
69163
69217
|
notifySubscribers: toNotify,
|
|
69164
69218
|
forceNotify: true
|
|
69165
69219
|
};
|
|
69166
69220
|
next(ctx);
|
|
69167
69221
|
},
|
|
69168
69222
|
afterNetwork(ctx, { resolve: resolve2 }) {
|
|
69169
|
-
ctx.cacheParams?.layer
|
|
69223
|
+
if (ctx.cacheParams?.layer) {
|
|
69224
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
69225
|
+
}
|
|
69170
69226
|
resolve2(ctx);
|
|
69171
69227
|
},
|
|
69172
69228
|
end(ctx, { resolve: resolve2, value }) {
|
|
69173
69229
|
const hasErrors = value.errors && value.errors.length > 0;
|
|
69174
69230
|
if (hasErrors) {
|
|
69175
|
-
ctx.cacheParams?.layer
|
|
69231
|
+
if (ctx.cacheParams?.layer) {
|
|
69232
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
69233
|
+
}
|
|
69176
69234
|
}
|
|
69177
69235
|
if (ctx.cacheParams?.layer) {
|
|
69178
69236
|
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
@@ -69182,7 +69240,7 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
69182
69240
|
catch(ctx, { error }) {
|
|
69183
69241
|
if (ctx.cacheParams?.layer) {
|
|
69184
69242
|
const { layer } = ctx.cacheParams;
|
|
69185
|
-
layer.
|
|
69243
|
+
cache_default.clearLayer(layer.id);
|
|
69186
69244
|
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
69187
69245
|
}
|
|
69188
69246
|
throw error;
|
|
@@ -71606,7 +71664,7 @@ function operationObject({
|
|
|
71606
71664
|
if (operationKind === "insert" || operationKind === "toggle") {
|
|
71607
71665
|
operation.position = position;
|
|
71608
71666
|
}
|
|
71609
|
-
if (operationKind
|
|
71667
|
+
if (allLists && operationKind !== "delete") {
|
|
71610
71668
|
operation.target = "all";
|
|
71611
71669
|
}
|
|
71612
71670
|
if (parentID) {
|
package/build/vite-esm/index.js
CHANGED
|
@@ -67153,10 +67153,10 @@ var ListManager = class {
|
|
|
67153
67153
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
67154
67154
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
67155
67155
|
}
|
|
67156
|
-
removeIDFromAllLists(id) {
|
|
67156
|
+
removeIDFromAllLists(id, layer) {
|
|
67157
67157
|
for (const fieldMap of this.lists.values()) {
|
|
67158
67158
|
for (const list of fieldMap.values()) {
|
|
67159
|
-
list.removeID(id);
|
|
67159
|
+
list.removeID(id, void 0, layer);
|
|
67160
67160
|
}
|
|
67161
67161
|
}
|
|
67162
67162
|
}
|
|
@@ -67313,7 +67313,7 @@ var List = class {
|
|
|
67313
67313
|
layer: layer?.id
|
|
67314
67314
|
});
|
|
67315
67315
|
}
|
|
67316
|
-
removeID(id, variables = {}) {
|
|
67316
|
+
removeID(id, variables = {}, layer) {
|
|
67317
67317
|
if (!this.validateWhen()) {
|
|
67318
67318
|
return;
|
|
67319
67319
|
}
|
|
@@ -67360,7 +67360,7 @@ var List = class {
|
|
|
67360
67360
|
subscribers.map((sub) => sub[0]),
|
|
67361
67361
|
variables
|
|
67362
67362
|
);
|
|
67363
|
-
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
67363
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
67364
67364
|
for (const [spec] of subscribers) {
|
|
67365
67365
|
spec.set(
|
|
67366
67366
|
this.cache._internal_unstable.getSelection({
|
|
@@ -67373,12 +67373,12 @@ var List = class {
|
|
|
67373
67373
|
}
|
|
67374
67374
|
return true;
|
|
67375
67375
|
}
|
|
67376
|
-
remove(data, variables = {}) {
|
|
67376
|
+
remove(data, variables = {}, layer) {
|
|
67377
67377
|
const targetID = this.cache._internal_unstable.id(this.listType(data), data);
|
|
67378
67378
|
if (!targetID) {
|
|
67379
67379
|
return;
|
|
67380
67380
|
}
|
|
67381
|
-
return this.removeID(targetID, variables);
|
|
67381
|
+
return this.removeID(targetID, variables, layer);
|
|
67382
67382
|
}
|
|
67383
67383
|
listType(data) {
|
|
67384
67384
|
return data.__typename || this.type;
|
|
@@ -67410,7 +67410,7 @@ var List = class {
|
|
|
67410
67410
|
layer,
|
|
67411
67411
|
where
|
|
67412
67412
|
}) {
|
|
67413
|
-
if (!this.remove(data, variables)) {
|
|
67413
|
+
if (!this.remove(data, variables, layer)) {
|
|
67414
67414
|
this.addToList(selection, data, variables, where, layer);
|
|
67415
67415
|
}
|
|
67416
67416
|
}
|
|
@@ -67547,7 +67547,7 @@ var StaleManager = class {
|
|
|
67547
67547
|
// src/runtime/cache/storage.ts
|
|
67548
67548
|
var InMemoryStorage = class {
|
|
67549
67549
|
data;
|
|
67550
|
-
idCount =
|
|
67550
|
+
idCount = 1;
|
|
67551
67551
|
rank = 0;
|
|
67552
67552
|
constructor() {
|
|
67553
67553
|
this.data = [];
|
|
@@ -67567,11 +67567,11 @@ var InMemoryStorage = class {
|
|
|
67567
67567
|
insert(id, field, location, target) {
|
|
67568
67568
|
return this.topLayer.insert(id, field, location, target);
|
|
67569
67569
|
}
|
|
67570
|
-
remove(id, field, target) {
|
|
67571
|
-
return
|
|
67570
|
+
remove(id, field, target, layerToUser = this.topLayer) {
|
|
67571
|
+
return layerToUser.remove(id, field, target);
|
|
67572
67572
|
}
|
|
67573
|
-
delete(id) {
|
|
67574
|
-
return
|
|
67573
|
+
delete(id, layerToUser = this.topLayer) {
|
|
67574
|
+
return layerToUser.delete(id);
|
|
67575
67575
|
}
|
|
67576
67576
|
deleteField(id, field) {
|
|
67577
67577
|
return this.topLayer.deleteField(id, field);
|
|
@@ -67943,6 +67943,9 @@ var InMemorySubscriptions = class {
|
|
|
67943
67943
|
subscribers = {};
|
|
67944
67944
|
referenceCounts = {};
|
|
67945
67945
|
keyVersions = {};
|
|
67946
|
+
activeFields(parent2) {
|
|
67947
|
+
return Object.keys(this.subscribers[parent2] || {});
|
|
67948
|
+
}
|
|
67946
67949
|
add({
|
|
67947
67950
|
parent: parent2,
|
|
67948
67951
|
spec,
|
|
@@ -68211,20 +68214,7 @@ var Cache = class {
|
|
|
68211
68214
|
}) {
|
|
68212
68215
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
68213
68216
|
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
68214
|
-
|
|
68215
|
-
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
68216
|
-
if (!notified.includes(spec.set)) {
|
|
68217
|
-
notified.push(spec.set);
|
|
68218
|
-
spec.set(
|
|
68219
|
-
this._internal_unstable.getSelection({
|
|
68220
|
-
parent: spec.parentID || rootID,
|
|
68221
|
-
selection: spec.selection,
|
|
68222
|
-
variables: spec.variables?.() || {},
|
|
68223
|
-
ignoreMasking: false
|
|
68224
|
-
}).data
|
|
68225
|
-
);
|
|
68226
|
-
}
|
|
68227
|
-
}
|
|
68217
|
+
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
68228
68218
|
return subscribers;
|
|
68229
68219
|
}
|
|
68230
68220
|
read(...args) {
|
|
@@ -68263,10 +68253,10 @@ var Cache = class {
|
|
|
68263
68253
|
}
|
|
68264
68254
|
return handler;
|
|
68265
68255
|
}
|
|
68266
|
-
delete(id) {
|
|
68256
|
+
delete(id, layer) {
|
|
68267
68257
|
this._internal_unstable.subscriptions.removeAllSubscribers(id);
|
|
68268
|
-
this._internal_unstable.lists.removeIDFromAllLists(id);
|
|
68269
|
-
this._internal_unstable.storage.delete(id);
|
|
68258
|
+
this._internal_unstable.lists.removeIDFromAllLists(id, layer);
|
|
68259
|
+
this._internal_unstable.storage.delete(id, layer);
|
|
68270
68260
|
}
|
|
68271
68261
|
setConfig(config4) {
|
|
68272
68262
|
this._internal_unstable.setConfig(config4);
|
|
@@ -68298,6 +68288,70 @@ var Cache = class {
|
|
|
68298
68288
|
config() {
|
|
68299
68289
|
return this._internal_unstable.config;
|
|
68300
68290
|
}
|
|
68291
|
+
clearLayer(layerID) {
|
|
68292
|
+
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
68293
|
+
if (!layer) {
|
|
68294
|
+
throw new Error("Cannot find layer with id: " + layerID);
|
|
68295
|
+
}
|
|
68296
|
+
const toNotify = [];
|
|
68297
|
+
const allFields = [];
|
|
68298
|
+
for (const target of [layer.fields, layer.links]) {
|
|
68299
|
+
for (const [id, fields] of Object.entries(target)) {
|
|
68300
|
+
allFields.push(
|
|
68301
|
+
...Object.entries(fields).map(([field, value]) => ({ id, field, value }))
|
|
68302
|
+
);
|
|
68303
|
+
}
|
|
68304
|
+
}
|
|
68305
|
+
const displayFields = [];
|
|
68306
|
+
for (const pair of allFields) {
|
|
68307
|
+
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
68308
|
+
if (!displayLayers.includes(layerID)) {
|
|
68309
|
+
continue;
|
|
68310
|
+
}
|
|
68311
|
+
displayFields.push(pair);
|
|
68312
|
+
}
|
|
68313
|
+
for (const [id, operation] of Object.entries(layer.operations)) {
|
|
68314
|
+
if (operation.deleted) {
|
|
68315
|
+
displayFields.push(
|
|
68316
|
+
...this._internal_unstable.subscriptions.activeFields(id).map((field) => ({ id, field }))
|
|
68317
|
+
);
|
|
68318
|
+
}
|
|
68319
|
+
const fields = Object.keys(operation.fields ?? {});
|
|
68320
|
+
if (fields.length > 0) {
|
|
68321
|
+
displayFields.push(...fields.map((field) => ({ id, field })));
|
|
68322
|
+
}
|
|
68323
|
+
}
|
|
68324
|
+
layer.clear();
|
|
68325
|
+
for (const display of displayFields) {
|
|
68326
|
+
const { field, id } = display;
|
|
68327
|
+
const notify = !("value" in display) || this._internal_unstable.storage.get(id, field).value !== display.value;
|
|
68328
|
+
if (notify) {
|
|
68329
|
+
toNotify.push(
|
|
68330
|
+
...this._internal_unstable.subscriptions.get(id, field).map((sub) => sub[0])
|
|
68331
|
+
);
|
|
68332
|
+
}
|
|
68333
|
+
}
|
|
68334
|
+
this.#notifySubscribers(toNotify);
|
|
68335
|
+
}
|
|
68336
|
+
#notifySubscribers(subs) {
|
|
68337
|
+
if (subs.length === 0) {
|
|
68338
|
+
return;
|
|
68339
|
+
}
|
|
68340
|
+
const notified = [];
|
|
68341
|
+
for (const spec of subs) {
|
|
68342
|
+
if (!notified.includes(spec.set)) {
|
|
68343
|
+
notified.push(spec.set);
|
|
68344
|
+
spec.set(
|
|
68345
|
+
this._internal_unstable.getSelection({
|
|
68346
|
+
parent: spec.parentID || rootID,
|
|
68347
|
+
selection: spec.selection,
|
|
68348
|
+
variables: spec.variables?.() || {},
|
|
68349
|
+
ignoreMasking: false
|
|
68350
|
+
}).data
|
|
68351
|
+
);
|
|
68352
|
+
}
|
|
68353
|
+
}
|
|
68354
|
+
}
|
|
68301
68355
|
};
|
|
68302
68356
|
var CacheInternal = class {
|
|
68303
68357
|
_disabled = false;
|
|
@@ -68585,8 +68639,16 @@ var CacheInternal = class {
|
|
|
68585
68639
|
operation.position || "last",
|
|
68586
68640
|
layer
|
|
68587
68641
|
);
|
|
68642
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
68643
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
68644
|
+
selection: fieldSelection,
|
|
68645
|
+
data: target,
|
|
68646
|
+
variables,
|
|
68647
|
+
where: operation.position || "last",
|
|
68648
|
+
layer
|
|
68649
|
+
});
|
|
68588
68650
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
68589
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
68651
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
|
|
68590
68652
|
} else if (operation.action === "delete" && operation.type) {
|
|
68591
68653
|
if (typeof target !== "string") {
|
|
68592
68654
|
throw new Error("Cannot delete a record with a non-string ID");
|
|
@@ -68595,15 +68657,7 @@ var CacheInternal = class {
|
|
|
68595
68657
|
if (!targetID) {
|
|
68596
68658
|
continue;
|
|
68597
68659
|
}
|
|
68598
|
-
this.cache.delete(targetID);
|
|
68599
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
68600
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
68601
|
-
selection: fieldSelection,
|
|
68602
|
-
data: target,
|
|
68603
|
-
variables,
|
|
68604
|
-
where: operation.position || "last",
|
|
68605
|
-
layer
|
|
68606
|
-
});
|
|
68660
|
+
this.cache.delete(targetID, layer);
|
|
68607
68661
|
}
|
|
68608
68662
|
}
|
|
68609
68663
|
}
|
|
@@ -69138,7 +69192,7 @@ var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
|
69138
69192
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
69139
69193
|
return {
|
|
69140
69194
|
async start(ctx, { next, marshalVariables }) {
|
|
69141
|
-
const
|
|
69195
|
+
const layerOptimistic = cache_default._internal_unstable.storage.createLayer(true);
|
|
69142
69196
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
69143
69197
|
let toNotify = [];
|
|
69144
69198
|
if (optimisticResponse) {
|
|
@@ -69149,25 +69203,29 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
69149
69203
|
data: optimisticResponse
|
|
69150
69204
|
}),
|
|
69151
69205
|
variables: marshalVariables(ctx),
|
|
69152
|
-
layer:
|
|
69206
|
+
layer: layerOptimistic.id
|
|
69153
69207
|
});
|
|
69154
69208
|
}
|
|
69155
69209
|
ctx.cacheParams = {
|
|
69156
69210
|
...ctx.cacheParams,
|
|
69157
|
-
layer,
|
|
69211
|
+
layer: layerOptimistic,
|
|
69158
69212
|
notifySubscribers: toNotify,
|
|
69159
69213
|
forceNotify: true
|
|
69160
69214
|
};
|
|
69161
69215
|
next(ctx);
|
|
69162
69216
|
},
|
|
69163
69217
|
afterNetwork(ctx, { resolve: resolve2 }) {
|
|
69164
|
-
ctx.cacheParams?.layer
|
|
69218
|
+
if (ctx.cacheParams?.layer) {
|
|
69219
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
69220
|
+
}
|
|
69165
69221
|
resolve2(ctx);
|
|
69166
69222
|
},
|
|
69167
69223
|
end(ctx, { resolve: resolve2, value }) {
|
|
69168
69224
|
const hasErrors = value.errors && value.errors.length > 0;
|
|
69169
69225
|
if (hasErrors) {
|
|
69170
|
-
ctx.cacheParams?.layer
|
|
69226
|
+
if (ctx.cacheParams?.layer) {
|
|
69227
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
69228
|
+
}
|
|
69171
69229
|
}
|
|
69172
69230
|
if (ctx.cacheParams?.layer) {
|
|
69173
69231
|
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
@@ -69177,7 +69235,7 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
69177
69235
|
catch(ctx, { error }) {
|
|
69178
69236
|
if (ctx.cacheParams?.layer) {
|
|
69179
69237
|
const { layer } = ctx.cacheParams;
|
|
69180
|
-
layer.
|
|
69238
|
+
cache_default.clearLayer(layer.id);
|
|
69181
69239
|
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
69182
69240
|
}
|
|
69183
69241
|
throw error;
|
|
@@ -71600,7 +71658,7 @@ function operationObject({
|
|
|
71600
71658
|
if (operationKind === "insert" || operationKind === "toggle") {
|
|
71601
71659
|
operation.position = position;
|
|
71602
71660
|
}
|
|
71603
|
-
if (operationKind
|
|
71661
|
+
if (allLists && operationKind !== "delete") {
|
|
71604
71662
|
operation.target = "all";
|
|
71605
71663
|
}
|
|
71606
71664
|
if (parentID) {
|