@soda-gql/codegen 0.0.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # @soda-gql/codegen
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@soda-gql/codegen.svg)](https://www.npmjs.com/package/@soda-gql/codegen)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Multi-schema GraphQL code generation engine for soda-gql.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ bun add -D @soda-gql/codegen
12
+ ```
13
+
14
+ > **Note**: This package is typically used indirectly via [@soda-gql/cli](../cli). Direct usage is only needed for advanced integration scenarios.
15
+
16
+ ## Overview
17
+
18
+ This package provides the code generation engine that transforms GraphQL schemas into type-safe TypeScript modules. It supports:
19
+
20
+ - Multiple schema configurations
21
+ - Custom scalar definitions
22
+ - Runtime adapter integration
23
+ - Incremental generation
24
+
25
+ ## Programmatic Usage
26
+
27
+ For advanced use cases where you need to integrate code generation into your own build pipeline:
28
+
29
+ ```typescript
30
+ import { runCodegen } from "@soda-gql/codegen";
31
+
32
+ const result = await runCodegen({
33
+ outPath: "./src/graphql-system/index.ts",
34
+ format: "json",
35
+ schemas: {
36
+ default: {
37
+ schema: "./schema.graphql",
38
+ inject: {
39
+ scalars: "./scalars.ts",
40
+ },
41
+ },
42
+ },
43
+ });
44
+
45
+ if (result.isErr()) {
46
+ console.error("Code generation failed:", result.error);
47
+ } else {
48
+ console.log("Code generation successful");
49
+ }
50
+ ```
51
+
52
+ ## Features
53
+
54
+ - **Multi-Schema Support**: Generate modules for multiple GraphQL schemas in a single run
55
+ - **Type Safety**: Full TypeScript type generation from GraphQL schema
56
+ - **Custom Scalars**: Support for custom scalar type definitions
57
+ - **Error Handling**: Type-safe error handling using neverthrow
58
+
59
+ ## Related Packages
60
+
61
+ - [@soda-gql/cli](../cli) - Command-line interface (recommended for most users)
62
+ - [@soda-gql/config](../config) - Configuration management
63
+ - [@soda-gql/core](../core) - Core types and utilities
64
+
65
+ ## License
66
+
67
+ MIT
@@ -1,4 +1,4 @@
1
- const require_generator = require('./generator-CxkxGwRx.cjs');
1
+ const require_generator = require('./generator-yvSYKjbW.cjs');
2
2
 
3
3
  exports.createSchemaIndex = require_generator.createSchemaIndex;
4
4
  exports.generateMultiSchemaModule = require_generator.generateMultiSchemaModule;
@@ -0,0 +1,3 @@
1
+ import { n as generateMultiSchemaModule, t as createSchemaIndex } from "./generator-HYfj5Qkm.mjs";
2
+
3
+ export { createSchemaIndex, generateMultiSchemaModule };
@@ -369,25 +369,27 @@ const collectUnionTypeNames = (schema) => Array.from(schema.unions.keys()).filte
369
369
  const collectScalarNames = (schema) => Array.from(schema.scalars.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
370
370
  const multiRuntimeTemplate = ($$) => {
371
371
  const imports = [];
372
- const adapterAliases = new Map();
373
372
  const scalarAliases = new Map();
373
+ const adapterAliases = new Map();
374
374
  if ($$.injection.mode === "inject") {
375
375
  const importsByPath = new Map();
376
376
  for (const [schemaName, injection] of $$.injection.perSchema) {
377
- const adapterAlias = `adapter_${schemaName}`;
378
377
  const scalarAlias = `scalar_${schemaName}`;
379
- adapterAliases.set(schemaName, adapterAlias);
380
378
  scalarAliases.set(schemaName, scalarAlias);
381
- const adapterSpecifiers = importsByPath.get(injection.adapterImportPath) ?? [];
382
- if (!importsByPath.has(injection.adapterImportPath)) {
383
- importsByPath.set(injection.adapterImportPath, adapterSpecifiers);
384
- }
385
- adapterSpecifiers.push(`adapter as ${adapterAlias}`);
386
379
  const scalarSpecifiers = importsByPath.get(injection.scalarImportPath) ?? [];
387
380
  if (!importsByPath.has(injection.scalarImportPath)) {
388
381
  importsByPath.set(injection.scalarImportPath, scalarSpecifiers);
389
382
  }
390
383
  scalarSpecifiers.push(`scalar as ${scalarAlias}`);
384
+ if (injection.adapterImportPath) {
385
+ const adapterAlias = `adapter_${schemaName}`;
386
+ adapterAliases.set(schemaName, adapterAlias);
387
+ const adapterSpecifiers = importsByPath.get(injection.adapterImportPath) ?? [];
388
+ if (!importsByPath.has(injection.adapterImportPath)) {
389
+ importsByPath.set(injection.adapterImportPath, adapterSpecifiers);
390
+ }
391
+ adapterSpecifiers.push(`adapter as ${adapterAlias}`);
392
+ }
391
393
  }
392
394
  for (const [path, specifiers] of importsByPath) {
393
395
  if (specifiers.length === 1) {
@@ -402,10 +404,13 @@ const multiRuntimeTemplate = ($$) => {
402
404
  const gqlEntries = [];
403
405
  for (const [name, config] of Object.entries($$.schemas)) {
404
406
  const schemaVar = `${name}Schema`;
405
- const adapterVar = $$.injection.mode === "inject" ? adapterAliases.get(name) : `adapter_${name}`;
406
407
  const scalarBlock = $$.injection.mode === "inject" ? scalarAliases.get(name) : config.scalarBlock;
407
- const adapterDefinition = $$.injection.mode === "inject" ? "" : `const ${adapterVar} = createRuntimeAdapter(({ type }) => ({\n nonGraphqlErrorType: type<{ type: "non-graphql-error"; cause: unknown }>(),\n}));\n`;
408
- schemaBlocks.push(`${adapterDefinition}
408
+ const adapterVar = adapterAliases.get(name);
409
+ const typeExports = [`export type Schema_${name} = typeof ${schemaVar} & { _?: never };`];
410
+ if (adapterVar) {
411
+ typeExports.push(`export type Adapter_${name} = typeof ${adapterVar} & { _?: never };`);
412
+ }
413
+ schemaBlocks.push(`
409
414
  const ${schemaVar} = {
410
415
  label: "${name}" as const,
411
416
  operations: defineOperationRoots({
@@ -420,11 +425,14 @@ const ${schemaVar} = {
420
425
  union: ${config.unionBlock},
421
426
  } satisfies AnyGraphqlSchema;
422
427
 
423
- export type Schema_${name} = typeof ${schemaVar} & { _?: never };
424
- export type Adapter_${name} = typeof ${adapterVar} & { _?: never };`);
425
- gqlEntries.push(` ${name}: createGqlElementComposer<Schema_${name}, Adapter_${name}>(${schemaVar})`);
428
+ ${typeExports.join("\n")}`);
429
+ if (adapterVar) {
430
+ const typeParams = `<Schema_${name}, Adapter_${name}>`;
431
+ gqlEntries.push(` ${name}: createGqlElementComposer${typeParams}(${schemaVar}, { adapter: ${adapterVar} })`);
432
+ } else {
433
+ gqlEntries.push(` ${name}: createGqlElementComposer<Schema_${name}>(${schemaVar})`);
434
+ }
426
435
  }
427
- const runtimeImport = $$.injection.mode === "inline" ? "\nimport { createRuntimeAdapter } from \"@soda-gql/runtime\";" : "";
428
436
  return `\
429
437
  import {
430
438
  type AnyGraphqlSchema,
@@ -433,7 +441,7 @@ import {
433
441
  defineOperationRoots,
434
442
  unsafeInputType,
435
443
  unsafeOutputType,
436
- } from "@soda-gql/core";${runtimeImport}
444
+ } from "@soda-gql/core";
437
445
  ${extraImports}
438
446
  ${schemaBlocks.join("\n")}
439
447
 
@@ -523,4 +531,4 @@ const generateMultiSchemaModule = (schemas, options) => {
523
531
 
524
532
  //#endregion
525
533
  export { generateMultiSchemaModule as n, createSchemaIndex as t };
526
- //# sourceMappingURL=generator-DSOZFGSD.mjs.map
534
+ //# sourceMappingURL=generator-HYfj5Qkm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator-HYfj5Qkm.mjs","names":["operationTypes: OperationTypeNames","modifier: TypeModifier","imports: string[]","schemaBlocks: string[]","gqlEntries: string[]","schemaConfigs: Record<string, any>","name","injection: RuntimeTemplateInjection"],"sources":["../src/generator.ts"],"sourcesContent":["import type { TypeModifier } from \"@soda-gql/core\";\nimport {\n type ConstDirectiveNode,\n type ConstValueNode,\n type DocumentNode,\n type EnumValueDefinitionNode,\n type FieldDefinitionNode,\n type InputValueDefinitionNode,\n Kind,\n type NamedTypeNode,\n type SchemaDefinitionNode,\n type SchemaExtensionNode,\n type TypeNode,\n} from \"graphql\";\n\nconst builtinScalarTypes = new Map<string, { readonly input: string; readonly output: string }>([\n [\"ID\", { input: \"string\", output: \"string\" }],\n [\"String\", { input: \"string\", output: \"string\" }],\n [\"Int\", { input: \"number\", output: \"number\" }],\n [\"Float\", { input: \"number\", output: \"number\" }],\n [\"Boolean\", { input: \"boolean\", output: \"boolean\" }],\n]);\n\ntype OperationTypeNames = {\n query?: string;\n mutation?: string;\n subscription?: string;\n};\n\ntype ObjectRecord = {\n readonly name: string;\n readonly fields: Map<string, FieldDefinitionNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype InputRecord = {\n readonly name: string;\n readonly fields: Map<string, InputValueDefinitionNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype EnumRecord = {\n readonly name: string;\n readonly values: Map<string, EnumValueDefinitionNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype UnionRecord = {\n readonly name: string;\n readonly members: Map<string, NamedTypeNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype ScalarRecord = {\n readonly name: string;\n directives: ConstDirectiveNode[];\n};\n\ntype SchemaIndex = {\n readonly objects: Map<string, ObjectRecord>;\n readonly inputs: Map<string, InputRecord>;\n readonly enums: Map<string, EnumRecord>;\n readonly unions: Map<string, UnionRecord>;\n readonly scalars: Map<string, ScalarRecord>;\n readonly operationTypes: OperationTypeNames;\n};\n\nconst ensureRecord = <T>(collection: Map<string, T>, key: string, factory: (name: string) => T): T => {\n const existing = collection.get(key);\n if (existing) {\n return existing;\n }\n\n const created = factory(key);\n collection.set(key, created);\n return created;\n};\n\nconst addObjectFields = (target: Map<string, FieldDefinitionNode>, fields: readonly FieldDefinitionNode[] | undefined): void => {\n if (!fields) {\n return;\n }\n\n for (const field of fields) {\n target.set(field.name.value, field);\n }\n};\n\nconst addInputFields = (\n target: Map<string, InputValueDefinitionNode>,\n fields: readonly InputValueDefinitionNode[] | undefined,\n): void => {\n if (!fields) {\n return;\n }\n\n for (const field of fields) {\n target.set(field.name.value, field);\n }\n};\n\nconst addEnumValues = (\n target: Map<string, EnumValueDefinitionNode>,\n values: readonly EnumValueDefinitionNode[] | undefined,\n): void => {\n if (!values) {\n return;\n }\n\n for (const value of values) {\n target.set(value.name.value, value);\n }\n};\n\nconst addUnionMembers = (target: Map<string, NamedTypeNode>, members: readonly NamedTypeNode[] | undefined): void => {\n if (!members) {\n return;\n }\n\n for (const member of members) {\n target.set(member.name.value, member);\n }\n};\n\nconst mergeDirectives = (\n existing: ConstDirectiveNode[] | undefined,\n incoming: readonly ConstDirectiveNode[] | undefined,\n precedence: \"definition\" | \"extension\",\n): ConstDirectiveNode[] => {\n const current = existing ?? [];\n const next = incoming ? Array.from(incoming) : [];\n return precedence === \"definition\" ? [...next, ...current] : [...current, ...next];\n};\n\nconst updateOperationTypes = (\n operationTypes: OperationTypeNames,\n definition: SchemaDefinitionNode | SchemaExtensionNode,\n): void => {\n for (const operation of definition.operationTypes ?? []) {\n const typeName = operation.type.name.value;\n switch (operation.operation) {\n case \"query\":\n operationTypes.query = typeName;\n break;\n case \"mutation\":\n operationTypes.mutation = typeName;\n break;\n case \"subscription\":\n operationTypes.subscription = typeName;\n break;\n default:\n break;\n }\n }\n};\n\nexport const createSchemaIndex = (document: DocumentNode): SchemaIndex => {\n const objects = new Map<string, ObjectRecord>();\n const inputs = new Map<string, InputRecord>();\n const enums = new Map<string, EnumRecord>();\n const unions = new Map<string, UnionRecord>();\n const scalars = new Map<string, ScalarRecord>();\n const operationTypes: OperationTypeNames = {};\n\n for (const definition of document.definitions) {\n switch (definition.kind) {\n case Kind.OBJECT_TYPE_DEFINITION:\n case Kind.OBJECT_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.OBJECT_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(objects, definition.name.value, (name) => ({\n name,\n fields: new Map<string, FieldDefinitionNode>(),\n directives: [],\n }));\n addObjectFields(record.fields, definition.fields);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.INPUT_OBJECT_TYPE_DEFINITION:\n case Kind.INPUT_OBJECT_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(inputs, definition.name.value, (name) => ({\n name,\n fields: new Map<string, InputValueDefinitionNode>(),\n directives: [],\n }));\n addInputFields(record.fields, definition.fields);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.ENUM_TYPE_DEFINITION:\n case Kind.ENUM_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.ENUM_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(enums, definition.name.value, (name) => ({\n name,\n values: new Map<string, EnumValueDefinitionNode>(),\n directives: [],\n }));\n addEnumValues(record.values, definition.values);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.UNION_TYPE_DEFINITION:\n case Kind.UNION_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.UNION_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(unions, definition.name.value, (name) => ({\n name,\n members: new Map<string, NamedTypeNode>(),\n directives: [],\n }));\n addUnionMembers(record.members, definition.types);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.SCALAR_TYPE_DEFINITION:\n case Kind.SCALAR_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.SCALAR_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(scalars, definition.name.value, (name) => ({\n name,\n directives: [],\n }));\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.SCHEMA_DEFINITION:\n case Kind.SCHEMA_EXTENSION:\n updateOperationTypes(operationTypes, definition);\n break;\n default:\n break;\n }\n }\n\n if (!operationTypes.query && objects.has(\"Query\")) {\n operationTypes.query = \"Query\";\n }\n if (!operationTypes.mutation && objects.has(\"Mutation\")) {\n operationTypes.mutation = \"Mutation\";\n }\n if (!operationTypes.subscription && objects.has(\"Subscription\")) {\n operationTypes.subscription = \"Subscription\";\n }\n\n return {\n objects,\n inputs,\n enums,\n unions,\n scalars,\n operationTypes,\n } satisfies SchemaIndex;\n};\n\ntype TypeLevel = {\n readonly kind: \"list\" | \"named\";\n readonly nonNull: boolean;\n};\n\nconst collectTypeLevels = (\n type: TypeNode,\n nonNull = false,\n levels: TypeLevel[] = [],\n): { readonly name: string; readonly levels: TypeLevel[] } => {\n if (type.kind === Kind.NON_NULL_TYPE) {\n return collectTypeLevels(type.type, true, levels);\n }\n\n if (type.kind === Kind.LIST_TYPE) {\n levels.push({ kind: \"list\", nonNull });\n return collectTypeLevels(type.type, false, levels);\n }\n\n levels.push({ kind: \"named\", nonNull });\n return { name: type.name.value, levels };\n};\n\nconst buildTypeModifier = (levels: TypeLevel[]): TypeModifier => {\n let modifier: TypeModifier = \"?\";\n\n for (const level of levels.slice().reverse()) {\n if (level.kind === \"named\") {\n // Inner type: always explicit nullable marker\n modifier = level.nonNull ? \"!\" : \"?\";\n continue;\n }\n\n // List type: append []? or []! based on list's nullability\n const listSuffix = level.nonNull ? \"[]!\" : \"[]?\";\n modifier = `${modifier}${listSuffix}` as TypeModifier;\n }\n\n return modifier;\n};\n\nconst parseTypeReference = (type: TypeNode): { readonly name: string; readonly modifier: string } => {\n const { name, levels } = collectTypeLevels(type);\n return { name, modifier: buildTypeModifier(levels) };\n};\n\nconst renderType = (name: string, modifier: string): string => JSON.stringify(`${name}:${modifier}`);\n\nconst isScalarName = (schema: SchemaIndex, name: string): boolean => builtinScalarTypes.has(name) || schema.scalars.has(name);\nconst isEnumName = (schema: SchemaIndex, name: string): boolean => schema.enums.has(name);\nconst _isInputName = (schema: SchemaIndex, name: string): boolean => schema.inputs.has(name);\nconst isUnionName = (schema: SchemaIndex, name: string): boolean => schema.unions.has(name);\nconst isObjectName = (schema: SchemaIndex, name: string): boolean => schema.objects.has(name);\n\nconst renderConstValue = (value: ConstValueNode): string => {\n switch (value.kind) {\n case Kind.NULL:\n return \"null\";\n case Kind.INT:\n case Kind.FLOAT:\n return value.value;\n case Kind.STRING:\n case Kind.ENUM:\n return JSON.stringify(value.value);\n case Kind.BOOLEAN:\n return value.value ? \"true\" : \"false\";\n case Kind.LIST:\n return `[${value.values.map((item) => renderConstValue(item)).join(\", \")}]`;\n case Kind.OBJECT: {\n if (value.fields.length === 0) {\n return \"{}\";\n }\n const entries = value.fields.map((field) => `${field.name.value}: ${renderConstValue(field.value)}`);\n return `{ ${entries.join(\", \")} }`;\n }\n }\n};\n\nconst renderConstArgumentMap = (\n args: readonly { readonly name: { readonly value: string }; readonly value: ConstValueNode }[] | undefined,\n): string => {\n const entries = (args ?? []).map((arg) => `${arg.name.value}: ${renderConstValue(arg.value)}`);\n return renderPropertyLines({ entries, indentSize: 8 });\n};\n\nconst renderDirectives = (directives: readonly ConstDirectiveNode[] | undefined): string => {\n const entries = (directives ?? []).map(\n (directive) => `${directive.name.value}: ${renderConstArgumentMap(directive.arguments)}`,\n );\n return renderPropertyLines({ entries, indentSize: 8 });\n};\n\nconst renderDefaultValue = (value: ConstValueNode | null | undefined): string =>\n value ? `() => (${renderConstValue(value)})` : \"null\";\n\nconst renderInputRef = (schema: SchemaIndex, definition: InputValueDefinitionNode): string => {\n const { name, modifier } = parseTypeReference(definition.type);\n const tuple = renderType(name, modifier);\n const defaultValue = renderDefaultValue(definition.defaultValue ?? null);\n const directives = renderDirectives(definition.directives);\n\n if (isScalarName(schema, name)) {\n return `unsafeInputType.scalar(${tuple}, { default: ${defaultValue}, directives: ${directives} })`;\n }\n\n if (isEnumName(schema, name)) {\n return `unsafeInputType.enum(${tuple}, { default: ${defaultValue}, directives: ${directives} })`;\n }\n\n return `unsafeInputType.input(${tuple}, { default: ${defaultValue}, directives: ${directives} })`;\n};\n\nconst renderArgumentMap = (schema: SchemaIndex, args: readonly InputValueDefinitionNode[] | undefined): string => {\n const entries = [...(args ?? [])]\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((arg) => `${arg.name.value}: ${renderInputRef(schema, arg)}`);\n\n return renderPropertyLines({ entries, indentSize: 8 });\n};\n\nconst renderOutputRef = (schema: SchemaIndex, type: TypeNode, args: readonly InputValueDefinitionNode[] | undefined): string => {\n const { name, modifier } = parseTypeReference(type);\n const modifiedType = renderType(name, modifier);\n const argumentMap = renderArgumentMap(schema, args);\n\n if (isScalarName(schema, name)) {\n return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n if (isEnumName(schema, name)) {\n return `unsafeOutputType.enum(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n if (isUnionName(schema, name)) {\n return `unsafeOutputType.union(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n if (isObjectName(schema, name)) {\n return `unsafeOutputType.object(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap} })`;\n};\n\nconst renderPropertyLines = ({ entries, indentSize }: { entries: string[]; indentSize: number }) => {\n if (entries.length === 0) {\n return \"{}\";\n }\n\n const indent = \" \".repeat(indentSize);\n const lastIndent = \" \".repeat(indentSize - 2);\n return [\"{\", `${indent}${entries.join(`,\\n${indent}`)},`, `${lastIndent}}`].join(`\\n`);\n};\n\nconst renderObjectFields = (schema: SchemaIndex, fields: Map<string, FieldDefinitionNode>): string => {\n const entries = Array.from(fields.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((field) => `${field.name.value}: ${renderOutputRef(schema, field.type, field.arguments)}`);\n\n return renderPropertyLines({ entries, indentSize: 6 });\n};\n\nconst renderInputFields = (schema: SchemaIndex, fields: Map<string, InputValueDefinitionNode>): string => {\n const entries = Array.from(fields.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((field) => `${field.name.value}: ${renderInputRef(schema, field)}`);\n\n return renderPropertyLines({ entries, indentSize: 6 });\n};\n\nconst renderScalarDefinition = (record: ScalarRecord): string => {\n const typeInfo = builtinScalarTypes.get(record.name) ?? { input: \"string\", output: \"string\" };\n const scalarType = `type<{ input: ${typeInfo.input}; output: ${typeInfo.output} }>()`;\n return `${record.name}: define(\"${record.name}\").scalar(${scalarType})`;\n};\n\nconst renderObjectDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.objects.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const fields = renderObjectFields(schema, record.fields);\n return `${record.name}: define(\"${record.name}\").object(${fields})`;\n};\n\nconst renderInputDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.inputs.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const fields = renderInputFields(schema, record.fields);\n return `${record.name}: define(\"${record.name}\").input(${fields})`;\n};\n\nconst renderEnumDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.enums.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const values = Array.from(record.values.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((value) => `${value.name.value}: true`)\n .join(\", \");\n const body = values.length === 0 ? \"{}\" : `{ ${values} }`;\n\n return `${record.name}: define(\"${record.name}\").enum(${body})`;\n};\n\nconst renderUnionDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.unions.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const members = Array.from(record.members.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((member) => `${member.name.value}: true`)\n .join(\", \");\n const body = members.length === 0 ? \"{}\" : `{ ${members} }`;\n\n return `${record.name}: define(\"${record.name}\").union(${body})`;\n};\n\nconst collectObjectTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.objects.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectInputTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.inputs.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectEnumTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.enums.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectUnionTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.unions.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectScalarNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.scalars.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nexport type GeneratedModule = {\n readonly code: string;\n readonly stats: {\n readonly objects: number;\n readonly enums: number;\n readonly inputs: number;\n readonly unions: number;\n };\n};\n\ntype PerSchemaInjection = {\n readonly scalarImportPath: string;\n readonly adapterImportPath?: string;\n};\n\ntype RuntimeTemplateInjection =\n | { readonly mode: \"inline\" }\n | {\n readonly mode: \"inject\";\n readonly perSchema: Map<string, PerSchemaInjection>;\n };\n\nexport type RuntimeGenerationOptions = {\n readonly injection?: Map<string, PerSchemaInjection>;\n};\n\ntype MultiRuntimeTemplateOptions = {\n readonly schemas: Record<\n string,\n {\n readonly queryType: string;\n readonly mutationType: string;\n readonly subscriptionType: string;\n readonly scalarBlock: string;\n readonly enumBlock: string;\n readonly inputBlock: string;\n readonly objectBlock: string;\n readonly unionBlock: string;\n }\n >;\n readonly injection: RuntimeTemplateInjection;\n};\n\nconst multiRuntimeTemplate = ($$: MultiRuntimeTemplateOptions) => {\n // Build imports based on injection mode\n const imports: string[] = [];\n const scalarAliases = new Map<string, string>();\n const adapterAliases = new Map<string, string>();\n\n if ($$.injection.mode === \"inject\") {\n // Group imports by file path\n const importsByPath = new Map<string, string[]>();\n\n for (const [schemaName, injection] of $$.injection.perSchema) {\n const scalarAlias = `scalar_${schemaName}`;\n scalarAliases.set(schemaName, scalarAlias);\n\n // Group scalar import\n const scalarSpecifiers = importsByPath.get(injection.scalarImportPath) ?? [];\n if (!importsByPath.has(injection.scalarImportPath)) {\n importsByPath.set(injection.scalarImportPath, scalarSpecifiers);\n }\n scalarSpecifiers.push(`scalar as ${scalarAlias}`);\n\n // Group adapter import (optional)\n if (injection.adapterImportPath) {\n const adapterAlias = `adapter_${schemaName}`;\n adapterAliases.set(schemaName, adapterAlias);\n const adapterSpecifiers = importsByPath.get(injection.adapterImportPath) ?? [];\n if (!importsByPath.has(injection.adapterImportPath)) {\n importsByPath.set(injection.adapterImportPath, adapterSpecifiers);\n }\n adapterSpecifiers.push(`adapter as ${adapterAlias}`);\n }\n }\n\n // Generate grouped imports\n for (const [path, specifiers] of importsByPath) {\n if (specifiers.length === 1) {\n imports.push(`import { ${specifiers[0]} } from \"${path}\";`);\n } else {\n imports.push(`import {\\n ${specifiers.join(\",\\n \")},\\n} from \"${path}\";`);\n }\n }\n }\n\n const extraImports = imports.length > 0 ? `${imports.join(\"\\n\")}\\n` : \"\";\n\n // Generate per-schema definitions\n const schemaBlocks: string[] = [];\n const gqlEntries: string[] = [];\n\n for (const [name, config] of Object.entries($$.schemas)) {\n const schemaVar = `${name}Schema`;\n const scalarBlock = $$.injection.mode === \"inject\" ? scalarAliases.get(name) : config.scalarBlock;\n\n // Get optional adapter\n const adapterVar = adapterAliases.get(name);\n\n // Build type exports\n const typeExports = [`export type Schema_${name} = typeof ${schemaVar} & { _?: never };`];\n if (adapterVar) {\n typeExports.push(`export type Adapter_${name} = typeof ${adapterVar} & { _?: never };`);\n }\n\n schemaBlocks.push(`\nconst ${schemaVar} = {\n label: \"${name}\" as const,\n operations: defineOperationRoots({\n query: \"${config.queryType}\",\n mutation: \"${config.mutationType}\",\n subscription: \"${config.subscriptionType}\",\n }),\n scalar: ${scalarBlock},\n enum: ${config.enumBlock},\n input: ${config.inputBlock},\n object: ${config.objectBlock},\n union: ${config.unionBlock},\n} satisfies AnyGraphqlSchema;\n\n${typeExports.join(\"\\n\")}`);\n\n // Build gql entry with options if needed\n if (adapterVar) {\n const typeParams = `<Schema_${name}, Adapter_${name}>`;\n gqlEntries.push(` ${name}: createGqlElementComposer${typeParams}(${schemaVar}, { adapter: ${adapterVar} })`);\n } else {\n gqlEntries.push(` ${name}: createGqlElementComposer<Schema_${name}>(${schemaVar})`);\n }\n }\n\n return `\\\nimport {\n type AnyGraphqlSchema,\n createGqlElementComposer,\n define,\n defineOperationRoots,\n unsafeInputType,\n unsafeOutputType,\n} from \"@soda-gql/core\";\n${extraImports}\n${schemaBlocks.join(\"\\n\")}\n\nexport const gql = {\n${gqlEntries.join(\",\\n\")}\n};\n`;\n};\n\nexport const generateMultiSchemaModule = (\n schemas: Map<string, DocumentNode>,\n options?: RuntimeGenerationOptions,\n): GeneratedModule => {\n // biome-ignore lint/suspicious/noExplicitAny: complex schema config type\n const schemaConfigs: Record<string, any> = {};\n const allStats = {\n objects: 0,\n enums: 0,\n inputs: 0,\n unions: 0,\n };\n\n for (const [name, document] of schemas.entries()) {\n const schema = createSchemaIndex(document);\n\n const builtinScalarDefinitions = Array.from(builtinScalarTypes.keys()).map((name) =>\n renderScalarDefinition(schema.scalars.get(name) ?? { name, directives: [] }),\n );\n\n const customScalarDefinitions = collectScalarNames(schema)\n .filter((name) => !builtinScalarTypes.has(name))\n .map((name) => {\n const record = schema.scalars.get(name);\n return record ? renderScalarDefinition(record) : \"\";\n })\n .filter((definition) => definition.length > 0);\n\n const allScalarDefinitions = builtinScalarDefinitions.concat(customScalarDefinitions);\n\n const objectTypeNames = collectObjectTypeNames(schema);\n const enumTypeNames = collectEnumTypeNames(schema);\n const inputTypeNames = collectInputTypeNames(schema);\n const unionTypeNames = collectUnionTypeNames(schema);\n\n const scalarBlock = renderPropertyLines({ entries: allScalarDefinitions, indentSize: 4 });\n const enumDefinitions = enumTypeNames\n .map((name) => renderEnumDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const enumBlock = renderPropertyLines({ entries: enumDefinitions, indentSize: 4 });\n const inputDefinitions = inputTypeNames\n .map((name) => renderInputDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const inputBlock = renderPropertyLines({ entries: inputDefinitions, indentSize: 4 });\n const objectDefinitions = objectTypeNames\n .map((name) => renderObjectDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const objectBlock = renderPropertyLines({ entries: objectDefinitions, indentSize: 4 });\n const unionDefinitions = unionTypeNames\n .map((name) => renderUnionDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const unionBlock = renderPropertyLines({ entries: unionDefinitions, indentSize: 4 });\n\n const queryType = schema.operationTypes.query ?? \"Query\";\n const mutationType = schema.operationTypes.mutation ?? \"Mutation\";\n const subscriptionType = schema.operationTypes.subscription ?? \"Subscription\";\n\n schemaConfigs[name] = {\n queryType,\n mutationType,\n subscriptionType,\n scalarBlock,\n enumBlock,\n inputBlock,\n objectBlock,\n unionBlock,\n };\n\n // Accumulate stats\n allStats.objects += objectDefinitions.length;\n allStats.enums += enumDefinitions.length;\n allStats.inputs += inputDefinitions.length;\n allStats.unions += unionDefinitions.length;\n }\n\n const injection: RuntimeTemplateInjection = options?.injection\n ? { mode: \"inject\", perSchema: options.injection }\n : { mode: \"inline\" };\n\n const code = multiRuntimeTemplate({\n schemas: schemaConfigs,\n injection,\n });\n\n return {\n code,\n stats: allStats,\n };\n};\n"],"mappings":";;;AAeA,MAAM,qBAAqB,IAAI,IAAiE;CAC9F,CAAC,MAAM;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CAC7C,CAAC,UAAU;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CACjD,CAAC,OAAO;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CAC9C,CAAC,SAAS;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CAChD,CAAC,WAAW;EAAE,OAAO;EAAW,QAAQ;EAAW,CAAC;CACrD,CAAC;AA8CF,MAAM,gBAAmB,YAA4B,KAAa,YAAoC;CACpG,MAAM,WAAW,WAAW,IAAI,IAAI;AACpC,KAAI,UAAU;AACZ,SAAO;;CAGT,MAAM,UAAU,QAAQ,IAAI;AAC5B,YAAW,IAAI,KAAK,QAAQ;AAC5B,QAAO;;AAGT,MAAM,mBAAmB,QAA0C,WAA6D;AAC9H,KAAI,CAAC,QAAQ;AACX;;AAGF,MAAK,MAAM,SAAS,QAAQ;AAC1B,SAAO,IAAI,MAAM,KAAK,OAAO,MAAM;;;AAIvC,MAAM,kBACJ,QACA,WACS;AACT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,MAAM,OAAO,qBAAqB;EAChC,SAAS;EACT;EACD,CAAC;AAEF,QAAO;EACL;EACA,OAAO;EACR"}
@@ -369,25 +369,27 @@ const collectUnionTypeNames = (schema) => Array.from(schema.unions.keys()).filte
369
369
  const collectScalarNames = (schema) => Array.from(schema.scalars.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
370
370
  const multiRuntimeTemplate = ($$) => {
371
371
  const imports = [];
372
- const adapterAliases = new Map();
373
372
  const scalarAliases = new Map();
373
+ const adapterAliases = new Map();
374
374
  if ($$.injection.mode === "inject") {
375
375
  const importsByPath = new Map();
376
376
  for (const [schemaName, injection] of $$.injection.perSchema) {
377
- const adapterAlias = `adapter_${schemaName}`;
378
377
  const scalarAlias = `scalar_${schemaName}`;
379
- adapterAliases.set(schemaName, adapterAlias);
380
378
  scalarAliases.set(schemaName, scalarAlias);
381
- const adapterSpecifiers = importsByPath.get(injection.adapterImportPath) ?? [];
382
- if (!importsByPath.has(injection.adapterImportPath)) {
383
- importsByPath.set(injection.adapterImportPath, adapterSpecifiers);
384
- }
385
- adapterSpecifiers.push(`adapter as ${adapterAlias}`);
386
379
  const scalarSpecifiers = importsByPath.get(injection.scalarImportPath) ?? [];
387
380
  if (!importsByPath.has(injection.scalarImportPath)) {
388
381
  importsByPath.set(injection.scalarImportPath, scalarSpecifiers);
389
382
  }
390
383
  scalarSpecifiers.push(`scalar as ${scalarAlias}`);
384
+ if (injection.adapterImportPath) {
385
+ const adapterAlias = `adapter_${schemaName}`;
386
+ adapterAliases.set(schemaName, adapterAlias);
387
+ const adapterSpecifiers = importsByPath.get(injection.adapterImportPath) ?? [];
388
+ if (!importsByPath.has(injection.adapterImportPath)) {
389
+ importsByPath.set(injection.adapterImportPath, adapterSpecifiers);
390
+ }
391
+ adapterSpecifiers.push(`adapter as ${adapterAlias}`);
392
+ }
391
393
  }
392
394
  for (const [path, specifiers] of importsByPath) {
393
395
  if (specifiers.length === 1) {
@@ -402,10 +404,13 @@ const multiRuntimeTemplate = ($$) => {
402
404
  const gqlEntries = [];
403
405
  for (const [name, config] of Object.entries($$.schemas)) {
404
406
  const schemaVar = `${name}Schema`;
405
- const adapterVar = $$.injection.mode === "inject" ? adapterAliases.get(name) : `adapter_${name}`;
406
407
  const scalarBlock = $$.injection.mode === "inject" ? scalarAliases.get(name) : config.scalarBlock;
407
- const adapterDefinition = $$.injection.mode === "inject" ? "" : `const ${adapterVar} = createRuntimeAdapter(({ type }) => ({\n nonGraphqlErrorType: type<{ type: "non-graphql-error"; cause: unknown }>(),\n}));\n`;
408
- schemaBlocks.push(`${adapterDefinition}
408
+ const adapterVar = adapterAliases.get(name);
409
+ const typeExports = [`export type Schema_${name} = typeof ${schemaVar} & { _?: never };`];
410
+ if (adapterVar) {
411
+ typeExports.push(`export type Adapter_${name} = typeof ${adapterVar} & { _?: never };`);
412
+ }
413
+ schemaBlocks.push(`
409
414
  const ${schemaVar} = {
410
415
  label: "${name}" as const,
411
416
  operations: defineOperationRoots({
@@ -420,11 +425,14 @@ const ${schemaVar} = {
420
425
  union: ${config.unionBlock},
421
426
  } satisfies AnyGraphqlSchema;
422
427
 
423
- export type Schema_${name} = typeof ${schemaVar} & { _?: never };
424
- export type Adapter_${name} = typeof ${adapterVar} & { _?: never };`);
425
- gqlEntries.push(` ${name}: createGqlElementComposer<Schema_${name}, Adapter_${name}>(${schemaVar})`);
428
+ ${typeExports.join("\n")}`);
429
+ if (adapterVar) {
430
+ const typeParams = `<Schema_${name}, Adapter_${name}>`;
431
+ gqlEntries.push(` ${name}: createGqlElementComposer${typeParams}(${schemaVar}, { adapter: ${adapterVar} })`);
432
+ } else {
433
+ gqlEntries.push(` ${name}: createGqlElementComposer<Schema_${name}>(${schemaVar})`);
434
+ }
426
435
  }
427
- const runtimeImport = $$.injection.mode === "inline" ? "\nimport { createRuntimeAdapter } from \"@soda-gql/runtime\";" : "";
428
436
  return `\
429
437
  import {
430
438
  type AnyGraphqlSchema,
@@ -433,7 +441,7 @@ import {
433
441
  defineOperationRoots,
434
442
  unsafeInputType,
435
443
  unsafeOutputType,
436
- } from "@soda-gql/core";${runtimeImport}
444
+ } from "@soda-gql/core";
437
445
  ${extraImports}
438
446
  ${schemaBlocks.join("\n")}
439
447
 
@@ -533,4 +541,5 @@ Object.defineProperty(exports, 'generateMultiSchemaModule', {
533
541
  get: function () {
534
542
  return generateMultiSchemaModule;
535
543
  }
536
- });
544
+ });
545
+ //# sourceMappingURL=generator-yvSYKjbW.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator-yvSYKjbW.cjs","names":["operationTypes: OperationTypeNames","Kind","modifier: TypeModifier","imports: string[]","schemaBlocks: string[]","gqlEntries: string[]","schemaConfigs: Record<string, any>","name","injection: RuntimeTemplateInjection"],"sources":["../src/generator.ts"],"sourcesContent":["import type { TypeModifier } from \"@soda-gql/core\";\nimport {\n type ConstDirectiveNode,\n type ConstValueNode,\n type DocumentNode,\n type EnumValueDefinitionNode,\n type FieldDefinitionNode,\n type InputValueDefinitionNode,\n Kind,\n type NamedTypeNode,\n type SchemaDefinitionNode,\n type SchemaExtensionNode,\n type TypeNode,\n} from \"graphql\";\n\nconst builtinScalarTypes = new Map<string, { readonly input: string; readonly output: string }>([\n [\"ID\", { input: \"string\", output: \"string\" }],\n [\"String\", { input: \"string\", output: \"string\" }],\n [\"Int\", { input: \"number\", output: \"number\" }],\n [\"Float\", { input: \"number\", output: \"number\" }],\n [\"Boolean\", { input: \"boolean\", output: \"boolean\" }],\n]);\n\ntype OperationTypeNames = {\n query?: string;\n mutation?: string;\n subscription?: string;\n};\n\ntype ObjectRecord = {\n readonly name: string;\n readonly fields: Map<string, FieldDefinitionNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype InputRecord = {\n readonly name: string;\n readonly fields: Map<string, InputValueDefinitionNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype EnumRecord = {\n readonly name: string;\n readonly values: Map<string, EnumValueDefinitionNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype UnionRecord = {\n readonly name: string;\n readonly members: Map<string, NamedTypeNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype ScalarRecord = {\n readonly name: string;\n directives: ConstDirectiveNode[];\n};\n\ntype SchemaIndex = {\n readonly objects: Map<string, ObjectRecord>;\n readonly inputs: Map<string, InputRecord>;\n readonly enums: Map<string, EnumRecord>;\n readonly unions: Map<string, UnionRecord>;\n readonly scalars: Map<string, ScalarRecord>;\n readonly operationTypes: OperationTypeNames;\n};\n\nconst ensureRecord = <T>(collection: Map<string, T>, key: string, factory: (name: string) => T): T => {\n const existing = collection.get(key);\n if (existing) {\n return existing;\n }\n\n const created = factory(key);\n collection.set(key, created);\n return created;\n};\n\nconst addObjectFields = (target: Map<string, FieldDefinitionNode>, fields: readonly FieldDefinitionNode[] | undefined): void => {\n if (!fields) {\n return;\n }\n\n for (const field of fields) {\n target.set(field.name.value, field);\n }\n};\n\nconst addInputFields = (\n target: Map<string, InputValueDefinitionNode>,\n fields: readonly InputValueDefinitionNode[] | undefined,\n): void => {\n if (!fields) {\n return;\n }\n\n for (const field of fields) {\n target.set(field.name.value, field);\n }\n};\n\nconst addEnumValues = (\n target: Map<string, EnumValueDefinitionNode>,\n values: readonly EnumValueDefinitionNode[] | undefined,\n): void => {\n if (!values) {\n return;\n }\n\n for (const value of values) {\n target.set(value.name.value, value);\n }\n};\n\nconst addUnionMembers = (target: Map<string, NamedTypeNode>, members: readonly NamedTypeNode[] | undefined): void => {\n if (!members) {\n return;\n }\n\n for (const member of members) {\n target.set(member.name.value, member);\n }\n};\n\nconst mergeDirectives = (\n existing: ConstDirectiveNode[] | undefined,\n incoming: readonly ConstDirectiveNode[] | undefined,\n precedence: \"definition\" | \"extension\",\n): ConstDirectiveNode[] => {\n const current = existing ?? [];\n const next = incoming ? Array.from(incoming) : [];\n return precedence === \"definition\" ? [...next, ...current] : [...current, ...next];\n};\n\nconst updateOperationTypes = (\n operationTypes: OperationTypeNames,\n definition: SchemaDefinitionNode | SchemaExtensionNode,\n): void => {\n for (const operation of definition.operationTypes ?? []) {\n const typeName = operation.type.name.value;\n switch (operation.operation) {\n case \"query\":\n operationTypes.query = typeName;\n break;\n case \"mutation\":\n operationTypes.mutation = typeName;\n break;\n case \"subscription\":\n operationTypes.subscription = typeName;\n break;\n default:\n break;\n }\n }\n};\n\nexport const createSchemaIndex = (document: DocumentNode): SchemaIndex => {\n const objects = new Map<string, ObjectRecord>();\n const inputs = new Map<string, InputRecord>();\n const enums = new Map<string, EnumRecord>();\n const unions = new Map<string, UnionRecord>();\n const scalars = new Map<string, ScalarRecord>();\n const operationTypes: OperationTypeNames = {};\n\n for (const definition of document.definitions) {\n switch (definition.kind) {\n case Kind.OBJECT_TYPE_DEFINITION:\n case Kind.OBJECT_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.OBJECT_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(objects, definition.name.value, (name) => ({\n name,\n fields: new Map<string, FieldDefinitionNode>(),\n directives: [],\n }));\n addObjectFields(record.fields, definition.fields);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.INPUT_OBJECT_TYPE_DEFINITION:\n case Kind.INPUT_OBJECT_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(inputs, definition.name.value, (name) => ({\n name,\n fields: new Map<string, InputValueDefinitionNode>(),\n directives: [],\n }));\n addInputFields(record.fields, definition.fields);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.ENUM_TYPE_DEFINITION:\n case Kind.ENUM_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.ENUM_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(enums, definition.name.value, (name) => ({\n name,\n values: new Map<string, EnumValueDefinitionNode>(),\n directives: [],\n }));\n addEnumValues(record.values, definition.values);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.UNION_TYPE_DEFINITION:\n case Kind.UNION_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.UNION_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(unions, definition.name.value, (name) => ({\n name,\n members: new Map<string, NamedTypeNode>(),\n directives: [],\n }));\n addUnionMembers(record.members, definition.types);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.SCALAR_TYPE_DEFINITION:\n case Kind.SCALAR_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.SCALAR_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(scalars, definition.name.value, (name) => ({\n name,\n directives: [],\n }));\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.SCHEMA_DEFINITION:\n case Kind.SCHEMA_EXTENSION:\n updateOperationTypes(operationTypes, definition);\n break;\n default:\n break;\n }\n }\n\n if (!operationTypes.query && objects.has(\"Query\")) {\n operationTypes.query = \"Query\";\n }\n if (!operationTypes.mutation && objects.has(\"Mutation\")) {\n operationTypes.mutation = \"Mutation\";\n }\n if (!operationTypes.subscription && objects.has(\"Subscription\")) {\n operationTypes.subscription = \"Subscription\";\n }\n\n return {\n objects,\n inputs,\n enums,\n unions,\n scalars,\n operationTypes,\n } satisfies SchemaIndex;\n};\n\ntype TypeLevel = {\n readonly kind: \"list\" | \"named\";\n readonly nonNull: boolean;\n};\n\nconst collectTypeLevels = (\n type: TypeNode,\n nonNull = false,\n levels: TypeLevel[] = [],\n): { readonly name: string; readonly levels: TypeLevel[] } => {\n if (type.kind === Kind.NON_NULL_TYPE) {\n return collectTypeLevels(type.type, true, levels);\n }\n\n if (type.kind === Kind.LIST_TYPE) {\n levels.push({ kind: \"list\", nonNull });\n return collectTypeLevels(type.type, false, levels);\n }\n\n levels.push({ kind: \"named\", nonNull });\n return { name: type.name.value, levels };\n};\n\nconst buildTypeModifier = (levels: TypeLevel[]): TypeModifier => {\n let modifier: TypeModifier = \"?\";\n\n for (const level of levels.slice().reverse()) {\n if (level.kind === \"named\") {\n // Inner type: always explicit nullable marker\n modifier = level.nonNull ? \"!\" : \"?\";\n continue;\n }\n\n // List type: append []? or []! based on list's nullability\n const listSuffix = level.nonNull ? \"[]!\" : \"[]?\";\n modifier = `${modifier}${listSuffix}` as TypeModifier;\n }\n\n return modifier;\n};\n\nconst parseTypeReference = (type: TypeNode): { readonly name: string; readonly modifier: string } => {\n const { name, levels } = collectTypeLevels(type);\n return { name, modifier: buildTypeModifier(levels) };\n};\n\nconst renderType = (name: string, modifier: string): string => JSON.stringify(`${name}:${modifier}`);\n\nconst isScalarName = (schema: SchemaIndex, name: string): boolean => builtinScalarTypes.has(name) || schema.scalars.has(name);\nconst isEnumName = (schema: SchemaIndex, name: string): boolean => schema.enums.has(name);\nconst _isInputName = (schema: SchemaIndex, name: string): boolean => schema.inputs.has(name);\nconst isUnionName = (schema: SchemaIndex, name: string): boolean => schema.unions.has(name);\nconst isObjectName = (schema: SchemaIndex, name: string): boolean => schema.objects.has(name);\n\nconst renderConstValue = (value: ConstValueNode): string => {\n switch (value.kind) {\n case Kind.NULL:\n return \"null\";\n case Kind.INT:\n case Kind.FLOAT:\n return value.value;\n case Kind.STRING:\n case Kind.ENUM:\n return JSON.stringify(value.value);\n case Kind.BOOLEAN:\n return value.value ? \"true\" : \"false\";\n case Kind.LIST:\n return `[${value.values.map((item) => renderConstValue(item)).join(\", \")}]`;\n case Kind.OBJECT: {\n if (value.fields.length === 0) {\n return \"{}\";\n }\n const entries = value.fields.map((field) => `${field.name.value}: ${renderConstValue(field.value)}`);\n return `{ ${entries.join(\", \")} }`;\n }\n }\n};\n\nconst renderConstArgumentMap = (\n args: readonly { readonly name: { readonly value: string }; readonly value: ConstValueNode }[] | undefined,\n): string => {\n const entries = (args ?? []).map((arg) => `${arg.name.value}: ${renderConstValue(arg.value)}`);\n return renderPropertyLines({ entries, indentSize: 8 });\n};\n\nconst renderDirectives = (directives: readonly ConstDirectiveNode[] | undefined): string => {\n const entries = (directives ?? []).map(\n (directive) => `${directive.name.value}: ${renderConstArgumentMap(directive.arguments)}`,\n );\n return renderPropertyLines({ entries, indentSize: 8 });\n};\n\nconst renderDefaultValue = (value: ConstValueNode | null | undefined): string =>\n value ? `() => (${renderConstValue(value)})` : \"null\";\n\nconst renderInputRef = (schema: SchemaIndex, definition: InputValueDefinitionNode): string => {\n const { name, modifier } = parseTypeReference(definition.type);\n const tuple = renderType(name, modifier);\n const defaultValue = renderDefaultValue(definition.defaultValue ?? null);\n const directives = renderDirectives(definition.directives);\n\n if (isScalarName(schema, name)) {\n return `unsafeInputType.scalar(${tuple}, { default: ${defaultValue}, directives: ${directives} })`;\n }\n\n if (isEnumName(schema, name)) {\n return `unsafeInputType.enum(${tuple}, { default: ${defaultValue}, directives: ${directives} })`;\n }\n\n return `unsafeInputType.input(${tuple}, { default: ${defaultValue}, directives: ${directives} })`;\n};\n\nconst renderArgumentMap = (schema: SchemaIndex, args: readonly InputValueDefinitionNode[] | undefined): string => {\n const entries = [...(args ?? [])]\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((arg) => `${arg.name.value}: ${renderInputRef(schema, arg)}`);\n\n return renderPropertyLines({ entries, indentSize: 8 });\n};\n\nconst renderOutputRef = (schema: SchemaIndex, type: TypeNode, args: readonly InputValueDefinitionNode[] | undefined): string => {\n const { name, modifier } = parseTypeReference(type);\n const modifiedType = renderType(name, modifier);\n const argumentMap = renderArgumentMap(schema, args);\n\n if (isScalarName(schema, name)) {\n return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n if (isEnumName(schema, name)) {\n return `unsafeOutputType.enum(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n if (isUnionName(schema, name)) {\n return `unsafeOutputType.union(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n if (isObjectName(schema, name)) {\n return `unsafeOutputType.object(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap} })`;\n};\n\nconst renderPropertyLines = ({ entries, indentSize }: { entries: string[]; indentSize: number }) => {\n if (entries.length === 0) {\n return \"{}\";\n }\n\n const indent = \" \".repeat(indentSize);\n const lastIndent = \" \".repeat(indentSize - 2);\n return [\"{\", `${indent}${entries.join(`,\\n${indent}`)},`, `${lastIndent}}`].join(`\\n`);\n};\n\nconst renderObjectFields = (schema: SchemaIndex, fields: Map<string, FieldDefinitionNode>): string => {\n const entries = Array.from(fields.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((field) => `${field.name.value}: ${renderOutputRef(schema, field.type, field.arguments)}`);\n\n return renderPropertyLines({ entries, indentSize: 6 });\n};\n\nconst renderInputFields = (schema: SchemaIndex, fields: Map<string, InputValueDefinitionNode>): string => {\n const entries = Array.from(fields.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((field) => `${field.name.value}: ${renderInputRef(schema, field)}`);\n\n return renderPropertyLines({ entries, indentSize: 6 });\n};\n\nconst renderScalarDefinition = (record: ScalarRecord): string => {\n const typeInfo = builtinScalarTypes.get(record.name) ?? { input: \"string\", output: \"string\" };\n const scalarType = `type<{ input: ${typeInfo.input}; output: ${typeInfo.output} }>()`;\n return `${record.name}: define(\"${record.name}\").scalar(${scalarType})`;\n};\n\nconst renderObjectDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.objects.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const fields = renderObjectFields(schema, record.fields);\n return `${record.name}: define(\"${record.name}\").object(${fields})`;\n};\n\nconst renderInputDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.inputs.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const fields = renderInputFields(schema, record.fields);\n return `${record.name}: define(\"${record.name}\").input(${fields})`;\n};\n\nconst renderEnumDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.enums.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const values = Array.from(record.values.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((value) => `${value.name.value}: true`)\n .join(\", \");\n const body = values.length === 0 ? \"{}\" : `{ ${values} }`;\n\n return `${record.name}: define(\"${record.name}\").enum(${body})`;\n};\n\nconst renderUnionDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.unions.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const members = Array.from(record.members.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((member) => `${member.name.value}: true`)\n .join(\", \");\n const body = members.length === 0 ? \"{}\" : `{ ${members} }`;\n\n return `${record.name}: define(\"${record.name}\").union(${body})`;\n};\n\nconst collectObjectTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.objects.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectInputTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.inputs.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectEnumTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.enums.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectUnionTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.unions.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectScalarNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.scalars.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nexport type GeneratedModule = {\n readonly code: string;\n readonly stats: {\n readonly objects: number;\n readonly enums: number;\n readonly inputs: number;\n readonly unions: number;\n };\n};\n\ntype PerSchemaInjection = {\n readonly scalarImportPath: string;\n readonly adapterImportPath?: string;\n};\n\ntype RuntimeTemplateInjection =\n | { readonly mode: \"inline\" }\n | {\n readonly mode: \"inject\";\n readonly perSchema: Map<string, PerSchemaInjection>;\n };\n\nexport type RuntimeGenerationOptions = {\n readonly injection?: Map<string, PerSchemaInjection>;\n};\n\ntype MultiRuntimeTemplateOptions = {\n readonly schemas: Record<\n string,\n {\n readonly queryType: string;\n readonly mutationType: string;\n readonly subscriptionType: string;\n readonly scalarBlock: string;\n readonly enumBlock: string;\n readonly inputBlock: string;\n readonly objectBlock: string;\n readonly unionBlock: string;\n }\n >;\n readonly injection: RuntimeTemplateInjection;\n};\n\nconst multiRuntimeTemplate = ($$: MultiRuntimeTemplateOptions) => {\n // Build imports based on injection mode\n const imports: string[] = [];\n const scalarAliases = new Map<string, string>();\n const adapterAliases = new Map<string, string>();\n\n if ($$.injection.mode === \"inject\") {\n // Group imports by file path\n const importsByPath = new Map<string, string[]>();\n\n for (const [schemaName, injection] of $$.injection.perSchema) {\n const scalarAlias = `scalar_${schemaName}`;\n scalarAliases.set(schemaName, scalarAlias);\n\n // Group scalar import\n const scalarSpecifiers = importsByPath.get(injection.scalarImportPath) ?? [];\n if (!importsByPath.has(injection.scalarImportPath)) {\n importsByPath.set(injection.scalarImportPath, scalarSpecifiers);\n }\n scalarSpecifiers.push(`scalar as ${scalarAlias}`);\n\n // Group adapter import (optional)\n if (injection.adapterImportPath) {\n const adapterAlias = `adapter_${schemaName}`;\n adapterAliases.set(schemaName, adapterAlias);\n const adapterSpecifiers = importsByPath.get(injection.adapterImportPath) ?? [];\n if (!importsByPath.has(injection.adapterImportPath)) {\n importsByPath.set(injection.adapterImportPath, adapterSpecifiers);\n }\n adapterSpecifiers.push(`adapter as ${adapterAlias}`);\n }\n }\n\n // Generate grouped imports\n for (const [path, specifiers] of importsByPath) {\n if (specifiers.length === 1) {\n imports.push(`import { ${specifiers[0]} } from \"${path}\";`);\n } else {\n imports.push(`import {\\n ${specifiers.join(\",\\n \")},\\n} from \"${path}\";`);\n }\n }\n }\n\n const extraImports = imports.length > 0 ? `${imports.join(\"\\n\")}\\n` : \"\";\n\n // Generate per-schema definitions\n const schemaBlocks: string[] = [];\n const gqlEntries: string[] = [];\n\n for (const [name, config] of Object.entries($$.schemas)) {\n const schemaVar = `${name}Schema`;\n const scalarBlock = $$.injection.mode === \"inject\" ? scalarAliases.get(name) : config.scalarBlock;\n\n // Get optional adapter\n const adapterVar = adapterAliases.get(name);\n\n // Build type exports\n const typeExports = [`export type Schema_${name} = typeof ${schemaVar} & { _?: never };`];\n if (adapterVar) {\n typeExports.push(`export type Adapter_${name} = typeof ${adapterVar} & { _?: never };`);\n }\n\n schemaBlocks.push(`\nconst ${schemaVar} = {\n label: \"${name}\" as const,\n operations: defineOperationRoots({\n query: \"${config.queryType}\",\n mutation: \"${config.mutationType}\",\n subscription: \"${config.subscriptionType}\",\n }),\n scalar: ${scalarBlock},\n enum: ${config.enumBlock},\n input: ${config.inputBlock},\n object: ${config.objectBlock},\n union: ${config.unionBlock},\n} satisfies AnyGraphqlSchema;\n\n${typeExports.join(\"\\n\")}`);\n\n // Build gql entry with options if needed\n if (adapterVar) {\n const typeParams = `<Schema_${name}, Adapter_${name}>`;\n gqlEntries.push(` ${name}: createGqlElementComposer${typeParams}(${schemaVar}, { adapter: ${adapterVar} })`);\n } else {\n gqlEntries.push(` ${name}: createGqlElementComposer<Schema_${name}>(${schemaVar})`);\n }\n }\n\n return `\\\nimport {\n type AnyGraphqlSchema,\n createGqlElementComposer,\n define,\n defineOperationRoots,\n unsafeInputType,\n unsafeOutputType,\n} from \"@soda-gql/core\";\n${extraImports}\n${schemaBlocks.join(\"\\n\")}\n\nexport const gql = {\n${gqlEntries.join(\",\\n\")}\n};\n`;\n};\n\nexport const generateMultiSchemaModule = (\n schemas: Map<string, DocumentNode>,\n options?: RuntimeGenerationOptions,\n): GeneratedModule => {\n // biome-ignore lint/suspicious/noExplicitAny: complex schema config type\n const schemaConfigs: Record<string, any> = {};\n const allStats = {\n objects: 0,\n enums: 0,\n inputs: 0,\n unions: 0,\n };\n\n for (const [name, document] of schemas.entries()) {\n const schema = createSchemaIndex(document);\n\n const builtinScalarDefinitions = Array.from(builtinScalarTypes.keys()).map((name) =>\n renderScalarDefinition(schema.scalars.get(name) ?? { name, directives: [] }),\n );\n\n const customScalarDefinitions = collectScalarNames(schema)\n .filter((name) => !builtinScalarTypes.has(name))\n .map((name) => {\n const record = schema.scalars.get(name);\n return record ? renderScalarDefinition(record) : \"\";\n })\n .filter((definition) => definition.length > 0);\n\n const allScalarDefinitions = builtinScalarDefinitions.concat(customScalarDefinitions);\n\n const objectTypeNames = collectObjectTypeNames(schema);\n const enumTypeNames = collectEnumTypeNames(schema);\n const inputTypeNames = collectInputTypeNames(schema);\n const unionTypeNames = collectUnionTypeNames(schema);\n\n const scalarBlock = renderPropertyLines({ entries: allScalarDefinitions, indentSize: 4 });\n const enumDefinitions = enumTypeNames\n .map((name) => renderEnumDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const enumBlock = renderPropertyLines({ entries: enumDefinitions, indentSize: 4 });\n const inputDefinitions = inputTypeNames\n .map((name) => renderInputDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const inputBlock = renderPropertyLines({ entries: inputDefinitions, indentSize: 4 });\n const objectDefinitions = objectTypeNames\n .map((name) => renderObjectDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const objectBlock = renderPropertyLines({ entries: objectDefinitions, indentSize: 4 });\n const unionDefinitions = unionTypeNames\n .map((name) => renderUnionDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const unionBlock = renderPropertyLines({ entries: unionDefinitions, indentSize: 4 });\n\n const queryType = schema.operationTypes.query ?? \"Query\";\n const mutationType = schema.operationTypes.mutation ?? \"Mutation\";\n const subscriptionType = schema.operationTypes.subscription ?? \"Subscription\";\n\n schemaConfigs[name] = {\n queryType,\n mutationType,\n subscriptionType,\n scalarBlock,\n enumBlock,\n inputBlock,\n objectBlock,\n unionBlock,\n };\n\n // Accumulate stats\n allStats.objects += objectDefinitions.length;\n allStats.enums += enumDefinitions.length;\n allStats.inputs += inputDefinitions.length;\n allStats.unions += unionDefinitions.length;\n }\n\n const injection: RuntimeTemplateInjection = options?.injection\n ? { mode: \"inject\", perSchema: options.injection }\n : { mode: \"inline\" };\n\n const code = multiRuntimeTemplate({\n schemas: schemaConfigs,\n injection,\n });\n\n return {\n code,\n stats: allStats,\n };\n};\n"],"mappings":";;;AAeA,MAAM,qBAAqB,IAAI,IAAiE;CAC9F,CAAC,MAAM;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CAC7C,CAAC,UAAU;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CACjD,CAAC,OAAO;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CAC9C,CAAC,SAAS;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CAChD,CAAC,WAAW;EAAE,OAAO;EAAW,QAAQ;EAAW,CAAC;CACrD,CAAC;AA8CF,MAAM,gBAAmB,YAA4B,KAAa,YAAoC;CACpG,MAAM,WAAW,WAAW,IAAI,IAAI;AACpC,KAAI,UAAU;AACZ,SAAO;;CAGT,MAAM,UAAU,QAAQ,IAAI;AAC5B,YAAW,IAAI,KAAK,QAAQ;AAC5B,QAAO;;AAGT,MAAM,mBAAmB,QAA0C,WAA6D;AAC9H,KAAI,CAAC,QAAQ;AACX;;AAGF,MAAK,MAAM,SAAS,QAAQ;AAC1B,SAAO,IAAI,MAAM,KAAK,OAAO,MAAM;;;AAIvC,MAAM,kBACJ,QACA,WACS;AACT,KAAI,CAAC,QAAQ;AACX;;AAGF,MAAK,MAAM,SAAS,QAAQ;AAC1B,SAAO,IAAI,MAAM,KAAK,OAAO,MAAM;;;AAIvC,MAAM,iBACJ,QACA,WACS;AACT,KAAI,CAAC,QAAQ;AACX;;AAGF,MAAK,MAAM,SAAS,QAAQ;AAC1B,SAAO,IAAI,MAAM,KAAK,OAAO,MAAM;;;AAIvC,MAAM,mBAAmB,QAAoC,YAAwD;AACnH,KAAI,CAAC,SAAS;AACZ;;AAGF,MAAK,MAAM,UAAU,SAAS;AAC5B,SAAO,IAAI,OA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AC;EAClF,MAAM,mBAAmB,eACtB,KAAK,WAAS,sBAAsB,QAAQA,OAAK,CAAC,CAClD,QAAQ,eAAe,WAAW,SAAS,EAAE;EAChD,MAAM,aAAa,oBAAoB;GAAE,SAAS;GAAkB,YAAY;GAAG,CAAC;EACpF,MAAM,oBAAoB,gBACvB,KAAK,WAAS,uBAAuB,QAAQA,OAAK,CAAC,CACnD,QAAQ,eAAe,WAAW,SAAS,EAAE;EAChD,MAAM,cAAc,oBAAoB;GAAE,SAAS;GAAmB,YAAY;GAAG,CAAC;EACtF,MAAM,mBAAmB,eACtB,KAAK,WAAS,sBAAsB,QAAQA,OAAK,CAAC,CAClD,QAAQ,eAAe,WAAW,SAAS,EAAE;EAChD,MAAM,aAAa,oBAAoB;GAAE,SAAS;GAAkB,YAAY;GAAG,CAAC;EAEpF,MAAM,YAAY,OAAO,eAAe,SAAS;EACjD,MAAM,eAAe,OAAO,eAAe,YAAY;EACvD,MAAM,mBAAmB,OAAO,eAAe,gBAAgB;AAE/D,gBAAc,QAAQ;GACpB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD;AAGD,WAAS,WAAW,kBAAkB;AACtC,WAAS,SAAS,gBAAgB;AAClC,WAAS,UAAU,iBAAiB;AACpC,WAAS,UAAU,iBAAiB;;CAGtC,MAAMC,YAAsC,SAAS,YACjD;EAAE,MAAM;EAAU,WAAW,QAAQ;EAAW,GAChD,EAAE,MAAM,UAAU;CAEtB,MAAM,OAAO,qBAAqB;EAChC,SAAS;EACT;EACD,CAAC;AAEF,QAAO;EACL;EACA,OAAO;EACR"}
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_generator = require('./generator-CxkxGwRx.cjs');
1
+ const require_generator = require('./generator-yvSYKjbW.cjs');
2
2
  let node_fs = require("node:fs");
3
3
  let node_path = require("node:path");
4
4
  let neverthrow = require("neverthrow");
@@ -9,39 +9,14 @@ let tsdown = require("tsdown");
9
9
  //#region packages/codegen/src/inject-template.ts
10
10
  const templateContents = `\
11
11
  import { defineScalar } from "@soda-gql/core";
12
- import { createRuntimeAdapter } from "@soda-gql/runtime";
13
12
 
14
13
  export const scalar = {
15
- ...defineScalar("ID", ({ type }) => ({
16
- input: type<string>(),
17
- output: type<string>(),
18
- directives: {},
19
- })),
20
- ...defineScalar("String", ({ type }) => ({
21
- input: type<string>(),
22
- output: type<string>(),
23
- directives: {},
24
- })),
25
- ...defineScalar("Int", ({ type }) => ({
26
- input: type<number>(),
27
- output: type<number>(),
28
- directives: {},
29
- })),
30
- ...defineScalar("Float", ({ type }) => ({
31
- input: type<number>(),
32
- output: type<number>(),
33
- directives: {},
34
- })),
35
- ...defineScalar("Boolean", ({ type }) => ({
36
- input: type<boolean>(),
37
- output: type<boolean>(),
38
- directives: {},
39
- })),
14
+ ...defineScalar<"ID", string, string>("ID"),
15
+ ...defineScalar<"String", string, string>("String"),
16
+ ...defineScalar<"Int", number, number>("Int"),
17
+ ...defineScalar<"Float", number, number>("Float"),
18
+ ...defineScalar<"Boolean", boolean, boolean>("Boolean"),
40
19
  } as const;
41
-
42
- export const adapter = createRuntimeAdapter(({ type }) => ({
43
- nonGraphqlErrorType: type<{ type: "non-graphql-error"; cause: unknown }>(),
44
- }));
45
20
  `;
46
21
  const writeInjectTemplate = (outPath) => {
47
22
  const targetPath = (0, node_path.resolve)(outPath);
@@ -182,62 +157,49 @@ const toImportSpecifier = (fromPath, targetPath, options) => {
182
157
  const withoutExt = currentExt ? withPrefix.slice(0, -currentExt.length) : withPrefix;
183
158
  return `${withoutExt}${runtimeExt}`;
184
159
  };
185
- const runMultiSchemaCodegen = async (options) => {
160
+ const runCodegen = async (options) => {
186
161
  const outPath = (0, node_path.resolve)(options.outPath);
187
- const runtimeAdapters = options.runtimeAdapters ?? (options.injectFromPath ? { default: options.injectFromPath } : {});
188
- const scalars = options.scalars ?? (options.injectFromPath ? { default: options.injectFromPath } : {});
189
- const adapterPaths = new Map();
190
- const scalarPaths = new Map();
191
- for (const [schemaName, adapterPath] of Object.entries(runtimeAdapters)) {
192
- const resolvedPath = (0, node_path.resolve)(adapterPath);
193
- if (!(0, node_fs.existsSync)(resolvedPath)) {
162
+ const importSpecifierOptions = { includeExtension: options.importExtension };
163
+ for (const [schemaName, schemaConfig] of Object.entries(options.schemas)) {
164
+ const scalarPath = (0, node_path.resolve)(schemaConfig.inject.scalars);
165
+ if (!(0, node_fs.existsSync)(scalarPath)) {
194
166
  return (0, neverthrow.err)({
195
167
  code: "INJECT_MODULE_NOT_FOUND",
196
- message: `Runtime adapter module not found for schema '${schemaName}': ${resolvedPath}`,
197
- injectPath: resolvedPath
168
+ message: `Scalar module not found for schema '${schemaName}': ${scalarPath}`,
169
+ injectPath: scalarPath
198
170
  });
199
171
  }
200
- adapterPaths.set(schemaName, resolvedPath);
201
- }
202
- for (const [schemaName, scalarPath] of Object.entries(scalars)) {
203
- const resolvedPath = (0, node_path.resolve)(scalarPath);
204
- if (!(0, node_fs.existsSync)(resolvedPath)) {
205
- return (0, neverthrow.err)({
206
- code: "INJECT_MODULE_NOT_FOUND",
207
- message: `Scalar module not found for schema '${schemaName}': ${resolvedPath}`,
208
- injectPath: resolvedPath
209
- });
172
+ if (schemaConfig.inject.adapter) {
173
+ const adapterPath = (0, node_path.resolve)(schemaConfig.inject.adapter);
174
+ if (!(0, node_fs.existsSync)(adapterPath)) {
175
+ return (0, neverthrow.err)({
176
+ code: "INJECT_MODULE_NOT_FOUND",
177
+ message: `Adapter module not found for schema '${schemaName}': ${adapterPath}`,
178
+ injectPath: adapterPath
179
+ });
180
+ }
210
181
  }
211
- scalarPaths.set(schemaName, resolvedPath);
212
182
  }
213
183
  const schemas = new Map();
214
184
  const schemaHashes = {};
215
- for (const [name, schemaPath] of Object.entries(options.schemas)) {
216
- const result = await loadSchema(schemaPath).match((doc) => Promise.resolve((0, neverthrow.ok)(doc)), (error) => Promise.resolve((0, neverthrow.err)(error)));
185
+ for (const [name, schemaConfig] of Object.entries(options.schemas)) {
186
+ const result = await loadSchema(schemaConfig.schema).match((doc) => Promise.resolve((0, neverthrow.ok)(doc)), (error) => Promise.resolve((0, neverthrow.err)(error)));
217
187
  if (result.isErr()) {
218
188
  return (0, neverthrow.err)(result.error);
219
189
  }
220
190
  schemas.set(name, result.value);
221
191
  }
222
192
  const injectionConfig = new Map();
223
- for (const schemaName of schemas.keys()) {
224
- const adapterPath = adapterPaths.get(schemaName);
225
- const scalarPath = scalarPaths.get(schemaName);
226
- if (!adapterPath || !scalarPath) {
227
- return (0, neverthrow.err)({
228
- code: "INJECT_MODULE_REQUIRED",
229
- message: `Missing adapter or scalar configuration for schema '${schemaName}'`
230
- });
231
- }
232
- const importSpecifierOptions = { includeExtension: options.importExtension };
193
+ for (const [schemaName, schemaConfig] of Object.entries(options.schemas)) {
194
+ const injectConfig = schemaConfig.inject;
233
195
  injectionConfig.set(schemaName, {
234
- adapterImportPath: toImportSpecifier(outPath, adapterPath, importSpecifierOptions),
235
- scalarImportPath: toImportSpecifier(outPath, scalarPath, importSpecifierOptions)
196
+ scalarImportPath: toImportSpecifier(outPath, (0, node_path.resolve)(injectConfig.scalars), importSpecifierOptions),
197
+ ...injectConfig.adapter ? { adapterImportPath: toImportSpecifier(outPath, (0, node_path.resolve)(injectConfig.adapter), importSpecifierOptions) } : {}
236
198
  });
237
199
  }
238
200
  const { code } = require_generator.generateMultiSchemaModule(schemas, { injection: injectionConfig });
239
201
  for (const [name, document] of schemas.entries()) {
240
- const schemaIndex = (await Promise.resolve().then(() => require("./generator-DRMPDjI-.cjs"))).createSchemaIndex(document);
202
+ const schemaIndex = (await Promise.resolve().then(() => require("./generator-9N1ZJrzm.cjs"))).createSchemaIndex(document);
241
203
  const objects = Array.from(schemaIndex.objects.keys()).filter((n) => !n.startsWith("__")).length;
242
204
  const enums = Array.from(schemaIndex.enums.keys()).filter((n) => !n.startsWith("__")).length;
243
205
  const inputs = Array.from(schemaIndex.inputs.keys()).filter((n) => !n.startsWith("__")).length;
@@ -269,5 +231,6 @@ const runMultiSchemaCodegen = async (options) => {
269
231
  //#endregion
270
232
  exports.hashSchema = hashSchema;
271
233
  exports.loadSchema = loadSchema;
272
- exports.runMultiSchemaCodegen = runMultiSchemaCodegen;
273
- exports.writeInjectTemplate = writeInjectTemplate;
234
+ exports.runCodegen = runCodegen;
235
+ exports.writeInjectTemplate = writeInjectTemplate;
236
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["extensionMap: Record<string, string>","withPrefix","currentExt","schemaHashes: Record<string, { schemaHash: string; objects: number; enums: number; inputs: number; unions: number }>","generateMultiSchemaModule"],"sources":["../src/inject-template.ts","../src/file.ts","../src/schema.ts","../src/tsdown-bundle.ts","../src/runner.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nconst templateContents = `\\\nimport { defineScalar } from \"@soda-gql/core\";\n\nexport const scalar = {\n ...defineScalar<\"ID\", string, string>(\"ID\"),\n ...defineScalar<\"String\", string, string>(\"String\"),\n ...defineScalar<\"Int\", number, number>(\"Int\"),\n ...defineScalar<\"Float\", number, number>(\"Float\"),\n ...defineScalar<\"Boolean\", boolean, boolean>(\"Boolean\"),\n} as const;\n`;\n\nexport const writeInjectTemplate = (outPath: string) => {\n const targetPath = resolve(outPath);\n\n try {\n if (existsSync(targetPath)) {\n return err<void, CodegenError>({\n code: \"INJECT_TEMPLATE_EXISTS\",\n message: `Inject module already exists: ${targetPath}`,\n outPath: targetPath,\n });\n }\n\n mkdirSync(dirname(targetPath), { recursive: true });\n writeFileSync(targetPath, `${templateContents}\\n`);\n return ok<void, CodegenError>(undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<void, CodegenError>({\n code: \"INJECT_TEMPLATE_FAILED\",\n message,\n outPath: targetPath,\n });\n }\n};\n\nexport const getInjectTemplate = (): string => `${templateContents}\\n`;\n","import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nexport const writeModule = (outPath: string, contents: string) => {\n const targetPath = resolve(outPath);\n\n try {\n mkdirSync(dirname(targetPath), { recursive: true });\n writeFileSync(targetPath, contents);\n return ok<void, CodegenError>(undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<void, CodegenError>({\n code: \"EMIT_FAILED\",\n message,\n outPath: targetPath,\n });\n }\n};\n","import { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { type DocumentNode, parse, print } from \"graphql\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nexport const loadSchema = (schemaPath: string) => {\n const resolvedPath = resolve(schemaPath);\n\n if (!existsSync(resolvedPath)) {\n return err<DocumentNode, CodegenError>({\n code: \"SCHEMA_NOT_FOUND\",\n message: `Schema file not found at ${resolvedPath}`,\n schemaPath: resolvedPath,\n });\n }\n\n try {\n const schemaSource = readFileSync(resolvedPath, \"utf8\");\n const document = parse(schemaSource);\n return ok<DocumentNode, CodegenError>(document);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<DocumentNode, CodegenError>({\n code: \"SCHEMA_INVALID\",\n message: `SchemaValidationError: ${message}`,\n schemaPath: resolvedPath,\n });\n }\n};\n\nexport const hashSchema = (document: DocumentNode): string => createHash(\"sha256\").update(print(document)).digest(\"hex\");\n","import { dirname, extname } from \"node:path\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport { build, type Options } from \"tsdown\";\nimport type { CodegenError } from \"./types\";\n\nexport type BundleResult = {\n readonly cjsPath: string;\n};\n\nexport const bundleGraphqlSystem = async (sourcePath: string): Promise<Result<BundleResult, CodegenError>> => {\n try {\n const sourceDir = dirname(sourcePath);\n const sourceExt = extname(sourcePath);\n const baseName = sourcePath.slice(0, -sourceExt.length);\n\n await build({\n config: false,\n entry: sourcePath,\n format: [\"cjs\"],\n platform: \"node\",\n external: [\"@soda-gql/core\", \"@soda-gql/runtime\"],\n dts: false,\n outDir: sourceDir,\n fixedExtension: true,\n clean: false,\n minify: false,\n sourcemap: false,\n treeshake: false,\n } satisfies Options);\n\n const cjsPath = `${baseName}.cjs`;\n\n return ok({ cjsPath });\n } catch (error) {\n return err({\n code: \"EMIT_FAILED\",\n message: `Failed to bundle graphql-system: ${error instanceof Error ? error.message : String(error)}`,\n outPath: sourcePath,\n });\n }\n};\n","import { existsSync } from \"node:fs\";\nimport { basename, dirname, extname, relative, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\nimport { writeModule } from \"./file\";\nimport { generateMultiSchemaModule } from \"./generator\";\nimport { hashSchema, loadSchema } from \"./schema\";\nimport { bundleGraphqlSystem } from \"./tsdown-bundle\";\nimport type { CodegenOptions, CodegenResult, CodegenSuccess } from \"./types\";\n\nconst extensionMap: Record<string, string> = {\n \".ts\": \".js\",\n \".tsx\": \".js\",\n \".mts\": \".mjs\",\n \".cts\": \".cjs\",\n \".js\": \".js\",\n \".mjs\": \".mjs\",\n \".cjs\": \".cjs\",\n};\n\ntype ImportSpecifierOptions = {\n includeExtension?: boolean;\n};\n\nconst toImportSpecifier = (fromPath: string, targetPath: string, options?: ImportSpecifierOptions): string => {\n const fromDir = dirname(fromPath);\n const normalized = relative(fromDir, targetPath).replace(/\\\\/g, \"/\");\n const sourceExt = extname(targetPath);\n\n // When includeExtension is false (default), strip the extension entirely\n if (!options?.includeExtension) {\n if (normalized.length === 0) {\n return `./${basename(targetPath, sourceExt)}`;\n }\n const withPrefix = normalized.startsWith(\".\") ? normalized : `./${normalized}`;\n const currentExt = extname(withPrefix);\n return currentExt ? withPrefix.slice(0, -currentExt.length) : withPrefix;\n }\n\n // When includeExtension is true, convert to runtime extension\n const runtimeExt = extensionMap[sourceExt] ?? sourceExt;\n\n if (normalized.length === 0) {\n const base = runtimeExt !== sourceExt ? basename(targetPath, sourceExt) : basename(targetPath);\n return `./${base}${runtimeExt}`;\n }\n\n const withPrefix = normalized.startsWith(\".\") ? normalized : `./${normalized}`;\n if (!runtimeExt) {\n return withPrefix;\n }\n if (withPrefix.endsWith(runtimeExt)) {\n return withPrefix;\n }\n\n const currentExt = extname(withPrefix);\n const withoutExt = currentExt ? withPrefix.slice(0, -currentExt.length) : withPrefix;\n return `${withoutExt}${runtimeExt}`;\n};\n\nexport const runCodegen = async (options: CodegenOptions): Promise<CodegenResult> => {\n const outPath = resolve(options.outPath);\n const importSpecifierOptions = { includeExtension: options.importExtension };\n\n // Validate that all schema and inject files exist\n for (const [schemaName, schemaConfig] of Object.entries(options.schemas)) {\n const scalarPath = resolve(schemaConfig.inject.scalars);\n if (!existsSync(scalarPath)) {\n return err({\n code: \"INJECT_MODULE_NOT_FOUND\",\n message: `Scalar module not found for schema '${schemaName}': ${scalarPath}`,\n injectPath: scalarPath,\n });\n }\n\n if (schemaConfig.inject.adapter) {\n const adapterPath = resolve(schemaConfig.inject.adapter);\n if (!existsSync(adapterPath)) {\n return err({\n code: \"INJECT_MODULE_NOT_FOUND\",\n message: `Adapter module not found for schema '${schemaName}': ${adapterPath}`,\n injectPath: adapterPath,\n });\n }\n }\n }\n\n // Load all schemas\n const schemas = new Map<string, import(\"graphql\").DocumentNode>();\n const schemaHashes: Record<string, { schemaHash: string; objects: number; enums: number; inputs: number; unions: number }> = {};\n\n for (const [name, schemaConfig] of Object.entries(options.schemas)) {\n const result = await loadSchema(schemaConfig.schema).match(\n (doc) => Promise.resolve(ok(doc)),\n (error) => Promise.resolve(err(error)),\n );\n\n if (result.isErr()) {\n return err(result.error);\n }\n\n schemas.set(name, result.value);\n }\n\n // Build injection config for each schema\n const injectionConfig = new Map<\n string,\n {\n scalarImportPath: string;\n adapterImportPath?: string;\n }\n >();\n\n for (const [schemaName, schemaConfig] of Object.entries(options.schemas)) {\n const injectConfig = schemaConfig.inject;\n\n injectionConfig.set(schemaName, {\n scalarImportPath: toImportSpecifier(outPath, resolve(injectConfig.scalars), importSpecifierOptions),\n ...(injectConfig.adapter\n ? { adapterImportPath: toImportSpecifier(outPath, resolve(injectConfig.adapter), importSpecifierOptions) }\n : {}),\n });\n }\n\n // Generate multi-schema module\n const { code } = generateMultiSchemaModule(schemas, {\n injection: injectionConfig,\n });\n\n // Calculate individual schema stats and hashes\n for (const [name, document] of schemas.entries()) {\n const schemaIndex = (await import(\"./generator\")).createSchemaIndex(document);\n const objects = Array.from(schemaIndex.objects.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const enums = Array.from(schemaIndex.enums.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const inputs = Array.from(schemaIndex.inputs.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const unions = Array.from(schemaIndex.unions.keys()).filter((n) => !n.startsWith(\"__\")).length;\n\n schemaHashes[name] = {\n schemaHash: hashSchema(document),\n objects,\n enums,\n inputs,\n unions,\n };\n }\n\n // Write the module\n const writeResult = await writeModule(outPath, code).match(\n () => Promise.resolve(ok(undefined)),\n (error) => Promise.resolve(err(error)),\n );\n\n if (writeResult.isErr()) {\n return err(writeResult.error);\n }\n\n // Bundle the generated module with tsdown\n const bundleOutcome = await bundleGraphqlSystem(outPath);\n const bundleResult = bundleOutcome.match(\n (result) => ok(result),\n (error) => err(error),\n );\n\n if (bundleResult.isErr()) {\n return err(bundleResult.error);\n }\n\n return ok({\n schemas: schemaHashes,\n outPath,\n cjsPath: bundleResult.value.cjsPath,\n } satisfies CodegenSuccess);\n};\n"],"mappings":";;;;;;;;;AAMA,MAAM,mBAAmB;;;;;;;;;;;AAYzB,MAAa,uBAAuB,YAAoB;CACtD,MAAM,oCAAqB,QAAQ;AAEnC,KAAI;AACF,8BAAe,WAAW,EAAE;AAC1B,8BAA+B;IAC7B,MAAM;IACN,SAAS,iCAAiC;IAC1C,SAAS;IACV,CAAC;;AAGJ,gDAAkB,WAAW,EAAE,EAAE,WAAW,MAAM,CAAC;AACnD,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AAS,EAClD,WAAW,iBACZ,CAAC;AAGF,MAAK,MAAM,CAAC,MAAM,aAAa,QAAQ,SAAS,EAAE;EAChD,MAAM,eAAe,2CAAM,8BAAuB,kBAAkB,SAAS;EAC7E,MAAM,UAAU,MAAM,KAAK,YAAY,QAAQ,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;EAC1F,MAAM,QAAQ,MAAM,KAAK,YAAY,MAAM,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;EACtF,MAAM,SAAS,MAAM,KAAK,YAAY,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;EACxF,MAAM,SAAS,MAAM,KAAK,YAAY,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;AAExF,eAAa,QAAQ;GACnB,YAAY,WAAW,SAAS;GAChC;GACA;GACA;GACA;GACD;;CAIH,MAAM,cAAc,MAAM,YAAY,SAAS,KAAK,CAAC,YAC7C,QAAQ,2BAAW,UAAU,CAAC,GACnC,UAAU,QAAQ,4BAAY,MAAM,CAAC,CACvC;AAED,KAAI,YAAY,OAAO,EAAE;AACvB,6BAAW,YAAY,MAAM;;CAI/B,MAAM,gBAAgB,MAAM,oBAAoB,QAAQ;CACxD,MAAM,eAAe,cAAc,OAChC,8BAAc,OAAO,GACrB,8BAAc,MAAM,CACtB;AAED,KAAI,aAAa,OAAO,EAAE;AACxB,6BAAW,aAAa,MAAM;;AAGhC,2BAAU;EACR,SAAS;EACT;EACA,SAAS,aAAa,MAAM;EAC7B,CAA0B"}
package/dist/index.d.cts CHANGED
@@ -4,19 +4,18 @@ import { DocumentNode } from "graphql";
4
4
 
5
5
  //#region packages/codegen/src/types.d.ts
6
6
  type CodegenFormat = "json" | "human";
7
- type CodegenOptions = {
8
- readonly schemaPath: string;
9
- readonly outPath: string;
10
- readonly format: CodegenFormat;
11
- readonly injectFromPath: string;
7
+ type CodegenInjectConfig = {
8
+ readonly scalars: string;
9
+ readonly adapter?: string;
12
10
  };
13
- type MultiSchemaCodegenOptions = {
14
- readonly schemas: Record<string, string>;
11
+ type CodegenSchemaConfig = {
12
+ readonly schema: string;
13
+ readonly inject: CodegenInjectConfig;
14
+ };
15
+ type CodegenOptions = {
16
+ readonly schemas: Record<string, CodegenSchemaConfig>;
15
17
  readonly outPath: string;
16
18
  readonly format: CodegenFormat;
17
- readonly runtimeAdapters?: Record<string, string>;
18
- readonly scalars?: Record<string, string>;
19
- readonly injectFromPath?: string;
20
19
  readonly importExtension?: boolean;
21
20
  };
22
21
  type CodegenCliCommand = {
@@ -56,14 +55,6 @@ type CodegenError = {
56
55
  readonly outPath: string;
57
56
  };
58
57
  type CodegenSuccess = {
59
- readonly schemaHash: string;
60
- readonly outPath: string;
61
- readonly objects: number;
62
- readonly enums: number;
63
- readonly inputs: number;
64
- readonly unions: number;
65
- };
66
- type MultiSchemaCodegenSuccess = {
67
58
  readonly schemas: Record<string, {
68
59
  readonly schemaHash: string;
69
60
  readonly objects: number;
@@ -75,18 +66,17 @@ type MultiSchemaCodegenSuccess = {
75
66
  readonly cjsPath: string;
76
67
  };
77
68
  type CodegenResult = Result<CodegenSuccess, CodegenError>;
78
- type MultiSchemaCodegenResult = Result<MultiSchemaCodegenSuccess, CodegenError>;
79
69
  //#endregion
80
70
  //#region packages/codegen/src/inject-template.d.ts
81
71
  declare const writeInjectTemplate: (outPath: string) => neverthrow0.Err<void, CodegenError> | neverthrow0.Ok<void, CodegenError>;
82
72
  declare const getInjectTemplate: () => string;
83
73
  //#endregion
84
74
  //#region packages/codegen/src/runner.d.ts
85
- declare const runMultiSchemaCodegen: (options: MultiSchemaCodegenOptions) => Promise<MultiSchemaCodegenResult>;
75
+ declare const runCodegen: (options: CodegenOptions) => Promise<CodegenResult>;
86
76
  //#endregion
87
77
  //#region packages/codegen/src/schema.d.ts
88
78
  declare const loadSchema: (schemaPath: string) => neverthrow0.Err<DocumentNode, CodegenError> | neverthrow0.Ok<DocumentNode, CodegenError>;
89
79
  declare const hashSchema: (document: DocumentNode) => string;
90
80
  //#endregion
91
- export { type CodegenCliCommand, type CodegenError, type CodegenFormat, type MultiSchemaCodegenOptions, type MultiSchemaCodegenResult, type MultiSchemaCodegenSuccess, hashSchema, loadSchema, runMultiSchemaCodegen, writeInjectTemplate };
81
+ export { type CodegenCliCommand, type CodegenError, type CodegenFormat, type CodegenInjectConfig, type CodegenOptions, type CodegenResult, type CodegenSchemaConfig, type CodegenSuccess, hashSchema, loadSchema, runCodegen, writeInjectTemplate };
92
82
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/inject-template.ts","../src/runner.ts","../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;KAEY,aAAA;KAEA,cAAA;;;EAFA,SAAA,MAAA,EAKO,aALM;EAEb,SAAA,cAAc,EAAA,MAGP;AAInB,CAAA;AACoB,KADR,yBAAA,GACQ;EAED,SAAA,OAAA,EAFC,MAED,CAAA,MAAA,EAAA,MAAA,CAAA;EACU,SAAA,OAAA,EAAA,MAAA;EACR,SAAA,MAAA,EAFF,aAEE;EAAM,SAAA,eAAA,CAAA,EADE,MACF,CAAA,MAAA,EAAA,MAAA,CAAA;EAKf,SAAA,OAAA,CAAA,EALS,MAKQ,CAAA,MAGL,EAAA,MAAA,CAAA;EAQZ,SAAA,cAAY,CAAA,EAAA,MAAA;EAoCZ,SAAA,eAAc,CAAA,EAAA,OAAA;AAS1B,CAAA;AAeY,KAvEA,iBAAA,GAuEa;EAAU,SAAA,IAAA,EAAA,UAAA;EAAgB,SAAA,OAAA,EApE3B,cAoE2B;CAAvB,GAAA;EAAM,SAAA,IAAA,EAAA,oBAAA;EACtB,SAAA,OAAA,EAAA,MAAA;EAAkC,SAAA,MAAA,EAhEvB,aAgEuB;CAA2B;AA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//#region packages/codegen/src/types.d.ts
6
6
  type CodegenFormat = "json" | "human";
7
- type CodegenOptions = {
8
- readonly schemaPath: string;
9
- readonly outPath: string;
10
- readonly format: CodegenFormat;
11
- readonly injectFromPath: string;
7
+ type CodegenInjectConfig = {
8
+ readonly scalars: string;
9
+ readonly adapter?: string;
12
10
  };
13
- type MultiSchemaCodegenOptions = {
14
- readonly schemas: Record<string, string>;
11
+ type CodegenSchemaConfig = {
12
+ readonly schema: string;
13
+ readonly inject: CodegenInjectConfig;
14
+ };
15
+ type CodegenOptions = {
16
+ readonly schemas: Record<string, CodegenSchemaConfig>;
15
17
  readonly outPath: string;
16
18
  readonly format: CodegenFormat;
17
- readonly runtimeAdapters?: Record<string, string>;
18
- readonly scalars?: Record<string, string>;
19
- readonly injectFromPath?: string;
20
19
  readonly importExtension?: boolean;
21
20
  };
22
21
  type CodegenCliCommand = {
@@ -56,14 +55,6 @@ type CodegenError = {
56
55
  readonly outPath: string;
57
56
  };
58
57
  type CodegenSuccess = {
59
- readonly schemaHash: string;
60
- readonly outPath: string;
61
- readonly objects: number;
62
- readonly enums: number;
63
- readonly inputs: number;
64
- readonly unions: number;
65
- };
66
- type MultiSchemaCodegenSuccess = {
67
58
  readonly schemas: Record<string, {
68
59
  readonly schemaHash: string;
69
60
  readonly objects: number;
@@ -75,18 +66,17 @@ type MultiSchemaCodegenSuccess = {
75
66
  readonly cjsPath: string;
76
67
  };
77
68
  type CodegenResult = Result<CodegenSuccess, CodegenError>;
78
- type MultiSchemaCodegenResult = Result<MultiSchemaCodegenSuccess, CodegenError>;
79
69
  //#endregion
80
70
  //#region packages/codegen/src/inject-template.d.ts
81
71
  declare const writeInjectTemplate: (outPath: string) => neverthrow0.Err<void, CodegenError> | neverthrow0.Ok<void, CodegenError>;
82
72
  declare const getInjectTemplate: () => string;
83
73
  //#endregion
84
74
  //#region packages/codegen/src/runner.d.ts
85
- declare const runMultiSchemaCodegen: (options: MultiSchemaCodegenOptions) => Promise<MultiSchemaCodegenResult>;
75
+ declare const runCodegen: (options: CodegenOptions) => Promise<CodegenResult>;
86
76
  //#endregion
87
77
  //#region packages/codegen/src/schema.d.ts
88
78
  declare const loadSchema: (schemaPath: string) => neverthrow0.Err<DocumentNode, CodegenError> | neverthrow0.Ok<DocumentNode, CodegenError>;
89
79
  declare const hashSchema: (document: DocumentNode) => string;
90
80
  //#endregion
91
- export { type CodegenCliCommand, type CodegenError, type CodegenFormat, type MultiSchemaCodegenOptions, type MultiSchemaCodegenResult, type MultiSchemaCodegenSuccess, hashSchema, loadSchema, runMultiSchemaCodegen, writeInjectTemplate };
81
+ export { type CodegenCliCommand, type CodegenError, type CodegenFormat, type CodegenInjectConfig, type CodegenOptions, type CodegenResult, type CodegenSchemaConfig, type CodegenSuccess, hashSchema, loadSchema, runCodegen, writeInjectTemplate };
92
82
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/inject-template.ts","../src/runner.ts","../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;KAEY,aAAA;KAEA,cAAA;;;EAFA,SAAA,MAAA,EAKO,aALM;EAEb,SAAA,cAAc,EAAA,MAGP;AAInB,CAAA;AACoB,KADR,yBAAA,GACQ;EAED,SAAA,OAAA,EAFC,MAED,CAAA,MAAA,EAAA,MAAA,CAAA;EACU,SAAA,OAAA,EAAA,MAAA;EACR,SAAA,MAAA,EAFF,aAEE;EAAM,SAAA,eAAA,CAAA,EADE,MACF,CAAA,MAAA,EAAA,MAAA,CAAA;EAKf,SAAA,OAAA,CAAA,EALS,MAKQ,CAAA,MAGL,EAAA,MAAA,CAAA;EAQZ,SAAA,cAAY,CAAA,EAAA,MAAA;EAoCZ,SAAA,eAAc,CAAA,EAAA,OAAA;AAS1B,CAAA;AAeY,KAvEA,iBAAA,GAuEa;EAAU,SAAA,IAAA,EAAA,UAAA;EAAgB,SAAA,OAAA,EApE3B,cAoE2B;CAAvB,GAAA;EAAM,SAAA,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A;cAyBhC,uBAAwB"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as generateMultiSchemaModule } from "./generator-DSOZFGSD.mjs";
1
+ import { n as generateMultiSchemaModule } from "./generator-HYfj5Qkm.mjs";
2
2
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { basename, dirname, extname, relative, resolve } from "node:path";
4
4
  import { err, ok } from "neverthrow";
@@ -9,39 +9,14 @@ import { build } from "tsdown";
9
9
  //#region packages/codegen/src/inject-template.ts
10
10
  const templateContents = `\
11
11
  import { defineScalar } from "@soda-gql/core";
12
- import { createRuntimeAdapter } from "@soda-gql/runtime";
13
12
 
14
13
  export const scalar = {
15
- ...defineScalar("ID", ({ type }) => ({
16
- input: type<string>(),
17
- output: type<string>(),
18
- directives: {},
19
- })),
20
- ...defineScalar("String", ({ type }) => ({
21
- input: type<string>(),
22
- output: type<string>(),
23
- directives: {},
24
- })),
25
- ...defineScalar("Int", ({ type }) => ({
26
- input: type<number>(),
27
- output: type<number>(),
28
- directives: {},
29
- })),
30
- ...defineScalar("Float", ({ type }) => ({
31
- input: type<number>(),
32
- output: type<number>(),
33
- directives: {},
34
- })),
35
- ...defineScalar("Boolean", ({ type }) => ({
36
- input: type<boolean>(),
37
- output: type<boolean>(),
38
- directives: {},
39
- })),
14
+ ...defineScalar<"ID", string, string>("ID"),
15
+ ...defineScalar<"String", string, string>("String"),
16
+ ...defineScalar<"Int", number, number>("Int"),
17
+ ...defineScalar<"Float", number, number>("Float"),
18
+ ...defineScalar<"Boolean", boolean, boolean>("Boolean"),
40
19
  } as const;
41
-
42
- export const adapter = createRuntimeAdapter(({ type }) => ({
43
- nonGraphqlErrorType: type<{ type: "non-graphql-error"; cause: unknown }>(),
44
- }));
45
20
  `;
46
21
  const writeInjectTemplate = (outPath) => {
47
22
  const targetPath = resolve(outPath);
@@ -182,62 +157,49 @@ const toImportSpecifier = (fromPath, targetPath, options) => {
182
157
  const withoutExt = currentExt ? withPrefix.slice(0, -currentExt.length) : withPrefix;
183
158
  return `${withoutExt}${runtimeExt}`;
184
159
  };
185
- const runMultiSchemaCodegen = async (options) => {
160
+ const runCodegen = async (options) => {
186
161
  const outPath = resolve(options.outPath);
187
- const runtimeAdapters = options.runtimeAdapters ?? (options.injectFromPath ? { default: options.injectFromPath } : {});
188
- const scalars = options.scalars ?? (options.injectFromPath ? { default: options.injectFromPath } : {});
189
- const adapterPaths = new Map();
190
- const scalarPaths = new Map();
191
- for (const [schemaName, adapterPath] of Object.entries(runtimeAdapters)) {
192
- const resolvedPath = resolve(adapterPath);
193
- if (!existsSync(resolvedPath)) {
162
+ const importSpecifierOptions = { includeExtension: options.importExtension };
163
+ for (const [schemaName, schemaConfig] of Object.entries(options.schemas)) {
164
+ const scalarPath = resolve(schemaConfig.inject.scalars);
165
+ if (!existsSync(scalarPath)) {
194
166
  return err({
195
167
  code: "INJECT_MODULE_NOT_FOUND",
196
- message: `Runtime adapter module not found for schema '${schemaName}': ${resolvedPath}`,
197
- injectPath: resolvedPath
168
+ message: `Scalar module not found for schema '${schemaName}': ${scalarPath}`,
169
+ injectPath: scalarPath
198
170
  });
199
171
  }
200
- adapterPaths.set(schemaName, resolvedPath);
201
- }
202
- for (const [schemaName, scalarPath] of Object.entries(scalars)) {
203
- const resolvedPath = resolve(scalarPath);
204
- if (!existsSync(resolvedPath)) {
205
- return err({
206
- code: "INJECT_MODULE_NOT_FOUND",
207
- message: `Scalar module not found for schema '${schemaName}': ${resolvedPath}`,
208
- injectPath: resolvedPath
209
- });
172
+ if (schemaConfig.inject.adapter) {
173
+ const adapterPath = resolve(schemaConfig.inject.adapter);
174
+ if (!existsSync(adapterPath)) {
175
+ return err({
176
+ code: "INJECT_MODULE_NOT_FOUND",
177
+ message: `Adapter module not found for schema '${schemaName}': ${adapterPath}`,
178
+ injectPath: adapterPath
179
+ });
180
+ }
210
181
  }
211
- scalarPaths.set(schemaName, resolvedPath);
212
182
  }
213
183
  const schemas = new Map();
214
184
  const schemaHashes = {};
215
- for (const [name, schemaPath] of Object.entries(options.schemas)) {
216
- const result = await loadSchema(schemaPath).match((doc) => Promise.resolve(ok(doc)), (error) => Promise.resolve(err(error)));
185
+ for (const [name, schemaConfig] of Object.entries(options.schemas)) {
186
+ const result = await loadSchema(schemaConfig.schema).match((doc) => Promise.resolve(ok(doc)), (error) => Promise.resolve(err(error)));
217
187
  if (result.isErr()) {
218
188
  return err(result.error);
219
189
  }
220
190
  schemas.set(name, result.value);
221
191
  }
222
192
  const injectionConfig = new Map();
223
- for (const schemaName of schemas.keys()) {
224
- const adapterPath = adapterPaths.get(schemaName);
225
- const scalarPath = scalarPaths.get(schemaName);
226
- if (!adapterPath || !scalarPath) {
227
- return err({
228
- code: "INJECT_MODULE_REQUIRED",
229
- message: `Missing adapter or scalar configuration for schema '${schemaName}'`
230
- });
231
- }
232
- const importSpecifierOptions = { includeExtension: options.importExtension };
193
+ for (const [schemaName, schemaConfig] of Object.entries(options.schemas)) {
194
+ const injectConfig = schemaConfig.inject;
233
195
  injectionConfig.set(schemaName, {
234
- adapterImportPath: toImportSpecifier(outPath, adapterPath, importSpecifierOptions),
235
- scalarImportPath: toImportSpecifier(outPath, scalarPath, importSpecifierOptions)
196
+ scalarImportPath: toImportSpecifier(outPath, resolve(injectConfig.scalars), importSpecifierOptions),
197
+ ...injectConfig.adapter ? { adapterImportPath: toImportSpecifier(outPath, resolve(injectConfig.adapter), importSpecifierOptions) } : {}
236
198
  });
237
199
  }
238
200
  const { code } = generateMultiSchemaModule(schemas, { injection: injectionConfig });
239
201
  for (const [name, document] of schemas.entries()) {
240
- const schemaIndex = (await import("./generator-CoRRPbfk.mjs")).createSchemaIndex(document);
202
+ const schemaIndex = (await import("./generator-B4EV40uX.mjs")).createSchemaIndex(document);
241
203
  const objects = Array.from(schemaIndex.objects.keys()).filter((n) => !n.startsWith("__")).length;
242
204
  const enums = Array.from(schemaIndex.enums.keys()).filter((n) => !n.startsWith("__")).length;
243
205
  const inputs = Array.from(schemaIndex.inputs.keys()).filter((n) => !n.startsWith("__")).length;
@@ -267,5 +229,5 @@ const runMultiSchemaCodegen = async (options) => {
267
229
  };
268
230
 
269
231
  //#endregion
270
- export { hashSchema, loadSchema, runMultiSchemaCodegen, writeInjectTemplate };
232
+ export { hashSchema, loadSchema, runCodegen, writeInjectTemplate };
271
233
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["extensionMap: Record<string, string>","withPrefix","currentExt","schemaHashes: Record<string, { schemaHash: string; objects: number; enums: number; inputs: number; unions: number }>"],"sources":["../src/inject-template.ts","../src/file.ts","../src/schema.ts","../src/tsdown-bundle.ts","../src/runner.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nconst templateContents = `\\\nimport { defineScalar } from \"@soda-gql/core\";\nimport { createRuntimeAdapter } from \"@soda-gql/runtime\";\n\nexport const scalar = {\n ...defineScalar(\"ID\", ({ type }) => ({\n input: type<string>(),\n output: type<string>(),\n directives: {},\n })),\n ...defineScalar(\"String\", ({ type }) => ({\n input: type<string>(),\n output: type<string>(),\n directives: {},\n })),\n ...defineScalar(\"Int\", ({ type }) => ({\n input: type<number>(),\n output: type<number>(),\n directives: {},\n })),\n ...defineScalar(\"Float\", ({ type }) => ({\n input: type<number>(),\n output: type<number>(),\n directives: {},\n })),\n ...defineScalar(\"Boolean\", ({ type }) => ({\n input: type<boolean>(),\n output: type<boolean>(),\n directives: {},\n })),\n} as const;\n\nexport const adapter = createRuntimeAdapter(({ type }) => ({\n nonGraphqlErrorType: type<{ type: \"non-graphql-error\"; cause: unknown }>(),\n}));\n`;\n\nexport const writeInjectTemplate = (outPath: string) => {\n const targetPath = resolve(outPath);\n\n try {\n if (existsSync(targetPath)) {\n return err<void, CodegenError>({\n code: \"INJECT_TEMPLATE_EXISTS\",\n message: `Inject module already exists: ${targetPath}`,\n outPath: targetPath,\n });\n }\n\n mkdirSync(dirname(targetPath), { recursive: true });\n writeFileSync(targetPath, `${templateContents}\\n`);\n return ok<void, CodegenError>(undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<void, CodegenError>({\n code: \"INJECT_TEMPLATE_FAILED\",\n message,\n outPath: targetPath,\n });\n }\n};\n\nexport const getInjectTemplate = (): string => `${templateContents}\\n`;\n","import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nexport const writeModule = (outPath: string, contents: string) => {\n const targetPath = resolve(outPath);\n\n try {\n mkdirSync(dirname(targetPath), { recursive: true });\n writeFileSync(targetPath, contents);\n return ok<void, CodegenError>(undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<void, CodegenError>({\n code: \"EMIT_FAILED\",\n message,\n outPath: targetPath,\n });\n }\n};\n","import { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { type DocumentNode, parse, print } from \"graphql\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nexport const loadSchema = (schemaPath: string) => {\n const resolvedPath = resolve(schemaPath);\n\n if (!existsSync(resolvedPath)) {\n return err<DocumentNode, CodegenError>({\n code: \"SCHEMA_NOT_FOUND\",\n message: `Schema file not found at ${resolvedPath}`,\n schemaPath: resolvedPath,\n });\n }\n\n try {\n const schemaSource = readFileSync(resolvedPath, \"utf8\");\n const document = parse(schemaSource);\n return ok<DocumentNode, CodegenError>(document);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<DocumentNode, CodegenError>({\n code: \"SCHEMA_INVALID\",\n message: `SchemaValidationError: ${message}`,\n schemaPath: resolvedPath,\n });\n }\n};\n\nexport const hashSchema = (document: DocumentNode): string => createHash(\"sha256\").update(print(document)).digest(\"hex\");\n","import { dirname, extname } from \"node:path\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport { build, type Options } from \"tsdown\";\nimport type { CodegenError } from \"./types\";\n\nexport type BundleResult = {\n readonly cjsPath: string;\n};\n\nexport const bundleGraphqlSystem = async (sourcePath: string): Promise<Result<BundleResult, CodegenError>> => {\n try {\n const sourceDir = dirname(sourcePath);\n const sourceExt = extname(sourcePath);\n const baseName = sourcePath.slice(0, -sourceExt.length);\n\n await build({\n config: false,\n entry: sourcePath,\n format: [\"cjs\"],\n platform: \"node\",\n external: [\"@soda-gql/core\", \"@soda-gql/runtime\"],\n dts: false,\n outDir: sourceDir,\n fixedExtension: true,\n clean: false,\n minify: false,\n sourcemap: false,\n treeshake: false,\n } satisfies Options);\n\n const cjsPath = `${baseName}.cjs`;\n\n return ok({ cjsPath });\n } catch (error) {\n return err({\n code: \"EMIT_FAILED\",\n message: `Failed to bundle graphql-system: ${error instanceof Error ? error.message : String(error)}`,\n outPath: sourcePath,\n });\n }\n};\n","import { existsSync } from \"node:fs\";\nimport { basename, dirname, extname, relative, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\nimport { writeModule } from \"./file\";\nimport { generateMultiSchemaModule } from \"./generator\";\nimport { hashSchema, loadSchema } from \"./schema\";\nimport { bundleGraphqlSystem } from \"./tsdown-bundle\";\nimport type { MultiSchemaCodegenOptions, MultiSchemaCodegenResult, MultiSchemaCodegenSuccess } from \"./types\";\n\nconst extensionMap: Record<string, string> = {\n \".ts\": \".js\",\n \".tsx\": \".js\",\n \".mts\": \".mjs\",\n \".cts\": \".cjs\",\n \".js\": \".js\",\n \".mjs\": \".mjs\",\n \".cjs\": \".cjs\",\n};\n\ntype ImportSpecifierOptions = {\n includeExtension?: boolean;\n};\n\nconst toImportSpecifier = (fromPath: string, targetPath: string, options?: ImportSpecifierOptions): string => {\n const fromDir = dirname(fromPath);\n const normalized = relative(fromDir, targetPath).replace(/\\\\/g, \"/\");\n const sourceExt = extname(targetPath);\n\n // When includeExtension is false (default), strip the extension entirely\n if (!options?.includeExtension) {\n if (normalized.length === 0) {\n return `./${basename(targetPath, sourceExt)}`;\n }\n const withPrefix = normalized.startsWith(\".\") ? normalized : `./${normalized}`;\n const currentExt = extname(withPrefix);\n return currentExt ? withPrefix.slice(0, -currentExt.length) : withPrefix;\n }\n\n // When includeExtension is true, convert to runtime extension\n const runtimeExt = extensionMap[sourceExt] ?? sourceExt;\n\n if (normalized.length === 0) {\n const base = runtimeExt !== sourceExt ? basename(targetPath, sourceExt) : basename(targetPath);\n return `./${base}${runtimeExt}`;\n }\n\n const withPrefix = normalized.startsWith(\".\") ? normalized : `./${normalized}`;\n if (!runtimeExt) {\n return withPrefix;\n }\n if (withPrefix.endsWith(runtimeExt)) {\n return withPrefix;\n }\n\n const currentExt = extname(withPrefix);\n const withoutExt = currentExt ? withPrefix.slice(0, -currentExt.length) : withPrefix;\n return `${withoutExt}${runtimeExt}`;\n};\n\nexport const runMultiSchemaCodegen = async (options: MultiSchemaCodegenOptions): Promise<MultiSchemaCodegenResult> => {\n const outPath = resolve(options.outPath);\n\n // Handle legacy injectFromPath for backward compatibility\n const runtimeAdapters = options.runtimeAdapters ?? (options.injectFromPath ? { default: options.injectFromPath } : {});\n const scalars = options.scalars ?? (options.injectFromPath ? { default: options.injectFromPath } : {});\n\n // Validate that all adapter and scalar files exist\n const adapterPaths = new Map<string, string>();\n const scalarPaths = new Map<string, string>();\n\n for (const [schemaName, adapterPath] of Object.entries(runtimeAdapters)) {\n const resolvedPath = resolve(adapterPath);\n if (!existsSync(resolvedPath)) {\n return err({\n code: \"INJECT_MODULE_NOT_FOUND\",\n message: `Runtime adapter module not found for schema '${schemaName}': ${resolvedPath}`,\n injectPath: resolvedPath,\n });\n }\n adapterPaths.set(schemaName, resolvedPath);\n }\n\n for (const [schemaName, scalarPath] of Object.entries(scalars)) {\n const resolvedPath = resolve(scalarPath);\n if (!existsSync(resolvedPath)) {\n return err({\n code: \"INJECT_MODULE_NOT_FOUND\",\n message: `Scalar module not found for schema '${schemaName}': ${resolvedPath}`,\n injectPath: resolvedPath,\n });\n }\n scalarPaths.set(schemaName, resolvedPath);\n }\n\n // Load all schemas\n const schemas = new Map<string, import(\"graphql\").DocumentNode>();\n const schemaHashes: Record<string, { schemaHash: string; objects: number; enums: number; inputs: number; unions: number }> = {};\n\n for (const [name, schemaPath] of Object.entries(options.schemas)) {\n const result = await loadSchema(schemaPath).match(\n (doc) => Promise.resolve(ok(doc)),\n (error) => Promise.resolve(err(error)),\n );\n\n if (result.isErr()) {\n return err(result.error);\n }\n\n schemas.set(name, result.value);\n }\n\n // Build injection config for each schema\n const injectionConfig = new Map<string, { adapterImportPath: string; scalarImportPath: string }>();\n\n for (const schemaName of schemas.keys()) {\n const adapterPath = adapterPaths.get(schemaName);\n const scalarPath = scalarPaths.get(schemaName);\n\n if (!adapterPath || !scalarPath) {\n return err({\n code: \"INJECT_MODULE_REQUIRED\",\n message: `Missing adapter or scalar configuration for schema '${schemaName}'`,\n });\n }\n\n const importSpecifierOptions = { includeExtension: options.importExtension };\n injectionConfig.set(schemaName, {\n adapterImportPath: toImportSpecifier(outPath, adapterPath, importSpecifierOptions),\n scalarImportPath: toImportSpecifier(outPath, scalarPath, importSpecifierOptions),\n });\n }\n\n // Generate multi-schema module\n const { code } = generateMultiSchemaModule(schemas, {\n injection: injectionConfig,\n });\n\n // Calculate individual schema stats and hashes\n for (const [name, document] of schemas.entries()) {\n const schemaIndex = (await import(\"./generator\")).createSchemaIndex(document);\n const objects = Array.from(schemaIndex.objects.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const enums = Array.from(schemaIndex.enums.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const inputs = Array.from(schemaIndex.inputs.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const unions = Array.from(schemaIndex.unions.keys()).filter((n) => !n.startsWith(\"__\")).length;\n\n schemaHashes[name] = {\n schemaHash: hashSchema(document),\n objects,\n enums,\n inputs,\n unions,\n };\n }\n\n // Write the module\n const writeResult = await writeModule(outPath, code).match(\n () => Promise.resolve(ok(undefined)),\n (error) => Promise.resolve(err(error)),\n );\n\n if (writeResult.isErr()) {\n return err(writeResult.error);\n }\n\n // Bundle the generated module with tsdown\n const bundleOutcome = await bundleGraphqlSystem(outPath);\n const bundleResult = bundleOutcome.match(\n (result) => ok(result),\n (error) => err(error),\n );\n\n if (bundleResult.isErr()) {\n return err(bundleResult.error);\n }\n\n return ok({\n schemas: schemaHashes,\n outPath,\n cjsPath: bundleResult.value.cjsPath,\n } satisfies MultiSchemaCodegenSuccess);\n};\n"],"mappings":";;;;;;;;;AAMA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCzB,MAAa,uBAAuB,YAAoB;CACtD,MAAM,aAAa,QAAQ,QAAQ;AAEnC,KAAI;AACF,MAAI,WAAW,WAAW,EAAE;AAC1B,UAAO,IAAwB;IAC7B,MAAM;IACN,SAAS,iCAAiC;IAC1C,SAAS;IACV,CAAC;;AAGJ,YAAU,QAAQ,WAAW,EAAE,EAAE,WAAW,MAAM,CAAC;AACnD,gBAAc,YAAY,GAAG,iBAAiB,IAAI;AAClD,SAAO,GAAuB,UAAU;UACjC,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AACtE,SAAO,IAAwB;GAC7B,MAAM;GACN;GACA,SAAS;GACV,CAAC;;;AAIN,MAAa,0BAAkC,GAAG,iBAAiB;;;;AC9DnE,MAAa,eAAe,SAAiB,aAAqB;CAChE,MAAM,aAAa,QAAQ,QAAQ;AAEnC,KAAI;AACF,YAAU,QAAQ,WAAW,EAAE,EAAE,WAAW,MAAM,CAAC;AACnD,gBAAc,YAAY,SAAS;AACnC,SAAO,GAAuB,UAAU;UACjC,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AACtE,SAAO,IAAwB;GAC7B,MAAM;GACN;GACA,SAAS;GACV,CA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,SAAS,EAClD,WAAW,iBACZ,CAAC;AAGF,MAAK,MAAM,CAAC,MAAM,aAAa,QAAQ,SAAS,EAAE;EAChD,MAAM,eAAe,MAAM,OAAO,6BAAgB,kBAAkB,SAAS;EAC7E,MAAM,UAAU,MAAM,KAAK,YAAY,QAAQ,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;EAC1F,MAAM,QAAQ,MAAM,KAAK,YAAY,MAAM,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;EACtF,MAAM,SAAS,MAAM,KAAK,YAAY,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;EACxF,MAAM,SAAS,MAAM,KAAK,YAAY,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;AAExF,eAAa,QAAQ;GACnB,YAAY,WAAW,SAAS;GAChC;GACA;GACA;GACA;GACD;;CAIH,MAAM,cAAc,MAAM,YAAY,SAAS,KAAK,CAAC,YAC7C,QAAQ,QAAQ,GAAG,UAAU,CAAC,GACnC,UAAU,QAAQ,QAAQ,IAAI,MAAM,CAAC,CACvC;AAED,KAAI,YAAY,OAAO,EAAE;AACvB,SAAO,IAAI,YAAY,MAAM;;CAI/B,MAAM,gBAAgB,MAAM,oBAAoB,QAAQ;CACxD,MAAM,eAAe,cAAc,OAChC,WAAW,GAAG,OAAO,GACrB,UAAU,IAAI,MAAM,CACtB;AAED,KAAI,aAAa,OAAO,EAAE;AACxB,SAAO,IAAI,aAAa,MAAM;;AAGhC,QAAO,GAAG;EACR,SAAS;EACT;EACA,SAAS,aAAa,MAAM;EAC7B,CAAqC"}
1
+ {"version":3,"file":"index.mjs","names":["extensionMap: Record<string, string>","withPrefix","currentExt","schemaHashes: Record<string, { schemaHash: string; objects: number; enums: number; inputs: number; unions: number }>"],"sources":["../src/inject-template.ts","../src/file.ts","../src/schema.ts","../src/tsdown-bundle.ts","../src/runner.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nconst templateContents = `\\\nimport { defineScalar } from \"@soda-gql/core\";\n\nexport const scalar = {\n ...defineScalar<\"ID\", string, string>(\"ID\"),\n ...defineScalar<\"String\", string, string>(\"String\"),\n ...defineScalar<\"Int\", number, number>(\"Int\"),\n ...defineScalar<\"Float\", number, number>(\"Float\"),\n ...defineScalar<\"Boolean\", boolean, boolean>(\"Boolean\"),\n} as const;\n`;\n\nexport const writeInjectTemplate = (outPath: string) => {\n const targetPath = resolve(outPath);\n\n try {\n if (existsSync(targetPath)) {\n return err<void, CodegenError>({\n code: \"INJECT_TEMPLATE_EXISTS\",\n message: `Inject module already exists: ${targetPath}`,\n outPath: targetPath,\n });\n }\n\n mkdirSync(dirname(targetPath), { recursive: true });\n writeFileSync(targetPath, `${templateContents}\\n`);\n return ok<void, CodegenError>(undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<void, CodegenError>({\n code: \"INJECT_TEMPLATE_FAILED\",\n message,\n outPath: targetPath,\n });\n }\n};\n\nexport const getInjectTemplate = (): string => `${templateContents}\\n`;\n","import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nexport const writeModule = (outPath: string, contents: string) => {\n const targetPath = resolve(outPath);\n\n try {\n mkdirSync(dirname(targetPath), { recursive: true });\n writeFileSync(targetPath, contents);\n return ok<void, CodegenError>(undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<void, CodegenError>({\n code: \"EMIT_FAILED\",\n message,\n outPath: targetPath,\n });\n }\n};\n","import { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { type DocumentNode, parse, print } from \"graphql\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nexport const loadSchema = (schemaPath: string) => {\n const resolvedPath = resolve(schemaPath);\n\n if (!existsSync(resolvedPath)) {\n return err<DocumentNode, CodegenError>({\n code: \"SCHEMA_NOT_FOUND\",\n message: `Schema file not found at ${resolvedPath}`,\n schemaPath: resolvedPath,\n });\n }\n\n try {\n const schemaSource = readFileSync(resolvedPath, \"utf8\");\n const document = parse(schemaSource);\n return ok<DocumentNode, CodegenError>(document);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<DocumentNode, CodegenError>({\n code: \"SCHEMA_INVALID\",\n message: `SchemaValidationError: ${message}`,\n schemaPath: resolvedPath,\n });\n }\n};\n\nexport const hashSchema = (document: DocumentNode): string => createHash(\"sha256\").update(print(document)).digest(\"hex\");\n","import { dirname, extname } from \"node:path\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport { build, type Options } from \"tsdown\";\nimport type { CodegenError } from \"./types\";\n\nexport type BundleResult = {\n readonly cjsPath: string;\n};\n\nexport const bundleGraphqlSystem = async (sourcePath: string): Promise<Result<BundleResult, CodegenError>> => {\n try {\n const sourceDir = dirname(sourcePath);\n const sourceExt = extname(sourcePath);\n const baseName = sourcePath.slice(0, -sourceExt.length);\n\n await build({\n config: false,\n entry: sourcePath,\n format: [\"cjs\"],\n platform: \"node\",\n external: [\"@soda-gql/core\", \"@soda-gql/runtime\"],\n dts: false,\n outDir: sourceDir,\n fixedExtension: true,\n clean: false,\n minify: false,\n sourcemap: false,\n treeshake: false,\n } satisfies Options);\n\n const cjsPath = `${baseName}.cjs`;\n\n return ok({ cjsPath });\n } catch (error) {\n return err({\n code: \"EMIT_FAILED\",\n message: `Failed to bundle graphql-system: ${error instanceof Error ? error.message : String(error)}`,\n outPath: sourcePath,\n });\n }\n};\n","import { existsSync } from \"node:fs\";\nimport { basename, dirname, extname, relative, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\nimport { writeModule } from \"./file\";\nimport { generateMultiSchemaModule } from \"./generator\";\nimport { hashSchema, loadSchema } from \"./schema\";\nimport { bundleGraphqlSystem } from \"./tsdown-bundle\";\nimport type { CodegenOptions, CodegenResult, CodegenSuccess } from \"./types\";\n\nconst extensionMap: Record<string, string> = {\n \".ts\": \".js\",\n \".tsx\": \".js\",\n \".mts\": \".mjs\",\n \".cts\": \".cjs\",\n \".js\": \".js\",\n \".mjs\": \".mjs\",\n \".cjs\": \".cjs\",\n};\n\ntype ImportSpecifierOptions = {\n includeExtension?: boolean;\n};\n\nconst toImportSpecifier = (fromPath: string, targetPath: string, options?: ImportSpecifierOptions): string => {\n const fromDir = dirname(fromPath);\n const normalized = relative(fromDir, targetPath).replace(/\\\\/g, \"/\");\n const sourceExt = extname(targetPath);\n\n // When includeExtension is false (default), strip the extension entirely\n if (!options?.includeExtension) {\n if (normalized.length === 0) {\n return `./${basename(targetPath, sourceExt)}`;\n }\n const withPrefix = normalized.startsWith(\".\") ? normalized : `./${normalized}`;\n const currentExt = extname(withPrefix);\n return currentExt ? withPrefix.slice(0, -currentExt.length) : withPrefix;\n }\n\n // When includeExtension is true, convert to runtime extension\n const runtimeExt = extensionMap[sourceExt] ?? sourceExt;\n\n if (normalized.length === 0) {\n const base = runtimeExt !== sourceExt ? basename(targetPath, sourceExt) : basename(targetPath);\n return `./${base}${runtimeExt}`;\n }\n\n const withPrefix = normalized.startsWith(\".\") ? normalized : `./${normalized}`;\n if (!runtimeExt) {\n return withPrefix;\n }\n if (withPrefix.endsWith(runtimeExt)) {\n return withPrefix;\n }\n\n const currentExt = extname(withPrefix);\n const withoutExt = currentExt ? withPrefix.slice(0, -currentExt.length) : withPrefix;\n return `${withoutExt}${runtimeExt}`;\n};\n\nexport const runCodegen = async (options: CodegenOptions): Promise<CodegenResult> => {\n const outPath = resolve(options.outPath);\n const importSpecifierOptions = { includeExtension: options.importExtension };\n\n // Validate that all schema and inject files exist\n for (const [schemaName, schemaConfig] of Object.entries(options.schemas)) {\n const scalarPath = resolve(schemaConfig.inject.scalars);\n if (!existsSync(scalarPath)) {\n return err({\n code: \"INJECT_MODULE_NOT_FOUND\",\n message: `Scalar module not found for schema '${schemaName}': ${scalarPath}`,\n injectPath: scalarPath,\n });\n }\n\n if (schemaConfig.inject.adapter) {\n const adapterPath = resolve(schemaConfig.inject.adapter);\n if (!existsSync(adapterPath)) {\n return err({\n code: \"INJECT_MODULE_NOT_FOUND\",\n message: `Adapter module not found for schema '${schemaName}': ${adapterPath}`,\n injectPath: adapterPath,\n });\n }\n }\n }\n\n // Load all schemas\n const schemas = new Map<string, import(\"graphql\").DocumentNode>();\n const schemaHashes: Record<string, { schemaHash: string; objects: number; enums: number; inputs: number; unions: number }> = {};\n\n for (const [name, schemaConfig] of Object.entries(options.schemas)) {\n const result = await loadSchema(schemaConfig.schema).match(\n (doc) => Promise.resolve(ok(doc)),\n (error) => Promise.resolve(err(error)),\n );\n\n if (result.isErr()) {\n return err(result.error);\n }\n\n schemas.set(name, result.value);\n }\n\n // Build injection config for each schema\n const injectionConfig = new Map<\n string,\n {\n scalarImportPath: string;\n adapterImportPath?: string;\n }\n >();\n\n for (const [schemaName, schemaConfig] of Object.entries(options.schemas)) {\n const injectConfig = schemaConfig.inject;\n\n injectionConfig.set(schemaName, {\n scalarImportPath: toImportSpecifier(outPath, resolve(injectConfig.scalars), importSpecifierOptions),\n ...(injectConfig.adapter\n ? { adapterImportPath: toImportSpecifier(outPath, resolve(injectConfig.adapter), importSpecifierOptions) }\n : {}),\n });\n }\n\n // Generate multi-schema module\n const { code } = generateMultiSchemaModule(schemas, {\n injection: injectionConfig,\n });\n\n // Calculate individual schema stats and hashes\n for (const [name, document] of schemas.entries()) {\n const schemaIndex = (await import(\"./generator\")).createSchemaIndex(document);\n const objects = Array.from(schemaIndex.objects.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const enums = Array.from(schemaIndex.enums.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const inputs = Array.from(schemaIndex.inputs.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const unions = Array.from(schemaIndex.unions.keys()).filter((n) => !n.startsWith(\"__\")).length;\n\n schemaHashes[name] = {\n schemaHash: hashSchema(document),\n objects,\n enums,\n inputs,\n unions,\n };\n }\n\n // Write the module\n const writeResult = await writeModule(outPath, code).match(\n () => Promise.resolve(ok(undefined)),\n (error) => Promise.resolve(err(error)),\n );\n\n if (writeResult.isErr()) {\n return err(writeResult.error);\n }\n\n // Bundle the generated module with tsdown\n const bundleOutcome = await bundleGraphqlSystem(outPath);\n const bundleResult = bundleOutcome.match(\n (result) => ok(result),\n (error) => err(error),\n );\n\n if (bundleResult.isErr()) {\n return err(bundleResult.error);\n }\n\n return ok({\n schemas: schemaHashes,\n outPath,\n cjsPath: bundleResult.value.cjsPath,\n } satisfies CodegenSuccess);\n};\n"],"mappings":";;;;;;;;;AAMA,MAAM,mBAAmB;;;;;;;;;;;AAYzB,MAAa,uBAAuB,YAAoB;CACtD,MAAM,aAAa,QAAQ,QAAQ;AAEnC,KAAI;AACF,MAAI,WAAW,WAAW,EAAE;AAC1B,UAAO,IAAwB;IAC7B,MAAM;IACN,SAAS,iCAAiC;IAC1C,SAAS;IACV,CAAC;;AAGJ,YAAU,QAAQ,WAAW,EAAE,EAAE,WAAW,MAAM,CAAC;AACnD,gBAAc,YAAY,GAAG,iBAAiB,IAAI;AAClD,SAAO,GAAuB,UAAU;UACjC,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AACtE,SAAO,IAAwB;GAC7B,MAAM;GACN;GACA,SAAS;GACV,CAAC;;;AAIN,MAAa,0BAAkC,GAAG,iBAAiB;;;;ACrCnE,MAAa,eAAe,SAAiB,aAAqB;CAChE,MAAM,aAAa,QAAQ,QAAQ;AAEnC,KAAI;AACF,YAAU,QAAQ,WAAW,EAAE,EAAE,WAAW,MAAM,CAAC;AACnD,gB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,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;EAC1F,MAAM,QAAQ,MAAM,KAAK,YAAY,MAAM,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;EACtF,MAAM,SAAS,MAAM,KAAK,YAAY,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;EACxF,MAAM,SAAS,MAAM,KAAK,YAAY,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;AAExF,eAAa,QAAQ;GACnB,YAAY,WAAW,SAAS;GAChC;GACA;GACA;GACA;GACD;;CAIH,MAAM,cAAc,MAAM,YAAY,SAAS,KAAK,CAAC,YAC7C,QAAQ,QAAQ,GAAG,UAAU,CAAC,GACnC,UAAU,QAAQ,QAAQ,IAAI,MAAM,CAAC,CACvC;AAED,KAAI,YAAY,OAAO,EAAE;AACvB,SAAO,IAAI,YAAY,MAAM;;CAI/B,MAAM,gBAAgB,MAAM,oBAAoB,QAAQ;CACxD,MAAM,eAAe,cAAc,OAChC,WAAW,GAAG,OAAO,GACrB,UAAU,IAAI,MAAM,CACtB;AAED,KAAI,aAAa,OAAO,EAAE;AACxB,SAAO,IAAI,aAAa,MAAM;;AAGhC,QAAO,GAAG;EACR,SAAS;EACT;EACA,SAAS,aAAa,MAAM;EAC7B,CAA0B"}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@soda-gql/codegen",
3
- "version": "0.0.9",
3
+ "version": "0.2.0",
4
+ "description": "GraphQL schema code generation for soda-gql",
4
5
  "type": "module",
5
6
  "private": false,
6
7
  "license": "MIT",
@@ -12,12 +13,31 @@
12
13
  "email": "shota.hatada@whatasoda.me",
13
14
  "url": "https://github.com/whatasoda"
14
15
  },
16
+ "keywords": [
17
+ "graphql",
18
+ "codegen",
19
+ "zero-runtime",
20
+ "typescript",
21
+ "schema"
22
+ ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/whatasoda/soda-gql.git",
26
+ "directory": "packages/codegen"
27
+ },
28
+ "homepage": "https://github.com/whatasoda/soda-gql#readme",
29
+ "bugs": {
30
+ "url": "https://github.com/whatasoda/soda-gql/issues"
31
+ },
32
+ "engines": {
33
+ "node": ">=18"
34
+ },
15
35
  "main": "./dist/index.mjs",
16
36
  "module": "./dist/index.mjs",
17
37
  "types": "./dist/index.d.mts",
18
38
  "exports": {
19
39
  ".": {
20
- "@soda-gql": "./src/index.ts",
40
+ "@soda-gql": "./@x-index.ts",
21
41
  "types": "./dist/index.d.mts",
22
42
  "import": "./dist/index.mjs",
23
43
  "require": "./dist/index.cjs",
@@ -26,8 +46,8 @@
26
46
  "./package.json": "./package.json"
27
47
  },
28
48
  "dependencies": {
29
- "@soda-gql/core": "0.0.9",
30
- "@soda-gql/runtime": "0.0.9",
49
+ "@soda-gql/core": "0.2.0",
50
+ "@soda-gql/runtime": "0.2.0",
31
51
  "graphql": "^16.8.1",
32
52
  "neverthrow": "^8.1.1",
33
53
  "tsdown": "^0.15.7"
@@ -1,3 +0,0 @@
1
- import { n as generateMultiSchemaModule, t as createSchemaIndex } from "./generator-DSOZFGSD.mjs";
2
-
3
- export { createSchemaIndex, generateMultiSchemaModule };
@@ -1 +0,0 @@
1
- {"version":3,"file":"generator-DSOZFGSD.mjs","names":["operationTypes: OperationTypeNames","modifier: TypeModifier","imports: string[]","schemaBlocks: string[]","gqlEntries: string[]","schemaConfigs: Record<string, any>","name","injection: RuntimeTemplateInjection"],"sources":["../src/generator.ts"],"sourcesContent":["import type { TypeModifier } from \"@soda-gql/core\";\nimport {\n type ConstDirectiveNode,\n type ConstValueNode,\n type DocumentNode,\n type EnumValueDefinitionNode,\n type FieldDefinitionNode,\n type InputValueDefinitionNode,\n Kind,\n type NamedTypeNode,\n type SchemaDefinitionNode,\n type SchemaExtensionNode,\n type TypeNode,\n} from \"graphql\";\n\nconst builtinScalarTypes = new Map<string, { readonly input: string; readonly output: string }>([\n [\"ID\", { input: \"string\", output: \"string\" }],\n [\"String\", { input: \"string\", output: \"string\" }],\n [\"Int\", { input: \"number\", output: \"number\" }],\n [\"Float\", { input: \"number\", output: \"number\" }],\n [\"Boolean\", { input: \"boolean\", output: \"boolean\" }],\n]);\n\ntype OperationTypeNames = {\n query?: string;\n mutation?: string;\n subscription?: string;\n};\n\ntype ObjectRecord = {\n readonly name: string;\n readonly fields: Map<string, FieldDefinitionNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype InputRecord = {\n readonly name: string;\n readonly fields: Map<string, InputValueDefinitionNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype EnumRecord = {\n readonly name: string;\n readonly values: Map<string, EnumValueDefinitionNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype UnionRecord = {\n readonly name: string;\n readonly members: Map<string, NamedTypeNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype ScalarRecord = {\n readonly name: string;\n directives: ConstDirectiveNode[];\n};\n\ntype SchemaIndex = {\n readonly objects: Map<string, ObjectRecord>;\n readonly inputs: Map<string, InputRecord>;\n readonly enums: Map<string, EnumRecord>;\n readonly unions: Map<string, UnionRecord>;\n readonly scalars: Map<string, ScalarRecord>;\n readonly operationTypes: OperationTypeNames;\n};\n\nconst ensureRecord = <T>(collection: Map<string, T>, key: string, factory: (name: string) => T): T => {\n const existing = collection.get(key);\n if (existing) {\n return existing;\n }\n\n const created = factory(key);\n collection.set(key, created);\n return created;\n};\n\nconst addObjectFields = (target: Map<string, FieldDefinitionNode>, fields: readonly FieldDefinitionNode[] | undefined): void => {\n if (!fields) {\n return;\n }\n\n for (const field of fields) {\n target.set(field.name.value, field);\n }\n};\n\nconst addInputFields = (\n target: Map<string, InputValueDefinitionNode>,\n fields: readonly InputValueDefinitionNode[] | undefined,\n): void => {\n if (!fields) {\n return;\n }\n\n for (const field of fields) {\n target.set(field.name.value, field);\n }\n};\n\nconst addEnumValues = (\n target: Map<string, EnumValueDefinitionNode>,\n values: readonly EnumValueDefinitionNode[] | undefined,\n): void => {\n if (!values) {\n return;\n }\n\n for (const value of values) {\n target.set(value.name.value, value);\n }\n};\n\nconst addUnionMembers = (target: Map<string, NamedTypeNode>, members: readonly NamedTypeNode[] | undefined): void => {\n if (!members) {\n return;\n }\n\n for (const member of members) {\n target.set(member.name.value, member);\n }\n};\n\nconst mergeDirectives = (\n existing: ConstDirectiveNode[] | undefined,\n incoming: readonly ConstDirectiveNode[] | undefined,\n precedence: \"definition\" | \"extension\",\n): ConstDirectiveNode[] => {\n const current = existing ?? [];\n const next = incoming ? Array.from(incoming) : [];\n return precedence === \"definition\" ? [...next, ...current] : [...current, ...next];\n};\n\nconst updateOperationTypes = (\n operationTypes: OperationTypeNames,\n definition: SchemaDefinitionNode | SchemaExtensionNode,\n): void => {\n for (const operation of definition.operationTypes ?? []) {\n const typeName = operation.type.name.value;\n switch (operation.operation) {\n case \"query\":\n operationTypes.query = typeName;\n break;\n case \"mutation\":\n operationTypes.mutation = typeName;\n break;\n case \"subscription\":\n operationTypes.subscription = typeName;\n break;\n default:\n break;\n }\n }\n};\n\nexport const createSchemaIndex = (document: DocumentNode): SchemaIndex => {\n const objects = new Map<string, ObjectRecord>();\n const inputs = new Map<string, InputRecord>();\n const enums = new Map<string, EnumRecord>();\n const unions = new Map<string, UnionRecord>();\n const scalars = new Map<string, ScalarRecord>();\n const operationTypes: OperationTypeNames = {};\n\n for (const definition of document.definitions) {\n switch (definition.kind) {\n case Kind.OBJECT_TYPE_DEFINITION:\n case Kind.OBJECT_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.OBJECT_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(objects, definition.name.value, (name) => ({\n name,\n fields: new Map<string, FieldDefinitionNode>(),\n directives: [],\n }));\n addObjectFields(record.fields, definition.fields);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.INPUT_OBJECT_TYPE_DEFINITION:\n case Kind.INPUT_OBJECT_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(inputs, definition.name.value, (name) => ({\n name,\n fields: new Map<string, InputValueDefinitionNode>(),\n directives: [],\n }));\n addInputFields(record.fields, definition.fields);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.ENUM_TYPE_DEFINITION:\n case Kind.ENUM_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.ENUM_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(enums, definition.name.value, (name) => ({\n name,\n values: new Map<string, EnumValueDefinitionNode>(),\n directives: [],\n }));\n addEnumValues(record.values, definition.values);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.UNION_TYPE_DEFINITION:\n case Kind.UNION_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.UNION_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(unions, definition.name.value, (name) => ({\n name,\n members: new Map<string, NamedTypeNode>(),\n directives: [],\n }));\n addUnionMembers(record.members, definition.types);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.SCALAR_TYPE_DEFINITION:\n case Kind.SCALAR_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.SCALAR_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(scalars, definition.name.value, (name) => ({\n name,\n directives: [],\n }));\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.SCHEMA_DEFINITION:\n case Kind.SCHEMA_EXTENSION:\n updateOperationTypes(operationTypes, definition);\n break;\n default:\n break;\n }\n }\n\n if (!operationTypes.query && objects.has(\"Query\")) {\n operationTypes.query = \"Query\";\n }\n if (!operationTypes.mutation && objects.has(\"Mutation\")) {\n operationTypes.mutation = \"Mutation\";\n }\n if (!operationTypes.subscription && objects.has(\"Subscription\")) {\n operationTypes.subscription = \"Subscription\";\n }\n\n return {\n objects,\n inputs,\n enums,\n unions,\n scalars,\n operationTypes,\n } satisfies SchemaIndex;\n};\n\ntype TypeLevel = {\n readonly kind: \"list\" | \"named\";\n readonly nonNull: boolean;\n};\n\nconst collectTypeLevels = (\n type: TypeNode,\n nonNull = false,\n levels: TypeLevel[] = [],\n): { readonly name: string; readonly levels: TypeLevel[] } => {\n if (type.kind === Kind.NON_NULL_TYPE) {\n return collectTypeLevels(type.type, true, levels);\n }\n\n if (type.kind === Kind.LIST_TYPE) {\n levels.push({ kind: \"list\", nonNull });\n return collectTypeLevels(type.type, false, levels);\n }\n\n levels.push({ kind: \"named\", nonNull });\n return { name: type.name.value, levels };\n};\n\nconst buildTypeModifier = (levels: TypeLevel[]): TypeModifier => {\n let modifier: TypeModifier = \"?\";\n\n for (const level of levels.slice().reverse()) {\n if (level.kind === \"named\") {\n // Inner type: always explicit nullable marker\n modifier = level.nonNull ? \"!\" : \"?\";\n continue;\n }\n\n // List type: append []? or []! based on list's nullability\n const listSuffix = level.nonNull ? \"[]!\" : \"[]?\";\n modifier = `${modifier}${listSuffix}` as TypeModifier;\n }\n\n return modifier;\n};\n\nconst parseTypeReference = (type: TypeNode): { readonly name: string; readonly modifier: string } => {\n const { name, levels } = collectTypeLevels(type);\n return { name, modifier: buildTypeModifier(levels) };\n};\n\nconst renderType = (name: string, modifier: string): string => JSON.stringify(`${name}:${modifier}`);\n\nconst isScalarName = (schema: SchemaIndex, name: string): boolean => builtinScalarTypes.has(name) || schema.scalars.has(name);\nconst isEnumName = (schema: SchemaIndex, name: string): boolean => schema.enums.has(name);\nconst _isInputName = (schema: SchemaIndex, name: string): boolean => schema.inputs.has(name);\nconst isUnionName = (schema: SchemaIndex, name: string): boolean => schema.unions.has(name);\nconst isObjectName = (schema: SchemaIndex, name: string): boolean => schema.objects.has(name);\n\nconst renderConstValue = (value: ConstValueNode): string => {\n switch (value.kind) {\n case Kind.NULL:\n return \"null\";\n case Kind.INT:\n case Kind.FLOAT:\n return value.value;\n case Kind.STRING:\n case Kind.ENUM:\n return JSON.stringify(value.value);\n case Kind.BOOLEAN:\n return value.value ? \"true\" : \"false\";\n case Kind.LIST:\n return `[${value.values.map((item) => renderConstValue(item)).join(\", \")}]`;\n case Kind.OBJECT: {\n if (value.fields.length === 0) {\n return \"{}\";\n }\n const entries = value.fields.map((field) => `${field.name.value}: ${renderConstValue(field.value)}`);\n return `{ ${entries.join(\", \")} }`;\n }\n }\n};\n\nconst renderConstArgumentMap = (\n args: readonly { readonly name: { readonly value: string }; readonly value: ConstValueNode }[] | undefined,\n): string => {\n const entries = (args ?? []).map((arg) => `${arg.name.value}: ${renderConstValue(arg.value)}`);\n return renderPropertyLines({ entries, indentSize: 8 });\n};\n\nconst renderDirectives = (directives: readonly ConstDirectiveNode[] | undefined): string => {\n const entries = (directives ?? []).map(\n (directive) => `${directive.name.value}: ${renderConstArgumentMap(directive.arguments)}`,\n );\n return renderPropertyLines({ entries, indentSize: 8 });\n};\n\nconst renderDefaultValue = (value: ConstValueNode | null | undefined): string =>\n value ? `() => (${renderConstValue(value)})` : \"null\";\n\nconst renderInputRef = (schema: SchemaIndex, definition: InputValueDefinitionNode): string => {\n const { name, modifier } = parseTypeReference(definition.type);\n const tuple = renderType(name, modifier);\n const defaultValue = renderDefaultValue(definition.defaultValue ?? null);\n const directives = renderDirectives(definition.directives);\n\n if (isScalarName(schema, name)) {\n return `unsafeInputType.scalar(${tuple}, { default: ${defaultValue}, directives: ${directives} })`;\n }\n\n if (isEnumName(schema, name)) {\n return `unsafeInputType.enum(${tuple}, { default: ${defaultValue}, directives: ${directives} })`;\n }\n\n return `unsafeInputType.input(${tuple}, { default: ${defaultValue}, directives: ${directives} })`;\n};\n\nconst renderArgumentMap = (schema: SchemaIndex, args: readonly InputValueDefinitionNode[] | undefined): string => {\n const entries = [...(args ?? [])]\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((arg) => `${arg.name.value}: ${renderInputRef(schema, arg)}`);\n\n return renderPropertyLines({ entries, indentSize: 8 });\n};\n\nconst renderOutputRef = (schema: SchemaIndex, type: TypeNode, args: readonly InputValueDefinitionNode[] | undefined): string => {\n const { name, modifier } = parseTypeReference(type);\n const modifiedType = renderType(name, modifier);\n const argumentMap = renderArgumentMap(schema, args);\n\n if (isScalarName(schema, name)) {\n return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n if (isEnumName(schema, name)) {\n return `unsafeOutputType.enum(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n if (isUnionName(schema, name)) {\n return `unsafeOutputType.union(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n if (isObjectName(schema, name)) {\n return `unsafeOutputType.object(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap} })`;\n};\n\nconst renderPropertyLines = ({ entries, indentSize }: { entries: string[]; indentSize: number }) => {\n if (entries.length === 0) {\n return \"{}\";\n }\n\n const indent = \" \".repeat(indentSize);\n const lastIndent = \" \".repeat(indentSize - 2);\n return [\"{\", `${indent}${entries.join(`,\\n${indent}`)},`, `${lastIndent}}`].join(`\\n`);\n};\n\nconst renderObjectFields = (schema: SchemaIndex, fields: Map<string, FieldDefinitionNode>): string => {\n const entries = Array.from(fields.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((field) => `${field.name.value}: ${renderOutputRef(schema, field.type, field.arguments)}`);\n\n return renderPropertyLines({ entries, indentSize: 6 });\n};\n\nconst renderInputFields = (schema: SchemaIndex, fields: Map<string, InputValueDefinitionNode>): string => {\n const entries = Array.from(fields.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((field) => `${field.name.value}: ${renderInputRef(schema, field)}`);\n\n return renderPropertyLines({ entries, indentSize: 6 });\n};\n\nconst renderScalarDefinition = (record: ScalarRecord): string => {\n const typeInfo = builtinScalarTypes.get(record.name) ?? { input: \"string\", output: \"string\" };\n const scalarType = `type<{ input: ${typeInfo.input}; output: ${typeInfo.output} }>()`;\n return `${record.name}: define(\"${record.name}\").scalar(${scalarType})`;\n};\n\nconst renderObjectDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.objects.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const fields = renderObjectFields(schema, record.fields);\n return `${record.name}: define(\"${record.name}\").object(${fields})`;\n};\n\nconst renderInputDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.inputs.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const fields = renderInputFields(schema, record.fields);\n return `${record.name}: define(\"${record.name}\").input(${fields})`;\n};\n\nconst renderEnumDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.enums.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const values = Array.from(record.values.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((value) => `${value.name.value}: true`)\n .join(\", \");\n const body = values.length === 0 ? \"{}\" : `{ ${values} }`;\n\n return `${record.name}: define(\"${record.name}\").enum(${body})`;\n};\n\nconst renderUnionDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.unions.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const members = Array.from(record.members.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((member) => `${member.name.value}: true`)\n .join(\", \");\n const body = members.length === 0 ? \"{}\" : `{ ${members} }`;\n\n return `${record.name}: define(\"${record.name}\").union(${body})`;\n};\n\nconst collectObjectTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.objects.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectInputTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.inputs.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectEnumTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.enums.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectUnionTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.unions.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectScalarNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.scalars.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nexport type GeneratedModule = {\n readonly code: string;\n readonly stats: {\n readonly objects: number;\n readonly enums: number;\n readonly inputs: number;\n readonly unions: number;\n };\n};\n\ntype PerSchemaInjection = {\n readonly adapterImportPath: string;\n readonly scalarImportPath: string;\n};\n\ntype RuntimeTemplateInjection =\n | { readonly mode: \"inline\" }\n | {\n readonly mode: \"inject\";\n readonly perSchema: Map<string, PerSchemaInjection>;\n };\n\nexport type RuntimeGenerationOptions = {\n readonly injection?: Map<string, PerSchemaInjection>;\n};\n\ntype MultiRuntimeTemplateOptions = {\n readonly schemas: Record<\n string,\n {\n readonly queryType: string;\n readonly mutationType: string;\n readonly subscriptionType: string;\n readonly scalarBlock: string;\n readonly enumBlock: string;\n readonly inputBlock: string;\n readonly objectBlock: string;\n readonly unionBlock: string;\n }\n >;\n readonly injection: RuntimeTemplateInjection;\n};\n\nconst multiRuntimeTemplate = ($$: MultiRuntimeTemplateOptions) => {\n // Build imports based on injection mode\n const imports: string[] = [];\n const adapterAliases = new Map<string, string>();\n const scalarAliases = new Map<string, string>();\n\n if ($$.injection.mode === \"inject\") {\n // Group imports by file path\n const importsByPath = new Map<string, string[]>();\n\n for (const [schemaName, injection] of $$.injection.perSchema) {\n const adapterAlias = `adapter_${schemaName}`;\n const scalarAlias = `scalar_${schemaName}`;\n adapterAliases.set(schemaName, adapterAlias);\n scalarAliases.set(schemaName, scalarAlias);\n\n // Group adapter import\n const adapterSpecifiers = importsByPath.get(injection.adapterImportPath) ?? [];\n if (!importsByPath.has(injection.adapterImportPath)) {\n importsByPath.set(injection.adapterImportPath, adapterSpecifiers);\n }\n adapterSpecifiers.push(`adapter as ${adapterAlias}`);\n\n // Group scalar import (may be same file as adapter)\n const scalarSpecifiers = importsByPath.get(injection.scalarImportPath) ?? [];\n if (!importsByPath.has(injection.scalarImportPath)) {\n importsByPath.set(injection.scalarImportPath, scalarSpecifiers);\n }\n scalarSpecifiers.push(`scalar as ${scalarAlias}`);\n }\n\n // Generate grouped imports\n for (const [path, specifiers] of importsByPath) {\n if (specifiers.length === 1) {\n imports.push(`import { ${specifiers[0]} } from \"${path}\";`);\n } else {\n imports.push(`import {\\n ${specifiers.join(\",\\n \")},\\n} from \"${path}\";`);\n }\n }\n }\n\n const extraImports = imports.length > 0 ? `${imports.join(\"\\n\")}\\n` : \"\";\n\n // Generate per-schema definitions\n const schemaBlocks: string[] = [];\n const gqlEntries: string[] = [];\n\n for (const [name, config] of Object.entries($$.schemas)) {\n const schemaVar = `${name}Schema`;\n const adapterVar = $$.injection.mode === \"inject\" ? adapterAliases.get(name) : `adapter_${name}`;\n const scalarBlock = $$.injection.mode === \"inject\" ? scalarAliases.get(name) : config.scalarBlock;\n\n // Generate adapter if inline mode\n const adapterDefinition =\n $$.injection.mode === \"inject\"\n ? \"\"\n : `const ${adapterVar} = createRuntimeAdapter(({ type }) => ({\\n nonGraphqlErrorType: type<{ type: \"non-graphql-error\"; cause: unknown }>(),\\n}));\\n`;\n\n schemaBlocks.push(`${adapterDefinition}\nconst ${schemaVar} = {\n label: \"${name}\" as const,\n operations: defineOperationRoots({\n query: \"${config.queryType}\",\n mutation: \"${config.mutationType}\",\n subscription: \"${config.subscriptionType}\",\n }),\n scalar: ${scalarBlock},\n enum: ${config.enumBlock},\n input: ${config.inputBlock},\n object: ${config.objectBlock},\n union: ${config.unionBlock},\n} satisfies AnyGraphqlSchema;\n\nexport type Schema_${name} = typeof ${schemaVar} & { _?: never };\nexport type Adapter_${name} = typeof ${adapterVar} & { _?: never };`);\n\n gqlEntries.push(` ${name}: createGqlElementComposer<Schema_${name}, Adapter_${name}>(${schemaVar})`);\n }\n\n // Include createRuntimeAdapter import only in inline mode\n const runtimeImport = $$.injection.mode === \"inline\" ? '\\nimport { createRuntimeAdapter } from \"@soda-gql/runtime\";' : \"\";\n\n return `\\\nimport {\n type AnyGraphqlSchema,\n createGqlElementComposer,\n define,\n defineOperationRoots,\n unsafeInputType,\n unsafeOutputType,\n} from \"@soda-gql/core\";${runtimeImport}\n${extraImports}\n${schemaBlocks.join(\"\\n\")}\n\nexport const gql = {\n${gqlEntries.join(\",\\n\")}\n};\n`;\n};\n\nexport const generateMultiSchemaModule = (\n schemas: Map<string, DocumentNode>,\n options?: RuntimeGenerationOptions,\n): GeneratedModule => {\n // biome-ignore lint/suspicious/noExplicitAny: complex schema config type\n const schemaConfigs: Record<string, any> = {};\n const allStats = {\n objects: 0,\n enums: 0,\n inputs: 0,\n unions: 0,\n };\n\n for (const [name, document] of schemas.entries()) {\n const schema = createSchemaIndex(document);\n\n const builtinScalarDefinitions = Array.from(builtinScalarTypes.keys()).map((name) =>\n renderScalarDefinition(schema.scalars.get(name) ?? { name, directives: [] }),\n );\n\n const customScalarDefinitions = collectScalarNames(schema)\n .filter((name) => !builtinScalarTypes.has(name))\n .map((name) => {\n const record = schema.scalars.get(name);\n return record ? renderScalarDefinition(record) : \"\";\n })\n .filter((definition) => definition.length > 0);\n\n const allScalarDefinitions = builtinScalarDefinitions.concat(customScalarDefinitions);\n\n const objectTypeNames = collectObjectTypeNames(schema);\n const enumTypeNames = collectEnumTypeNames(schema);\n const inputTypeNames = collectInputTypeNames(schema);\n const unionTypeNames = collectUnionTypeNames(schema);\n\n const scalarBlock = renderPropertyLines({ entries: allScalarDefinitions, indentSize: 4 });\n const enumDefinitions = enumTypeNames\n .map((name) => renderEnumDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const enumBlock = renderPropertyLines({ entries: enumDefinitions, indentSize: 4 });\n const inputDefinitions = inputTypeNames\n .map((name) => renderInputDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const inputBlock = renderPropertyLines({ entries: inputDefinitions, indentSize: 4 });\n const objectDefinitions = objectTypeNames\n .map((name) => renderObjectDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const objectBlock = renderPropertyLines({ entries: objectDefinitions, indentSize: 4 });\n const unionDefinitions = unionTypeNames\n .map((name) => renderUnionDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const unionBlock = renderPropertyLines({ entries: unionDefinitions, indentSize: 4 });\n\n const queryType = schema.operationTypes.query ?? \"Query\";\n const mutationType = schema.operationTypes.mutation ?? \"Mutation\";\n const subscriptionType = schema.operationTypes.subscription ?? \"Subscription\";\n\n schemaConfigs[name] = {\n queryType,\n mutationType,\n subscriptionType,\n scalarBlock,\n enumBlock,\n inputBlock,\n objectBlock,\n unionBlock,\n };\n\n // Accumulate stats\n allStats.objects += objectDefinitions.length;\n allStats.enums += enumDefinitions.length;\n allStats.inputs += inputDefinitions.length;\n allStats.unions += unionDefinitions.length;\n }\n\n const injection: RuntimeTemplateInjection = options?.injection\n ? { mode: \"inject\", perSchema: options.injection }\n : { mode: \"inline\" };\n\n const code = multiRuntimeTemplate({\n schemas: schemaConfigs,\n injection,\n });\n\n return {\n code,\n stats: allStats,\n };\n};\n"],"mappings":";;;AAeA,MAAM,qBAAqB,IAAI,IAAiE;CAC9F,CAAC,MAAM;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CAC7C,CAAC,UAAU;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CACjD,CAAC,OAAO;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CAC9C,CAAC,SAAS;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CAChD,CAAC,WAAW;EAAE,OAAO;EAAW,QAAQ;EAAW,CAAC;CACrD,CAAC;AA8CF,MAAM,gBAAmB,YAA4B,KAAa,YAAoC;CACpG,MAAM,WAAW,WAAW,IAAI,IAAI;AACpC,KAAI,UAAU;AACZ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