houdini 1.1.1 → 1.1.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.
@@ -70326,13 +70326,23 @@ var List = class {
70326
70326
  when(when) {
70327
70327
  return this.manager.lists.get(this.name).get(this.recordID).when(when);
70328
70328
  }
70329
- append(selection, data, variables = {}) {
70330
- return this.addToList(selection, data, variables, "last");
70329
+ append({
70330
+ selection,
70331
+ data,
70332
+ variables = {},
70333
+ layer
70334
+ }) {
70335
+ return this.addToList(selection, data, variables, "last", layer);
70331
70336
  }
70332
- prepend(selection, data, variables = {}) {
70333
- return this.addToList(selection, data, variables, "first");
70337
+ prepend({
70338
+ selection,
70339
+ data,
70340
+ variables = {},
70341
+ layer
70342
+ }) {
70343
+ return this.addToList(selection, data, variables, "first", layer);
70334
70344
  }
70335
- addToList(selection, data, variables = {}, where) {
70345
+ addToList(selection, data, variables = {}, where, layer) {
70336
70346
  const listType = this.listType(data);
70337
70347
  const dataID = this.cache._internal_unstable.id(listType, data);
70338
70348
  if (!this.validateWhen() || !dataID) {
@@ -70410,7 +70420,8 @@ var List = class {
70410
70420
  data: insertData,
70411
70421
  variables,
70412
70422
  parent: this.recordID,
70413
- applyUpdates: [where === "first" ? "prepend" : "append"]
70423
+ applyUpdates: [where === "first" ? "prepend" : "append"],
70424
+ layer: layer?.id
70414
70425
  });
70415
70426
  }
70416
70427
  removeID(id, variables = {}) {
@@ -70503,9 +70514,15 @@ var List = class {
70503
70514
  }
70504
70515
  return ok;
70505
70516
  }
70506
- toggleElement(selection, data, variables = {}, where) {
70517
+ toggleElement({
70518
+ selection,
70519
+ data,
70520
+ variables = {},
70521
+ layer,
70522
+ where
70523
+ }) {
70507
70524
  if (!this.remove(data, variables)) {
70508
- this.addToList(selection, data, variables, where);
70525
+ this.addToList(selection, data, variables, where, layer);
70509
70526
  }
70510
70527
  }
70511
70528
  *[Symbol.iterator]() {
@@ -71513,6 +71530,9 @@ var CacheInternal = class {
71513
71530
  nullable,
71514
71531
  link: !!fieldSelection
71515
71532
  });
71533
+ if (value && typeof value === "object" && "__typename" in value && value["__typename"]) {
71534
+ linkedType = value["__typename"];
71535
+ }
71516
71536
  const currentSubscribers = this.subscriptions.get(parent, key);
71517
71537
  const specs = currentSubscribers.map((sub) => sub[0]);
71518
71538
  const { value: previousValue, displayLayers } = this.storage.get(parent, key);
@@ -71566,7 +71586,6 @@ var CacheInternal = class {
71566
71586
  "Encountered interface type without __typename in the payload"
71567
71587
  );
71568
71588
  }
71569
- linkedType = value.__typename;
71570
71589
  }
71571
71590
  const embedded = this.idFields(linkedType)?.filter(
71572
71591
  (field2) => typeof value[field2] === "undefined"
@@ -71722,7 +71741,8 @@ var CacheInternal = class {
71722
71741
  fieldSelection,
71723
71742
  target,
71724
71743
  variables,
71725
- operation.position || "last"
71744
+ operation.position || "last",
71745
+ layer
71726
71746
  );
71727
71747
  } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
71728
71748
  this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
@@ -71736,12 +71756,13 @@ var CacheInternal = class {
71736
71756
  }
71737
71757
  this.cache.delete(targetID);
71738
71758
  } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
71739
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
71740
- fieldSelection,
71741
- target,
71759
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
71760
+ selection: fieldSelection,
71761
+ data: target,
71742
71762
  variables,
71743
- operation.position || "last"
71744
- );
71763
+ where: operation.position || "last",
71764
+ layer
71765
+ });
71745
71766
  }
71746
71767
  }
71747
71768
  }
@@ -71770,7 +71791,7 @@ var CacheInternal = class {
71770
71791
  ])
71771
71792
  );
71772
71793
  }
71773
- let hasData = false;
71794
+ let hasData = !!selection.fragments;
71774
71795
  let partial = false;
71775
71796
  let cascadeNull = false;
71776
71797
  let stale = false;
@@ -71985,13 +72006,12 @@ var CacheInternal = class {
71985
72006
  const embedded = this.idFields(linkedType)?.filter(
71986
72007
  (field) => typeof entry[field] === "undefined"
71987
72008
  ).length > 0;
71988
- const typename = entryObj.__typename;
71989
72009
  let innerType = linkedType;
71990
- if (abstract) {
71991
- if (!typename) {
71992
- throw new Error("Encountered interface type without __typename in the payload");
71993
- }
72010
+ const typename = entryObj.__typename;
72011
+ if (typename) {
71994
72012
  innerType = typename;
72013
+ } else if (abstract) {
72014
+ throw new Error("Encountered interface type without __typename in the payload");
71995
72015
  }
71996
72016
  if (!embedded) {
71997
72017
  const id = this.id(innerType, entry);
@@ -75849,19 +75869,6 @@ function artifactGenerator(stats) {
75849
75869
  if (docKind === ArtifactKind.Fragment && directive) {
75850
75870
  inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
75851
75871
  }
75852
- const mask = selection_default({
75853
- config: config2,
75854
- filepath: doc.filename,
75855
- rootType,
75856
- operations: {},
75857
- document: doc,
75858
- selections: flattenSelections({
75859
- config: config2,
75860
- filepath: doc.filename,
75861
- selections: selectionSet.selections,
75862
- fragmentDefinitions
75863
- })
75864
- });
75865
75872
  let artifact = {
75866
75873
  name,
75867
75874
  kind: docKind,
@@ -75891,7 +75898,23 @@ function artifactGenerator(stats) {
75891
75898
  }),
75892
75899
  pluginData: {}
75893
75900
  };
75894
- applyMask(config2, artifact.selection, mask);
75901
+ applyMask(
75902
+ config2,
75903
+ artifact.selection,
75904
+ selection_default({
75905
+ config: config2,
75906
+ filepath: doc.filename,
75907
+ rootType,
75908
+ operations: {},
75909
+ document: doc,
75910
+ selections: flattenSelections({
75911
+ config: config2,
75912
+ filepath: doc.filename,
75913
+ selections: selectionSet.selections,
75914
+ fragmentDefinitions
75915
+ })
75916
+ })
75917
+ );
75895
75918
  artifact.pluginData = {};
75896
75919
  for (const plugin2 of config2.plugins) {
75897
75920
  if (!plugin2.artifactData) {
@@ -75969,14 +75992,21 @@ function artifactGenerator(stats) {
75969
75992
  };
75970
75993
  }
75971
75994
  function applyMask(config2, target, mask) {
75995
+ const targetFields = Object.entries(target.fields ?? {}).concat(
75996
+ Object.values(target.abstractFields?.fields ?? {}).flatMap((typeMap) => Object.entries(typeMap))
75997
+ );
75972
75998
  for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
75973
- const targetSelection = target.fields?.[fieldName];
75974
- if (!targetSelection || !mask.fields) {
75975
- continue;
75976
- }
75977
- targetSelection.visible = true;
75978
- if (targetSelection.selection && value.selection) {
75979
- applyMask(config2, targetSelection.selection, value.selection);
75999
+ for (const [potentialFieldName, targetSelection] of targetFields) {
76000
+ if (fieldName !== potentialFieldName) {
76001
+ continue;
76002
+ }
76003
+ if (!targetSelection) {
76004
+ continue;
76005
+ }
76006
+ targetSelection.visible = true;
76007
+ if (targetSelection.selection && value.selection) {
76008
+ applyMask(config2, targetSelection.selection, value.selection);
76009
+ }
75980
76010
  }
75981
76011
  }
75982
76012
  for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
@@ -77587,6 +77617,24 @@ async function addTypename(config2, documents) {
77587
77617
  }
77588
77618
  };
77589
77619
  }
77620
+ },
77621
+ FragmentDefinition(node) {
77622
+ return {
77623
+ ...node,
77624
+ selectionSet: {
77625
+ ...node.selectionSet,
77626
+ selections: [
77627
+ ...node.selectionSet.selections,
77628
+ {
77629
+ kind: graphql23.Kind.FIELD,
77630
+ name: {
77631
+ kind: graphql23.Kind.NAME,
77632
+ value: "__typename"
77633
+ }
77634
+ }
77635
+ ]
77636
+ }
77637
+ };
77590
77638
  }
77591
77639
  });
77592
77640
  }
@@ -79239,8 +79287,8 @@ async function updatePackageJSON(targetPath) {
79239
79287
  }
79240
79288
  packageJSON.devDependencies = {
79241
79289
  ...packageJSON.devDependencies,
79242
- houdini: "^1.1.1",
79243
- "houdini-svelte": "^1.1.1"
79290
+ houdini: "^1.1.3",
79291
+ "houdini-svelte": "^1.1.3"
79244
79292
  };
79245
79293
  await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
79246
79294
  }
@@ -70332,13 +70332,23 @@ var List = class {
70332
70332
  when(when) {
70333
70333
  return this.manager.lists.get(this.name).get(this.recordID).when(when);
70334
70334
  }
70335
- append(selection, data, variables = {}) {
70336
- return this.addToList(selection, data, variables, "last");
70335
+ append({
70336
+ selection,
70337
+ data,
70338
+ variables = {},
70339
+ layer
70340
+ }) {
70341
+ return this.addToList(selection, data, variables, "last", layer);
70337
70342
  }
70338
- prepend(selection, data, variables = {}) {
70339
- return this.addToList(selection, data, variables, "first");
70343
+ prepend({
70344
+ selection,
70345
+ data,
70346
+ variables = {},
70347
+ layer
70348
+ }) {
70349
+ return this.addToList(selection, data, variables, "first", layer);
70340
70350
  }
70341
- addToList(selection, data, variables = {}, where) {
70351
+ addToList(selection, data, variables = {}, where, layer) {
70342
70352
  const listType = this.listType(data);
70343
70353
  const dataID = this.cache._internal_unstable.id(listType, data);
70344
70354
  if (!this.validateWhen() || !dataID) {
@@ -70416,7 +70426,8 @@ var List = class {
70416
70426
  data: insertData,
70417
70427
  variables,
70418
70428
  parent: this.recordID,
70419
- applyUpdates: [where === "first" ? "prepend" : "append"]
70429
+ applyUpdates: [where === "first" ? "prepend" : "append"],
70430
+ layer: layer?.id
70420
70431
  });
70421
70432
  }
70422
70433
  removeID(id, variables = {}) {
@@ -70509,9 +70520,15 @@ var List = class {
70509
70520
  }
70510
70521
  return ok;
70511
70522
  }
70512
- toggleElement(selection, data, variables = {}, where) {
70523
+ toggleElement({
70524
+ selection,
70525
+ data,
70526
+ variables = {},
70527
+ layer,
70528
+ where
70529
+ }) {
70513
70530
  if (!this.remove(data, variables)) {
70514
- this.addToList(selection, data, variables, where);
70531
+ this.addToList(selection, data, variables, where, layer);
70515
70532
  }
70516
70533
  }
70517
70534
  *[Symbol.iterator]() {
@@ -71519,6 +71536,9 @@ var CacheInternal = class {
71519
71536
  nullable,
71520
71537
  link: !!fieldSelection
71521
71538
  });
71539
+ if (value && typeof value === "object" && "__typename" in value && value["__typename"]) {
71540
+ linkedType = value["__typename"];
71541
+ }
71522
71542
  const currentSubscribers = this.subscriptions.get(parent, key);
71523
71543
  const specs = currentSubscribers.map((sub) => sub[0]);
71524
71544
  const { value: previousValue, displayLayers } = this.storage.get(parent, key);
@@ -71572,7 +71592,6 @@ var CacheInternal = class {
71572
71592
  "Encountered interface type without __typename in the payload"
71573
71593
  );
71574
71594
  }
71575
- linkedType = value.__typename;
71576
71595
  }
71577
71596
  const embedded = this.idFields(linkedType)?.filter(
71578
71597
  (field2) => typeof value[field2] === "undefined"
@@ -71728,7 +71747,8 @@ var CacheInternal = class {
71728
71747
  fieldSelection,
71729
71748
  target,
71730
71749
  variables,
71731
- operation.position || "last"
71750
+ operation.position || "last",
71751
+ layer
71732
71752
  );
71733
71753
  } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
71734
71754
  this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
@@ -71742,12 +71762,13 @@ var CacheInternal = class {
71742
71762
  }
71743
71763
  this.cache.delete(targetID);
71744
71764
  } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
71745
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
71746
- fieldSelection,
71747
- target,
71765
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
71766
+ selection: fieldSelection,
71767
+ data: target,
71748
71768
  variables,
71749
- operation.position || "last"
71750
- );
71769
+ where: operation.position || "last",
71770
+ layer
71771
+ });
71751
71772
  }
71752
71773
  }
71753
71774
  }
@@ -71776,7 +71797,7 @@ var CacheInternal = class {
71776
71797
  ])
71777
71798
  );
71778
71799
  }
71779
- let hasData = false;
71800
+ let hasData = !!selection.fragments;
71780
71801
  let partial = false;
71781
71802
  let cascadeNull = false;
71782
71803
  let stale = false;
@@ -71991,13 +72012,12 @@ var CacheInternal = class {
71991
72012
  const embedded = this.idFields(linkedType)?.filter(
71992
72013
  (field) => typeof entry[field] === "undefined"
71993
72014
  ).length > 0;
71994
- const typename = entryObj.__typename;
71995
72015
  let innerType = linkedType;
71996
- if (abstract) {
71997
- if (!typename) {
71998
- throw new Error("Encountered interface type without __typename in the payload");
71999
- }
72016
+ const typename = entryObj.__typename;
72017
+ if (typename) {
72000
72018
  innerType = typename;
72019
+ } else if (abstract) {
72020
+ throw new Error("Encountered interface type without __typename in the payload");
72001
72021
  }
72002
72022
  if (!embedded) {
72003
72023
  const id = this.id(innerType, entry);
@@ -75854,19 +75874,6 @@ function artifactGenerator(stats) {
75854
75874
  if (docKind === ArtifactKind.Fragment && directive) {
75855
75875
  inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
75856
75876
  }
75857
- const mask = selection_default({
75858
- config: config2,
75859
- filepath: doc.filename,
75860
- rootType,
75861
- operations: {},
75862
- document: doc,
75863
- selections: flattenSelections({
75864
- config: config2,
75865
- filepath: doc.filename,
75866
- selections: selectionSet.selections,
75867
- fragmentDefinitions
75868
- })
75869
- });
75870
75877
  let artifact = {
75871
75878
  name,
75872
75879
  kind: docKind,
@@ -75896,7 +75903,23 @@ function artifactGenerator(stats) {
75896
75903
  }),
75897
75904
  pluginData: {}
75898
75905
  };
75899
- applyMask(config2, artifact.selection, mask);
75906
+ applyMask(
75907
+ config2,
75908
+ artifact.selection,
75909
+ selection_default({
75910
+ config: config2,
75911
+ filepath: doc.filename,
75912
+ rootType,
75913
+ operations: {},
75914
+ document: doc,
75915
+ selections: flattenSelections({
75916
+ config: config2,
75917
+ filepath: doc.filename,
75918
+ selections: selectionSet.selections,
75919
+ fragmentDefinitions
75920
+ })
75921
+ })
75922
+ );
75900
75923
  artifact.pluginData = {};
75901
75924
  for (const plugin2 of config2.plugins) {
75902
75925
  if (!plugin2.artifactData) {
@@ -75974,14 +75997,21 @@ function artifactGenerator(stats) {
75974
75997
  };
75975
75998
  }
75976
75999
  function applyMask(config2, target, mask) {
76000
+ const targetFields = Object.entries(target.fields ?? {}).concat(
76001
+ Object.values(target.abstractFields?.fields ?? {}).flatMap((typeMap) => Object.entries(typeMap))
76002
+ );
75977
76003
  for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
75978
- const targetSelection = target.fields?.[fieldName];
75979
- if (!targetSelection || !mask.fields) {
75980
- continue;
75981
- }
75982
- targetSelection.visible = true;
75983
- if (targetSelection.selection && value.selection) {
75984
- applyMask(config2, targetSelection.selection, value.selection);
76004
+ for (const [potentialFieldName, targetSelection] of targetFields) {
76005
+ if (fieldName !== potentialFieldName) {
76006
+ continue;
76007
+ }
76008
+ if (!targetSelection) {
76009
+ continue;
76010
+ }
76011
+ targetSelection.visible = true;
76012
+ if (targetSelection.selection && value.selection) {
76013
+ applyMask(config2, targetSelection.selection, value.selection);
76014
+ }
75985
76015
  }
75986
76016
  }
75987
76017
  for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
@@ -77592,6 +77622,24 @@ async function addTypename(config2, documents) {
77592
77622
  }
77593
77623
  };
77594
77624
  }
77625
+ },
77626
+ FragmentDefinition(node) {
77627
+ return {
77628
+ ...node,
77629
+ selectionSet: {
77630
+ ...node.selectionSet,
77631
+ selections: [
77632
+ ...node.selectionSet.selections,
77633
+ {
77634
+ kind: graphql23.Kind.FIELD,
77635
+ name: {
77636
+ kind: graphql23.Kind.NAME,
77637
+ value: "__typename"
77638
+ }
77639
+ }
77640
+ ]
77641
+ }
77642
+ };
77595
77643
  }
77596
77644
  });
77597
77645
  }
@@ -79244,8 +79292,8 @@ async function updatePackageJSON(targetPath) {
79244
79292
  }
79245
79293
  packageJSON.devDependencies = {
79246
79294
  ...packageJSON.devDependencies,
79247
- houdini: "^1.1.1",
79248
- "houdini-svelte": "^1.1.1"
79295
+ houdini: "^1.1.3",
79296
+ "houdini-svelte": "^1.1.3"
79249
79297
  };
79250
79298
  await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
79251
79299
  }