@baeta/plugin-graphql 0.1.0 → 0.1.2

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @baeta/plugin-graphql
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#170](https://github.com/andreisergiu98/baeta/pull/170) [`59bbb9c`](https://github.com/andreisergiu98/baeta/commit/59bbb9c4baaf716f27dc251fe7aeb0231e6c5321) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
8
+
9
+ - [#169](https://github.com/andreisergiu98/baeta/pull/169) [`e84137f`](https://github.com/andreisergiu98/baeta/commit/e84137f5a0cd65402e88cd56224fff450057c473) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - fix #163, resolve custom scalar types relative to baeta config
10
+
11
+ - Updated dependencies [[`e3fb6f8`](https://github.com/andreisergiu98/baeta/commit/e3fb6f877b4b20e248ad79cbaa3655cabe973f6b), [`59bbb9c`](https://github.com/andreisergiu98/baeta/commit/59bbb9c4baaf716f27dc251fe7aeb0231e6c5321)]:
12
+ - @baeta/generator-sdk@0.1.2
13
+ - @baeta/util-path@0.1.2
14
+
15
+ ## 0.1.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [`7f1958c`](https://github.com/andreisergiu98/baeta/commit/7f1958c44d1b9bed473e48c875fdaa7020c434fa) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - allow custom extension for generated file imports
20
+
21
+ - [#157](https://github.com/andreisergiu98/baeta/pull/157) [`b9638eb`](https://github.com/andreisergiu98/baeta/commit/b9638eb9fb713507efa9821b4f04cc7896a997b1) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - stricter linting, better type safety
22
+
23
+ - [`9d8d6a1`](https://github.com/andreisergiu98/baeta/commit/9d8d6a15d63579a2e0bdaa07b7efdcf10aff2492) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - remove all loaders apart from graphql file loader, and let users define extra loaders if needed
24
+
25
+ - [`a3f0e5d`](https://github.com/andreisergiu98/baeta/commit/a3f0e5d03fc9ef21a87d3ec6bf264d0e9707636a) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - fix exports order in package.json
26
+
27
+ - [#161](https://github.com/andreisergiu98/baeta/pull/161) [`cca37dd`](https://github.com/andreisergiu98/baeta/commit/cca37dd7135a2852f1f6e287c46911306bdc8da0) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
28
+
29
+ - [`34877dc`](https://github.com/andreisergiu98/baeta/commit/34877dce585a36abd3bb21adfaa2b84075a416a9) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - revert blank objects
30
+
31
+ - [#107](https://github.com/andreisergiu98/baeta/pull/107) [`b6e87ce`](https://github.com/andreisergiu98/baeta/commit/b6e87ce347406164a9c0fca49172f1d5d4f50f74) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - add type hashes
32
+
33
+ - Updated dependencies [[`7f1958c`](https://github.com/andreisergiu98/baeta/commit/7f1958c44d1b9bed473e48c875fdaa7020c434fa), [`b9638eb`](https://github.com/andreisergiu98/baeta/commit/b9638eb9fb713507efa9821b4f04cc7896a997b1), [`fd3a5d2`](https://github.com/andreisergiu98/baeta/commit/fd3a5d27b497aca4b8807155e801b1c1197c5fe2), [`9d8d6a1`](https://github.com/andreisergiu98/baeta/commit/9d8d6a15d63579a2e0bdaa07b7efdcf10aff2492), [`a3f0e5d`](https://github.com/andreisergiu98/baeta/commit/a3f0e5d03fc9ef21a87d3ec6bf264d0e9707636a), [`cca37dd`](https://github.com/andreisergiu98/baeta/commit/cca37dd7135a2852f1f6e287c46911306bdc8da0)]:
34
+ - @baeta/generator-sdk@0.1.1
35
+ - @baeta/util-path@0.1.1
36
+
3
37
  ## 0.1.0
4
38
 
5
39
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -8,6 +8,7 @@ var __export = (target, all) => {
8
8
  var _generatorsdk = require('@baeta/generator-sdk');
9
9
 
10
10
  // lib/codegen.ts
11
+ var _utilpath = require('@baeta/util-path');
11
12
  var _core = require('@graphql-codegen/core');
12
13
  var _pluginhelpers = require('@graphql-codegen/plugin-helpers');
13
14
  var _typescript = require('@graphql-codegen/typescript'); var typescriptPlugin = _interopRequireWildcard(_typescript);
@@ -29,17 +30,10 @@ function createCache() {
29
30
 
30
31
  // utils/load.ts
31
32
 
32
- var _apolloengineloader = require('@graphql-tools/apollo-engine-loader');
33
- var _codefileloader = require('@graphql-tools/code-file-loader');
34
- var _gitloader = require('@graphql-tools/git-loader');
35
- var _githubloader = require('@graphql-tools/github-loader');
36
33
  var _graphqlfileloader = require('@graphql-tools/graphql-file-loader');
37
- var _jsonfileloader = require('@graphql-tools/json-file-loader');
38
34
 
39
35
 
40
36
  var _load = require('@graphql-tools/load');
41
- var _prismaloader = require('@graphql-tools/prisma-loader');
42
- var _urlloader = require('@graphql-tools/url-loader');
43
37
  var _graphql = require('graphql');
44
38
 
45
39
  // utils/hash.ts
@@ -54,18 +48,9 @@ function hashSchema(schema) {
54
48
  }
55
49
 
56
50
  // utils/load.ts
57
- async function loadSchema(schemaPointerMap, cwd) {
51
+ async function loadSchema(schemaPointerMap, cwd, extraLoaders = []) {
58
52
  const outputSchemaAst = await _load.loadSchema.call(void 0, schemaPointerMap, {
59
- loaders: [
60
- new (0, _codefileloader.CodeFileLoader)(),
61
- new (0, _gitloader.GitLoader)(),
62
- new (0, _githubloader.GithubLoader)(),
63
- new (0, _graphqlfileloader.GraphQLFileLoader)(),
64
- new (0, _jsonfileloader.JsonFileLoader)(),
65
- new (0, _urlloader.UrlLoader)(),
66
- new (0, _apolloengineloader.ApolloEngineLoader)(),
67
- new (0, _prismaloader.PrismaLoader)()
68
- ],
53
+ loaders: [new (0, _graphqlfileloader.GraphQLFileLoader)(), ...extraLoaders],
69
54
  cwd,
70
55
  includeSources: true
71
56
  });
@@ -80,20 +65,49 @@ ${messages}`);
80
65
  if (!outputSchemaAst.extensions) {
81
66
  outputSchemaAst.extensions = {};
82
67
  }
83
- outputSchemaAst.extensions["hash"] = hashSchema(outputSchemaAst);
68
+ outputSchemaAst.extensions.hash = hashSchema(outputSchemaAst);
84
69
  return {
85
70
  outputSchemaAst,
86
71
  outputSchema: _pluginhelpers.getCachedDocumentNodeFromSchema.call(void 0, outputSchemaAst)
87
72
  };
88
73
  }
89
74
 
75
+ // utils/scalars.ts
76
+
77
+ var _visitorplugincommon = require('@graphql-codegen/visitor-plugin-common');
78
+ function buildScalarMap(map, cwd, typesPath) {
79
+ if (!map) {
80
+ return {};
81
+ }
82
+ const fixedMap = {};
83
+ for (const key in map) {
84
+ const mapped = _visitorplugincommon.parseMapper.call(void 0, map[key]);
85
+ if (!mapped.isExternal) {
86
+ fixedMap[key] = map[key];
87
+ continue;
88
+ }
89
+ if (_utilpath.isAbsolute.call(void 0, mapped.source)) {
90
+ fixedMap[key] = map[key];
91
+ continue;
92
+ }
93
+ const scalarPath = _utilpath.joinSafe.call(void 0, cwd, mapped.source);
94
+ const relativePath = _utilpath.relative.call(void 0, _utilpath.dirname.call(void 0, typesPath), scalarPath);
95
+ if (mapped.default) {
96
+ fixedMap[key] = `${relativePath}#default`;
97
+ continue;
98
+ }
99
+ fixedMap[key] = `${relativePath}#${mapped.import}`;
100
+ }
101
+ return fixedMap;
102
+ }
103
+
90
104
  // lib/context/index.ts
91
105
  var context_exports = {};
92
106
  __export(context_exports, {
93
107
  default: () => context_default,
94
108
  plugin: () => plugin
95
109
  });
96
- var _visitorplugincommon = require('@graphql-codegen/visitor-plugin-common');
110
+
97
111
  var plugin = async (schema, documents, config) => {
98
112
  const prepend = [];
99
113
  const mapper = _visitorplugincommon.parseMapper.call(void 0, config.contextType || "any");
@@ -124,7 +138,7 @@ var plugin = async (schema, documents, config) => {
124
138
  var context_default = { plugin };
125
139
 
126
140
  // lib/modules/index.ts
127
- var _utilpath = require('@baeta/util-path');
141
+
128
142
 
129
143
 
130
144
 
@@ -141,6 +155,48 @@ var _changecaseall = require('change-case-all');
141
155
 
142
156
 
143
157
 
158
+ // lib/modules/hashes.ts
159
+
160
+
161
+
162
+ var _murmurhash = require('murmurhash'); var _murmurhash2 = _interopRequireDefault(_murmurhash);
163
+ function getObjectTypeHash(node) {
164
+ const fieldNames = buildFieldsNames(node.fields);
165
+ const typeFields = fieldNames.map(([fieldName, fieldType]) => `${fieldName}:${fieldType}`).join(",");
166
+ const fieldMap = {};
167
+ for (const [fieldName, fieldType] of fieldNames) {
168
+ fieldMap[fieldName] = _murmurhash2.default.v3(fieldType).toString(36);
169
+ }
170
+ return {
171
+ hash: _murmurhash2.default.v3(typeFields).toString(36),
172
+ fieldsHashes: fieldMap
173
+ };
174
+ }
175
+ function buildFieldsNames(fields = []) {
176
+ if (fields.length === 0) {
177
+ return [];
178
+ }
179
+ const fieldsNames = [];
180
+ for (const field of fields) {
181
+ const fieldName = field.name.value;
182
+ const fieldType = buildTypeName(field.type);
183
+ fieldsNames.push([fieldName, fieldType]);
184
+ }
185
+ return fieldsNames.sort(([a], [b]) => a.localeCompare(b));
186
+ }
187
+ function buildTypeName(node) {
188
+ if (node.kind === _graphql.Kind.NAMED_TYPE) {
189
+ return node.name.value;
190
+ }
191
+ if (node.kind === _graphql.Kind.LIST_TYPE) {
192
+ return `[${buildTypeName(node.type)}]`;
193
+ }
194
+ if (node.kind === _graphql.Kind.NON_NULL_TYPE) {
195
+ return `${buildTypeName(node.type)}!`;
196
+ }
197
+ return "";
198
+ }
199
+
144
200
  // lib/modules/utils.ts
145
201
  var _os = require('os');
146
202
 
@@ -392,6 +448,7 @@ function buildModule(name, doc, {
392
448
  );
393
449
  const defined = createObject(registryKeys, () => []);
394
450
  const extended = createObject(registryKeys, () => []);
451
+ const hashes = {};
395
452
  const usedTypes = collectUsedTypes(doc);
396
453
  _graphql.visit.call(void 0, doc, {
397
454
  ObjectTypeDefinition(node) {
@@ -438,7 +495,7 @@ function buildModule(name, doc, {
438
495
  );
439
496
  const imports = [
440
497
  `import * as ${importNamespace} from "${importPath}";`,
441
- 'import { DocumentNode } from "graphql";',
498
+ 'import type { DocumentNode } from "graphql";',
442
499
  'import * as Baeta from "@baeta/core/sdk";'
443
500
  ];
444
501
  if (extensionsPath) {
@@ -472,6 +529,7 @@ ${shouldDeclare ? `${indent(2)(imports.join("\n"))}
472
529
  return `export namespace ModuleMetadata {
473
530
  export const id = '${name}';
474
531
  export const dirname = './${name}';
532
+ export const hashes = ${JSON.stringify(hashes)};
475
533
  export const typedef = ${JSON.stringify(doc)} as unknown as DocumentNode;
476
534
  ${printBaetaManager()}
477
535
  }`;
@@ -719,6 +777,7 @@ ${body}
719
777
  case _graphql.Kind.OBJECT_TYPE_DEFINITION: {
720
778
  defined.objects.push(name2);
721
779
  collectFields(node, picks.objects);
780
+ hashes[name2] = getObjectTypeHash(node);
722
781
  break;
723
782
  }
724
783
  case _graphql.Kind.ENUM_TYPE_DEFINITION: {
@@ -752,6 +811,7 @@ ${body}
752
811
  switch (node.kind) {
753
812
  case _graphql.Kind.OBJECT_TYPE_EXTENSION: {
754
813
  collectFields(node, picks.objects);
814
+ hashes[name2] = getObjectTypeHash(node);
755
815
  if (rootTypes.includes(name2)) {
756
816
  pushUnique(defined.objects, name2);
757
817
  return;
@@ -782,17 +842,17 @@ ${body}
782
842
  }
783
843
  function getParentType(type) {
784
844
  if (["Query", "Mutation", "Subscription"].includes(type)) {
785
- return "{}";
845
+ return "{ }";
786
846
  }
787
847
  return type;
788
848
  }
789
849
  function getResultType(type, field) {
790
- return _optionalChain([fieldTypes, 'optionalAccess', _18 => _18[type], 'optionalAccess', _19 => _19[field]]) || "{}";
850
+ return _optionalChain([fieldTypes, 'optionalAccess', _18 => _18[type], 'optionalAccess', _19 => _19[field]]) || "{ }";
791
851
  }
792
852
  function getArgsType(type, field) {
793
853
  const hasArgs = _nullishCoalesce(_optionalChain([fieldArguments, 'optionalAccess', _20 => _20[type], 'optionalAccess', _21 => _21[field]]), () => ( false));
794
854
  if (!hasArgs) {
795
- return "{}";
855
+ return "{ }";
796
856
  }
797
857
  const fieldUpper = field[0].toUpperCase() + field.slice(1);
798
858
  return `Types.${type}${fieldUpper}Args`;
@@ -806,7 +866,7 @@ ${body}
806
866
  var preset = {
807
867
  buildGeneratesSection: (options) => {
808
868
  const { baseOutputDir } = options;
809
- const { baseTypesPath, extensionsPath, encapsulateModuleTypes } = options.presetConfig;
869
+ const { baseTypesPath, extensionsPath, encapsulateModuleTypes, importExtension } = options.presetConfig;
810
870
  const requireRootResolvers = _visitorplugincommon.getConfigValue.call(void 0, _optionalChain([options, 'optionalAccess', _22 => _22.presetConfig, 'access', _23 => _23.requireRootResolvers]), false);
811
871
  const cwd = _utilpath.resolve.call(void 0, options.presetConfig.cwd || process.cwd());
812
872
  const importTypesNamespace = options.presetConfig.importTypesNamespace || "Types";
@@ -973,7 +1033,7 @@ ${result}
973
1033
  },
974
1034
  schemaAst: options.schemaAst
975
1035
  };
976
- const baseTypesFilename = baseTypesPath.replace(/\.(js|ts|d.ts)$/, "");
1036
+ const baseTypesFilename = _utilpath.basename.call(void 0, baseTypesPath).replace(/\.(js|ts|d.ts)$/, "") + (importExtension || "");
977
1037
  const baseTypesDir = stripFilename(baseOutput.filename);
978
1038
  const outputs = modules.map((moduleName) => {
979
1039
  const filename = _utilpath.resolve.call(void 0, cwd, baseOutputDir, moduleName, options.presetConfig.filename);
@@ -1049,9 +1109,9 @@ async function generate(options) {
1049
1109
  Object.assign(schemaPointerMap, ptr);
1050
1110
  }
1051
1111
  }
1052
- const hash = JSON.stringify(schemaPointerMap);
1053
- const result = await cache("schema", hash, async () => {
1054
- return loadSchema(schemaPointerMap, options.cwd);
1112
+ const hash2 = JSON.stringify(schemaPointerMap);
1113
+ const result = await cache("schema", hash2, async () => {
1114
+ return loadSchema(schemaPointerMap, options.cwd, options.loaders);
1055
1115
  });
1056
1116
  const outputs = await preset.buildGeneratesSection({
1057
1117
  baseOutputDir: options.modulesDir,
@@ -1059,7 +1119,8 @@ async function generate(options) {
1059
1119
  baseTypesPath: rootConfig.baseTypesPath,
1060
1120
  filename: rootConfig.moduleDefinitionName,
1061
1121
  encapsulateModuleTypes: "none",
1062
- extensionsPath: options.extensions
1122
+ extensionsPath: options.extensions,
1123
+ importExtension: options.importExtension
1063
1124
  },
1064
1125
  schema: result.outputSchema,
1065
1126
  schemaAst: result.outputSchemaAst,
@@ -1070,9 +1131,11 @@ async function generate(options) {
1070
1131
  inputMaybeValue: "T | undefined",
1071
1132
  contextType: rootConfig.contextType,
1072
1133
  useTypeImports: true,
1073
- scalars: {
1074
- ...rootConfig.scalars
1075
- }
1134
+ scalars: buildScalarMap(
1135
+ rootConfig.scalars,
1136
+ options.cwd,
1137
+ _utilpath.join.call(void 0, options.modulesDir, options.baseTypesPath)
1138
+ )
1076
1139
  }
1077
1140
  });
1078
1141
  const promises = outputs.map(async (output) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/baeta/baeta/packages/plugin-graphql/dist/index.cjs","../index.ts","../lib/codegen.ts","../utils/cache.ts","../utils/load.ts","../utils/hash.ts","../lib/context/index.ts","../lib/modules/index.ts","../lib/modules/builder.ts","../lib/modules/utils.ts"],"names":["getCachedDocumentNodeFromSchema","isScalarType","Kind","name","sources","unionsDefinition","types","typePicks","result"],"mappings":"AAAA,uiCAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,SAAS,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG;AAChC,EAAE,IAAI,CAAC,IAAI,KAAK,GAAG,GAAG;AACtB,IAAI,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;AACjE,CAAC;AACD;AACA;ACNA,oDAA0D;ADQ1D;AACA;AERA,6CAAsC;AACtC,gEAA0D;AAC1D,sHAAkC;AFUlC;AACA;AGdO,SAAS,WAAA,CAAA,EAIA;AACf,EAAA,MAAM,MAA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AER,EAAA;AACY,EAAA;AACN,IAAA;AACV,MAAA;AACiB,IAAA;AACH,MAAA;AACf,IAAA;AACD,EAAA;AAEkB,EAAA;AACH,EAAA;AACI,IAAA;AAClB,EAAA;AAEe,EAAA;AACA,IAAA;AACD,IAAA;AACE,MAAA;AACL,MAAA;AACV,MAAA;AACgB,MAAA;AACjB,IAAA;AACe,IAAA;AACG,IAAA;AACN,IAAA;AACD,IAAA;AACF,IAAA;AACD,IAAA;AACP,MAAA;AACa,MAAA;AACG,MAAA;AACP,MAAA;AACM,QAAA;AACf,MAAA;AACD,IAAA;AACA,EAAA;AAEgB,EAAA;AACD,IAAA;AACX,MAAA;AACH,MAAA;AACA,IAAA;AAEM,IAAA;AACI,MAAA;AACDI,MAAAA;AACV,IAAA;AACA,EAAA;AAEkB,EAAA;AACpB;AFo/BsB;AACA;AC/jCN;AACR,EAAA;AACA,IAAA;AACM,IAAA;AACK,IAAA;AACV,MAAA;AACO,QAAA;AACA,UAAA;AACZ,QAAA;AACD,MAAA;AAEW,MAAA;AACA,MAAA;AACZ,IAAA;AACiB,IAAA;AACF,MAAA;AAEH,MAAA;AACN,QAAA;AACL,MAAA;AAEY,MAAA;AACb,IAAA;AACA,EAAA;AACF;AD8jCsB;AACA;AACA","file":"/home/runner/work/baeta/baeta/packages/plugin-graphql/dist/index.cjs","sourcesContent":[null,"import { type WatcherFile, createPluginV1, isMatch } from '@baeta/generator-sdk';\nimport { generate } from './lib/codegen.ts';\n\nexport function graphqlPlugin() {\n\treturn createPluginV1({\n\t\tname: 'graphql',\n\t\tactionName: 'GraphQL modules',\n\t\twatch: (options, watcher, reload) => {\n\t\t\tconst handleChange = (file: WatcherFile) => {\n\t\t\t\tif (isMatch(file.relativePath, options.schemas)) {\n\t\t\t\t\treload(file);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\twatcher.on('update', handleChange);\n\t\t\twatcher.on('delete', handleChange);\n\t\t},\n\t\tgenerate: async (ctx, next) => {\n\t\t\tconst items = await generate(ctx.generatorOptions);\n\n\t\t\tfor (const item of items) {\n\t\t\t\tctx.fileManager.createAndAdd(item.filename, item.content, 'graphql');\n\t\t\t}\n\n\t\t\treturn next();\n\t\t},\n\t});\n}\n","import type { NormalizedGeneratorOptions } from '@baeta/generator-sdk';\nimport { codegen as gqlCodegen } from '@graphql-codegen/core';\nimport { normalizeConfig, normalizeInstanceOrArray } from '@graphql-codegen/plugin-helpers';\nimport * as typescriptPlugin from '@graphql-codegen/typescript';\nimport type { UnnormalizedTypeDefPointer } from '@graphql-tools/load';\nimport { createCache } from '../utils/cache.ts';\nimport { loadSchema } from '../utils/load.ts';\nimport * as contextPlugin from './context/index.ts';\nimport * as modules from './modules/index.ts';\n\nexport async function generate(options: NormalizedGeneratorOptions) {\n\tconst rootConfig = {\n\t\tschemas: normalizeInstanceOrArray(options.schemas),\n\t\tmodulesDir: options.modulesDir,\n\t\tbaseTypesPath: options.baseTypesPath,\n\t\tcontextType: options.contextType,\n\t\tmoduleDefinitionName: options.moduleDefinitionName,\n\t\tscalars: options.scalars,\n\t\tplugins: normalizeConfig(['typescript', 'context']),\n\t\tpluginMap: {\n\t\t\ttypescript: typescriptPlugin,\n\t\t\tcontext: contextPlugin,\n\t\t},\n\t};\n\n\tconst cache = createCache();\n\n\tconst schemaPointerMap: UnnormalizedTypeDefPointer = {};\n\tfor (const ptr of rootConfig.schemas) {\n\t\tif (typeof ptr === 'string') {\n\t\t\tschemaPointerMap[ptr] = {};\n\t\t} else if (typeof ptr === 'object') {\n\t\t\tObject.assign(schemaPointerMap, ptr);\n\t\t}\n\t}\n\n\tconst hash = JSON.stringify(schemaPointerMap);\n\tconst result = await cache('schema', hash, async () => {\n\t\treturn loadSchema(schemaPointerMap, options.cwd);\n\t});\n\n\tconst outputs = await modules.preset.buildGeneratesSection({\n\t\tbaseOutputDir: options.modulesDir,\n\t\tpresetConfig: {\n\t\t\tbaseTypesPath: rootConfig.baseTypesPath,\n\t\t\tfilename: rootConfig.moduleDefinitionName,\n\t\t\tencapsulateModuleTypes: 'none',\n\t\t\textensionsPath: options.extensions,\n\t\t},\n\t\tschema: result.outputSchema,\n\t\tschemaAst: result.outputSchemaAst,\n\t\tdocuments: [],\n\t\tpluginMap: rootConfig.pluginMap,\n\t\tplugins: rootConfig.plugins,\n\t\tconfig: {\n\t\t\tinputMaybeValue: 'T | undefined',\n\t\t\tcontextType: rootConfig.contextType,\n\t\t\tuseTypeImports: true,\n\t\t\tscalars: {\n\t\t\t\t...rootConfig.scalars,\n\t\t\t},\n\t\t},\n\t});\n\n\tconst promises = outputs.map(async (output) => {\n\t\tconst result = await gqlCodegen({\n\t\t\t...output,\n\t\t\tcache,\n\t\t});\n\n\t\treturn {\n\t\t\tfilename: output.filename,\n\t\t\tcontent: result,\n\t\t};\n\t});\n\n\treturn Promise.all(promises);\n}\n","export function createCache(): <T>(\n\tnamespace: string,\n\tkey: string,\n\tfactory: () => Promise<T>,\n) => Promise<T> {\n\tconst cache = new Map<string, Promise<unknown>>();\n\n\treturn function ensure<T>(namespace: string, key: string, factory: () => Promise<T>): Promise<T> {\n\t\tconst cacheKey = `${namespace}:${key}`;\n\n\t\tconst cachedValue = cache.get(cacheKey);\n\n\t\tif (cachedValue) {\n\t\t\treturn cachedValue as Promise<T>;\n\t\t}\n\n\t\tconst value = factory();\n\t\tcache.set(cacheKey, value);\n\n\t\treturn value;\n\t};\n}\n","import { getCachedDocumentNodeFromSchema } from '@graphql-codegen/plugin-helpers';\nimport { ApolloEngineLoader } from '@graphql-tools/apollo-engine-loader';\nimport { CodeFileLoader } from '@graphql-tools/code-file-loader';\nimport { GitLoader } from '@graphql-tools/git-loader';\nimport { GithubLoader } from '@graphql-tools/github-loader';\nimport { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader';\nimport { JsonFileLoader } from '@graphql-tools/json-file-loader';\nimport {\n\ttype UnnormalizedTypeDefPointer,\n\tloadSchema as loadSchemaToolkit,\n} from '@graphql-tools/load';\nimport { PrismaLoader } from '@graphql-tools/prisma-loader';\nimport { UrlLoader } from '@graphql-tools/url-loader';\nimport { type GraphQLSchemaExtensions, validateSchema } from 'graphql';\nimport { hashSchema } from './hash.ts';\n\nexport async function loadSchema(schemaPointerMap: UnnormalizedTypeDefPointer, cwd: string) {\n\tconst outputSchemaAst = await loadSchemaToolkit(schemaPointerMap, {\n\t\tloaders: [\n\t\t\tnew CodeFileLoader(),\n\t\t\tnew GitLoader(),\n\t\t\tnew GithubLoader(),\n\t\t\tnew GraphQLFileLoader(),\n\t\t\tnew JsonFileLoader(),\n\t\t\tnew UrlLoader(),\n\t\t\tnew ApolloEngineLoader(),\n\t\t\tnew PrismaLoader(),\n\t\t],\n\t\tcwd,\n\t\tincludeSources: true,\n\t});\n\n\tconst errors = validateSchema(outputSchemaAst);\n\n\tif (errors.length > 0) {\n\t\tconst messages = errors.map((e) => e.toString()).join('\\n\\n--------------------\\n\\n');\n\t\tconst subject = errors.length === 1 ? 'error' : 'errors';\n\t\tthrow new Error(`Invalid schema. Found ${errors.length} ${subject}:\\n\\n${messages}`);\n\t}\n\n\tif (!outputSchemaAst.extensions) {\n\t\toutputSchemaAst.extensions = {};\n\t}\n\n\t(outputSchemaAst.extensions as GraphQLSchemaExtensions)['hash'] = hashSchema(outputSchemaAst);\n\n\treturn {\n\t\toutputSchemaAst,\n\t\toutputSchema: getCachedDocumentNodeFromSchema(outputSchemaAst),\n\t};\n}\n","import { createHash } from 'node:crypto';\nimport { getCachedDocumentNodeFromSchema } from '@graphql-codegen/plugin-helpers';\nimport { type GraphQLSchema, print } from 'graphql';\n\nexport function hashContent(content: string): string {\n\treturn createHash('sha256').update(content).digest('hex');\n}\n\nexport function hashSchema(schema: GraphQLSchema): string {\n\treturn hashContent(print(getCachedDocumentNodeFromSchema(schema)));\n}\n","import type { PluginFunction, Types } from '@graphql-codegen/plugin-helpers';\nimport { buildMapperImport, parseMapper } from '@graphql-codegen/visitor-plugin-common';\nimport type { GraphQLSchema } from 'graphql';\n\ninterface Config {\n\tcontextType: string | undefined;\n}\n\nexport const plugin: PluginFunction<Config> = async (\n\tschema: GraphQLSchema,\n\tdocuments: Types.DocumentFile[],\n\tconfig: Config,\n): Promise<Types.PluginOutput> => {\n\tconst prepend: string[] = [];\n\tconst mapper = parseMapper(config.contextType || 'any');\n\n\tif (mapper.isExternal && mapper.source) {\n\t\tconst identifier = mapper.default ? 'ContextType' : `${mapper.import} as ContextType`;\n\n\t\tconst result = buildMapperImport(\n\t\t\tmapper.source,\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tidentifier,\n\t\t\t\t\tasDefault: mapper.default,\n\t\t\t\t},\n\t\t\t],\n\t\t\ttrue,\n\t\t);\n\n\t\tif (result) {\n\t\t\tprepend.push(result);\n\t\t}\n\t} else {\n\t\tprepend.push(`type ContextType = ${mapper.type}`);\n\t}\n\n\tprepend.push('export type { ContextType }');\n\n\treturn {\n\t\tcontent: '',\n\t\tprepend: prepend,\n\t};\n};\n\nexport default { plugin };\n","import { join, relative, resolve } from '@baeta/util-path';\nimport type { Types } from '@graphql-codegen/plugin-helpers';\nimport { BaseVisitor, getConfigValue } from '@graphql-codegen/visitor-plugin-common';\nimport type { Source } from '@graphql-tools/utils';\nimport {\n\ttype DocumentNode,\n\ttype ObjectTypeDefinitionNode,\n\ttype UnionTypeDefinitionNode,\n\ttype UnionTypeExtensionNode,\n\tconcatAST,\n\tisScalarType,\n} from 'graphql';\nimport { buildModule } from './builder.ts';\nimport type { ModulesConfig } from './config.ts';\nimport {\n\tcollectObjectFieldTypesAndArguments,\n\tgroupSourcesByModule,\n\tisGraphQLPrimitive,\n\tnormalize,\n\tstripFilename,\n} from './utils.ts';\n\nexport const preset: Types.OutputPreset<ModulesConfig> = {\n\tbuildGeneratesSection: (options) => {\n\t\tconst { baseOutputDir } = options;\n\t\tconst { baseTypesPath, extensionsPath, encapsulateModuleTypes } = options.presetConfig;\n\n\t\tconst requireRootResolvers = getConfigValue(options?.presetConfig.requireRootResolvers, false);\n\n\t\tconst cwd = resolve(options.presetConfig.cwd || process.cwd());\n\t\tconst importTypesNamespace = options.presetConfig.importTypesNamespace || 'Types';\n\n\t\tif (!baseTypesPath) {\n\t\t\tthrow new Error(\n\t\t\t\t`Preset \"graphql-modules\" requires you to specify \"baseTypesPath\" configuration and point it to your base types file (generated by \"typescript\" plugin)!`,\n\t\t\t);\n\t\t}\n\n\t\tif (!options.schemaAst?.extensions.sources) {\n\t\t\tthrow new Error(`Preset \"graphql-modules\" requires to use GraphQL SDL`);\n\t\t}\n\n\t\tconst extensions = options.schemaAst?.extensions;\n\t\tconst sources = (extensions?.extendedSources ?? []) as Source[];\n\t\tconst sourcesByModuleMap = groupSourcesByModule(sources, baseOutputDir);\n\t\tconst modules = Object.keys(sourcesByModuleMap);\n\n\t\tconst baseVisitor = new BaseVisitor(options.config, {});\n\t\tconst { fieldTypes, fieldArguments } = collectObjectFieldTypesAndArguments(options.schemaAst);\n\n\t\t// One file with an output from all plugins\n\t\tconst baseOutput: Types.GenerateOptions = {\n\t\t\tfilename: resolve(cwd, baseOutputDir, baseTypesPath),\n\t\t\tschema: options.schema,\n\t\t\tdocuments: options.documents,\n\t\t\tplugins: [\n\t\t\t\t...options.plugins,\n\t\t\t\t{\n\t\t\t\t\t'modules-exported-scalars': {},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t'modules-exported-picks': {},\n\t\t\t\t},\n\t\t\t],\n\t\t\tpluginMap: {\n\t\t\t\t...options.pluginMap,\n\t\t\t\t'modules-exported-scalars': {\n\t\t\t\t\tplugin: (schema) => {\n\t\t\t\t\t\tconst typeMap = schema.getTypeMap();\n\n\t\t\t\t\t\treturn Object.keys(typeMap)\n\t\t\t\t\t\t\t.map((t) => {\n\t\t\t\t\t\t\t\tif (t && typeMap[t] && isScalarType(typeMap[t]) && !isGraphQLPrimitive(t)) {\n\t\t\t\t\t\t\t\t\tconst convertedName = baseVisitor.convertName(t);\n\t\t\t\t\t\t\t\t\treturn `export type ${convertedName} = Scalars[\"${t}\"];`;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t\t\t.join('\\n');\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t'modules-exported-picks': {\n\t\t\t\t\tplugin: (schema) => {\n\t\t\t\t\t\tconst typePicks: string[] = [];\n\t\t\t\t\t\tconst unionPicks: string[] = [];\n\t\t\t\t\t\tconst unionResults: string[] = [];\n\t\t\t\t\t\tconst interfacePicks: string[] = [];\n\t\t\t\t\t\tconst interfaceResults: string[] = [];\n\n\t\t\t\t\t\tconst unionTypesMap: Record<string, string[] | undefined> = {};\n\t\t\t\t\t\tconst interfacesTypesMap: Record<string, string[] | undefined> = {};\n\n\t\t\t\t\t\tfor (const moduleName of modules) {\n\t\t\t\t\t\t\tconst sources = sourcesByModuleMap[moduleName];\n\t\t\t\t\t\t\tconst documents = sources.map((source) => source.document) as DocumentNode[];\n\t\t\t\t\t\t\tconst moduleDocument = concatAST(documents);\n\n\t\t\t\t\t\t\tconst types = moduleDocument.definitions.filter(\n\t\t\t\t\t\t\t\t(def) => def.kind === 'ObjectTypeDefinition',\n\t\t\t\t\t\t\t) as ObjectTypeDefinitionNode[];\n\n\t\t\t\t\t\t\tconst unionsDefinition = moduleDocument.definitions.filter(\n\t\t\t\t\t\t\t\t(def) => def.kind === 'UnionTypeDefinition',\n\t\t\t\t\t\t\t) as UnionTypeDefinitionNode[];\n\n\t\t\t\t\t\t\tconst unionsExtensions = moduleDocument.definitions.filter(\n\t\t\t\t\t\t\t\t(def) => def.kind === 'UnionTypeExtension',\n\t\t\t\t\t\t\t) as UnionTypeExtensionNode[];\n\n\t\t\t\t\t\t\tconst unions = [...unionsDefinition, ...unionsExtensions];\n\n\t\t\t\t\t\t\tfor (const type of types) {\n\t\t\t\t\t\t\t\tconst name = type.name.value;\n\n\t\t\t\t\t\t\t\tfor (const interfaceNode of type.interfaces ?? []) {\n\t\t\t\t\t\t\t\t\tconst interfaceName = interfaceNode.name.value;\n\n\t\t\t\t\t\t\t\t\tif (interfacesTypesMap[interfaceName] == null) {\n\t\t\t\t\t\t\t\t\t\tinterfacesTypesMap[interfaceName] = [];\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tinterfacesTypesMap[interfaceName]?.push(name);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (name === 'Query' || name === 'Mutation' || name === 'Subscription') {\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst fields = type.fields ?? [];\n\n\t\t\t\t\t\t\t\tif (fields.length === 0) {\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst fieldNames = fields.map((f) => `\"${f.name.value}\"`).join(' | ');\n\n\t\t\t\t\t\t\t\ttypePicks.push(` ${name}: ${fieldNames};`);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfor (const union of unions) {\n\t\t\t\t\t\t\t\tconst types = union.types?.map((t) => t.name.value) ?? [];\n\n\t\t\t\t\t\t\t\tif (unionTypesMap[union.name.value] == null) {\n\t\t\t\t\t\t\t\t\tunionTypesMap[union.name.value] = [];\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tunionTypesMap[union.name.value]?.push(...types);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (const unionName in unionTypesMap) {\n\t\t\t\t\t\t\tconst types = unionTypesMap[unionName];\n\n\t\t\t\t\t\t\tif (types == null || types.length === 0) {\n\t\t\t\t\t\t\t\tunionPicks.push(` ${unionName}: never;`);\n\t\t\t\t\t\t\t\tunionResults.push(` ${unionName}: null;`);\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst typePicks = types.map((t) => {\n\t\t\t\t\t\t\t\tconst normalizedTypeName = baseVisitor.convertName(t, {\n\t\t\t\t\t\t\t\t\tuseTypesSuffix: true,\n\t\t\t\t\t\t\t\t\tuseTypesPrefix: true,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn `Pick<${normalizedTypeName}, DefinedFieldsWithoutExtensions[\"${t}\"] | \"__typename\">`;\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst resultPicks = types.map((t) => `\"${t}\"`);\n\n\t\t\t\t\t\t\tunionPicks.push(` ${unionName}: ${typePicks.join(' | ')};`);\n\t\t\t\t\t\t\tunionResults.push(` ${unionName}: ${resultPicks.join(' | ')} | null;`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (const interfaceName in interfacesTypesMap) {\n\t\t\t\t\t\t\tconst types = interfacesTypesMap[interfaceName];\n\n\t\t\t\t\t\t\tif (types == null || types.length === 0) {\n\t\t\t\t\t\t\t\tinterfacePicks.push(` ${interfaceName}: never;`);\n\t\t\t\t\t\t\t\tinterfaceResults.push(` ${interfaceName}: null;`);\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst typePicks = types.map((t) => {\n\t\t\t\t\t\t\t\tconst normalizedTypeName = baseVisitor.convertName(t, {\n\t\t\t\t\t\t\t\t\tuseTypesSuffix: true,\n\t\t\t\t\t\t\t\t\tuseTypesPrefix: true,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn `Pick<${normalizedTypeName}, DefinedFieldsWithoutExtensions[\"${t}\"] | \"__typename\">`;\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst resultPicks = types.map((t) => `\"${t}\"`);\n\n\t\t\t\t\t\t\tinterfacePicks.push(` ${interfaceName}: ${typePicks.join(' | ')};`);\n\t\t\t\t\t\t\tinterfaceResults.push(` ${interfaceName}: ${resultPicks.join(' | ')} | null;`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst fieldsDefinition = `export type DefinedFieldsWithoutExtensions = {\\n${typePicks.join('\\n')}\\n};`;\n\t\t\t\t\t\tconst unionsDefinition = `export type DefinedUnionsWithoutExtensions = {\\n${unionPicks.join('\\n')}\\n};`;\n\t\t\t\t\t\tconst unionsResultsDefinition = `export type DefinedUnionsResults = {\\n${unionResults.join('\\n')}\\n};`;\n\t\t\t\t\t\tconst interfacesDefinition = `export type DefinedInterfacesWithoutExtensions = {\\n${interfacePicks.join('\\n')}\\n};`;\n\t\t\t\t\t\tconst interfacesResultsDefinition = `export type DefinedInterfacesResults = {\\n${interfaceResults.join(\n\t\t\t\t\t\t\t'\\n',\n\t\t\t\t\t\t)}\\n};`;\n\n\t\t\t\t\t\tconst result = [\n\t\t\t\t\t\t\tfieldsDefinition,\n\t\t\t\t\t\t\tunionsDefinition,\n\t\t\t\t\t\t\tunionsResultsDefinition,\n\t\t\t\t\t\t\tinterfacesDefinition,\n\t\t\t\t\t\t\tinterfacesResultsDefinition,\n\t\t\t\t\t\t].join('\\n\\n');\n\n\t\t\t\t\t\treturn `\\n${result}\\n`;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tconfig: {\n\t\t\t\t...options.config,\n\t\t\t\tenumsAsTypes: true,\n\t\t\t},\n\t\t\tschemaAst: options.schemaAst,\n\t\t};\n\n\t\tconst baseTypesFilename = baseTypesPath.replace(/\\.(js|ts|d.ts)$/, '');\n\t\tconst baseTypesDir = stripFilename(baseOutput.filename);\n\n\t\t// One file per each module\n\t\tconst outputs: Types.GenerateOptions[] = modules.map((moduleName) => {\n\t\t\tconst filename = resolve(cwd, baseOutputDir, moduleName, options.presetConfig.filename);\n\t\t\tconst dirpath = stripFilename(filename);\n\t\t\tconst relativePath = relative(dirpath, baseTypesDir);\n\t\t\tconst importPath =\n\t\t\t\toptions.presetConfig.importBaseTypesFrom ||\n\t\t\t\tnormalize(join(relativePath, baseTypesFilename));\n\t\t\tconst sources = sourcesByModuleMap[moduleName];\n\n\t\t\tconst documents = sources.map((source) => source.document) as DocumentNode[];\n\n\t\t\tconst moduleDocument = concatAST(documents);\n\n\t\t\tconst shouldDeclare = filename.endsWith('.d.ts');\n\n\t\t\treturn {\n\t\t\t\tfilename,\n\t\t\t\tschema: options.schema,\n\t\t\t\tdocuments: [],\n\t\t\t\tplugins: [\n\t\t\t\t\t...options.plugins.filter((p) => typeof p === 'object' && !!p.add),\n\t\t\t\t\t{\n\t\t\t\t\t\t'graphql-modules-plugin': {},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tpluginMap: {\n\t\t\t\t\t...options.pluginMap,\n\t\t\t\t\t'graphql-modules-plugin': {\n\t\t\t\t\t\tplugin: (schema) =>\n\t\t\t\t\t\t\tbuildModule(moduleName, moduleDocument, {\n\t\t\t\t\t\t\t\timportNamespace: importTypesNamespace,\n\t\t\t\t\t\t\t\timportPath,\n\t\t\t\t\t\t\t\tencapsulate: encapsulateModuleTypes || 'namespace',\n\t\t\t\t\t\t\t\trequireRootResolvers,\n\t\t\t\t\t\t\t\tshouldDeclare,\n\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\tbaseVisitor,\n\t\t\t\t\t\t\t\tuseGraphQLModules: false,\n\t\t\t\t\t\t\t\tfieldTypes,\n\t\t\t\t\t\t\t\tfieldArguments,\n\t\t\t\t\t\t\t\textensionsPath,\n\t\t\t\t\t\t\t\trootTypes: [\n\t\t\t\t\t\t\t\t\tschema.getQueryType()?.name || '',\n\t\t\t\t\t\t\t\t\tschema.getMutationType()?.name || '',\n\t\t\t\t\t\t\t\t\tschema.getSubscriptionType()?.name || '',\n\t\t\t\t\t\t\t\t].filter(Boolean),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tconfig: options.config,\n\t\t\t\tschemaAst: options.schemaAst,\n\t\t\t};\n\t\t});\n\n\t\treturn [baseOutput].concat(outputs);\n\t},\n};\n\nexport default preset;\n","import type { BaseVisitor } from '@graphql-codegen/visitor-plugin-common';\nimport { pascalCase } from 'change-case-all';\nimport {\n\ttype DocumentNode,\n\ttype EnumTypeDefinitionNode,\n\ttype EnumTypeExtensionNode,\n\ttype GraphQLSchema,\n\ttype InputObjectTypeDefinitionNode,\n\ttype InputObjectTypeExtensionNode,\n\ttype InterfaceTypeDefinitionNode,\n\ttype InterfaceTypeExtensionNode,\n\tKind,\n\ttype ObjectTypeDefinitionNode,\n\ttype ObjectTypeExtensionNode,\n\ttype TypeDefinitionNode,\n\ttype TypeExtensionNode,\n\ttype UnionTypeDefinitionNode,\n\tisInterfaceType,\n\tisScalarType,\n\tisUnionType,\n\tvisit,\n} from 'graphql';\nimport type { ModulesConfig } from './config.ts';\nimport {\n\tbuildBlock,\n\tcollectUsedTypes,\n\tconcatByKey,\n\tcreateObject,\n\tindent,\n\tpushUnique,\n\tunique,\n\tuniqueByKey,\n\twithQuotes,\n} from './utils.ts';\n\ntype RegistryKeys = 'objects' | 'inputs' | 'interfaces' | 'scalars' | 'unions' | 'enums';\ntype Registry = Record<RegistryKeys, string[]>;\nconst registryKeys: RegistryKeys[] = [\n\t'objects',\n\t'inputs',\n\t'interfaces',\n\t'scalars',\n\t'unions',\n\t'enums',\n];\nconst resolverKeys: Extract<RegistryKeys, 'objects' | 'enums' | 'scalars'>[] = [\n\t'scalars',\n\t'objects',\n\t'enums',\n];\n\nexport function buildModule(\n\tname: string,\n\tdoc: DocumentNode,\n\t{\n\t\timportNamespace,\n\t\timportPath,\n\t\tencapsulate,\n\t\trequireRootResolvers,\n\t\tshouldDeclare,\n\t\trootTypes,\n\t\tschema,\n\t\tbaseVisitor,\n\t\tfieldTypes,\n\t\tfieldArguments,\n\t\textensionsPath,\n\t}: {\n\t\timportNamespace: string;\n\t\timportPath: string;\n\t\tencapsulate: ModulesConfig['encapsulateModuleTypes'];\n\t\trequireRootResolvers: ModulesConfig['requireRootResolvers'];\n\t\tshouldDeclare: boolean;\n\t\trootTypes: string[];\n\t\tbaseVisitor: BaseVisitor;\n\t\tschema?: GraphQLSchema;\n\t\tuseGraphQLModules: boolean;\n\t\tfieldTypes: Record<string, Record<string, string>>;\n\t\tfieldArguments: Record<string, Record<string, boolean>>;\n\t\textensionsPath?: string;\n\t},\n): string {\n\tconst picks: Record<RegistryKeys, Record<string, string[]>> = createObject(\n\t\tregistryKeys,\n\t\t() => ({}),\n\t);\n\tconst defined: Registry = createObject(registryKeys, () => []);\n\tconst extended: Registry = createObject(registryKeys, () => []);\n\n\t// List of types used in objects, fields, arguments etc\n\tconst usedTypes = collectUsedTypes(doc);\n\n\tvisit(doc, {\n\t\tObjectTypeDefinition(node) {\n\t\t\tcollectTypeDefinition(node);\n\t\t},\n\t\tObjectTypeExtension(node) {\n\t\t\tcollectTypeExtension(node);\n\t\t},\n\t\tInputObjectTypeDefinition(node) {\n\t\t\tcollectTypeDefinition(node);\n\t\t},\n\t\tInputObjectTypeExtension(node) {\n\t\t\tcollectTypeExtension(node);\n\t\t},\n\t\tInterfaceTypeDefinition(node) {\n\t\t\tcollectTypeDefinition(node);\n\t\t},\n\t\tInterfaceTypeExtension(node) {\n\t\t\tcollectTypeExtension(node);\n\t\t},\n\t\tScalarTypeDefinition(node) {\n\t\t\tcollectTypeDefinition(node);\n\t\t},\n\t\tUnionTypeDefinition(node) {\n\t\t\tcollectTypeDefinition(node);\n\t\t},\n\t\tUnionTypeExtension(node) {\n\t\t\tcollectTypeExtension(node);\n\t\t},\n\t\tEnumTypeDefinition(node) {\n\t\t\tcollectTypeDefinition(node);\n\t\t},\n\t\tEnumTypeExtension(node) {\n\t\t\tcollectTypeExtension(node);\n\t\t},\n\t});\n\n\t// Defined and Extended types\n\tconst visited: Registry = createObject(registryKeys, (key) =>\n\t\tconcatByKey(defined, extended, key),\n\t);\n\n\t// Types that are not defined or extended in a module, they come from other modules\n\tconst external: Registry = createObject(registryKeys, (key) =>\n\t\tuniqueByKey(extended, defined, key),\n\t);\n\n\t//\n\t//\n\t//\n\t// Prints\n\t//\n\t//\n\t//\n\n\t// An actual output\n\tconst imports = [\n\t\t`import * as ${importNamespace} from \"${importPath}\";`,\n\t\t'import { DocumentNode } from \"graphql\";',\n\t\t'import * as Baeta from \"@baeta/core/sdk\";',\n\t];\n\n\tif (extensionsPath) {\n\t\timports.push(`import baetaExtensions from \"${extensionsPath}\";`);\n\t}\n\n\timports.push('\\n');\n\n\tlet content = [\n\t\tprintDefinedFields(),\n\t\tprintDefinedEnumValues(),\n\t\tprintDefinedInputFields(),\n\t\tprintSchemaTypes(usedTypes),\n\t\tprintMetadata(),\n\t]\n\t\t.filter(Boolean)\n\t\t.join('\\n\\n');\n\n\tconst moduleNamespace = baseVisitor.convertName(name, {\n\t\tsuffix: 'Module',\n\t\tuseTypesPrefix: false,\n\t\tuseTypesSuffix: false,\n\t});\n\n\tif (encapsulate === 'namespace') {\n\t\tcontent = `${shouldDeclare ? 'declare' : 'export'} namespace ${baseVisitor.convertName(name, {\n\t\t\tsuffix: 'Module',\n\t\t\tuseTypesPrefix: false,\n\t\t\tuseTypesSuffix: false,\n\t\t})} {\\n${shouldDeclare ? `${indent(2)(imports.join('\\n'))}\\n` : ''}${indent(2)(content)}\\n}`;\n\t}\n\n\treturn [...(shouldDeclare ? [] : imports), content, printFactoryMethod()]\n\t\t.filter(Boolean)\n\t\t.join('\\n');\n\n\tfunction printMetadata() {\n\t\treturn `export namespace ModuleMetadata {\n export const id = '${name}';\n export const dirname = './${name}';\n export const typedef = ${JSON.stringify(doc)} as unknown as DocumentNode;\n ${printBaetaManager()}\n}`;\n\t}\n\n\t/**\n\t * A dictionary of fields to pick from an object\n\t */\n\tfunction printDefinedFields() {\n\t\treturn buildBlock({\n\t\t\tname: 'interface DefinedFields',\n\t\t\tlines: [...visited.objects, ...visited.interfaces].map(\n\t\t\t\t(typeName) =>\n\t\t\t\t\t`${typeName}: ${printPicks(typeName, {\n\t\t\t\t\t\t...picks.objects,\n\t\t\t\t\t\t...picks.interfaces,\n\t\t\t\t\t})};`,\n\t\t\t),\n\t\t});\n\t}\n\n\tfunction printFactoryMethod() {\n\t\tconst name = moduleNamespace.slice(0, moduleNamespace.length - 6);\n\t\tconst createModuleFn = `create${name}Module`;\n\t\tconst getModuleFn = `get${name}Module`;\n\t\tconst extensionsArg = extensionsPath ? ', baetaExtensions' : '';\n\n\t\treturn `\nexport const ${createModuleFn} = () => Baeta.createModuleManager(ModuleMetadata${extensionsArg});\nexport const ${getModuleFn} = Baeta.createSingletonModule(${createModuleFn});\n`;\n\t}\n\n\t/**\n\t * Baeta manager\n\t */\n\n\tfunction printObjectFieldResolverBuilder(typeName: string, field: string) {\n\t\tconst parentType = getParentType(typeName);\n\t\tconst resultType = getResultType(typeName, field);\n\t\tconst argumentsType = getArgsType(typeName, field);\n\t\tconst contextType = getContextType();\n\t\treturn `${field}: module.createResolverBuilder<${resultType}, ${parentType}, ${contextType}, ${argumentsType}>(\"${typeName}\", \"${field}\"),`;\n\t}\n\n\tfunction printObjectResolverBuilder(typeName: string, objects: Record<string, string[]>) {\n\t\tconst fields =\n\t\t\tobjects[typeName]\n\t\t\t\t?.filter(unique)\n\t\t\t\t.map((field) => printObjectFieldResolverBuilder(typeName, field)) ?? [];\n\n\t\tif (fields.length === 0) {\n\t\t\treturn '';\n\t\t}\n\n\t\tconst parentType = getParentType(typeName);\n\t\tconst contextType = getContextType();\n\n\t\tconst addons = [`...module.createTypeMethods<${parentType}, ${contextType}>(\"${typeName}\"),`];\n\t\tconst contentBody = [...addons, ...fields].map(indent(2)).join('\\n');\n\t\tconst content = `{\\n${contentBody}\\n}`;\n\t\treturn `${typeName}: ${content},`;\n\t}\n\n\tfunction printSubscriptionFieldBuilder(field: string) {\n\t\tconst parentType = getParentType('Subscription');\n\t\tconst resultType = getResultType('Subscription', field);\n\t\tconst argumentsType = getArgsType('Subscription', field);\n\t\tconst contextType = getContextType();\n\t\treturn `${field}: module.createSubscriptionBuilder<${resultType}, ${parentType}, ${contextType}, ${argumentsType}>(\"${field}\"),`;\n\t}\n\n\tfunction printSubscriptionObjectBuilder() {\n\t\tconst subscriptions = picks.objects.Subscription?.filter(unique) ?? [];\n\n\t\tif (subscriptions.length === 0) {\n\t\t\treturn '';\n\t\t}\n\n\t\tconst fields = subscriptions.map((subscription) => printSubscriptionFieldBuilder(subscription));\n\n\t\tconst parentType = getParentType('Subscription');\n\t\tconst contextType = getContextType();\n\t\tconst addons = [`...module.createSubscriptionMethods<${parentType}, ${contextType}>(),`];\n\t\tconst contentBody = [...addons, ...fields].map(indent(2)).join('\\n');\n\n\t\tconst content = `{\\n${contentBody}\\n}`;\n\t\treturn `Subscription: ${content},`;\n\t}\n\n\tfunction printScalarBuilder() {\n\t\tconst scalars = visited.scalars;\n\t\tif (scalars.length === 0) {\n\t\t\treturn '';\n\t\t}\n\n\t\tconst fields = scalars.map((scalar) => `${scalar}: module.createScalarBuilder(\"${scalar}\"),`);\n\t\tconst content = fields.map(indent(2)).join('\\n');\n\t\treturn `Scalar: {\\n${content}\\n},`;\n\t}\n\n\tfunction printTypenameResolverBuilder(\n\t\tname: string,\n\t\tresultNamespace: string,\n\t\tvalueNamespace: string,\n\t) {\n\t\tconst resultType = `${importNamespace}.${resultNamespace}[\"${name}\"]`;\n\t\tconst valueType = `${importNamespace}.${valueNamespace}[\"${name}\"]`;\n\t\tconst contextType = getContextType();\n\t\tconst resolver = `$resolveType: module.createResolveType<${resultType}, ${valueType}, ${contextType}>(\"${name}\"),`;\n\t\treturn `${name}: {\\n${indent(2)(resolver)}\\n},`;\n\t}\n\n\tfunction printInterfaceBuilder() {\n\t\tconst interfaces = defined.interfaces;\n\n\t\tif (interfaces.length === 0) {\n\t\t\treturn '';\n\t\t}\n\n\t\treturn interfaces\n\t\t\t.map((interfaceName) =>\n\t\t\t\tprintTypenameResolverBuilder(\n\t\t\t\t\tinterfaceName,\n\t\t\t\t\t'DefinedInterfacesResults',\n\t\t\t\t\t'DefinedInterfacesWithoutExtensions',\n\t\t\t\t),\n\t\t\t)\n\t\t\t.join('\\n');\n\t}\n\n\tfunction printUnionBuilder() {\n\t\tconst unions = defined.unions;\n\n\t\tif (unions.length === 0) {\n\t\t\treturn '';\n\t\t}\n\n\t\treturn unions\n\t\t\t.map((unionName) =>\n\t\t\t\tprintTypenameResolverBuilder(\n\t\t\t\t\tunionName,\n\t\t\t\t\t'DefinedUnionsResults',\n\t\t\t\t\t'DefinedUnionsWithoutExtensions',\n\t\t\t\t),\n\t\t\t)\n\t\t\t.join('\\n');\n\t}\n\n\tfunction printBaetaManager() {\n\t\tconst objects = visited.objects\n\t\t\t.filter((type) => type !== 'Subscription')\n\t\t\t.map((typeName) => printObjectResolverBuilder(typeName, picks.objects))\n\t\t\t.filter(Boolean);\n\n\t\tconst contextType = getContextType();\n\t\tconst addons = [`...module.createModuleMethods<${contextType}>(),`];\n\n\t\tconst bodyFields = [\n\t\t\t...addons,\n\t\t\t...objects,\n\t\t\tprintScalarBuilder(),\n\t\t\tprintSubscriptionObjectBuilder(),\n\t\t\tprintInterfaceBuilder(),\n\t\t\tprintUnionBuilder(),\n\t\t];\n\n\t\tconst body = bodyFields.filter(Boolean).map(indent(6)).join('\\n');\n\t\tconst content = `{\\n${body}\\n }`;\n\n\t\treturn `\n export function createManager(module: Baeta.ModuleBuilder) {\n return ${content};\n }`;\n\t}\n\n\t/**\n\t * A dictionary of values to pick from an enum\n\t */\n\tfunction printDefinedEnumValues() {\n\t\treturn buildBlock({\n\t\t\tname: 'interface DefinedEnumValues',\n\t\t\tlines: visited.enums.map((typeName) => `${typeName}: ${printPicks(typeName, picks.enums)};`),\n\t\t});\n\t}\n\n\tfunction encapsulateTypeName(typeName: string): string {\n\t\tif (encapsulate === 'prefix') {\n\t\t\treturn `${pascalCase(name)}_${typeName}`;\n\t\t}\n\n\t\treturn typeName;\n\t}\n\n\t/**\n\t * A dictionary of fields to pick from an input\n\t */\n\tfunction printDefinedInputFields() {\n\t\treturn buildBlock({\n\t\t\tname: 'interface DefinedInputFields',\n\t\t\tlines: visited.inputs.map(\n\t\t\t\t(typeName) => `${typeName}: ${printPicks(typeName, picks.inputs)};`,\n\t\t\t),\n\t\t});\n\t}\n\n\t/**\n\t * Prints signatures of schema types with picks\n\t */\n\tfunction printSchemaTypes(types: string[]) {\n\t\treturn types\n\t\t\t.filter((type) => !visited.scalars.includes(type))\n\t\t\t.map(printExportType)\n\t\t\t.join('\\n');\n\t}\n\n\tfunction printPicks(typeName: string, records: Record<string, string[]>): string {\n\t\treturn records[typeName].filter(unique).map(withQuotes).join(' | ');\n\t}\n\n\tfunction printTypeBody(typeName: string): string {\n\t\tconst normalizedTypeName = baseVisitor.convertName(typeName, {\n\t\t\tuseTypesSuffix: true,\n\t\t\tuseTypesPrefix: true,\n\t\t});\n\n\t\tconst coreType = `${importNamespace}.${normalizedTypeName}`;\n\n\t\tif (external.enums.includes(typeName) || external.objects.includes(typeName)) {\n\t\t\tif (schema && isScalarType(schema.getType(typeName))) {\n\t\t\t\treturn `${importNamespace}.Scalars['${typeName}']`;\n\t\t\t}\n\n\t\t\treturn `Pick<${coreType}, ${importNamespace}.DefinedFieldsWithoutExtensions[\"${typeName}\"]>`;\n\t\t}\n\n\t\tif (external.unions.includes(typeName)) {\n\t\t\treturn `${importNamespace}.DefinedUnionsWithoutExtensions[\"${typeName}\"]`;\n\t\t}\n\n\t\tif (external.interfaces.includes(typeName)) {\n\t\t\treturn `Pick<${coreType}, ${importNamespace}.DefinedFieldsWithoutExtensions[\"${typeName}\"]>`;\n\t\t}\n\n\t\tif (defined.enums.includes(typeName) && picks.enums[typeName]) {\n\t\t\treturn `DefinedEnumValues['${typeName}']`;\n\t\t}\n\n\t\tif (defined.unions.includes(typeName) && picks.unions[typeName]) {\n\t\t\treturn `${importNamespace}.DefinedUnionsWithoutExtensions[\"${typeName}\"]`;\n\t\t}\n\n\t\tif (defined.objects.includes(typeName) && picks.objects[typeName]) {\n\t\t\treturn `Pick<${coreType}, DefinedFields['${typeName}']>`;\n\t\t}\n\n\t\tif (defined.interfaces.includes(typeName) && picks.interfaces[typeName]) {\n\t\t\treturn `${importNamespace}.DefinedInterfacesWithoutExtensions[\"${typeName}\"]`;\n\t\t}\n\n\t\tif (defined.inputs.includes(typeName) && picks.inputs[typeName]) {\n\t\t\treturn `Pick<${coreType}, DefinedInputFields['${typeName}']>`;\n\t\t}\n\n\t\tif (isScalarType(schema?.getType(typeName))) {\n\t\t\treturn coreType;\n\t\t}\n\n\t\tif (isInterfaceType(schema?.getType(typeName))) {\n\t\t\treturn `${importNamespace}.DefinedInterfacesWithoutExtensions[\"${typeName}\"]`;\n\t\t}\n\n\t\tif (isUnionType(schema?.getType(typeName))) {\n\t\t\treturn `${importNamespace}.DefinedUnionsWithoutExtensions[\"${typeName}\"]`;\n\t\t}\n\n\t\treturn `Pick<${coreType}, ${importNamespace}.DefinedFieldsWithoutExtensions[\"${typeName}\"]>`;\n\t}\n\n\tfunction printExportType(typeName: string): string {\n\t\treturn `export type ${encapsulateTypeName(typeName)} = ${printTypeBody(typeName)};`;\n\t}\n\n\t//\n\t//\n\t//\n\t// Utils\n\t//\n\t//\n\t//\n\n\tfunction collectFields(\n\t\tnode:\n\t\t\t| ObjectTypeDefinitionNode\n\t\t\t| ObjectTypeExtensionNode\n\t\t\t| InterfaceTypeDefinitionNode\n\t\t\t| InterfaceTypeExtensionNode\n\t\t\t| InputObjectTypeDefinitionNode\n\t\t\t| InputObjectTypeExtensionNode,\n\t\tpicksObj: Record<string, string[]>,\n\t) {\n\t\tconst name = node.name.value;\n\n\t\tif (node.fields) {\n\t\t\tif (!picksObj[name]) {\n\t\t\t\tpicksObj[name] = [];\n\t\t\t}\n\n\t\t\tfor (const field of node.fields) {\n\t\t\t\tpicksObj[name].push(field.name.value);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction collectValuesFromEnum(node: EnumTypeDefinitionNode | EnumTypeExtensionNode) {\n\t\tconst name = node.name.value;\n\n\t\tif (node.values) {\n\t\t\tif (!picks.enums[name]) {\n\t\t\t\tpicks.enums[name] = [];\n\t\t\t}\n\n\t\t\tfor (const field of node.values) {\n\t\t\t\tpicks.enums[name].push(field.name.value);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction collectUnionTypes(node: UnionTypeDefinitionNode) {\n\t\tconst name = node.name.value;\n\n\t\tif (node.types) {\n\t\t\tif (!picks.unions[name]) {\n\t\t\t\tpicks.unions[name] = [];\n\t\t\t}\n\n\t\t\tfor (const type of node.types) {\n\t\t\t\tpicks.unions[name].push(type.name.value);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction collectTypeDefinition(node: TypeDefinitionNode) {\n\t\tconst name = node.name.value;\n\n\t\tswitch (node.kind) {\n\t\t\tcase Kind.OBJECT_TYPE_DEFINITION: {\n\t\t\t\tdefined.objects.push(name);\n\t\t\t\tcollectFields(node, picks.objects);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.ENUM_TYPE_DEFINITION: {\n\t\t\t\tdefined.enums.push(name);\n\t\t\t\tcollectValuesFromEnum(node);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.INPUT_OBJECT_TYPE_DEFINITION: {\n\t\t\t\tdefined.inputs.push(name);\n\t\t\t\tcollectFields(node, picks.inputs);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.SCALAR_TYPE_DEFINITION: {\n\t\t\t\tdefined.scalars.push(name);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.INTERFACE_TYPE_DEFINITION: {\n\t\t\t\tdefined.interfaces.push(name);\n\t\t\t\tcollectFields(node, picks.interfaces);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.UNION_TYPE_DEFINITION: {\n\t\t\t\tdefined.unions.push(name);\n\t\t\t\tcollectUnionTypes(node);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction collectTypeExtension(node: TypeExtensionNode) {\n\t\tconst name = node.name.value;\n\n\t\tswitch (node.kind) {\n\t\t\tcase Kind.OBJECT_TYPE_EXTENSION: {\n\t\t\t\tcollectFields(node, picks.objects);\n\t\t\t\t// Do not include root types as extensions\n\t\t\t\t// so we can use them in DefinedFields\n\t\t\t\tif (rootTypes.includes(name)) {\n\t\t\t\t\tpushUnique(defined.objects, name);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tpushUnique(extended.objects, name);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.ENUM_TYPE_EXTENSION: {\n\t\t\t\tcollectValuesFromEnum(node);\n\t\t\t\tpushUnique(extended.enums, name);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.INPUT_OBJECT_TYPE_EXTENSION: {\n\t\t\t\tcollectFields(node, picks.inputs);\n\t\t\t\tpushUnique(extended.inputs, name);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.INTERFACE_TYPE_EXTENSION: {\n\t\t\t\tcollectFields(node, picks.interfaces);\n\t\t\t\tpushUnique(extended.interfaces, name);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.UNION_TYPE_EXTENSION: {\n\t\t\t\tpushUnique(extended.unions, name);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction getParentType(type: string) {\n\t\tif (['Query', 'Mutation', 'Subscription'].includes(type)) {\n\t\t\treturn '{}';\n\t\t}\n\t\treturn type;\n\t}\n\n\tfunction getResultType(type: string, field: string) {\n\t\treturn fieldTypes?.[type]?.[field] || '{}';\n\t}\n\n\tfunction getArgsType(type: string, field: string) {\n\t\tconst hasArgs = fieldArguments?.[type]?.[field] ?? false;\n\t\tif (!hasArgs) {\n\t\t\treturn '{}';\n\t\t}\n\t\tconst fieldUpper = field[0].toUpperCase() + field.slice(1);\n\t\treturn `Types.${type}${fieldUpper}Args`;\n\t}\n\n\tfunction getContextType() {\n\t\treturn 'Types.ContextType';\n\t}\n}\n","import { platform } from 'node:os';\nimport { getBaseType } from '@graphql-codegen/plugin-helpers';\nimport { DEFAULT_SCALARS, wrapTypeWithModifiers } from '@graphql-codegen/visitor-plugin-common';\nimport type { Source } from '@graphql-tools/utils';\nimport {\n\ttype DefinitionNode,\n\ttype DocumentNode,\n\ttype FieldDefinitionNode,\n\ttype GraphQLFieldMap,\n\ttype GraphQLObjectType,\n\ttype GraphQLSchema,\n\ttype InputValueDefinitionNode,\n\tKind,\n\ttype NamedTypeNode,\n\ttype ObjectTypeDefinitionNode,\n\ttype TypeNode,\n} from 'graphql';\nimport parse from 'parse-filepath';\n\nconst sep = '/';\n\n/**\n * Searches every node to collect used types\n */\nexport function collectUsedTypes(doc: DocumentNode): string[] {\n\tconst used: string[] = [];\n\n\tfor (const definition of doc.definitions) {\n\t\tfindRelated(definition);\n\t}\n\n\tfunction markAsUsed(type: string) {\n\t\tpushUnique(used, type);\n\t}\n\n\tfunction findRelated(\n\t\tnode: DefinitionNode | FieldDefinitionNode | InputValueDefinitionNode | NamedTypeNode,\n\t) {\n\t\tif (node.kind === Kind.OBJECT_TYPE_DEFINITION || node.kind === Kind.OBJECT_TYPE_EXTENSION) {\n\t\t\t// Object\n\t\t\tmarkAsUsed(node.name.value);\n\n\t\t\tif (node.fields) {\n\t\t\t\tfor (const field of node.fields) {\n\t\t\t\t\tfindRelated(field);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (node.interfaces) {\n\t\t\t\tfor (const _interface of node.interfaces) {\n\t\t\t\t\tfindRelated(_interface);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (\n\t\t\tnode.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ||\n\t\t\tnode.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION\n\t\t) {\n\t\t\t// Input\n\t\t\tmarkAsUsed(node.name.value);\n\n\t\t\tif (node.fields) {\n\t\t\t\tfor (const field of node.fields) {\n\t\t\t\t\tfindRelated(field);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (\n\t\t\tnode.kind === Kind.INTERFACE_TYPE_DEFINITION ||\n\t\t\tnode.kind === Kind.INTERFACE_TYPE_EXTENSION\n\t\t) {\n\t\t\t// Interface\n\t\t\tmarkAsUsed(node.name.value);\n\n\t\t\tif (node.fields) {\n\t\t\t\tfor (const field of node.fields) {\n\t\t\t\t\tfindRelated(field);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (node.interfaces) {\n\t\t\t\tfor (const _interface of node.interfaces) {\n\t\t\t\t\tfindRelated(_interface);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (\n\t\t\tnode.kind === Kind.UNION_TYPE_DEFINITION ||\n\t\t\tnode.kind === Kind.UNION_TYPE_EXTENSION\n\t\t) {\n\t\t\t// Union\n\t\t\tmarkAsUsed(node.name.value);\n\n\t\t\tif (node.types) {\n\t\t\t\tfor (const type of node.types) {\n\t\t\t\t\tfindRelated(type);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (node.kind === Kind.ENUM_TYPE_DEFINITION || node.kind === Kind.ENUM_TYPE_EXTENSION) {\n\t\t\t// Enum\n\t\t\tmarkAsUsed(node.name.value);\n\t\t} else if (\n\t\t\tnode.kind === Kind.SCALAR_TYPE_DEFINITION ||\n\t\t\tnode.kind === Kind.SCALAR_TYPE_EXTENSION\n\t\t) {\n\t\t\t// Scalar\n\t\t\tif (!isGraphQLPrimitive(node.name.value)) {\n\t\t\t\tmarkAsUsed(node.name.value);\n\t\t\t}\n\t\t} else if (node.kind === Kind.INPUT_VALUE_DEFINITION) {\n\t\t\t// Argument\n\t\t\tfindRelated(resolveTypeNode(node.type));\n\t\t} else if (node.kind === Kind.FIELD_DEFINITION) {\n\t\t\t// Field\n\t\t\tfindRelated(resolveTypeNode(node.type));\n\n\t\t\tif (node.arguments) {\n\t\t\t\tfor (const argument of node.arguments) {\n\t\t\t\t\tfindRelated(argument);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (\n\t\t\tnode.kind === Kind.NAMED_TYPE &&\n\t\t\t// Named type\n\t\t\t!isGraphQLPrimitive(node.name.value)\n\t\t) {\n\t\t\tmarkAsUsed(node.name.value);\n\t\t}\n\t}\n\n\treturn used;\n}\n\nfunction collectObjectFieldType(\n\tnode: ObjectTypeDefinitionNode,\n\tfieldDefinition: FieldDefinitionNode,\n\tfieldsMap: GraphQLFieldMap<unknown, unknown>,\n\tfieldTypes: Record<string, Record<string, string>>,\n) {\n\tconst objectName = node.name.value;\n\tconst fieldName = fieldDefinition.name.value;\n\n\tconst field = fieldsMap[fieldDefinition.name.value];\n\tconst baseName = getBaseType(field.type).name;\n\tconst isDefaultScalar = DEFAULT_SCALARS[baseName] != null;\n\tconst name = isDefaultScalar ? `Types.Scalars[\"${baseName}\"][\"output\"]` : baseName;\n\n\tconst type = wrapTypeWithModifiers(name, field.type, {\n\t\twrapOptional: (str: string) => {\n\t\t\treturn `Types.Maybe<${str}>`;\n\t\t},\n\t\twrapArray: (str: string) => {\n\t\t\treturn `Array<${str}>`;\n\t\t},\n\t});\n\n\tif (fieldTypes[objectName] == null) {\n\t\tfieldTypes[objectName] = {};\n\t}\n\tfieldTypes[objectName][fieldName] = type;\n}\n\nfunction collectObjectFieldArguments(\n\tnode: ObjectTypeDefinitionNode,\n\tfieldDefinition: FieldDefinitionNode,\n\tfieldArguments: Record<string, Record<string, boolean>>,\n) {\n\tconst objectName = node.name.value;\n\tconst fieldName = fieldDefinition.name.value;\n\tconst hasArguments = fieldDefinition.arguments != null && fieldDefinition.arguments.length > 0;\n\n\tif (fieldArguments[objectName] == null) {\n\t\tfieldArguments[objectName] = {};\n\t}\n\tfieldArguments[objectName][fieldName] = hasArguments;\n}\n\nexport function collectObjectFieldTypesAndArguments(schema?: GraphQLSchema) {\n\tconst fieldTypes: Record<string, Record<string, string>> = {};\n\tconst fieldArguments: Record<string, Record<string, boolean>> = {};\n\n\tif (!schema) {\n\t\treturn { fieldTypes, fieldArguments };\n\t}\n\n\tconst schemaTypes = schema.getTypeMap();\n\n\tfor (const type of Object.values(schemaTypes)) {\n\t\tif (type.astNode?.kind !== Kind.OBJECT_TYPE_DEFINITION) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst schemaType = schemaTypes[type.name] as GraphQLObjectType;\n\t\tconst fieldsMap = schemaType.getFields();\n\n\t\tfor (const field of type.astNode.fields ?? []) {\n\t\t\tcollectObjectFieldArguments(type.astNode, field, fieldArguments);\n\t\t\tcollectObjectFieldType(type.astNode, field, fieldsMap, fieldTypes);\n\t\t}\n\t}\n\n\treturn { fieldTypes, fieldArguments };\n}\n\nexport function resolveTypeNode(node: TypeNode): NamedTypeNode {\n\tif (node.kind === Kind.LIST_TYPE) {\n\t\treturn resolveTypeNode(node.type);\n\t}\n\n\tif (node.kind === Kind.NON_NULL_TYPE) {\n\t\treturn resolveTypeNode(node.type);\n\t}\n\n\treturn node;\n}\n\nexport function isGraphQLPrimitive(name: string): boolean {\n\treturn ['String', 'Boolean', 'ID', 'Float', 'Int'].includes(name);\n}\n\nexport function unique<T>(val: T, i: number, all: T[]): boolean {\n\treturn i === all.indexOf(val);\n}\n\nexport function withQuotes(val: string): string {\n\treturn `'${val}'`;\n}\n\nexport function indent(size: number) {\n\tconst space = new Array(size).fill(' ').join('');\n\n\tfunction indentInner(val: string): string {\n\t\treturn val\n\t\t\t.split('\\n')\n\t\t\t.map((line) => `${space}${line}`)\n\t\t\t.join('\\n');\n\t}\n\n\treturn indentInner;\n}\n\nexport function buildBlock({ name, lines }: { name: string; lines: string[] }): string {\n\tif (!lines.length) {\n\t\treturn '';\n\t}\n\n\treturn [`${name} {`, ...lines.map(indent(2)), '};'].join('\\n');\n}\n\nconst getRelativePath = (filepath: string, basePath: string) => {\n\tconst normalizedFilepath = normalize(filepath);\n\tconst normalizedBasePath = ensureStartsWithSeparator(\n\t\tnormalize(ensureEndsWithSeparator(basePath)),\n\t);\n\tconst [, relativePath] = normalizedFilepath.split(normalizedBasePath);\n\treturn relativePath;\n};\n\nexport function groupSourcesByModule(\n\tsources: Source[],\n\tbasePath: string,\n): Record<string, Source[]> {\n\tconst grouped: Record<string, Source[]> = {};\n\n\tfor (const source of sources) {\n\t\tif (!source.location) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst relativePath = getRelativePath(source.location, basePath);\n\n\t\tif (relativePath) {\n\t\t\t// PERF: we could guess the module by matching source.location with a list of already resolved paths\n\t\t\tconst mod = extractModuleDirectory(source.location, basePath);\n\n\t\t\tif (!grouped[mod]) {\n\t\t\t\tgrouped[mod] = [];\n\t\t\t}\n\n\t\t\tgrouped[mod].push(source);\n\t\t}\n\t}\n\n\treturn grouped;\n}\n\nfunction extractModuleDirectory(filepath: string, basePath: string): string {\n\tconst relativePath = getRelativePath(filepath, basePath);\n\n\tconst [moduleDirectory] = relativePath.split(sep);\n\n\treturn moduleDirectory;\n}\n\nexport function stripFilename(path: string) {\n\tconst parsedPath = parse(path);\n\treturn normalize(parsedPath.dir);\n}\n\nexport function normalize(path: string) {\n\treturn path.replace(/\\\\/g, '/');\n}\n\nfunction ensureEndsWithSeparator(path: string) {\n\treturn path.endsWith(sep) ? path : path + sep;\n}\n\nfunction ensureStartsWithSeparator(path: string) {\n\tif (platform() === 'win32') {\n\t\treturn path;\n\t}\n\n\treturn path.startsWith('.')\n\t\t? path.replace(/^(..\\/)|(.\\/)/, '/')\n\t\t: path.startsWith('/')\n\t\t\t? path\n\t\t\t: `/${path}`;\n}\n\n/**\n * Pushes an item to a list only if the list doesn't include the item\n */\nexport function pushUnique<T>(list: T[], item: T): void {\n\tif (!list.includes(item)) {\n\t\tlist.push(item);\n\t}\n}\n\nexport function concatByKey<T extends Record<string, string[]>, K extends keyof T>(\n\tleft: T,\n\tright: T,\n\tkey: K,\n) {\n\t// Remove duplicate, if an element is in right & left, it will be only once in the returned array.\n\treturn [...new Set([...left[key], ...right[key]])];\n}\n\nexport function uniqueByKey<T extends Record<string, string[]>, K extends keyof T>(\n\tleft: T,\n\tright: T,\n\tkey: K,\n) {\n\treturn left[key].filter((item) => !right[key].includes(item));\n}\n\nexport function createObject<K extends string, T>(keys: K[], valueFn: (key: K) => T) {\n\tconst obj: Record<K, T> = {} as Record<K, T>;\n\n\tfor (const key of keys) {\n\t\tobj[key] = valueFn(key);\n\t}\n\n\treturn obj;\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/baeta/baeta/packages/plugin-graphql/dist/index.cjs","../index.ts","../lib/codegen.ts","../utils/cache.ts","../utils/load.ts","../utils/hash.ts","../utils/scalars.ts","../lib/context/index.ts","../lib/modules/index.ts","../lib/modules/builder.ts","../lib/modules/hashes.ts","../lib/modules/utils.ts"],"names":["getCachedDocumentNodeFromSchema","parseMapper","isScalarType","Kind","name","sources","unionsDefinition","types","typePicks","result"],"mappings":"AAAA,uiCAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,SAAS,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG;AAChC,EAAE,IAAI,CAAC,IAAI,KAAK,GAAG,GAAG;AACtB,IAAI,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;AACjE,CAAC;AACD;AACA;ACNA,oDAA0D;ADQ1D;AACA;AERA,4CAAqB;AACrB,6CAAsC;AACtC,gEAA0D;AAC1D,sHAAkC;AFUlC;AACA;AGfO,SAAS,WAAA,CAAA,EAIA;AACf,EAAA,MAAM,MAAA,kBAAQ,IAAI,GAAA,CAA8B,CAAA;AAEhD,EAAA,OAAO,SAAS,MAAA,CAAU,SAAA,EAAmB,GAAA,EAAa,OAAA,EAAuC;AAChG,IAAA,MAAM,SAAA,EAAW,CAAA,EAAA;AAEX,IAAA;AAEW,IAAA;AACT,MAAA;AACR,IAAA;AAEc,IAAA;AACJ,IAAA;AAEH,IAAA;AACR,EAAA;AACD;AHQsB;AACA;AI9Bb;AACA;AACT;AAEe;AACR;AAEgC;AJ8BjB;AACA;AKtCb;AACA;AACiC;AAEd;AACT,EAAA;AACnB;AAE2B;AACP,EAAA;AACpB;ALsCsB;AACA;AIvCA;AAKf,EAAA;AACS,IA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QAAA;AACZ,MAAA;AACA,IAAA;AAEiB,IAAA;AACnB,EAAA;AACD;AR+xBsB;AACA;AEnjCA;AACF,EAAA;AACT,IAAA;AACG,IAAA;AACG,IAAA;AACF,IAAA;AACb,IAAA;AACiB,IAAA;AACR,IAAA;AACE,IAAA;AACE,MAAA;AACH,MAAA;AACV,IAAA;AACD,EAAA;AAEc,EAAA;AAER,EAAA;AACY,EAAA;AACN,IAAA;AACV,MAAA;AACiB,IAAA;AACH,MAAA;AACf,IAAA;AACD,EAAA;AAEkB,EAAA;AACH,EAAA;AACI,IAAA;AAClB,EAAA;AAEe,EAAA;AACA,IAAA;AACD,IAAA;AACE,MAAA;AACL,MAAA;AACV,MAAA;AACgB,MAAA;AAChB,MAAA;AACD,IAAA;AACe,IAAA;AACG,IAAA;AACN,IAAA;AACD,IAAA;AACF,IAAA;AACD,IAAA;AACP,MAAA;AACa,MAAA;AACG,MAAA;AACP,MAAA;AACG,QAAA;AACH,QAAA;AACK,QAAA;AACd,MAAA;AACD,IAAA;AACA,EAAA;AAEgB,EAAA;AACD,IAAA;AACX,MAAA;AACH,MAAA;AACA,IAAA;AAEM,IAAA;AACI,MAAA;AACDI,MAAAA;AACV,IAAA;AACA,EAAA;AAEkB,EAAA;AACpB;AF8iCsB;AACA;AC9nCN;AACR,EAAA;AACA,IAAA;AACM,IAAA;AACK,IAAA;AACV,MAAA;AACO,QAAA;AACA,UAAA;AACZ,QAAA;AACD,MAAA;AAEW,MAAA;AACA,MAAA;AACZ,IAAA;AACiB,IAAA;AACF,MAAA;AAEH,MAAA;AACN,QAAA;AACL,MAAA;AAEY,MAAA;AACb,IAAA;AACA,EAAA;AACF;AD6nCsB;AACA;AACA","file":"/home/runner/work/baeta/baeta/packages/plugin-graphql/dist/index.cjs","sourcesContent":[null,"import { type WatcherFile, createPluginV1, isMatch } from '@baeta/generator-sdk';\nimport { generate } from './lib/codegen.ts';\n\nexport function graphqlPlugin() {\n\treturn createPluginV1({\n\t\tname: 'graphql',\n\t\tactionName: 'GraphQL modules',\n\t\twatch: (options, watcher, reload) => {\n\t\t\tconst handleChange = (file: WatcherFile) => {\n\t\t\t\tif (isMatch(file.relativePath, options.schemas)) {\n\t\t\t\t\treload(file);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\twatcher.on('update', handleChange);\n\t\t\twatcher.on('delete', handleChange);\n\t\t},\n\t\tgenerate: async (ctx, next) => {\n\t\t\tconst items = await generate(ctx.generatorOptions);\n\n\t\t\tfor (const item of items) {\n\t\t\t\tctx.fileManager.createAndAdd(item.filename, item.content, 'graphql');\n\t\t\t}\n\n\t\t\treturn next();\n\t\t},\n\t});\n}\n","import type { NormalizedGeneratorOptions } from '@baeta/generator-sdk';\nimport { join } from '@baeta/util-path';\nimport { codegen as gqlCodegen } from '@graphql-codegen/core';\nimport { normalizeConfig, normalizeInstanceOrArray } from '@graphql-codegen/plugin-helpers';\nimport * as typescriptPlugin from '@graphql-codegen/typescript';\nimport type { UnnormalizedTypeDefPointer } from '@graphql-tools/load';\nimport { createCache } from '../utils/cache.ts';\nimport { loadSchema } from '../utils/load.ts';\nimport { buildScalarMap } from '../utils/scalars.ts';\nimport * as contextPlugin from './context/index.ts';\nimport * as modules from './modules/index.ts';\n\nexport async function generate(options: NormalizedGeneratorOptions) {\n\tconst rootConfig = {\n\t\tschemas: normalizeInstanceOrArray(options.schemas),\n\t\tmodulesDir: options.modulesDir,\n\t\tbaseTypesPath: options.baseTypesPath,\n\t\tcontextType: options.contextType,\n\t\tmoduleDefinitionName: options.moduleDefinitionName,\n\t\tscalars: options.scalars,\n\t\tplugins: normalizeConfig(['typescript', 'context']),\n\t\tpluginMap: {\n\t\t\ttypescript: typescriptPlugin,\n\t\t\tcontext: contextPlugin,\n\t\t},\n\t};\n\n\tconst cache = createCache();\n\n\tconst schemaPointerMap: UnnormalizedTypeDefPointer = {};\n\tfor (const ptr of rootConfig.schemas) {\n\t\tif (typeof ptr === 'string') {\n\t\t\tschemaPointerMap[ptr] = {};\n\t\t} else if (typeof ptr === 'object') {\n\t\t\tObject.assign(schemaPointerMap, ptr);\n\t\t}\n\t}\n\n\tconst hash = JSON.stringify(schemaPointerMap);\n\tconst result = await cache('schema', hash, async () => {\n\t\treturn loadSchema(schemaPointerMap, options.cwd, options.loaders);\n\t});\n\n\tconst outputs = await modules.preset.buildGeneratesSection({\n\t\tbaseOutputDir: options.modulesDir,\n\t\tpresetConfig: {\n\t\t\tbaseTypesPath: rootConfig.baseTypesPath,\n\t\t\tfilename: rootConfig.moduleDefinitionName,\n\t\t\tencapsulateModuleTypes: 'none',\n\t\t\textensionsPath: options.extensions,\n\t\t\timportExtension: options.importExtension,\n\t\t},\n\t\tschema: result.outputSchema,\n\t\tschemaAst: result.outputSchemaAst,\n\t\tdocuments: [],\n\t\tpluginMap: rootConfig.pluginMap,\n\t\tplugins: rootConfig.plugins,\n\t\tconfig: {\n\t\t\tinputMaybeValue: 'T | undefined',\n\t\t\tcontextType: rootConfig.contextType,\n\t\t\tuseTypeImports: true,\n\t\t\tscalars: buildScalarMap(\n\t\t\t\trootConfig.scalars,\n\t\t\t\toptions.cwd,\n\t\t\t\tjoin(options.modulesDir, options.baseTypesPath),\n\t\t\t),\n\t\t},\n\t});\n\n\tconst promises = outputs.map(async (output) => {\n\t\tconst result = await gqlCodegen({\n\t\t\t...output,\n\t\t\tcache,\n\t\t});\n\n\t\treturn {\n\t\t\tfilename: output.filename,\n\t\t\tcontent: result,\n\t\t};\n\t});\n\n\treturn Promise.all(promises);\n}\n","export function createCache(): <T>(\n\tnamespace: string,\n\tkey: string,\n\tfactory: () => Promise<T>,\n) => Promise<T> {\n\tconst cache = new Map<string, Promise<unknown>>();\n\n\treturn function ensure<T>(namespace: string, key: string, factory: () => Promise<T>): Promise<T> {\n\t\tconst cacheKey = `${namespace}:${key}`;\n\n\t\tconst cachedValue = cache.get(cacheKey);\n\n\t\tif (cachedValue) {\n\t\t\treturn cachedValue as Promise<T>;\n\t\t}\n\n\t\tconst value = factory();\n\t\tcache.set(cacheKey, value);\n\n\t\treturn value;\n\t};\n}\n","import { getCachedDocumentNodeFromSchema } from '@graphql-codegen/plugin-helpers';\nimport { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader';\nimport {\n\ttype UnnormalizedTypeDefPointer,\n\tloadSchema as loadSchemaToolkit,\n} from '@graphql-tools/load';\nimport type { BaseLoaderOptions, Loader } from '@graphql-tools/utils';\nimport { type GraphQLSchemaExtensions, validateSchema } from 'graphql';\nimport { hashSchema } from './hash.ts';\n\nexport async function loadSchema(\n\tschemaPointerMap: UnnormalizedTypeDefPointer,\n\tcwd: string,\n\textraLoaders: Loader<BaseLoaderOptions>[] = [],\n) {\n\tconst outputSchemaAst = await loadSchemaToolkit(schemaPointerMap, {\n\t\tloaders: [new GraphQLFileLoader(), ...extraLoaders],\n\t\tcwd,\n\t\tincludeSources: true,\n\t});\n\n\tconst errors = validateSchema(outputSchemaAst);\n\n\tif (errors.length > 0) {\n\t\tconst messages = errors.map((e) => e.toString()).join('\\n\\n--------------------\\n\\n');\n\t\tconst subject = errors.length === 1 ? 'error' : 'errors';\n\t\tthrow new Error(`Invalid schema. Found ${errors.length} ${subject}:\\n\\n${messages}`);\n\t}\n\n\tif (!outputSchemaAst.extensions) {\n\t\toutputSchemaAst.extensions = {};\n\t}\n\n\t(outputSchemaAst.extensions as GraphQLSchemaExtensions).hash = hashSchema(outputSchemaAst);\n\n\treturn {\n\t\toutputSchemaAst,\n\t\toutputSchema: getCachedDocumentNodeFromSchema(outputSchemaAst),\n\t};\n}\n","import { createHash } from 'node:crypto';\nimport { getCachedDocumentNodeFromSchema } from '@graphql-codegen/plugin-helpers';\nimport { type GraphQLSchema, print } from 'graphql';\n\nexport function hashContent(content: string): string {\n\treturn createHash('sha256').update(content).digest('hex');\n}\n\nexport function hashSchema(schema: GraphQLSchema): string {\n\treturn hashContent(print(getCachedDocumentNodeFromSchema(schema)));\n}\n","import { dirname, isAbsolute, joinSafe, relative } from '@baeta/util-path';\nimport { parseMapper } from '@graphql-codegen/visitor-plugin-common';\n\nexport function buildScalarMap(\n\tmap: Record<string, string> | undefined,\n\tcwd: string,\n\ttypesPath: string,\n) {\n\tif (!map) {\n\t\treturn {};\n\t}\n\n\tconst fixedMap: Record<string, string> = {};\n\n\tfor (const key in map) {\n\t\tconst mapped = parseMapper(map[key]);\n\n\t\tif (!mapped.isExternal) {\n\t\t\tfixedMap[key] = map[key];\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (isAbsolute(mapped.source)) {\n\t\t\tfixedMap[key] = map[key];\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst scalarPath = joinSafe(cwd, mapped.source);\n\t\tconst relativePath = relative(dirname(typesPath), scalarPath);\n\n\t\tif (mapped.default) {\n\t\t\tfixedMap[key] = `${relativePath}#default`;\n\t\t\tcontinue;\n\t\t}\n\n\t\tfixedMap[key] = `${relativePath}#${mapped.import}`;\n\t}\n\n\treturn fixedMap;\n}\n","import type { PluginFunction, Types } from '@graphql-codegen/plugin-helpers';\nimport { buildMapperImport, parseMapper } from '@graphql-codegen/visitor-plugin-common';\nimport type { GraphQLSchema } from 'graphql';\n\ninterface Config {\n\tcontextType: string | undefined;\n}\n\nexport const plugin: PluginFunction<Config> = async (\n\tschema: GraphQLSchema,\n\tdocuments: Types.DocumentFile[],\n\tconfig: Config,\n): Promise<Types.PluginOutput> => {\n\tconst prepend: string[] = [];\n\tconst mapper = parseMapper(config.contextType || 'any');\n\n\tif (mapper.isExternal && mapper.source) {\n\t\tconst identifier = mapper.default ? 'ContextType' : `${mapper.import} as ContextType`;\n\n\t\tconst result = buildMapperImport(\n\t\t\tmapper.source,\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tidentifier,\n\t\t\t\t\tasDefault: mapper.default,\n\t\t\t\t},\n\t\t\t],\n\t\t\ttrue,\n\t\t);\n\n\t\tif (result) {\n\t\t\tprepend.push(result);\n\t\t}\n\t} else {\n\t\tprepend.push(`type ContextType = ${mapper.type}`);\n\t}\n\n\tprepend.push('export type { ContextType }');\n\n\treturn {\n\t\tcontent: '',\n\t\tprepend: prepend,\n\t};\n};\n\nexport default { plugin };\n","import { basename, join, relative, resolve } from '@baeta/util-path';\nimport type { Types } from '@graphql-codegen/plugin-helpers';\nimport { BaseVisitor, getConfigValue } from '@graphql-codegen/visitor-plugin-common';\nimport type { Source } from '@graphql-tools/utils';\nimport {\n\ttype DocumentNode,\n\ttype ObjectTypeDefinitionNode,\n\ttype UnionTypeDefinitionNode,\n\ttype UnionTypeExtensionNode,\n\tconcatAST,\n\tisScalarType,\n} from 'graphql';\nimport { buildModule } from './builder.ts';\nimport type { ModulesConfig } from './config.ts';\nimport {\n\tcollectObjectFieldTypesAndArguments,\n\tgroupSourcesByModule,\n\tisGraphQLPrimitive,\n\tnormalize,\n\tstripFilename,\n} from './utils.ts';\n\nexport const preset: Types.OutputPreset<ModulesConfig> = {\n\tbuildGeneratesSection: (options) => {\n\t\tconst { baseOutputDir } = options;\n\t\tconst { baseTypesPath, extensionsPath, encapsulateModuleTypes, importExtension } =\n\t\t\toptions.presetConfig;\n\n\t\tconst requireRootResolvers = getConfigValue(options?.presetConfig.requireRootResolvers, false);\n\n\t\tconst cwd = resolve(options.presetConfig.cwd || process.cwd());\n\t\tconst importTypesNamespace = options.presetConfig.importTypesNamespace || 'Types';\n\n\t\tif (!baseTypesPath) {\n\t\t\tthrow new Error(\n\t\t\t\t`Preset \"graphql-modules\" requires you to specify \"baseTypesPath\" configuration and point it to your base types file (generated by \"typescript\" plugin)!`,\n\t\t\t);\n\t\t}\n\n\t\tif (!options.schemaAst?.extensions.sources) {\n\t\t\tthrow new Error(`Preset \"graphql-modules\" requires to use GraphQL SDL`);\n\t\t}\n\n\t\tconst extensions = options.schemaAst?.extensions;\n\t\tconst sources = (extensions?.extendedSources ?? []) as Source[];\n\t\tconst sourcesByModuleMap = groupSourcesByModule(sources, baseOutputDir);\n\t\tconst modules = Object.keys(sourcesByModuleMap);\n\n\t\tconst baseVisitor = new BaseVisitor(options.config, {});\n\t\tconst { fieldTypes, fieldArguments } = collectObjectFieldTypesAndArguments(options.schemaAst);\n\n\t\t// One file with an output from all plugins\n\t\tconst baseOutput: Types.GenerateOptions = {\n\t\t\tfilename: resolve(cwd, baseOutputDir, baseTypesPath),\n\t\t\tschema: options.schema,\n\t\t\tdocuments: options.documents,\n\t\t\tplugins: [\n\t\t\t\t...options.plugins,\n\t\t\t\t{\n\t\t\t\t\t'modules-exported-scalars': {},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t'modules-exported-picks': {},\n\t\t\t\t},\n\t\t\t],\n\t\t\tpluginMap: {\n\t\t\t\t...options.pluginMap,\n\t\t\t\t'modules-exported-scalars': {\n\t\t\t\t\tplugin: (schema) => {\n\t\t\t\t\t\tconst typeMap = schema.getTypeMap();\n\n\t\t\t\t\t\treturn Object.keys(typeMap)\n\t\t\t\t\t\t\t.map((t) => {\n\t\t\t\t\t\t\t\tif (t && typeMap[t] && isScalarType(typeMap[t]) && !isGraphQLPrimitive(t)) {\n\t\t\t\t\t\t\t\t\tconst convertedName = baseVisitor.convertName(t);\n\t\t\t\t\t\t\t\t\treturn `export type ${convertedName} = Scalars[\"${t}\"];`;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t\t\t.join('\\n');\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t'modules-exported-picks': {\n\t\t\t\t\tplugin: (schema) => {\n\t\t\t\t\t\tconst typePicks: string[] = [];\n\t\t\t\t\t\tconst unionPicks: string[] = [];\n\t\t\t\t\t\tconst unionResults: string[] = [];\n\t\t\t\t\t\tconst interfacePicks: string[] = [];\n\t\t\t\t\t\tconst interfaceResults: string[] = [];\n\n\t\t\t\t\t\tconst unionTypesMap: Record<string, string[] | undefined> = {};\n\t\t\t\t\t\tconst interfacesTypesMap: Record<string, string[] | undefined> = {};\n\n\t\t\t\t\t\tfor (const moduleName of modules) {\n\t\t\t\t\t\t\tconst sources = sourcesByModuleMap[moduleName];\n\t\t\t\t\t\t\tconst documents = sources.map((source) => source.document) as DocumentNode[];\n\t\t\t\t\t\t\tconst moduleDocument = concatAST(documents);\n\n\t\t\t\t\t\t\tconst types = moduleDocument.definitions.filter(\n\t\t\t\t\t\t\t\t(def) => def.kind === 'ObjectTypeDefinition',\n\t\t\t\t\t\t\t) as ObjectTypeDefinitionNode[];\n\n\t\t\t\t\t\t\tconst unionsDefinition = moduleDocument.definitions.filter(\n\t\t\t\t\t\t\t\t(def) => def.kind === 'UnionTypeDefinition',\n\t\t\t\t\t\t\t) as UnionTypeDefinitionNode[];\n\n\t\t\t\t\t\t\tconst unionsExtensions = moduleDocument.definitions.filter(\n\t\t\t\t\t\t\t\t(def) => def.kind === 'UnionTypeExtension',\n\t\t\t\t\t\t\t) as UnionTypeExtensionNode[];\n\n\t\t\t\t\t\t\tconst unions = [...unionsDefinition, ...unionsExtensions];\n\n\t\t\t\t\t\t\tfor (const type of types) {\n\t\t\t\t\t\t\t\tconst name = type.name.value;\n\n\t\t\t\t\t\t\t\tfor (const interfaceNode of type.interfaces ?? []) {\n\t\t\t\t\t\t\t\t\tconst interfaceName = interfaceNode.name.value;\n\n\t\t\t\t\t\t\t\t\tif (interfacesTypesMap[interfaceName] == null) {\n\t\t\t\t\t\t\t\t\t\tinterfacesTypesMap[interfaceName] = [];\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tinterfacesTypesMap[interfaceName]?.push(name);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (name === 'Query' || name === 'Mutation' || name === 'Subscription') {\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst fields = type.fields ?? [];\n\n\t\t\t\t\t\t\t\tif (fields.length === 0) {\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst fieldNames = fields.map((f) => `\"${f.name.value}\"`).join(' | ');\n\n\t\t\t\t\t\t\t\ttypePicks.push(` ${name}: ${fieldNames};`);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfor (const union of unions) {\n\t\t\t\t\t\t\t\tconst types = union.types?.map((t) => t.name.value) ?? [];\n\n\t\t\t\t\t\t\t\tif (unionTypesMap[union.name.value] == null) {\n\t\t\t\t\t\t\t\t\tunionTypesMap[union.name.value] = [];\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tunionTypesMap[union.name.value]?.push(...types);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (const unionName in unionTypesMap) {\n\t\t\t\t\t\t\tconst types = unionTypesMap[unionName];\n\n\t\t\t\t\t\t\tif (types == null || types.length === 0) {\n\t\t\t\t\t\t\t\tunionPicks.push(` ${unionName}: never;`);\n\t\t\t\t\t\t\t\tunionResults.push(` ${unionName}: null;`);\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst typePicks = types.map((t) => {\n\t\t\t\t\t\t\t\tconst normalizedTypeName = baseVisitor.convertName(t, {\n\t\t\t\t\t\t\t\t\tuseTypesSuffix: true,\n\t\t\t\t\t\t\t\t\tuseTypesPrefix: true,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn `Pick<${normalizedTypeName}, DefinedFieldsWithoutExtensions[\"${t}\"] | \"__typename\">`;\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst resultPicks = types.map((t) => `\"${t}\"`);\n\n\t\t\t\t\t\t\tunionPicks.push(` ${unionName}: ${typePicks.join(' | ')};`);\n\t\t\t\t\t\t\tunionResults.push(` ${unionName}: ${resultPicks.join(' | ')} | null;`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (const interfaceName in interfacesTypesMap) {\n\t\t\t\t\t\t\tconst types = interfacesTypesMap[interfaceName];\n\n\t\t\t\t\t\t\tif (types == null || types.length === 0) {\n\t\t\t\t\t\t\t\tinterfacePicks.push(` ${interfaceName}: never;`);\n\t\t\t\t\t\t\t\tinterfaceResults.push(` ${interfaceName}: null;`);\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst typePicks = types.map((t) => {\n\t\t\t\t\t\t\t\tconst normalizedTypeName = baseVisitor.convertName(t, {\n\t\t\t\t\t\t\t\t\tuseTypesSuffix: true,\n\t\t\t\t\t\t\t\t\tuseTypesPrefix: true,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\treturn `Pick<${normalizedTypeName}, DefinedFieldsWithoutExtensions[\"${t}\"] | \"__typename\">`;\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst resultPicks = types.map((t) => `\"${t}\"`);\n\n\t\t\t\t\t\t\tinterfacePicks.push(` ${interfaceName}: ${typePicks.join(' | ')};`);\n\t\t\t\t\t\t\tinterfaceResults.push(` ${interfaceName}: ${resultPicks.join(' | ')} | null;`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst fieldsDefinition = `export type DefinedFieldsWithoutExtensions = {\\n${typePicks.join('\\n')}\\n};`;\n\t\t\t\t\t\tconst unionsDefinition = `export type DefinedUnionsWithoutExtensions = {\\n${unionPicks.join('\\n')}\\n};`;\n\t\t\t\t\t\tconst unionsResultsDefinition = `export type DefinedUnionsResults = {\\n${unionResults.join('\\n')}\\n};`;\n\t\t\t\t\t\tconst interfacesDefinition = `export type DefinedInterfacesWithoutExtensions = {\\n${interfacePicks.join('\\n')}\\n};`;\n\t\t\t\t\t\tconst interfacesResultsDefinition = `export type DefinedInterfacesResults = {\\n${interfaceResults.join(\n\t\t\t\t\t\t\t'\\n',\n\t\t\t\t\t\t)}\\n};`;\n\n\t\t\t\t\t\tconst result = [\n\t\t\t\t\t\t\tfieldsDefinition,\n\t\t\t\t\t\t\tunionsDefinition,\n\t\t\t\t\t\t\tunionsResultsDefinition,\n\t\t\t\t\t\t\tinterfacesDefinition,\n\t\t\t\t\t\t\tinterfacesResultsDefinition,\n\t\t\t\t\t\t].join('\\n\\n');\n\n\t\t\t\t\t\treturn `\\n${result}\\n`;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tconfig: {\n\t\t\t\t...options.config,\n\t\t\t\tenumsAsTypes: true,\n\t\t\t},\n\t\t\tschemaAst: options.schemaAst,\n\t\t};\n\n\t\tconst baseTypesFilename =\n\t\t\tbasename(baseTypesPath).replace(/\\.(js|ts|d.ts)$/, '') + (importExtension || '');\n\t\tconst baseTypesDir = stripFilename(baseOutput.filename);\n\n\t\t// One file per each module\n\t\tconst outputs: Types.GenerateOptions[] = modules.map((moduleName) => {\n\t\t\tconst filename = resolve(cwd, baseOutputDir, moduleName, options.presetConfig.filename);\n\t\t\tconst dirpath = stripFilename(filename);\n\t\t\tconst relativePath = relative(dirpath, baseTypesDir);\n\t\t\tconst importPath =\n\t\t\t\toptions.presetConfig.importBaseTypesFrom ||\n\t\t\t\tnormalize(join(relativePath, baseTypesFilename));\n\t\t\tconst sources = sourcesByModuleMap[moduleName];\n\n\t\t\tconst documents = sources.map((source) => source.document) as DocumentNode[];\n\n\t\t\tconst moduleDocument = concatAST(documents);\n\n\t\t\tconst shouldDeclare = filename.endsWith('.d.ts');\n\n\t\t\treturn {\n\t\t\t\tfilename,\n\t\t\t\tschema: options.schema,\n\t\t\t\tdocuments: [],\n\t\t\t\tplugins: [\n\t\t\t\t\t...options.plugins.filter((p) => typeof p === 'object' && !!p.add),\n\t\t\t\t\t{\n\t\t\t\t\t\t'graphql-modules-plugin': {},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tpluginMap: {\n\t\t\t\t\t...options.pluginMap,\n\t\t\t\t\t'graphql-modules-plugin': {\n\t\t\t\t\t\tplugin: (schema) =>\n\t\t\t\t\t\t\tbuildModule(moduleName, moduleDocument, {\n\t\t\t\t\t\t\t\timportNamespace: importTypesNamespace,\n\t\t\t\t\t\t\t\timportPath,\n\t\t\t\t\t\t\t\tencapsulate: encapsulateModuleTypes || 'namespace',\n\t\t\t\t\t\t\t\trequireRootResolvers,\n\t\t\t\t\t\t\t\tshouldDeclare,\n\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\tbaseVisitor,\n\t\t\t\t\t\t\t\tuseGraphQLModules: false,\n\t\t\t\t\t\t\t\tfieldTypes,\n\t\t\t\t\t\t\t\tfieldArguments,\n\t\t\t\t\t\t\t\textensionsPath,\n\t\t\t\t\t\t\t\trootTypes: [\n\t\t\t\t\t\t\t\t\tschema.getQueryType()?.name || '',\n\t\t\t\t\t\t\t\t\tschema.getMutationType()?.name || '',\n\t\t\t\t\t\t\t\t\tschema.getSubscriptionType()?.name || '',\n\t\t\t\t\t\t\t\t].filter(Boolean),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tconfig: options.config,\n\t\t\t\tschemaAst: options.schemaAst,\n\t\t\t};\n\t\t});\n\n\t\treturn [baseOutput].concat(outputs);\n\t},\n};\n\nexport default preset;\n","import type { BaseVisitor } from '@graphql-codegen/visitor-plugin-common';\nimport { pascalCase } from 'change-case-all';\nimport {\n\ttype DocumentNode,\n\ttype EnumTypeDefinitionNode,\n\ttype EnumTypeExtensionNode,\n\ttype GraphQLSchema,\n\ttype InputObjectTypeDefinitionNode,\n\ttype InputObjectTypeExtensionNode,\n\ttype InterfaceTypeDefinitionNode,\n\ttype InterfaceTypeExtensionNode,\n\tKind,\n\ttype ObjectTypeDefinitionNode,\n\ttype ObjectTypeExtensionNode,\n\ttype TypeDefinitionNode,\n\ttype TypeExtensionNode,\n\ttype UnionTypeDefinitionNode,\n\tisInterfaceType,\n\tisScalarType,\n\tisUnionType,\n\tvisit,\n} from 'graphql';\nimport type { ModulesConfig } from './config.ts';\nimport { type TypeHash, getObjectTypeHash } from './hashes.ts';\nimport {\n\tbuildBlock,\n\tcollectUsedTypes,\n\tconcatByKey,\n\tcreateObject,\n\tindent,\n\tpushUnique,\n\tunique,\n\tuniqueByKey,\n\twithQuotes,\n} from './utils.ts';\n\ntype RegistryKeys = 'objects' | 'inputs' | 'interfaces' | 'scalars' | 'unions' | 'enums';\ntype Registry = Record<RegistryKeys, string[]>;\nconst registryKeys: RegistryKeys[] = [\n\t'objects',\n\t'inputs',\n\t'interfaces',\n\t'scalars',\n\t'unions',\n\t'enums',\n];\nconst resolverKeys: Extract<RegistryKeys, 'objects' | 'enums' | 'scalars'>[] = [\n\t'scalars',\n\t'objects',\n\t'enums',\n];\n\nexport function buildModule(\n\tname: string,\n\tdoc: DocumentNode,\n\t{\n\t\timportNamespace,\n\t\timportPath,\n\t\tencapsulate,\n\t\trequireRootResolvers,\n\t\tshouldDeclare,\n\t\trootTypes,\n\t\tschema,\n\t\tbaseVisitor,\n\t\tfieldTypes,\n\t\tfieldArguments,\n\t\textensionsPath,\n\t}: {\n\t\timportNamespace: string;\n\t\timportPath: string;\n\t\tencapsulate: ModulesConfig['encapsulateModuleTypes'];\n\t\trequireRootResolvers: ModulesConfig['requireRootResolvers'];\n\t\tshouldDeclare: boolean;\n\t\trootTypes: string[];\n\t\tbaseVisitor: BaseVisitor;\n\t\tschema?: GraphQLSchema;\n\t\tuseGraphQLModules: boolean;\n\t\tfieldTypes: Record<string, Record<string, string>>;\n\t\tfieldArguments: Record<string, Record<string, boolean>>;\n\t\textensionsPath?: string;\n\t},\n): string {\n\tconst picks: Record<RegistryKeys, Record<string, string[]>> = createObject(\n\t\tregistryKeys,\n\t\t() => ({}),\n\t);\n\tconst defined: Registry = createObject(registryKeys, () => []);\n\tconst extended: Registry = createObject(registryKeys, () => []);\n\n\tconst hashes: Record<string, TypeHash> = {};\n\n\t// List of types used in objects, fields, arguments etc\n\tconst usedTypes = collectUsedTypes(doc);\n\n\tvisit(doc, {\n\t\tObjectTypeDefinition(node) {\n\t\t\tcollectTypeDefinition(node);\n\t\t},\n\t\tObjectTypeExtension(node) {\n\t\t\tcollectTypeExtension(node);\n\t\t},\n\t\tInputObjectTypeDefinition(node) {\n\t\t\tcollectTypeDefinition(node);\n\t\t},\n\t\tInputObjectTypeExtension(node) {\n\t\t\tcollectTypeExtension(node);\n\t\t},\n\t\tInterfaceTypeDefinition(node) {\n\t\t\tcollectTypeDefinition(node);\n\t\t},\n\t\tInterfaceTypeExtension(node) {\n\t\t\tcollectTypeExtension(node);\n\t\t},\n\t\tScalarTypeDefinition(node) {\n\t\t\tcollectTypeDefinition(node);\n\t\t},\n\t\tUnionTypeDefinition(node) {\n\t\t\tcollectTypeDefinition(node);\n\t\t},\n\t\tUnionTypeExtension(node) {\n\t\t\tcollectTypeExtension(node);\n\t\t},\n\t\tEnumTypeDefinition(node) {\n\t\t\tcollectTypeDefinition(node);\n\t\t},\n\t\tEnumTypeExtension(node) {\n\t\t\tcollectTypeExtension(node);\n\t\t},\n\t});\n\n\t// Defined and Extended types\n\tconst visited: Registry = createObject(registryKeys, (key) =>\n\t\tconcatByKey(defined, extended, key),\n\t);\n\n\t// Types that are not defined or extended in a module, they come from other modules\n\tconst external: Registry = createObject(registryKeys, (key) =>\n\t\tuniqueByKey(extended, defined, key),\n\t);\n\n\t//\n\t//\n\t//\n\t// Prints\n\t//\n\t//\n\t//\n\n\t// An actual output\n\tconst imports = [\n\t\t`import * as ${importNamespace} from \"${importPath}\";`,\n\t\t'import type { DocumentNode } from \"graphql\";',\n\t\t'import * as Baeta from \"@baeta/core/sdk\";',\n\t];\n\n\tif (extensionsPath) {\n\t\timports.push(`import baetaExtensions from \"${extensionsPath}\";`);\n\t}\n\n\timports.push('\\n');\n\n\tlet content = [\n\t\tprintDefinedFields(),\n\t\tprintDefinedEnumValues(),\n\t\tprintDefinedInputFields(),\n\t\tprintSchemaTypes(usedTypes),\n\t\tprintMetadata(),\n\t]\n\t\t.filter(Boolean)\n\t\t.join('\\n\\n');\n\n\tconst moduleNamespace = baseVisitor.convertName(name, {\n\t\tsuffix: 'Module',\n\t\tuseTypesPrefix: false,\n\t\tuseTypesSuffix: false,\n\t});\n\n\tif (encapsulate === 'namespace') {\n\t\tcontent = `${shouldDeclare ? 'declare' : 'export'} namespace ${baseVisitor.convertName(name, {\n\t\t\tsuffix: 'Module',\n\t\t\tuseTypesPrefix: false,\n\t\t\tuseTypesSuffix: false,\n\t\t})} {\\n${shouldDeclare ? `${indent(2)(imports.join('\\n'))}\\n` : ''}${indent(2)(content)}\\n}`;\n\t}\n\n\treturn [...(shouldDeclare ? [] : imports), content, printFactoryMethod()]\n\t\t.filter(Boolean)\n\t\t.join('\\n');\n\n\tfunction printMetadata() {\n\t\treturn `export namespace ModuleMetadata {\n export const id = '${name}';\n export const dirname = './${name}';\n export const hashes = ${JSON.stringify(hashes)};\n export const typedef = ${JSON.stringify(doc)} as unknown as DocumentNode;\n ${printBaetaManager()}\n}`;\n\t}\n\n\t/**\n\t * A dictionary of fields to pick from an object\n\t */\n\tfunction printDefinedFields() {\n\t\treturn buildBlock({\n\t\t\tname: 'interface DefinedFields',\n\t\t\tlines: [...visited.objects, ...visited.interfaces].map(\n\t\t\t\t(typeName) =>\n\t\t\t\t\t`${typeName}: ${printPicks(typeName, {\n\t\t\t\t\t\t...picks.objects,\n\t\t\t\t\t\t...picks.interfaces,\n\t\t\t\t\t})};`,\n\t\t\t),\n\t\t});\n\t}\n\n\tfunction printFactoryMethod() {\n\t\tconst name = moduleNamespace.slice(0, moduleNamespace.length - 6);\n\t\tconst createModuleFn = `create${name}Module`;\n\t\tconst getModuleFn = `get${name}Module`;\n\t\tconst extensionsArg = extensionsPath ? ', baetaExtensions' : '';\n\n\t\treturn `\nexport const ${createModuleFn} = () => Baeta.createModuleManager(ModuleMetadata${extensionsArg});\nexport const ${getModuleFn} = Baeta.createSingletonModule(${createModuleFn});\n`;\n\t}\n\n\t/**\n\t * Baeta manager\n\t */\n\n\tfunction printObjectFieldResolverBuilder(typeName: string, field: string) {\n\t\tconst parentType = getParentType(typeName);\n\t\tconst resultType = getResultType(typeName, field);\n\t\tconst argumentsType = getArgsType(typeName, field);\n\t\tconst contextType = getContextType();\n\t\treturn `${field}: module.createResolverBuilder<${resultType}, ${parentType}, ${contextType}, ${argumentsType}>(\"${typeName}\", \"${field}\"),`;\n\t}\n\n\tfunction printObjectResolverBuilder(typeName: string, objects: Record<string, string[]>) {\n\t\tconst fields =\n\t\t\tobjects[typeName]\n\t\t\t\t?.filter(unique)\n\t\t\t\t.map((field) => printObjectFieldResolverBuilder(typeName, field)) ?? [];\n\n\t\tif (fields.length === 0) {\n\t\t\treturn '';\n\t\t}\n\n\t\tconst parentType = getParentType(typeName);\n\t\tconst contextType = getContextType();\n\n\t\tconst addons = [`...module.createTypeMethods<${parentType}, ${contextType}>(\"${typeName}\"),`];\n\t\tconst contentBody = [...addons, ...fields].map(indent(2)).join('\\n');\n\t\tconst content = `{\\n${contentBody}\\n}`;\n\t\treturn `${typeName}: ${content},`;\n\t}\n\n\tfunction printSubscriptionFieldBuilder(field: string) {\n\t\tconst parentType = getParentType('Subscription');\n\t\tconst resultType = getResultType('Subscription', field);\n\t\tconst argumentsType = getArgsType('Subscription', field);\n\t\tconst contextType = getContextType();\n\t\treturn `${field}: module.createSubscriptionBuilder<${resultType}, ${parentType}, ${contextType}, ${argumentsType}>(\"${field}\"),`;\n\t}\n\n\tfunction printSubscriptionObjectBuilder() {\n\t\tconst subscriptions = picks.objects.Subscription?.filter(unique) ?? [];\n\n\t\tif (subscriptions.length === 0) {\n\t\t\treturn '';\n\t\t}\n\n\t\tconst fields = subscriptions.map((subscription) => printSubscriptionFieldBuilder(subscription));\n\n\t\tconst parentType = getParentType('Subscription');\n\t\tconst contextType = getContextType();\n\t\tconst addons = [`...module.createSubscriptionMethods<${parentType}, ${contextType}>(),`];\n\t\tconst contentBody = [...addons, ...fields].map(indent(2)).join('\\n');\n\n\t\tconst content = `{\\n${contentBody}\\n}`;\n\t\treturn `Subscription: ${content},`;\n\t}\n\n\tfunction printScalarBuilder() {\n\t\tconst scalars = visited.scalars;\n\t\tif (scalars.length === 0) {\n\t\t\treturn '';\n\t\t}\n\n\t\tconst fields = scalars.map((scalar) => `${scalar}: module.createScalarBuilder(\"${scalar}\"),`);\n\t\tconst content = fields.map(indent(2)).join('\\n');\n\t\treturn `Scalar: {\\n${content}\\n},`;\n\t}\n\n\tfunction printTypenameResolverBuilder(\n\t\tname: string,\n\t\tresultNamespace: string,\n\t\tvalueNamespace: string,\n\t) {\n\t\tconst resultType = `${importNamespace}.${resultNamespace}[\"${name}\"]`;\n\t\tconst valueType = `${importNamespace}.${valueNamespace}[\"${name}\"]`;\n\t\tconst contextType = getContextType();\n\t\tconst resolver = `$resolveType: module.createResolveType<${resultType}, ${valueType}, ${contextType}>(\"${name}\"),`;\n\t\treturn `${name}: {\\n${indent(2)(resolver)}\\n},`;\n\t}\n\n\tfunction printInterfaceBuilder() {\n\t\tconst interfaces = defined.interfaces;\n\n\t\tif (interfaces.length === 0) {\n\t\t\treturn '';\n\t\t}\n\n\t\treturn interfaces\n\t\t\t.map((interfaceName) =>\n\t\t\t\tprintTypenameResolverBuilder(\n\t\t\t\t\tinterfaceName,\n\t\t\t\t\t'DefinedInterfacesResults',\n\t\t\t\t\t'DefinedInterfacesWithoutExtensions',\n\t\t\t\t),\n\t\t\t)\n\t\t\t.join('\\n');\n\t}\n\n\tfunction printUnionBuilder() {\n\t\tconst unions = defined.unions;\n\n\t\tif (unions.length === 0) {\n\t\t\treturn '';\n\t\t}\n\n\t\treturn unions\n\t\t\t.map((unionName) =>\n\t\t\t\tprintTypenameResolverBuilder(\n\t\t\t\t\tunionName,\n\t\t\t\t\t'DefinedUnionsResults',\n\t\t\t\t\t'DefinedUnionsWithoutExtensions',\n\t\t\t\t),\n\t\t\t)\n\t\t\t.join('\\n');\n\t}\n\n\tfunction printBaetaManager() {\n\t\tconst objects = visited.objects\n\t\t\t.filter((type) => type !== 'Subscription')\n\t\t\t.map((typeName) => printObjectResolverBuilder(typeName, picks.objects))\n\t\t\t.filter(Boolean);\n\n\t\tconst contextType = getContextType();\n\t\tconst addons = [`...module.createModuleMethods<${contextType}>(),`];\n\n\t\tconst bodyFields = [\n\t\t\t...addons,\n\t\t\t...objects,\n\t\t\tprintScalarBuilder(),\n\t\t\tprintSubscriptionObjectBuilder(),\n\t\t\tprintInterfaceBuilder(),\n\t\t\tprintUnionBuilder(),\n\t\t];\n\n\t\tconst body = bodyFields.filter(Boolean).map(indent(6)).join('\\n');\n\t\tconst content = `{\\n${body}\\n }`;\n\n\t\treturn `\n export function createManager(module: Baeta.ModuleBuilder) {\n return ${content};\n }`;\n\t}\n\n\t/**\n\t * A dictionary of values to pick from an enum\n\t */\n\tfunction printDefinedEnumValues() {\n\t\treturn buildBlock({\n\t\t\tname: 'interface DefinedEnumValues',\n\t\t\tlines: visited.enums.map((typeName) => `${typeName}: ${printPicks(typeName, picks.enums)};`),\n\t\t});\n\t}\n\n\tfunction encapsulateTypeName(typeName: string): string {\n\t\tif (encapsulate === 'prefix') {\n\t\t\treturn `${pascalCase(name)}_${typeName}`;\n\t\t}\n\n\t\treturn typeName;\n\t}\n\n\t/**\n\t * A dictionary of fields to pick from an input\n\t */\n\tfunction printDefinedInputFields() {\n\t\treturn buildBlock({\n\t\t\tname: 'interface DefinedInputFields',\n\t\t\tlines: visited.inputs.map(\n\t\t\t\t(typeName) => `${typeName}: ${printPicks(typeName, picks.inputs)};`,\n\t\t\t),\n\t\t});\n\t}\n\n\t/**\n\t * Prints signatures of schema types with picks\n\t */\n\tfunction printSchemaTypes(types: string[]) {\n\t\treturn types\n\t\t\t.filter((type) => !visited.scalars.includes(type))\n\t\t\t.map(printExportType)\n\t\t\t.join('\\n');\n\t}\n\n\tfunction printPicks(typeName: string, records: Record<string, string[]>): string {\n\t\treturn records[typeName].filter(unique).map(withQuotes).join(' | ');\n\t}\n\n\tfunction printTypeBody(typeName: string): string {\n\t\tconst normalizedTypeName = baseVisitor.convertName(typeName, {\n\t\t\tuseTypesSuffix: true,\n\t\t\tuseTypesPrefix: true,\n\t\t});\n\n\t\tconst coreType = `${importNamespace}.${normalizedTypeName}`;\n\n\t\tif (external.enums.includes(typeName) || external.objects.includes(typeName)) {\n\t\t\tif (schema && isScalarType(schema.getType(typeName))) {\n\t\t\t\treturn `${importNamespace}.Scalars['${typeName}']`;\n\t\t\t}\n\n\t\t\treturn `Pick<${coreType}, ${importNamespace}.DefinedFieldsWithoutExtensions[\"${typeName}\"]>`;\n\t\t}\n\n\t\tif (external.unions.includes(typeName)) {\n\t\t\treturn `${importNamespace}.DefinedUnionsWithoutExtensions[\"${typeName}\"]`;\n\t\t}\n\n\t\tif (external.interfaces.includes(typeName)) {\n\t\t\treturn `Pick<${coreType}, ${importNamespace}.DefinedFieldsWithoutExtensions[\"${typeName}\"]>`;\n\t\t}\n\n\t\tif (defined.enums.includes(typeName) && picks.enums[typeName]) {\n\t\t\treturn `DefinedEnumValues['${typeName}']`;\n\t\t}\n\n\t\tif (defined.unions.includes(typeName) && picks.unions[typeName]) {\n\t\t\treturn `${importNamespace}.DefinedUnionsWithoutExtensions[\"${typeName}\"]`;\n\t\t}\n\n\t\tif (defined.objects.includes(typeName) && picks.objects[typeName]) {\n\t\t\treturn `Pick<${coreType}, DefinedFields['${typeName}']>`;\n\t\t}\n\n\t\tif (defined.interfaces.includes(typeName) && picks.interfaces[typeName]) {\n\t\t\treturn `${importNamespace}.DefinedInterfacesWithoutExtensions[\"${typeName}\"]`;\n\t\t}\n\n\t\tif (defined.inputs.includes(typeName) && picks.inputs[typeName]) {\n\t\t\treturn `Pick<${coreType}, DefinedInputFields['${typeName}']>`;\n\t\t}\n\n\t\tif (isScalarType(schema?.getType(typeName))) {\n\t\t\treturn coreType;\n\t\t}\n\n\t\tif (isInterfaceType(schema?.getType(typeName))) {\n\t\t\treturn `${importNamespace}.DefinedInterfacesWithoutExtensions[\"${typeName}\"]`;\n\t\t}\n\n\t\tif (isUnionType(schema?.getType(typeName))) {\n\t\t\treturn `${importNamespace}.DefinedUnionsWithoutExtensions[\"${typeName}\"]`;\n\t\t}\n\n\t\treturn `Pick<${coreType}, ${importNamespace}.DefinedFieldsWithoutExtensions[\"${typeName}\"]>`;\n\t}\n\n\tfunction printExportType(typeName: string): string {\n\t\treturn `export type ${encapsulateTypeName(typeName)} = ${printTypeBody(typeName)};`;\n\t}\n\n\t//\n\t//\n\t//\n\t// Utils\n\t//\n\t//\n\t//\n\n\tfunction collectFields(\n\t\tnode:\n\t\t\t| ObjectTypeDefinitionNode\n\t\t\t| ObjectTypeExtensionNode\n\t\t\t| InterfaceTypeDefinitionNode\n\t\t\t| InterfaceTypeExtensionNode\n\t\t\t| InputObjectTypeDefinitionNode\n\t\t\t| InputObjectTypeExtensionNode,\n\t\tpicksObj: Record<string, string[]>,\n\t) {\n\t\tconst name = node.name.value;\n\n\t\tif (node.fields) {\n\t\t\tif (!picksObj[name]) {\n\t\t\t\tpicksObj[name] = [];\n\t\t\t}\n\n\t\t\tfor (const field of node.fields) {\n\t\t\t\tpicksObj[name].push(field.name.value);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction collectValuesFromEnum(node: EnumTypeDefinitionNode | EnumTypeExtensionNode) {\n\t\tconst name = node.name.value;\n\n\t\tif (node.values) {\n\t\t\tif (!picks.enums[name]) {\n\t\t\t\tpicks.enums[name] = [];\n\t\t\t}\n\n\t\t\tfor (const field of node.values) {\n\t\t\t\tpicks.enums[name].push(field.name.value);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction collectUnionTypes(node: UnionTypeDefinitionNode) {\n\t\tconst name = node.name.value;\n\n\t\tif (node.types) {\n\t\t\tif (!picks.unions[name]) {\n\t\t\t\tpicks.unions[name] = [];\n\t\t\t}\n\n\t\t\tfor (const type of node.types) {\n\t\t\t\tpicks.unions[name].push(type.name.value);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction collectTypeDefinition(node: TypeDefinitionNode) {\n\t\tconst name = node.name.value;\n\n\t\tswitch (node.kind) {\n\t\t\tcase Kind.OBJECT_TYPE_DEFINITION: {\n\t\t\t\tdefined.objects.push(name);\n\t\t\t\tcollectFields(node, picks.objects);\n\t\t\t\thashes[name] = getObjectTypeHash(node);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.ENUM_TYPE_DEFINITION: {\n\t\t\t\tdefined.enums.push(name);\n\t\t\t\tcollectValuesFromEnum(node);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.INPUT_OBJECT_TYPE_DEFINITION: {\n\t\t\t\tdefined.inputs.push(name);\n\t\t\t\tcollectFields(node, picks.inputs);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.SCALAR_TYPE_DEFINITION: {\n\t\t\t\tdefined.scalars.push(name);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.INTERFACE_TYPE_DEFINITION: {\n\t\t\t\tdefined.interfaces.push(name);\n\t\t\t\tcollectFields(node, picks.interfaces);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.UNION_TYPE_DEFINITION: {\n\t\t\t\tdefined.unions.push(name);\n\t\t\t\tcollectUnionTypes(node);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction collectTypeExtension(node: TypeExtensionNode) {\n\t\tconst name = node.name.value;\n\n\t\tswitch (node.kind) {\n\t\t\tcase Kind.OBJECT_TYPE_EXTENSION: {\n\t\t\t\tcollectFields(node, picks.objects);\n\t\t\t\thashes[name] = getObjectTypeHash(node);\n\n\t\t\t\t// Do not include root types as extensions\n\t\t\t\t// so we can use them in DefinedFields\n\t\t\t\tif (rootTypes.includes(name)) {\n\t\t\t\t\tpushUnique(defined.objects, name);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tpushUnique(extended.objects, name);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.ENUM_TYPE_EXTENSION: {\n\t\t\t\tcollectValuesFromEnum(node);\n\t\t\t\tpushUnique(extended.enums, name);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.INPUT_OBJECT_TYPE_EXTENSION: {\n\t\t\t\tcollectFields(node, picks.inputs);\n\t\t\t\tpushUnique(extended.inputs, name);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.INTERFACE_TYPE_EXTENSION: {\n\t\t\t\tcollectFields(node, picks.interfaces);\n\t\t\t\tpushUnique(extended.interfaces, name);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Kind.UNION_TYPE_EXTENSION: {\n\t\t\t\tpushUnique(extended.unions, name);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction getParentType(type: string) {\n\t\tif (['Query', 'Mutation', 'Subscription'].includes(type)) {\n\t\t\treturn '{ }';\n\t\t}\n\t\treturn type;\n\t}\n\n\tfunction getResultType(type: string, field: string) {\n\t\treturn fieldTypes?.[type]?.[field] || '{ }';\n\t}\n\n\tfunction getArgsType(type: string, field: string) {\n\t\tconst hasArgs = fieldArguments?.[type]?.[field] ?? false;\n\t\tif (!hasArgs) {\n\t\t\treturn '{ }';\n\t\t}\n\t\tconst fieldUpper = field[0].toUpperCase() + field.slice(1);\n\t\treturn `Types.${type}${fieldUpper}Args`;\n\t}\n\n\tfunction getContextType() {\n\t\treturn 'Types.ContextType';\n\t}\n}\n","import {\n\ttype FieldDefinitionNode,\n\tKind,\n\ttype ObjectTypeDefinitionNode,\n\ttype ObjectTypeExtensionNode,\n\ttype TypeNode,\n} from 'graphql';\nimport hash from 'murmurhash';\n\nexport type TypeHash = {\n\thash: string;\n\tfieldsHashes: Record<string, string>;\n};\n\nexport function getObjectTypeHash(\n\tnode: ObjectTypeDefinitionNode | ObjectTypeExtensionNode,\n): TypeHash {\n\tconst fieldNames = buildFieldsNames(node.fields);\n\tconst typeFields = fieldNames\n\t\t.map(([fieldName, fieldType]) => `${fieldName}:${fieldType}`)\n\t\t.join(',');\n\n\tconst fieldMap: Record<string, string> = {};\n\n\tfor (const [fieldName, fieldType] of fieldNames) {\n\t\tfieldMap[fieldName] = hash.v3(fieldType).toString(36);\n\t}\n\n\treturn {\n\t\thash: hash.v3(typeFields).toString(36),\n\t\tfieldsHashes: fieldMap,\n\t};\n}\n\nfunction buildFieldsNames(fields: readonly FieldDefinitionNode[] = []) {\n\tif (fields.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst fieldsNames: Array<[string, string]> = [];\n\n\tfor (const field of fields) {\n\t\tconst fieldName = field.name.value;\n\t\tconst fieldType = buildTypeName(field.type);\n\t\tfieldsNames.push([fieldName, fieldType]);\n\t}\n\n\treturn fieldsNames.sort(([a], [b]) => a.localeCompare(b));\n}\n\nfunction buildTypeName(node: TypeNode): string {\n\tif (node.kind === Kind.NAMED_TYPE) {\n\t\treturn node.name.value;\n\t}\n\n\tif (node.kind === Kind.LIST_TYPE) {\n\t\treturn `[${buildTypeName(node.type)}]`;\n\t}\n\n\tif (node.kind === Kind.NON_NULL_TYPE) {\n\t\treturn `${buildTypeName(node.type)}!`;\n\t}\n\n\treturn '';\n}\n","import { platform } from 'node:os';\nimport { getBaseType } from '@graphql-codegen/plugin-helpers';\nimport { DEFAULT_SCALARS, wrapTypeWithModifiers } from '@graphql-codegen/visitor-plugin-common';\nimport type { Source } from '@graphql-tools/utils';\nimport {\n\ttype DefinitionNode,\n\ttype DocumentNode,\n\ttype FieldDefinitionNode,\n\ttype GraphQLFieldMap,\n\ttype GraphQLObjectType,\n\ttype GraphQLSchema,\n\ttype InputValueDefinitionNode,\n\tKind,\n\ttype NamedTypeNode,\n\ttype ObjectTypeDefinitionNode,\n\ttype TypeNode,\n} from 'graphql';\nimport parse from 'parse-filepath';\n\nconst sep = '/';\n\n/**\n * Searches every node to collect used types\n */\nexport function collectUsedTypes(doc: DocumentNode): string[] {\n\tconst used: string[] = [];\n\n\tfor (const definition of doc.definitions) {\n\t\tfindRelated(definition);\n\t}\n\n\tfunction markAsUsed(type: string) {\n\t\tpushUnique(used, type);\n\t}\n\n\tfunction findRelated(\n\t\tnode: DefinitionNode | FieldDefinitionNode | InputValueDefinitionNode | NamedTypeNode,\n\t) {\n\t\tif (node.kind === Kind.OBJECT_TYPE_DEFINITION || node.kind === Kind.OBJECT_TYPE_EXTENSION) {\n\t\t\t// Object\n\t\t\tmarkAsUsed(node.name.value);\n\n\t\t\tif (node.fields) {\n\t\t\t\tfor (const field of node.fields) {\n\t\t\t\t\tfindRelated(field);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (node.interfaces) {\n\t\t\t\tfor (const _interface of node.interfaces) {\n\t\t\t\t\tfindRelated(_interface);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (\n\t\t\tnode.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ||\n\t\t\tnode.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION\n\t\t) {\n\t\t\t// Input\n\t\t\tmarkAsUsed(node.name.value);\n\n\t\t\tif (node.fields) {\n\t\t\t\tfor (const field of node.fields) {\n\t\t\t\t\tfindRelated(field);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (\n\t\t\tnode.kind === Kind.INTERFACE_TYPE_DEFINITION ||\n\t\t\tnode.kind === Kind.INTERFACE_TYPE_EXTENSION\n\t\t) {\n\t\t\t// Interface\n\t\t\tmarkAsUsed(node.name.value);\n\n\t\t\tif (node.fields) {\n\t\t\t\tfor (const field of node.fields) {\n\t\t\t\t\tfindRelated(field);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (node.interfaces) {\n\t\t\t\tfor (const _interface of node.interfaces) {\n\t\t\t\t\tfindRelated(_interface);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (\n\t\t\tnode.kind === Kind.UNION_TYPE_DEFINITION ||\n\t\t\tnode.kind === Kind.UNION_TYPE_EXTENSION\n\t\t) {\n\t\t\t// Union\n\t\t\tmarkAsUsed(node.name.value);\n\n\t\t\tif (node.types) {\n\t\t\t\tfor (const type of node.types) {\n\t\t\t\t\tfindRelated(type);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (node.kind === Kind.ENUM_TYPE_DEFINITION || node.kind === Kind.ENUM_TYPE_EXTENSION) {\n\t\t\t// Enum\n\t\t\tmarkAsUsed(node.name.value);\n\t\t} else if (\n\t\t\tnode.kind === Kind.SCALAR_TYPE_DEFINITION ||\n\t\t\tnode.kind === Kind.SCALAR_TYPE_EXTENSION\n\t\t) {\n\t\t\t// Scalar\n\t\t\tif (!isGraphQLPrimitive(node.name.value)) {\n\t\t\t\tmarkAsUsed(node.name.value);\n\t\t\t}\n\t\t} else if (node.kind === Kind.INPUT_VALUE_DEFINITION) {\n\t\t\t// Argument\n\t\t\tfindRelated(resolveTypeNode(node.type));\n\t\t} else if (node.kind === Kind.FIELD_DEFINITION) {\n\t\t\t// Field\n\t\t\tfindRelated(resolveTypeNode(node.type));\n\n\t\t\tif (node.arguments) {\n\t\t\t\tfor (const argument of node.arguments) {\n\t\t\t\t\tfindRelated(argument);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (\n\t\t\tnode.kind === Kind.NAMED_TYPE &&\n\t\t\t// Named type\n\t\t\t!isGraphQLPrimitive(node.name.value)\n\t\t) {\n\t\t\tmarkAsUsed(node.name.value);\n\t\t}\n\t}\n\n\treturn used;\n}\n\nfunction collectObjectFieldType(\n\tnode: ObjectTypeDefinitionNode,\n\tfieldDefinition: FieldDefinitionNode,\n\tfieldsMap: GraphQLFieldMap<unknown, unknown>,\n\tfieldTypes: Record<string, Record<string, string>>,\n) {\n\tconst objectName = node.name.value;\n\tconst fieldName = fieldDefinition.name.value;\n\n\tconst field = fieldsMap[fieldDefinition.name.value];\n\tconst baseName = getBaseType(field.type).name;\n\tconst isDefaultScalar = DEFAULT_SCALARS[baseName] != null;\n\tconst name = isDefaultScalar ? `Types.Scalars[\"${baseName}\"][\"output\"]` : baseName;\n\n\tconst type = wrapTypeWithModifiers(name, field.type, {\n\t\twrapOptional: (str: string) => {\n\t\t\treturn `Types.Maybe<${str}>`;\n\t\t},\n\t\twrapArray: (str: string) => {\n\t\t\treturn `Array<${str}>`;\n\t\t},\n\t});\n\n\tif (fieldTypes[objectName] == null) {\n\t\tfieldTypes[objectName] = {};\n\t}\n\tfieldTypes[objectName][fieldName] = type;\n}\n\nfunction collectObjectFieldArguments(\n\tnode: ObjectTypeDefinitionNode,\n\tfieldDefinition: FieldDefinitionNode,\n\tfieldArguments: Record<string, Record<string, boolean>>,\n) {\n\tconst objectName = node.name.value;\n\tconst fieldName = fieldDefinition.name.value;\n\tconst hasArguments = fieldDefinition.arguments != null && fieldDefinition.arguments.length > 0;\n\n\tif (fieldArguments[objectName] == null) {\n\t\tfieldArguments[objectName] = {};\n\t}\n\tfieldArguments[objectName][fieldName] = hasArguments;\n}\n\nexport function collectObjectFieldTypesAndArguments(schema?: GraphQLSchema) {\n\tconst fieldTypes: Record<string, Record<string, string>> = {};\n\tconst fieldArguments: Record<string, Record<string, boolean>> = {};\n\n\tif (!schema) {\n\t\treturn { fieldTypes, fieldArguments };\n\t}\n\n\tconst schemaTypes = schema.getTypeMap();\n\n\tfor (const type of Object.values(schemaTypes)) {\n\t\tif (type.astNode?.kind !== Kind.OBJECT_TYPE_DEFINITION) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst schemaType = schemaTypes[type.name] as GraphQLObjectType;\n\t\tconst fieldsMap = schemaType.getFields();\n\n\t\tfor (const field of type.astNode.fields ?? []) {\n\t\t\tcollectObjectFieldArguments(type.astNode, field, fieldArguments);\n\t\t\tcollectObjectFieldType(type.astNode, field, fieldsMap, fieldTypes);\n\t\t}\n\t}\n\n\treturn { fieldTypes, fieldArguments };\n}\n\nexport function resolveTypeNode(node: TypeNode): NamedTypeNode {\n\tif (node.kind === Kind.LIST_TYPE) {\n\t\treturn resolveTypeNode(node.type);\n\t}\n\n\tif (node.kind === Kind.NON_NULL_TYPE) {\n\t\treturn resolveTypeNode(node.type);\n\t}\n\n\treturn node;\n}\n\nexport function isGraphQLPrimitive(name: string): boolean {\n\treturn ['String', 'Boolean', 'ID', 'Float', 'Int'].includes(name);\n}\n\nexport function unique<T>(val: T, i: number, all: T[]): boolean {\n\treturn i === all.indexOf(val);\n}\n\nexport function withQuotes(val: string): string {\n\treturn `'${val}'`;\n}\n\nexport function indent(size: number) {\n\tconst space = new Array(size).fill(' ').join('');\n\n\tfunction indentInner(val: string): string {\n\t\treturn val\n\t\t\t.split('\\n')\n\t\t\t.map((line) => `${space}${line}`)\n\t\t\t.join('\\n');\n\t}\n\n\treturn indentInner;\n}\n\nexport function buildBlock({ name, lines }: { name: string; lines: string[] }): string {\n\tif (!lines.length) {\n\t\treturn '';\n\t}\n\n\treturn [`${name} {`, ...lines.map(indent(2)), '};'].join('\\n');\n}\n\nconst getRelativePath = (filepath: string, basePath: string) => {\n\tconst normalizedFilepath = normalize(filepath);\n\tconst normalizedBasePath = ensureStartsWithSeparator(\n\t\tnormalize(ensureEndsWithSeparator(basePath)),\n\t);\n\tconst [, relativePath] = normalizedFilepath.split(normalizedBasePath);\n\treturn relativePath;\n};\n\nexport function groupSourcesByModule(\n\tsources: Source[],\n\tbasePath: string,\n): Record<string, Source[]> {\n\tconst grouped: Record<string, Source[]> = {};\n\n\tfor (const source of sources) {\n\t\tif (!source.location) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst relativePath = getRelativePath(source.location, basePath);\n\n\t\tif (relativePath) {\n\t\t\t// PERF: we could guess the module by matching source.location with a list of already resolved paths\n\t\t\tconst mod = extractModuleDirectory(source.location, basePath);\n\n\t\t\tif (!grouped[mod]) {\n\t\t\t\tgrouped[mod] = [];\n\t\t\t}\n\n\t\t\tgrouped[mod].push(source);\n\t\t}\n\t}\n\n\treturn grouped;\n}\n\nfunction extractModuleDirectory(filepath: string, basePath: string): string {\n\tconst relativePath = getRelativePath(filepath, basePath);\n\n\tconst [moduleDirectory] = relativePath.split(sep);\n\n\treturn moduleDirectory;\n}\n\nexport function stripFilename(path: string) {\n\tconst parsedPath = parse(path);\n\treturn normalize(parsedPath.dir);\n}\n\nexport function normalize(path: string) {\n\treturn path.replace(/\\\\/g, '/');\n}\n\nfunction ensureEndsWithSeparator(path: string) {\n\treturn path.endsWith(sep) ? path : path + sep;\n}\n\nfunction ensureStartsWithSeparator(path: string) {\n\tif (platform() === 'win32') {\n\t\treturn path;\n\t}\n\n\treturn path.startsWith('.')\n\t\t? path.replace(/^(..\\/)|(.\\/)/, '/')\n\t\t: path.startsWith('/')\n\t\t\t? path\n\t\t\t: `/${path}`;\n}\n\n/**\n * Pushes an item to a list only if the list doesn't include the item\n */\nexport function pushUnique<T>(list: T[], item: T): void {\n\tif (!list.includes(item)) {\n\t\tlist.push(item);\n\t}\n}\n\nexport function concatByKey<T extends Record<string, string[]>, K extends keyof T>(\n\tleft: T,\n\tright: T,\n\tkey: K,\n) {\n\t// Remove duplicate, if an element is in right & left, it will be only once in the returned array.\n\treturn [...new Set([...left[key], ...right[key]])];\n}\n\nexport function uniqueByKey<T extends Record<string, string[]>, K extends keyof T>(\n\tleft: T,\n\tright: T,\n\tkey: K,\n) {\n\treturn left[key].filter((item) => !right[key].includes(item));\n}\n\nexport function createObject<K extends string, T>(keys: K[], valueFn: (key: K) => T) {\n\tconst obj: Record<K, T> = {} as Record<K, T>;\n\n\tfor (const key of keys) {\n\t\tobj[key] = valueFn(key);\n\t}\n\n\treturn obj;\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _baeta_generator_sdk from '@baeta/generator-sdk';
2
2
 
3
- declare function graphqlPlugin(): _baeta_generator_sdk.GeneratorPluginV1<{}>;
3
+ declare function graphqlPlugin(): _baeta_generator_sdk.GeneratorPluginV1<unknown>;
4
4
 
5
5
  export { graphqlPlugin };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _baeta_generator_sdk from '@baeta/generator-sdk';
2
2
 
3
- declare function graphqlPlugin(): _baeta_generator_sdk.GeneratorPluginV1<{}>;
3
+ declare function graphqlPlugin(): _baeta_generator_sdk.GeneratorPluginV1<unknown>;
4
4
 
5
5
  export { graphqlPlugin };