houdini 1.1.2 → 1.1.4-react.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 (41) hide show
  1. package/build/cmd-cjs/index.js +230 -158
  2. package/build/cmd-esm/index.js +230 -158
  3. package/build/codegen-cjs/index.js +217 -156
  4. package/build/codegen-esm/index.js +217 -156
  5. package/build/lib/config.d.ts +1 -0
  6. package/build/lib/parse.d.ts +2 -1
  7. package/build/lib/types.d.ts +4 -1
  8. package/build/lib-cjs/index.js +178 -146
  9. package/build/lib-esm/index.js +178 -146
  10. package/build/runtime/client/documentStore.d.ts +3 -0
  11. package/build/runtime/client/index.d.ts +1 -1
  12. package/build/runtime/lib/pageInfo.d.ts +7 -0
  13. package/build/runtime/lib/pagination.d.ts +29 -0
  14. package/build/runtime/lib/types.d.ts +46 -0
  15. package/build/runtime-cjs/client/documentStore.d.ts +3 -0
  16. package/build/runtime-cjs/client/documentStore.js +11 -6
  17. package/build/runtime-cjs/client/index.d.ts +1 -1
  18. package/build/runtime-cjs/client/plugins/cache.js +6 -3
  19. package/build/runtime-cjs/client/plugins/fragment.js +8 -1
  20. package/build/runtime-cjs/client/plugins/query.js +2 -1
  21. package/build/runtime-cjs/lib/pageInfo.d.ts +7 -0
  22. package/build/runtime-cjs/lib/pageInfo.js +79 -0
  23. package/build/runtime-cjs/lib/pagination.d.ts +29 -0
  24. package/build/runtime-cjs/lib/pagination.js +231 -0
  25. package/build/runtime-cjs/lib/types.d.ts +46 -0
  26. package/build/runtime-esm/client/documentStore.d.ts +3 -0
  27. package/build/runtime-esm/client/documentStore.js +11 -6
  28. package/build/runtime-esm/client/index.d.ts +1 -1
  29. package/build/runtime-esm/client/plugins/cache.js +6 -3
  30. package/build/runtime-esm/client/plugins/fragment.js +8 -1
  31. package/build/runtime-esm/client/plugins/query.js +2 -1
  32. package/build/runtime-esm/lib/pageInfo.d.ts +7 -0
  33. package/build/runtime-esm/lib/pageInfo.js +52 -0
  34. package/build/runtime-esm/lib/pagination.d.ts +29 -0
  35. package/build/runtime-esm/lib/pagination.js +206 -0
  36. package/build/runtime-esm/lib/types.d.ts +46 -0
  37. package/build/test-cjs/index.js +224 -155
  38. package/build/test-esm/index.js +224 -155
  39. package/build/vite-cjs/index.js +228 -156
  40. package/build/vite-esm/index.js +228 -156
  41. package/package.json +1 -1
@@ -2398,7 +2398,7 @@ var require_visitor = __commonJS({
2398
2398
  Object.defineProperty(exports, "__esModule", {
2399
2399
  value: true
2400
2400
  });
2401
- exports.visit = visit12;
2401
+ exports.visit = visit13;
2402
2402
  exports.visitInParallel = visitInParallel;
2403
2403
  exports.getVisitFn = getVisitFn;
2404
2404
  exports.BREAK = exports.QueryDocumentKeys = void 0;
@@ -2461,7 +2461,7 @@ var require_visitor = __commonJS({
2461
2461
  exports.QueryDocumentKeys = QueryDocumentKeys;
2462
2462
  var BREAK = Object.freeze({});
2463
2463
  exports.BREAK = BREAK;
2464
- function visit12(root, visitor) {
2464
+ function visit13(root, visitor) {
2465
2465
  var visitorKeys = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : QueryDocumentKeys;
2466
2466
  var stack = void 0;
2467
2467
  var inArray = Array.isArray(root);
@@ -37667,6 +37667,109 @@ var require_lib3 = __commonJS({
37667
37667
  }
37668
37668
  });
37669
37669
 
37670
+ // ../../node_modules/.pnpm/deepmerge@4.2.2/node_modules/deepmerge/dist/cjs.js
37671
+ var require_cjs = __commonJS({
37672
+ "../../node_modules/.pnpm/deepmerge@4.2.2/node_modules/deepmerge/dist/cjs.js"(exports, module2) {
37673
+ "use strict";
37674
+ var isMergeableObject = function isMergeableObject2(value) {
37675
+ return isNonNullObject(value) && !isSpecial(value);
37676
+ };
37677
+ function isNonNullObject(value) {
37678
+ return !!value && typeof value === "object";
37679
+ }
37680
+ function isSpecial(value) {
37681
+ var stringValue = Object.prototype.toString.call(value);
37682
+ return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
37683
+ }
37684
+ var canUseSymbol = typeof Symbol === "function" && Symbol.for;
37685
+ var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103;
37686
+ function isReactElement(value) {
37687
+ return value.$$typeof === REACT_ELEMENT_TYPE;
37688
+ }
37689
+ function emptyTarget(val) {
37690
+ return Array.isArray(val) ? [] : {};
37691
+ }
37692
+ function cloneUnlessOtherwiseSpecified(value, options) {
37693
+ return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
37694
+ }
37695
+ function defaultArrayMerge(target, source, options) {
37696
+ return target.concat(source).map(function(element) {
37697
+ return cloneUnlessOtherwiseSpecified(element, options);
37698
+ });
37699
+ }
37700
+ function getMergeFunction(key, options) {
37701
+ if (!options.customMerge) {
37702
+ return deepmerge;
37703
+ }
37704
+ var customMerge = options.customMerge(key);
37705
+ return typeof customMerge === "function" ? customMerge : deepmerge;
37706
+ }
37707
+ function getEnumerableOwnPropertySymbols(target) {
37708
+ return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
37709
+ return target.propertyIsEnumerable(symbol);
37710
+ }) : [];
37711
+ }
37712
+ function getKeys(target) {
37713
+ return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
37714
+ }
37715
+ function propertyIsOnObject(object, property) {
37716
+ try {
37717
+ return property in object;
37718
+ } catch (_) {
37719
+ return false;
37720
+ }
37721
+ }
37722
+ function propertyIsUnsafe(target, key) {
37723
+ return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
37724
+ }
37725
+ function mergeObject(target, source, options) {
37726
+ var destination = {};
37727
+ if (options.isMergeableObject(target)) {
37728
+ getKeys(target).forEach(function(key) {
37729
+ destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
37730
+ });
37731
+ }
37732
+ getKeys(source).forEach(function(key) {
37733
+ if (propertyIsUnsafe(target, key)) {
37734
+ return;
37735
+ }
37736
+ if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
37737
+ destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
37738
+ } else {
37739
+ destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
37740
+ }
37741
+ });
37742
+ return destination;
37743
+ }
37744
+ function deepmerge(target, source, options) {
37745
+ options = options || {};
37746
+ options.arrayMerge = options.arrayMerge || defaultArrayMerge;
37747
+ options.isMergeableObject = options.isMergeableObject || isMergeableObject;
37748
+ options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
37749
+ var sourceIsArray = Array.isArray(source);
37750
+ var targetIsArray = Array.isArray(target);
37751
+ var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
37752
+ if (!sourceAndTargetTypesMatch) {
37753
+ return cloneUnlessOtherwiseSpecified(source, options);
37754
+ } else if (sourceIsArray) {
37755
+ return options.arrayMerge(target, source, options);
37756
+ } else {
37757
+ return mergeObject(target, source, options);
37758
+ }
37759
+ }
37760
+ deepmerge.all = function deepmergeAll(array, options) {
37761
+ if (!Array.isArray(array)) {
37762
+ throw new Error("first argument should be an array");
37763
+ }
37764
+ return array.reduce(function(prev, next) {
37765
+ return deepmerge(prev, next, options);
37766
+ }, {});
37767
+ };
37768
+ var deepmerge_1 = deepmerge;
37769
+ module2.exports = deepmerge_1;
37770
+ }
37771
+ });
37772
+
37670
37773
  // ../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js
37671
37774
  var require_tslib = __commonJS({
37672
37775
  "../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js"(exports, module2) {
@@ -39936,7 +40039,7 @@ var require_path_visitor = __commonJS({
39936
40039
  }
39937
40040
  return target;
39938
40041
  }
39939
- PathVisitor.visit = function visit12(node, methods) {
40042
+ PathVisitor.visit = function visit13(node, methods) {
39940
40043
  return PathVisitor.fromMethodsObject(methods).visit(node);
39941
40044
  };
39942
40045
  var PVp = PathVisitor.prototype;
@@ -40127,7 +40230,7 @@ var require_path_visitor = __commonJS({
40127
40230
  this.needToCallTraverse = false;
40128
40231
  return visitChildren(path2, PathVisitor.fromMethodsObject(newVisitor || this.visitor));
40129
40232
  };
40130
- sharedContextProtoMethods.visit = function visit12(path2, newVisitor) {
40233
+ sharedContextProtoMethods.visit = function visit13(path2, newVisitor) {
40131
40234
  if (!(this instanceof this.Context)) {
40132
40235
  throw new Error("");
40133
40236
  }
@@ -41520,7 +41623,7 @@ var require_main = __commonJS({
41520
41623
  var someField = _a.someField;
41521
41624
  var Type = _a.Type;
41522
41625
  var use = _a.use;
41523
- var visit12 = _a.visit;
41626
+ var visit13 = _a.visit;
41524
41627
  exports.astNodesAreEquivalent = astNodesAreEquivalent;
41525
41628
  exports.builders = builders;
41526
41629
  exports.builtInTypes = builtInTypes;
@@ -41537,7 +41640,7 @@ var require_main = __commonJS({
41537
41640
  exports.someField = someField;
41538
41641
  exports.Type = Type;
41539
41642
  exports.use = use;
41540
- exports.visit = visit12;
41643
+ exports.visit = visit13;
41541
41644
  Object.assign(namedTypes_1.namedTypes, n);
41542
41645
  }
41543
41646
  });
@@ -53999,109 +54102,6 @@ var require_main2 = __commonJS({
53999
54102
  }
54000
54103
  });
54001
54104
 
54002
- // ../../node_modules/.pnpm/deepmerge@4.2.2/node_modules/deepmerge/dist/cjs.js
54003
- var require_cjs = __commonJS({
54004
- "../../node_modules/.pnpm/deepmerge@4.2.2/node_modules/deepmerge/dist/cjs.js"(exports, module2) {
54005
- "use strict";
54006
- var isMergeableObject = function isMergeableObject2(value) {
54007
- return isNonNullObject(value) && !isSpecial(value);
54008
- };
54009
- function isNonNullObject(value) {
54010
- return !!value && typeof value === "object";
54011
- }
54012
- function isSpecial(value) {
54013
- var stringValue = Object.prototype.toString.call(value);
54014
- return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
54015
- }
54016
- var canUseSymbol = typeof Symbol === "function" && Symbol.for;
54017
- var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103;
54018
- function isReactElement(value) {
54019
- return value.$$typeof === REACT_ELEMENT_TYPE;
54020
- }
54021
- function emptyTarget(val) {
54022
- return Array.isArray(val) ? [] : {};
54023
- }
54024
- function cloneUnlessOtherwiseSpecified(value, options) {
54025
- return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
54026
- }
54027
- function defaultArrayMerge(target, source, options) {
54028
- return target.concat(source).map(function(element) {
54029
- return cloneUnlessOtherwiseSpecified(element, options);
54030
- });
54031
- }
54032
- function getMergeFunction(key, options) {
54033
- if (!options.customMerge) {
54034
- return deepmerge;
54035
- }
54036
- var customMerge = options.customMerge(key);
54037
- return typeof customMerge === "function" ? customMerge : deepmerge;
54038
- }
54039
- function getEnumerableOwnPropertySymbols(target) {
54040
- return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
54041
- return target.propertyIsEnumerable(symbol);
54042
- }) : [];
54043
- }
54044
- function getKeys(target) {
54045
- return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
54046
- }
54047
- function propertyIsOnObject(object, property) {
54048
- try {
54049
- return property in object;
54050
- } catch (_) {
54051
- return false;
54052
- }
54053
- }
54054
- function propertyIsUnsafe(target, key) {
54055
- return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
54056
- }
54057
- function mergeObject(target, source, options) {
54058
- var destination = {};
54059
- if (options.isMergeableObject(target)) {
54060
- getKeys(target).forEach(function(key) {
54061
- destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
54062
- });
54063
- }
54064
- getKeys(source).forEach(function(key) {
54065
- if (propertyIsUnsafe(target, key)) {
54066
- return;
54067
- }
54068
- if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
54069
- destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
54070
- } else {
54071
- destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
54072
- }
54073
- });
54074
- return destination;
54075
- }
54076
- function deepmerge(target, source, options) {
54077
- options = options || {};
54078
- options.arrayMerge = options.arrayMerge || defaultArrayMerge;
54079
- options.isMergeableObject = options.isMergeableObject || isMergeableObject;
54080
- options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
54081
- var sourceIsArray = Array.isArray(source);
54082
- var targetIsArray = Array.isArray(target);
54083
- var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
54084
- if (!sourceAndTargetTypesMatch) {
54085
- return cloneUnlessOtherwiseSpecified(source, options);
54086
- } else if (sourceIsArray) {
54087
- return options.arrayMerge(target, source, options);
54088
- } else {
54089
- return mergeObject(target, source, options);
54090
- }
54091
- }
54092
- deepmerge.all = function deepmergeAll(array, options) {
54093
- if (!Array.isArray(array)) {
54094
- throw new Error("first argument should be an array");
54095
- }
54096
- return array.reduce(function(prev, next) {
54097
- return deepmerge(prev, next, options);
54098
- }, {});
54099
- };
54100
- var deepmerge_1 = deepmerge;
54101
- module2.exports = deepmerge_1;
54102
- }
54103
- });
54104
-
54105
54105
  // src/test/index.ts
54106
54106
  var test_exports = {};
54107
54107
  __export(test_exports, {
@@ -56623,10 +56623,11 @@ var query = documentPlugin(ArtifactKind.Query, function() {
56623
56623
  cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
56624
56624
  }
56625
56625
  lastVariables = { ...marshalVariables(ctx) };
56626
+ const variables = lastVariables;
56626
56627
  subscriptionSpec = {
56627
56628
  rootType: ctx.artifact.rootType,
56628
56629
  selection: ctx.artifact.selection,
56629
- variables: () => lastVariables,
56630
+ variables: () => variables,
56630
56631
  set: (newValue) => {
56631
56632
  resolve2(ctx, {
56632
56633
  data: newValue,
@@ -56655,12 +56656,17 @@ var query = documentPlugin(ArtifactKind.Query, function() {
56655
56656
  // src/runtime/client/plugins/fragment.ts
56656
56657
  var fragment = documentPlugin(ArtifactKind.Fragment, function() {
56657
56658
  let subscriptionSpec = null;
56659
+ let lastReference = null;
56658
56660
  return {
56659
56661
  start(ctx, { next, resolve: resolve2, variablesChanged, marshalVariables }) {
56660
56662
  if (!ctx.stuff.parentID) {
56661
56663
  return next(ctx);
56662
56664
  }
56663
- if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
56665
+ const currentReference = {
56666
+ parent: ctx.stuff.parentID,
56667
+ variables: marshalVariables(ctx)
56668
+ };
56669
+ if (!ctx.cacheParams?.disableSubscriptions && (!deepEquals(lastReference, currentReference) || variablesChanged(ctx))) {
56664
56670
  if (subscriptionSpec) {
56665
56671
  cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
56666
56672
  }
@@ -56683,6 +56689,7 @@ var fragment = documentPlugin(ArtifactKind.Fragment, function() {
56683
56689
  }
56684
56690
  };
56685
56691
  cache_default.subscribe(subscriptionSpec, variables);
56692
+ lastReference = currentReference;
56686
56693
  }
56687
56694
  next(ctx);
56688
56695
  },
@@ -57191,6 +57198,17 @@ var Config = class {
57191
57198
  }, []) ?? [];
57192
57199
  return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
57193
57200
  }
57201
+ needsRefetchArtifact(document) {
57202
+ let needsArtifact = false;
57203
+ graphql.visit(document, {
57204
+ Directive: (node) => {
57205
+ if ([this.paginateDirective].includes(node.name.value)) {
57206
+ needsArtifact = true;
57207
+ }
57208
+ }
57209
+ });
57210
+ return needsArtifact;
57211
+ }
57194
57212
  #fragmentVariableMaps;
57195
57213
  registerFragmentVariablesHash({
57196
57214
  hash,
@@ -57462,13 +57480,40 @@ var TypeWrapper = /* @__PURE__ */ ((TypeWrapper2) => {
57462
57480
 
57463
57481
  // src/lib/parse.ts
57464
57482
  var import_parser = __toESM(require_lib3(), 1);
57465
- async function parseJS(str) {
57483
+
57484
+ // src/lib/deepMerge.ts
57485
+ var import_deepmerge = __toESM(require_cjs(), 1);
57486
+ function deepMerge(filepath, ...targets) {
57487
+ try {
57488
+ if (targets.length === 1) {
57489
+ return targets[0];
57490
+ } else if (targets.length === 2) {
57491
+ return (0, import_deepmerge.default)(targets[0], targets[1], {
57492
+ arrayMerge: (source, update) => [...new Set(source.concat(update))]
57493
+ });
57494
+ }
57495
+ return deepMerge(filepath, targets[0], deepMerge(filepath, ...targets.slice(1)));
57496
+ } catch (e) {
57497
+ throw new HoudiniError({
57498
+ filepath,
57499
+ message: "could not merge: " + JSON.stringify(targets, null, 4),
57500
+ description: e.message
57501
+ });
57502
+ }
57503
+ }
57504
+
57505
+ // src/lib/parse.ts
57506
+ async function parseJS(str, config2) {
57507
+ const defaultConfig = {
57508
+ plugins: ["typescript"],
57509
+ sourceType: "module"
57510
+ };
57466
57511
  return {
57467
57512
  start: 0,
57468
- script: (0, import_parser.parse)(str || "", {
57469
- plugins: ["typescript"],
57470
- sourceType: "module"
57471
- }).program,
57513
+ script: (0, import_parser.parse)(
57514
+ str || "",
57515
+ config2 ? deepMerge("", defaultConfig, config2) : defaultConfig
57516
+ ).program,
57472
57517
  end: str.length
57473
57518
  };
57474
57519
  }
@@ -57518,27 +57563,6 @@ async function cleanupFiles(pathFolder, listOfObj) {
57518
57563
  return allFilesNotInList;
57519
57564
  }
57520
57565
 
57521
- // src/lib/deepMerge.ts
57522
- var import_deepmerge = __toESM(require_cjs(), 1);
57523
- function deepMerge(filepath, ...targets) {
57524
- try {
57525
- if (targets.length === 1) {
57526
- return targets[0];
57527
- } else if (targets.length === 2) {
57528
- return (0, import_deepmerge.default)(targets[0], targets[1], {
57529
- arrayMerge: (source, update) => [...new Set(source.concat(update))]
57530
- });
57531
- }
57532
- return deepMerge(filepath, targets[0], deepMerge(filepath, ...targets.slice(1)));
57533
- } catch (e) {
57534
- throw new HoudiniError({
57535
- filepath,
57536
- message: "could not merge: " + targets,
57537
- description: e.message
57538
- });
57539
- }
57540
- }
57541
-
57542
57566
  // src/codegen/generators/artifacts/index.ts
57543
57567
  var graphql12 = __toESM(require_graphql2(), 1);
57544
57568
  var recast5 = __toESM(require_main2(), 1);
@@ -60213,12 +60237,12 @@ ${exportStatement("config")}
60213
60237
  },
60214
60238
  [path_exports.join(config2.runtimeSource, "client", "plugins", "injectedPlugins.js")]: (content) => injectPlugins({ config: config2, content, importStatement, exportStatement })
60215
60239
  }),
60216
- ...config2.plugins.filter((plugin2) => plugin2.includeRuntime).map((plugin2) => generatePluginRuntime(config2, plugin2)),
60240
+ ...config2.plugins.filter((plugin2) => plugin2.includeRuntime).map((plugin2) => generatePluginRuntime(config2, docs, plugin2)),
60217
60241
  generatePluginIndex({ config: config2, exportStatement: exportStar })
60218
60242
  ]);
60219
60243
  await generateGraphqlReturnTypes(config2, docs);
60220
60244
  }
60221
- async function generatePluginRuntime(config2, plugin2) {
60245
+ async function generatePluginRuntime(config2, docs, plugin2) {
60222
60246
  if (houdini_mode.is_testing || !plugin2.includeRuntime) {
60223
60247
  return;
60224
60248
  }
@@ -60235,12 +60259,16 @@ async function generatePluginRuntime(config2, plugin2) {
60235
60259
  });
60236
60260
  }
60237
60261
  const pluginDir = config2.pluginRuntimeDirectory(plugin2.name);
60262
+ let transformMap = plugin2.transformRuntime ?? {};
60263
+ if (transformMap && typeof transformMap === "function") {
60264
+ transformMap = transformMap(docs);
60265
+ }
60238
60266
  await fs_exports.mkdirp(pluginDir);
60239
60267
  await fs_exports.recursiveCopy(
60240
60268
  runtime_path,
60241
60269
  pluginDir,
60242
60270
  Object.fromEntries(
60243
- Object.entries(plugin2.transformRuntime ?? {}).map(([key, value]) => [
60271
+ Object.entries(transformMap).map(([key, value]) => [
60244
60272
  path_exports.join(runtime_path, key),
60245
60273
  (content) => value({ config: config2, content })
60246
60274
  ])
@@ -60680,7 +60708,8 @@ async function generateDocumentTypes(config2, docs) {
60680
60708
  originalParsed: originalDocument,
60681
60709
  name,
60682
60710
  filename,
60683
- generateArtifact
60711
+ generateArtifact,
60712
+ artifact
60684
60713
  }) => {
60685
60714
  if (!generateArtifact) {
60686
60715
  return;
@@ -60719,6 +60748,14 @@ async function generateDocumentTypes(config2, docs) {
60719
60748
  missingScalars
60720
60749
  );
60721
60750
  }
60751
+ program.body.push(
60752
+ AST11.exportNamedDeclaration(
60753
+ AST11.tsTypeAliasDeclaration(
60754
+ AST11.identifier(`${name}$artifact`),
60755
+ convertToTs(serializeValue(artifact))
60756
+ )
60757
+ )
60758
+ );
60722
60759
  await fs_exports.writeFile(typeDefPath, recast11.print(program).code);
60723
60760
  typePaths.push(typeDefPath);
60724
60761
  }
@@ -60745,18 +60782,17 @@ export * from "${module2}"
60745
60782
  `;
60746
60783
  let indexContent = recast11.print(typeIndex).code;
60747
60784
  for (const plugin2 of config2.plugins) {
60748
- if (!plugin2.indexFile) {
60749
- continue;
60785
+ if (plugin2.indexFile) {
60786
+ indexContent = plugin2.indexFile({
60787
+ config: config2,
60788
+ content: indexContent,
60789
+ exportDefaultAs,
60790
+ exportStarFrom: exportStarFrom2,
60791
+ pluginRoot: config2.pluginDirectory(plugin2.name),
60792
+ typedef: true,
60793
+ documents: docs
60794
+ });
60750
60795
  }
60751
- indexContent = plugin2.indexFile({
60752
- config: config2,
60753
- content: indexContent,
60754
- exportDefaultAs,
60755
- exportStarFrom: exportStarFrom2,
60756
- pluginRoot: config2.pluginDirectory(plugin2.name),
60757
- typedef: true,
60758
- documents: docs
60759
- });
60760
60796
  if (plugin2.includeRuntime) {
60761
60797
  indexContent += exportStarFrom2({
60762
60798
  module: "./" + path_exports.relative(config2.rootDir, config2.pluginRuntimeDirectory(plugin2.name))
@@ -60788,6 +60824,42 @@ ${[...missingScalars].map(
60788
60824
  For more information, please visit this link: ${siteURL}/api/config#custom-scalars`);
60789
60825
  }
60790
60826
  }
60827
+ function convertToTs(source) {
60828
+ if (source.type === "ObjectExpression") {
60829
+ return AST11.tsTypeLiteral(
60830
+ source.properties.reduce(
60831
+ (props, prop) => {
60832
+ if (prop.type !== "ObjectProperty" || prop.key.type !== "StringLiteral" && prop.key.type === "Identifier") {
60833
+ return props;
60834
+ }
60835
+ return [
60836
+ ...props,
60837
+ AST11.tsPropertySignature(
60838
+ prop.key,
60839
+ AST11.tsTypeAnnotation(convertToTs(prop.value))
60840
+ )
60841
+ ];
60842
+ },
60843
+ []
60844
+ )
60845
+ );
60846
+ }
60847
+ if (source.type === "ArrayExpression") {
60848
+ return AST11.tsTupleType(
60849
+ source.elements.map((element) => convertToTs(element))
60850
+ );
60851
+ }
60852
+ if (source.type === "Literal" && typeof source.value === "boolean") {
60853
+ return AST11.tsLiteralType(AST11.booleanLiteral(source.value));
60854
+ }
60855
+ if (source.type === "Literal" && typeof source.value === "number") {
60856
+ return AST11.tsLiteralType(AST11.numericLiteral(source.value));
60857
+ }
60858
+ if (source.type === "Literal" && typeof source.value === "string") {
60859
+ return AST11.tsLiteralType(AST11.stringLiteral(source.value));
60860
+ }
60861
+ return AST11.tsLiteralType(source);
60862
+ }
60791
60863
  async function generateOperationTypeDefs(config2, filepath, body, definition, selections, visitedTypes, missingScalars) {
60792
60864
  let parentType = null;
60793
60865
  if (definition.operation === "query") {
@@ -61495,9 +61567,6 @@ async function writeIndexFile2(config2, docs) {
61495
61567
  module: relative2(config2.pluginRuntimeDirectory(plugin2.name))
61496
61568
  });
61497
61569
  }
61498
- if (!plugin2.indexFile) {
61499
- continue;
61500
- }
61501
61570
  }
61502
61571
  await fs_exports.writeFile(path_exports.join(config2.rootDir, "index.js"), body);
61503
61572
  }