houdini 1.5.6 → 1.5.8

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.
@@ -70812,20 +70812,21 @@ var CacheInternal = class {
70812
70812
  }
70813
70813
  } else if (Array.isArray(value) && (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
70814
70814
  let oldIDs = [...previousValue || []];
70815
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
70816
- if (!id) {
70817
- return "";
70818
- }
70819
- const { value: cursorField } = this.storage.get(id, "cursor");
70820
- if (cursorField) {
70821
- return "";
70822
- }
70823
- const { value: node } = this.storage.get(id, "node");
70824
- if (!node) {
70825
- return "";
70826
- }
70827
- return node;
70828
- });
70815
+ if (updates?.includes("append") || updates?.includes("prepend")) {
70816
+ oldIDs = oldIDs.filter((id) => {
70817
+ for (const layer2 of this.storage.data) {
70818
+ for (const operation of Object.values(layer2.operations)) {
70819
+ if (operation.fields?.[key])
70820
+ for (const listOperation of operation.fields[key]) {
70821
+ if ("id" in listOperation && listOperation.id === id) {
70822
+ return false;
70823
+ }
70824
+ }
70825
+ }
70826
+ }
70827
+ return true;
70828
+ });
70829
+ }
70829
70830
  let linkedIDs = [];
70830
70831
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
70831
70832
  value,
@@ -70844,39 +70845,45 @@ var CacheInternal = class {
70844
70845
  layer.writeLink(parent2, key, linkedIDs);
70845
70846
  };
70846
70847
  if (applyUpdates && updates) {
70847
- if (key === "edges") {
70848
- const newNodeIDs = [];
70849
- for (const id of newIDs) {
70848
+ const filterIDs = (keep, insert) => {
70849
+ const existingIDs = /* @__PURE__ */ new Set();
70850
+ for (const id of keep) {
70850
70851
  if (!id) {
70851
70852
  continue;
70852
70853
  }
70853
70854
  const { value: node } = this.storage.get(id, "node");
70854
- if (typeof node !== "string") {
70855
+ if (!node) {
70855
70856
  continue;
70856
70857
  }
70857
- if (!node || !this.storage.get(node, "__typename")) {
70858
+ const nodeID = this.storage.get(node, "id");
70859
+ if (!nodeID) {
70858
70860
  continue;
70859
70861
  }
70860
- newNodeIDs.push(node);
70862
+ existingIDs.add(nodeID.value);
70861
70863
  }
70862
- oldIDs = oldIDs.filter((id) => {
70864
+ return insert.filter((id) => {
70863
70865
  if (!id) {
70864
70866
  return true;
70865
70867
  }
70866
- const { value: value2 } = this.storage.get(id, "node");
70867
- const node = value2;
70868
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
70869
- return false;
70868
+ const { value: node } = this.storage.get(id, "node");
70869
+ if (!node) {
70870
+ return true;
70870
70871
  }
70871
- return true;
70872
+ const nodeID = this.storage.get(node, "id");
70873
+ if (!nodeID) {
70874
+ return true;
70875
+ }
70876
+ return !existingIDs.has(nodeID.value);
70872
70877
  });
70873
- }
70878
+ };
70874
70879
  for (const update of applyUpdates) {
70875
70880
  if (update !== "replace" && !updates.includes(update)) {
70876
70881
  continue;
70877
70882
  }
70878
70883
  if (update === "prepend") {
70879
- linkedIDs = newIDs.concat(oldIDs);
70884
+ linkedIDs = newIDs.concat(
70885
+ filterIDs(newIDs, oldIDs)
70886
+ );
70880
70887
  if (layer?.optimistic) {
70881
70888
  action = () => {
70882
70889
  for (const id of newIDs) {
@@ -70887,7 +70894,7 @@ var CacheInternal = class {
70887
70894
  };
70888
70895
  }
70889
70896
  } else if (update === "append") {
70890
- linkedIDs = oldIDs.concat(newIDs);
70897
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
70891
70898
  if (layer?.optimistic) {
70892
70899
  action = () => {
70893
70900
  for (const id of newIDs) {
@@ -82355,12 +82362,13 @@ async function packageJSON(targetPath, frameworkInfo) {
82355
82362
  }
82356
82363
  packageJSON2.devDependencies = {
82357
82364
  ...packageJSON2.devDependencies,
82358
- houdini: "^1.5.6"
82365
+ houdini: "^1.5.8",
82366
+ "@sveltejs/kit": "<=2.21.0"
82359
82367
  };
82360
82368
  if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
82361
82369
  packageJSON2.devDependencies = {
82362
82370
  ...packageJSON2.devDependencies,
82363
- "houdini-svelte": "^2.1.16"
82371
+ "houdini-svelte": "^2.1.18"
82364
82372
  };
82365
82373
  } else {
82366
82374
  throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);
@@ -70818,20 +70818,21 @@ var CacheInternal = class {
70818
70818
  }
70819
70819
  } else if (Array.isArray(value) && (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
70820
70820
  let oldIDs = [...previousValue || []];
70821
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
70822
- if (!id) {
70823
- return "";
70824
- }
70825
- const { value: cursorField } = this.storage.get(id, "cursor");
70826
- if (cursorField) {
70827
- return "";
70828
- }
70829
- const { value: node } = this.storage.get(id, "node");
70830
- if (!node) {
70831
- return "";
70832
- }
70833
- return node;
70834
- });
70821
+ if (updates?.includes("append") || updates?.includes("prepend")) {
70822
+ oldIDs = oldIDs.filter((id) => {
70823
+ for (const layer2 of this.storage.data) {
70824
+ for (const operation of Object.values(layer2.operations)) {
70825
+ if (operation.fields?.[key])
70826
+ for (const listOperation of operation.fields[key]) {
70827
+ if ("id" in listOperation && listOperation.id === id) {
70828
+ return false;
70829
+ }
70830
+ }
70831
+ }
70832
+ }
70833
+ return true;
70834
+ });
70835
+ }
70835
70836
  let linkedIDs = [];
70836
70837
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
70837
70838
  value,
@@ -70850,39 +70851,45 @@ var CacheInternal = class {
70850
70851
  layer.writeLink(parent2, key, linkedIDs);
70851
70852
  };
70852
70853
  if (applyUpdates && updates) {
70853
- if (key === "edges") {
70854
- const newNodeIDs = [];
70855
- for (const id of newIDs) {
70854
+ const filterIDs = (keep, insert) => {
70855
+ const existingIDs = /* @__PURE__ */ new Set();
70856
+ for (const id of keep) {
70856
70857
  if (!id) {
70857
70858
  continue;
70858
70859
  }
70859
70860
  const { value: node } = this.storage.get(id, "node");
70860
- if (typeof node !== "string") {
70861
+ if (!node) {
70861
70862
  continue;
70862
70863
  }
70863
- if (!node || !this.storage.get(node, "__typename")) {
70864
+ const nodeID = this.storage.get(node, "id");
70865
+ if (!nodeID) {
70864
70866
  continue;
70865
70867
  }
70866
- newNodeIDs.push(node);
70868
+ existingIDs.add(nodeID.value);
70867
70869
  }
70868
- oldIDs = oldIDs.filter((id) => {
70870
+ return insert.filter((id) => {
70869
70871
  if (!id) {
70870
70872
  return true;
70871
70873
  }
70872
- const { value: value2 } = this.storage.get(id, "node");
70873
- const node = value2;
70874
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
70875
- return false;
70874
+ const { value: node } = this.storage.get(id, "node");
70875
+ if (!node) {
70876
+ return true;
70876
70877
  }
70877
- return true;
70878
+ const nodeID = this.storage.get(node, "id");
70879
+ if (!nodeID) {
70880
+ return true;
70881
+ }
70882
+ return !existingIDs.has(nodeID.value);
70878
70883
  });
70879
- }
70884
+ };
70880
70885
  for (const update of applyUpdates) {
70881
70886
  if (update !== "replace" && !updates.includes(update)) {
70882
70887
  continue;
70883
70888
  }
70884
70889
  if (update === "prepend") {
70885
- linkedIDs = newIDs.concat(oldIDs);
70890
+ linkedIDs = newIDs.concat(
70891
+ filterIDs(newIDs, oldIDs)
70892
+ );
70886
70893
  if (layer?.optimistic) {
70887
70894
  action = () => {
70888
70895
  for (const id of newIDs) {
@@ -70893,7 +70900,7 @@ var CacheInternal = class {
70893
70900
  };
70894
70901
  }
70895
70902
  } else if (update === "append") {
70896
- linkedIDs = oldIDs.concat(newIDs);
70903
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
70897
70904
  if (layer?.optimistic) {
70898
70905
  action = () => {
70899
70906
  for (const id of newIDs) {
@@ -82360,12 +82367,13 @@ async function packageJSON(targetPath, frameworkInfo) {
82360
82367
  }
82361
82368
  packageJSON2.devDependencies = {
82362
82369
  ...packageJSON2.devDependencies,
82363
- houdini: "^1.5.6"
82370
+ houdini: "^1.5.8",
82371
+ "@sveltejs/kit": "<=2.21.0"
82364
82372
  };
82365
82373
  if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
82366
82374
  packageJSON2.devDependencies = {
82367
82375
  ...packageJSON2.devDependencies,
82368
- "houdini-svelte": "^2.1.16"
82376
+ "houdini-svelte": "^2.1.18"
82369
82377
  };
82370
82378
  } else {
82371
82379
  throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);
@@ -60139,20 +60139,21 @@ var CacheInternal = class {
60139
60139
  }
60140
60140
  } else if (Array.isArray(value) && (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
60141
60141
  let oldIDs = [...previousValue || []];
60142
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
60143
- if (!id) {
60144
- return "";
60145
- }
60146
- const { value: cursorField } = this.storage.get(id, "cursor");
60147
- if (cursorField) {
60148
- return "";
60149
- }
60150
- const { value: node } = this.storage.get(id, "node");
60151
- if (!node) {
60152
- return "";
60153
- }
60154
- return node;
60155
- });
60142
+ if (updates?.includes("append") || updates?.includes("prepend")) {
60143
+ oldIDs = oldIDs.filter((id) => {
60144
+ for (const layer2 of this.storage.data) {
60145
+ for (const operation of Object.values(layer2.operations)) {
60146
+ if (operation.fields?.[key])
60147
+ for (const listOperation of operation.fields[key]) {
60148
+ if ("id" in listOperation && listOperation.id === id) {
60149
+ return false;
60150
+ }
60151
+ }
60152
+ }
60153
+ }
60154
+ return true;
60155
+ });
60156
+ }
60156
60157
  let linkedIDs = [];
60157
60158
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
60158
60159
  value,
@@ -60171,39 +60172,45 @@ var CacheInternal = class {
60171
60172
  layer.writeLink(parent2, key, linkedIDs);
60172
60173
  };
60173
60174
  if (applyUpdates && updates) {
60174
- if (key === "edges") {
60175
- const newNodeIDs = [];
60176
- for (const id of newIDs) {
60175
+ const filterIDs = (keep, insert) => {
60176
+ const existingIDs = /* @__PURE__ */ new Set();
60177
+ for (const id of keep) {
60177
60178
  if (!id) {
60178
60179
  continue;
60179
60180
  }
60180
60181
  const { value: node } = this.storage.get(id, "node");
60181
- if (typeof node !== "string") {
60182
+ if (!node) {
60182
60183
  continue;
60183
60184
  }
60184
- if (!node || !this.storage.get(node, "__typename")) {
60185
+ const nodeID = this.storage.get(node, "id");
60186
+ if (!nodeID) {
60185
60187
  continue;
60186
60188
  }
60187
- newNodeIDs.push(node);
60189
+ existingIDs.add(nodeID.value);
60188
60190
  }
60189
- oldIDs = oldIDs.filter((id) => {
60191
+ return insert.filter((id) => {
60190
60192
  if (!id) {
60191
60193
  return true;
60192
60194
  }
60193
- const { value: value2 } = this.storage.get(id, "node");
60194
- const node = value2;
60195
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
60196
- return false;
60195
+ const { value: node } = this.storage.get(id, "node");
60196
+ if (!node) {
60197
+ return true;
60197
60198
  }
60198
- return true;
60199
+ const nodeID = this.storage.get(node, "id");
60200
+ if (!nodeID) {
60201
+ return true;
60202
+ }
60203
+ return !existingIDs.has(nodeID.value);
60199
60204
  });
60200
- }
60205
+ };
60201
60206
  for (const update of applyUpdates) {
60202
60207
  if (update !== "replace" && !updates.includes(update)) {
60203
60208
  continue;
60204
60209
  }
60205
60210
  if (update === "prepend") {
60206
- linkedIDs = newIDs.concat(oldIDs);
60211
+ linkedIDs = newIDs.concat(
60212
+ filterIDs(newIDs, oldIDs)
60213
+ );
60207
60214
  if (layer?.optimistic) {
60208
60215
  action = () => {
60209
60216
  for (const id of newIDs) {
@@ -60214,7 +60221,7 @@ var CacheInternal = class {
60214
60221
  };
60215
60222
  }
60216
60223
  } else if (update === "append") {
60217
- linkedIDs = oldIDs.concat(newIDs);
60224
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
60218
60225
  if (layer?.optimistic) {
60219
60226
  action = () => {
60220
60227
  for (const id of newIDs) {
@@ -60139,20 +60139,21 @@ var CacheInternal = class {
60139
60139
  }
60140
60140
  } else if (Array.isArray(value) && (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
60141
60141
  let oldIDs = [...previousValue || []];
60142
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
60143
- if (!id) {
60144
- return "";
60145
- }
60146
- const { value: cursorField } = this.storage.get(id, "cursor");
60147
- if (cursorField) {
60148
- return "";
60149
- }
60150
- const { value: node } = this.storage.get(id, "node");
60151
- if (!node) {
60152
- return "";
60153
- }
60154
- return node;
60155
- });
60142
+ if (updates?.includes("append") || updates?.includes("prepend")) {
60143
+ oldIDs = oldIDs.filter((id) => {
60144
+ for (const layer2 of this.storage.data) {
60145
+ for (const operation of Object.values(layer2.operations)) {
60146
+ if (operation.fields?.[key])
60147
+ for (const listOperation of operation.fields[key]) {
60148
+ if ("id" in listOperation && listOperation.id === id) {
60149
+ return false;
60150
+ }
60151
+ }
60152
+ }
60153
+ }
60154
+ return true;
60155
+ });
60156
+ }
60156
60157
  let linkedIDs = [];
60157
60158
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
60158
60159
  value,
@@ -60171,39 +60172,45 @@ var CacheInternal = class {
60171
60172
  layer.writeLink(parent2, key, linkedIDs);
60172
60173
  };
60173
60174
  if (applyUpdates && updates) {
60174
- if (key === "edges") {
60175
- const newNodeIDs = [];
60176
- for (const id of newIDs) {
60175
+ const filterIDs = (keep, insert) => {
60176
+ const existingIDs = /* @__PURE__ */ new Set();
60177
+ for (const id of keep) {
60177
60178
  if (!id) {
60178
60179
  continue;
60179
60180
  }
60180
60181
  const { value: node } = this.storage.get(id, "node");
60181
- if (typeof node !== "string") {
60182
+ if (!node) {
60182
60183
  continue;
60183
60184
  }
60184
- if (!node || !this.storage.get(node, "__typename")) {
60185
+ const nodeID = this.storage.get(node, "id");
60186
+ if (!nodeID) {
60185
60187
  continue;
60186
60188
  }
60187
- newNodeIDs.push(node);
60189
+ existingIDs.add(nodeID.value);
60188
60190
  }
60189
- oldIDs = oldIDs.filter((id) => {
60191
+ return insert.filter((id) => {
60190
60192
  if (!id) {
60191
60193
  return true;
60192
60194
  }
60193
- const { value: value2 } = this.storage.get(id, "node");
60194
- const node = value2;
60195
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
60196
- return false;
60195
+ const { value: node } = this.storage.get(id, "node");
60196
+ if (!node) {
60197
+ return true;
60197
60198
  }
60198
- return true;
60199
+ const nodeID = this.storage.get(node, "id");
60200
+ if (!nodeID) {
60201
+ return true;
60202
+ }
60203
+ return !existingIDs.has(nodeID.value);
60199
60204
  });
60200
- }
60205
+ };
60201
60206
  for (const update of applyUpdates) {
60202
60207
  if (update !== "replace" && !updates.includes(update)) {
60203
60208
  continue;
60204
60209
  }
60205
60210
  if (update === "prepend") {
60206
- linkedIDs = newIDs.concat(oldIDs);
60211
+ linkedIDs = newIDs.concat(
60212
+ filterIDs(newIDs, oldIDs)
60213
+ );
60207
60214
  if (layer?.optimistic) {
60208
60215
  action = () => {
60209
60216
  for (const id of newIDs) {
@@ -60214,7 +60221,7 @@ var CacheInternal = class {
60214
60221
  };
60215
60222
  }
60216
60223
  } else if (update === "append") {
60217
- linkedIDs = oldIDs.concat(newIDs);
60224
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
60218
60225
  if (layer?.optimistic) {
60219
60226
  action = () => {
60220
60227
  for (const id of newIDs) {
@@ -69759,20 +69759,21 @@ var CacheInternal = class {
69759
69759
  }
69760
69760
  } else if (Array.isArray(value) && (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
69761
69761
  let oldIDs = [...previousValue || []];
69762
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
69763
- if (!id) {
69764
- return "";
69765
- }
69766
- const { value: cursorField } = this.storage.get(id, "cursor");
69767
- if (cursorField) {
69768
- return "";
69769
- }
69770
- const { value: node } = this.storage.get(id, "node");
69771
- if (!node) {
69772
- return "";
69773
- }
69774
- return node;
69775
- });
69762
+ if (updates?.includes("append") || updates?.includes("prepend")) {
69763
+ oldIDs = oldIDs.filter((id) => {
69764
+ for (const layer2 of this.storage.data) {
69765
+ for (const operation of Object.values(layer2.operations)) {
69766
+ if (operation.fields?.[key])
69767
+ for (const listOperation of operation.fields[key]) {
69768
+ if ("id" in listOperation && listOperation.id === id) {
69769
+ return false;
69770
+ }
69771
+ }
69772
+ }
69773
+ }
69774
+ return true;
69775
+ });
69776
+ }
69776
69777
  let linkedIDs = [];
69777
69778
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
69778
69779
  value,
@@ -69791,39 +69792,45 @@ var CacheInternal = class {
69791
69792
  layer.writeLink(parent, key, linkedIDs);
69792
69793
  };
69793
69794
  if (applyUpdates && updates) {
69794
- if (key === "edges") {
69795
- const newNodeIDs = [];
69796
- for (const id of newIDs) {
69795
+ const filterIDs = (keep, insert) => {
69796
+ const existingIDs = /* @__PURE__ */ new Set();
69797
+ for (const id of keep) {
69797
69798
  if (!id) {
69798
69799
  continue;
69799
69800
  }
69800
69801
  const { value: node } = this.storage.get(id, "node");
69801
- if (typeof node !== "string") {
69802
+ if (!node) {
69802
69803
  continue;
69803
69804
  }
69804
- if (!node || !this.storage.get(node, "__typename")) {
69805
+ const nodeID = this.storage.get(node, "id");
69806
+ if (!nodeID) {
69805
69807
  continue;
69806
69808
  }
69807
- newNodeIDs.push(node);
69809
+ existingIDs.add(nodeID.value);
69808
69810
  }
69809
- oldIDs = oldIDs.filter((id) => {
69811
+ return insert.filter((id) => {
69810
69812
  if (!id) {
69811
69813
  return true;
69812
69814
  }
69813
- const { value: value2 } = this.storage.get(id, "node");
69814
- const node = value2;
69815
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
69816
- return false;
69815
+ const { value: node } = this.storage.get(id, "node");
69816
+ if (!node) {
69817
+ return true;
69817
69818
  }
69818
- return true;
69819
+ const nodeID = this.storage.get(node, "id");
69820
+ if (!nodeID) {
69821
+ return true;
69822
+ }
69823
+ return !existingIDs.has(nodeID.value);
69819
69824
  });
69820
- }
69825
+ };
69821
69826
  for (const update of applyUpdates) {
69822
69827
  if (update !== "replace" && !updates.includes(update)) {
69823
69828
  continue;
69824
69829
  }
69825
69830
  if (update === "prepend") {
69826
- linkedIDs = newIDs.concat(oldIDs);
69831
+ linkedIDs = newIDs.concat(
69832
+ filterIDs(newIDs, oldIDs)
69833
+ );
69827
69834
  if (layer?.optimistic) {
69828
69835
  action = () => {
69829
69836
  for (const id of newIDs) {
@@ -69834,7 +69841,7 @@ var CacheInternal = class {
69834
69841
  };
69835
69842
  }
69836
69843
  } else if (update === "append") {
69837
- linkedIDs = oldIDs.concat(newIDs);
69844
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
69838
69845
  if (layer?.optimistic) {
69839
69846
  action = () => {
69840
69847
  for (const id of newIDs) {