houdini 1.0.0-next.8 → 1.0.0

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.
Files changed (92) hide show
  1. package/README.md +4 -1
  2. package/build/cmd-cjs/index.js +2325 -121
  3. package/build/cmd-esm/index.js +2325 -121
  4. package/build/codegen/generators/runtime/runtimeConfig.d.ts +7 -0
  5. package/build/codegen/generators/typescript/typeReference.d.ts +4 -2
  6. package/build/codegen/generators/typescript/types.d.ts +0 -1
  7. package/build/codegen/utils/flattenSelections.d.ts +1 -1
  8. package/build/codegen-cjs/index.js +2919 -689
  9. package/build/codegen-esm/index.js +2919 -689
  10. package/build/lib/config.d.ts +4 -6
  11. package/build/lib/types.d.ts +18 -15
  12. package/build/lib-cjs/index.js +3159 -171
  13. package/build/lib-esm/index.js +3152 -171
  14. package/build/runtime/cache/storage.d.ts +18 -15
  15. package/build/runtime/client/documentStore.d.ts +15 -13
  16. package/build/runtime/client/index.d.ts +1 -1
  17. package/build/runtime/client/plugins/cache.d.ts +1 -1
  18. package/build/runtime/client/plugins/fetch.d.ts +1 -1
  19. package/build/runtime/client/plugins/fetchParams.d.ts +1 -1
  20. package/build/runtime/client/plugins/mutation.d.ts +1 -1
  21. package/build/runtime/client/plugins/query.d.ts +1 -1
  22. package/build/runtime/client/plugins/subscription.d.ts +1 -1
  23. package/build/runtime/client/plugins/throwOnError.d.ts +1 -1
  24. package/build/runtime/client/utils/documentPlugins.d.ts +2 -2
  25. package/build/runtime/imports/pluginConfig.d.ts +3 -0
  26. package/build/runtime/lib/config.d.ts +2 -2
  27. package/build/runtime/lib/scalars.d.ts +1 -1
  28. package/build/runtime/lib/types.d.ts +42 -42
  29. package/build/runtime-cjs/cache/storage.d.ts +18 -15
  30. package/build/runtime-cjs/cache/storage.js +9 -11
  31. package/build/runtime-cjs/client/documentStore.d.ts +15 -13
  32. package/build/runtime-cjs/client/documentStore.js +11 -8
  33. package/build/runtime-cjs/client/index.d.ts +1 -1
  34. package/build/runtime-cjs/client/index.js +16 -13
  35. package/build/runtime-cjs/client/plugins/cache.d.ts +1 -1
  36. package/build/runtime-cjs/client/plugins/cache.js +6 -6
  37. package/build/runtime-cjs/client/plugins/fetch.d.ts +1 -1
  38. package/build/runtime-cjs/client/plugins/fetch.js +9 -9
  39. package/build/runtime-cjs/client/plugins/fetchParams.d.ts +1 -1
  40. package/build/runtime-cjs/client/plugins/fetchParams.js +3 -3
  41. package/build/runtime-cjs/client/plugins/mutation.d.ts +1 -1
  42. package/build/runtime-cjs/client/plugins/mutation.js +3 -3
  43. package/build/runtime-cjs/client/plugins/query.d.ts +1 -1
  44. package/build/runtime-cjs/client/plugins/query.js +4 -4
  45. package/build/runtime-cjs/client/plugins/subscription.d.ts +1 -1
  46. package/build/runtime-cjs/client/plugins/subscription.js +5 -5
  47. package/build/runtime-cjs/client/plugins/throwOnError.d.ts +1 -1
  48. package/build/runtime-cjs/client/plugins/throwOnError.js +3 -3
  49. package/build/runtime-cjs/client/utils/documentPlugins.d.ts +2 -2
  50. package/build/runtime-cjs/imports/pluginConfig.d.ts +3 -0
  51. package/build/runtime-cjs/imports/pluginConfig.js +27 -0
  52. package/build/runtime-cjs/lib/config.d.ts +2 -2
  53. package/build/runtime-cjs/lib/config.js +11 -1
  54. package/build/runtime-cjs/lib/scalars.d.ts +1 -1
  55. package/build/runtime-cjs/lib/scalars.js +13 -2
  56. package/build/runtime-cjs/lib/types.d.ts +42 -42
  57. package/build/runtime-cjs/lib/types.js +26 -30
  58. package/build/runtime-esm/cache/storage.d.ts +18 -15
  59. package/build/runtime-esm/cache/storage.js +9 -11
  60. package/build/runtime-esm/client/documentStore.d.ts +15 -13
  61. package/build/runtime-esm/client/documentStore.js +12 -9
  62. package/build/runtime-esm/client/index.d.ts +1 -1
  63. package/build/runtime-esm/client/index.js +13 -10
  64. package/build/runtime-esm/client/plugins/cache.d.ts +1 -1
  65. package/build/runtime-esm/client/plugins/cache.js +5 -5
  66. package/build/runtime-esm/client/plugins/fetch.d.ts +1 -1
  67. package/build/runtime-esm/client/plugins/fetch.js +8 -8
  68. package/build/runtime-esm/client/plugins/fetchParams.d.ts +1 -1
  69. package/build/runtime-esm/client/plugins/fetchParams.js +2 -2
  70. package/build/runtime-esm/client/plugins/mutation.d.ts +1 -1
  71. package/build/runtime-esm/client/plugins/mutation.js +2 -2
  72. package/build/runtime-esm/client/plugins/query.d.ts +1 -1
  73. package/build/runtime-esm/client/plugins/query.js +3 -3
  74. package/build/runtime-esm/client/plugins/subscription.d.ts +1 -1
  75. package/build/runtime-esm/client/plugins/subscription.js +4 -4
  76. package/build/runtime-esm/client/plugins/throwOnError.d.ts +1 -1
  77. package/build/runtime-esm/client/plugins/throwOnError.js +2 -2
  78. package/build/runtime-esm/client/utils/documentPlugins.d.ts +2 -2
  79. package/build/runtime-esm/imports/pluginConfig.d.ts +3 -0
  80. package/build/runtime-esm/imports/pluginConfig.js +5 -0
  81. package/build/runtime-esm/lib/config.d.ts +2 -2
  82. package/build/runtime-esm/lib/config.js +11 -1
  83. package/build/runtime-esm/lib/scalars.d.ts +1 -1
  84. package/build/runtime-esm/lib/scalars.js +13 -2
  85. package/build/runtime-esm/lib/types.d.ts +42 -42
  86. package/build/runtime-esm/lib/types.js +26 -30
  87. package/build/test-cjs/index.js +2302 -98
  88. package/build/test-esm/index.js +2302 -98
  89. package/build/vite/houdini.d.ts +2 -0
  90. package/build/vite-cjs/index.js +2328 -122
  91. package/build/vite-esm/index.js +2328 -122
  92. package/package.json +2 -2
@@ -7500,7 +7500,7 @@ var require_definition = __commonJS({
7500
7500
  exports.assertInterfaceType = assertInterfaceType;
7501
7501
  exports.isUnionType = isUnionType13;
7502
7502
  exports.assertUnionType = assertUnionType;
7503
- exports.isEnumType = isEnumType10;
7503
+ exports.isEnumType = isEnumType11;
7504
7504
  exports.assertEnumType = assertEnumType;
7505
7505
  exports.isInputObjectType = isInputObjectType8;
7506
7506
  exports.assertInputObjectType = assertInputObjectType;
@@ -7571,7 +7571,7 @@ var require_definition = __commonJS({
7571
7571
  return Constructor;
7572
7572
  }
7573
7573
  function isType(type) {
7574
- return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType10(type) || isInputObjectType8(type) || isListType8(type) || isNonNullType10(type);
7574
+ return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType11(type) || isInputObjectType8(type) || isListType8(type) || isNonNullType10(type);
7575
7575
  }
7576
7576
  function assertType(type) {
7577
7577
  if (!isType(type)) {
@@ -7615,11 +7615,11 @@ var require_definition = __commonJS({
7615
7615
  }
7616
7616
  return type;
7617
7617
  }
7618
- function isEnumType10(type) {
7618
+ function isEnumType11(type) {
7619
7619
  return (0, _instanceOf.default)(type, GraphQLEnumType4);
7620
7620
  }
7621
7621
  function assertEnumType(type) {
7622
- if (!isEnumType10(type)) {
7622
+ if (!isEnumType11(type)) {
7623
7623
  throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Enum type."));
7624
7624
  }
7625
7625
  return type;
@@ -7652,7 +7652,7 @@ var require_definition = __commonJS({
7652
7652
  return type;
7653
7653
  }
7654
7654
  function isInputType(type) {
7655
- return isScalarType13(type) || isEnumType10(type) || isInputObjectType8(type) || isWrappingType(type) && isInputType(type.ofType);
7655
+ return isScalarType13(type) || isEnumType11(type) || isInputObjectType8(type) || isWrappingType(type) && isInputType(type.ofType);
7656
7656
  }
7657
7657
  function assertInputType(type) {
7658
7658
  if (!isInputType(type)) {
@@ -7661,7 +7661,7 @@ var require_definition = __commonJS({
7661
7661
  return type;
7662
7662
  }
7663
7663
  function isOutputType(type) {
7664
- return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType10(type) || isWrappingType(type) && isOutputType(type.ofType);
7664
+ return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType11(type) || isWrappingType(type) && isOutputType(type.ofType);
7665
7665
  }
7666
7666
  function assertOutputType(type) {
7667
7667
  if (!isOutputType(type)) {
@@ -7670,7 +7670,7 @@ var require_definition = __commonJS({
7670
7670
  return type;
7671
7671
  }
7672
7672
  function isLeafType4(type) {
7673
- return isScalarType13(type) || isEnumType10(type);
7673
+ return isScalarType13(type) || isEnumType11(type);
7674
7674
  }
7675
7675
  function assertLeafType(type) {
7676
7676
  if (!isLeafType4(type)) {
@@ -7758,7 +7758,7 @@ var require_definition = __commonJS({
7758
7758
  }
7759
7759
  }
7760
7760
  function isNamedType4(type) {
7761
- return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType10(type) || isInputObjectType8(type);
7761
+ return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType11(type) || isInputObjectType8(type);
7762
7762
  }
7763
7763
  function assertNamedType(type) {
7764
7764
  if (!isNamedType4(type)) {
@@ -24055,42 +24055,42 @@ var require_node = __commonJS({
24055
24055
  return Link2;
24056
24056
  }(events_1.EventEmitter);
24057
24057
  exports.Link = Link;
24058
- var File3 = function() {
24059
- function File4(link, node, flags, fd) {
24058
+ var File4 = function() {
24059
+ function File5(link, node, flags, fd) {
24060
24060
  this.position = 0;
24061
24061
  this.link = link;
24062
24062
  this.node = node;
24063
24063
  this.flags = flags;
24064
24064
  this.fd = fd;
24065
24065
  }
24066
- File4.prototype.getString = function(encoding) {
24066
+ File5.prototype.getString = function(encoding) {
24067
24067
  if (encoding === void 0) {
24068
24068
  encoding = "utf8";
24069
24069
  }
24070
24070
  return this.node.getString();
24071
24071
  };
24072
- File4.prototype.setString = function(str) {
24072
+ File5.prototype.setString = function(str) {
24073
24073
  this.node.setString(str);
24074
24074
  };
24075
- File4.prototype.getBuffer = function() {
24075
+ File5.prototype.getBuffer = function() {
24076
24076
  return this.node.getBuffer();
24077
24077
  };
24078
- File4.prototype.setBuffer = function(buf) {
24078
+ File5.prototype.setBuffer = function(buf) {
24079
24079
  this.node.setBuffer(buf);
24080
24080
  };
24081
- File4.prototype.getSize = function() {
24081
+ File5.prototype.getSize = function() {
24082
24082
  return this.node.getSize();
24083
24083
  };
24084
- File4.prototype.truncate = function(len) {
24084
+ File5.prototype.truncate = function(len) {
24085
24085
  this.node.truncate(len);
24086
24086
  };
24087
- File4.prototype.seekTo = function(position) {
24087
+ File5.prototype.seekTo = function(position) {
24088
24088
  this.position = position;
24089
24089
  };
24090
- File4.prototype.stats = function() {
24090
+ File5.prototype.stats = function() {
24091
24091
  return Stats_1.default.build(this.node);
24092
24092
  };
24093
- File4.prototype.write = function(buf, offset, length, position) {
24093
+ File5.prototype.write = function(buf, offset, length, position) {
24094
24094
  if (offset === void 0) {
24095
24095
  offset = 0;
24096
24096
  }
@@ -24105,7 +24105,7 @@ var require_node = __commonJS({
24105
24105
  this.position = position + bytes;
24106
24106
  return bytes;
24107
24107
  };
24108
- File4.prototype.read = function(buf, offset, length, position) {
24108
+ File5.prototype.read = function(buf, offset, length, position) {
24109
24109
  if (offset === void 0) {
24110
24110
  offset = 0;
24111
24111
  }
@@ -24118,15 +24118,15 @@ var require_node = __commonJS({
24118
24118
  this.position = position + bytes;
24119
24119
  return bytes;
24120
24120
  };
24121
- File4.prototype.chmod = function(perm) {
24121
+ File5.prototype.chmod = function(perm) {
24122
24122
  this.node.chmod(perm);
24123
24123
  };
24124
- File4.prototype.chown = function(uid, gid) {
24124
+ File5.prototype.chown = function(uid, gid) {
24125
24125
  this.node.chown(uid, gid);
24126
24126
  };
24127
- return File4;
24127
+ return File5;
24128
24128
  }();
24129
- exports.File = File3;
24129
+ exports.File = File4;
24130
24130
  }
24131
24131
  });
24132
24132
 
@@ -24812,20 +24812,20 @@ var require_volume = __commonJS({
24812
24812
  }
24813
24813
  function flattenJSON(nestedJSON) {
24814
24814
  var flatJSON = {};
24815
- function flatten(pathPrefix, node) {
24815
+ function flatten2(pathPrefix, node) {
24816
24816
  for (var path2 in node) {
24817
24817
  var contentOrNode = node[path2];
24818
24818
  var joinedPath = join3(pathPrefix, path2);
24819
24819
  if (typeof contentOrNode === "string") {
24820
24820
  flatJSON[joinedPath] = contentOrNode;
24821
24821
  } else if (typeof contentOrNode === "object" && contentOrNode !== null && Object.keys(contentOrNode).length > 0) {
24822
- flatten(joinedPath, contentOrNode);
24822
+ flatten2(joinedPath, contentOrNode);
24823
24823
  } else {
24824
24824
  flatJSON[joinedPath] = null;
24825
24825
  }
24826
24826
  }
24827
24827
  }
24828
- flatten("", nestedJSON);
24828
+ flatten2("", nestedJSON);
24829
24829
  return flatJSON;
24830
24830
  }
24831
24831
  var Volume = function() {
@@ -30235,9 +30235,9 @@ var require_streams = __commonJS({
30235
30235
  }
30236
30236
  }
30237
30237
  try {
30238
- const { Blob: Blob3 } = __require("buffer");
30239
- if (Blob3 && !Blob3.prototype.stream) {
30240
- Blob3.prototype.stream = function name(params) {
30238
+ const { Blob: Blob4 } = __require("buffer");
30239
+ if (Blob4 && !Blob4.prototype.stream) {
30240
+ Blob4.prototype.stream = function name(params) {
30241
30241
  let position = 0;
30242
30242
  const blob = this;
30243
30243
  return new ReadableStream({
@@ -30288,12 +30288,12 @@ async function* toIterator(parts, clone2 = true) {
30288
30288
  }
30289
30289
  }
30290
30290
  }
30291
- var import_streams, POOL_SIZE, _Blob, Blob2, fetch_blob_default;
30291
+ var import_streams, POOL_SIZE, _Blob, Blob3, fetch_blob_default;
30292
30292
  var init_fetch_blob = __esm({
30293
30293
  "../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/index.js"() {
30294
30294
  import_streams = __toESM(require_streams(), 1);
30295
30295
  POOL_SIZE = 65536;
30296
- _Blob = class Blob {
30296
+ _Blob = class Blob2 {
30297
30297
  #parts = [];
30298
30298
  #type = "";
30299
30299
  #size = 0;
@@ -30317,7 +30317,7 @@ var init_fetch_blob = __esm({
30317
30317
  part = new Uint8Array(element.buffer.slice(element.byteOffset, element.byteOffset + element.byteLength));
30318
30318
  } else if (element instanceof ArrayBuffer) {
30319
30319
  part = new Uint8Array(element.slice(0));
30320
- } else if (element instanceof Blob) {
30320
+ } else if (element instanceof Blob2) {
30321
30321
  part = element;
30322
30322
  } else {
30323
30323
  part = encoder.encode(`${element}`);
@@ -30396,7 +30396,7 @@ var init_fetch_blob = __esm({
30396
30396
  relativeStart = 0;
30397
30397
  }
30398
30398
  }
30399
- const blob = new Blob([], { type: String(type).toLowerCase() });
30399
+ const blob = new Blob2([], { type: String(type).toLowerCase() });
30400
30400
  blob.#size = span;
30401
30401
  blob.#parts = blobParts;
30402
30402
  return blob;
@@ -30413,17 +30413,17 @@ var init_fetch_blob = __esm({
30413
30413
  type: { enumerable: true },
30414
30414
  slice: { enumerable: true }
30415
30415
  });
30416
- Blob2 = _Blob;
30417
- fetch_blob_default = Blob2;
30416
+ Blob3 = _Blob;
30417
+ fetch_blob_default = Blob3;
30418
30418
  }
30419
30419
  });
30420
30420
 
30421
30421
  // ../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/file.js
30422
- var _File, File2, file_default;
30422
+ var _File, File3, file_default;
30423
30423
  var init_file = __esm({
30424
30424
  "../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/file.js"() {
30425
30425
  init_fetch_blob();
30426
- _File = class File extends fetch_blob_default {
30426
+ _File = class File2 extends fetch_blob_default {
30427
30427
  #lastModified = 0;
30428
30428
  #name = "";
30429
30429
  constructor(fileBits, fileName, options = {}) {
@@ -30452,8 +30452,8 @@ var init_file = __esm({
30452
30452
  return !!object && object instanceof fetch_blob_default && /^(File)$/.test(object[Symbol.toStringTag]);
30453
30453
  }
30454
30454
  };
30455
- File2 = _File;
30456
- file_default = File2;
30455
+ File3 = _File;
30456
+ file_default = File3;
30457
30457
  }
30458
30458
  });
30459
30459
 
@@ -30471,7 +30471,7 @@ Content-Type: ${v.type || "application/octet-stream"}\r
30471
30471
  c.push(`--${b}--`);
30472
30472
  return new B(c, { type: "multipart/form-data; boundary=" + b });
30473
30473
  }
30474
- var t, i, h, r, m, f, e, x, FormData;
30474
+ var t, i, h, r, m, f, e, x, FormData2;
30475
30475
  var init_esm_min = __esm({
30476
30476
  "../../node_modules/.pnpm/formdata-polyfill@4.0.10/node_modules/formdata-polyfill/esm.min.js"() {
30477
30477
  init_fetch_blob();
@@ -30486,7 +30486,7 @@ var init_esm_min = __esm({
30486
30486
  throw new TypeError(`Failed to execute '${n}' on 'FormData': ${e2} arguments required, but only ${a.length} present.`);
30487
30487
  }
30488
30488
  };
30489
- FormData = class FormData2 {
30489
+ FormData2 = class FormData3 {
30490
30490
  #d = [];
30491
30491
  constructor(...a) {
30492
30492
  if (a.length)
@@ -30652,7 +30652,7 @@ async function toFormData(Body2, ct) {
30652
30652
  let contentType;
30653
30653
  let filename;
30654
30654
  const entryChunks = [];
30655
- const formData = new FormData();
30655
+ const formData = new FormData2();
30656
30656
  const onPartData = (ui8a) => {
30657
30657
  entryValue += decoder.decode(ui8a, { stream: true });
30658
30658
  };
@@ -65182,7 +65182,18 @@ var graphql2 = __toESM(require_graphql2(), 1);
65182
65182
  var import_minimatch = __toESM(require_minimatch(), 1);
65183
65183
  import { fileURLToPath, pathToFileURL } from "node:url";
65184
65184
 
65185
+ // src/runtime/imports/config.ts
65186
+ var config_default = {};
65187
+
65188
+ // src/runtime/imports/pluginConfig.ts
65189
+ var configs = [];
65190
+ var pluginConfig_default = configs;
65191
+
65185
65192
  // src/runtime/lib/config.ts
65193
+ var mockConfig = null;
65194
+ function getMockConfig() {
65195
+ return mockConfig;
65196
+ }
65186
65197
  function defaultConfigValues(file) {
65187
65198
  return {
65188
65199
  defaultKeys: ["id"],
@@ -65210,12 +65221,150 @@ function computeID(configFile, type, data) {
65210
65221
  }
65211
65222
  return id.slice(0, -2);
65212
65223
  }
65224
+ var _configFile = null;
65225
+ function getCurrentConfig() {
65226
+ const mockConfig2 = getMockConfig();
65227
+ if (mockConfig2) {
65228
+ return mockConfig2;
65229
+ }
65230
+ if (_configFile) {
65231
+ return _configFile;
65232
+ }
65233
+ let configFile = defaultConfigValues(config_default);
65234
+ for (const pluginConfig of pluginConfig_default) {
65235
+ configFile = pluginConfig(configFile);
65236
+ }
65237
+ _configFile = configFile;
65238
+ return configFile;
65239
+ }
65240
+
65241
+ // src/runtime/lib/deepEquals.ts
65242
+ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
65243
+ if (Object.is(objA, objB))
65244
+ return true;
65245
+ if (objA instanceof Date && objB instanceof Date) {
65246
+ return objA.getTime() === objB.getTime();
65247
+ }
65248
+ if (objA instanceof RegExp && objB instanceof RegExp) {
65249
+ return objA.toString() === objB.toString();
65250
+ }
65251
+ if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
65252
+ return false;
65253
+ }
65254
+ if (map.get(objA) === objB)
65255
+ return true;
65256
+ map.set(objA, objB);
65257
+ const keysA = Reflect.ownKeys(objA);
65258
+ const keysB = Reflect.ownKeys(objB);
65259
+ if (keysA.length !== keysB.length) {
65260
+ return false;
65261
+ }
65262
+ for (let i2 = 0; i2 < keysA.length; i2++) {
65263
+ if (!Reflect.has(objB, keysA[i2]) || !deepEquals(objA[keysA[i2]], objB[keysA[i2]], map)) {
65264
+ return false;
65265
+ }
65266
+ }
65267
+ return true;
65268
+ }
65269
+
65270
+ // src/runtime/lib/selection.ts
65271
+ function getFieldsForType(selection2, __typename) {
65272
+ let targetSelection = selection2.fields || {};
65273
+ if (selection2.abstractFields && __typename) {
65274
+ const mappedType = selection2.abstractFields.typeMap[__typename];
65275
+ if (mappedType) {
65276
+ targetSelection = selection2.abstractFields.fields[mappedType];
65277
+ } else if (selection2.abstractFields.fields[__typename]) {
65278
+ targetSelection = selection2.abstractFields.fields[__typename];
65279
+ }
65280
+ }
65281
+ return targetSelection;
65282
+ }
65283
+
65284
+ // src/runtime/lib/scalars.ts
65285
+ async function marshalSelection({
65286
+ selection: selection2,
65287
+ data
65288
+ }) {
65289
+ const config4 = getCurrentConfig();
65290
+ if (data === null || typeof data === "undefined") {
65291
+ return data;
65292
+ }
65293
+ if (Array.isArray(data)) {
65294
+ return await Promise.all(data.map((val) => marshalSelection({ selection: selection2, data: val })));
65295
+ }
65296
+ const targetSelection = getFieldsForType(selection2, data["__typename"]);
65297
+ return Object.fromEntries(
65298
+ await Promise.all(
65299
+ Object.entries(data).map(async ([fieldName, value]) => {
65300
+ const { type, selection: selection3 } = targetSelection[fieldName];
65301
+ if (!type) {
65302
+ return [fieldName, value];
65303
+ }
65304
+ if (selection3) {
65305
+ return [fieldName, await marshalSelection({ selection: selection3, data: value })];
65306
+ }
65307
+ if (config4.scalars?.[type]) {
65308
+ const marshalFn = config4.scalars[type].marshal;
65309
+ if (!marshalFn) {
65310
+ throw new Error(
65311
+ `scalar type ${type} is missing a \`marshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
65312
+ );
65313
+ }
65314
+ if (Array.isArray(value)) {
65315
+ return [fieldName, value.map(marshalFn)];
65316
+ }
65317
+ return [fieldName, marshalFn(value)];
65318
+ }
65319
+ return [fieldName, value];
65320
+ })
65321
+ )
65322
+ );
65323
+ }
65213
65324
 
65214
65325
  // src/runtime/lib/types.ts
65215
- var CompiledFragmentKind = "HoudiniFragment" /* Fragment */;
65216
- var CompiledMutationKind = "HoudiniMutation" /* Mutation */;
65217
- var CompiledQueryKind = "HoudiniQuery" /* Query */;
65218
- var CompiledSubscriptionKind = "HoudiniSubscription" /* Subscription */;
65326
+ var CachePolicy = {
65327
+ CacheOrNetwork: "CacheOrNetwork",
65328
+ CacheOnly: "CacheOnly",
65329
+ NetworkOnly: "NetworkOnly",
65330
+ CacheAndNetwork: "CacheAndNetwork"
65331
+ };
65332
+ var ArtifactKind = {
65333
+ Query: "HoudiniQuery",
65334
+ Subscription: "HoudiniSubscription",
65335
+ Mutation: "HoudiniMutation",
65336
+ Fragment: "HoudiniFragment"
65337
+ };
65338
+ var CompiledFragmentKind = ArtifactKind.Fragment;
65339
+ var CompiledMutationKind = ArtifactKind.Mutation;
65340
+ var CompiledQueryKind = ArtifactKind.Query;
65341
+ var CompiledSubscriptionKind = ArtifactKind.Subscription;
65342
+ var RefetchUpdateMode = {
65343
+ append: "append",
65344
+ prepend: "prepend",
65345
+ replace: "replace"
65346
+ };
65347
+ var DataSource = {
65348
+ Cache: "cache",
65349
+ Network: "network",
65350
+ Ssr: "ssr"
65351
+ };
65352
+
65353
+ // src/runtime/lib/key.ts
65354
+ var computeKey = ({ field, args }) => {
65355
+ const keys = Object.keys(args ?? {});
65356
+ keys.sort();
65357
+ return args && keys.length > 0 ? `${field}(${keys.map((key) => `${key}: ${stringifyObjectWithNoQuotesOnKeys(args[key])}`).join(", ")})` : field;
65358
+ };
65359
+ var stringifyObjectWithNoQuotesOnKeys = (obj_from_json) => {
65360
+ if (Array.isArray(obj_from_json)) {
65361
+ return `[${obj_from_json.map((obj) => `${stringifyObjectWithNoQuotesOnKeys(obj)}`).join(", ")}]`;
65362
+ }
65363
+ if (typeof obj_from_json !== "object" || obj_from_json instanceof Date || obj_from_json === null) {
65364
+ return JSON.stringify(obj_from_json).replace(/"([^"]+)":/g, "$1: ");
65365
+ }
65366
+ return `{${Object.keys(obj_from_json).map((key) => `${key}: ${stringifyObjectWithNoQuotesOnKeys(obj_from_json[key])}`).join(", ")}}`;
65367
+ };
65219
65368
 
65220
65369
  // src/lib/constants.ts
65221
65370
  var siteURL = "https://houdinigraphql.com";
@@ -65661,7 +65810,7 @@ var Body = class {
65661
65810
  } else if (ArrayBuffer.isView(body)) {
65662
65811
  body = Buffer2.from(body.buffer, body.byteOffset, body.byteLength);
65663
65812
  } else if (body instanceof Stream) {
65664
- } else if (body instanceof FormData) {
65813
+ } else if (body instanceof FormData2) {
65665
65814
  body = formDataToBlob(body);
65666
65815
  boundary = body.type.split("=")[1];
65667
65816
  } else {
@@ -65701,7 +65850,7 @@ var Body = class {
65701
65850
  async formData() {
65702
65851
  const ct = this.headers.get("content-type");
65703
65852
  if (ct.startsWith("application/x-www-form-urlencoded")) {
65704
- const formData = new FormData();
65853
+ const formData = new FormData2();
65705
65854
  const parameters = new URLSearchParams(await this.text());
65706
65855
  for (const [name, value] of parameters) {
65707
65856
  formData.append(name, value);
@@ -65827,7 +65976,7 @@ var extractContentType = (body, request) => {
65827
65976
  if (Buffer2.isBuffer(body) || types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
65828
65977
  return null;
65829
65978
  }
65830
- if (body instanceof FormData) {
65979
+ if (body instanceof FormData2) {
65831
65980
  return `multipart/form-data; boundary=${request[INTERNALS].boundary}`;
65832
65981
  }
65833
65982
  if (body && typeof body.getBoundary === "function") {
@@ -66794,14 +66943,2002 @@ function plugin(name, hooks) {
66794
66943
  return data;
66795
66944
  }
66796
66945
 
66946
+ // src/runtime/lib/flatten.ts
66947
+ function flatten(source) {
66948
+ if (!source) {
66949
+ return [];
66950
+ }
66951
+ return source.reduce((acc, element) => {
66952
+ if (!element) {
66953
+ return acc;
66954
+ }
66955
+ if (Array.isArray(element)) {
66956
+ return acc.concat(flatten(element));
66957
+ }
66958
+ return acc.concat(element);
66959
+ }, []);
66960
+ }
66961
+
66962
+ // src/runtime/cache/gc.ts
66963
+ var GarbageCollector = class {
66964
+ cache;
66965
+ lifetimes = /* @__PURE__ */ new Map();
66966
+ get cacheBufferSize() {
66967
+ return this.cache._internal_unstable.config.cacheBufferSize ?? 10;
66968
+ }
66969
+ constructor(cache) {
66970
+ this.cache = cache;
66971
+ }
66972
+ resetLifetime(id, field) {
66973
+ if (!this.lifetimes.get(id)) {
66974
+ this.lifetimes.set(id, /* @__PURE__ */ new Map());
66975
+ }
66976
+ this.lifetimes.get(id).set(field, 0);
66977
+ }
66978
+ tick() {
66979
+ const dt_tick = Date.now().valueOf();
66980
+ const config_max_time = this.cache._internal_unstable.config.defaultLifetime;
66981
+ for (const [id, fieldMap] of this.lifetimes.entries()) {
66982
+ for (const [field, lifetime] of fieldMap.entries()) {
66983
+ if (this.cache._internal_unstable.subscriptions.get(id, field).length > 0) {
66984
+ continue;
66985
+ }
66986
+ fieldMap.set(field, lifetime + 1);
66987
+ if (fieldMap.get(field) > this.cacheBufferSize) {
66988
+ this.cache._internal_unstable.storage.deleteField(id, field);
66989
+ this.cache._internal_unstable.lists.deleteField(id, field);
66990
+ fieldMap.delete(field);
66991
+ if ([...fieldMap.keys()].length === 0) {
66992
+ this.lifetimes.delete(id);
66993
+ }
66994
+ this.cache._internal_unstable.staleManager.delete(id, field);
66995
+ }
66996
+ if (config_max_time && config_max_time > 0) {
66997
+ const dt_valueOf = this.cache.getFieldTime(id, field);
66998
+ if (dt_valueOf && dt_tick - dt_valueOf > config_max_time) {
66999
+ this.cache._internal_unstable.staleManager.markFieldStale(id, field);
67000
+ }
67001
+ }
67002
+ }
67003
+ }
67004
+ }
67005
+ };
67006
+
67007
+ // src/runtime/cache/lists.ts
67008
+ var ListManager = class {
67009
+ rootID;
67010
+ cache;
67011
+ constructor(cache, rootID2) {
67012
+ this.rootID = rootID2;
67013
+ this.cache = cache;
67014
+ }
67015
+ lists = /* @__PURE__ */ new Map();
67016
+ listsByField = /* @__PURE__ */ new Map();
67017
+ get(listName, id, allLists) {
67018
+ const matches = this.lists.get(listName);
67019
+ if (!matches || matches.size === 0) {
67020
+ return null;
67021
+ }
67022
+ if (allLists) {
67023
+ return new ListCollection(
67024
+ Array.from(matches, ([key, value]) => [...value.lists]).flat()
67025
+ );
67026
+ }
67027
+ const head = [...matches.values()][0];
67028
+ const { recordType } = head.lists[0];
67029
+ const parentID = id ? this.cache._internal_unstable.id(recordType || "", id) : this.rootID;
67030
+ if (matches?.size === 1) {
67031
+ if (!id) {
67032
+ return head;
67033
+ }
67034
+ return parentID === Array.from(matches.keys())[0] ? head : null;
67035
+ }
67036
+ if (!id) {
67037
+ console.error(
67038
+ `Found multiple instances of "${listName}". Please provide one of @parentID or @allLists directives to help identify which list you want modify. For more information, visit this guide: https://www.houdinigraphql.com/api/graphql#parentidvalue-string `
67039
+ );
67040
+ return null;
67041
+ }
67042
+ return this.lists.get(listName)?.get(parentID);
67043
+ }
67044
+ remove(listName, id) {
67045
+ this.lists.get(listName)?.delete(id || this.rootID);
67046
+ }
67047
+ add(list) {
67048
+ if (!this.lists.has(list.name)) {
67049
+ this.lists.set(list.name, /* @__PURE__ */ new Map());
67050
+ }
67051
+ const name = list.name;
67052
+ const parentID = list.recordID || this.rootID;
67053
+ if (this.lists.get(name)?.get(parentID)?.includes(list.key)) {
67054
+ return;
67055
+ }
67056
+ if (!this.lists.has(name)) {
67057
+ this.lists.set(name, /* @__PURE__ */ new Map());
67058
+ }
67059
+ if (!this.lists.get(name).has(parentID)) {
67060
+ this.lists.get(name).set(parentID, new ListCollection([]));
67061
+ }
67062
+ if (!this.listsByField.has(parentID)) {
67063
+ this.listsByField.set(parentID, /* @__PURE__ */ new Map());
67064
+ }
67065
+ if (!this.listsByField.get(parentID).has(list.key)) {
67066
+ this.listsByField.get(parentID)?.set(list.key, []);
67067
+ }
67068
+ const handler = new List({ ...list, manager: this });
67069
+ this.lists.get(list.name).get(parentID).lists.push(handler);
67070
+ this.listsByField.get(parentID).get(list.key).push(handler);
67071
+ }
67072
+ removeIDFromAllLists(id) {
67073
+ for (const fieldMap of this.lists.values()) {
67074
+ for (const list of fieldMap.values()) {
67075
+ list.removeID(id);
67076
+ }
67077
+ }
67078
+ }
67079
+ deleteField(parentID, field) {
67080
+ if (!this.listsByField.get(parentID)?.has(field)) {
67081
+ return;
67082
+ }
67083
+ for (const list of this.listsByField.get(parentID).get(field)) {
67084
+ this.lists.get(list.name)?.get(list.recordID)?.deleteListWithKey(field);
67085
+ if (this.lists.get(list.name)?.get(list.recordID)?.lists.length === 0) {
67086
+ this.lists.get(list.name)?.delete(list.recordID);
67087
+ }
67088
+ }
67089
+ this.listsByField.get(parentID).delete(field);
67090
+ }
67091
+ };
67092
+ var List = class {
67093
+ recordID;
67094
+ recordType;
67095
+ key;
67096
+ type;
67097
+ cache;
67098
+ selection;
67099
+ _when;
67100
+ filters;
67101
+ name;
67102
+ connection;
67103
+ manager;
67104
+ abstract;
67105
+ constructor({
67106
+ name,
67107
+ recordID,
67108
+ recordType,
67109
+ key,
67110
+ listType,
67111
+ selection: selection2,
67112
+ when,
67113
+ filters,
67114
+ connection,
67115
+ manager,
67116
+ abstract
67117
+ }) {
67118
+ this.recordID = recordID || rootID;
67119
+ this.recordType = recordType;
67120
+ this.key = key;
67121
+ this.type = listType;
67122
+ this.cache = manager.cache;
67123
+ this.selection = selection2;
67124
+ this._when = when;
67125
+ this.filters = filters;
67126
+ this.name = name;
67127
+ this.connection = connection;
67128
+ this.manager = manager;
67129
+ this.abstract = abstract;
67130
+ }
67131
+ when(when) {
67132
+ return this.manager.lists.get(this.name).get(this.recordID).when(when);
67133
+ }
67134
+ append(selection2, data, variables = {}) {
67135
+ return this.addToList(selection2, data, variables, "last");
67136
+ }
67137
+ prepend(selection2, data, variables = {}) {
67138
+ return this.addToList(selection2, data, variables, "first");
67139
+ }
67140
+ addToList(selection2, data, variables = {}, where) {
67141
+ const listType = this.listType(data);
67142
+ const dataID = this.cache._internal_unstable.id(listType, data);
67143
+ if (!this.validateWhen() || !dataID) {
67144
+ return;
67145
+ }
67146
+ let insertSelection = selection2;
67147
+ let insertData = data;
67148
+ if (this.connection) {
67149
+ insertSelection = {
67150
+ fields: {
67151
+ newEntry: {
67152
+ keyRaw: this.key,
67153
+ type: "Connection",
67154
+ selection: {
67155
+ fields: {
67156
+ edges: {
67157
+ keyRaw: "edges",
67158
+ type: "ConnectionEdge",
67159
+ updates: ["append", "prepend"],
67160
+ selection: {
67161
+ fields: {
67162
+ node: {
67163
+ type: listType,
67164
+ keyRaw: "node",
67165
+ selection: {
67166
+ ...selection2,
67167
+ fields: {
67168
+ ...selection2.fields,
67169
+ __typename: {
67170
+ keyRaw: "__typename",
67171
+ type: "String"
67172
+ }
67173
+ }
67174
+ }
67175
+ }
67176
+ }
67177
+ }
67178
+ }
67179
+ }
67180
+ }
67181
+ }
67182
+ }
67183
+ };
67184
+ insertData = {
67185
+ newEntry: {
67186
+ edges: [{ node: { ...data, __typename: listType } }]
67187
+ }
67188
+ };
67189
+ } else {
67190
+ insertSelection = {
67191
+ fields: {
67192
+ newEntries: {
67193
+ keyRaw: this.key,
67194
+ type: listType,
67195
+ updates: ["append", "prepend"],
67196
+ selection: {
67197
+ ...selection2,
67198
+ fields: {
67199
+ ...selection2.fields,
67200
+ __typename: {
67201
+ keyRaw: "__typename",
67202
+ type: "String"
67203
+ }
67204
+ }
67205
+ }
67206
+ }
67207
+ }
67208
+ };
67209
+ insertData = {
67210
+ newEntries: [{ ...data, __typename: listType }]
67211
+ };
67212
+ }
67213
+ this.cache.write({
67214
+ selection: insertSelection,
67215
+ data: insertData,
67216
+ variables,
67217
+ parent: this.recordID,
67218
+ applyUpdates: [where === "first" ? "prepend" : "append"]
67219
+ });
67220
+ }
67221
+ removeID(id, variables = {}) {
67222
+ if (!this.validateWhen()) {
67223
+ return;
67224
+ }
67225
+ let parentID = this.recordID;
67226
+ let targetID = id;
67227
+ let targetKey = this.key;
67228
+ if (this.connection) {
67229
+ const { value: embeddedConnection } = this.cache._internal_unstable.storage.get(
67230
+ this.recordID,
67231
+ this.key
67232
+ );
67233
+ if (!embeddedConnection) {
67234
+ return;
67235
+ }
67236
+ const embeddedConnectionID = embeddedConnection;
67237
+ const { value: edges } = this.cache._internal_unstable.storage.get(
67238
+ embeddedConnectionID,
67239
+ "edges"
67240
+ );
67241
+ for (const edge of flatten(edges) || []) {
67242
+ if (!edge) {
67243
+ continue;
67244
+ }
67245
+ const edgeID = edge;
67246
+ const { value: nodeID } = this.cache._internal_unstable.storage.get(edgeID, "node");
67247
+ if (!nodeID) {
67248
+ continue;
67249
+ }
67250
+ if (nodeID === id) {
67251
+ targetID = edgeID;
67252
+ }
67253
+ }
67254
+ parentID = embeddedConnectionID;
67255
+ targetKey = "edges";
67256
+ }
67257
+ let value = this.cache._internal_unstable.storage.get(parentID, targetKey).value;
67258
+ if (!value || !value.includes(targetID)) {
67259
+ return;
67260
+ }
67261
+ const subscribers = this.cache._internal_unstable.subscriptions.get(this.recordID, this.key);
67262
+ this.cache._internal_unstable.subscriptions.remove(
67263
+ targetID,
67264
+ this.connection ? this.selection.fields.edges.selection : this.selection,
67265
+ subscribers.map((sub) => sub[0]),
67266
+ variables
67267
+ );
67268
+ this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
67269
+ for (const [spec] of subscribers) {
67270
+ spec.set(
67271
+ this.cache._internal_unstable.getSelection({
67272
+ parent: spec.parentID || this.manager.rootID,
67273
+ selection: spec.selection,
67274
+ variables: spec.variables?.() || {}
67275
+ }).data
67276
+ );
67277
+ }
67278
+ return true;
67279
+ }
67280
+ remove(data, variables = {}) {
67281
+ const targetID = this.cache._internal_unstable.id(this.listType(data), data);
67282
+ if (!targetID) {
67283
+ return;
67284
+ }
67285
+ return this.removeID(targetID, variables);
67286
+ }
67287
+ listType(data) {
67288
+ return data.__typename || this.type;
67289
+ }
67290
+ validateWhen(when) {
67291
+ let filters = when || this._when;
67292
+ let ok = true;
67293
+ if (filters) {
67294
+ const targets = this.filters;
67295
+ if (filters.must && targets) {
67296
+ ok = Object.entries(filters.must).reduce(
67297
+ (prev, [key, value]) => Boolean(prev && targets[key] == value),
67298
+ ok
67299
+ );
67300
+ }
67301
+ if (filters.must_not) {
67302
+ ok = !targets || Object.entries(filters.must_not).reduce(
67303
+ (prev, [key, value]) => Boolean(prev && targets[key] != value),
67304
+ ok
67305
+ );
67306
+ }
67307
+ }
67308
+ return ok;
67309
+ }
67310
+ toggleElement(selection2, data, variables = {}, where) {
67311
+ if (!this.remove(data, variables)) {
67312
+ this.addToList(selection2, data, variables, where);
67313
+ }
67314
+ }
67315
+ *[Symbol.iterator]() {
67316
+ let entries = [];
67317
+ let value = this.cache._internal_unstable.storage.get(this.recordID, this.key).value;
67318
+ if (!this.connection) {
67319
+ entries = flatten(value);
67320
+ } else {
67321
+ entries = this.cache._internal_unstable.storage.get(value, "edges").value;
67322
+ }
67323
+ for (let record2 of entries) {
67324
+ yield record2;
67325
+ }
67326
+ }
67327
+ };
67328
+ var ListCollection = class {
67329
+ lists = [];
67330
+ constructor(lists) {
67331
+ this.lists = lists;
67332
+ }
67333
+ get selection() {
67334
+ return this.lists[0].selection;
67335
+ }
67336
+ append(...args) {
67337
+ this.lists.forEach((list) => list.append(...args));
67338
+ }
67339
+ prepend(...args) {
67340
+ this.lists.forEach((list) => list.prepend(...args));
67341
+ }
67342
+ addToList(...args) {
67343
+ this.lists.forEach((list) => list.addToList(...args));
67344
+ }
67345
+ removeID(...args) {
67346
+ this.lists.forEach((list) => list.removeID(...args));
67347
+ }
67348
+ remove(...args) {
67349
+ this.lists.forEach((list) => list.remove(...args));
67350
+ }
67351
+ toggleElement(...args) {
67352
+ this.lists.forEach((list) => list.toggleElement(...args));
67353
+ }
67354
+ when(when) {
67355
+ return new ListCollection(
67356
+ this.lists.filter((list) => {
67357
+ return list.validateWhen(when);
67358
+ })
67359
+ );
67360
+ }
67361
+ includes(key) {
67362
+ return !!this.lists.find((list) => list.key === key);
67363
+ }
67364
+ deleteListWithKey(key) {
67365
+ return this.lists = this.lists.filter((list) => list.key !== key);
67366
+ }
67367
+ *[Symbol.iterator]() {
67368
+ for (let list of this.lists) {
67369
+ for (const entry of list) {
67370
+ yield entry;
67371
+ }
67372
+ }
67373
+ }
67374
+ };
67375
+
67376
+ // src/runtime/cache/schema.ts
67377
+ var SchemaManager = class {
67378
+ cache;
67379
+ fieldTypes = {};
67380
+ constructor(cache) {
67381
+ this.cache = cache;
67382
+ }
67383
+ setFieldType({
67384
+ parent,
67385
+ key,
67386
+ type,
67387
+ nullable = false,
67388
+ link
67389
+ }) {
67390
+ let parensIndex = key.indexOf("(");
67391
+ if (parensIndex !== -1) {
67392
+ key = key.substring(0, parensIndex);
67393
+ }
67394
+ if (parent === rootID) {
67395
+ parent = "Query";
67396
+ } else if (parent.includes(":")) {
67397
+ parent = parent.substring(0, parent.indexOf(":"));
67398
+ }
67399
+ if (!this.fieldTypes[parent]) {
67400
+ this.fieldTypes[parent] = {};
67401
+ }
67402
+ this.fieldTypes[parent][key] = {
67403
+ type,
67404
+ nullable,
67405
+ link: !!link
67406
+ };
67407
+ }
67408
+ fieldType(type, field) {
67409
+ return this.fieldTypes[type]?.[field] || null;
67410
+ }
67411
+ get config() {
67412
+ return this.cache._internal_unstable.config;
67413
+ }
67414
+ };
67415
+
67416
+ // src/runtime/cache/staleManager.ts
67417
+ var StaleManager = class {
67418
+ cache;
67419
+ fieldsTime = /* @__PURE__ */ new Map();
67420
+ constructor(cache) {
67421
+ this.cache = cache;
67422
+ }
67423
+ #initMapId = (id) => {
67424
+ if (!this.fieldsTime.get(id)) {
67425
+ this.fieldsTime.set(id, /* @__PURE__ */ new Map());
67426
+ }
67427
+ };
67428
+ getFieldTime(id, field) {
67429
+ return this.fieldsTime.get(id)?.get(field);
67430
+ }
67431
+ setFieldTimeToNow(id, field) {
67432
+ this.#initMapId(id);
67433
+ this.fieldsTime.get(id)?.set(field, new Date().valueOf());
67434
+ }
67435
+ markFieldStale(id, field) {
67436
+ this.#initMapId(id);
67437
+ this.fieldsTime.get(id)?.set(field, null);
67438
+ }
67439
+ markAllStale() {
67440
+ for (const [id, fieldMap] of this.fieldsTime.entries()) {
67441
+ for (const [field] of fieldMap.entries()) {
67442
+ this.markFieldStale(id, field);
67443
+ }
67444
+ }
67445
+ }
67446
+ markRecordStale(id) {
67447
+ const fieldsTimeOfType = this.fieldsTime.get(id);
67448
+ if (fieldsTimeOfType) {
67449
+ for (const [field] of fieldsTimeOfType.entries()) {
67450
+ this.markFieldStale(id, field);
67451
+ }
67452
+ }
67453
+ }
67454
+ markTypeStale(type) {
67455
+ for (const [id, fieldMap] of this.fieldsTime.entries()) {
67456
+ if (id.startsWith(`${type}:`)) {
67457
+ for (const [field] of fieldMap.entries()) {
67458
+ this.markFieldStale(id, field);
67459
+ }
67460
+ }
67461
+ }
67462
+ }
67463
+ markTypeFieldStale(type, field, when) {
67464
+ const key = computeKey({ field, args: when });
67465
+ for (const [id, fieldMap] of this.fieldsTime.entries()) {
67466
+ if (id.startsWith(`${type}:`)) {
67467
+ for (const local_field of fieldMap.keys()) {
67468
+ if (local_field === key) {
67469
+ this.markFieldStale(id, field);
67470
+ }
67471
+ }
67472
+ }
67473
+ }
67474
+ }
67475
+ delete(id, field) {
67476
+ if (this.fieldsTime.has(id)) {
67477
+ this.fieldsTime.get(id)?.delete(field);
67478
+ if (this.fieldsTime.get(id)?.size === 0) {
67479
+ this.fieldsTime.delete(id);
67480
+ }
67481
+ }
67482
+ }
67483
+ };
67484
+
67485
+ // src/runtime/cache/storage.ts
67486
+ var InMemoryStorage = class {
67487
+ data;
67488
+ idCount = 0;
67489
+ rank = 0;
67490
+ constructor() {
67491
+ this.data = [];
67492
+ }
67493
+ get layerCount() {
67494
+ return this.data.length;
67495
+ }
67496
+ get nextRank() {
67497
+ return this.rank++;
67498
+ }
67499
+ createLayer(optimistic = false) {
67500
+ const layer = new Layer(this.idCount++);
67501
+ layer.optimistic = optimistic;
67502
+ this.data.push(layer);
67503
+ return layer;
67504
+ }
67505
+ insert(id, field, location, target) {
67506
+ return this.topLayer.insert(id, field, location, target);
67507
+ }
67508
+ remove(id, field, target) {
67509
+ return this.topLayer.remove(id, field, target);
67510
+ }
67511
+ delete(id) {
67512
+ return this.topLayer.delete(id);
67513
+ }
67514
+ deleteField(id, field) {
67515
+ return this.topLayer.deleteField(id, field);
67516
+ }
67517
+ getLayer(id) {
67518
+ for (const layer of this.data) {
67519
+ if (layer.id === id) {
67520
+ return layer;
67521
+ }
67522
+ }
67523
+ throw new Error("Could not find layer with id: " + id);
67524
+ }
67525
+ replaceID(replacement) {
67526
+ for (const layer of this.data) {
67527
+ layer.replaceID(replacement);
67528
+ }
67529
+ }
67530
+ get(id, field) {
67531
+ const operations = {
67532
+ [OperationKind.insert]: {
67533
+ [OperationLocation.start]: [],
67534
+ [OperationLocation.end]: []
67535
+ },
67536
+ [OperationKind.remove]: /* @__PURE__ */ new Set()
67537
+ };
67538
+ const layerIDs = [];
67539
+ for (let i2 = this.data.length - 1; i2 >= 0; i2--) {
67540
+ const layer = this.data[i2];
67541
+ const [layerValue, kind] = layer.get(id, field);
67542
+ const layerOperations = layer.getOperations(id, field) || [];
67543
+ layer.deletedIDs.forEach((v) => {
67544
+ if (layer.operations[v]?.undoDeletesInList?.includes(field)) {
67545
+ return;
67546
+ }
67547
+ operations.remove.add(v);
67548
+ });
67549
+ if (typeof layerValue === "undefined" && layerOperations.length === 0) {
67550
+ if (layer.deletedIDs.size > 0) {
67551
+ layerIDs.push(layer.id);
67552
+ }
67553
+ continue;
67554
+ }
67555
+ if (typeof layerValue !== "undefined" && !Array.isArray(layerValue)) {
67556
+ return {
67557
+ value: layerValue,
67558
+ kind,
67559
+ displayLayers: [layer.id]
67560
+ };
67561
+ }
67562
+ layerIDs.push(layer.id);
67563
+ if (layerOperations.length > 0) {
67564
+ for (const op of layerOperations) {
67565
+ if (isRemoveOperation(op)) {
67566
+ operations.remove.add(op.id);
67567
+ }
67568
+ if (isInsertOperation(op)) {
67569
+ operations.insert[op.location].unshift(op.id);
67570
+ }
67571
+ if (isDeleteOperation(op)) {
67572
+ return {
67573
+ value: void 0,
67574
+ kind: "unknown",
67575
+ displayLayers: []
67576
+ };
67577
+ }
67578
+ }
67579
+ }
67580
+ if (typeof layerValue === "undefined") {
67581
+ continue;
67582
+ }
67583
+ if (!operations.remove.size && !operations.insert.start.length && !operations.insert.end.length) {
67584
+ return { value: layerValue, displayLayers: layerIDs, kind: "link" };
67585
+ }
67586
+ return {
67587
+ value: [...operations.insert.start, ...layerValue, ...operations.insert.end].filter(
67588
+ (value) => !operations.remove.has(value)
67589
+ ),
67590
+ displayLayers: layerIDs,
67591
+ kind
67592
+ };
67593
+ }
67594
+ return {
67595
+ value: void 0,
67596
+ kind: "unknown",
67597
+ displayLayers: []
67598
+ };
67599
+ }
67600
+ writeLink(id, field, value) {
67601
+ return this.topLayer.writeLink(id, field, value);
67602
+ }
67603
+ writeField(id, field, value) {
67604
+ return this.topLayer.writeField(id, field, value);
67605
+ }
67606
+ resolveLayer(id) {
67607
+ let startingIndex = null;
67608
+ for (const [index, layer] of this.data.entries()) {
67609
+ if (layer.id !== id) {
67610
+ continue;
67611
+ }
67612
+ startingIndex = index - 1;
67613
+ this.data[index].optimistic = false;
67614
+ break;
67615
+ }
67616
+ if (startingIndex === null) {
67617
+ throw new Error("could not find layer with id: " + id);
67618
+ }
67619
+ if (startingIndex === -1) {
67620
+ startingIndex = 0;
67621
+ }
67622
+ if (this.data[startingIndex].optimistic) {
67623
+ startingIndex++;
67624
+ }
67625
+ const baseLayer = this.data[startingIndex];
67626
+ let layerIndex = startingIndex;
67627
+ while (layerIndex < this.data.length) {
67628
+ const layer = this.data[layerIndex++];
67629
+ if (layer.optimistic) {
67630
+ layerIndex--;
67631
+ break;
67632
+ }
67633
+ baseLayer.writeLayer(layer);
67634
+ }
67635
+ this.data.splice(startingIndex + 1, layerIndex - startingIndex - 1);
67636
+ }
67637
+ get topLayer() {
67638
+ if (this.data.length === 0) {
67639
+ this.createLayer();
67640
+ }
67641
+ if (this.data[this.data.length - 1]?.optimistic) {
67642
+ this.createLayer();
67643
+ }
67644
+ return this.data[this.data.length - 1];
67645
+ }
67646
+ };
67647
+ var Layer = class {
67648
+ id;
67649
+ optimistic = false;
67650
+ fields = {};
67651
+ links = {};
67652
+ operations = {};
67653
+ deletedIDs = /* @__PURE__ */ new Set();
67654
+ constructor(id) {
67655
+ this.id = id;
67656
+ }
67657
+ get(id, field) {
67658
+ if (typeof this.links[id]?.[field] !== "undefined") {
67659
+ return [this.links[id][field], "link"];
67660
+ }
67661
+ return [this.fields[id]?.[field], "scalar"];
67662
+ }
67663
+ getOperations(id, field) {
67664
+ if (this.operations[id]?.deleted) {
67665
+ return [
67666
+ {
67667
+ kind: OperationKind.delete,
67668
+ target: id
67669
+ }
67670
+ ];
67671
+ }
67672
+ if (this.operations[id]?.fields?.[field]) {
67673
+ return this.operations[id].fields[field];
67674
+ }
67675
+ }
67676
+ writeField(id, field, value) {
67677
+ this.fields[id] = {
67678
+ ...this.fields[id],
67679
+ [field]: value
67680
+ };
67681
+ return this.id;
67682
+ }
67683
+ writeLink(id, field, value) {
67684
+ const valueList = Array.isArray(value) ? value : [value];
67685
+ for (const value2 of flatten(valueList)) {
67686
+ if (!value2) {
67687
+ continue;
67688
+ }
67689
+ const fieldOperations = this.operations[id]?.fields[field];
67690
+ if (this.operations[value2]?.deleted || this.deletedIDs.has(value2)) {
67691
+ this.operations[value2] = {
67692
+ ...this.operations[value2],
67693
+ undoDeletesInList: [...this.operations[id]?.undoDeletesInList || [], field]
67694
+ };
67695
+ } else if (value2 && fieldOperations?.length > 0) {
67696
+ this.operations[id].fields[field] = fieldOperations.filter(
67697
+ (op) => op.kind !== "remove" || op.id !== value2
67698
+ );
67699
+ }
67700
+ }
67701
+ this.links[id] = {
67702
+ ...this.links[id],
67703
+ [field]: value
67704
+ };
67705
+ return this.id;
67706
+ }
67707
+ isDisplayLayer(displayLayers) {
67708
+ return displayLayers.length === 0 || displayLayers.includes(this.id) || Math.max(...displayLayers) < this.id;
67709
+ }
67710
+ clear() {
67711
+ this.links = {};
67712
+ this.fields = {};
67713
+ this.operations = {};
67714
+ this.deletedIDs = /* @__PURE__ */ new Set();
67715
+ }
67716
+ replaceID({ from, to }) {
67717
+ this.fields[to] = this.fields[from];
67718
+ this.links[to] = this.links[from];
67719
+ this.operations[to] = this.operations[from] || { fields: {} };
67720
+ if (this.deletedIDs.has(from)) {
67721
+ this.deletedIDs.add(to);
67722
+ }
67723
+ }
67724
+ removeUndefinedFields() {
67725
+ for (const [id, fields] of Object.entries(this.fields)) {
67726
+ for (const [field, value] of Object.entries(fields)) {
67727
+ if (typeof value === "undefined") {
67728
+ try {
67729
+ delete this.fields[id][field];
67730
+ } catch {
67731
+ }
67732
+ try {
67733
+ delete this.links[id][field];
67734
+ } catch {
67735
+ }
67736
+ }
67737
+ }
67738
+ if (Object.keys(fields || {}).length === 0) {
67739
+ delete this.fields[id];
67740
+ }
67741
+ if (Object.keys(this.links[id] || {}).length === 0) {
67742
+ delete this.links[id];
67743
+ }
67744
+ }
67745
+ }
67746
+ delete(id) {
67747
+ this.operations = {
67748
+ ...this.operations,
67749
+ [id]: {
67750
+ ...this.operations[id],
67751
+ deleted: true,
67752
+ undoDeletesInList: []
67753
+ }
67754
+ };
67755
+ this.deletedIDs.add(id);
67756
+ }
67757
+ deleteField(id, field) {
67758
+ this.fields[id] = {
67759
+ ...this.fields[id],
67760
+ [field]: void 0
67761
+ };
67762
+ }
67763
+ insert(id, field, where, target) {
67764
+ this.addFieldOperation(id, field, {
67765
+ kind: OperationKind.insert,
67766
+ id: target,
67767
+ location: where
67768
+ });
67769
+ }
67770
+ remove(id, field, target) {
67771
+ this.addFieldOperation(id, field, {
67772
+ kind: OperationKind.remove,
67773
+ id: target
67774
+ });
67775
+ }
67776
+ writeLayer(layer) {
67777
+ if (layer.id === this.id) {
67778
+ return;
67779
+ }
67780
+ for (const [id, ops] of Object.entries(layer.operations)) {
67781
+ const fields = {};
67782
+ for (const opMap of [this.operations[id], layer.operations[id]].filter(Boolean)) {
67783
+ for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
67784
+ fields[fieldName] = [...fields[fieldName] || [], ...operations];
67785
+ }
67786
+ }
67787
+ if (Object.keys(fields).length > 0) {
67788
+ this.operations[id] = {
67789
+ ...this.operations[id],
67790
+ fields
67791
+ };
67792
+ }
67793
+ if (ops?.deleted) {
67794
+ delete this.fields[id];
67795
+ delete this.links[id];
67796
+ }
67797
+ }
67798
+ for (const [id, values] of Object.entries(layer.fields)) {
67799
+ if (!values) {
67800
+ continue;
67801
+ }
67802
+ for (const [field, value] of Object.entries(values)) {
67803
+ this.writeField(id, field, value);
67804
+ }
67805
+ }
67806
+ for (const [id, values] of Object.entries(layer.links)) {
67807
+ if (!values) {
67808
+ continue;
67809
+ }
67810
+ for (const [field, value] of Object.entries(values)) {
67811
+ this.writeLink(id, field, value);
67812
+ }
67813
+ }
67814
+ layer.deletedIDs.forEach((v) => this.deletedIDs.add(v));
67815
+ }
67816
+ addFieldOperation(id, field, operation) {
67817
+ this.operations = {
67818
+ ...this.operations,
67819
+ [id]: {
67820
+ ...this.operations[id],
67821
+ fields: {
67822
+ [field]: [...this.operations[id]?.fields[field] || [], operation]
67823
+ }
67824
+ }
67825
+ };
67826
+ }
67827
+ };
67828
+ function isDeleteOperation(value) {
67829
+ return !!value && value.kind === OperationKind.delete;
67830
+ }
67831
+ function isInsertOperation(value) {
67832
+ return !!value && value.kind === OperationKind.insert;
67833
+ }
67834
+ function isRemoveOperation(value) {
67835
+ return !!value && value.kind === OperationKind.remove;
67836
+ }
67837
+ var OperationLocation = {
67838
+ start: "start",
67839
+ end: "end"
67840
+ };
67841
+ var OperationKind = {
67842
+ delete: "delete",
67843
+ insert: "insert",
67844
+ remove: "remove"
67845
+ };
67846
+
67847
+ // src/runtime/cache/stuff.ts
67848
+ function evaluateKey(key, variables = {}) {
67849
+ let evaluated = "";
67850
+ let varName = "";
67851
+ let inString = false;
67852
+ for (const char of key) {
67853
+ if (varName) {
67854
+ if (varChars.includes(char)) {
67855
+ varName += char;
67856
+ continue;
67857
+ }
67858
+ const value = variables[varName.slice(1)];
67859
+ evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
67860
+ varName = "";
67861
+ }
67862
+ if (char === "$" && !inString) {
67863
+ varName = "$";
67864
+ continue;
67865
+ }
67866
+ if (char === '"') {
67867
+ inString = !inString;
67868
+ }
67869
+ evaluated += char;
67870
+ }
67871
+ return evaluated;
67872
+ }
67873
+ var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
67874
+
67875
+ // src/runtime/cache/subscription.ts
67876
+ var InMemorySubscriptions = class {
67877
+ cache;
67878
+ constructor(cache) {
67879
+ this.cache = cache;
67880
+ }
67881
+ subscribers = {};
67882
+ referenceCounts = {};
67883
+ keyVersions = {};
67884
+ add({
67885
+ parent,
67886
+ spec,
67887
+ selection: selection2,
67888
+ variables,
67889
+ parentType
67890
+ }) {
67891
+ const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
67892
+ let targetSelection = getFieldsForType(selection2, __typename);
67893
+ for (const fieldSelection of Object.values(targetSelection || {})) {
67894
+ const { keyRaw, selection: innerSelection, type, list, filters } = fieldSelection;
67895
+ const key = evaluateKey(keyRaw, variables);
67896
+ let targetSelection2;
67897
+ if (innerSelection) {
67898
+ const __typename2 = this.cache._internal_unstable.storage.get(parent, "__typename").value;
67899
+ targetSelection2 = getFieldsForType(innerSelection, __typename2);
67900
+ }
67901
+ this.addFieldSubscription({
67902
+ id: parent,
67903
+ key,
67904
+ selection: [spec, targetSelection2],
67905
+ type
67906
+ });
67907
+ if (list) {
67908
+ this.registerList({
67909
+ list,
67910
+ filters,
67911
+ id: parent,
67912
+ key,
67913
+ variables,
67914
+ selection: innerSelection,
67915
+ parentType: parentType || spec.rootType
67916
+ });
67917
+ }
67918
+ if (innerSelection) {
67919
+ const { value: linkedRecord } = this.cache._internal_unstable.storage.get(
67920
+ parent,
67921
+ key
67922
+ );
67923
+ let children = !Array.isArray(linkedRecord) ? [linkedRecord] : flatten(linkedRecord) || [];
67924
+ for (const child of children) {
67925
+ if (!child) {
67926
+ continue;
67927
+ }
67928
+ this.add({
67929
+ parent: child,
67930
+ spec,
67931
+ selection: innerSelection,
67932
+ variables,
67933
+ parentType: type
67934
+ });
67935
+ }
67936
+ }
67937
+ }
67938
+ }
67939
+ addFieldSubscription({
67940
+ id,
67941
+ key,
67942
+ selection: selection2,
67943
+ type
67944
+ }) {
67945
+ const spec = selection2[0];
67946
+ if (!this.subscribers[id]) {
67947
+ this.subscribers[id] = {};
67948
+ }
67949
+ if (!this.subscribers[id][key]) {
67950
+ this.subscribers[id][key] = [];
67951
+ }
67952
+ if (!this.keyVersions[key]) {
67953
+ this.keyVersions[key] = /* @__PURE__ */ new Set();
67954
+ }
67955
+ this.keyVersions[key].add(key);
67956
+ if (!this.subscribers[id][key].map(([{ set }]) => set).includes(spec.set)) {
67957
+ this.subscribers[id][key].push([spec, selection2[1]]);
67958
+ }
67959
+ if (!this.referenceCounts[id]) {
67960
+ this.referenceCounts[id] = {};
67961
+ }
67962
+ if (!this.referenceCounts[id][key]) {
67963
+ this.referenceCounts[id][key] = /* @__PURE__ */ new Map();
67964
+ }
67965
+ const counts = this.referenceCounts[id][key];
67966
+ counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
67967
+ this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
67968
+ const { selection: innerSelection } = selection2[1]?.[key] ?? {};
67969
+ }
67970
+ registerList({
67971
+ list,
67972
+ id,
67973
+ key,
67974
+ parentType,
67975
+ selection: selection2,
67976
+ filters,
67977
+ variables
67978
+ }) {
67979
+ this.cache._internal_unstable.lists.add({
67980
+ name: list.name,
67981
+ connection: list.connection,
67982
+ recordID: id,
67983
+ recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
67984
+ listType: list.type,
67985
+ key,
67986
+ selection: selection2,
67987
+ filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
67988
+ return {
67989
+ ...acc,
67990
+ [key2]: kind !== "Variable" ? value : variables[value]
67991
+ };
67992
+ }, {})
67993
+ });
67994
+ }
67995
+ addMany({
67996
+ parent,
67997
+ variables,
67998
+ subscribers,
67999
+ parentType
68000
+ }) {
68001
+ for (const [spec, targetSelection] of subscribers) {
68002
+ for (const selection2 of Object.values(targetSelection ?? {})) {
68003
+ const {
68004
+ type: linkedType,
68005
+ keyRaw,
68006
+ selection: innerSelection,
68007
+ list,
68008
+ filters
68009
+ } = selection2;
68010
+ const key = evaluateKey(keyRaw, variables);
68011
+ const fieldSelection = innerSelection ? getFieldsForType(innerSelection, parentType) : void 0;
68012
+ this.addFieldSubscription({
68013
+ id: parent,
68014
+ key,
68015
+ selection: [spec, fieldSelection],
68016
+ type: linkedType
68017
+ });
68018
+ if (list) {
68019
+ this.registerList({
68020
+ list,
68021
+ filters,
68022
+ id: parent,
68023
+ key,
68024
+ variables,
68025
+ selection: innerSelection,
68026
+ parentType: parentType || spec.rootType
68027
+ });
68028
+ }
68029
+ const childSelection = selection2.selection;
68030
+ if (childSelection) {
68031
+ const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
68032
+ const children = !Array.isArray(link) ? [link] : flatten(link);
68033
+ for (const linkedRecord of children) {
68034
+ if (!linkedRecord) {
68035
+ continue;
68036
+ }
68037
+ const __typename = this.cache._internal_unstable.storage.get(
68038
+ linkedRecord,
68039
+ "__typename"
68040
+ ).value;
68041
+ let targetSelection2 = getFieldsForType(childSelection, __typename);
68042
+ this.addMany({
68043
+ parent: linkedRecord,
68044
+ variables,
68045
+ subscribers: subscribers.map(([sub]) => [sub, targetSelection2]),
68046
+ parentType: linkedType
68047
+ });
68048
+ }
68049
+ }
68050
+ }
68051
+ }
68052
+ }
68053
+ get(id, field) {
68054
+ return this.subscribers[id]?.[field] || [];
68055
+ }
68056
+ remove(id, selection2, targets, variables, visited = []) {
68057
+ visited.push(id);
68058
+ const linkedIDs = [];
68059
+ const __typename = this.cache._internal_unstable.storage.get(id, "__typename").value;
68060
+ let targetSelection = getFieldsForType(selection2, __typename);
68061
+ for (const fieldSelection of Object.values(targetSelection || {})) {
68062
+ const key = evaluateKey(fieldSelection.keyRaw, variables);
68063
+ this.removeSubscribers(id, key, targets);
68064
+ if (!fieldSelection.selection) {
68065
+ continue;
68066
+ }
68067
+ const { value: previousValue } = this.cache._internal_unstable.storage.get(id, key);
68068
+ const links = !Array.isArray(previousValue) ? [previousValue] : flatten(previousValue);
68069
+ for (const link of links) {
68070
+ if (link !== null) {
68071
+ linkedIDs.push([link, fieldSelection.selection || {}]);
68072
+ }
68073
+ }
68074
+ }
68075
+ for (const [linkedRecordID, linkFields] of linkedIDs) {
68076
+ this.remove(linkedRecordID, linkFields, targets, visited);
68077
+ }
68078
+ }
68079
+ removeSubscribers(id, fieldName, specs) {
68080
+ let targets = [];
68081
+ for (const spec of specs) {
68082
+ if (!this.referenceCounts[id]?.[fieldName]?.has(spec.set)) {
68083
+ continue;
68084
+ }
68085
+ const counts = this.referenceCounts[id][fieldName];
68086
+ const newVal = (counts.get(spec.set) || 0) - 1;
68087
+ counts.set(spec.set, newVal);
68088
+ if (newVal <= 0) {
68089
+ targets.push(spec.set);
68090
+ counts.delete(spec.set);
68091
+ }
68092
+ }
68093
+ if (this.subscribers[id]) {
68094
+ this.subscribers[id][fieldName] = this.get(id, fieldName).filter(
68095
+ ([{ set }]) => !targets.includes(set)
68096
+ );
68097
+ }
68098
+ }
68099
+ removeAllSubscribers(id, targets, visited = []) {
68100
+ visited.push(id);
68101
+ for (const field of Object.keys(this.subscribers[id] || [])) {
68102
+ const subscribers = targets || this.subscribers[id][field].map(([spec]) => spec);
68103
+ this.removeSubscribers(id, field, subscribers);
68104
+ const { value, kind } = this.cache._internal_unstable.storage.get(id, field);
68105
+ if (kind === "scalar") {
68106
+ continue;
68107
+ }
68108
+ const nextTargets = Array.isArray(value) ? flatten(value) : [value];
68109
+ for (const id2 of nextTargets) {
68110
+ if (visited.includes(id2)) {
68111
+ continue;
68112
+ }
68113
+ this.removeAllSubscribers(id2, subscribers, visited);
68114
+ }
68115
+ }
68116
+ }
68117
+ };
68118
+
68119
+ // src/runtime/cache/cache.ts
68120
+ var Cache = class {
68121
+ _internal_unstable;
68122
+ constructor(config4) {
68123
+ this._internal_unstable = new CacheInternal({
68124
+ cache: this,
68125
+ storage: new InMemoryStorage(),
68126
+ subscriptions: new InMemorySubscriptions(this),
68127
+ lists: new ListManager(this, rootID),
68128
+ lifetimes: new GarbageCollector(this),
68129
+ staleManager: new StaleManager(this),
68130
+ schema: new SchemaManager(this)
68131
+ });
68132
+ if (config4) {
68133
+ this.setConfig(defaultConfigValues(config4));
68134
+ }
68135
+ }
68136
+ write({
68137
+ layer: layerID,
68138
+ notifySubscribers = [],
68139
+ ...args
68140
+ }) {
68141
+ const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
68142
+ const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
68143
+ const notified = [];
68144
+ for (const spec of subscribers.concat(notifySubscribers)) {
68145
+ if (!notified.includes(spec.set)) {
68146
+ notified.push(spec.set);
68147
+ spec.set(
68148
+ this._internal_unstable.getSelection({
68149
+ parent: spec.parentID || rootID,
68150
+ selection: spec.selection,
68151
+ variables: spec.variables?.() || {}
68152
+ }).data
68153
+ );
68154
+ }
68155
+ }
68156
+ return subscribers;
68157
+ }
68158
+ read(...args) {
68159
+ const { data, partial, stale, hasData } = this._internal_unstable.getSelection(...args);
68160
+ if (!hasData) {
68161
+ return { data: null, partial: false, stale: false };
68162
+ }
68163
+ return {
68164
+ data,
68165
+ partial,
68166
+ stale
68167
+ };
68168
+ }
68169
+ subscribe(spec, variables = {}) {
68170
+ return this._internal_unstable.subscriptions.add({
68171
+ parent: spec.parentID || rootID,
68172
+ spec,
68173
+ selection: spec.selection,
68174
+ variables
68175
+ });
68176
+ }
68177
+ unsubscribe(spec, variables = {}) {
68178
+ return this._internal_unstable.subscriptions.remove(
68179
+ spec.parentID || rootID,
68180
+ spec.selection,
68181
+ [spec],
68182
+ variables
68183
+ );
68184
+ }
68185
+ list(name, parentID, allLists) {
68186
+ const handler = this._internal_unstable.lists.get(name, parentID, allLists);
68187
+ if (!handler) {
68188
+ throw new Error(
68189
+ `Cannot find list with name: ${name}${parentID ? " under parent " + parentID : ""}. Is it possible that the query is not mounted?`
68190
+ );
68191
+ }
68192
+ return handler;
68193
+ }
68194
+ delete(id) {
68195
+ this._internal_unstable.subscriptions.removeAllSubscribers(id);
68196
+ this._internal_unstable.lists.removeIDFromAllLists(id);
68197
+ this._internal_unstable.storage.delete(id);
68198
+ }
68199
+ setConfig(config4) {
68200
+ this._internal_unstable.setConfig(config4);
68201
+ }
68202
+ markTypeStale(options) {
68203
+ if (!options) {
68204
+ this._internal_unstable.staleManager.markAllStale();
68205
+ } else if (!options.field) {
68206
+ this._internal_unstable.staleManager.markTypeStale(options.type);
68207
+ } else {
68208
+ this._internal_unstable.staleManager.markTypeFieldStale(
68209
+ options.type,
68210
+ options.field,
68211
+ options.when
68212
+ );
68213
+ }
68214
+ }
68215
+ markRecordStale(id, options) {
68216
+ if (options.field) {
68217
+ const key = computeKey({ field: options.field, args: options.when ?? {} });
68218
+ this._internal_unstable.staleManager.markFieldStale(id, key);
68219
+ } else {
68220
+ this._internal_unstable.staleManager.markRecordStale(id);
68221
+ }
68222
+ }
68223
+ getFieldTime(id, field) {
68224
+ return this._internal_unstable.staleManager.getFieldTime(id, field);
68225
+ }
68226
+ };
68227
+ var CacheInternal = class {
68228
+ _disabled = false;
68229
+ config = defaultConfigValues({
68230
+ plugins: {
68231
+ "houdini-svelte": {
68232
+ client: ""
68233
+ }
68234
+ }
68235
+ });
68236
+ storage;
68237
+ subscriptions;
68238
+ lists;
68239
+ cache;
68240
+ lifetimes;
68241
+ staleManager;
68242
+ schema;
68243
+ constructor({
68244
+ storage,
68245
+ subscriptions,
68246
+ lists,
68247
+ cache,
68248
+ lifetimes,
68249
+ staleManager,
68250
+ schema
68251
+ }) {
68252
+ this.storage = storage;
68253
+ this.subscriptions = subscriptions;
68254
+ this.lists = lists;
68255
+ this.cache = cache;
68256
+ this.lifetimes = lifetimes;
68257
+ this.staleManager = staleManager;
68258
+ this.schema = schema;
68259
+ this._disabled = typeof globalThis.window === "undefined";
68260
+ try {
68261
+ if (process.env.HOUDINI_TEST === "true") {
68262
+ this._disabled = false;
68263
+ }
68264
+ } catch {
68265
+ }
68266
+ }
68267
+ setConfig(config4) {
68268
+ this.config = config4;
68269
+ }
68270
+ writeSelection({
68271
+ data,
68272
+ selection: selection2,
68273
+ variables = {},
68274
+ parent = rootID,
68275
+ applyUpdates,
68276
+ layer,
68277
+ toNotify = [],
68278
+ forceNotify,
68279
+ forceStale
68280
+ }) {
68281
+ if (this._disabled) {
68282
+ return [];
68283
+ }
68284
+ let targetSelection = getFieldsForType(selection2, data["__typename"]);
68285
+ for (const [field, value] of Object.entries(data)) {
68286
+ if (!selection2 || !targetSelection[field]) {
68287
+ throw new Error(
68288
+ "Could not find field listing in selection for " + field + " @ " + JSON.stringify(selection2)
68289
+ );
68290
+ }
68291
+ let {
68292
+ type: linkedType,
68293
+ keyRaw,
68294
+ selection: fieldSelection,
68295
+ operations,
68296
+ abstract: isAbstract,
68297
+ updates,
68298
+ nullable
68299
+ } = targetSelection[field];
68300
+ const key = evaluateKey(keyRaw, variables);
68301
+ this.schema.setFieldType({
68302
+ parent,
68303
+ key: keyRaw,
68304
+ type: linkedType,
68305
+ nullable,
68306
+ link: !!fieldSelection
68307
+ });
68308
+ const currentSubscribers = this.subscriptions.get(parent, key);
68309
+ const specs = currentSubscribers.map((sub) => sub[0]);
68310
+ const { value: previousValue, displayLayers } = this.storage.get(parent, key);
68311
+ const displayLayer = layer.isDisplayLayer(displayLayers);
68312
+ if (displayLayer) {
68313
+ this.lifetimes.resetLifetime(parent, key);
68314
+ if (forceStale) {
68315
+ this.staleManager.markFieldStale(parent, key);
68316
+ } else {
68317
+ this.staleManager.setFieldTimeToNow(parent, key);
68318
+ }
68319
+ }
68320
+ if (!fieldSelection) {
68321
+ let newValue = value;
68322
+ if (updates && applyUpdates && Array.isArray(value)) {
68323
+ for (const update of applyUpdates) {
68324
+ if (!updates.includes(update)) {
68325
+ continue;
68326
+ }
68327
+ if (update === "append") {
68328
+ newValue = (previousValue || []).concat(value);
68329
+ } else if (update === "prepend") {
68330
+ newValue = value.concat(previousValue || []);
68331
+ }
68332
+ }
68333
+ }
68334
+ if (updates && applyUpdates?.includes("prepend") && ["endCursor", "hasNextPage"].includes(key)) {
68335
+ newValue = previousValue;
68336
+ } else if (updates && applyUpdates?.includes("append") && ["startCursor", "hasPreviousPage"].includes(key)) {
68337
+ newValue = previousValue;
68338
+ }
68339
+ const valueChanged = !deepEquals(newValue, previousValue);
68340
+ if (displayLayer && (valueChanged || forceNotify)) {
68341
+ toNotify.push(...currentSubscribers);
68342
+ }
68343
+ layer.writeField(parent, key, newValue);
68344
+ } else if (value === null) {
68345
+ if (previousValue === null) {
68346
+ continue;
68347
+ }
68348
+ const previousLinks = flatten([previousValue]);
68349
+ for (const link of previousLinks) {
68350
+ this.subscriptions.remove(link, fieldSelection, specs, variables);
68351
+ }
68352
+ layer.writeLink(parent, key, null);
68353
+ toNotify.push(...currentSubscribers);
68354
+ } else if (value instanceof Object && !Array.isArray(value)) {
68355
+ if (isAbstract) {
68356
+ if (!value.__typename) {
68357
+ throw new Error(
68358
+ "Encountered interface type without __typename in the payload"
68359
+ );
68360
+ }
68361
+ linkedType = value.__typename;
68362
+ }
68363
+ const embedded = this.idFields(linkedType)?.filter(
68364
+ (field2) => typeof value[field2] === "undefined"
68365
+ ).length > 0;
68366
+ let linkedID = null;
68367
+ if (value !== null) {
68368
+ linkedID = !embedded ? this.id(linkedType, value) : `${parent}.${key}`;
68369
+ }
68370
+ let linkChange = linkedID !== previousValue;
68371
+ layer.writeLink(parent, key, linkedID);
68372
+ if (linkedID && displayLayer && (linkChange || forceNotify)) {
68373
+ if (previousValue && typeof previousValue === "string") {
68374
+ this.subscriptions.remove(previousValue, fieldSelection, specs, variables);
68375
+ }
68376
+ this.subscriptions.addMany({
68377
+ parent: linkedID,
68378
+ subscribers: currentSubscribers,
68379
+ variables,
68380
+ parentType: linkedType
68381
+ });
68382
+ toNotify.push(...currentSubscribers);
68383
+ }
68384
+ if (linkedID) {
68385
+ this.writeSelection({
68386
+ selection: fieldSelection,
68387
+ parent: linkedID,
68388
+ data: value,
68389
+ variables,
68390
+ toNotify,
68391
+ applyUpdates,
68392
+ layer,
68393
+ forceNotify
68394
+ });
68395
+ }
68396
+ } else if (Array.isArray(value) && (typeof previousValue === "undefined" || Array.isArray(previousValue))) {
68397
+ let oldIDs = [...previousValue || []];
68398
+ const emptyEdges = !updates ? [] : oldIDs.map((id) => {
68399
+ if (!id) {
68400
+ return "";
68401
+ }
68402
+ const { value: cursorField } = this.storage.get(id, "cursor");
68403
+ if (cursorField) {
68404
+ return "";
68405
+ }
68406
+ const { value: node } = this.storage.get(id, "node");
68407
+ if (!node) {
68408
+ return "";
68409
+ }
68410
+ return node;
68411
+ });
68412
+ let linkedIDs = [];
68413
+ const { newIDs, nestedIDs } = this.extractNestedListIDs({
68414
+ value,
68415
+ abstract: Boolean(isAbstract),
68416
+ specs: toNotify,
68417
+ applyUpdates,
68418
+ recordID: parent,
68419
+ key,
68420
+ linkedType,
68421
+ variables,
68422
+ fields: fieldSelection,
68423
+ layer,
68424
+ forceNotify
68425
+ });
68426
+ if (applyUpdates && updates) {
68427
+ if (key === "edges") {
68428
+ const newNodeIDs = [];
68429
+ for (const id of newIDs) {
68430
+ if (!id) {
68431
+ continue;
68432
+ }
68433
+ const { value: node } = this.storage.get(id, "node");
68434
+ if (typeof node !== "string") {
68435
+ continue;
68436
+ }
68437
+ if (!node || !this.storage.get(node, "__typename")) {
68438
+ continue;
68439
+ }
68440
+ newNodeIDs.push(node);
68441
+ }
68442
+ oldIDs = oldIDs.filter((id) => {
68443
+ if (!id) {
68444
+ return true;
68445
+ }
68446
+ const { value: value2 } = this.storage.get(id, "node");
68447
+ const node = value2;
68448
+ if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
68449
+ return false;
68450
+ }
68451
+ return true;
68452
+ });
68453
+ }
68454
+ for (const update of applyUpdates) {
68455
+ if (update !== "replace" && !updates.includes(update)) {
68456
+ continue;
68457
+ }
68458
+ if (update === "prepend") {
68459
+ linkedIDs = newIDs.concat(oldIDs);
68460
+ } else if (update === "append") {
68461
+ linkedIDs = oldIDs.concat(newIDs);
68462
+ } else if (update === "replace") {
68463
+ linkedIDs = newIDs;
68464
+ }
68465
+ }
68466
+ } else {
68467
+ linkedIDs = nestedIDs;
68468
+ }
68469
+ const contentChanged = !deepEquals(linkedIDs, oldIDs);
68470
+ if (contentChanged || forceNotify) {
68471
+ toNotify.push(...currentSubscribers);
68472
+ }
68473
+ for (const lostID of oldIDs) {
68474
+ if (linkedIDs.includes(lostID) || !lostID) {
68475
+ continue;
68476
+ }
68477
+ this.subscriptions.remove(lostID, fieldSelection, specs, variables);
68478
+ }
68479
+ if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
68480
+ layer.writeLink(parent, key, linkedIDs);
68481
+ }
68482
+ for (const id of newIDs.filter((id2) => !oldIDs.includes(id2))) {
68483
+ if (id == null) {
68484
+ continue;
68485
+ }
68486
+ this.subscriptions.addMany({
68487
+ parent: id,
68488
+ subscribers: currentSubscribers,
68489
+ variables,
68490
+ parentType: linkedType
68491
+ });
68492
+ }
68493
+ }
68494
+ for (const operation of operations || []) {
68495
+ let parentID;
68496
+ if (operation.parentID) {
68497
+ if (operation.parentID.kind !== "Variable") {
68498
+ parentID = operation.parentID.value;
68499
+ } else {
68500
+ const id = variables[operation.parentID.value];
68501
+ if (typeof id !== "string") {
68502
+ throw new Error("parentID value must be a string");
68503
+ }
68504
+ parentID = id;
68505
+ }
68506
+ }
68507
+ if (operation.list && !this.lists.get(operation.list, parentID, operation.target === "all")) {
68508
+ continue;
68509
+ }
68510
+ const targets = Array.isArray(value) ? value : [value];
68511
+ for (const target of targets) {
68512
+ if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
68513
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
68514
+ fieldSelection,
68515
+ target,
68516
+ variables,
68517
+ operation.position || "last"
68518
+ );
68519
+ } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
68520
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
68521
+ } else if (operation.action === "delete" && operation.type) {
68522
+ if (typeof target !== "string") {
68523
+ throw new Error("Cannot delete a record with a non-string ID");
68524
+ }
68525
+ const targetID = this.id(operation.type, target);
68526
+ if (!targetID) {
68527
+ continue;
68528
+ }
68529
+ this.cache.delete(targetID);
68530
+ } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
68531
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
68532
+ fieldSelection,
68533
+ target,
68534
+ variables,
68535
+ operation.position || "last"
68536
+ );
68537
+ }
68538
+ }
68539
+ }
68540
+ }
68541
+ return toNotify;
68542
+ }
68543
+ getSelection({
68544
+ selection: selection2,
68545
+ parent = rootID,
68546
+ variables,
68547
+ stepsFromConnection = null
68548
+ }) {
68549
+ if (parent === null) {
68550
+ return { data: null, partial: false, stale: false, hasData: true };
68551
+ }
68552
+ const target = {};
68553
+ let hasData = false;
68554
+ let partial = false;
68555
+ let cascadeNull = false;
68556
+ let stale = false;
68557
+ const typename = this.storage.get(parent, "__typename").value;
68558
+ let targetSelection = getFieldsForType(selection2, typename);
68559
+ for (const [
68560
+ attributeName,
68561
+ { type, keyRaw, selection: fieldSelection, nullable, list }
68562
+ ] of Object.entries(targetSelection)) {
68563
+ const key = evaluateKey(keyRaw, variables);
68564
+ const { value } = this.storage.get(parent, key);
68565
+ const dt_field = this.staleManager.getFieldTime(parent, key);
68566
+ if (dt_field === null) {
68567
+ stale = true;
68568
+ }
68569
+ let nextStep = stepsFromConnection;
68570
+ if (nextStep !== null) {
68571
+ if (nextStep >= 2) {
68572
+ nextStep = null;
68573
+ } else {
68574
+ nextStep += 1;
68575
+ }
68576
+ }
68577
+ if (list?.connection) {
68578
+ nextStep = 0;
68579
+ }
68580
+ const embeddedCursor = key === "cursor" && stepsFromConnection === 1;
68581
+ if (typeof value === "undefined" && !embeddedCursor) {
68582
+ partial = true;
68583
+ }
68584
+ if (typeof value === "undefined" || value === null) {
68585
+ target[attributeName] = null;
68586
+ if (typeof value !== "undefined") {
68587
+ hasData = true;
68588
+ }
68589
+ } else if (!fieldSelection) {
68590
+ const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
68591
+ if (fnUnmarshal) {
68592
+ target[attributeName] = fnUnmarshal(value);
68593
+ } else {
68594
+ target[attributeName] = value;
68595
+ }
68596
+ hasData = true;
68597
+ } else if (Array.isArray(value)) {
68598
+ const listValue = this.hydrateNestedList({
68599
+ fields: fieldSelection,
68600
+ variables,
68601
+ linkedList: value,
68602
+ stepsFromConnection: nextStep
68603
+ });
68604
+ target[attributeName] = listValue.data;
68605
+ if (listValue.partial) {
68606
+ partial = true;
68607
+ }
68608
+ if (listValue.stale) {
68609
+ stale = true;
68610
+ }
68611
+ if (listValue.hasData || value.length === 0) {
68612
+ hasData = true;
68613
+ }
68614
+ } else {
68615
+ const objectFields = this.getSelection({
68616
+ parent: value,
68617
+ selection: fieldSelection,
68618
+ variables,
68619
+ stepsFromConnection: nextStep
68620
+ });
68621
+ target[attributeName] = objectFields.data;
68622
+ if (objectFields.partial) {
68623
+ partial = true;
68624
+ }
68625
+ if (objectFields.stale) {
68626
+ stale = true;
68627
+ }
68628
+ if (objectFields.hasData) {
68629
+ hasData = true;
68630
+ }
68631
+ }
68632
+ if (target[attributeName] === null && !nullable && !embeddedCursor) {
68633
+ cascadeNull = true;
68634
+ }
68635
+ }
68636
+ return {
68637
+ data: cascadeNull ? null : target,
68638
+ partial: hasData && partial,
68639
+ stale: hasData && stale,
68640
+ hasData
68641
+ };
68642
+ }
68643
+ id(type, data) {
68644
+ const id = typeof data === "string" ? data : this.computeID(type, data);
68645
+ if (!id) {
68646
+ return null;
68647
+ }
68648
+ if (!type) {
68649
+ return id;
68650
+ }
68651
+ return type + ":" + id;
68652
+ }
68653
+ idFields(type) {
68654
+ return keyFieldsForType(this.config, type);
68655
+ }
68656
+ computeID(type, data) {
68657
+ return computeID(this.config, type, data);
68658
+ }
68659
+ hydrateNestedList({
68660
+ fields,
68661
+ variables,
68662
+ linkedList,
68663
+ stepsFromConnection
68664
+ }) {
68665
+ const result = [];
68666
+ let partialData = false;
68667
+ let stale = false;
68668
+ let hasValues = false;
68669
+ for (const entry of linkedList) {
68670
+ if (Array.isArray(entry)) {
68671
+ const nestedValue = this.hydrateNestedList({
68672
+ fields,
68673
+ variables,
68674
+ linkedList: entry,
68675
+ stepsFromConnection
68676
+ });
68677
+ result.push(nestedValue.data);
68678
+ if (nestedValue.partial) {
68679
+ partialData = true;
68680
+ }
68681
+ continue;
68682
+ }
68683
+ if (entry === null) {
68684
+ result.push(entry);
68685
+ continue;
68686
+ }
68687
+ const {
68688
+ data,
68689
+ partial,
68690
+ stale: local_stale,
68691
+ hasData
68692
+ } = this.getSelection({
68693
+ parent: entry,
68694
+ selection: fields,
68695
+ variables,
68696
+ stepsFromConnection
68697
+ });
68698
+ result.push(data);
68699
+ if (partial) {
68700
+ partialData = true;
68701
+ }
68702
+ if (local_stale) {
68703
+ stale = true;
68704
+ }
68705
+ if (hasData) {
68706
+ hasValues = true;
68707
+ }
68708
+ }
68709
+ return {
68710
+ data: result,
68711
+ partial: partialData,
68712
+ stale,
68713
+ hasData: hasValues
68714
+ };
68715
+ }
68716
+ extractNestedListIDs({
68717
+ value,
68718
+ abstract,
68719
+ recordID,
68720
+ key,
68721
+ linkedType,
68722
+ fields,
68723
+ variables,
68724
+ applyUpdates,
68725
+ specs,
68726
+ layer,
68727
+ forceNotify
68728
+ }) {
68729
+ const nestedIDs = [];
68730
+ const newIDs = [];
68731
+ for (const [i2, entry] of value.entries()) {
68732
+ if (Array.isArray(entry)) {
68733
+ const inner = this.extractNestedListIDs({
68734
+ value: entry,
68735
+ abstract,
68736
+ recordID,
68737
+ key,
68738
+ linkedType,
68739
+ fields,
68740
+ variables,
68741
+ applyUpdates,
68742
+ specs,
68743
+ layer,
68744
+ forceNotify
68745
+ });
68746
+ newIDs.push(...inner.newIDs);
68747
+ nestedIDs[i2] = inner.nestedIDs;
68748
+ continue;
68749
+ }
68750
+ if (entry === null || typeof entry === "undefined") {
68751
+ newIDs.push(null);
68752
+ nestedIDs[i2] = null;
68753
+ continue;
68754
+ }
68755
+ const entryObj = entry;
68756
+ let linkedID = `${recordID}.${key}[${this.storage.nextRank}]`;
68757
+ const embedded = this.idFields(linkedType)?.filter(
68758
+ (field) => typeof entry[field] === "undefined"
68759
+ ).length > 0;
68760
+ const typename = entryObj.__typename;
68761
+ let innerType = linkedType;
68762
+ if (abstract) {
68763
+ if (!typename) {
68764
+ throw new Error("Encountered interface type without __typename in the payload");
68765
+ }
68766
+ innerType = typename;
68767
+ }
68768
+ if (!embedded) {
68769
+ const id = this.id(innerType, entry);
68770
+ if (id) {
68771
+ linkedID = id;
68772
+ } else {
68773
+ continue;
68774
+ }
68775
+ }
68776
+ this.writeSelection({
68777
+ root: rootID,
68778
+ selection: fields,
68779
+ parent: linkedID,
68780
+ data: entryObj,
68781
+ variables,
68782
+ toNotify: specs,
68783
+ applyUpdates,
68784
+ layer,
68785
+ forceNotify
68786
+ });
68787
+ newIDs.push(linkedID);
68788
+ nestedIDs[i2] = linkedID;
68789
+ }
68790
+ return { newIDs, nestedIDs };
68791
+ }
68792
+ collectGarbage() {
68793
+ this.lifetimes.tick();
68794
+ if (this.storage.layerCount === 1) {
68795
+ this.storage.topLayer.removeUndefinedFields();
68796
+ }
68797
+ }
68798
+ };
68799
+ var rootID = "_ROOT_";
68800
+
68801
+ // src/runtime/cache/index.ts
68802
+ var cache_default = new Cache();
68803
+
68804
+ // src/runtime/client/utils/documentPlugins.ts
68805
+ var documentPlugin = (kind, source) => {
68806
+ return () => {
68807
+ const sourceHandlers = source();
68808
+ const enterWrapper = (handler) => {
68809
+ return !handler ? void 0 : (ctx, handlers) => {
68810
+ if (ctx.artifact.kind !== kind) {
68811
+ return handlers.next(ctx);
68812
+ }
68813
+ return handler(ctx, handlers);
68814
+ };
68815
+ };
68816
+ const exitWrapper = (handler) => {
68817
+ return !handler ? void 0 : (ctx, handlers) => {
68818
+ if (ctx.artifact.kind !== kind) {
68819
+ return handlers.resolve(ctx);
68820
+ }
68821
+ return handler(ctx, handlers);
68822
+ };
68823
+ };
68824
+ return {
68825
+ start: enterWrapper(sourceHandlers.start),
68826
+ network: enterWrapper(sourceHandlers.network),
68827
+ afterNetwork: exitWrapper(sourceHandlers.afterNetwork),
68828
+ end: exitWrapper(sourceHandlers.end),
68829
+ catch: sourceHandlers.catch ? (ctx, handlers) => sourceHandlers.catch(ctx, handlers) : void 0,
68830
+ cleanup: (...args) => sourceHandlers.cleanup?.(...args)
68831
+ };
68832
+ };
68833
+ };
68834
+
68835
+ // src/runtime/client/plugins/query.ts
68836
+ var query = documentPlugin(ArtifactKind.Query, function() {
68837
+ let subscriptionSpec = null;
68838
+ let lastVariables = null;
68839
+ let artifactName = "";
68840
+ return {
68841
+ start(ctx, { next }) {
68842
+ ctx.variables = {
68843
+ ...lastVariables,
68844
+ ...ctx.variables
68845
+ };
68846
+ next(ctx);
68847
+ },
68848
+ end(ctx, { resolve: resolve2, marshalVariables, variablesChanged }) {
68849
+ if (variablesChanged(ctx)) {
68850
+ artifactName = ctx.artifact.name;
68851
+ if (subscriptionSpec) {
68852
+ cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
68853
+ }
68854
+ lastVariables = { ...marshalVariables(ctx) };
68855
+ subscriptionSpec = {
68856
+ rootType: ctx.artifact.rootType,
68857
+ selection: ctx.artifact.selection,
68858
+ variables: () => lastVariables,
68859
+ set: (newValue) => {
68860
+ resolve2(ctx, {
68861
+ data: newValue,
68862
+ errors: null,
68863
+ fetching: false,
68864
+ partial: false,
68865
+ stale: false,
68866
+ source: DataSource.Cache,
68867
+ variables: ctx.variables ?? {}
68868
+ });
68869
+ }
68870
+ };
68871
+ cache_default.subscribe(subscriptionSpec, lastVariables ?? {});
68872
+ }
68873
+ resolve2(ctx);
68874
+ },
68875
+ cleanup() {
68876
+ if (subscriptionSpec) {
68877
+ cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() ?? {});
68878
+ lastVariables = null;
68879
+ }
68880
+ }
68881
+ };
68882
+ });
68883
+
68884
+ // src/runtime/client/plugins/mutation.ts
68885
+ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
68886
+ return {
68887
+ async start(ctx, { next, marshalVariables }) {
68888
+ const layer = cache_default._internal_unstable.storage.createLayer(true);
68889
+ const optimisticResponse = ctx.stuff.optimisticResponse;
68890
+ let toNotify = [];
68891
+ if (optimisticResponse) {
68892
+ toNotify = cache_default.write({
68893
+ selection: ctx.artifact.selection,
68894
+ data: await marshalSelection({
68895
+ selection: ctx.artifact.selection,
68896
+ data: optimisticResponse
68897
+ }),
68898
+ variables: marshalVariables(ctx),
68899
+ layer: layer.id
68900
+ });
68901
+ }
68902
+ ctx.cacheParams = {
68903
+ ...ctx.cacheParams,
68904
+ layer,
68905
+ notifySubscribers: toNotify,
68906
+ forceNotify: true
68907
+ };
68908
+ next(ctx);
68909
+ },
68910
+ afterNetwork(ctx, { resolve: resolve2 }) {
68911
+ ctx.cacheParams?.layer?.clear();
68912
+ resolve2(ctx);
68913
+ },
68914
+ end(ctx, { resolve: resolve2, value }) {
68915
+ const hasErrors = value.errors && value.errors.length > 0;
68916
+ if (hasErrors) {
68917
+ ctx.cacheParams?.layer?.clear();
68918
+ }
68919
+ if (ctx.cacheParams?.layer) {
68920
+ cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
68921
+ }
68922
+ resolve2(ctx);
68923
+ },
68924
+ catch(ctx, { error }) {
68925
+ if (ctx.cacheParams?.layer) {
68926
+ const { layer } = ctx.cacheParams;
68927
+ layer.clear();
68928
+ cache_default._internal_unstable.storage.resolveLayer(layer.id);
68929
+ }
68930
+ throw error;
68931
+ }
68932
+ };
68933
+ });
68934
+
66797
68935
  // src/lib/types.ts
66798
- var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
66799
- LogLevel2["Full"] = "full";
66800
- LogLevel2["Summary"] = "summary";
66801
- LogLevel2["ShortSummary"] = "short-summary";
66802
- LogLevel2["Quiet"] = "quiet";
66803
- return LogLevel2;
66804
- })(LogLevel || {});
68936
+ var LogLevel = {
68937
+ Full: "full",
68938
+ Summary: "summary",
68939
+ ShortSummary: "short-summary",
68940
+ Quiet: "quiet"
68941
+ };
66805
68942
 
66806
68943
  // src/lib/config.ts
66807
68944
  var currentDir = global.__dirname || dirname(fileURLToPath(import.meta.url));
@@ -66852,7 +68989,7 @@ var Config = class {
66852
68989
  scalars,
66853
68990
  cacheBufferSize,
66854
68991
  definitionsPath,
66855
- defaultCachePolicy = "CacheOrNetwork" /* CacheOrNetwork */,
68992
+ defaultCachePolicy = CachePolicy.CacheOrNetwork,
66856
68993
  defaultPartial = false,
66857
68994
  defaultListPosition = "append",
66858
68995
  defaultListTarget = null,
@@ -66874,7 +69011,7 @@ var Config = class {
66874
69011
  Object.values(LogLevel)
66875
69012
  )}`
66876
69013
  );
66877
- logLevel = "summary" /* Summary */;
69014
+ logLevel = LogLevel.Summary;
66878
69015
  }
66879
69016
  this.schemaPath = schemaPath;
66880
69017
  this.filepath = filepath;
@@ -66890,7 +69027,7 @@ var Config = class {
66890
69027
  this.internalListPosition = defaultListPosition === "append" ? "last" : "first";
66891
69028
  this.defaultListTarget = defaultListTarget;
66892
69029
  this.definitionsFolder = definitionsPath;
66893
- this.logLevel = (logLevel || "summary" /* Summary */).toLowerCase();
69030
+ this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
66894
69031
  this.defaultFragmentMasking = defaultFragmentMasking;
66895
69032
  this.routesDir = join2(this.projectRoot, "src", "routes");
66896
69033
  this.schemaPollInterval = watchSchema?.interval ?? 2e3;
@@ -67231,8 +69368,10 @@ var Config = class {
67231
69368
  return node.name.value === "CachePolicy";
67232
69369
  }
67233
69370
  isInternalDirective(name) {
67234
- const internalDirectives = this.#newSchemaInstance?.getDirectives().map((directive) => directive.name) ?? [];
67235
- return internalDirectives.includes(name) || this.isDeleteDirective(name);
69371
+ const internalDirectives = this.#newSchemaInstance?.getDirectives().reduce((list, directive) => {
69372
+ return list.concat(directive.name);
69373
+ }, []) ?? [];
69374
+ return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
67236
69375
  }
67237
69376
  isListFragment(name) {
67238
69377
  return name.endsWith(this.insertFragmentSuffix) || name.endsWith(this.removeFragmentSuffix) || name.endsWith(this.toggleFragmentSuffix);
@@ -67339,7 +69478,13 @@ async function getConfig({
67339
69478
  const plugins = pluginsNested.flat();
67340
69479
  for (const plugin2 of plugins) {
67341
69480
  if (plugin2.config) {
67342
- configFile = deepMerge(configPath, configFile, await plugin2.config(configFile));
69481
+ try {
69482
+ const configFactory = await import(plugin2.config);
69483
+ const newValue = typeof configFactory === "function" ? configFactory(configFile) : configFactory;
69484
+ configFile = deepMerge(configPath, configFile, newValue);
69485
+ } catch {
69486
+ console.log("could not load config file" + plugin2.config);
69487
+ }
67343
69488
  }
67344
69489
  }
67345
69490
  _config = new Config({
@@ -67497,6 +69642,8 @@ async function loadSchemaFile(schemaPath) {
67497
69642
  }
67498
69643
  return graphql2.buildClientSchema(jsonContents);
67499
69644
  }
69645
+ var emptySchema = graphql2.buildSchema("type Query { hello: String }");
69646
+ var defaultDirectives = emptySchema.getDirectives().map((dir) => dir.name);
67500
69647
 
67501
69648
  // src/lib/graphql.ts
67502
69649
  var graphql3 = __toESM(require_graphql2(), 1);
@@ -67513,7 +69660,7 @@ function getRootType(type) {
67513
69660
  function hashDocument({
67514
69661
  document
67515
69662
  }) {
67516
- const docString = typeof document === "string" ? document : document.artifact?.raw;
69663
+ const docString = typeof document === "string" ? document : document.originalString;
67517
69664
  return crypto.createHash("sha256").update(docString ?? "").digest("hex");
67518
69665
  }
67519
69666
  function parentTypeFromAncestors(schema, filepath, ancestors) {
@@ -68053,7 +70200,13 @@ var FieldCollection = class {
68053
70200
  if (fragment.selection.size === 0) {
68054
70201
  return [];
68055
70202
  }
68056
- fragment.astNode.selectionSet.selections = fragment.selection.toSelectionSet();
70203
+ fragment.astNode = {
70204
+ ...fragment.astNode,
70205
+ selectionSet: {
70206
+ ...fragment.astNode.selectionSet,
70207
+ selections: fragment.selection.toSelectionSet()
70208
+ }
70209
+ };
68057
70210
  return [fragment.astNode];
68058
70211
  }).concat(
68059
70212
  Object.values(this.fields).map((field) => {
@@ -68277,7 +70430,7 @@ async function fragmentVariables(config4, documents) {
68277
70430
  };
68278
70431
  documents.push({
68279
70432
  name: "generated::fragmentVariables",
68280
- kind: "HoudiniFragment" /* Fragment */,
70433
+ kind: ArtifactKind.Fragment,
68281
70434
  document: doc,
68282
70435
  originalParsed: doc,
68283
70436
  generateStore: false,
@@ -69204,7 +71357,7 @@ async function paginate(config4, documents) {
69204
71357
  ]
69205
71358
  };
69206
71359
  newDocs.push({
69207
- kind: "HoudiniQuery" /* Query */,
71360
+ kind: ArtifactKind.Query,
69208
71361
  filename: doc.filename,
69209
71362
  name: refetchQueryName,
69210
71363
  document: queryDoc,
@@ -69624,7 +71777,7 @@ async function addListFragments(config4, documents) {
69624
71777
  config4.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(graphql11.print).join("\n\n");
69625
71778
  documents.push({
69626
71779
  name: "generated::lists",
69627
- kind: "HoudiniFragment" /* Fragment */,
71780
+ kind: ArtifactKind.Fragment,
69628
71781
  generateArtifact: false,
69629
71782
  generateStore: false,
69630
71783
  document: generatedDoc,
@@ -69891,7 +72044,7 @@ function selection({
69891
72044
  (directive) => directive.name.value === config4.paginateDirective
69892
72045
  );
69893
72046
  if (paginated && document.refetch && document.refetch.method === "offset") {
69894
- fieldObj.updates = ["append" /* append */];
72047
+ fieldObj.updates = [RefetchUpdateMode.append];
69895
72048
  }
69896
72049
  let continueConnection = inConnection;
69897
72050
  if ([
@@ -69901,7 +72054,7 @@ function selection({
69901
72054
  "hasNextPage",
69902
72055
  "hasPreviousPage"
69903
72056
  ].includes(attributeName) && inConnection && document.refetch) {
69904
- fieldObj.updates = ["append" /* append */, "prepend" /* prepend */];
72057
+ fieldObj.updates = [RefetchUpdateMode.append, RefetchUpdateMode.prepend];
69905
72058
  }
69906
72059
  if (attributeName === "node" && inConnection) {
69907
72060
  continueConnection = false;
@@ -70080,7 +72233,7 @@ function artifactGenerator(stats) {
70080
72233
  );
70081
72234
  let rootType = "";
70082
72235
  let selectionSet;
70083
- if (docKind !== "HoudiniFragment" /* Fragment */) {
72236
+ if (docKind !== ArtifactKind.Fragment) {
70084
72237
  const operation = operations[0];
70085
72238
  if (operation.operation === "query") {
70086
72239
  rootType = config4.schema.getQueryType()?.name;
@@ -70113,7 +72266,7 @@ function artifactGenerator(stats) {
70113
72266
  let directive = fragments[0]?.directives?.find(
70114
72267
  (directive2) => directive2.name.value === config4.argumentsDirective
70115
72268
  );
70116
- if (docKind === "HoudiniFragment" /* Fragment */ && directive) {
72269
+ if (docKind === ArtifactKind.Fragment && directive) {
70117
72270
  inputs = fragmentArgumentsDefinitions(config4, doc.filename, fragments[0]);
70118
72271
  }
70119
72272
  const mergedSelection = flattenSelections({
@@ -70154,22 +72307,12 @@ function artifactGenerator(stats) {
70154
72307
  document: doc
70155
72308
  })
70156
72309
  };
70157
- const plugin_data = config4.plugins.reduce(
70158
- (prev, plugin2) => {
70159
- if (!plugin2.artifactData) {
70160
- return prev;
70161
- }
70162
- const result = { ...prev };
70163
- const dataToAdd = plugin2.artifactData({ config: config4, document: doc }) ?? {};
70164
- if (Object.keys(dataToAdd).length > 0) {
70165
- result[plugin2.name] = dataToAdd;
70166
- }
70167
- return result;
70168
- },
70169
- {}
70170
- );
70171
- if (Object.keys(plugin_data).length > 0) {
70172
- artifact.plugin_data = plugin_data;
72310
+ artifact.pluginData = {};
72311
+ for (const plugin2 of config4.plugins) {
72312
+ if (!plugin2.artifactData) {
72313
+ continue;
72314
+ }
72315
+ artifact.pluginData[plugin2.name] = plugin2.artifactData({ config: config4, document: doc }) ?? {};
70173
72316
  }
70174
72317
  if (inputs && inputs.length > 0) {
70175
72318
  artifact.input = inputObject(config4, inputs);
@@ -70230,7 +72373,7 @@ function artifactGenerator(stats) {
70230
72373
  return;
70231
72374
  }
70232
72375
  const match = existingArtifact && existingArtifact.match(/"HoudiniHash=(\w+)"/);
70233
- if (match && match[1] !== hash({ config: config4, document: doc })) {
72376
+ if (match && match[1] !== artifact.hash) {
70234
72377
  stats.changed.push(artifact.name);
70235
72378
  }
70236
72379
  stats.total.push(artifact.name);
@@ -70343,6 +72486,30 @@ async function generatePluginIndex({
70343
72486
  ]);
70344
72487
  }
70345
72488
 
72489
+ // src/codegen/generators/runtime/runtimeConfig.ts
72490
+ async function injectConfig({
72491
+ config: config4,
72492
+ content,
72493
+ importStatement,
72494
+ exportStatement
72495
+ }) {
72496
+ const extraConfigs = config4.plugins.reduce((acc, plugin2) => {
72497
+ if (!plugin2.config) {
72498
+ return acc;
72499
+ }
72500
+ return [...acc, plugin2.config];
72501
+ }, []);
72502
+ return extraConfigs.length > 0 ? `
72503
+ ${extraConfigs.map((plugin2, i2) => importStatement(plugin2, `plugin${i2}`))}
72504
+
72505
+ const plugins = [
72506
+ ${extraConfigs.map((_, i2) => `plugin${i2}`).join(",\n")}
72507
+ ]
72508
+
72509
+ ${exportStatement("plugins")}
72510
+ ` : content;
72511
+ }
72512
+
70346
72513
  // src/codegen/generators/runtime/index.ts
70347
72514
  async function runtimeGenerator(config4, docs) {
70348
72515
  const importStatement = config4.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
@@ -70353,6 +72520,9 @@ async function runtimeGenerator(config4, docs) {
70353
72520
  [path_exports.join(config4.runtimeSource, "lib", "constants.js")]: (content) => {
70354
72521
  return content.replace("SITE_URL", siteURL);
70355
72522
  },
72523
+ [path_exports.join(config4.runtimeSource, "imports", "pluginConfig.js")]: (content) => {
72524
+ return injectConfig({ config: config4, importStatement, exportStatement, content });
72525
+ },
70356
72526
  [path_exports.join(config4.runtimeSource, "imports", "config.js")]: (content) => {
70357
72527
  const configFilePath = path_exports.join(config4.runtimeDirectory, "imports", "config.js");
70358
72528
  const relativePath = path_exports.relative(path_exports.dirname(configFilePath), config4.filepath);
@@ -70461,11 +72631,13 @@ function scalarPropertyValue(config4, missingScalars, target) {
70461
72631
 
70462
72632
  // src/codegen/generators/typescript/typeReference.ts
70463
72633
  var AST8 = recast8.types.builders;
70464
- function tsTypeReference(config4, missingScalars, definition) {
72634
+ function tsTypeReference(config4, missingScalars, definition, body) {
70465
72635
  const { type, wrappers } = unwrapType(config4, definition.type);
70466
72636
  let result;
70467
72637
  if (graphql16.isScalarType(type)) {
70468
72638
  result = scalarPropertyValue(config4, missingScalars, type);
72639
+ } else if (graphql16.isEnumType(type)) {
72640
+ result = enumReference(config4, body, type.name);
70469
72641
  } else {
70470
72642
  result = AST8.tsTypeReference(AST8.identifier(type.name));
70471
72643
  }
@@ -70480,6 +72652,19 @@ function tsTypeReference(config4, missingScalars, definition) {
70480
72652
  }
70481
72653
  return result;
70482
72654
  }
72655
+ function enumReference(config4, body, name) {
72656
+ ensureImports({
72657
+ config: config4,
72658
+ body,
72659
+ import: ["ValueOf"],
72660
+ importKind: "type",
72661
+ sourceModule: "$houdini/runtime/lib/types"
72662
+ });
72663
+ return AST8.tsTypeReference(
72664
+ AST8.identifier("ValueOf"),
72665
+ AST8.tsTypeParameterInstantiation([AST8.tsTypeQuery(AST8.identifier(name))])
72666
+ );
72667
+ }
70483
72668
 
70484
72669
  // src/codegen/generators/typescript/addReferencedInputTypes.ts
70485
72670
  var AST9 = recast9.types.builders;
@@ -70511,7 +72696,7 @@ function addReferencedInputTypes(config4, filepath, body, visitedTypes, missingS
70511
72696
  members.push(
70512
72697
  AST9.tsPropertySignature(
70513
72698
  AST9.identifier(field.name),
70514
- AST9.tsTypeAnnotation(tsTypeReference(config4, missingScalars, field)),
72699
+ AST9.tsTypeAnnotation(tsTypeReference(config4, missingScalars, field, body)),
70515
72700
  graphql17.isNullableType(field.type)
70516
72701
  )
70517
72702
  );
@@ -70542,6 +72727,13 @@ function inlineType({
70542
72727
  if (graphql18.isScalarType(type)) {
70543
72728
  result = scalarPropertyValue(config4, missingScalars, type);
70544
72729
  } else if (graphql18.isEnumType(type)) {
72730
+ ensureImports({
72731
+ config: config4,
72732
+ body,
72733
+ importKind: "type",
72734
+ import: ["ValueOf"],
72735
+ sourceModule: "$houdini/runtime/lib/types"
72736
+ });
70545
72737
  if (!visitedTypes.has(type.name)) {
70546
72738
  ensureImports({
70547
72739
  config: config4,
@@ -70551,7 +72743,7 @@ function inlineType({
70551
72743
  });
70552
72744
  visitedTypes.add(type.name);
70553
72745
  }
70554
- result = AST10.tsTypeReference(AST10.identifier(type.name));
72746
+ result = enumReference(config4, body, type.name);
70555
72747
  } else if (selections) {
70556
72748
  const rootObj = type;
70557
72749
  const inlineFragments = {};
@@ -70984,7 +73176,7 @@ async function generateOperationTypeDefs(config4, filepath, body, definition, se
70984
73176
  return AST11.tsPropertySignature(
70985
73177
  AST11.identifier(definition2.variable.name.value),
70986
73178
  AST11.tsTypeAnnotation(
70987
- tsTypeReference(config4, missingScalars, definition2)
73179
+ tsTypeReference(config4, missingScalars, definition2, body)
70988
73180
  ),
70989
73181
  definition2.type.kind !== "NonNullType"
70990
73182
  );
@@ -71051,7 +73243,12 @@ async function generateFragmentTypeDefs(config4, filepath, body, selections, def
71051
73243
  return AST11.tsPropertySignature(
71052
73244
  AST11.identifier(definition2.variable.name.value),
71053
73245
  AST11.tsTypeAnnotation(
71054
- tsTypeReference(config4, missingScalars, definition2)
73246
+ tsTypeReference(
73247
+ config4,
73248
+ missingScalars,
73249
+ definition2,
73250
+ body
73251
+ )
71055
73252
  ),
71056
73253
  definition2.type.kind !== "NonNullType"
71057
73254
  );
@@ -71144,7 +73341,7 @@ async function imperativeCacheTypef(config4, docs) {
71144
73341
  ),
71145
73342
  AST12.tsPropertySignature(
71146
73343
  AST12.identifier("lists"),
71147
- AST12.tsTypeAnnotation(listDefinitions(config4, docs))
73344
+ AST12.tsTypeAnnotation(listDefinitions(config4, body, docs))
71148
73345
  ),
71149
73346
  AST12.tsPropertySignature(
71150
73347
  AST12.identifier("queries"),
@@ -71253,7 +73450,7 @@ function typeDefinitions(config4, body, docs, returnType) {
71253
73450
  const prop = AST12.tsPropertySignature(
71254
73451
  AST12.identifier(arg.name),
71255
73452
  AST12.tsTypeAnnotation(
71256
- tsTypeReference(config4, /* @__PURE__ */ new Set(), arg)
73453
+ tsTypeReference(config4, /* @__PURE__ */ new Set(), arg, body)
71257
73454
  )
71258
73455
  );
71259
73456
  const unwrapped2 = unwrapType(config4, arg.type);
@@ -71303,7 +73500,7 @@ function typeDefinitions(config4, body, docs, returnType) {
71303
73500
  })
71304
73501
  );
71305
73502
  }
71306
- function listDefinitions(config4, docs) {
73503
+ function listDefinitions(config4, body, docs) {
71307
73504
  const lists = [];
71308
73505
  const visitedLists = /* @__PURE__ */ new Set();
71309
73506
  for (const doc of docs) {
@@ -71360,7 +73557,8 @@ function listDefinitions(config4, docs) {
71360
73557
  tsTypeReference(
71361
73558
  config4,
71362
73559
  /* @__PURE__ */ new Set(),
71363
- arg
73560
+ arg,
73561
+ body
71364
73562
  )
71365
73563
  )
71366
73564
  );
@@ -71382,7 +73580,7 @@ function listDefinitions(config4, docs) {
71382
73580
  function queryDefinitions(config4, body, docs, returnType) {
71383
73581
  return AST12.tsTupleType(
71384
73582
  docs.reduce((prev, doc) => {
71385
- if (doc.kind !== "HoudiniQuery" /* Query */ || !doc.generateStore) {
73583
+ if (doc.kind !== ArtifactKind.Query || !doc.generateStore) {
71386
73584
  return prev;
71387
73585
  }
71388
73586
  const definition = doc.document.definitions.find(
@@ -71413,7 +73611,7 @@ function queryDefinitions(config4, body, docs, returnType) {
71413
73611
  }
71414
73612
  function fragmentListMap(config4, concreteTypes, body, docs, return_type) {
71415
73613
  return docs.reduce((prev, doc) => {
71416
- if (doc.kind !== "HoudiniFragment" /* Fragment */) {
73614
+ if (doc.kind !== ArtifactKind.Fragment) {
71417
73615
  return prev;
71418
73616
  }
71419
73617
  const definition = doc.document.definitions.find(
@@ -71552,13 +73750,19 @@ async function definitionsGenerator(config4) {
71552
73750
  })
71553
73751
  )
71554
73752
  ).code;
71555
- const typeDefinitions2 = enums.sort((a, b) => a.name.value.localeCompare(b.name.value)).map(
71556
- (definition) => `
71557
- export declare enum ${definition.name.value} {
71558
- ${definition.values?.map((value) => ` ${value.name.value} = "${value.name.value}"`).join(",\n")}
73753
+ const typeDefinitions2 = `
73754
+ type ValuesOf<T> = T[keyof T]
73755
+ ` + enums.sort((a, b) => a.name.value.localeCompare(b.name.value)).map((definition) => {
73756
+ const name = definition.name.value;
73757
+ const values = definition.values;
73758
+ return `
73759
+ export declare const ${name}: {
73760
+ ${values?.map((value) => ` readonly ${value.name.value}: "${value.name.value}";`).join("\n")}
71559
73761
  }
71560
- `
71561
- ).join("");
73762
+
73763
+ export type ${name}$options = ValuesOf<typeof ${name}>
73764
+ `;
73765
+ }).join("");
71562
73766
  const definitionsIndex = `
71563
73767
  export * from './enums.js'
71564
73768
  `;
@@ -71624,10 +73828,10 @@ var graphql22 = __toESM(require_graphql2(), 1);
71624
73828
  async function graphqlExtensions(config4, documents) {
71625
73829
  let internalSchema = `
71626
73830
  enum CachePolicy {
71627
- ${"CacheAndNetwork" /* CacheAndNetwork */}
71628
- ${"CacheOnly" /* CacheOnly */}
71629
- ${"CacheOrNetwork" /* CacheOrNetwork */}
71630
- ${"NetworkOnly" /* NetworkOnly */}
73831
+ ${CachePolicy.CacheAndNetwork}
73832
+ ${CachePolicy.CacheOnly}
73833
+ ${CachePolicy.CacheOrNetwork}
73834
+ ${CachePolicy.NetworkOnly}
71631
73835
  }
71632
73836
 
71633
73837
  """
@@ -72543,7 +74747,7 @@ function getAndVerifyNodeInterface(config4) {
72543
74747
  var nbInvalidNodeFieldMessageDisplayed = 0;
72544
74748
  function displayInvalidNodeFieldMessage(logLevel) {
72545
74749
  if (nbInvalidNodeFieldMessageDisplayed === 0) {
72546
- if (logLevel === "full" /* Full */) {
74750
+ if (logLevel === LogLevel.Full) {
72547
74751
  console.warn(invalidNodeFieldMessage);
72548
74752
  } else {
72549
74753
  console.warn(invalidNodeFieldMessageLight);
@@ -72711,7 +74915,7 @@ async function runPipeline2(config4, docs) {
72711
74915
  }
72712
74916
  const unchanged = artifactStats.total.length - artifactStats.changed.length - artifactStats.new.length - artifactStats.deleted.length;
72713
74917
  const printMessage = !config4.pluginMode || unchanged !== artifactStats.total.length;
72714
- if (!printMessage || config4.logLevel === "quiet" /* Quiet */) {
74918
+ if (!printMessage || config4.logLevel === LogLevel.Quiet) {
72715
74919
  if (error) {
72716
74920
  throw error;
72717
74921
  }
@@ -72725,14 +74929,14 @@ async function runPipeline2(config4, docs) {
72725
74929
  }
72726
74930
  if (artifactStats.total.length === 0) {
72727
74931
  console.log(`\u{1F4A1} No operation found. If that's unexpected, please check your config.`);
72728
- } else if (["summary" /* Summary */, "short-summary" /* ShortSummary */].includes(config4.logLevel)) {
74932
+ } else if (config4.logLevel == LogLevel.Summary || config4.logLevel == LogLevel.ShortSummary) {
72729
74933
  if (unchanged > 0 && printMessage && !config4.pluginMode) {
72730
74934
  console.log(`\u{1F4C3} Unchanged: ${unchanged}`);
72731
74935
  }
72732
74936
  logStyled("CREATED", artifactStats.new, config4.logLevel, config4.pluginMode);
72733
74937
  logStyled("UPDATED", artifactStats.changed, config4.logLevel, config4.pluginMode);
72734
74938
  logStyled("DELETED", artifactStats.deleted, config4.logLevel, config4.pluginMode);
72735
- } else if (config4.logLevel === "full" /* Full */) {
74939
+ } else if (config4.logLevel === LogLevel.Full) {
72736
74940
  for (const artifact of artifactStats.total) {
72737
74941
  let emoji = "\u{1F4C3}";
72738
74942
  if (artifactStats.changed.includes(artifact)) {
@@ -72842,14 +75046,14 @@ async function processGraphQLDocument(config4, filepath, document) {
72842
75046
  });
72843
75047
  }
72844
75048
  }
72845
- let kind = "HoudiniFragment" /* Fragment */;
75049
+ let kind = ArtifactKind.Fragment;
72846
75050
  if (operations.length === 1) {
72847
75051
  if (operations[0].kind === "OperationDefinition" && operations[0].operation === "query") {
72848
- kind = "HoudiniQuery" /* Query */;
75052
+ kind = ArtifactKind.Query;
72849
75053
  } else if (operations[0].kind === "OperationDefinition" && operations[0].operation === "mutation") {
72850
- kind = "HoudiniMutation" /* Mutation */;
75054
+ kind = ArtifactKind.Mutation;
72851
75055
  } else if (operations[0].kind === "OperationDefinition" && operations[0].operation === "subscription") {
72852
- kind = "HoudiniSubscription" /* Subscription */;
75056
+ kind = ArtifactKind.Subscription;
72853
75057
  }
72854
75058
  }
72855
75059
  return {
@@ -72894,7 +75098,7 @@ function logStyled(kind, stat3, logLevel, plugin2) {
72894
75098
  }
72895
75099
  }
72896
75100
  console.log(msg.join(""));
72897
- if (!plugin2 && logLevel === "summary" /* Summary */) {
75101
+ if (!plugin2 && logLevel === LogLevel.Summary) {
72898
75102
  for (const artifact of stat3.slice(0, nbToDisplay)) {
72899
75103
  console.log(` ${artifact}`);
72900
75104
  }
@@ -72942,16 +75146,18 @@ function Plugin(opts = {}) {
72942
75146
  content: code,
72943
75147
  watch_file: this.addWatchFile,
72944
75148
  config: config3,
72945
- filepath
75149
+ filepath,
75150
+ map: this.getCombinedSourcemap()
72946
75151
  };
72947
75152
  for (const plugin2 of config3.plugins) {
72948
75153
  if (!plugin2.transformFile) {
72949
75154
  continue;
72950
75155
  }
72951
- const { code: code2 } = await plugin2.transformFile(ctx);
75156
+ const { code: code2, map } = await plugin2.transformFile(ctx);
72952
75157
  ctx.content = code2;
75158
+ ctx.map = map;
72953
75159
  }
72954
- return { code: ctx.content };
75160
+ return { code: ctx.content, map: ctx.map };
72955
75161
  },
72956
75162
  async load(id, opts2, ...rest) {
72957
75163
  for (const plugin2 of config3.plugins) {