houdini 1.5.2 → 1.5.4

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.
@@ -61674,7 +61674,7 @@ function mergeSchemas(config) {
61674
61674
 
61675
61675
  // src/lib/config.ts
61676
61676
  var import_minimatch8 = __toESM(require_minimatch(), 1);
61677
- import * as graphql4 from "graphql";
61677
+ import * as graphql5 from "graphql";
61678
61678
  import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
61679
61679
 
61680
61680
  // src/runtime/imports/config.ts
@@ -68885,142 +68885,247 @@ function plugin(name, hooks) {
68885
68885
  }
68886
68886
 
68887
68887
  // src/lib/router/conventions.ts
68888
- var conventions_exports = {};
68889
- __export(conventions_exports, {
68890
- adapter_config_path: () => adapter_config_path,
68891
- app_component_path: () => app_component_path,
68892
- componentField_unit_path: () => componentField_unit_path,
68893
- fallback_unit_path: () => fallback_unit_path,
68894
- is_layout: () => is_layout,
68895
- layout_unit_path: () => layout_unit_path,
68896
- page_entries_dir: () => page_entries_dir,
68897
- page_entry_path: () => page_entry_path,
68898
- page_id: () => page_id,
68899
- page_unit_path: () => page_unit_path,
68900
- read_layoutQuery: () => read_layoutQuery,
68901
- read_layoutView: () => read_layoutView,
68902
- read_pageQuery: () => read_pageQuery,
68903
- read_pageView: () => read_pageView,
68904
- router_index_path: () => router_index_path,
68905
- router_path: () => router_path,
68906
- serialized_manifest_path: () => serialized_manifest_path,
68907
- server_adapter_path: () => server_adapter_path,
68908
- temp_dir: () => temp_dir,
68909
- units_dir: () => units_dir,
68910
- vite_render_path: () => vite_render_path
68911
- });
68912
- function router_path(config) {
68913
- return path_exports.join(base_dir(config), "Router.jsx");
68914
- }
68915
- function page_entry_path(config, id, base) {
68916
- return path_exports.join(page_entries_dir(config, base), `${id}.jsx`);
68917
- }
68918
- function server_adapter_path(config, base) {
68919
- return path_exports.join(units_dir(config, base), "render", "server.js");
68920
- }
68921
- function adapter_config_path(config, base) {
68922
- return path_exports.join(units_dir(config, base), "render", "config.js");
68888
+ function temp_dir(config, key) {
68889
+ return join2(config.rootDir, "temp", key);
68923
68890
  }
68924
- function vite_render_path(config, base) {
68925
- return path_exports.join(units_dir(config, base), "render", "vite.js");
68891
+
68892
+ // src/lib/router/manifest.ts
68893
+ var t2 = __toESM(require_lib5(), 1);
68894
+ import * as graphql3 from "graphql";
68895
+
68896
+ // src/lib/graphql.ts
68897
+ import * as graphql2 from "graphql";
68898
+ import crypto2 from "node:crypto";
68899
+ function getRootType(type) {
68900
+ if (graphql2.isNonNullType(type)) {
68901
+ return getRootType(type.ofType);
68902
+ }
68903
+ if (graphql2.isListType(type)) {
68904
+ return getRootType(type.ofType);
68905
+ }
68906
+ return type;
68926
68907
  }
68927
- function app_component_path(config, base) {
68928
- return path_exports.join(units_dir(config, base), "render", "App.jsx");
68908
+ function hashOriginal({ document }) {
68909
+ return hashDocument(document.originalString);
68929
68910
  }
68930
- function page_unit_path(config, id, base) {
68931
- return path_exports.join(page_units_dir(config, base), `${id}.jsx`);
68911
+ function hashRaw({ document }) {
68912
+ return hashDocument(document.artifact?.raw);
68932
68913
  }
68933
- function layout_unit_path(config, id, base) {
68934
- return path_exports.join(layout_units_dir(config, base), `${id}.jsx`);
68914
+ function hashDocument(str) {
68915
+ return crypto2.createHash("sha256").update(str || "").digest("hex");
68935
68916
  }
68936
- function componentField_unit_path(config, id, base) {
68937
- return path_exports.join(units_dir(config, base), "componentFields", `wrapper_${id}.jsx`);
68917
+ function parentField(ancestors) {
68918
+ return walkParentField([...ancestors].sort(() => -1));
68938
68919
  }
68939
- function fallback_unit_path(config, which, id, base) {
68940
- return path_exports.join(fallbacks_units_dir(config, which, base), `${id}.jsx`);
68920
+ function walkParentField(ancestors) {
68921
+ let head = ancestors.shift();
68922
+ if (Array.isArray(head) || head.kind === "SelectionSet") {
68923
+ return walkParentField(ancestors);
68924
+ }
68925
+ return head;
68941
68926
  }
68942
- async function read_pageQuery(base) {
68943
- const target = path_exports.join(base, "+page.gql");
68944
- return [target, await fs_exports.readFile(target)];
68927
+ function parentTypeFromAncestors(schema, filepath, ancestors) {
68928
+ const parents = [...ancestors];
68929
+ parents.reverse();
68930
+ return walkAncestors(schema, filepath, parents);
68945
68931
  }
68946
- async function read_pageView(base) {
68947
- for (const name of ["+page.tsx", "+page.jsx"]) {
68948
- let target = path_exports.join(base, name);
68949
- let result = await fs_exports.readFile(target);
68950
- if (result) {
68951
- return [target, result];
68932
+ function walkAncestors(schema, filepath, ancestors) {
68933
+ let head = ancestors.shift();
68934
+ if (Array.isArray(head)) {
68935
+ return walkAncestors(schema, filepath, ancestors);
68936
+ }
68937
+ if (!head) {
68938
+ throw new HoudiniError({ filepath, message: "Could not figure out type of field" });
68939
+ }
68940
+ if (head.kind === "OperationDefinition") {
68941
+ const operationType = {
68942
+ query: schema.getQueryType(),
68943
+ mutation: schema.getMutationType(),
68944
+ subscription: schema.getSubscriptionType()
68945
+ }[head.operation];
68946
+ if (!operationType) {
68947
+ throw new HoudiniError({ filepath, message: "Could not find operation type" });
68952
68948
  }
68949
+ return operationType;
68953
68950
  }
68954
- return [null, null];
68955
- }
68956
- async function read_layoutQuery(base) {
68957
- const target = path_exports.join(base, "+layout.gql");
68958
- return [target, await fs_exports.readFile(target)];
68959
- }
68960
- async function read_layoutView(base) {
68961
- for (const name of ["+layout.tsx", "+layout.jsx"]) {
68962
- let target = path_exports.join(base, name);
68963
- let result = await fs_exports.readFile(target);
68964
- if (result) {
68965
- return [target, result];
68951
+ if (head.kind === "FragmentDefinition") {
68952
+ const result = schema.getType(head.typeCondition.name.value);
68953
+ if (!result) {
68954
+ throw new HoudiniError({
68955
+ filepath,
68956
+ message: `Could not find definition for ${head.typeCondition.name.value} in the schema`
68957
+ });
68966
68958
  }
68959
+ return result;
68967
68960
  }
68968
- return [null, null];
68969
- }
68970
- function temp_dir(config, key) {
68971
- return path_exports.join(config.rootDir, "temp", key);
68972
- }
68973
- function router_index_path(config) {
68974
- return path_exports.join(config.routesDir, "..", "+index.jsx");
68961
+ if (head.kind === "FragmentSpread") {
68962
+ throw new Error("How the hell did this happen?");
68963
+ }
68964
+ const parent2 = walkAncestors(schema, filepath, ancestors);
68965
+ if (head.kind === "InlineFragment") {
68966
+ if (!head.typeCondition) {
68967
+ return parent2;
68968
+ }
68969
+ const wrapper = schema.getType(head.typeCondition.name.value);
68970
+ if (!wrapper) {
68971
+ throw new HoudiniError({
68972
+ filepath,
68973
+ message: "Could not find type with name: " + head.typeCondition.name.value
68974
+ });
68975
+ }
68976
+ return wrapper;
68977
+ }
68978
+ if (head.kind === "SelectionSet") {
68979
+ return parent2;
68980
+ }
68981
+ const field = parent2.getFields()[head.name.value];
68982
+ if (!field) {
68983
+ throw new HoudiniError({
68984
+ filepath,
68985
+ message: `Could not find definition of ${head.name.value} in ${parent2.toString()}`
68986
+ });
68987
+ }
68988
+ return getRootType(field.type);
68975
68989
  }
68976
- function is_layout(path4) {
68977
- return path4.endsWith("+layout.tsx") || path4.endsWith("+layout.jsx");
68990
+ function definitionFromAncestors(ancestors) {
68991
+ let parents = [...ancestors];
68992
+ parents.shift();
68993
+ let definition = parents.shift();
68994
+ while (Array.isArray(definition) && definition) {
68995
+ definition = parents.shift();
68996
+ }
68997
+ return { parents, definition };
68978
68998
  }
68979
- function page_id(path4) {
68980
- if (path4.endsWith("/") && path4.length > 1) {
68981
- path4 = path4.substring(0, path4.length - 1);
68982
- }
68983
- const special_chars = ["/", "]", "[", "(", ")", "-"];
68984
- const mask = "_";
68985
- let copy = "";
68986
- for (const char of path4) {
68987
- const match2 = special_chars.indexOf(char);
68988
- if (match2 !== -1) {
68989
- copy += mask;
68999
+ function formatErrors(e3, afterError) {
69000
+ const errors = Array.isArray(e3) ? e3 : [e3];
69001
+ for (const error of errors) {
69002
+ if ("filepath" in error && error.filepath) {
69003
+ const relative2 = relative(process.cwd(), error.filepath);
69004
+ console.error(`\u274C Encountered error in ${relative2}`);
69005
+ if (error.message) {
69006
+ console.error(error.message);
69007
+ }
68990
69008
  } else {
68991
- copy += char;
69009
+ console.error(`\u274C ${error.message}`);
69010
+ if ("description" in error && error.description) {
69011
+ console.error(`${error.description}`);
69012
+ }
68992
69013
  }
69014
+ afterError?.(e3);
68993
69015
  }
68994
- return copy;
68995
69016
  }
68996
- function page_entries_dir(config, base) {
68997
- return path_exports.join(units_dir(config, base), "entries");
68998
- }
68999
- function page_units_dir(config, base) {
69000
- return path_exports.join(units_dir(config, base), "pages");
69017
+ function unwrapType(config, type, wrappers = [], convertRuntimeScalars) {
69018
+ if (type.kind === "NonNullType") {
69019
+ return unwrapType(config, type.type, [TypeWrapper.NonNull, ...wrappers]);
69020
+ }
69021
+ if (type instanceof graphql2.GraphQLNonNull) {
69022
+ return unwrapType(config, type.ofType, [TypeWrapper.NonNull, ...wrappers]);
69023
+ }
69024
+ if (wrappers[0] !== TypeWrapper.NonNull) {
69025
+ wrappers.unshift(TypeWrapper.Nullable);
69026
+ }
69027
+ if (type.kind === "ListType") {
69028
+ return unwrapType(config, type.type, [TypeWrapper.List, ...wrappers]);
69029
+ }
69030
+ if (type instanceof graphql2.GraphQLList) {
69031
+ return unwrapType(config, type.ofType, [TypeWrapper.List, ...wrappers]);
69032
+ }
69033
+ if (convertRuntimeScalars && config.configFile.features?.runtimeScalars?.[type.name.value]) {
69034
+ type = config.schema.getType(
69035
+ config.configFile.features?.runtimeScalars?.[type.name.value].type
69036
+ );
69037
+ }
69038
+ const namedType = config.schema.getType(type.name.value || type.name);
69039
+ if (!namedType) {
69040
+ throw new Error("Unknown type: " + type.name.value || type.name);
69041
+ }
69042
+ return { type: namedType, wrappers };
69001
69043
  }
69002
- function layout_units_dir(config, base) {
69003
- return path_exports.join(units_dir(config, base), "layouts");
69044
+ function wrapType({
69045
+ type,
69046
+ wrappers
69047
+ }) {
69048
+ const head = wrappers[0];
69049
+ const tail = wrappers.slice(1);
69050
+ let kind = graphql2.Kind.NAMED_TYPE;
69051
+ if (head === TypeWrapper.List) {
69052
+ kind = graphql2.Kind.LIST_TYPE;
69053
+ } else if (head === TypeWrapper.NonNull) {
69054
+ kind = graphql2.Kind.NON_NULL_TYPE;
69055
+ }
69056
+ if (kind === "NamedType") {
69057
+ return {
69058
+ kind,
69059
+ name: {
69060
+ kind: graphql2.Kind.NAME,
69061
+ value: type.name
69062
+ }
69063
+ };
69064
+ }
69065
+ return {
69066
+ kind,
69067
+ type: wrapType({ type, wrappers: tail })
69068
+ };
69004
69069
  }
69005
- function fallbacks_units_dir(config, which, base) {
69006
- return path_exports.join(units_dir(config, base), "fallbacks", which);
69070
+ var TypeWrapper = /* @__PURE__ */ ((TypeWrapper2) => {
69071
+ TypeWrapper2["Nullable"] = "Nullable";
69072
+ TypeWrapper2["List"] = "List";
69073
+ TypeWrapper2["NonNull"] = "NonNull";
69074
+ return TypeWrapper2;
69075
+ })(TypeWrapper || {});
69076
+
69077
+ // src/lib/parse.ts
69078
+ var import_parser = __toESM(require_lib6(), 1);
69079
+ var import_recast = __toESM(require_main2(), 1);
69080
+
69081
+ // src/lib/deepMerge.ts
69082
+ var import_deepmerge = __toESM(require_cjs(), 1);
69083
+ function deepMerge2(filepath, ...targets) {
69084
+ try {
69085
+ if (targets.length === 1) {
69086
+ return targets[0];
69087
+ } else if (targets.length === 2) {
69088
+ return (0, import_deepmerge.default)(targets[0], targets[1], {
69089
+ arrayMerge: (source, update) => [...new Set(source.concat(update))]
69090
+ });
69091
+ }
69092
+ return deepMerge2(filepath, targets[0], deepMerge2(filepath, ...targets.slice(1)));
69093
+ } catch (e3) {
69094
+ throw new HoudiniError({
69095
+ filepath,
69096
+ message: "could not merge: " + JSON.stringify(targets, null, 4),
69097
+ description: e3.message
69098
+ });
69099
+ }
69007
69100
  }
69008
- function units_dir(config, base = base_dir(config)) {
69009
- return path_exports.join(base, "units");
69101
+
69102
+ // src/lib/parse.ts
69103
+ function parseJS(str, config) {
69104
+ const defaultConfig = {
69105
+ plugins: [
69106
+ "typescript",
69107
+ "importAssertions",
69108
+ "decorators-legacy",
69109
+ "explicitResourceManagement"
69110
+ ],
69111
+ sourceType: "module"
69112
+ };
69113
+ return (0, import_parser.parse)(str || "", config ? deepMerge2("", defaultConfig, config) : defaultConfig).program;
69010
69114
  }
69011
- function base_dir(config) {
69012
- return config.pluginDirectory("houdini-react");
69115
+ function parseJSON(str) {
69116
+ str = str.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m3, g3) => g3 ? "" : m3);
69117
+ return JSON.parse(str);
69013
69118
  }
69014
- function serialized_manifest_path(config, base = base_dir(config)) {
69015
- return path_exports.join(base, "manifest.json");
69119
+ async function printJS(script, options) {
69120
+ if (options?.pretty) {
69121
+ return (0, import_recast.prettyPrint)(script, options);
69122
+ } else {
69123
+ return (0, import_recast.print)(script, options);
69124
+ }
69016
69125
  }
69017
69126
 
69018
- // src/lib/router/manifest.ts
69019
- var t2 = __toESM(require_lib5(), 1);
69020
- import * as graphql2 from "graphql";
69021
-
69022
69127
  // src/lib/router/server.ts
69023
- import * as graphql3 from "graphql";
69128
+ import * as graphql4 from "graphql";
69024
69129
  import path3 from "node:path";
69025
69130
 
69026
69131
  // src/runtime/lib/flatten.ts
@@ -71369,14 +71474,14 @@ function isSecondaryBuild() {
71369
71474
  async function buildLocalSchema(config) {
71370
71475
  const { build } = await import("vite");
71371
71476
  const schema = path3.join(config.localApiDir, "+schema");
71372
- const outDir = conventions_exports.temp_dir(config, "schema");
71477
+ const outDir = temp_dir(config, "schema");
71373
71478
  process.env.HOUDINI_SECONDARY_BUILD = "true";
71374
71479
  try {
71375
- await fs_exports.remove(path3.join(outDir, "assets", "schema.js"));
71480
+ await remove(path3.join(outDir, "assets", "schema.js"));
71376
71481
  } catch {
71377
71482
  }
71378
71483
  try {
71379
- await fs_exports.mkdir(outDir);
71484
+ await mkdir(outDir);
71380
71485
  } catch {
71381
71486
  }
71382
71487
  await build({
@@ -71408,14 +71513,14 @@ async function loadLocalSchema(config) {
71408
71513
  }
71409
71514
  try {
71410
71515
  const { default: schema } = await import(path3.join(
71411
- conventions_exports.temp_dir(config, "schema"),
71516
+ temp_dir(config, "schema"),
71412
71517
  `schema.js?${Date.now().valueOf()}}`
71413
71518
  ));
71414
71519
  return schema;
71415
71520
  } catch (e3) {
71416
71521
  const message = "message" in e3 ? e3.message : e3;
71417
71522
  console.error("\u26A0\uFE0F Failed to load local schema: ", message);
71418
- return new graphql3.GraphQLSchema({});
71523
+ return new graphql4.GraphQLSchema({});
71419
71524
  }
71420
71525
  }
71421
71526
 
@@ -71490,7 +71595,7 @@ var Config = class {
71490
71595
  persistedQueriesPath
71491
71596
  } = this.configFile;
71492
71597
  if (typeof schema === "string") {
71493
- this.schema = graphql4.buildSchema(schema);
71598
+ this.schema = graphql5.buildSchema(schema);
71494
71599
  } else {
71495
71600
  this.schema = schema;
71496
71601
  }
@@ -71638,7 +71743,7 @@ var Config = class {
71638
71743
  set newSchema(value) {
71639
71744
  this.schemaString = value;
71640
71745
  if (value) {
71641
- this.#newSchemaInstance = graphql4.buildSchema(value);
71746
+ this.#newSchemaInstance = graphql5.buildSchema(value);
71642
71747
  } else {
71643
71748
  this.#newSchemaInstance = null;
71644
71749
  }
@@ -71728,21 +71833,21 @@ var Config = class {
71728
71833
  }
71729
71834
  documentName(document) {
71730
71835
  const operation = document.definitions.find(
71731
- ({ kind }) => kind === graphql4.Kind.OPERATION_DEFINITION
71836
+ ({ kind }) => kind === graphql5.Kind.OPERATION_DEFINITION
71732
71837
  );
71733
71838
  if (operation) {
71734
71839
  if (!operation.name) {
71735
- throw new Error("encountered operation with no name: " + graphql4.print(document));
71840
+ throw new Error("encountered operation with no name: " + graphql5.print(document));
71736
71841
  }
71737
71842
  return operation.name.value;
71738
71843
  }
71739
71844
  const fragmentDefinitions = document.definitions.filter(
71740
- ({ kind }) => kind === graphql4.Kind.FRAGMENT_DEFINITION
71845
+ ({ kind }) => kind === graphql5.Kind.FRAGMENT_DEFINITION
71741
71846
  );
71742
71847
  if (fragmentDefinitions.length) {
71743
71848
  return fragmentDefinitions[0].name.value;
71744
71849
  }
71745
- throw new Error("Could not generate artifact name for document: " + graphql4.print(document));
71850
+ throw new Error("Could not generate artifact name for document: " + graphql5.print(document));
71746
71851
  }
71747
71852
  isSelectionScalar(type) {
71748
71853
  return ["String", "Boolean", "Float", "ID", "Int"].concat(Object.keys(this.scalars || {})).includes(type);
@@ -71762,8 +71867,8 @@ var Config = class {
71762
71867
  relative(process.cwd(), filepath).replaceAll(sep2, "_").replace(".ts", ".js")
71763
71868
  );
71764
71869
  }
71765
- excludeFile(filepath) {
71766
- if (this.exclude.length > 0 && this.exclude.some((pattern) => (0, import_minimatch8.default)(filepath, pattern))) {
71870
+ excludeFile(filepath, { root = this.projectRoot }) {
71871
+ if (this.exclude.length > 0 && this.exclude.some((pattern) => (0, import_minimatch8.default)(filepath, join2(root, pattern)))) {
71767
71872
  return true;
71768
71873
  }
71769
71874
  for (const plugin2 of this.plugins) {
@@ -71792,7 +71897,7 @@ var Config = class {
71792
71897
  if (!included && !this.include.some((pattern) => (0, import_minimatch8.default)(filepath, join2(root, pattern)))) {
71793
71898
  return false;
71794
71899
  }
71795
- return !this.excludeFile(filepath);
71900
+ return !this.excludeFile(filepath, { root });
71796
71901
  }
71797
71902
  pluginRuntimeDirectory(name) {
71798
71903
  return join2(this.pluginDirectory(name), "runtime");
@@ -71952,10 +72057,10 @@ var Config = class {
71952
72057
  localDocumentData(document) {
71953
72058
  let paginated = false;
71954
72059
  let componentFields3 = [];
71955
- const typeInfo = new graphql4.TypeInfo(this.schema);
71956
- graphql4.visit(
72060
+ const typeInfo = new graphql5.TypeInfo(this.schema);
72061
+ graphql5.visit(
71957
72062
  document,
71958
- graphql4.visitWithTypeInfo(typeInfo, {
72063
+ graphql5.visitWithTypeInfo(typeInfo, {
71959
72064
  Directive: (node) => {
71960
72065
  if ([this.paginateDirective].includes(node.name.value)) {
71961
72066
  paginated = true;
@@ -72315,248 +72420,17 @@ async function loadSchemaFile(schemaPath) {
72315
72420
  }
72316
72421
  const contents = await readFile(schemaPath);
72317
72422
  if (schemaPath.endsWith("gql") || schemaPath.endsWith("graphql") || schemaPath.endsWith("graphqls")) {
72318
- return graphql4.buildSchema(contents);
72423
+ return graphql5.buildSchema(contents);
72319
72424
  }
72320
72425
  const jsonContents = JSON.parse(contents);
72321
72426
  if (jsonContents.data) {
72322
- return graphql4.buildClientSchema(jsonContents.data);
72427
+ return graphql5.buildClientSchema(jsonContents.data);
72323
72428
  }
72324
- return graphql4.buildClientSchema(jsonContents);
72429
+ return graphql5.buildClientSchema(jsonContents);
72325
72430
  }
72326
- var emptySchema = graphql4.buildSchema("type Query { hello: String }");
72431
+ var emptySchema = graphql5.buildSchema("type Query { hello: String }");
72327
72432
  var defaultDirectives = emptySchema.getDirectives().map((dir) => dir.name);
72328
72433
 
72329
- // src/lib/graphql.ts
72330
- import * as graphql5 from "graphql";
72331
- import crypto2 from "node:crypto";
72332
- function getRootType(type) {
72333
- if (graphql5.isNonNullType(type)) {
72334
- return getRootType(type.ofType);
72335
- }
72336
- if (graphql5.isListType(type)) {
72337
- return getRootType(type.ofType);
72338
- }
72339
- return type;
72340
- }
72341
- function hashOriginal({ document }) {
72342
- return hashDocument(document.originalString);
72343
- }
72344
- function hashRaw({ document }) {
72345
- return hashDocument(document.artifact?.raw);
72346
- }
72347
- function hashDocument(str) {
72348
- return crypto2.createHash("sha256").update(str || "").digest("hex");
72349
- }
72350
- function parentField(ancestors) {
72351
- return walkParentField([...ancestors].sort(() => -1));
72352
- }
72353
- function walkParentField(ancestors) {
72354
- let head = ancestors.shift();
72355
- if (Array.isArray(head) || head.kind === "SelectionSet") {
72356
- return walkParentField(ancestors);
72357
- }
72358
- return head;
72359
- }
72360
- function parentTypeFromAncestors(schema, filepath, ancestors) {
72361
- const parents = [...ancestors];
72362
- parents.reverse();
72363
- return walkAncestors(schema, filepath, parents);
72364
- }
72365
- function walkAncestors(schema, filepath, ancestors) {
72366
- let head = ancestors.shift();
72367
- if (Array.isArray(head)) {
72368
- return walkAncestors(schema, filepath, ancestors);
72369
- }
72370
- if (!head) {
72371
- throw new HoudiniError({ filepath, message: "Could not figure out type of field" });
72372
- }
72373
- if (head.kind === "OperationDefinition") {
72374
- const operationType = {
72375
- query: schema.getQueryType(),
72376
- mutation: schema.getMutationType(),
72377
- subscription: schema.getSubscriptionType()
72378
- }[head.operation];
72379
- if (!operationType) {
72380
- throw new HoudiniError({ filepath, message: "Could not find operation type" });
72381
- }
72382
- return operationType;
72383
- }
72384
- if (head.kind === "FragmentDefinition") {
72385
- const result = schema.getType(head.typeCondition.name.value);
72386
- if (!result) {
72387
- throw new HoudiniError({
72388
- filepath,
72389
- message: `Could not find definition for ${head.typeCondition.name.value} in the schema`
72390
- });
72391
- }
72392
- return result;
72393
- }
72394
- if (head.kind === "FragmentSpread") {
72395
- throw new Error("How the hell did this happen?");
72396
- }
72397
- const parent2 = walkAncestors(schema, filepath, ancestors);
72398
- if (head.kind === "InlineFragment") {
72399
- if (!head.typeCondition) {
72400
- return parent2;
72401
- }
72402
- const wrapper = schema.getType(head.typeCondition.name.value);
72403
- if (!wrapper) {
72404
- throw new HoudiniError({
72405
- filepath,
72406
- message: "Could not find type with name: " + head.typeCondition.name.value
72407
- });
72408
- }
72409
- return wrapper;
72410
- }
72411
- if (head.kind === "SelectionSet") {
72412
- return parent2;
72413
- }
72414
- const field = parent2.getFields()[head.name.value];
72415
- if (!field) {
72416
- throw new HoudiniError({
72417
- filepath,
72418
- message: `Could not find definition of ${head.name.value} in ${parent2.toString()}`
72419
- });
72420
- }
72421
- return getRootType(field.type);
72422
- }
72423
- function definitionFromAncestors(ancestors) {
72424
- let parents = [...ancestors];
72425
- parents.shift();
72426
- let definition = parents.shift();
72427
- while (Array.isArray(definition) && definition) {
72428
- definition = parents.shift();
72429
- }
72430
- return { parents, definition };
72431
- }
72432
- function formatErrors(e3, afterError) {
72433
- const errors = Array.isArray(e3) ? e3 : [e3];
72434
- for (const error of errors) {
72435
- if ("filepath" in error && error.filepath) {
72436
- const relative2 = relative(process.cwd(), error.filepath);
72437
- console.error(`\u274C Encountered error in ${relative2}`);
72438
- if (error.message) {
72439
- console.error(error.message);
72440
- }
72441
- } else {
72442
- console.error(`\u274C ${error.message}`);
72443
- if ("description" in error && error.description) {
72444
- console.error(`${error.description}`);
72445
- }
72446
- }
72447
- afterError?.(e3);
72448
- }
72449
- }
72450
- function unwrapType(config, type, wrappers = [], convertRuntimeScalars) {
72451
- if (type.kind === "NonNullType") {
72452
- return unwrapType(config, type.type, [TypeWrapper.NonNull, ...wrappers]);
72453
- }
72454
- if (type instanceof graphql5.GraphQLNonNull) {
72455
- return unwrapType(config, type.ofType, [TypeWrapper.NonNull, ...wrappers]);
72456
- }
72457
- if (wrappers[0] !== TypeWrapper.NonNull) {
72458
- wrappers.unshift(TypeWrapper.Nullable);
72459
- }
72460
- if (type.kind === "ListType") {
72461
- return unwrapType(config, type.type, [TypeWrapper.List, ...wrappers]);
72462
- }
72463
- if (type instanceof graphql5.GraphQLList) {
72464
- return unwrapType(config, type.ofType, [TypeWrapper.List, ...wrappers]);
72465
- }
72466
- if (convertRuntimeScalars && config.configFile.features?.runtimeScalars?.[type.name.value]) {
72467
- type = config.schema.getType(
72468
- config.configFile.features?.runtimeScalars?.[type.name.value].type
72469
- );
72470
- }
72471
- const namedType = config.schema.getType(type.name.value || type.name);
72472
- if (!namedType) {
72473
- throw new Error("Unknown type: " + type.name.value || type.name);
72474
- }
72475
- return { type: namedType, wrappers };
72476
- }
72477
- function wrapType({
72478
- type,
72479
- wrappers
72480
- }) {
72481
- const head = wrappers[0];
72482
- const tail = wrappers.slice(1);
72483
- let kind = graphql5.Kind.NAMED_TYPE;
72484
- if (head === TypeWrapper.List) {
72485
- kind = graphql5.Kind.LIST_TYPE;
72486
- } else if (head === TypeWrapper.NonNull) {
72487
- kind = graphql5.Kind.NON_NULL_TYPE;
72488
- }
72489
- if (kind === "NamedType") {
72490
- return {
72491
- kind,
72492
- name: {
72493
- kind: graphql5.Kind.NAME,
72494
- value: type.name
72495
- }
72496
- };
72497
- }
72498
- return {
72499
- kind,
72500
- type: wrapType({ type, wrappers: tail })
72501
- };
72502
- }
72503
- var TypeWrapper = /* @__PURE__ */ ((TypeWrapper2) => {
72504
- TypeWrapper2["Nullable"] = "Nullable";
72505
- TypeWrapper2["List"] = "List";
72506
- TypeWrapper2["NonNull"] = "NonNull";
72507
- return TypeWrapper2;
72508
- })(TypeWrapper || {});
72509
-
72510
- // src/lib/parse.ts
72511
- var import_parser = __toESM(require_lib6(), 1);
72512
- var import_recast = __toESM(require_main2(), 1);
72513
-
72514
- // src/lib/deepMerge.ts
72515
- var import_deepmerge = __toESM(require_cjs(), 1);
72516
- function deepMerge2(filepath, ...targets) {
72517
- try {
72518
- if (targets.length === 1) {
72519
- return targets[0];
72520
- } else if (targets.length === 2) {
72521
- return (0, import_deepmerge.default)(targets[0], targets[1], {
72522
- arrayMerge: (source, update) => [...new Set(source.concat(update))]
72523
- });
72524
- }
72525
- return deepMerge2(filepath, targets[0], deepMerge2(filepath, ...targets.slice(1)));
72526
- } catch (e3) {
72527
- throw new HoudiniError({
72528
- filepath,
72529
- message: "could not merge: " + JSON.stringify(targets, null, 4),
72530
- description: e3.message
72531
- });
72532
- }
72533
- }
72534
-
72535
- // src/lib/parse.ts
72536
- function parseJS(str, config) {
72537
- const defaultConfig = {
72538
- plugins: [
72539
- "typescript",
72540
- "importAssertions",
72541
- "decorators-legacy",
72542
- "explicitResourceManagement"
72543
- ],
72544
- sourceType: "module"
72545
- };
72546
- return (0, import_parser.parse)(str || "", config ? deepMerge2("", defaultConfig, config) : defaultConfig).program;
72547
- }
72548
- function parseJSON(str) {
72549
- str = str.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m3, g3) => g3 ? "" : m3);
72550
- return JSON.parse(str);
72551
- }
72552
- async function printJS(script, options) {
72553
- if (options?.pretty) {
72554
- return (0, import_recast.prettyPrint)(script, options);
72555
- } else {
72556
- return (0, import_recast.print)(script, options);
72557
- }
72558
- }
72559
-
72560
72434
  // src/lib/imports.ts
72561
72435
  var recast = __toESM(require_main2(), 1);
72562
72436
  var AST2 = recast.types.builders;
@@ -72619,7 +72493,7 @@ async function cleanupFiles(pathFolder, listOfObj) {
72619
72493
  // src/lib/detectTools.ts
72620
72494
  async function detectFromPackageJSON(cwd) {
72621
72495
  try {
72622
- const packageJSONFile = await fs_exports.readFile(path_exports.join(cwd, "package.json"));
72496
+ const packageJSONFile = await readFile(join2(cwd, "package.json"));
72623
72497
  if (packageJSONFile) {
72624
72498
  var packageJSON2 = JSON.parse(packageJSONFile);
72625
72499
  } else {
@@ -72644,22 +72518,22 @@ async function detectFromPackageJSON(cwd) {
72644
72518
  async function detectTools(cwd = process.cwd()) {
72645
72519
  let typescript = false;
72646
72520
  try {
72647
- await fs_exports.stat(path_exports.join(cwd, "tsconfig.json"));
72521
+ await stat(join2(cwd, "tsconfig.json"));
72648
72522
  typescript = true;
72649
72523
  } catch {
72650
72524
  }
72651
72525
  let package_manager = "npm";
72652
72526
  let dir = cwd;
72653
72527
  do {
72654
- if (fs_exports.existsSync(path_exports.join(dir, "pnpm-lock.yaml"))) {
72528
+ if (existsSync(join2(dir, "pnpm-lock.yaml"))) {
72655
72529
  package_manager = "pnpm";
72656
72530
  break;
72657
72531
  }
72658
- if (fs_exports.existsSync(path_exports.join(dir, "yarn.lock"))) {
72532
+ if (existsSync(join2(dir, "yarn.lock"))) {
72659
72533
  package_manager = "yarn";
72660
72534
  break;
72661
72535
  }
72662
- } while (dir !== (dir = path_exports.dirname(dir)));
72536
+ } while (dir !== (dir = dirname(dir)));
72663
72537
  return {
72664
72538
  typescript,
72665
72539
  package_manager,
@@ -72736,18 +72610,18 @@ function scalarPropertyValue(config, filepath, missingScalars, target, body, fie
72736
72610
  return AST3.tsNeverKeyword();
72737
72611
  }
72738
72612
  const component = config.componentFields[field.parent][field.field];
72739
- const sourcePathRelative = path_exports.relative(
72740
- path_exports.join(config.projectRoot, "src"),
72613
+ const sourcePathRelative = relative(
72614
+ join2(config.projectRoot, "src"),
72741
72615
  component.filepath
72742
72616
  );
72743
- let sourcePathParsed = path_exports.parse(sourcePathRelative);
72744
- let sourcePath = path_exports.join(sourcePathParsed.dir, sourcePathParsed.name);
72617
+ let sourcePathParsed = parse3(sourcePathRelative);
72618
+ let sourcePath = join2(sourcePathParsed.dir, sourcePathParsed.name);
72745
72619
  const localImport = ensureImports({
72746
72620
  config,
72747
72621
  body,
72748
72622
  import: "__component__" + component.fragment,
72749
- sourceModule: path_exports.join(
72750
- path_exports.relative(path_exports.dirname(filepath), config.projectRoot),
72623
+ sourceModule: join2(
72624
+ relative(dirname(filepath), config.projectRoot),
72751
72625
  "src",
72752
72626
  sourcePath
72753
72627
  )
@@ -75665,6 +75539,16 @@ async function generatePluginIndex({
75665
75539
  }
75666
75540
 
75667
75541
  // src/codegen/generators/runtime/pluginRuntime.ts
75542
+ function moduleStatments(config) {
75543
+ const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
75544
+ const exportDefaultStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
75545
+ const exportStarStatement = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
75546
+ return {
75547
+ importStatement,
75548
+ exportDefaultStatement,
75549
+ exportStarStatement
75550
+ };
75551
+ }
75668
75552
  async function generatePluginRuntimes({
75669
75553
  config,
75670
75554
  docs
@@ -75680,7 +75564,7 @@ async function generatePluginRuntimes({
75680
75564
  return;
75681
75565
  }
75682
75566
  try {
75683
- await fs_exports.stat(runtime_path);
75567
+ await stat(runtime_path);
75684
75568
  } catch {
75685
75569
  throw new HoudiniError({
75686
75570
  message: "Cannot find runtime to generate for " + plugin2.name,
@@ -75692,13 +75576,13 @@ async function generatePluginRuntimes({
75692
75576
  if (transformMap && typeof transformMap === "function") {
75693
75577
  transformMap = transformMap(docs, { config });
75694
75578
  }
75695
- await fs_exports.mkdirp(pluginDir);
75696
- await fs_exports.recursiveCopy(
75579
+ await mkdirp(pluginDir);
75580
+ await recursiveCopy(
75697
75581
  runtime_path,
75698
75582
  pluginDir,
75699
75583
  Object.fromEntries(
75700
75584
  Object.entries(transformMap).map(([key, value]) => [
75701
- path_exports.join(runtime_path, key),
75585
+ join2(runtime_path, key),
75702
75586
  (content) => value({
75703
75587
  config,
75704
75588
  content,
@@ -75745,21 +75629,21 @@ async function runtimeGenerator(config, docs) {
75745
75629
  exportStarStatement: exportStar
75746
75630
  } = moduleStatments(config);
75747
75631
  await Promise.all([
75748
- fs_exports.recursiveCopy(config.runtimeSource, config.runtimeDirectory, {
75749
- [path_exports.join(config.runtimeSource, "lib", "constants.js")]: (content) => {
75632
+ recursiveCopy(config.runtimeSource, config.runtimeDirectory, {
75633
+ [join2(config.runtimeSource, "lib", "constants.js")]: (content) => {
75750
75634
  return content.replace("SITE_URL", siteURL);
75751
75635
  },
75752
- [path_exports.join(config.runtimeSource, "imports", "pluginConfig.js")]: (content) => {
75636
+ [join2(config.runtimeSource, "imports", "pluginConfig.js")]: (content) => {
75753
75637
  return injectConfig({ config, importStatement, exportStatement, content });
75754
75638
  },
75755
- [path_exports.join(config.runtimeSource, "imports", "config.js")]: (content) => {
75756
- const configFilePath = path_exports.join(config.runtimeDirectory, "imports", "config.js");
75757
- const relativePath = path_exports.relative(path_exports.dirname(configFilePath), config.filepath);
75639
+ [join2(config.runtimeSource, "imports", "config.js")]: (content) => {
75640
+ const configFilePath = join2(config.runtimeDirectory, "imports", "config.js");
75641
+ const relativePath = relative(dirname(configFilePath), config.filepath);
75758
75642
  return `${importStatement(relativePath, "config")}
75759
75643
  ${exportStatement("config")}
75760
75644
  `;
75761
75645
  },
75762
- [path_exports.join(config.runtimeSource, "client", "plugins", "injectedPlugins.js")]: (content) => injectPlugins({ config, content, importStatement, exportStatement })
75646
+ [join2(config.runtimeSource, "client", "plugins", "injectedPlugins.js")]: (content) => injectPlugins({ config, content, importStatement, exportStatement })
75763
75647
  }),
75764
75648
  generatePluginRuntimes({
75765
75649
  config,
@@ -75769,16 +75653,6 @@ ${exportStatement("config")}
75769
75653
  ]);
75770
75654
  await generateGraphqlReturnTypes(config, docs);
75771
75655
  }
75772
- function moduleStatments(config) {
75773
- const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
75774
- const exportDefaultStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
75775
- const exportStarStatement = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
75776
- return {
75777
- importStatement,
75778
- exportDefaultStatement,
75779
- exportStarStatement
75780
- };
75781
- }
75782
75656
 
75783
75657
  // src/codegen/generators/typescript/documentTypes.ts
75784
75658
  var recast11 = __toESM(require_main2(), 1);
@@ -82418,12 +82292,12 @@ async function packageJSON(targetPath, frameworkInfo) {
82418
82292
  }
82419
82293
  packageJSON2.devDependencies = {
82420
82294
  ...packageJSON2.devDependencies,
82421
- houdini: "^1.5.2"
82295
+ houdini: "^1.5.4"
82422
82296
  };
82423
82297
  if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
82424
82298
  packageJSON2.devDependencies = {
82425
82299
  ...packageJSON2.devDependencies,
82426
- "houdini-svelte": "^2.1.6"
82300
+ "houdini-svelte": "^2.1.8"
82427
82301
  };
82428
82302
  } else {
82429
82303
  throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);