@baeta/plugin-graphql 2.0.0-next.13 → 2.0.0-next.15

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,25 @@
1
1
  # @baeta/plugin-graphql
2
2
 
3
+ ## 2.0.0-next.15
4
+
5
+ ### Patch Changes
6
+
7
+ - Drop Node v23 and v25 by [@andreisergiu98](https://github.com/andreisergiu98) in [#474](https://github.com/andreisergiu98/baeta/pull/474)
8
+
9
+ - Avoid generating unused code by [@andreisergiu98](https://github.com/andreisergiu98) in [#469](https://github.com/andreisergiu98/baeta/pull/469)
10
+
11
+ - Improve generated block with no lines by [@andreisergiu98](https://github.com/andreisergiu98) in [#528](https://github.com/andreisergiu98/baeta/pull/528)
12
+
13
+ - Drop extensions concept and api in favor of app plugins by [@andreisergiu98](https://github.com/andreisergiu98) in [#428](https://github.com/andreisergiu98/baeta/pull/428)
14
+
15
+ - Drop change-case-all dependency in favor of change-case by [@andreisergiu98](https://github.com/andreisergiu98) in [#418](https://github.com/andreisergiu98/baeta/pull/418)
16
+ - Updated dependencies [[`dc89e17`](https://github.com/andreisergiu98/baeta/commit/dc89e1728926f4bd5a5e1351635c38bf8d5938dc), [`f4bdeae`](https://github.com/andreisergiu98/baeta/commit/f4bdeaeae9d9d067121447bed2cf4bf503650ee6), [`1249b32`](https://github.com/andreisergiu98/baeta/commit/1249b32c42270151d6d6de46d54c82c1f975719b), [`3571c17`](https://github.com/andreisergiu98/baeta/commit/3571c1785a4eb1361c47b80725c990cefa27a791), [`d179c12`](https://github.com/andreisergiu98/baeta/commit/d179c12488f6ac11add26f8337e088f791d820b7), [`03c2bc9`](https://github.com/andreisergiu98/baeta/commit/03c2bc9913b6ffdc15f627f9d177347e0805defd)]:
17
+ - @baeta/generator-sdk@2.0.0-next.6
18
+ - @baeta/util-graphql@2.0.0-next.3
19
+ - @baeta/util-path@2.0.0-next.5
20
+
21
+ ## 2.0.0-next.14
22
+
3
23
  ## 2.0.0-next.13
4
24
 
5
25
  ### Patch Changes
package/README.md CHANGED
@@ -35,10 +35,11 @@ Building GraphQL APIs shouldn't be complicated. **Baeta** is a modern, modular,
35
35
  - **Middleware & Directives**: Easy integration of custom behaviors
36
36
  - **High Performance**: Built for scalability and efficiency
37
37
 
38
- #### And optional extensions and plugins
38
+ #### And optional app plugins and libraries
39
39
 
40
- - **@baeta/extension-auth**: Add powerful scope-based authorization
41
- - **@baeta/extension-cache**: Implement automatic caching with simple update patterns
40
+ - **@baeta/auth**: Add powerful scope-based authorization
41
+ - **@baeta/complexity**: Reject resource-exhausting queries with depth, breadth and complexity limits
42
+ - **@baeta/cache**: Type-safe caching with declarative queries and automatic reconciliation
42
43
  - ... and more!
43
44
 
44
45
  ## Why use Baeta?
@@ -89,7 +90,7 @@ const usersQuery = Query.users.resolve(() => {
89
90
  return dataSource.user.findMany();
90
91
  });
91
92
 
92
- Query.$fields({
93
+ export default Query.$fields({
93
94
  user: userQuery,
94
95
  users: usersQuery,
95
96
  });
@@ -98,17 +99,13 @@ Query.$fields({
98
99
  #### 3. Add authorization
99
100
 
100
101
  ```typescript
102
+ import { auth, rule, scope } from "./lib/auth.ts";
101
103
  import { UserModule } from "./typedef.ts";
102
104
 
103
105
  const { Query } = UserModule;
104
106
 
105
107
  const userQuery = Query.user
106
- .$auth({
107
- $or: {
108
- isPublic: true,
109
- isLoggedIn: true,
110
- },
111
- })
108
+ .$use(auth(rule.or(scope.isPublic, scope.isLoggedIn)))
112
109
  .resolve(async ({ args }) => {
113
110
  // ...
114
111
  });
@@ -117,23 +114,33 @@ const userQuery = Query.user
117
114
  #### 4. Add caching
118
115
 
119
116
  ```typescript
120
- const { Query, Mutation, User } = UserModule;
121
-
122
- export const userCache = User.$createCache();
123
-
124
- const userQuery = Query.user
125
- .$auth({
126
- // ...
117
+ import { createCache, defineQuery } from "@baeta/cache";
118
+ import { redisClient } from "./lib/redis.ts";
119
+
120
+ const { Query, Mutation } = UserModule;
121
+
122
+ export const userCache = createCache(redisClient, {
123
+ name: "UserCache",
124
+ parse: JSON.parse,
125
+ serialize: JSON.stringify,
126
+ })
127
+ .withQueries({
128
+ findUser: defineQuery({
129
+ resolve: async (args: { id: string }) => {
130
+ return dataSource.user.findUnique({ where: args });
131
+ },
132
+ }),
127
133
  })
128
- .$useCache(userCache)
129
- .resolve(async ({ args }) => {
130
- // ...
131
- });
134
+ .build();
135
+
136
+ const userQuery = Query.user.map(({ args }) =>
137
+ userCache.queries.findUser({ id: args.where.id }),
138
+ );
132
139
 
133
140
  const updateUserMutation = Mutation.updateUser
134
141
  .$use(async (next) => {
135
142
  const user = await next();
136
- await userCache.save(user);
143
+ if (user) await userCache.update(user);
137
144
  return user;
138
145
  })
139
146
  .resolve(async ({ args }) => {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import * as _$_baeta_generator_sdk0 from "@baeta/generator-sdk";
2
-
3
1
  //#region index.d.ts
4
- declare function graphqlPlugin(): _$_baeta_generator_sdk0.GeneratorPluginV1<unknown>;
2
+ declare function graphqlPlugin(): import("@baeta/generator-sdk").GeneratorPluginV1<unknown>;
5
3
  //#endregion
6
4
  export { graphqlPlugin };
7
5
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -2,7 +2,15 @@ import { createPluginV1, isMatch } from "@baeta/generator-sdk";
2
2
  import { createDefinitionsMapFromDocument, createDefinitionsMapFromSources, createModuleRegistry, getSourcesFromSchema, groupSourcesByModule, isScalarType, loadSchema } from "@baeta/util-graphql";
3
3
  import { join, posixPath, relative } from "@baeta/util-path";
4
4
  import { Kind, concatAST } from "graphql";
5
- import { camelCase, pascalCase } from "change-case-all";
5
+ import { camelCase, pascalCase } from "change-case";
6
+ //#region lib/namespace.ts
7
+ const namespace = {
8
+ sdk: "BaetaSdk",
9
+ graphql: "BaetaGraphql",
10
+ globalTypes: "BaetaTypes",
11
+ userTypes: "BaetaUserTypes"
12
+ };
13
+ //#endregion
6
14
  //#region lib/field-info.ts
7
15
  function createFieldInfoMap(definitionsMap, defaultScalars) {
8
16
  const map = /* @__PURE__ */ new Map();
@@ -26,8 +34,8 @@ function printNamedType$1(definitionsMap, defaultScalars, type, nullable = true)
26
34
  const withNullable = nullable ? " | null" : "";
27
35
  switch (type.kind) {
28
36
  case Kind.NAMED_TYPE:
29
- if (isScalarType(definitionsMap, defaultScalars, type)) return `Types.Scalars["${type.name.value}"]${withNullable}`;
30
- return `Types.${type.name.value}${withNullable}`;
37
+ if (isScalarType(definitionsMap, defaultScalars, type)) return `${namespace.globalTypes}.Scalars["${type.name.value}"]${withNullable}`;
38
+ return `${namespace.globalTypes}.${type.name.value}${withNullable}`;
31
39
  case Kind.LIST_TYPE: return `Array<${printNamedType$1(definitionsMap, defaultScalars, type.type)}>${withNullable}`;
32
40
  case Kind.NON_NULL_TYPE: return printNamedType$1(definitionsMap, defaultScalars, type.type, false);
33
41
  default: return type;
@@ -64,6 +72,7 @@ function buildBlock({ name, lines }) {
64
72
  ].join("\n");
65
73
  }
66
74
  function buildCodeBlock({ name, lines }) {
75
+ if (lines.length === 0) return `${name} {}`;
67
76
  const linesWithSep = lines.filter(Boolean).map(indent(2)).join(",\n");
68
77
  return [
69
78
  `${name} {`,
@@ -97,22 +106,18 @@ function printModuleIndexStarter(config, moduleName) {
97
106
  }
98
107
  function printModuleImports(config, moduleName) {
99
108
  const typesDir = makeRelativePathForImport(join(config.modulesDir, moduleName), config.typesDir);
109
+ const hasTypes = config.registry.defined.objects.length > 0;
100
110
  return [
101
- "import type { DocumentNode, GraphQLScalarType } from \"graphql\";",
102
- "import * as Baeta from \"@baeta/core/sdk\";",
103
- `import extensions from "../extensions${config.importExtension}";`,
104
- `import type {Ctx, Info} from "../types${config.importExtension}";`,
105
- `import type * as Types from "${typesDir}/types${config.importExtension}";`
106
- ].join("\n");
111
+ `import * as ${namespace.sdk} from "@baeta/core/sdk";`,
112
+ `import type * as ${namespace.graphql} from "graphql";`,
113
+ hasTypes ? `import type * as ${namespace.globalTypes} from "${typesDir}/types${config.importExtension}";` : null,
114
+ `import type * as ${namespace.userTypes} from "../types${config.importExtension}";`
115
+ ].filter((el) => el != null).join("\n");
107
116
  }
108
117
  function printModuleMetadata(name, doc) {
109
118
  return buildCodeBlock({
110
119
  name: "const moduleMetadata =",
111
- lines: [
112
- `id: '${name}'`,
113
- `dirname: './${name}'`,
114
- `typedef: ${JSON.stringify(doc)} as unknown as DocumentNode`
115
- ]
120
+ lines: [`id: '${name}'`, `typedef: ${JSON.stringify(doc)} as unknown as ${namespace.graphql}.DocumentNode`]
116
121
  });
117
122
  }
118
123
  function printBaetaModuleTypes(config) {
@@ -168,16 +173,18 @@ function printObjectTypeModuleType(typeName, objects, isFactory) {
168
173
  const parentType = getParentType(typeName);
169
174
  const contextType = getContextType();
170
175
  const infoType = getInfoType();
171
- if (isFactory) return `${typeName}: Baeta.TypeCompilerFactory<${parentType}, ${contextType}, ${infoType}, BaetaModuleObjectTypeFields['${typeName}']['Factory']>`;
172
- return `${typeName}: Baeta.TypeMethods<${parentType}, ${contextType}, ${infoType}, BaetaModuleObjectTypeFields['${typeName}']['Builder'], BaetaModuleObjectTypeFields['${typeName}']['Factory']>`;
176
+ if (isFactory) return `${typeName}: ${namespace.sdk}.TypeCompilerFactory<${parentType}, ${contextType}, ${infoType}, BaetaModuleObjectTypeFields['${typeName}']['Factory']>`;
177
+ return `${typeName}: ${namespace.sdk}.TypeMethods<${parentType}, ${contextType}, ${infoType}, BaetaModuleObjectTypeFields['${typeName}']['Builder'], BaetaModuleObjectTypeFields['${typeName}']['Factory']>`;
173
178
  }
174
179
  function printBaetaModuleTypesScalars(config) {
175
- return config.registry.defined.scalars.map((scalar) => `${scalar}: GraphQLScalarType`);
180
+ return config.registry.defined.scalars.map((scalar) => `${scalar}: ${namespace.graphql}.GraphQLScalarType`);
176
181
  }
177
182
  function printModuleObjectTypeFields(config) {
183
+ const objects = config.registry.defined.objects.map((typeName) => printObjectTypeFields(config, typeName, config.registry.picks.objects)).filter(Boolean);
184
+ if (objects.length === 0) return "";
178
185
  return buildBlock({
179
186
  name: "interface BaetaModuleObjectTypeFields",
180
- lines: config.registry.defined.objects.map((typeName) => printObjectTypeFields(config, typeName, config.registry.picks.objects)).filter(Boolean)
187
+ lines: objects
181
188
  });
182
189
  }
183
190
  function printObjectTypeFields(config, typeName, objects) {
@@ -202,7 +209,8 @@ function printObjectTypeFieldBuilders(config, typeName, field) {
202
209
  const argumentsType = getArgsType(config, typeName, field);
203
210
  const contextType = getContextType();
204
211
  const infoType = getInfoType();
205
- return `${field}: Baeta.${typeName === "Subscription" ? "SubscriptionMethods" : "FieldMethods"}<${resultType}, ${parentType}, ${contextType}, ${argumentsType}, ${infoType}>`;
212
+ const fieldType = typeName === "Subscription" ? "SubscriptionMethods" : "FieldMethods";
213
+ return `${field}: ${namespace.sdk}.${fieldType}<${resultType}, ${parentType}, ${contextType}, ${argumentsType}, ${infoType}>`;
206
214
  }
207
215
  function printObjectTypeFieldFactories(config, typeName, field) {
208
216
  const parentType = getParentType(typeName);
@@ -210,7 +218,8 @@ function printObjectTypeFieldFactories(config, typeName, field) {
210
218
  const argumentsType = getArgsType(config, typeName, field);
211
219
  const contextType = getContextType();
212
220
  const infoType = getInfoType();
213
- return `${field}: Baeta.${typeName === "Subscription" ? "SubscriptionField" : "Field"}<${resultType}, ${resultType}, ${parentType}, ${contextType}, ${argumentsType}, ${infoType}>`;
221
+ const fieldType = typeName === "Subscription" ? "SubscriptionField" : "Field";
222
+ return `${field}: ${namespace.sdk}.${fieldType}<${resultType}, ${resultType}, ${parentType}, ${contextType}, ${argumentsType}, ${infoType}>`;
214
223
  }
215
224
  function printModuleBuilder(config, moduleName) {
216
225
  const builders = buildCodeBlock({
@@ -224,20 +233,21 @@ function printModuleBuilder(config, moduleName) {
224
233
  const infoType = getInfoType();
225
234
  const contextType = getContextType();
226
235
  return [
227
- `export const ${pascalCase(moduleName)}Module = Baeta.createModuleBuilder<${contextType}, ${infoType}, BaetaModuleTypes['Builders'], BaetaModuleTypes['Factories']>(moduleMetadata.id, moduleMetadata.typedef,`,
236
+ `export const ${pascalCase(moduleName)}Module = ${namespace.sdk}.createModuleBuilder<${contextType}, ${infoType}, BaetaModuleTypes['Builders'], BaetaModuleTypes['Factories']>(moduleMetadata.id, moduleMetadata.typedef,`,
228
237
  builders,
229
238
  ",",
230
239
  typeNameResolvers,
231
- `, ${getExtensionsVar()});`
240
+ `);`
232
241
  ].join("");
233
242
  }
234
243
  function printObjectTypeBuilder(typeName, objects) {
235
244
  const fields = objects[typeName]?.map((field) => printObjectTypeFieldBuilder(typeName, field));
236
245
  if (fields == null || fields.length === 0) return "";
237
- return `${typeName}: Baeta.createTypeBuilder("${typeName}",${buildCodeBlock({
246
+ const content = buildCodeBlock({
238
247
  name: "",
239
248
  lines: fields
240
- })}, ${getExtensionsVar()})`;
249
+ });
250
+ return `${typeName}: ${namespace.sdk}.createTypeBuilder("${typeName}",${content})`;
241
251
  }
242
252
  function printTypeNameResolver() {
243
253
  return "{ __resolveType: (source: {__typename: string}) => { return source.__typename; }}";
@@ -248,7 +258,7 @@ function getParentType(type) {
248
258
  "Mutation",
249
259
  "Subscription"
250
260
  ].includes(type)) return "{}";
251
- return `Types.${type}`;
261
+ return `${namespace.globalTypes}.${type}`;
252
262
  }
253
263
  function getResultType(config, type, field) {
254
264
  const fieldType = config.fieldInfo.get(type)?.get(field)?.type;
@@ -257,20 +267,18 @@ function getResultType(config, type, field) {
257
267
  }
258
268
  function getArgsType(config, type, field) {
259
269
  if (!(config.fieldInfo.get(type)?.get(field)?.hasArguments ?? false)) return "{}";
260
- return `Types.${type}${pascalCase(field)}Args`;
270
+ const fieldUpper = pascalCase(field);
271
+ return `${namespace.globalTypes}.${type}${fieldUpper}Args`;
261
272
  }
262
273
  function printObjectTypeFieldBuilder(typeName, field) {
263
- if (typeName === "Subscription") return `${field}: Baeta.createSubscriptionBuilder("${field}", ${getExtensionsVar()})`;
264
- return `${field}: Baeta.createFieldBuilder("${typeName}", "${field}", ${getExtensionsVar()})`;
274
+ if (typeName === "Subscription") return `${field}: ${namespace.sdk}.createSubscriptionBuilder("${field}")`;
275
+ return `${field}: ${namespace.sdk}.createFieldBuilder("${typeName}", "${field}")`;
265
276
  }
266
277
  function getContextType() {
267
- return "Ctx";
278
+ return `${namespace.userTypes}.Ctx`;
268
279
  }
269
280
  function getInfoType() {
270
- return "Info";
271
- }
272
- function getExtensionsVar() {
273
- return "extensions";
281
+ return `${namespace.userTypes}.Info`;
274
282
  }
275
283
  //#endregion
276
284
  //#region lib/printer-templates.ts
@@ -287,12 +295,6 @@ export type Ctx = {};
287
295
  export type Info = GraphQLResolveInfo;
288
296
  `;
289
297
  }
290
- function printExtensionsTemplate() {
291
- return `import { createExtensions } from '@baeta/core';
292
-
293
- export default createExtensions({});
294
- `;
295
- }
296
298
  //#endregion
297
299
  //#region lib/printer-types.ts
298
300
  function printUtilityTypes() {
@@ -502,20 +504,7 @@ async function generate(options, currentFiles) {
502
504
  }),
503
505
  options: {
504
506
  disableOverwrite: true,
505
- disableBiomeV1Header: true,
506
- disableBiomeV2Header: true,
507
- disableEslintHeader: true,
508
- disableGenerationNoticeHeader: true
509
- }
510
- },
511
- {
512
- filename: join(options.modulesDir, "extensions.ts"),
513
- content: printExtensionsTemplate(),
514
- options: {
515
- disableOverwrite: true,
516
- disableBiomeV1Header: true,
517
- disableBiomeV2Header: true,
518
- disableEslintHeader: true,
507
+ enableLintHeaders: false,
519
508
  disableGenerationNoticeHeader: true
520
509
  }
521
510
  }
@@ -548,9 +537,7 @@ async function generate(options, currentFiles) {
548
537
  content: printModuleIndexStarter(config, module),
549
538
  options: {
550
539
  disableOverwrite: true,
551
- disableBiomeV1Header: true,
552
- disableBiomeV2Header: true,
553
- disableEslintHeader: true,
540
+ enableLintHeaders: false,
554
541
  disableGenerationNoticeHeader: true
555
542
  }
556
543
  });
@@ -573,7 +560,7 @@ function graphqlPlugin() {
573
560
  generate: async (ctx, next) => {
574
561
  const items = await generate(ctx.generatorOptions, ctx.fileManager.files);
575
562
  for (const item of items) ctx.fileManager.createAndAdd(item.filename, item.content, "graphql", item.options);
576
- return next();
563
+ return await next();
577
564
  }
578
565
  });
579
566
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["printNamedType"],"sources":["../lib/field-info.ts","../lib/printer-autoload.ts","../lib/printer-utils.ts","../lib/printer-module.ts","../lib/printer-templates.ts","../lib/printer-types.ts","../lib/codegen.ts","../index.ts"],"sourcesContent":["import { type DefinitionsMap, isScalarType } from '@baeta/util-graphql';\nimport { Kind, type TypeNode } from 'graphql';\n\nexport type FieldInfoMap = Map<string, Map<string, { type: string; hasArguments: boolean }>>;\n\nexport function createFieldInfoMap(definitionsMap: DefinitionsMap, defaultScalars: string[]) {\n\tconst map: FieldInfoMap = new Map();\n\tfor (const objectType of definitionsMap.objectTypeMap.values()) {\n\t\tconst objectName = objectType.name.value;\n\t\tfor (const field of objectType.fields ?? []) {\n\t\t\tconst fieldName = field.name.value;\n\t\t\tconst type = printNamedType(definitionsMap, defaultScalars, field.type);\n\t\t\tconst hasArguments = field.arguments != null && field.arguments.length > 0;\n\t\t\tconst fieldMap = map.get(objectName) ?? new Map();\n\t\t\tfieldMap.set(fieldName, { type, hasArguments });\n\t\t\tmap.set(objectName, fieldMap);\n\t\t}\n\t}\n\treturn map;\n}\n\nfunction printNamedType(\n\tdefinitionsMap: DefinitionsMap,\n\tdefaultScalars: string[],\n\ttype: TypeNode,\n\tnullable = true,\n): string {\n\tconst withNullable = nullable ? ' | null' : '';\n\tswitch (type.kind) {\n\t\tcase Kind.NAMED_TYPE:\n\t\t\tif (isScalarType(definitionsMap, defaultScalars, type)) {\n\t\t\t\treturn `Types.Scalars[\"${type.name.value}\"]${withNullable}`;\n\t\t\t}\n\t\t\treturn `Types.${type.name.value}${withNullable}`;\n\t\tcase Kind.LIST_TYPE:\n\t\t\treturn `Array<${printNamedType(definitionsMap, defaultScalars, type.type)}>${withNullable}`;\n\t\tcase Kind.NON_NULL_TYPE:\n\t\t\treturn printNamedType(definitionsMap, defaultScalars, type.type, false);\n\t\tdefault:\n\t\t\treturn type satisfies never;\n\t}\n}\n","import { camelCase, pascalCase } from 'change-case-all';\n\ninterface AutoloadPrinterConfig {\n\tmoduleDefinitionName: string;\n\timportExtension: '.ts' | '.js' | '';\n}\n\nexport function printAutoload(config: AutoloadPrinterConfig, modules: string[]) {\n\treturn [printImports(config, modules), printExport(modules)].join('\\n\\n');\n}\n\nfunction printImports(config: AutoloadPrinterConfig, modules: string[]) {\n\tconst dependencyImports = [\n\t\t'import type { ModuleCompilerFactory } from \"@baeta/core/sdk\";',\n\t\t`import type { Ctx, Info } from \"./types${config.importExtension}\"`,\n\t];\n\tconst moduleTypeImports = modules.map(\n\t\t(module) =>\n\t\t\t`import type { BaetaModuleTypes as ${pascalCase(module)}ModuleTypes } from \"./${module}/${config.moduleDefinitionName}${config.importExtension}\"`,\n\t);\n\tconst moduleImports = modules.flatMap(\n\t\t(module) => `import ${camelCase(module)} from \"./${module}/index${config.importExtension}\"`,\n\t);\n\treturn [...dependencyImports, ...moduleTypeImports, ...moduleImports].join('\\n');\n}\n\nfunction printExport(modules: string[]) {\n\treturn `export default [\\n${modules.map(printModuleWithSatisfies).join(',\\n')}\\n];`;\n}\n\nfunction printModuleWithSatisfies(module: string) {\n\treturn ` ${camelCase(module)} satisfies ModuleCompilerFactory<Ctx, Info, ${pascalCase(module)}ModuleTypes[\"Factories\"]>`;\n}\n","import { posixPath, relative } from '@baeta/util-path';\n\nexport function buildBlock({ name, lines }: { name: string; lines: string[] }): string {\n\treturn [`${name} {`, ...lines.filter(Boolean).map(indent(2)), '};'].join('\\n');\n}\n\nexport function buildCodeBlock({ name, lines }: { name: string; lines: string[] }) {\n\tconst linesWithSep = lines.filter(Boolean).map(indent(2)).join(',\\n');\n\treturn [`${name} {`, linesWithSep, '}'].join('\\n');\n}\n\nexport function indent(size: number) {\n\tconst space = new Array(size).fill(' ').join('');\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\treturn indentInner;\n}\n\nexport function unique<T>(val: T, i: number, all: T[]): boolean {\n\treturn i === all.indexOf(val);\n}\n\nexport function makeRelativePathForImport(from: string, to: string) {\n\tconst res = posixPath(relative(from, to));\n\tif (res.startsWith('.') || res.startsWith('/')) {\n\t\treturn res;\n\t}\n\treturn `./${res}`;\n}\n","import type { ModuleRegistry } from '@baeta/util-graphql';\nimport { join } from '@baeta/util-path';\nimport { pascalCase } from 'change-case-all';\nimport type { DocumentNode } from 'graphql';\nimport type { FieldInfoMap } from './field-info.ts';\nimport { buildBlock, buildCodeBlock, indent, makeRelativePathForImport } from './printer-utils.ts';\n\nexport interface ModulePrinterConfig {\n\tregistry: ModuleRegistry;\n\tfieldInfo: FieldInfoMap;\n\ttypesDir: string;\n\tmodulesDir: string;\n\tmoduleDefinitionName: string;\n\timportExtension: '.ts' | '.js' | '';\n}\n\nexport function printModuleIndexStarter(config: ModulePrinterConfig, moduleName: string): string {\n\tconst typeEntries = Object.entries(config.registry.picks.objects);\n\tconst types = typeEntries.map(([typeName]) => typeName);\n\n\treturn [\n\t\tprintModuleIndexImports(config, moduleName),\n\t\tprintModuleIndexDestructuredTypes(moduleName, types),\n\t\t...typeEntries.map(([typeName, fields]) => printModuleIndexType(typeName, fields)),\n\t\tprintModuleIndexSchema(moduleName, types, config.registry.defined.scalars),\n\t]\n\t\t.filter((el) => el != null)\n\t\t.join('\\n\\n');\n}\n\nexport function printModuleImports(config: ModulePrinterConfig, moduleName: string) {\n\tconst typesDir = makeRelativePathForImport(join(config.modulesDir, moduleName), config.typesDir);\n\treturn [\n\t\t'import type { DocumentNode, GraphQLScalarType } from \"graphql\";',\n\t\t'import * as Baeta from \"@baeta/core/sdk\";',\n\t\t`import extensions from \"../extensions${config.importExtension}\";`,\n\t\t`import type {Ctx, Info} from \"../types${config.importExtension}\";`,\n\t\t`import type * as Types from \"${typesDir}/types${config.importExtension}\";`,\n\t].join('\\n');\n}\n\nexport function printModuleMetadata(name: string, doc: DocumentNode) {\n\treturn buildCodeBlock({\n\t\tname: 'const moduleMetadata =',\n\t\tlines: [\n\t\t\t`id: '${name}'`,\n\t\t\t`dirname: './${name}'`,\n\t\t\t`typedef: ${JSON.stringify(doc)} as unknown as DocumentNode`,\n\t\t],\n\t});\n}\n\nexport function printBaetaModuleTypes(config: ModulePrinterConfig) {\n\treturn buildBlock({\n\t\tname: 'export interface BaetaModuleTypes',\n\t\tlines: [\n\t\t\tbuildBlock({\n\t\t\t\tname: 'Builders:',\n\t\t\t\tlines: printBaetaModuleTypesForFields(config, false),\n\t\t\t}),\n\t\t\tbuildBlock({\n\t\t\t\tname: 'Factories:',\n\t\t\t\tlines: [\n\t\t\t\t\t...printBaetaModuleTypesForFields(config, true),\n\t\t\t\t\t...printBaetaModuleTypesScalars(config),\n\t\t\t\t],\n\t\t\t}),\n\t\t],\n\t});\n}\n\nfunction printModuleIndexDestructuredTypes(moduleName: string, types: string[]) {\n\treturn `const { ${types.join(', ')} } = ${pascalCase(moduleName)}Module;`;\n}\n\nfunction printModuleIndexImports(config: ModulePrinterConfig, moduleName: string) {\n\tconst hasScalars = config.registry.defined.scalars.length > 0;\n\tconst moduleImport = `import { ${pascalCase(moduleName)}Module } from \"./${config.moduleDefinitionName}${config.importExtension}\";`;\n\tif (!hasScalars) {\n\t\treturn moduleImport;\n\t}\n\treturn [`import { GraphQLScalarType } from \"graphql\";`, moduleImport].join('\\n');\n}\n\nfunction printModuleIndexSchema(moduleName: string, types: string[], scalars: string[]) {\n\tconst printedTypes = [\n\t\t...types.map((typeName) => `${typeName}: ${typeName}Resolver,`),\n\t\t...scalars.map(\n\t\t\t(scalarName) => `${scalarName}: new GraphQLScalarType({ name: '${scalarName}' }),`,\n\t\t),\n\t]\n\t\t.map(indent(2))\n\t\t.join('\\n');\n\n\treturn `export default ${pascalCase(moduleName)}Module.$schema({\n${printedTypes}\n});`;\n}\n\nfunction printModuleIndexType(typeName: string, fields: string[]) {\n\tconst printedFields = fields\n\t\t.map((fieldName) => printModuleIndexTypeField(typeName, fieldName))\n\t\t.map(indent(2))\n\t\t.join('\\n');\n\n\treturn `const ${typeName}Resolver = ${typeName}.$fields({\n${printedFields}\n});`;\n}\n\nfunction printModuleIndexTypeField(typeName: string, fieldName: string) {\n\tif (typeName === 'Query' || typeName === 'Mutation') {\n\t\treturn `${fieldName}: ${typeName}.${fieldName}.resolve((params) => {\n // Implement resolver logic here\n}),`;\n\t}\n\n\tif (typeName === 'Subscription') {\n\t\treturn `${fieldName}: ${typeName}.${fieldName}\n .subscribe((params) => {\n // Implement subscribe logic here\n })\n .resolve((params) => {\n // Implement resolver logic here\n }),`;\n\t}\n\n\treturn `${fieldName}: ${typeName}.${fieldName}.key('${fieldName}'),`;\n}\n\nfunction printBaetaModuleTypesForFields(config: ModulePrinterConfig, isFactory: boolean) {\n\treturn config.registry.defined.objects\n\t\t.map((typeName) =>\n\t\t\tprintObjectTypeModuleType(typeName, config.registry.picks.objects, isFactory),\n\t\t)\n\t\t.filter(Boolean);\n}\n\nfunction printObjectTypeModuleType(\n\ttypeName: string,\n\tobjects: Record<string, string[] | undefined>,\n\tisFactory: boolean,\n) {\n\tconst object = objects[typeName];\n\tif (!object) {\n\t\treturn '';\n\t}\n\tconst parentType = getParentType(typeName);\n\tconst contextType = getContextType();\n\tconst infoType = getInfoType();\n\tif (isFactory) {\n\t\treturn `${typeName}: Baeta.TypeCompilerFactory<${parentType}, ${contextType}, ${infoType}, BaetaModuleObjectTypeFields['${typeName}']['Factory']>`;\n\t}\n\treturn `${typeName}: Baeta.TypeMethods<${parentType}, ${contextType}, ${infoType}, BaetaModuleObjectTypeFields['${typeName}']['Builder'], BaetaModuleObjectTypeFields['${typeName}']['Factory']>`;\n}\n\nfunction printBaetaModuleTypesScalars(config: ModulePrinterConfig) {\n\treturn config.registry.defined.scalars.map((scalar) => `${scalar}: GraphQLScalarType`);\n}\n\nexport function printModuleObjectTypeFields(config: ModulePrinterConfig) {\n\tconst objects = config.registry.defined.objects\n\t\t.map((typeName) => printObjectTypeFields(config, typeName, config.registry.picks.objects))\n\t\t.filter(Boolean);\n\treturn buildBlock({\n\t\tname: 'interface BaetaModuleObjectTypeFields',\n\t\tlines: objects,\n\t});\n}\n\nfunction printObjectTypeFields(\n\tconfig: ModulePrinterConfig,\n\ttypeName: string,\n\tobjects: Record<string, string[] | undefined>,\n) {\n\tconst fields = objects[typeName];\n\tif (!fields || fields.length === 0) {\n\t\treturn '';\n\t}\n\tconst fieldsBuilders = fields.map((field) =>\n\t\tprintObjectTypeFieldBuilders(config, typeName, field),\n\t);\n\tconst fieldsFactories = fields.map((field) =>\n\t\tprintObjectTypeFieldFactories(config, typeName, field),\n\t);\n\treturn buildBlock({\n\t\tname: `${typeName}:`,\n\t\tlines: [\n\t\t\tbuildBlock({\n\t\t\t\tname: 'Builder:',\n\t\t\t\tlines: fieldsBuilders,\n\t\t\t}),\n\t\t\tbuildBlock({\n\t\t\t\tname: 'Factory:',\n\t\t\t\tlines: fieldsFactories,\n\t\t\t}),\n\t\t],\n\t});\n}\n\nfunction printObjectTypeFieldBuilders(\n\tconfig: ModulePrinterConfig,\n\ttypeName: string,\n\tfield: string,\n) {\n\tconst parentType = getParentType(typeName);\n\tconst resultType = getResultType(config, typeName, field);\n\tconst argumentsType = getArgsType(config, typeName, field);\n\tconst contextType = getContextType();\n\tconst infoType = getInfoType();\n\tconst namespace = typeName === 'Subscription' ? 'SubscriptionMethods' : 'FieldMethods';\n\treturn `${field}: Baeta.${namespace}<${resultType}, ${parentType}, ${contextType}, ${argumentsType}, ${infoType}>`;\n}\n\nfunction printObjectTypeFieldFactories(\n\tconfig: ModulePrinterConfig,\n\ttypeName: string,\n\tfield: string,\n) {\n\tconst parentType = getParentType(typeName);\n\tconst resultType = getResultType(config, typeName, field);\n\tconst argumentsType = getArgsType(config, typeName, field);\n\tconst contextType = getContextType();\n\tconst infoType = getInfoType();\n\tconst namespace = typeName === 'Subscription' ? 'SubscriptionField' : 'Field';\n\treturn `${field}: Baeta.${namespace}<${resultType}, ${resultType}, ${parentType}, ${contextType}, ${argumentsType}, ${infoType}>`;\n}\n\nexport function printModuleBuilder(config: ModulePrinterConfig, moduleName: string) {\n\tconst objectTypes = config.registry.defined.objects\n\t\t.map((typeName) => printObjectTypeBuilder(typeName, config.registry.picks.objects))\n\t\t.filter(Boolean);\n\tconst builders = buildCodeBlock({\n\t\tname: '',\n\t\tlines: objectTypes,\n\t});\n\tconst typeNameResolvers = buildCodeBlock({\n\t\tname: '',\n\t\tlines: [...config.registry.defined.unions, ...config.registry.defined.interfaces].map(\n\t\t\t(name) => `${name}: ${printTypeNameResolver()}`,\n\t\t),\n\t});\n\tconst infoType = getInfoType();\n\tconst contextType = getContextType();\n\treturn [\n\t\t`export const ${pascalCase(moduleName)}Module = Baeta.createModuleBuilder<${contextType}, ${infoType}, BaetaModuleTypes['Builders'], BaetaModuleTypes['Factories']>(moduleMetadata.id, moduleMetadata.typedef,`,\n\t\tbuilders,\n\t\t',',\n\t\ttypeNameResolvers,\n\t\t`, ${getExtensionsVar()});`,\n\t].join('');\n}\n\nfunction printObjectTypeBuilder(typeName: string, objects: Record<string, string[] | undefined>) {\n\tconst fields = objects[typeName]?.map((field) => printObjectTypeFieldBuilder(typeName, field));\n\tif (fields == null || fields.length === 0) {\n\t\treturn '';\n\t}\n\tconst content = buildCodeBlock({\n\t\tname: '',\n\t\tlines: fields,\n\t});\n\treturn `${typeName}: Baeta.createTypeBuilder(\"${typeName}\",${content}, ${getExtensionsVar()})`;\n}\n\nfunction printTypeNameResolver() {\n\treturn '{ __resolveType: (source: {__typename: string}) => { return source.__typename; }}';\n}\n\nfunction getParentType(type: string) {\n\tif (['Query', 'Mutation', 'Subscription'].includes(type)) {\n\t\treturn '{}';\n\t}\n\treturn `Types.${type}`;\n}\n\nfunction getResultType(config: ModulePrinterConfig, type: string, field: string) {\n\tconst fieldType = config.fieldInfo.get(type)?.get(field)?.type;\n\tif (fieldType == null) {\n\t\treturn '{}';\n\t}\n\treturn fieldType;\n}\n\nfunction getArgsType(config: ModulePrinterConfig, type: string, field: string) {\n\tconst hasArgs = config.fieldInfo.get(type)?.get(field)?.hasArguments ?? false;\n\tif (!hasArgs) {\n\t\treturn '{}';\n\t}\n\tconst fieldUpper = pascalCase(field);\n\treturn `Types.${type}${fieldUpper}Args`;\n}\n\nfunction printObjectTypeFieldBuilder(typeName: string, field: string) {\n\tif (typeName === 'Subscription') {\n\t\treturn `${field}: Baeta.createSubscriptionBuilder(\"${field}\", ${getExtensionsVar()})`;\n\t}\n\treturn `${field}: Baeta.createFieldBuilder(\"${typeName}\", \"${field}\", ${getExtensionsVar()})`;\n}\n\nfunction getContextType() {\n\treturn 'Ctx';\n}\n\nfunction getInfoType() {\n\treturn 'Info';\n}\n\nfunction getExtensionsVar() {\n\treturn 'extensions';\n}\n","import { makeRelativePathForImport } from './printer-utils.ts';\n\nexport function printTypesTemplate(options: {\n\timportExtension: '.js' | '.ts' | '';\n\ttypesDir: string;\n\tmodulesDir: string;\n}) {\n\tconst importDir = makeRelativePathForImport(options.modulesDir, options.typesDir);\n\n\treturn `import type { GraphQLResolveInfo } from 'graphql';\nimport type { BaseObjectTypes, BaseScalars } from '${importDir}/utility${options.importExtension}';\n\nexport interface Scalars extends BaseScalars {}\n\nexport interface ObjectTypes extends BaseObjectTypes {}\n\nexport type Ctx = {};\n\nexport type Info = GraphQLResolveInfo;\n`;\n}\n\nexport function printExtensionsTemplate() {\n\treturn `import { createExtensions } from '@baeta/core';\n\nexport default createExtensions({});\n`;\n}\n","import { type DefinitionsMap, isScalarType } from '@baeta/util-graphql';\nimport { pascalCase } from 'change-case-all';\nimport {\n\ttype EnumTypeDefinitionNode,\n\ttype FieldDefinitionNode,\n\ttype InputObjectTypeDefinitionNode,\n\ttype InputValueDefinitionNode,\n\ttype InterfaceTypeDefinitionNode,\n\tKind,\n\ttype ListTypeNode,\n\ttype NamedTypeNode,\n\ttype ObjectTypeDefinitionNode,\n\ttype TypeNode,\n\ttype UnionTypeDefinitionNode,\n} from 'graphql';\nimport { buildBlock, indent, makeRelativePathForImport } from './printer-utils.ts';\n\nexport interface PrinterConfig {\n\tglobalDefinitions: DefinitionsMap;\n\twithMaybe: boolean;\n\twithOptional: boolean;\n\tdefaultScalars: string[];\n\timportExtension: '.ts' | '.js' | '';\n\ttypesDir: string;\n\tmodulesDir: string;\n}\n\nexport function printUtilityTypes(): string {\n\treturn [\n\t\t'export type Or<A, B> = void extends A ? B : A;',\n\t\t'export type Maybe<T> = T | null;',\n\t].join('\\n\\n');\n}\n\nconst defaultScalarTypes: Record<string, string | undefined> = {\n\tID: 'string',\n\tString: 'string',\n\tBoolean: 'boolean',\n\tInt: 'number',\n\tFloat: 'number',\n};\n\nexport function printBaseScalars(config: PrinterConfig): string {\n\tconst defaultScalars = config.defaultScalars\n\t\t.map((scalar) => {\n\t\t\tconst type = defaultScalarTypes[scalar];\n\t\t\tif (type == null) return null;\n\t\t\treturn `${scalar}: ${type};`;\n\t\t})\n\t\t.filter((el) => el != null);\n\tconst customScalars = [...config.globalDefinitions.scalarTypeMap.values()].map(\n\t\t(scalar) => `${scalar.name.value}: unknown;`,\n\t);\n\n\treturn buildBlock({\n\t\tname: 'export type BaseScalars =',\n\t\tlines: [...defaultScalars, ...customScalars],\n\t});\n}\n\nexport function printBaseObjectTypes(config: PrinterConfig): string {\n\tconst objectTypes = [...config.globalDefinitions.objectTypeMap.values()].map((t) => t.name.value);\n\treturn buildBlock({\n\t\tname: 'export interface BaseObjectTypes',\n\t\tlines: objectTypes.map((t) => `${t}: unknown;`),\n\t});\n}\n\nexport function printTypesHeaders(config: PrinterConfig): string {\n\tconst overridesDir = makeRelativePathForImport(config.typesDir, config.modulesDir);\n\treturn [\n\t\t`import type * as BaetaUtility from \"./utility${config.importExtension}\";`,\n\t\t`import type * as BaetaOverrides from \"${overridesDir}/types${config.importExtension}\";`,\n\t\t'',\n\t\t'export type Scalars = BaetaOverrides.Scalars;',\n\t].join('\\n');\n}\n\nexport function printRootTypesFromMap(\n\tconfig: PrinterConfig,\n\trootTypes: string[],\n\tmap: Map<string, ObjectTypeDefinitionNode>,\n) {\n\treturn [...map.values()]\n\t\t.filter((type) => rootTypes.includes(type.name.value))\n\t\t.map((type) => printObjectType(config, type))\n\t\t.join('\\n\\n');\n}\n\nexport function printObjectTypeTypesFromMap(\n\tconfig: PrinterConfig,\n\tmap: Map<string, ObjectTypeDefinitionNode>,\n) {\n\treturn [...map.values()].map((type) => printObjectType(config, type));\n}\n\nfunction printObjectType(config: PrinterConfig, type: ObjectTypeDefinitionNode) {\n\tconst fields = type.fields?.map((field) => printObjectTypeField(config, field));\n\treturn `export type ${type.name.value} = ${printOrObjectType(type, fields)}`;\n}\n\nfunction printObjectTypeField(config: PrinterConfig, field: FieldDefinitionNode) {\n\tconst optionalMarker = printOptionalMarker(config, field.type);\n\treturn `${field.name.value}${optionalMarker}: ${printType(config, field.type)}`;\n}\n\nexport function printEnumTypesFromMap(map: Map<string, EnumTypeDefinitionNode>) {\n\treturn [...map.values()].map(printEnumType);\n}\n\nfunction printEnumType(type: EnumTypeDefinitionNode) {\n\tconst values = type.values?.map((value) => `'${value.name.value}'`);\n\treturn `export type ${type.name.value} = ${values?.join(' | ') || 'never'}`;\n}\n\nexport function printInterfaceTypesFromMap(\n\tconfig: PrinterConfig,\n\tmap: Map<string, InterfaceTypeDefinitionNode>,\n) {\n\treturn [...map.values()].map((type) => printInterfaceType(config, type));\n}\n\nfunction printInterfaceType(config: PrinterConfig, type: InterfaceTypeDefinitionNode) {\n\tconst objectTypes = Array.from(config.globalDefinitions.objectTypeMap.values());\n\tconst implementingTypes = objectTypes.filter((t) =>\n\t\tt.interfaces?.some((i) => i.name.value === type.name.value),\n\t);\n\tconst types = implementingTypes.map((t) => printNamedTypeForInterface(t.name.value));\n\treturn `export type ${type.name.value} = ${types.join(' | ') || 'never'}`;\n}\n\nfunction printNamedTypeForInterface(name: string) {\n\treturn `${name} & {__typename: \"${name}\"}`;\n}\n\nexport function printUnionTypesFromMap(\n\tconfig: PrinterConfig,\n\tmap: Map<string, UnionTypeDefinitionNode>,\n) {\n\treturn [...map.values()].map((type) => printUnionType(config, type));\n}\n\nfunction printUnionType(config: PrinterConfig, type: UnionTypeDefinitionNode) {\n\tconst types = type.types?.map((type) => printNamedTypeForUnion(config, type));\n\treturn `export type ${type.name.value} = ${types?.join(' | ') || 'never'}`;\n}\n\nfunction printNamedTypeForUnion(config: PrinterConfig, type: NamedTypeNode) {\n\treturn `${printNamedType(config, type, false)} & {__typename: \"${type.name.value}\"}`;\n}\n\nexport function printInputObjectTypeTypesFromMap(\n\tconfig: PrinterConfig,\n\tmap: Map<string, InputObjectTypeDefinitionNode>,\n) {\n\treturn [...map.values()].map((type) => printInputObjectType(config, type));\n}\n\nfunction printInputObjectType(config: PrinterConfig, type: InputObjectTypeDefinitionNode) {\n\tconst fields = type.fields?.map((field) => printInputObjectTypeField(config, field));\n\treturn buildBlock({\n\t\tname: `export type ${type.name.value} =`,\n\t\tlines: fields ?? [],\n\t});\n}\n\nfunction printInputObjectTypeField(config: PrinterConfig, field: InputValueDefinitionNode) {\n\tconst optionalMarker = printOptionalMarker(config, field.type);\n\treturn `${field.name.value}${optionalMarker}: ${printType(config, field.type)}`;\n}\n\nexport function printObjectTypeFieldsArgsFromMap(\n\tconfig: PrinterConfig,\n\tmap: Map<string, ObjectTypeDefinitionNode>,\n) {\n\treturn [...map.values()].flatMap((type) => printObjectTypeArgs(config, type));\n}\n\nfunction printObjectTypeArgs(config: PrinterConfig, type: ObjectTypeDefinitionNode) {\n\tif (type.fields == null) {\n\t\treturn [];\n\t}\n\treturn type.fields\n\t\t.map((field) => printObjectTypeFieldArgs(config, type.name.value, field))\n\t\t.filter(Boolean);\n}\n\nfunction printObjectTypeFieldArgs(\n\tconfig: PrinterConfig,\n\ttypeName: string,\n\tfield: FieldDefinitionNode,\n) {\n\tconst name = `${typeName + pascalCase(field.name.value)}Args`;\n\treturn buildBlock({\n\t\tname: `export type ${name} =`,\n\t\tlines: field.arguments?.map((arg) => printObjectTypeFieldArg(config, arg)) ?? [],\n\t});\n}\n\nfunction printObjectTypeFieldArg(config: PrinterConfig, arg: InputValueDefinitionNode) {\n\treturn `${arg.name.value}: ${printType(config, arg.type)}`;\n}\n\nfunction printType(config: PrinterConfig, type: TypeNode, nullable = true): string {\n\tswitch (type.kind) {\n\t\tcase Kind.NAMED_TYPE:\n\t\t\treturn printNamedType(config, type, nullable);\n\t\tcase Kind.LIST_TYPE:\n\t\t\treturn printListType(config, type, nullable);\n\t\tcase Kind.NON_NULL_TYPE:\n\t\t\treturn printType(config, type.type, false);\n\t\tdefault:\n\t\t\treturn type satisfies never;\n\t}\n}\n\nfunction printListType(config: PrinterConfig, type: ListTypeNode, nullable = true): string {\n\treturn printValue(config, `Array<${printType(config, type.type)}>`, nullable);\n}\n\nfunction printNamedType(config: PrinterConfig, type: NamedTypeNode, nullable = true): string {\n\tif (isScalarType(config.globalDefinitions, config.defaultScalars, type)) {\n\t\treturn printScalarType(config, type, nullable);\n\t}\n\treturn printValue(config, type.name.value, nullable);\n}\n\nfunction printScalarType(config: PrinterConfig, type: NamedTypeNode, nullable = true): string {\n\treturn printValue(config, `Scalars[\"${type.name.value}\"]`, nullable);\n}\n\nfunction printValue(config: PrinterConfig, value: string, nullable: boolean): string {\n\tif (!nullable) {\n\t\treturn value;\n\t}\n\tif (config.withMaybe) {\n\t\treturn `BaetaUtility.Maybe<${value}>`;\n\t}\n\treturn `${value} | null`;\n}\n\nfunction printOptionalMarker(config: PrinterConfig, type: TypeNode): string {\n\treturn config.withOptional && type.kind !== Kind.NON_NULL_TYPE ? '?' : '';\n}\n\nfunction printOrObjectType(type: ObjectTypeDefinitionNode, fields?: string[]): string {\n\treturn `BaetaUtility.Or<BaetaOverrides.ObjectTypes[\"${type.name.value}\"], {\\n${fields?.map(indent(2)).join('\\n') ?? ''}\\n}>`;\n}\n","import type { File, FileOptions, NormalizedGeneratorOptions } from '@baeta/generator-sdk';\nimport {\n\tcreateDefinitionsMapFromDocument,\n\tcreateDefinitionsMapFromSources,\n\tcreateModuleRegistry,\n\tgetSourcesFromSchema,\n\tgroupSourcesByModule,\n\tloadSchema,\n} from '@baeta/util-graphql';\nimport { join } from '@baeta/util-path';\nimport { concatAST } from 'graphql';\nimport { createFieldInfoMap } from './field-info.ts';\nimport { printAutoload } from './printer-autoload.ts';\nimport {\n\ttype ModulePrinterConfig,\n\tprintBaetaModuleTypes,\n\tprintModuleBuilder,\n\tprintModuleImports,\n\tprintModuleIndexStarter,\n\tprintModuleMetadata,\n\tprintModuleObjectTypeFields,\n} from './printer-module.ts';\nimport { printExtensionsTemplate, printTypesTemplate } from './printer-templates.ts';\nimport {\n\ttype PrinterConfig,\n\tprintBaseObjectTypes,\n\tprintBaseScalars,\n\tprintEnumTypesFromMap,\n\tprintInputObjectTypeTypesFromMap,\n\tprintInterfaceTypesFromMap,\n\tprintObjectTypeFieldsArgsFromMap,\n\tprintObjectTypeTypesFromMap,\n\tprintRootTypesFromMap,\n\tprintTypesHeaders,\n\tprintUnionTypesFromMap,\n\tprintUtilityTypes,\n} from './printer-types.ts';\n\ntype GeneratedFile = {\n\tfilename: string;\n\tcontent: string;\n\toptions?: FileOptions;\n};\n\nexport async function generate(\n\toptions: NormalizedGeneratorOptions,\n\tcurrentFiles: File[],\n): Promise<GeneratedFile[]> {\n\tconst { outputSchema, outputSchemaAst } = await loadSchema(\n\t\toptions.schemas,\n\t\toptions.cwd,\n\t\toptions.loaders,\n\t);\n\tconst sources = getSourcesFromSchema(outputSchemaAst);\n\tconst sourcesByModule = groupSourcesByModule(sources, options.modulesDir);\n\tconst modules = Array.from(sourcesByModule.keys());\n\tconst globalDefinitions = createDefinitionsMapFromDocument(outputSchema);\n\tconst modulesDefinitions = createDefinitionsMapFromSources(sources);\n\n\tconst defaultScalars = ['ID', 'Int', 'Float', 'String', 'Boolean'];\n\n\tconst config: PrinterConfig = {\n\t\tglobalDefinitions,\n\t\twithMaybe: false,\n\t\twithOptional: false,\n\t\tdefaultScalars,\n\t\timportExtension: options.importExtension,\n\t\ttypesDir: options.typesDir,\n\t\tmodulesDir: options.modulesDir,\n\t};\n\n\tconst fieldInfo = createFieldInfoMap(globalDefinitions, defaultScalars);\n\n\tconst typesContent = [\n\t\tprintTypesHeaders(config),\n\t\tprintRootTypesFromMap(\n\t\t\tconfig,\n\t\t\t['Query', 'Mutation', 'Subscription'],\n\t\t\tglobalDefinitions.objectTypeMap,\n\t\t),\n\t\t...printEnumTypesFromMap(globalDefinitions.enumTypeMap),\n\t\t...printObjectTypeTypesFromMap(config, modulesDefinitions.objectTypeMap),\n\t\t...printObjectTypeFieldsArgsFromMap(config, globalDefinitions.objectTypeMap),\n\t\t...printInputObjectTypeTypesFromMap(config, globalDefinitions.inputObjectTypeMap),\n\t\t...printInterfaceTypesFromMap(config, globalDefinitions.interfaceTypeMap),\n\t\t...printUnionTypesFromMap(config, globalDefinitions.unionTypeMap),\n\t].join('\\n\\n');\n\n\tconst utilityContent = [\n\t\tprintUtilityTypes(),\n\t\tprintBaseScalars(config),\n\t\tprintBaseObjectTypes(config),\n\t].join('\\n\\n');\n\n\tconst files: GeneratedFile[] = [\n\t\t{\n\t\t\tfilename: join(options.typesDir, 'types.ts'),\n\t\t\tcontent: typesContent,\n\t\t},\n\t\t{\n\t\t\tfilename: join(options.typesDir, 'utility.ts'),\n\t\t\tcontent: utilityContent,\n\t\t},\n\t\t{\n\t\t\tfilename: join(options.modulesDir, 'index.ts'),\n\t\t\tcontent: printAutoload(\n\t\t\t\t{\n\t\t\t\t\timportExtension: options.importExtension,\n\t\t\t\t\tmoduleDefinitionName: options.moduleDefinitionName,\n\t\t\t\t},\n\t\t\t\tmodules,\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tfilename: join(options.modulesDir, 'types.ts'),\n\t\t\tcontent: printTypesTemplate({\n\t\t\t\timportExtension: options.importExtension,\n\t\t\t\ttypesDir: options.typesDir,\n\t\t\t\tmodulesDir: options.modulesDir,\n\t\t\t}),\n\t\t\toptions: {\n\t\t\t\tdisableOverwrite: true,\n\t\t\t\tdisableBiomeV1Header: true,\n\t\t\t\tdisableBiomeV2Header: true,\n\t\t\t\tdisableEslintHeader: true,\n\t\t\t\tdisableGenerationNoticeHeader: true,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tfilename: join(options.modulesDir, 'extensions.ts'),\n\t\t\tcontent: printExtensionsTemplate(),\n\t\t\toptions: {\n\t\t\t\tdisableOverwrite: true,\n\t\t\t\tdisableBiomeV1Header: true,\n\t\t\t\tdisableBiomeV2Header: true,\n\t\t\t\tdisableEslintHeader: true,\n\t\t\t\tdisableGenerationNoticeHeader: true,\n\t\t\t},\n\t\t},\n\t];\n\n\tfor (const module of modules) {\n\t\tconst sources = sourcesByModule.get(module);\n\t\tconst documents = sources?.map((s) => s.document).filter((el) => el != null) ?? [];\n\t\tif (documents.length === 0) continue;\n\t\tconst document = concatAST(documents);\n\t\tconst config: ModulePrinterConfig = {\n\t\t\ttypesDir: options.typesDir,\n\t\t\tfieldInfo,\n\t\t\timportExtension: options.importExtension,\n\t\t\tmodulesDir: options.modulesDir,\n\t\t\tregistry: createModuleRegistry(document),\n\t\t\tmoduleDefinitionName: options.moduleDefinitionName,\n\t\t};\n\t\tfiles.push({\n\t\t\tfilename: join(options.modulesDir, `/${module}/${options.moduleDefinitionName}.ts`),\n\t\t\tcontent: [\n\t\t\t\tprintModuleImports(config, module),\n\t\t\t\tprintModuleMetadata(module, document),\n\t\t\t\tprintBaetaModuleTypes(config),\n\t\t\t\tprintModuleObjectTypeFields(config),\n\t\t\t\tprintModuleBuilder(config, module),\n\t\t\t].join('\\n\\n'),\n\t\t});\n\n\t\tconst moduleStarterPath = join(options.modulesDir, `/${module}/index.ts`);\n\t\tconst moduleStarterExists = currentFiles.some((file) => file.filename === moduleStarterPath);\n\t\tif (!moduleStarterExists) {\n\t\t\tfiles.push({\n\t\t\t\tfilename: join(options.modulesDir, `/${module}/index.ts`),\n\t\t\t\tcontent: printModuleIndexStarter(config, module),\n\t\t\t\toptions: {\n\t\t\t\t\tdisableOverwrite: true,\n\t\t\t\t\tdisableBiomeV1Header: true,\n\t\t\t\t\tdisableBiomeV2Header: true,\n\t\t\t\t\tdisableEslintHeader: true,\n\t\t\t\t\tdisableGenerationNoticeHeader: true,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\n\treturn files;\n}\n","import { createPluginV1, isMatch, type WatcherFile } 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\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, ctx.fileManager.files);\n\t\t\tfor (const item of items) {\n\t\t\t\tctx.fileManager.createAndAdd(item.filename, item.content, 'graphql', item.options);\n\t\t\t}\n\t\t\treturn next();\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;AAKA,SAAgB,mBAAmB,gBAAgC,gBAA0B;CAC5F,MAAM,sBAAoB,IAAI,KAAK;AACnC,MAAK,MAAM,cAAc,eAAe,cAAc,QAAQ,EAAE;EAC/D,MAAM,aAAa,WAAW,KAAK;AACnC,OAAK,MAAM,SAAS,WAAW,UAAU,EAAE,EAAE;GAC5C,MAAM,YAAY,MAAM,KAAK;GAC7B,MAAM,OAAOA,iBAAe,gBAAgB,gBAAgB,MAAM,KAAK;GACvE,MAAM,eAAe,MAAM,aAAa,QAAQ,MA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qBAAqB,KAAK;GACnF,SAAS;IACR,mBAAmB,QAAQ,OAAO;IAClC,oBAAoB,QAAQ,SAAS;IACrC,sBAAsB,OAAO;IAC7B,4BAA4B,OAAO;IACnC,mBAAmB,QAAQ,OAAO;IAClC,CAAC,KAAK,OAAO;GACd,CAAC;EAEF,MAAM,oBAAoB,KAAK,QAAQ,YAAY,IAAI,OAAO,WAAW;AAEzE,MAAI,CADwB,aAAa,MAAM,SAAS,KAAK,aAAa,kBAClD,CACvB,OAAM,KAAK;GACV,UAAU,KAAK,QAAQ,YAAY,IAAI,OAAO,WAAW;GACzD,SAAS,wBAAwB,QAAQ,OAAO;GAChD,SAAS;IACR,kBAAkB;IAClB,sBAAsB;IACtB,sBAAsB;IACtB,qBAAqB;IACrB,+BAA+B;IAC/B;GACD,CAAC;;AAIJ,QAAO;;;;ACnLR,SAAgB,gBAAgB;AAC/B,QAAO,eAAe;EACrB,MAAM;EACN,YAAY;EACZ,QAAQ,SAAS,SAAS,WAAW;GACpC,MAAM,gBAAgB,SAAsB;AAC3C,QAAI,QAAQ,KAAK,cAAc,QAAQ,QAAQ,CAC9C,QAAO,KAAK;;AAGd,WAAQ,GAAG,UAAU,aAAa;AAClC,WAAQ,GAAG,UAAU,aAAa;;EAEnC,UAAU,OAAO,KAAK,SAAS;GAC9B,MAAM,QAAQ,MAAM,SAAS,IAAI,kBAAkB,IAAI,YAAY,MAAM;AACzE,QAAK,MAAM,QAAQ,MAClB,KAAI,YAAY,aAAa,KAAK,UAAU,KAAK,SAAS,WAAW,KAAK,QAAQ;AAEnF,UAAO,MAAM;;EAEd,CAAC"}
1
+ {"version":3,"file":"index.js","names":["printNamedType"],"sources":["../lib/namespace.ts","../lib/field-info.ts","../lib/printer-autoload.ts","../lib/printer-utils.ts","../lib/printer-module.ts","../lib/printer-templates.ts","../lib/printer-types.ts","../lib/codegen.ts","../index.ts"],"sourcesContent":["export const namespace = {\n\tsdk: 'BaetaSdk',\n\tgraphql: 'BaetaGraphql',\n\tglobalTypes: 'BaetaTypes',\n\tuserTypes: 'BaetaUserTypes',\n};\n","import { type DefinitionsMap, isScalarType } from '@baeta/util-graphql';\nimport { Kind, type TypeNode } from 'graphql';\nimport { namespace } from './namespace.ts';\n\nexport type FieldInfoMap = Map<string, Map<string, { type: string; hasArguments: boolean }>>;\n\nexport function createFieldInfoMap(definitionsMap: DefinitionsMap, defaultScalars: string[]) {\n\tconst map: FieldInfoMap = new Map();\n\tfor (const objectType of definitionsMap.objectTypeMap.values()) {\n\t\tconst objectName = objectType.name.value;\n\t\tfor (const field of objectType.fields ?? []) {\n\t\t\tconst fieldName = field.name.value;\n\t\t\tconst type = printNamedType(definitionsMap, defaultScalars, field.type);\n\t\t\tconst hasArguments = field.arguments != null && field.arguments.length > 0;\n\t\t\tconst fieldMap = map.get(objectName) ?? new Map();\n\t\t\tfieldMap.set(fieldName, { type, hasArguments });\n\t\t\tmap.set(objectName, fieldMap);\n\t\t}\n\t}\n\treturn map;\n}\n\nfunction printNamedType(\n\tdefinitionsMap: DefinitionsMap,\n\tdefaultScalars: string[],\n\ttype: TypeNode,\n\tnullable = true,\n): string {\n\tconst withNullable = nullable ? ' | null' : '';\n\tswitch (type.kind) {\n\t\tcase Kind.NAMED_TYPE:\n\t\t\tif (isScalarType(definitionsMap, defaultScalars, type)) {\n\t\t\t\treturn `${namespace.globalTypes}.Scalars[\"${type.name.value}\"]${withNullable}`;\n\t\t\t}\n\t\t\treturn `${namespace.globalTypes}.${type.name.value}${withNullable}`;\n\t\tcase Kind.LIST_TYPE:\n\t\t\treturn `Array<${printNamedType(definitionsMap, defaultScalars, type.type)}>${withNullable}`;\n\t\tcase Kind.NON_NULL_TYPE:\n\t\t\treturn printNamedType(definitionsMap, defaultScalars, type.type, false);\n\t\tdefault:\n\t\t\treturn type satisfies never;\n\t}\n}\n","import { camelCase, pascalCase } from 'change-case';\n\ninterface AutoloadPrinterConfig {\n\tmoduleDefinitionName: string;\n\timportExtension: '.ts' | '.js' | '';\n}\n\nexport function printAutoload(config: AutoloadPrinterConfig, modules: string[]) {\n\treturn [printImports(config, modules), printExport(modules)].join('\\n\\n');\n}\n\nfunction printImports(config: AutoloadPrinterConfig, modules: string[]) {\n\tconst dependencyImports = [\n\t\t'import type { ModuleCompilerFactory } from \"@baeta/core/sdk\";',\n\t\t`import type { Ctx, Info } from \"./types${config.importExtension}\"`,\n\t];\n\tconst moduleTypeImports = modules.map(\n\t\t(module) =>\n\t\t\t`import type { BaetaModuleTypes as ${pascalCase(module)}ModuleTypes } from \"./${module}/${config.moduleDefinitionName}${config.importExtension}\"`,\n\t);\n\tconst moduleImports = modules.flatMap(\n\t\t(module) => `import ${camelCase(module)} from \"./${module}/index${config.importExtension}\"`,\n\t);\n\treturn [...dependencyImports, ...moduleTypeImports, ...moduleImports].join('\\n');\n}\n\nfunction printExport(modules: string[]) {\n\treturn `export default [\\n${modules.map(printModuleWithSatisfies).join(',\\n')}\\n];`;\n}\n\nfunction printModuleWithSatisfies(module: string) {\n\treturn ` ${camelCase(module)} satisfies ModuleCompilerFactory<Ctx, Info, ${pascalCase(module)}ModuleTypes[\"Factories\"]>`;\n}\n","import { posixPath, relative } from '@baeta/util-path';\n\nexport function buildBlock({ name, lines }: { name: string; lines: string[] }): string {\n\treturn [`${name} {`, ...lines.filter(Boolean).map(indent(2)), '};'].join('\\n');\n}\n\nexport function buildCodeBlock({ name, lines }: { name: string; lines: string[] }) {\n\tif (lines.length === 0) {\n\t\treturn `${name} {}`;\n\t}\n\tconst linesWithSep = lines.filter(Boolean).map(indent(2)).join(',\\n');\n\treturn [`${name} {`, linesWithSep, '}'].join('\\n');\n}\n\nexport function indent(size: number) {\n\tconst space = new Array(size).fill(' ').join('');\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\treturn indentInner;\n}\n\nexport function unique<T>(val: T, i: number, all: T[]): boolean {\n\treturn i === all.indexOf(val);\n}\n\nexport function makeRelativePathForImport(from: string, to: string) {\n\tconst res = posixPath(relative(from, to));\n\tif (res.startsWith('.') || res.startsWith('/')) {\n\t\treturn res;\n\t}\n\treturn `./${res}`;\n}\n","import type { ModuleRegistry } from '@baeta/util-graphql';\nimport { join } from '@baeta/util-path';\nimport { pascalCase } from 'change-case';\nimport type { DocumentNode } from 'graphql';\nimport type { FieldInfoMap } from './field-info.ts';\nimport { namespace } from './namespace.ts';\nimport { buildBlock, buildCodeBlock, indent, makeRelativePathForImport } from './printer-utils.ts';\n\nexport interface ModulePrinterConfig {\n\tregistry: ModuleRegistry;\n\tfieldInfo: FieldInfoMap;\n\ttypesDir: string;\n\tmodulesDir: string;\n\tmoduleDefinitionName: string;\n\timportExtension: '.ts' | '.js' | '';\n}\n\nexport function printModuleIndexStarter(config: ModulePrinterConfig, moduleName: string): string {\n\tconst typeEntries = Object.entries(config.registry.picks.objects);\n\tconst types = typeEntries.map(([typeName]) => typeName);\n\n\treturn [\n\t\tprintModuleIndexImports(config, moduleName),\n\t\tprintModuleIndexDestructuredTypes(moduleName, types),\n\t\t...typeEntries.map(([typeName, fields]) => printModuleIndexType(typeName, fields)),\n\t\tprintModuleIndexSchema(moduleName, types, config.registry.defined.scalars),\n\t]\n\t\t.filter((el) => el != null)\n\t\t.join('\\n\\n');\n}\n\nexport function printModuleImports(config: ModulePrinterConfig, moduleName: string) {\n\tconst typesDir = makeRelativePathForImport(join(config.modulesDir, moduleName), config.typesDir);\n\tconst hasTypes = config.registry.defined.objects.length > 0;\n\treturn [\n\t\t`import * as ${namespace.sdk} from \"@baeta/core/sdk\";`,\n\t\t`import type * as ${namespace.graphql} from \"graphql\";`,\n\t\thasTypes\n\t\t\t? `import type * as ${namespace.globalTypes} from \"${typesDir}/types${config.importExtension}\";`\n\t\t\t: null,\n\t\t`import type * as ${namespace.userTypes} from \"../types${config.importExtension}\";`,\n\t]\n\t\t.filter((el) => el != null)\n\t\t.join('\\n');\n}\n\nexport function printModuleMetadata(name: string, doc: DocumentNode) {\n\treturn buildCodeBlock({\n\t\tname: 'const moduleMetadata =',\n\t\tlines: [\n\t\t\t`id: '${name}'`,\n\t\t\t`typedef: ${JSON.stringify(doc)} as unknown as ${namespace.graphql}.DocumentNode`,\n\t\t],\n\t});\n}\n\nexport function printBaetaModuleTypes(config: ModulePrinterConfig) {\n\treturn buildBlock({\n\t\tname: 'export interface BaetaModuleTypes',\n\t\tlines: [\n\t\t\tbuildBlock({\n\t\t\t\tname: 'Builders:',\n\t\t\t\tlines: printBaetaModuleTypesForFields(config, false),\n\t\t\t}),\n\t\t\tbuildBlock({\n\t\t\t\tname: 'Factories:',\n\t\t\t\tlines: [\n\t\t\t\t\t...printBaetaModuleTypesForFields(config, true),\n\t\t\t\t\t...printBaetaModuleTypesScalars(config),\n\t\t\t\t],\n\t\t\t}),\n\t\t],\n\t});\n}\n\nfunction printModuleIndexDestructuredTypes(moduleName: string, types: string[]) {\n\treturn `const { ${types.join(', ')} } = ${pascalCase(moduleName)}Module;`;\n}\n\nfunction printModuleIndexImports(config: ModulePrinterConfig, moduleName: string) {\n\tconst hasScalars = config.registry.defined.scalars.length > 0;\n\tconst moduleImport = `import { ${pascalCase(moduleName)}Module } from \"./${config.moduleDefinitionName}${config.importExtension}\";`;\n\tif (!hasScalars) {\n\t\treturn moduleImport;\n\t}\n\treturn [`import { GraphQLScalarType } from \"graphql\";`, moduleImport].join('\\n');\n}\n\nfunction printModuleIndexSchema(moduleName: string, types: string[], scalars: string[]) {\n\tconst printedTypes = [\n\t\t...types.map((typeName) => `${typeName}: ${typeName}Resolver,`),\n\t\t...scalars.map(\n\t\t\t(scalarName) => `${scalarName}: new GraphQLScalarType({ name: '${scalarName}' }),`,\n\t\t),\n\t]\n\t\t.map(indent(2))\n\t\t.join('\\n');\n\n\treturn `export default ${pascalCase(moduleName)}Module.$schema({\n${printedTypes}\n});`;\n}\n\nfunction printModuleIndexType(typeName: string, fields: string[]) {\n\tconst printedFields = fields\n\t\t.map((fieldName) => printModuleIndexTypeField(typeName, fieldName))\n\t\t.map(indent(2))\n\t\t.join('\\n');\n\n\treturn `const ${typeName}Resolver = ${typeName}.$fields({\n${printedFields}\n});`;\n}\n\nfunction printModuleIndexTypeField(typeName: string, fieldName: string) {\n\tif (typeName === 'Query' || typeName === 'Mutation') {\n\t\treturn `${fieldName}: ${typeName}.${fieldName}.resolve((params) => {\n // Implement resolver logic here\n}),`;\n\t}\n\n\tif (typeName === 'Subscription') {\n\t\treturn `${fieldName}: ${typeName}.${fieldName}\n .subscribe((params) => {\n // Implement subscribe logic here\n })\n .resolve((params) => {\n // Implement resolver logic here\n }),`;\n\t}\n\n\treturn `${fieldName}: ${typeName}.${fieldName}.key('${fieldName}'),`;\n}\n\nfunction printBaetaModuleTypesForFields(config: ModulePrinterConfig, isFactory: boolean) {\n\treturn config.registry.defined.objects\n\t\t.map((typeName) =>\n\t\t\tprintObjectTypeModuleType(typeName, config.registry.picks.objects, isFactory),\n\t\t)\n\t\t.filter(Boolean);\n}\n\nfunction printObjectTypeModuleType(\n\ttypeName: string,\n\tobjects: Record<string, string[] | undefined>,\n\tisFactory: boolean,\n) {\n\tconst object = objects[typeName];\n\tif (!object) {\n\t\treturn '';\n\t}\n\tconst parentType = getParentType(typeName);\n\tconst contextType = getContextType();\n\tconst infoType = getInfoType();\n\tif (isFactory) {\n\t\treturn `${typeName}: ${namespace.sdk}.TypeCompilerFactory<${parentType}, ${contextType}, ${infoType}, BaetaModuleObjectTypeFields['${typeName}']['Factory']>`;\n\t}\n\treturn `${typeName}: ${namespace.sdk}.TypeMethods<${parentType}, ${contextType}, ${infoType}, BaetaModuleObjectTypeFields['${typeName}']['Builder'], BaetaModuleObjectTypeFields['${typeName}']['Factory']>`;\n}\n\nfunction printBaetaModuleTypesScalars(config: ModulePrinterConfig) {\n\treturn config.registry.defined.scalars.map(\n\t\t(scalar) => `${scalar}: ${namespace.graphql}.GraphQLScalarType`,\n\t);\n}\n\nexport function printModuleObjectTypeFields(config: ModulePrinterConfig) {\n\tconst objects = config.registry.defined.objects\n\t\t.map((typeName) => printObjectTypeFields(config, typeName, config.registry.picks.objects))\n\t\t.filter(Boolean);\n\tif (objects.length === 0) {\n\t\treturn '';\n\t}\n\treturn buildBlock({\n\t\tname: 'interface BaetaModuleObjectTypeFields',\n\t\tlines: objects,\n\t});\n}\n\nfunction printObjectTypeFields(\n\tconfig: ModulePrinterConfig,\n\ttypeName: string,\n\tobjects: Record<string, string[] | undefined>,\n) {\n\tconst fields = objects[typeName];\n\tif (!fields || fields.length === 0) {\n\t\treturn '';\n\t}\n\tconst fieldsBuilders = fields.map((field) =>\n\t\tprintObjectTypeFieldBuilders(config, typeName, field),\n\t);\n\tconst fieldsFactories = fields.map((field) =>\n\t\tprintObjectTypeFieldFactories(config, typeName, field),\n\t);\n\treturn buildBlock({\n\t\tname: `${typeName}:`,\n\t\tlines: [\n\t\t\tbuildBlock({\n\t\t\t\tname: 'Builder:',\n\t\t\t\tlines: fieldsBuilders,\n\t\t\t}),\n\t\t\tbuildBlock({\n\t\t\t\tname: 'Factory:',\n\t\t\t\tlines: fieldsFactories,\n\t\t\t}),\n\t\t],\n\t});\n}\n\nfunction printObjectTypeFieldBuilders(\n\tconfig: ModulePrinterConfig,\n\ttypeName: string,\n\tfield: string,\n) {\n\tconst parentType = getParentType(typeName);\n\tconst resultType = getResultType(config, typeName, field);\n\tconst argumentsType = getArgsType(config, typeName, field);\n\tconst contextType = getContextType();\n\tconst infoType = getInfoType();\n\tconst fieldType = typeName === 'Subscription' ? 'SubscriptionMethods' : 'FieldMethods';\n\treturn `${field}: ${namespace.sdk}.${fieldType}<${resultType}, ${parentType}, ${contextType}, ${argumentsType}, ${infoType}>`;\n}\n\nfunction printObjectTypeFieldFactories(\n\tconfig: ModulePrinterConfig,\n\ttypeName: string,\n\tfield: string,\n) {\n\tconst parentType = getParentType(typeName);\n\tconst resultType = getResultType(config, typeName, field);\n\tconst argumentsType = getArgsType(config, typeName, field);\n\tconst contextType = getContextType();\n\tconst infoType = getInfoType();\n\tconst fieldType = typeName === 'Subscription' ? 'SubscriptionField' : 'Field';\n\treturn `${field}: ${namespace.sdk}.${fieldType}<${resultType}, ${resultType}, ${parentType}, ${contextType}, ${argumentsType}, ${infoType}>`;\n}\n\nexport function printModuleBuilder(config: ModulePrinterConfig, moduleName: string) {\n\tconst objectTypes = config.registry.defined.objects\n\t\t.map((typeName) => printObjectTypeBuilder(typeName, config.registry.picks.objects))\n\t\t.filter(Boolean);\n\tconst builders = buildCodeBlock({\n\t\tname: '',\n\t\tlines: objectTypes,\n\t});\n\tconst typeNameResolvers = buildCodeBlock({\n\t\tname: '',\n\t\tlines: [...config.registry.defined.unions, ...config.registry.defined.interfaces].map(\n\t\t\t(name) => `${name}: ${printTypeNameResolver()}`,\n\t\t),\n\t});\n\tconst infoType = getInfoType();\n\tconst contextType = getContextType();\n\treturn [\n\t\t`export const ${pascalCase(moduleName)}Module = ${namespace.sdk}.createModuleBuilder<${contextType}, ${infoType}, BaetaModuleTypes['Builders'], BaetaModuleTypes['Factories']>(moduleMetadata.id, moduleMetadata.typedef,`,\n\t\tbuilders,\n\t\t',',\n\t\ttypeNameResolvers,\n\t\t`);`,\n\t].join('');\n}\n\nfunction printObjectTypeBuilder(typeName: string, objects: Record<string, string[] | undefined>) {\n\tconst fields = objects[typeName]?.map((field) => printObjectTypeFieldBuilder(typeName, field));\n\tif (fields == null || fields.length === 0) {\n\t\treturn '';\n\t}\n\tconst content = buildCodeBlock({\n\t\tname: '',\n\t\tlines: fields,\n\t});\n\treturn `${typeName}: ${namespace.sdk}.createTypeBuilder(\"${typeName}\",${content})`;\n}\n\nfunction printTypeNameResolver() {\n\treturn '{ __resolveType: (source: {__typename: string}) => { return source.__typename; }}';\n}\n\nfunction getParentType(type: string) {\n\tif (['Query', 'Mutation', 'Subscription'].includes(type)) {\n\t\treturn '{}';\n\t}\n\treturn `${namespace.globalTypes}.${type}`;\n}\n\nfunction getResultType(config: ModulePrinterConfig, type: string, field: string) {\n\tconst fieldType = config.fieldInfo.get(type)?.get(field)?.type;\n\tif (fieldType == null) {\n\t\treturn '{}';\n\t}\n\treturn fieldType;\n}\n\nfunction getArgsType(config: ModulePrinterConfig, type: string, field: string) {\n\tconst hasArgs = config.fieldInfo.get(type)?.get(field)?.hasArguments ?? false;\n\tif (!hasArgs) {\n\t\treturn '{}';\n\t}\n\tconst fieldUpper = pascalCase(field);\n\treturn `${namespace.globalTypes}.${type}${fieldUpper}Args`;\n}\n\nfunction printObjectTypeFieldBuilder(typeName: string, field: string) {\n\tif (typeName === 'Subscription') {\n\t\treturn `${field}: ${namespace.sdk}.createSubscriptionBuilder(\"${field}\")`;\n\t}\n\treturn `${field}: ${namespace.sdk}.createFieldBuilder(\"${typeName}\", \"${field}\")`;\n}\n\nfunction getContextType() {\n\treturn `${namespace.userTypes}.Ctx`;\n}\n\nfunction getInfoType() {\n\treturn `${namespace.userTypes}.Info`;\n}\n","import { makeRelativePathForImport } from './printer-utils.ts';\n\nexport function printTypesTemplate(options: {\n\timportExtension: '.js' | '.ts' | '';\n\ttypesDir: string;\n\tmodulesDir: string;\n}) {\n\tconst importDir = makeRelativePathForImport(options.modulesDir, options.typesDir);\n\n\treturn `import type { GraphQLResolveInfo } from 'graphql';\nimport type { BaseObjectTypes, BaseScalars } from '${importDir}/utility${options.importExtension}';\n\nexport interface Scalars extends BaseScalars {}\n\nexport interface ObjectTypes extends BaseObjectTypes {}\n\nexport type Ctx = {};\n\nexport type Info = GraphQLResolveInfo;\n`;\n}\n","import { type DefinitionsMap, isScalarType } from '@baeta/util-graphql';\nimport { pascalCase } from 'change-case';\nimport {\n\ttype EnumTypeDefinitionNode,\n\ttype FieldDefinitionNode,\n\ttype InputObjectTypeDefinitionNode,\n\ttype InputValueDefinitionNode,\n\ttype InterfaceTypeDefinitionNode,\n\tKind,\n\ttype ListTypeNode,\n\ttype NamedTypeNode,\n\ttype ObjectTypeDefinitionNode,\n\ttype TypeNode,\n\ttype UnionTypeDefinitionNode,\n} from 'graphql';\nimport { buildBlock, indent, makeRelativePathForImport } from './printer-utils.ts';\n\nexport interface PrinterConfig {\n\tglobalDefinitions: DefinitionsMap;\n\twithMaybe: boolean;\n\twithOptional: boolean;\n\tdefaultScalars: string[];\n\timportExtension: '.ts' | '.js' | '';\n\ttypesDir: string;\n\tmodulesDir: string;\n}\n\nexport function printUtilityTypes(): string {\n\treturn [\n\t\t'export type Or<A, B> = void extends A ? B : A;',\n\t\t'export type Maybe<T> = T | null;',\n\t].join('\\n\\n');\n}\n\nconst defaultScalarTypes: Record<string, string | undefined> = {\n\tID: 'string',\n\tString: 'string',\n\tBoolean: 'boolean',\n\tInt: 'number',\n\tFloat: 'number',\n};\n\nexport function printBaseScalars(config: PrinterConfig): string {\n\tconst defaultScalars = config.defaultScalars\n\t\t.map((scalar) => {\n\t\t\tconst type = defaultScalarTypes[scalar];\n\t\t\tif (type == null) return null;\n\t\t\treturn `${scalar}: ${type};`;\n\t\t})\n\t\t.filter((el) => el != null);\n\tconst customScalars = [...config.globalDefinitions.scalarTypeMap.values()].map(\n\t\t(scalar) => `${scalar.name.value}: unknown;`,\n\t);\n\n\treturn buildBlock({\n\t\tname: 'export type BaseScalars =',\n\t\tlines: [...defaultScalars, ...customScalars],\n\t});\n}\n\nexport function printBaseObjectTypes(config: PrinterConfig): string {\n\tconst objectTypes = [...config.globalDefinitions.objectTypeMap.values()].map((t) => t.name.value);\n\treturn buildBlock({\n\t\tname: 'export interface BaseObjectTypes',\n\t\tlines: objectTypes.map((t) => `${t}: unknown;`),\n\t});\n}\n\nexport function printTypesHeaders(config: PrinterConfig): string {\n\tconst overridesDir = makeRelativePathForImport(config.typesDir, config.modulesDir);\n\treturn [\n\t\t`import type * as BaetaUtility from \"./utility${config.importExtension}\";`,\n\t\t`import type * as BaetaOverrides from \"${overridesDir}/types${config.importExtension}\";`,\n\t\t'',\n\t\t'export type Scalars = BaetaOverrides.Scalars;',\n\t].join('\\n');\n}\n\nexport function printRootTypesFromMap(\n\tconfig: PrinterConfig,\n\trootTypes: string[],\n\tmap: Map<string, ObjectTypeDefinitionNode>,\n) {\n\treturn [...map.values()]\n\t\t.filter((type) => rootTypes.includes(type.name.value))\n\t\t.map((type) => printObjectType(config, type))\n\t\t.join('\\n\\n');\n}\n\nexport function printObjectTypeTypesFromMap(\n\tconfig: PrinterConfig,\n\tmap: Map<string, ObjectTypeDefinitionNode>,\n) {\n\treturn [...map.values()].map((type) => printObjectType(config, type));\n}\n\nfunction printObjectType(config: PrinterConfig, type: ObjectTypeDefinitionNode) {\n\tconst fields = type.fields?.map((field) => printObjectTypeField(config, field));\n\treturn `export type ${type.name.value} = ${printOrObjectType(type, fields)}`;\n}\n\nfunction printObjectTypeField(config: PrinterConfig, field: FieldDefinitionNode) {\n\tconst optionalMarker = printOptionalMarker(config, field.type);\n\treturn `${field.name.value}${optionalMarker}: ${printType(config, field.type)}`;\n}\n\nexport function printEnumTypesFromMap(map: Map<string, EnumTypeDefinitionNode>) {\n\treturn [...map.values()].map(printEnumType);\n}\n\nfunction printEnumType(type: EnumTypeDefinitionNode) {\n\tconst values = type.values?.map((value) => `'${value.name.value}'`);\n\treturn `export type ${type.name.value} = ${values?.join(' | ') || 'never'}`;\n}\n\nexport function printInterfaceTypesFromMap(\n\tconfig: PrinterConfig,\n\tmap: Map<string, InterfaceTypeDefinitionNode>,\n) {\n\treturn [...map.values()].map((type) => printInterfaceType(config, type));\n}\n\nfunction printInterfaceType(config: PrinterConfig, type: InterfaceTypeDefinitionNode) {\n\tconst objectTypes = Array.from(config.globalDefinitions.objectTypeMap.values());\n\tconst implementingTypes = objectTypes.filter((t) =>\n\t\tt.interfaces?.some((i) => i.name.value === type.name.value),\n\t);\n\tconst types = implementingTypes.map((t) => printNamedTypeForInterface(t.name.value));\n\treturn `export type ${type.name.value} = ${types.join(' | ') || 'never'}`;\n}\n\nfunction printNamedTypeForInterface(name: string) {\n\treturn `${name} & {__typename: \"${name}\"}`;\n}\n\nexport function printUnionTypesFromMap(\n\tconfig: PrinterConfig,\n\tmap: Map<string, UnionTypeDefinitionNode>,\n) {\n\treturn [...map.values()].map((type) => printUnionType(config, type));\n}\n\nfunction printUnionType(config: PrinterConfig, type: UnionTypeDefinitionNode) {\n\tconst types = type.types?.map((type) => printNamedTypeForUnion(config, type));\n\treturn `export type ${type.name.value} = ${types?.join(' | ') || 'never'}`;\n}\n\nfunction printNamedTypeForUnion(config: PrinterConfig, type: NamedTypeNode) {\n\treturn `${printNamedType(config, type, false)} & {__typename: \"${type.name.value}\"}`;\n}\n\nexport function printInputObjectTypeTypesFromMap(\n\tconfig: PrinterConfig,\n\tmap: Map<string, InputObjectTypeDefinitionNode>,\n) {\n\treturn [...map.values()].map((type) => printInputObjectType(config, type));\n}\n\nfunction printInputObjectType(config: PrinterConfig, type: InputObjectTypeDefinitionNode) {\n\tconst fields = type.fields?.map((field) => printInputObjectTypeField(config, field));\n\treturn buildBlock({\n\t\tname: `export type ${type.name.value} =`,\n\t\tlines: fields ?? [],\n\t});\n}\n\nfunction printInputObjectTypeField(config: PrinterConfig, field: InputValueDefinitionNode) {\n\tconst optionalMarker = printOptionalMarker(config, field.type);\n\treturn `${field.name.value}${optionalMarker}: ${printType(config, field.type)}`;\n}\n\nexport function printObjectTypeFieldsArgsFromMap(\n\tconfig: PrinterConfig,\n\tmap: Map<string, ObjectTypeDefinitionNode>,\n) {\n\treturn [...map.values()].flatMap((type) => printObjectTypeArgs(config, type));\n}\n\nfunction printObjectTypeArgs(config: PrinterConfig, type: ObjectTypeDefinitionNode) {\n\tif (type.fields == null) {\n\t\treturn [];\n\t}\n\treturn type.fields\n\t\t.map((field) => printObjectTypeFieldArgs(config, type.name.value, field))\n\t\t.filter(Boolean);\n}\n\nfunction printObjectTypeFieldArgs(\n\tconfig: PrinterConfig,\n\ttypeName: string,\n\tfield: FieldDefinitionNode,\n) {\n\tconst name = `${typeName + pascalCase(field.name.value)}Args`;\n\treturn buildBlock({\n\t\tname: `export type ${name} =`,\n\t\tlines: field.arguments?.map((arg) => printObjectTypeFieldArg(config, arg)) ?? [],\n\t});\n}\n\nfunction printObjectTypeFieldArg(config: PrinterConfig, arg: InputValueDefinitionNode) {\n\treturn `${arg.name.value}: ${printType(config, arg.type)}`;\n}\n\nfunction printType(config: PrinterConfig, type: TypeNode, nullable = true): string {\n\tswitch (type.kind) {\n\t\tcase Kind.NAMED_TYPE:\n\t\t\treturn printNamedType(config, type, nullable);\n\t\tcase Kind.LIST_TYPE:\n\t\t\treturn printListType(config, type, nullable);\n\t\tcase Kind.NON_NULL_TYPE:\n\t\t\treturn printType(config, type.type, false);\n\t\tdefault:\n\t\t\treturn type satisfies never;\n\t}\n}\n\nfunction printListType(config: PrinterConfig, type: ListTypeNode, nullable = true): string {\n\treturn printValue(config, `Array<${printType(config, type.type)}>`, nullable);\n}\n\nfunction printNamedType(config: PrinterConfig, type: NamedTypeNode, nullable = true): string {\n\tif (isScalarType(config.globalDefinitions, config.defaultScalars, type)) {\n\t\treturn printScalarType(config, type, nullable);\n\t}\n\treturn printValue(config, type.name.value, nullable);\n}\n\nfunction printScalarType(config: PrinterConfig, type: NamedTypeNode, nullable = true): string {\n\treturn printValue(config, `Scalars[\"${type.name.value}\"]`, nullable);\n}\n\nfunction printValue(config: PrinterConfig, value: string, nullable: boolean): string {\n\tif (!nullable) {\n\t\treturn value;\n\t}\n\tif (config.withMaybe) {\n\t\treturn `BaetaUtility.Maybe<${value}>`;\n\t}\n\treturn `${value} | null`;\n}\n\nfunction printOptionalMarker(config: PrinterConfig, type: TypeNode) {\n\treturn config.withOptional && type.kind !== Kind.NON_NULL_TYPE ? '?' : '';\n}\n\nfunction printOrObjectType(type: ObjectTypeDefinitionNode, fields?: string[]): string {\n\treturn `BaetaUtility.Or<BaetaOverrides.ObjectTypes[\"${type.name.value}\"], {\\n${fields?.map(indent(2)).join('\\n') ?? ''}\\n}>`;\n}\n","import type { File, FileOptions, NormalizedGeneratorOptions } from '@baeta/generator-sdk';\nimport {\n\tcreateDefinitionsMapFromDocument,\n\tcreateDefinitionsMapFromSources,\n\tcreateModuleRegistry,\n\tgetSourcesFromSchema,\n\tgroupSourcesByModule,\n\tloadSchema,\n} from '@baeta/util-graphql';\nimport { join } from '@baeta/util-path';\nimport { concatAST } from 'graphql';\nimport { createFieldInfoMap } from './field-info.ts';\nimport { printAutoload } from './printer-autoload.ts';\nimport {\n\ttype ModulePrinterConfig,\n\tprintBaetaModuleTypes,\n\tprintModuleBuilder,\n\tprintModuleImports,\n\tprintModuleIndexStarter,\n\tprintModuleMetadata,\n\tprintModuleObjectTypeFields,\n} from './printer-module.ts';\nimport { printTypesTemplate } from './printer-templates.ts';\nimport {\n\ttype PrinterConfig,\n\tprintBaseObjectTypes,\n\tprintBaseScalars,\n\tprintEnumTypesFromMap,\n\tprintInputObjectTypeTypesFromMap,\n\tprintInterfaceTypesFromMap,\n\tprintObjectTypeFieldsArgsFromMap,\n\tprintObjectTypeTypesFromMap,\n\tprintRootTypesFromMap,\n\tprintTypesHeaders,\n\tprintUnionTypesFromMap,\n\tprintUtilityTypes,\n} from './printer-types.ts';\n\ntype GeneratedFile = {\n\tfilename: string;\n\tcontent: string;\n\toptions?: FileOptions;\n};\n\nexport async function generate(\n\toptions: NormalizedGeneratorOptions,\n\tcurrentFiles: File[],\n): Promise<GeneratedFile[]> {\n\tconst { outputSchema, outputSchemaAst } = await loadSchema(\n\t\toptions.schemas,\n\t\toptions.cwd,\n\t\toptions.loaders,\n\t);\n\tconst sources = getSourcesFromSchema(outputSchemaAst);\n\tconst sourcesByModule = groupSourcesByModule(sources, options.modulesDir);\n\tconst modules = Array.from(sourcesByModule.keys());\n\tconst globalDefinitions = createDefinitionsMapFromDocument(outputSchema);\n\tconst modulesDefinitions = createDefinitionsMapFromSources(sources);\n\n\tconst defaultScalars = ['ID', 'Int', 'Float', 'String', 'Boolean'];\n\n\tconst config: PrinterConfig = {\n\t\tglobalDefinitions,\n\t\twithMaybe: false,\n\t\twithOptional: false,\n\t\tdefaultScalars,\n\t\timportExtension: options.importExtension,\n\t\ttypesDir: options.typesDir,\n\t\tmodulesDir: options.modulesDir,\n\t};\n\n\tconst fieldInfo = createFieldInfoMap(globalDefinitions, defaultScalars);\n\n\tconst typesContent = [\n\t\tprintTypesHeaders(config),\n\t\tprintRootTypesFromMap(\n\t\t\tconfig,\n\t\t\t['Query', 'Mutation', 'Subscription'],\n\t\t\tglobalDefinitions.objectTypeMap,\n\t\t),\n\t\t...printEnumTypesFromMap(globalDefinitions.enumTypeMap),\n\t\t...printObjectTypeTypesFromMap(config, modulesDefinitions.objectTypeMap),\n\t\t...printObjectTypeFieldsArgsFromMap(config, globalDefinitions.objectTypeMap),\n\t\t...printInputObjectTypeTypesFromMap(config, globalDefinitions.inputObjectTypeMap),\n\t\t...printInterfaceTypesFromMap(config, globalDefinitions.interfaceTypeMap),\n\t\t...printUnionTypesFromMap(config, globalDefinitions.unionTypeMap),\n\t].join('\\n\\n');\n\n\tconst utilityContent = [\n\t\tprintUtilityTypes(),\n\t\tprintBaseScalars(config),\n\t\tprintBaseObjectTypes(config),\n\t].join('\\n\\n');\n\n\tconst files: GeneratedFile[] = [\n\t\t{\n\t\t\tfilename: join(options.typesDir, 'types.ts'),\n\t\t\tcontent: typesContent,\n\t\t},\n\t\t{\n\t\t\tfilename: join(options.typesDir, 'utility.ts'),\n\t\t\tcontent: utilityContent,\n\t\t},\n\t\t{\n\t\t\tfilename: join(options.modulesDir, 'index.ts'),\n\t\t\tcontent: printAutoload(\n\t\t\t\t{\n\t\t\t\t\timportExtension: options.importExtension,\n\t\t\t\t\tmoduleDefinitionName: options.moduleDefinitionName,\n\t\t\t\t},\n\t\t\t\tmodules,\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tfilename: join(options.modulesDir, 'types.ts'),\n\t\t\tcontent: printTypesTemplate({\n\t\t\t\timportExtension: options.importExtension,\n\t\t\t\ttypesDir: options.typesDir,\n\t\t\t\tmodulesDir: options.modulesDir,\n\t\t\t}),\n\t\t\toptions: {\n\t\t\t\tdisableOverwrite: true,\n\t\t\t\tenableLintHeaders: false,\n\t\t\t\tdisableGenerationNoticeHeader: true,\n\t\t\t},\n\t\t},\n\t];\n\n\tfor (const module of modules) {\n\t\tconst sources = sourcesByModule.get(module);\n\t\tconst documents = sources?.map((s) => s.document).filter((el) => el != null) ?? [];\n\t\tif (documents.length === 0) continue;\n\t\tconst document = concatAST(documents);\n\t\tconst config: ModulePrinterConfig = {\n\t\t\ttypesDir: options.typesDir,\n\t\t\tfieldInfo,\n\t\t\timportExtension: options.importExtension,\n\t\t\tmodulesDir: options.modulesDir,\n\t\t\tregistry: createModuleRegistry(document),\n\t\t\tmoduleDefinitionName: options.moduleDefinitionName,\n\t\t};\n\t\tfiles.push({\n\t\t\tfilename: join(options.modulesDir, `/${module}/${options.moduleDefinitionName}.ts`),\n\t\t\tcontent: [\n\t\t\t\tprintModuleImports(config, module),\n\t\t\t\tprintModuleMetadata(module, document),\n\t\t\t\tprintBaetaModuleTypes(config),\n\t\t\t\tprintModuleObjectTypeFields(config),\n\t\t\t\tprintModuleBuilder(config, module),\n\t\t\t].join('\\n\\n'),\n\t\t});\n\n\t\tconst moduleStarterPath = join(options.modulesDir, `/${module}/index.ts`);\n\t\tconst moduleStarterExists = currentFiles.some((file) => file.filename === moduleStarterPath);\n\t\tif (!moduleStarterExists) {\n\t\t\tfiles.push({\n\t\t\t\tfilename: join(options.modulesDir, `/${module}/index.ts`),\n\t\t\t\tcontent: printModuleIndexStarter(config, module),\n\t\t\t\toptions: {\n\t\t\t\t\tdisableOverwrite: true,\n\t\t\t\t\tenableLintHeaders: false,\n\t\t\t\t\tdisableGenerationNoticeHeader: true,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\n\treturn files;\n}\n","import { createPluginV1, isMatch, type WatcherFile } 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\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, ctx.fileManager.files);\n\t\t\tfor (const item of items) {\n\t\t\t\tctx.fileManager.createAndAdd(item.filename, item.content, 'graphql', item.options);\n\t\t\t}\n\t\t\treturn await next();\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;AAAA,MAAa,YAAY;CACxB,KAAK;CACL,SAAS;CACT,aAAa;CACb,WAAW;AACZ;;;ACCA,SAAgB,mBAAmB,gBAAgC,gBAA0B;CAC5F,MAAM,sBAAoB,IAAI,IAAI;CAClC,KAAK,MAAM,cAAc,eAAe,cAAc,OAAO,GAAG;EAC/D,MAAM,aAAa,WAAW,KAAK;EACnC,KAAK,MAAM,SAAS,WAAW,UAAU,CAAC,GAAG;GAC5C,MAAM,YAAY,MAAM,KAAK;GAC7B,MAAM,OAAOA,iBAAe,gBAAgB,gBAAgB,MAAM,IAAI;GACtE,MAAM,eAAe,MAAM,aAAa,QAAQ,MAAM,UAAU,SAAS;GACzE,MAAM,WAAW,IAAI,IAAI,UAAU,qBAAK,IAAI,IAAI;GAChD,SAAS,IAAI,WAAW;IAAE;IAAM;GAAa,CAAC;GAC9C,IAAI,IAAI,YAAY,QAAQ;EAC7B;CACD;CACA,OAAO;AACR;AAEA,SAASA,iBACR,gBACA,gBACA,MACA,WAAW,MACF;CACT,MAAM,eAAe,WAAW,YAAY;CAC5C,QAAQ,KAAK,MAAb;EACC,KAAK,KAAK;GACT,IAAI,aAAa,gBAAgB,gBAAgB,IAAI,GACpD,OAAO,GAAG,UAAU,YAAY,YAAY,KAAK,KAAK,MAAM,IAAI;GAEjE,OAAO,GAAG,UAAU,YAAY,GAAG,KAA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;EAC/B;EACA,MAAM,KAAK;GACV,UAAU,KAAK,QAAQ,YAAY,IAAI,OAAO,GAAG,QAAQ,qBAAqB,IAAI;GAClF,SAAS;IACR,mBAAmB,QAAQ,MAAM;IACjC,oBAAoB,QAAQ,QAAQ;IACpC,sBAAsB,MAAM;IAC5B,4BAA4B,MAAM;IAClC,mBAAmB,QAAQ,MAAM;GAClC,EAAE,KAAK,MAAM;EACd,CAAC;EAED,MAAM,oBAAoB,KAAK,QAAQ,YAAY,IAAI,OAAO,UAAU;EAExE,IAAI,CADwB,aAAa,MAAM,SAAS,KAAK,aAAa,iBACnD,GACtB,MAAM,KAAK;GACV,UAAU,KAAK,QAAQ,YAAY,IAAI,OAAO,UAAU;GACxD,SAAS,wBAAwB,QAAQ,MAAM;GAC/C,SAAS;IACR,kBAAkB;IAClB,mBAAmB;IACnB,+BAA+B;GAChC;EACD,CAAC;CAEH;CAEA,OAAO;AACR;;;ACrKA,SAAgB,gBAAgB;CAC/B,OAAO,eAAe;EACrB,MAAM;EACN,YAAY;EACZ,QAAQ,SAAS,SAAS,WAAW;GACpC,MAAM,gBAAgB,SAAsB;IAC3C,IAAI,QAAQ,KAAK,cAAc,QAAQ,OAAO,GAC7C,OAAO,IAAI;GAEb;GACA,QAAQ,GAAG,UAAU,YAAY;GACjC,QAAQ,GAAG,UAAU,YAAY;EAClC;EACA,UAAU,OAAO,KAAK,SAAS;GAC9B,MAAM,QAAQ,MAAM,SAAS,IAAI,kBAAkB,IAAI,YAAY,KAAK;GACxE,KAAK,MAAM,QAAQ,OAClB,IAAI,YAAY,aAAa,KAAK,UAAU,KAAK,SAAS,WAAW,KAAK,OAAO;GAElF,OAAO,MAAM,KAAK;EACnB;CACD,CAAC;AACF"}
package/package.json CHANGED
@@ -1,59 +1,64 @@
1
1
  {
2
2
  "name": "@baeta/plugin-graphql",
3
- "version": "2.0.0-next.13",
3
+ "version": "2.0.0-next.15",
4
+ "description": "GraphQL codegen plugin for Baeta.",
4
5
  "keywords": [
5
6
  "baeta",
7
+ "builder",
8
+ "framework",
6
9
  "graphql",
7
10
  "schema",
8
11
  "types",
9
- "typescript",
10
- "framework",
11
- "builder"
12
+ "typescript"
12
13
  ],
13
14
  "homepage": "https://github.com/andreisergiu98/baeta#readme",
14
15
  "bugs": {
15
16
  "url": "https://github.com/andreisergiu98/baeta/issues"
16
17
  },
17
- "repository": {
18
- "type": "git",
19
- "url": "https://github.com/andreisergiu98/baeta.git",
20
- "directory": "packages/plugin-graphql"
21
- },
22
18
  "license": "MIT",
23
19
  "author": {
24
20
  "name": "Andrei Pampu",
25
21
  "url": "https://github.com/andreisergiu98"
26
22
  },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/andreisergiu98/baeta.git",
26
+ "directory": "packages/plugin-graphql"
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
27
31
  "type": "module",
32
+ "sideEffects": false,
33
+ "types": "dist/index.d.ts",
28
34
  "exports": {
29
35
  ".": {
30
36
  "types": "./dist/index.d.ts",
31
37
  "default": "./dist/index.js"
32
38
  }
33
39
  },
34
- "types": "dist/index.d.ts",
35
- "files": [
36
- "dist",
37
- "package.json"
38
- ],
40
+ "publishConfig": {
41
+ "exports": {
42
+ ".": {
43
+ "types": "./dist/index.d.ts",
44
+ "default": "./dist/index.js"
45
+ }
46
+ },
47
+ "access": "public"
48
+ },
39
49
  "scripts": {
40
50
  "build": "builder build",
41
51
  "check:deps": "builder check-deps",
42
- "prepack": "builder prepare",
43
52
  "postpack": "builder prepare --restore",
53
+ "prepack": "builder prepare",
44
54
  "test": "builder test",
45
55
  "types": "tsc --noEmit"
46
56
  },
47
- "ava": {
48
- "extensions": [
49
- "ts"
50
- ]
51
- },
52
57
  "dependencies": {
53
- "@baeta/generator-sdk": "^2.0.0-next.5",
54
- "@baeta/util-graphql": "^2.0.0-next.2",
55
- "@baeta/util-path": "^2.0.0-next.4",
56
- "change-case-all": "2.1.0"
58
+ "@baeta/generator-sdk": "^2.0.0-next.6",
59
+ "@baeta/util-graphql": "^2.0.0-next.3",
60
+ "@baeta/util-path": "^2.0.0-next.5",
61
+ "change-case": "^5.4.4"
57
62
  },
58
63
  "devDependencies": {
59
64
  "@baeta/builder": "^0.0.0",
@@ -66,17 +71,13 @@
66
71
  "peerDependencies": {
67
72
  "graphql": "^16.6.0"
68
73
  },
69
- "engines": {
70
- "node": ">=22.20.0"
74
+ "ava": {
75
+ "extensions": [
76
+ "ts"
77
+ ]
71
78
  },
72
- "publishConfig": {
73
- "access": "public",
74
- "exports": {
75
- ".": {
76
- "types": "./dist/index.d.ts",
77
- "default": "./dist/index.js"
78
- }
79
- }
79
+ "engines": {
80
+ "node": "^22.20.0 || ^24.0.0 || >=26.0.0"
80
81
  },
81
82
  "typedocOptions": {
82
83
  "entryPoints": [