houdini 1.1.3 → 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
@@ -2403,7 +2403,7 @@ var require_visitor = __commonJS({
2403
2403
  Object.defineProperty(exports, "__esModule", {
2404
2404
  value: true
2405
2405
  });
2406
- exports.visit = visit12;
2406
+ exports.visit = visit13;
2407
2407
  exports.visitInParallel = visitInParallel;
2408
2408
  exports.getVisitFn = getVisitFn;
2409
2409
  exports.BREAK = exports.QueryDocumentKeys = void 0;
@@ -2466,7 +2466,7 @@ var require_visitor = __commonJS({
2466
2466
  exports.QueryDocumentKeys = QueryDocumentKeys;
2467
2467
  var BREAK = Object.freeze({});
2468
2468
  exports.BREAK = BREAK;
2469
- function visit12(root, visitor) {
2469
+ function visit13(root, visitor) {
2470
2470
  var visitorKeys = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : QueryDocumentKeys;
2471
2471
  var stack = void 0;
2472
2472
  var inArray = Array.isArray(root);
@@ -37672,6 +37672,109 @@ var require_lib3 = __commonJS({
37672
37672
  }
37673
37673
  });
37674
37674
 
37675
+ // ../../node_modules/.pnpm/deepmerge@4.2.2/node_modules/deepmerge/dist/cjs.js
37676
+ var require_cjs = __commonJS({
37677
+ "../../node_modules/.pnpm/deepmerge@4.2.2/node_modules/deepmerge/dist/cjs.js"(exports, module) {
37678
+ "use strict";
37679
+ var isMergeableObject = function isMergeableObject2(value) {
37680
+ return isNonNullObject(value) && !isSpecial(value);
37681
+ };
37682
+ function isNonNullObject(value) {
37683
+ return !!value && typeof value === "object";
37684
+ }
37685
+ function isSpecial(value) {
37686
+ var stringValue = Object.prototype.toString.call(value);
37687
+ return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
37688
+ }
37689
+ var canUseSymbol = typeof Symbol === "function" && Symbol.for;
37690
+ var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103;
37691
+ function isReactElement(value) {
37692
+ return value.$$typeof === REACT_ELEMENT_TYPE;
37693
+ }
37694
+ function emptyTarget(val) {
37695
+ return Array.isArray(val) ? [] : {};
37696
+ }
37697
+ function cloneUnlessOtherwiseSpecified(value, options) {
37698
+ return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
37699
+ }
37700
+ function defaultArrayMerge(target, source, options) {
37701
+ return target.concat(source).map(function(element) {
37702
+ return cloneUnlessOtherwiseSpecified(element, options);
37703
+ });
37704
+ }
37705
+ function getMergeFunction(key, options) {
37706
+ if (!options.customMerge) {
37707
+ return deepmerge;
37708
+ }
37709
+ var customMerge = options.customMerge(key);
37710
+ return typeof customMerge === "function" ? customMerge : deepmerge;
37711
+ }
37712
+ function getEnumerableOwnPropertySymbols(target) {
37713
+ return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
37714
+ return target.propertyIsEnumerable(symbol);
37715
+ }) : [];
37716
+ }
37717
+ function getKeys(target) {
37718
+ return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
37719
+ }
37720
+ function propertyIsOnObject(object, property) {
37721
+ try {
37722
+ return property in object;
37723
+ } catch (_) {
37724
+ return false;
37725
+ }
37726
+ }
37727
+ function propertyIsUnsafe(target, key) {
37728
+ return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
37729
+ }
37730
+ function mergeObject(target, source, options) {
37731
+ var destination = {};
37732
+ if (options.isMergeableObject(target)) {
37733
+ getKeys(target).forEach(function(key) {
37734
+ destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
37735
+ });
37736
+ }
37737
+ getKeys(source).forEach(function(key) {
37738
+ if (propertyIsUnsafe(target, key)) {
37739
+ return;
37740
+ }
37741
+ if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
37742
+ destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
37743
+ } else {
37744
+ destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
37745
+ }
37746
+ });
37747
+ return destination;
37748
+ }
37749
+ function deepmerge(target, source, options) {
37750
+ options = options || {};
37751
+ options.arrayMerge = options.arrayMerge || defaultArrayMerge;
37752
+ options.isMergeableObject = options.isMergeableObject || isMergeableObject;
37753
+ options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
37754
+ var sourceIsArray = Array.isArray(source);
37755
+ var targetIsArray = Array.isArray(target);
37756
+ var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
37757
+ if (!sourceAndTargetTypesMatch) {
37758
+ return cloneUnlessOtherwiseSpecified(source, options);
37759
+ } else if (sourceIsArray) {
37760
+ return options.arrayMerge(target, source, options);
37761
+ } else {
37762
+ return mergeObject(target, source, options);
37763
+ }
37764
+ }
37765
+ deepmerge.all = function deepmergeAll(array, options) {
37766
+ if (!Array.isArray(array)) {
37767
+ throw new Error("first argument should be an array");
37768
+ }
37769
+ return array.reduce(function(prev, next) {
37770
+ return deepmerge(prev, next, options);
37771
+ }, {});
37772
+ };
37773
+ var deepmerge_1 = deepmerge;
37774
+ module.exports = deepmerge_1;
37775
+ }
37776
+ });
37777
+
37675
37778
  // ../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js
37676
37779
  var require_tslib = __commonJS({
37677
37780
  "../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js"(exports, module) {
@@ -39941,7 +40044,7 @@ var require_path_visitor = __commonJS({
39941
40044
  }
39942
40045
  return target;
39943
40046
  }
39944
- PathVisitor.visit = function visit12(node, methods) {
40047
+ PathVisitor.visit = function visit13(node, methods) {
39945
40048
  return PathVisitor.fromMethodsObject(methods).visit(node);
39946
40049
  };
39947
40050
  var PVp = PathVisitor.prototype;
@@ -40132,7 +40235,7 @@ var require_path_visitor = __commonJS({
40132
40235
  this.needToCallTraverse = false;
40133
40236
  return visitChildren(path2, PathVisitor.fromMethodsObject(newVisitor || this.visitor));
40134
40237
  };
40135
- sharedContextProtoMethods.visit = function visit12(path2, newVisitor) {
40238
+ sharedContextProtoMethods.visit = function visit13(path2, newVisitor) {
40136
40239
  if (!(this instanceof this.Context)) {
40137
40240
  throw new Error("");
40138
40241
  }
@@ -41525,7 +41628,7 @@ var require_main = __commonJS({
41525
41628
  var someField = _a.someField;
41526
41629
  var Type = _a.Type;
41527
41630
  var use = _a.use;
41528
- var visit12 = _a.visit;
41631
+ var visit13 = _a.visit;
41529
41632
  exports.astNodesAreEquivalent = astNodesAreEquivalent;
41530
41633
  exports.builders = builders;
41531
41634
  exports.builtInTypes = builtInTypes;
@@ -41542,7 +41645,7 @@ var require_main = __commonJS({
41542
41645
  exports.someField = someField;
41543
41646
  exports.Type = Type;
41544
41647
  exports.use = use;
41545
- exports.visit = visit12;
41648
+ exports.visit = visit13;
41546
41649
  Object.assign(namedTypes_1.namedTypes, n);
41547
41650
  }
41548
41651
  });
@@ -54004,109 +54107,6 @@ var require_main2 = __commonJS({
54004
54107
  }
54005
54108
  });
54006
54109
 
54007
- // ../../node_modules/.pnpm/deepmerge@4.2.2/node_modules/deepmerge/dist/cjs.js
54008
- var require_cjs = __commonJS({
54009
- "../../node_modules/.pnpm/deepmerge@4.2.2/node_modules/deepmerge/dist/cjs.js"(exports, module) {
54010
- "use strict";
54011
- var isMergeableObject = function isMergeableObject2(value) {
54012
- return isNonNullObject(value) && !isSpecial(value);
54013
- };
54014
- function isNonNullObject(value) {
54015
- return !!value && typeof value === "object";
54016
- }
54017
- function isSpecial(value) {
54018
- var stringValue = Object.prototype.toString.call(value);
54019
- return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
54020
- }
54021
- var canUseSymbol = typeof Symbol === "function" && Symbol.for;
54022
- var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103;
54023
- function isReactElement(value) {
54024
- return value.$$typeof === REACT_ELEMENT_TYPE;
54025
- }
54026
- function emptyTarget(val) {
54027
- return Array.isArray(val) ? [] : {};
54028
- }
54029
- function cloneUnlessOtherwiseSpecified(value, options) {
54030
- return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
54031
- }
54032
- function defaultArrayMerge(target, source, options) {
54033
- return target.concat(source).map(function(element) {
54034
- return cloneUnlessOtherwiseSpecified(element, options);
54035
- });
54036
- }
54037
- function getMergeFunction(key, options) {
54038
- if (!options.customMerge) {
54039
- return deepmerge;
54040
- }
54041
- var customMerge = options.customMerge(key);
54042
- return typeof customMerge === "function" ? customMerge : deepmerge;
54043
- }
54044
- function getEnumerableOwnPropertySymbols(target) {
54045
- return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
54046
- return target.propertyIsEnumerable(symbol);
54047
- }) : [];
54048
- }
54049
- function getKeys(target) {
54050
- return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
54051
- }
54052
- function propertyIsOnObject(object, property) {
54053
- try {
54054
- return property in object;
54055
- } catch (_) {
54056
- return false;
54057
- }
54058
- }
54059
- function propertyIsUnsafe(target, key) {
54060
- return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
54061
- }
54062
- function mergeObject(target, source, options) {
54063
- var destination = {};
54064
- if (options.isMergeableObject(target)) {
54065
- getKeys(target).forEach(function(key) {
54066
- destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
54067
- });
54068
- }
54069
- getKeys(source).forEach(function(key) {
54070
- if (propertyIsUnsafe(target, key)) {
54071
- return;
54072
- }
54073
- if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
54074
- destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
54075
- } else {
54076
- destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
54077
- }
54078
- });
54079
- return destination;
54080
- }
54081
- function deepmerge(target, source, options) {
54082
- options = options || {};
54083
- options.arrayMerge = options.arrayMerge || defaultArrayMerge;
54084
- options.isMergeableObject = options.isMergeableObject || isMergeableObject;
54085
- options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
54086
- var sourceIsArray = Array.isArray(source);
54087
- var targetIsArray = Array.isArray(target);
54088
- var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
54089
- if (!sourceAndTargetTypesMatch) {
54090
- return cloneUnlessOtherwiseSpecified(source, options);
54091
- } else if (sourceIsArray) {
54092
- return options.arrayMerge(target, source, options);
54093
- } else {
54094
- return mergeObject(target, source, options);
54095
- }
54096
- }
54097
- deepmerge.all = function deepmergeAll(array, options) {
54098
- if (!Array.isArray(array)) {
54099
- throw new Error("first argument should be an array");
54100
- }
54101
- return array.reduce(function(prev, next) {
54102
- return deepmerge(prev, next, options);
54103
- }, {});
54104
- };
54105
- var deepmerge_1 = deepmerge;
54106
- module.exports = deepmerge_1;
54107
- }
54108
- });
54109
-
54110
54110
  // src/test/index.ts
54111
54111
  var graphql25 = __toESM(require_graphql2(), 1);
54112
54112
  var import_memfs2 = __toESM(require_lib(), 1);
@@ -56619,10 +56619,11 @@ var query = documentPlugin(ArtifactKind.Query, function() {
56619
56619
  cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
56620
56620
  }
56621
56621
  lastVariables = { ...marshalVariables(ctx) };
56622
+ const variables = lastVariables;
56622
56623
  subscriptionSpec = {
56623
56624
  rootType: ctx.artifact.rootType,
56624
56625
  selection: ctx.artifact.selection,
56625
- variables: () => lastVariables,
56626
+ variables: () => variables,
56626
56627
  set: (newValue) => {
56627
56628
  resolve2(ctx, {
56628
56629
  data: newValue,
@@ -56651,12 +56652,17 @@ var query = documentPlugin(ArtifactKind.Query, function() {
56651
56652
  // src/runtime/client/plugins/fragment.ts
56652
56653
  var fragment = documentPlugin(ArtifactKind.Fragment, function() {
56653
56654
  let subscriptionSpec = null;
56655
+ let lastReference = null;
56654
56656
  return {
56655
56657
  start(ctx, { next, resolve: resolve2, variablesChanged, marshalVariables }) {
56656
56658
  if (!ctx.stuff.parentID) {
56657
56659
  return next(ctx);
56658
56660
  }
56659
- if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
56661
+ const currentReference = {
56662
+ parent: ctx.stuff.parentID,
56663
+ variables: marshalVariables(ctx)
56664
+ };
56665
+ if (!ctx.cacheParams?.disableSubscriptions && (!deepEquals(lastReference, currentReference) || variablesChanged(ctx))) {
56660
56666
  if (subscriptionSpec) {
56661
56667
  cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
56662
56668
  }
@@ -56679,6 +56685,7 @@ var fragment = documentPlugin(ArtifactKind.Fragment, function() {
56679
56685
  }
56680
56686
  };
56681
56687
  cache_default.subscribe(subscriptionSpec, variables);
56688
+ lastReference = currentReference;
56682
56689
  }
56683
56690
  next(ctx);
56684
56691
  },
@@ -57186,6 +57193,17 @@ var Config = class {
57186
57193
  }, []) ?? [];
57187
57194
  return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
57188
57195
  }
57196
+ needsRefetchArtifact(document) {
57197
+ let needsArtifact = false;
57198
+ graphql.visit(document, {
57199
+ Directive: (node) => {
57200
+ if ([this.paginateDirective].includes(node.name.value)) {
57201
+ needsArtifact = true;
57202
+ }
57203
+ }
57204
+ });
57205
+ return needsArtifact;
57206
+ }
57189
57207
  #fragmentVariableMaps;
57190
57208
  registerFragmentVariablesHash({
57191
57209
  hash,
@@ -57457,13 +57475,40 @@ var TypeWrapper = /* @__PURE__ */ ((TypeWrapper2) => {
57457
57475
 
57458
57476
  // src/lib/parse.ts
57459
57477
  var import_parser = __toESM(require_lib3(), 1);
57460
- async function parseJS(str) {
57478
+
57479
+ // src/lib/deepMerge.ts
57480
+ var import_deepmerge = __toESM(require_cjs(), 1);
57481
+ function deepMerge(filepath, ...targets) {
57482
+ try {
57483
+ if (targets.length === 1) {
57484
+ return targets[0];
57485
+ } else if (targets.length === 2) {
57486
+ return (0, import_deepmerge.default)(targets[0], targets[1], {
57487
+ arrayMerge: (source, update) => [...new Set(source.concat(update))]
57488
+ });
57489
+ }
57490
+ return deepMerge(filepath, targets[0], deepMerge(filepath, ...targets.slice(1)));
57491
+ } catch (e) {
57492
+ throw new HoudiniError({
57493
+ filepath,
57494
+ message: "could not merge: " + JSON.stringify(targets, null, 4),
57495
+ description: e.message
57496
+ });
57497
+ }
57498
+ }
57499
+
57500
+ // src/lib/parse.ts
57501
+ async function parseJS(str, config2) {
57502
+ const defaultConfig = {
57503
+ plugins: ["typescript"],
57504
+ sourceType: "module"
57505
+ };
57461
57506
  return {
57462
57507
  start: 0,
57463
- script: (0, import_parser.parse)(str || "", {
57464
- plugins: ["typescript"],
57465
- sourceType: "module"
57466
- }).program,
57508
+ script: (0, import_parser.parse)(
57509
+ str || "",
57510
+ config2 ? deepMerge("", defaultConfig, config2) : defaultConfig
57511
+ ).program,
57467
57512
  end: str.length
57468
57513
  };
57469
57514
  }
@@ -57513,27 +57558,6 @@ async function cleanupFiles(pathFolder, listOfObj) {
57513
57558
  return allFilesNotInList;
57514
57559
  }
57515
57560
 
57516
- // src/lib/deepMerge.ts
57517
- var import_deepmerge = __toESM(require_cjs(), 1);
57518
- function deepMerge(filepath, ...targets) {
57519
- try {
57520
- if (targets.length === 1) {
57521
- return targets[0];
57522
- } else if (targets.length === 2) {
57523
- return (0, import_deepmerge.default)(targets[0], targets[1], {
57524
- arrayMerge: (source, update) => [...new Set(source.concat(update))]
57525
- });
57526
- }
57527
- return deepMerge(filepath, targets[0], deepMerge(filepath, ...targets.slice(1)));
57528
- } catch (e) {
57529
- throw new HoudiniError({
57530
- filepath,
57531
- message: "could not merge: " + targets,
57532
- description: e.message
57533
- });
57534
- }
57535
- }
57536
-
57537
57561
  // src/codegen/generators/artifacts/index.ts
57538
57562
  var graphql12 = __toESM(require_graphql2(), 1);
57539
57563
  var recast5 = __toESM(require_main2(), 1);
@@ -60208,12 +60232,12 @@ ${exportStatement("config")}
60208
60232
  },
60209
60233
  [path_exports.join(config2.runtimeSource, "client", "plugins", "injectedPlugins.js")]: (content) => injectPlugins({ config: config2, content, importStatement, exportStatement })
60210
60234
  }),
60211
- ...config2.plugins.filter((plugin2) => plugin2.includeRuntime).map((plugin2) => generatePluginRuntime(config2, plugin2)),
60235
+ ...config2.plugins.filter((plugin2) => plugin2.includeRuntime).map((plugin2) => generatePluginRuntime(config2, docs, plugin2)),
60212
60236
  generatePluginIndex({ config: config2, exportStatement: exportStar })
60213
60237
  ]);
60214
60238
  await generateGraphqlReturnTypes(config2, docs);
60215
60239
  }
60216
- async function generatePluginRuntime(config2, plugin2) {
60240
+ async function generatePluginRuntime(config2, docs, plugin2) {
60217
60241
  if (houdini_mode.is_testing || !plugin2.includeRuntime) {
60218
60242
  return;
60219
60243
  }
@@ -60230,12 +60254,16 @@ async function generatePluginRuntime(config2, plugin2) {
60230
60254
  });
60231
60255
  }
60232
60256
  const pluginDir = config2.pluginRuntimeDirectory(plugin2.name);
60257
+ let transformMap = plugin2.transformRuntime ?? {};
60258
+ if (transformMap && typeof transformMap === "function") {
60259
+ transformMap = transformMap(docs);
60260
+ }
60233
60261
  await fs_exports.mkdirp(pluginDir);
60234
60262
  await fs_exports.recursiveCopy(
60235
60263
  runtime_path,
60236
60264
  pluginDir,
60237
60265
  Object.fromEntries(
60238
- Object.entries(plugin2.transformRuntime ?? {}).map(([key, value]) => [
60266
+ Object.entries(transformMap).map(([key, value]) => [
60239
60267
  path_exports.join(runtime_path, key),
60240
60268
  (content) => value({ config: config2, content })
60241
60269
  ])
@@ -60675,7 +60703,8 @@ async function generateDocumentTypes(config2, docs) {
60675
60703
  originalParsed: originalDocument,
60676
60704
  name,
60677
60705
  filename,
60678
- generateArtifact
60706
+ generateArtifact,
60707
+ artifact
60679
60708
  }) => {
60680
60709
  if (!generateArtifact) {
60681
60710
  return;
@@ -60714,6 +60743,14 @@ async function generateDocumentTypes(config2, docs) {
60714
60743
  missingScalars
60715
60744
  );
60716
60745
  }
60746
+ program.body.push(
60747
+ AST11.exportNamedDeclaration(
60748
+ AST11.tsTypeAliasDeclaration(
60749
+ AST11.identifier(`${name}$artifact`),
60750
+ convertToTs(serializeValue(artifact))
60751
+ )
60752
+ )
60753
+ );
60717
60754
  await fs_exports.writeFile(typeDefPath, recast11.print(program).code);
60718
60755
  typePaths.push(typeDefPath);
60719
60756
  }
@@ -60740,18 +60777,17 @@ export * from "${module}"
60740
60777
  `;
60741
60778
  let indexContent = recast11.print(typeIndex).code;
60742
60779
  for (const plugin2 of config2.plugins) {
60743
- if (!plugin2.indexFile) {
60744
- continue;
60780
+ if (plugin2.indexFile) {
60781
+ indexContent = plugin2.indexFile({
60782
+ config: config2,
60783
+ content: indexContent,
60784
+ exportDefaultAs,
60785
+ exportStarFrom: exportStarFrom2,
60786
+ pluginRoot: config2.pluginDirectory(plugin2.name),
60787
+ typedef: true,
60788
+ documents: docs
60789
+ });
60745
60790
  }
60746
- indexContent = plugin2.indexFile({
60747
- config: config2,
60748
- content: indexContent,
60749
- exportDefaultAs,
60750
- exportStarFrom: exportStarFrom2,
60751
- pluginRoot: config2.pluginDirectory(plugin2.name),
60752
- typedef: true,
60753
- documents: docs
60754
- });
60755
60791
  if (plugin2.includeRuntime) {
60756
60792
  indexContent += exportStarFrom2({
60757
60793
  module: "./" + path_exports.relative(config2.rootDir, config2.pluginRuntimeDirectory(plugin2.name))
@@ -60783,6 +60819,42 @@ ${[...missingScalars].map(
60783
60819
  For more information, please visit this link: ${siteURL}/api/config#custom-scalars`);
60784
60820
  }
60785
60821
  }
60822
+ function convertToTs(source) {
60823
+ if (source.type === "ObjectExpression") {
60824
+ return AST11.tsTypeLiteral(
60825
+ source.properties.reduce(
60826
+ (props, prop) => {
60827
+ if (prop.type !== "ObjectProperty" || prop.key.type !== "StringLiteral" && prop.key.type === "Identifier") {
60828
+ return props;
60829
+ }
60830
+ return [
60831
+ ...props,
60832
+ AST11.tsPropertySignature(
60833
+ prop.key,
60834
+ AST11.tsTypeAnnotation(convertToTs(prop.value))
60835
+ )
60836
+ ];
60837
+ },
60838
+ []
60839
+ )
60840
+ );
60841
+ }
60842
+ if (source.type === "ArrayExpression") {
60843
+ return AST11.tsTupleType(
60844
+ source.elements.map((element) => convertToTs(element))
60845
+ );
60846
+ }
60847
+ if (source.type === "Literal" && typeof source.value === "boolean") {
60848
+ return AST11.tsLiteralType(AST11.booleanLiteral(source.value));
60849
+ }
60850
+ if (source.type === "Literal" && typeof source.value === "number") {
60851
+ return AST11.tsLiteralType(AST11.numericLiteral(source.value));
60852
+ }
60853
+ if (source.type === "Literal" && typeof source.value === "string") {
60854
+ return AST11.tsLiteralType(AST11.stringLiteral(source.value));
60855
+ }
60856
+ return AST11.tsLiteralType(source);
60857
+ }
60786
60858
  async function generateOperationTypeDefs(config2, filepath, body, definition, selections, visitedTypes, missingScalars) {
60787
60859
  let parentType = null;
60788
60860
  if (definition.operation === "query") {
@@ -61490,9 +61562,6 @@ async function writeIndexFile2(config2, docs) {
61490
61562
  module: relative2(config2.pluginRuntimeDirectory(plugin2.name))
61491
61563
  });
61492
61564
  }
61493
- if (!plugin2.indexFile) {
61494
- continue;
61495
- }
61496
61565
  }
61497
61566
  await fs_exports.writeFile(path_exports.join(config2.rootDir, "index.js"), body);
61498
61567
  }