@soda-gql/typegen 0.10.2 → 0.11.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/dist/index.cjs +135 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +135 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -156,6 +156,7 @@ const groupBySchema = (fieldSelections, schemas) => {
|
|
|
156
156
|
const inputType = hasVariables ? (0, __soda_gql_core.generateInputTypeFromSpecifiers)(schema, selection.variableDefinitions, { formatters: inputFormatters }) : "void";
|
|
157
157
|
group.fragments.push({
|
|
158
158
|
key: selection.key,
|
|
159
|
+
typename: selection.typename,
|
|
159
160
|
inputType,
|
|
160
161
|
outputType
|
|
161
162
|
});
|
|
@@ -315,7 +316,7 @@ const generateTypesCode = (grouped, schemas, injectsModulePath) => {
|
|
|
315
316
|
lines.push(...inputTypeLines);
|
|
316
317
|
lines.push("");
|
|
317
318
|
}
|
|
318
|
-
const fragmentEntries = fragments.sort((a, b) => a.key.localeCompare(b.key)).map((f) => ` readonly "${f.key}": { readonly input: ${f.inputType}; readonly output: ${f.outputType} };`);
|
|
319
|
+
const fragmentEntries = fragments.sort((a, b) => a.key.localeCompare(b.key)).map((f) => ` readonly "${f.key}": { readonly typename: "${f.typename}"; readonly input: ${f.inputType}; readonly output: ${f.outputType} };`);
|
|
319
320
|
const operationEntries = operations.sort((a, b) => a.key.localeCompare(b.key)).map((o) => ` readonly "${o.key}": { readonly input: ${o.inputType}; readonly output: ${o.outputType} };`);
|
|
320
321
|
lines.push(`export type PrebuiltTypes_${schemaName} = {`);
|
|
321
322
|
lines.push(" readonly fragments: {");
|
|
@@ -328,7 +329,7 @@ const generateTypesCode = (grouped, schemas, injectsModulePath) => {
|
|
|
328
329
|
lines.push(...operationEntries);
|
|
329
330
|
}
|
|
330
331
|
lines.push(" };");
|
|
331
|
-
lines.push("}
|
|
332
|
+
lines.push("};");
|
|
332
333
|
lines.push("");
|
|
333
334
|
}
|
|
334
335
|
return lines.join("\n");
|
|
@@ -387,12 +388,9 @@ const emitPrebuiltTypes = async (options) => {
|
|
|
387
388
|
/**
|
|
388
389
|
* Generate the prebuilt index module code.
|
|
389
390
|
*
|
|
390
|
-
* Generates index.prebuilt.ts with
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
* - Adapters from _internal-injects.ts
|
|
394
|
-
* - Runtime values from _internal.ts
|
|
395
|
-
* - AnyGqlContext instead of heavy Context type inference
|
|
391
|
+
* Generates index.prebuilt.ts with builder-level type resolution.
|
|
392
|
+
* Types are resolved at the fragment/operation builder level using TKey/TName,
|
|
393
|
+
* eliminating the need for ResolvePrebuiltElement at the composer level.
|
|
396
394
|
*/
|
|
397
395
|
const generatePrebuiltModule = (schemas, options) => {
|
|
398
396
|
const schemaNames = Array.from(schemas.keys());
|
|
@@ -409,60 +407,165 @@ const generatePrebuiltModule = (schemas, options) => {
|
|
|
409
407
|
`__inputTypeMethods_${name}`,
|
|
410
408
|
`__directiveMethods_${name}`
|
|
411
409
|
]);
|
|
410
|
+
const genericTypes = `
|
|
411
|
+
/**
|
|
412
|
+
* Generic field factory for type-erased field access.
|
|
413
|
+
* Returns a callable for nested field builders. Primitive fields can be spread directly.
|
|
414
|
+
* Runtime behavior differs but spread works for both: ...f.id() and ...f.user()(...)
|
|
415
|
+
*/
|
|
416
|
+
type GenericFieldFactory = (
|
|
417
|
+
...args: unknown[]
|
|
418
|
+
) => (nest: (tools: GenericFieldsBuilderTools) => AnyFields) => AnyFields;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Generic tools for fields builder callbacks.
|
|
422
|
+
* Uses type-erased factory to allow any field access while maintaining strict mode compatibility.
|
|
423
|
+
*/
|
|
424
|
+
type GenericFieldsBuilderTools = {
|
|
425
|
+
readonly f: Record<string, GenericFieldFactory>;
|
|
426
|
+
readonly $: Record<string, unknown>;
|
|
427
|
+
};
|
|
428
|
+
`;
|
|
429
|
+
const contextTypes = schemaNames.map((name) => `
|
|
430
|
+
/**
|
|
431
|
+
* Resolve fragment types at builder level using TKey.
|
|
432
|
+
* If TKey is a known key in PrebuiltTypes, return resolved types.
|
|
433
|
+
* Otherwise, return PrebuiltEntryNotFound.
|
|
434
|
+
*/
|
|
435
|
+
type ResolveFragmentAtBuilder_${name}<
|
|
436
|
+
TKey extends string | undefined
|
|
437
|
+
> = TKey extends keyof PrebuiltTypes_${name}["fragments"]
|
|
438
|
+
? Fragment<
|
|
439
|
+
PrebuiltTypes_${name}["fragments"][TKey]["typename"],
|
|
440
|
+
PrebuiltTypes_${name}["fragments"][TKey]["input"] extends infer TInput
|
|
441
|
+
? TInput extends void ? void : Partial<TInput & object>
|
|
442
|
+
: void,
|
|
443
|
+
Partial<AnyFields>,
|
|
444
|
+
PrebuiltTypes_${name}["fragments"][TKey]["output"] & object
|
|
445
|
+
>
|
|
446
|
+
: TKey extends undefined
|
|
447
|
+
? Fragment<"(unknown)", PrebuiltEntryNotFound<"(undefined)", "fragment">, Partial<AnyFields>, PrebuiltEntryNotFound<"(undefined)", "fragment">>
|
|
448
|
+
: Fragment<"(unknown)", PrebuiltEntryNotFound<TKey & string, "fragment">, Partial<AnyFields>, PrebuiltEntryNotFound<TKey & string, "fragment">>;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Resolve operation types at builder level using TName.
|
|
452
|
+
*/
|
|
453
|
+
type ResolveOperationAtBuilder_${name}<
|
|
454
|
+
TOperationType extends OperationType,
|
|
455
|
+
TName extends string
|
|
456
|
+
> = TName extends keyof PrebuiltTypes_${name}["operations"]
|
|
457
|
+
? Operation<
|
|
458
|
+
TOperationType,
|
|
459
|
+
TName,
|
|
460
|
+
string[],
|
|
461
|
+
PrebuiltTypes_${name}["operations"][TName]["input"] & AnyConstAssignableInput,
|
|
462
|
+
Partial<AnyFields>,
|
|
463
|
+
PrebuiltTypes_${name}["operations"][TName]["output"] & object
|
|
464
|
+
>
|
|
465
|
+
: Operation<
|
|
466
|
+
TOperationType,
|
|
467
|
+
TName,
|
|
468
|
+
string[],
|
|
469
|
+
PrebuiltEntryNotFound<TName, "operation">,
|
|
470
|
+
Partial<AnyFields>,
|
|
471
|
+
PrebuiltEntryNotFound<TName, "operation">
|
|
472
|
+
>;
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Fragment builder that resolves types at builder level using TKey.
|
|
476
|
+
*/
|
|
477
|
+
type PrebuiltFragmentBuilder_${name} = <TKey extends string | undefined = undefined>(
|
|
478
|
+
options: {
|
|
479
|
+
key?: TKey;
|
|
480
|
+
fields: (tools: GenericFieldsBuilderTools) => AnyFields;
|
|
481
|
+
variables?: Record<string, unknown>;
|
|
482
|
+
metadata?: unknown;
|
|
483
|
+
}
|
|
484
|
+
) => ResolveFragmentAtBuilder_${name}<TKey>;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Operation builder that resolves types at builder level using TName.
|
|
488
|
+
*/
|
|
489
|
+
type PrebuiltOperationBuilder_${name}<TOperationType extends OperationType> = <TName extends string>(
|
|
490
|
+
options: {
|
|
491
|
+
name: TName;
|
|
492
|
+
fields: (tools: GenericFieldsBuilderTools) => AnyFields;
|
|
493
|
+
variables?: Record<string, unknown>;
|
|
494
|
+
metadata?: unknown;
|
|
495
|
+
}
|
|
496
|
+
) => ResolveOperationAtBuilder_${name}<TOperationType, TName>;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Prebuilt context with builder-level type resolution for schema "${name}".
|
|
500
|
+
*/
|
|
501
|
+
type PrebuiltContext_${name} = {
|
|
502
|
+
readonly fragment: { [K: string]: PrebuiltFragmentBuilder_${name} };
|
|
503
|
+
readonly query: { readonly operation: PrebuiltOperationBuilder_${name}<"query"> };
|
|
504
|
+
readonly mutation: { readonly operation: PrebuiltOperationBuilder_${name}<"mutation"> };
|
|
505
|
+
readonly subscription: { readonly operation: PrebuiltOperationBuilder_${name}<"subscription"> };
|
|
506
|
+
readonly $var: unknown;
|
|
507
|
+
readonly $dir: StandardDirectives;
|
|
508
|
+
readonly $colocate: unknown;
|
|
509
|
+
};`).join("\n");
|
|
412
510
|
const gqlEntries = schemaNames.map((name) => {
|
|
413
511
|
const config = injection.get(name);
|
|
414
|
-
const
|
|
415
|
-
return ` ${name}:
|
|
416
|
-
AnyGraphqlSchema,
|
|
417
|
-
PrebuiltTypes_${name},
|
|
418
|
-
Record<string, unknown>,
|
|
419
|
-
StandardDirectives,
|
|
420
|
-
AnyGqlContext
|
|
421
|
-
>(
|
|
512
|
+
const adapterLine = config?.hasAdapter ? `,\n adapter: adapter_${name}` : "";
|
|
513
|
+
return ` ${name}: createGqlElementComposer(
|
|
422
514
|
__schema_${name} as AnyGraphqlSchema,
|
|
423
515
|
{
|
|
424
516
|
inputTypeMethods: __inputTypeMethods_${name},
|
|
425
|
-
directiveMethods: __directiveMethods_${name}
|
|
426
|
-
${adapterArg}
|
|
517
|
+
directiveMethods: __directiveMethods_${name}${adapterLine}
|
|
427
518
|
}
|
|
428
|
-
)`;
|
|
519
|
+
) as unknown as GqlComposer_${name}`;
|
|
429
520
|
});
|
|
430
521
|
const injectsImportSpecifiers = adapterImports.length > 0 ? adapterImports.join(", ") : "";
|
|
431
522
|
const injectsImportLine = injectsImportSpecifiers ? `import { ${injectsImportSpecifiers} } from "${options.injectsModulePath}";` : "";
|
|
432
523
|
const indexCode = `\
|
|
433
524
|
/**
|
|
434
|
-
* Prebuilt GQL module
|
|
525
|
+
* Prebuilt GQL module with builder-level type resolution.
|
|
435
526
|
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
* Uses lightweight imports:
|
|
440
|
-
* - Adapters from _internal-injects.ts
|
|
441
|
-
* - Runtime values from _internal.ts
|
|
442
|
-
* - AnyGqlContext instead of heavy Context type inference
|
|
527
|
+
* Types are resolved at the fragment/operation builder level using TKey/TName,
|
|
528
|
+
* not at the composer level. This enables proper typing for builder arguments
|
|
529
|
+
* and eliminates the need for ResolvePrebuiltElement.
|
|
443
530
|
*
|
|
444
531
|
* @module
|
|
445
532
|
* @generated by @soda-gql/typegen
|
|
446
533
|
*/
|
|
447
534
|
|
|
448
535
|
import {
|
|
449
|
-
|
|
450
|
-
type
|
|
536
|
+
createGqlElementComposer,
|
|
537
|
+
type AnyConstAssignableInput,
|
|
538
|
+
type AnyFields,
|
|
451
539
|
type AnyGraphqlSchema,
|
|
540
|
+
type Fragment,
|
|
541
|
+
type Operation,
|
|
542
|
+
type OperationType,
|
|
543
|
+
type PrebuiltEntryNotFound,
|
|
452
544
|
type StandardDirectives,
|
|
453
545
|
} from "@soda-gql/core";
|
|
454
546
|
${injectsImportLine}
|
|
455
547
|
import { ${internalImports.join(", ")} } from "${options.internalModulePath}";
|
|
456
548
|
import type { ${schemaNames.map((name) => `PrebuiltTypes_${name}`).join(", ")} } from "./types.prebuilt";
|
|
549
|
+
${genericTypes}
|
|
550
|
+
${contextTypes}
|
|
551
|
+
|
|
552
|
+
// Export context types for explicit annotation
|
|
553
|
+
${schemaNames.map((name) => `export type { PrebuiltContext_${name} };`).join("\n")}
|
|
554
|
+
|
|
555
|
+
// Composer type - TResult already has resolved types from builders, no ResolvePrebuiltElement needed
|
|
556
|
+
${schemaNames.map((name) => `type GqlComposer_${name} = {
|
|
557
|
+
<TResult>(composeElement: (context: PrebuiltContext_${name}) => TResult): TResult;
|
|
558
|
+
readonly $schema: AnyGraphqlSchema;
|
|
559
|
+
};`).join("\n")}
|
|
457
560
|
|
|
458
561
|
/**
|
|
459
|
-
* Prebuilt GQL composers with
|
|
562
|
+
* Prebuilt GQL composers with builder-level type resolution.
|
|
460
563
|
*
|
|
461
564
|
* These composers have the same runtime behavior as the base composers,
|
|
462
565
|
* but their return types are resolved from the prebuilt type registry
|
|
463
|
-
* instead of using
|
|
566
|
+
* at the builder level instead of using ResolvePrebuiltElement.
|
|
464
567
|
*/
|
|
465
|
-
export const gql = {
|
|
568
|
+
export const gql: { ${schemaNames.map((name) => `${name}: GqlComposer_${name}`).join("; ")} } = {
|
|
466
569
|
${gqlEntries.join(",\n")}
|
|
467
570
|
};
|
|
468
571
|
`;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["lines: string[]","warnings: string[]","missingKeyFragments: { canonicalId: string; typename: string; schemaLabel: string }[]","builderErrors","outputFormatters: TypeFormatters","inputFormatters: TypeFormatters","Kind","lines: string[]","formatters: TypeFormatters","adapterImports: string[]","extensionMap: Record<string, string>","withPrefix","currentExt"],"sources":["../src/errors.ts","../src/emitter.ts","../src/prebuilt-generator.ts","../src/runner.ts"],"sourcesContent":["/**\n * Error types for typegen package.\n *\n * @module\n */\n\nimport type { BuilderError } from \"@soda-gql/builder\";\n\n/**\n * Error codes specific to typegen operations.\n */\nexport type TypegenErrorCode =\n | \"TYPEGEN_CODEGEN_REQUIRED\"\n | \"TYPEGEN_SCHEMA_LOAD_FAILED\"\n | \"TYPEGEN_BUILD_FAILED\"\n | \"TYPEGEN_EMIT_FAILED\"\n | \"TYPEGEN_BUNDLE_FAILED\"\n | \"TYPEGEN_FRAGMENT_MISSING_KEY\";\n\n/**\n * Typegen-specific error type.\n */\nexport type TypegenSpecificError =\n | {\n readonly code: \"TYPEGEN_CODEGEN_REQUIRED\";\n readonly message: string;\n readonly outdir: string;\n }\n | {\n readonly code: \"TYPEGEN_SCHEMA_LOAD_FAILED\";\n readonly message: string;\n readonly schemaNames: readonly string[];\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_BUILD_FAILED\";\n readonly message: string;\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_EMIT_FAILED\";\n readonly message: string;\n readonly path: string;\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_BUNDLE_FAILED\";\n readonly message: string;\n readonly path: string;\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_FRAGMENT_MISSING_KEY\";\n readonly message: string;\n readonly fragments: readonly {\n readonly canonicalId: string;\n readonly typename: string;\n readonly schemaLabel: string;\n }[];\n };\n\n/**\n * Union of all typegen errors (specific + builder errors).\n */\nexport type TypegenError = TypegenSpecificError | BuilderError;\n\n/**\n * Error constructor helpers for concise error creation.\n */\nexport const typegenErrors = {\n codegenRequired: (outdir: string): TypegenSpecificError => ({\n code: \"TYPEGEN_CODEGEN_REQUIRED\",\n message: `Generated graphql-system module not found at '${outdir}'. Run 'soda-gql codegen' first.`,\n outdir,\n }),\n\n schemaLoadFailed: (schemaNames: readonly string[], cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_SCHEMA_LOAD_FAILED\",\n message: `Failed to load schemas: ${schemaNames.join(\", \")}`,\n schemaNames,\n cause,\n }),\n\n buildFailed: (message: string, cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_BUILD_FAILED\",\n message,\n cause,\n }),\n\n emitFailed: (path: string, message: string, cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_EMIT_FAILED\",\n message,\n path,\n cause,\n }),\n\n bundleFailed: (path: string, message: string, cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_BUNDLE_FAILED\",\n message,\n path,\n cause,\n }),\n\n fragmentMissingKey: (\n fragments: readonly { canonicalId: string; typename: string; schemaLabel: string }[],\n ): TypegenSpecificError => ({\n code: \"TYPEGEN_FRAGMENT_MISSING_KEY\",\n message: `${fragments.length} fragment(s) missing required 'key' property for prebuilt types`,\n fragments,\n }),\n} as const;\n\n/**\n * Format TypegenError for console output (human-readable).\n */\nexport const formatTypegenError = (error: TypegenError): string => {\n const lines: string[] = [];\n\n lines.push(`Error [${error.code}]: ${error.message}`);\n\n switch (error.code) {\n case \"TYPEGEN_CODEGEN_REQUIRED\":\n lines.push(` Output directory: ${error.outdir}`);\n lines.push(\" Hint: Run 'soda-gql codegen' to generate the graphql-system module first.\");\n break;\n case \"TYPEGEN_SCHEMA_LOAD_FAILED\":\n lines.push(` Schemas: ${error.schemaNames.join(\", \")}`);\n break;\n case \"TYPEGEN_EMIT_FAILED\":\n case \"TYPEGEN_BUNDLE_FAILED\":\n lines.push(` Path: ${error.path}`);\n break;\n case \"TYPEGEN_FRAGMENT_MISSING_KEY\":\n lines.push(\" Fragments missing 'key' property:\");\n for (const fragment of error.fragments) {\n lines.push(` - ${fragment.canonicalId} (${fragment.typename} on ${fragment.schemaLabel})`);\n }\n lines.push(\" Hint: Add a 'key' property to each fragment for prebuilt type resolution.\");\n break;\n }\n\n if (\"cause\" in error && error.cause) {\n lines.push(` Caused by: ${error.cause}`);\n }\n\n return lines.join(\"\\n\");\n};\n","/**\n * Prebuilt types emitter.\n *\n * Generates TypeScript type definitions for PrebuiltTypes registry\n * from field selection data and schema.\n *\n * ## Error Handling Strategy\n *\n * The emitter uses a partial failure approach for type calculation errors:\n *\n * **Recoverable errors** (result in warnings, element skipped):\n * - Type calculation failures (e.g., `calculateFieldsType` throws)\n * - Input type generation failures (e.g., `generateInputType` throws)\n * - These are caught per-element, logged as warnings, and the element is omitted\n *\n * **Fatal errors** (result in error result):\n * - `SCHEMA_NOT_FOUND`: Selection references non-existent schema\n * - `WRITE_FAILED`: Cannot write output file to disk\n *\n * This allows builds to succeed with partial type coverage when some elements\n * have issues, while providing visibility into problems via warnings.\n *\n * @module\n */\n\nimport { writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { type BuilderError, builderErrors, type FieldSelectionsMap } from \"@soda-gql/builder\";\nimport type { AnyGraphqlSchema, InputTypeSpecifiers, TypeFormatters } from \"@soda-gql/core\";\nimport { calculateFieldsType, generateInputObjectType, generateInputType, generateInputTypeFromSpecifiers } from \"@soda-gql/core\";\nimport { Kind, type TypeNode, type VariableDefinitionNode } from \"graphql\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport { type TypegenError, typegenErrors } from \"./errors\";\n\n/**\n * Options for emitting prebuilt types.\n */\nexport type PrebuiltTypesEmitterOptions = {\n /**\n * Schema definitions per schema name.\n * These come from the codegen output.\n */\n readonly schemas: Record<string, AnyGraphqlSchema>;\n /**\n * Field selections extracted from the builder.\n */\n readonly fieldSelections: FieldSelectionsMap;\n /**\n * Output directory (where prebuilt/types.ts should be written).\n * This should be the same as config.outdir.\n */\n readonly outdir: string;\n /**\n * Relative import path to _internal-injects.ts from types.prebuilt.ts.\n * Example: \"./_internal-injects\"\n */\n readonly injectsModulePath: string;\n};\n\ntype PrebuiltTypeEntry = {\n readonly key: string;\n readonly inputType: string;\n readonly outputType: string;\n};\n\ntype SchemaGroup = {\n fragments: PrebuiltTypeEntry[];\n operations: PrebuiltTypeEntry[];\n inputObjects: Set<string>;\n};\n\ntype GroupBySchemaResult = {\n readonly grouped: Map<string, SchemaGroup>;\n readonly warnings: string[];\n};\n\n/**\n * Group field selections by schema.\n * Uses the schemaLabel from each selection to group them correctly.\n *\n * In strict mode, all fragments must have a 'key' property. Fragments\n * without keys will cause an error.\n *\n * @returns Result containing grouped selections and warnings, or error if schema not found\n * or fragments are missing keys\n */\nconst groupBySchema = (\n fieldSelections: FieldSelectionsMap,\n schemas: Record<string, AnyGraphqlSchema>,\n): Result<GroupBySchemaResult, BuilderError | TypegenError> => {\n const grouped = new Map<string, SchemaGroup>();\n const warnings: string[] = [];\n const missingKeyFragments: { canonicalId: string; typename: string; schemaLabel: string }[] = [];\n\n // Initialize groups for each schema\n for (const schemaName of Object.keys(schemas)) {\n grouped.set(schemaName, { fragments: [], operations: [], inputObjects: new Set() });\n }\n\n for (const [canonicalId, selection] of fieldSelections) {\n // Use schemaLabel to determine which schema this selection belongs to\n const schemaName = selection.schemaLabel;\n const schema = schemas[schemaName];\n const group = grouped.get(schemaName);\n\n if (!schema || !group) {\n return err(builderErrors.schemaNotFound(schemaName, canonicalId));\n }\n\n // Create formatters for schema-specific type names\n const outputFormatters: TypeFormatters = {\n scalarOutput: (name) => `ScalarOutput_${schemaName}<\"${name}\">`,\n };\n const inputFormatters: TypeFormatters = {\n scalarInput: (name) => `ScalarInput_${schemaName}<\"${name}\">`,\n inputObject: (name) => `Input_${schemaName}_${name}`,\n };\n\n if (selection.type === \"fragment\") {\n // Strict mode: fragments must have keys\n if (!selection.key) {\n missingKeyFragments.push({\n canonicalId,\n typename: selection.typename,\n schemaLabel: selection.schemaLabel,\n });\n continue; // Continue collecting all errors before reporting\n }\n\n try {\n // Collect input objects used in fragment variables\n const usedInputObjects = collectUsedInputObjectsFromSpecifiers(schema, selection.variableDefinitions);\n for (const inputName of usedInputObjects) {\n group.inputObjects.add(inputName);\n }\n\n // Generate output type with schema-specific scalar names\n const outputType = calculateFieldsType(schema, selection.fields, outputFormatters);\n\n // Generate input type from variableDefinitions with schema-specific names\n const hasVariables = Object.keys(selection.variableDefinitions).length > 0;\n const inputType = hasVariables\n ? generateInputTypeFromSpecifiers(schema, selection.variableDefinitions, { formatters: inputFormatters })\n : \"void\";\n\n group.fragments.push({\n key: selection.key,\n inputType,\n outputType,\n });\n } catch (error) {\n warnings.push(\n `[prebuilt] Failed to calculate type for fragment \"${selection.key}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n } else if (selection.type === \"operation\") {\n try {\n // Collect input objects used in this operation\n const usedInputObjects = collectUsedInputObjects(schema, selection.variableDefinitions);\n for (const inputName of usedInputObjects) {\n group.inputObjects.add(inputName);\n }\n\n // Generate output type with schema-specific scalar names\n const outputType = calculateFieldsType(schema, selection.fields, outputFormatters);\n\n // Generate input type with schema-specific scalar and input object names\n const inputType = generateInputType(schema, selection.variableDefinitions, inputFormatters);\n\n group.operations.push({\n key: selection.operationName,\n inputType,\n outputType,\n });\n } catch (error) {\n warnings.push(\n `[prebuilt] Failed to calculate type for operation \"${selection.operationName}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n }\n\n // Strict mode: error if any fragments are missing keys\n if (missingKeyFragments.length > 0) {\n return err(typegenErrors.fragmentMissingKey(missingKeyFragments));\n }\n\n return ok({ grouped, warnings });\n};\n\n/**\n * Extract input object names from a GraphQL TypeNode.\n */\nconst extractInputObjectsFromType = (schema: AnyGraphqlSchema, typeNode: TypeNode, inputObjects: Set<string>): void => {\n switch (typeNode.kind) {\n case Kind.NON_NULL_TYPE:\n extractInputObjectsFromType(schema, typeNode.type, inputObjects);\n break;\n case Kind.LIST_TYPE:\n extractInputObjectsFromType(schema, typeNode.type, inputObjects);\n break;\n case Kind.NAMED_TYPE: {\n const name = typeNode.name.value;\n // Check if it's an input object (not a scalar or enum)\n if (!schema.scalar[name] && !schema.enum[name] && schema.input[name]) {\n inputObjects.add(name);\n }\n break;\n }\n }\n};\n\n/**\n * Recursively collect nested input objects from schema definitions.\n * Takes a set of initial input names and expands to include all nested inputs.\n */\nconst collectNestedInputObjects = (schema: AnyGraphqlSchema, initialInputNames: Set<string>): Set<string> => {\n const inputObjects = new Set(initialInputNames);\n\n const collectNested = (inputName: string, seen: Set<string>): void => {\n if (seen.has(inputName)) {\n return;\n }\n seen.add(inputName);\n\n const inputDef = schema.input[inputName];\n if (!inputDef) {\n return;\n }\n\n for (const field of Object.values(inputDef.fields)) {\n if (field.kind === \"input\" && !inputObjects.has(field.name)) {\n inputObjects.add(field.name);\n collectNested(field.name, seen);\n }\n }\n };\n\n for (const inputName of Array.from(initialInputNames)) {\n collectNested(inputName, new Set());\n }\n\n return inputObjects;\n};\n\n/**\n * Collect all input object types used in variable definitions.\n * Recursively collects nested input objects from the schema.\n */\nconst collectUsedInputObjects = (\n schema: AnyGraphqlSchema,\n variableDefinitions: readonly VariableDefinitionNode[],\n): Set<string> => {\n const directInputs = new Set<string>();\n for (const varDef of variableDefinitions) {\n extractInputObjectsFromType(schema, varDef.type, directInputs);\n }\n return collectNestedInputObjects(schema, directInputs);\n};\n\n/**\n * Collect all input object types used in InputTypeSpecifiers.\n * Recursively collects nested input objects from the schema.\n */\nconst collectUsedInputObjectsFromSpecifiers = (schema: AnyGraphqlSchema, specifiers: InputTypeSpecifiers): Set<string> => {\n const directInputs = new Set<string>();\n for (const specifier of Object.values(specifiers)) {\n if (specifier.kind === \"input\" && schema.input[specifier.name]) {\n directInputs.add(specifier.name);\n }\n }\n return collectNestedInputObjects(schema, directInputs);\n};\n\n/**\n * Generate type definitions for input objects.\n */\nconst generateInputObjectTypeDefinitions = (schema: AnyGraphqlSchema, schemaName: string, inputNames: Set<string>): string[] => {\n const lines: string[] = [];\n\n // Get depth config from schema (optional properties defined in AnyGraphqlSchema)\n const defaultDepth = schema.__defaultInputDepth ?? 3;\n const depthOverrides = schema.__inputDepthOverrides ?? {};\n\n // Create formatters for schema-specific type names\n const formatters: TypeFormatters = {\n scalarInput: (name) => `ScalarInput_${schemaName}<\"${name}\">`,\n inputObject: (name) => `Input_${schemaName}_${name}`,\n };\n\n // Sort for deterministic output\n const sortedNames = Array.from(inputNames).sort();\n\n for (const inputName of sortedNames) {\n const typeString = generateInputObjectType(schema, inputName, {\n defaultDepth,\n depthOverrides,\n formatters,\n });\n\n lines.push(`type Input_${schemaName}_${inputName} = ${typeString};`);\n }\n\n return lines;\n};\n\n/**\n * Generate the TypeScript code for prebuilt types.\n */\nconst generateTypesCode = (\n grouped: Map<string, SchemaGroup>,\n schemas: Record<string, AnyGraphqlSchema>,\n injectsModulePath: string,\n): string => {\n const schemaNames = Object.keys(schemas);\n\n const lines: string[] = [\n \"/**\",\n \" * Prebuilt type registry.\",\n \" *\",\n \" * This file is auto-generated by @soda-gql/typegen.\",\n \" * Do not edit manually.\",\n \" *\",\n \" * @module\",\n \" * @generated\",\n \" */\",\n \"\",\n 'import type { PrebuiltTypeRegistry } from \"@soda-gql/core\";',\n ];\n\n // Generate import from _internal-injects.ts\n const scalarImports = schemaNames.map((name) => `scalar_${name}`).join(\", \");\n lines.push(`import type { ${scalarImports} } from \"${injectsModulePath}\";`);\n\n lines.push(\"\");\n\n // Generate ScalarInput and ScalarOutput helper types\n for (const schemaName of schemaNames) {\n lines.push(\n `type ScalarInput_${schemaName}<T extends keyof typeof scalar_${schemaName}> = ` +\n `typeof scalar_${schemaName}[T][\"$type\"][\"input\"];`,\n );\n lines.push(\n `type ScalarOutput_${schemaName}<T extends keyof typeof scalar_${schemaName}> = ` +\n `typeof scalar_${schemaName}[T][\"$type\"][\"output\"];`,\n );\n }\n\n lines.push(\"\");\n\n for (const [schemaName, { fragments, operations, inputObjects }] of grouped) {\n const schema = schemas[schemaName];\n\n // Generate input object type definitions if there are any\n if (inputObjects.size > 0 && schema) {\n lines.push(\"// Input object types\");\n const inputTypeLines = generateInputObjectTypeDefinitions(schema, schemaName, inputObjects);\n lines.push(...inputTypeLines);\n lines.push(\"\");\n }\n\n // Generate fragments type\n const fragmentEntries = fragments\n .sort((a, b) => a.key.localeCompare(b.key))\n .map((f) => ` readonly \"${f.key}\": { readonly input: ${f.inputType}; readonly output: ${f.outputType} };`);\n\n // Generate operations type\n const operationEntries = operations\n .sort((a, b) => a.key.localeCompare(b.key))\n .map((o) => ` readonly \"${o.key}\": { readonly input: ${o.inputType}; readonly output: ${o.outputType} };`);\n\n lines.push(`export type PrebuiltTypes_${schemaName} = {`);\n lines.push(\" readonly fragments: {\");\n if (fragmentEntries.length > 0) {\n lines.push(...fragmentEntries);\n }\n lines.push(\" };\");\n lines.push(\" readonly operations: {\");\n if (operationEntries.length > 0) {\n lines.push(...operationEntries);\n }\n lines.push(\" };\");\n lines.push(\"} satisfies PrebuiltTypeRegistry;\");\n lines.push(\"\");\n }\n\n return lines.join(\"\\n\");\n};\n\n/**\n * Result of emitting prebuilt types.\n */\nexport type PrebuiltTypesEmitResult = {\n readonly path: string;\n readonly warnings: readonly string[];\n};\n\n/**\n * Emit prebuilt types to the prebuilt/types.ts file.\n *\n * This function uses a partial failure strategy: if type calculation fails for\n * individual elements (e.g., due to invalid field selections or missing schema\n * types), those elements are skipped and warnings are collected rather than\n * failing the entire emission. This allows builds to succeed even when some\n * elements have issues, while still reporting problems via warnings.\n *\n * @param options - Emitter options including schemas, field selections, and output directory\n * @returns Result containing output path and warnings, or error if a hard failure occurs\n *\n * @example\n * ```typescript\n * const result = await emitPrebuiltTypes({\n * schemas: { mySchema: schema },\n * fieldSelections,\n * outdir: \"./generated\",\n * injects: { mySchema: { scalars: \"./scalars.ts\" } },\n * });\n *\n * if (result.isOk()) {\n * console.log(`Generated: ${result.value.path}`);\n * if (result.value.warnings.length > 0) {\n * console.warn(\"Warnings:\", result.value.warnings);\n * }\n * }\n * ```\n */\nexport const emitPrebuiltTypes = async (\n options: PrebuiltTypesEmitterOptions,\n): Promise<Result<PrebuiltTypesEmitResult, BuilderError | TypegenError>> => {\n const { schemas, fieldSelections, outdir, injectsModulePath } = options;\n\n // Group selections by schema\n const groupResult = groupBySchema(fieldSelections, schemas);\n if (groupResult.isErr()) {\n return err(groupResult.error);\n }\n const { grouped, warnings } = groupResult.value;\n\n // Generate the types code\n const code = generateTypesCode(grouped, schemas, injectsModulePath);\n\n // Write to types.prebuilt.ts\n const typesPath = join(outdir, \"types.prebuilt.ts\");\n\n try {\n await writeFile(typesPath, code, \"utf-8\");\n return ok({ path: typesPath, warnings });\n } catch (error) {\n return err(\n builderErrors.writeFailed(\n typesPath,\n `Failed to write prebuilt types: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n }\n};\n","/**\n * Prebuilt module generator for bundler-compatible type resolution.\n *\n * Generates index.prebuilt.ts in the output directory (flat layout).\n * This module creates prebuilt gql composers that use PrebuiltTypes\n * for type lookup instead of complex inference.\n *\n * Generated file structure (in outdir):\n * - index.prebuilt.ts: Prebuilt gql composers\n * - types.prebuilt.ts: Type registry (generated by emitter.ts)\n *\n * Import strategy for lightweight type serialization:\n * - Adapters from _internal-injects.ts (scalar, adapter)\n * - Runtime values from _internal.ts (__schema_*, etc.)\n * - Uses AnyGqlContext instead of heavy Context type inference\n *\n * @module\n */\n\nimport type { DocumentNode } from \"graphql\";\n\nexport type PrebuiltGeneratorOptions = {\n /**\n * Relative import path to the internal module.\n * Example: \"./_internal\" (from index.prebuilt.ts to _internal.ts)\n */\n readonly internalModulePath: string;\n /**\n * Relative import path to the injects module.\n * Example: \"./_internal-injects\" (from index.prebuilt.ts to _internal-injects.ts)\n */\n readonly injectsModulePath: string;\n /**\n * Per-schema injection config.\n * Maps schema name to whether it has an adapter.\n */\n readonly injection?: Map<\n string,\n {\n readonly hasAdapter?: boolean;\n }\n >;\n};\n\nexport type PrebuiltGeneratedModule = {\n /** The generated code for index.prebuilt.ts */\n readonly indexCode: string;\n};\n\n/**\n * Generate the prebuilt index module code.\n *\n * Generates index.prebuilt.ts with prebuilt gql composers using\n * createPrebuiltGqlElementComposer. The generated module uses\n * lightweight imports for type serialization compatibility:\n * - Adapters from _internal-injects.ts\n * - Runtime values from _internal.ts\n * - AnyGqlContext instead of heavy Context type inference\n */\nexport const generatePrebuiltModule = (\n schemas: Map<string, DocumentNode>,\n options: PrebuiltGeneratorOptions,\n): PrebuiltGeneratedModule => {\n const schemaNames = Array.from(schemas.keys());\n const injection = options.injection ?? new Map();\n\n // Generate adapter imports from _internal-injects.ts\n const adapterImports: string[] = [];\n for (const name of schemaNames) {\n const config = injection.get(name);\n if (config?.hasAdapter) {\n adapterImports.push(`adapter_${name}`);\n }\n }\n\n // Generate internal imports (runtime values needed for composer creation)\n const internalImports = schemaNames.flatMap((name) => [\n `__schema_${name}`,\n `__inputTypeMethods_${name}`,\n `__directiveMethods_${name}`,\n ]);\n\n // Generate gql entries using createPrebuiltGqlElementComposer\n const gqlEntries = schemaNames.map((name) => {\n const config = injection.get(name);\n const adapterArg = config?.hasAdapter ? `adapter: adapter_${name},` : \"\";\n\n return ` ${name}: createPrebuiltGqlElementComposer<\n AnyGraphqlSchema,\n PrebuiltTypes_${name},\n Record<string, unknown>,\n StandardDirectives,\n AnyGqlContext\n >(\n __schema_${name} as AnyGraphqlSchema,\n {\n inputTypeMethods: __inputTypeMethods_${name},\n directiveMethods: __directiveMethods_${name},\n ${adapterArg}\n }\n )`;\n });\n\n // Build injects import line\n const injectsImportSpecifiers = adapterImports.length > 0 ? adapterImports.join(\", \") : \"\";\n const injectsImportLine = injectsImportSpecifiers\n ? `import { ${injectsImportSpecifiers} } from \"${options.injectsModulePath}\";`\n : \"\";\n\n // Generate index.prebuilt.ts code with lightweight imports\n const indexCode = `\\\n/**\n * Prebuilt GQL module for bundler-compatible type resolution.\n *\n * This module creates prebuilt composers using createPrebuiltGqlElementComposer\n * that look up types from PrebuiltTypes instead of complex inference.\n *\n * Uses lightweight imports:\n * - Adapters from _internal-injects.ts\n * - Runtime values from _internal.ts\n * - AnyGqlContext instead of heavy Context type inference\n *\n * @module\n * @generated by @soda-gql/typegen\n */\n\nimport {\n createPrebuiltGqlElementComposer,\n type AnyGqlContext,\n type AnyGraphqlSchema,\n type StandardDirectives,\n} from \"@soda-gql/core\";\n${injectsImportLine}\nimport { ${internalImports.join(\", \")} } from \"${options.internalModulePath}\";\nimport type { ${schemaNames.map((name) => `PrebuiltTypes_${name}`).join(\", \")} } from \"./types.prebuilt\";\n\n/**\n * Prebuilt GQL composers with strict type resolution from PrebuiltTypeRegistry.\n *\n * These composers have the same runtime behavior as the base composers,\n * but their return types are resolved from the prebuilt type registry\n * instead of using complex type inference.\n */\nexport const gql = {\n${gqlEntries.join(\",\\n\")}\n};\n`;\n\n return {\n indexCode,\n };\n};\n","/**\n * Main typegen runner.\n *\n * Orchestrates the prebuilt type generation process:\n * 1. Load schemas from generated CJS bundle\n * 2. Generate index.prebuilt.ts\n * 3. Build artifact to evaluate elements\n * 4. Extract field selections\n * 5. Emit types.prebuilt.ts\n * 6. Bundle prebuilt module\n *\n * @module\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, extname, join, relative, resolve } from \"node:path\";\nimport {\n createBuilderService,\n extractFieldSelections,\n type IntermediateArtifactElement,\n loadSchemasFromBundle,\n} from \"@soda-gql/builder\";\nimport type { CanonicalId } from \"@soda-gql/common\";\nimport type { ResolvedSodaGqlConfig } from \"@soda-gql/config\";\nimport { build } from \"esbuild\";\nimport { type DocumentNode, parse } from \"graphql\";\nimport { err, ok } from \"neverthrow\";\nimport { emitPrebuiltTypes } from \"./emitter\";\nimport { typegenErrors } from \"./errors\";\nimport { generatePrebuiltModule } from \"./prebuilt-generator\";\nimport type { TypegenResult, TypegenSuccess } from \"./types\";\n\n/**\n * Options for running typegen.\n */\nexport type RunTypegenOptions = {\n /**\n * Resolved soda-gql configuration.\n */\n readonly config: ResolvedSodaGqlConfig;\n};\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 `./${targetPath.slice(0, -sourceExt.length).split(\"/\").pop()}`;\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 ? targetPath.slice(0, -sourceExt.length).split(\"/\").pop() : targetPath.split(\"/\").pop();\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\n/**\n * Bundle the prebuilt module to CJS format.\n */\nconst bundlePrebuiltModule = async (sourcePath: string): Promise<{ cjsPath: string }> => {\n const sourceExt = extname(sourcePath);\n const baseName = sourcePath.slice(0, -sourceExt.length);\n const cjsPath = `${baseName}.cjs`;\n\n await build({\n entryPoints: [sourcePath],\n outfile: cjsPath,\n format: \"cjs\",\n platform: \"node\",\n bundle: true,\n external: [\"@soda-gql/core\", \"@soda-gql/runtime\"],\n sourcemap: false,\n minify: false,\n treeShaking: false,\n });\n\n return { cjsPath };\n};\n\n/**\n * Write a TypeScript module to disk.\n */\nconst writeModule = async (path: string, content: string): Promise<void> => {\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, content, \"utf-8\");\n};\n\n/**\n * Load GraphQL schema documents from schema paths.\n * This is needed for generatePrebuiltModule which expects DocumentNode.\n */\nconst loadSchemaDocuments = (schemasConfig: ResolvedSodaGqlConfig[\"schemas\"]): Map<string, DocumentNode> => {\n const documents = new Map<string, DocumentNode>();\n\n for (const [name, schemaConfig] of Object.entries(schemasConfig)) {\n const schemaPaths = Array.isArray(schemaConfig.schema) ? schemaConfig.schema : [schemaConfig.schema];\n\n // Concatenate all schema files\n let combinedSource = \"\";\n for (const schemaPath of schemaPaths) {\n combinedSource += `${readFileSync(schemaPath, \"utf-8\")}\\n`;\n }\n\n documents.set(name, parse(combinedSource));\n }\n\n return documents;\n};\n\n/**\n * Run the typegen process.\n *\n * This function:\n * 1. Loads schemas from the generated CJS bundle\n * 2. Generates index.prebuilt.ts using generatePrebuiltModule\n * 3. Creates a BuilderService and builds the artifact\n * 4. Extracts field selections from the artifact\n * 5. Emits types.prebuilt.ts using emitPrebuiltTypes\n * 6. Bundles the prebuilt module\n *\n * @param options - Typegen options including config\n * @returns Result containing success data or error\n */\nexport const runTypegen = async (options: RunTypegenOptions): Promise<TypegenResult> => {\n const { config } = options;\n const outdir = resolve(config.outdir);\n const cjsPath = join(outdir, \"index.cjs\");\n const importSpecifierOptions = { includeExtension: config.styles.importExtension };\n\n // Step 1: Check if codegen has been run\n if (!existsSync(cjsPath)) {\n return err(typegenErrors.codegenRequired(outdir));\n }\n\n // Step 2: Load schemas from CJS bundle\n const schemaNames = Object.keys(config.schemas);\n const schemasResult = loadSchemasFromBundle(cjsPath, schemaNames);\n if (schemasResult.isErr()) {\n return err(typegenErrors.schemaLoadFailed(schemaNames, schemasResult.error));\n }\n const schemas = schemasResult.value;\n\n // Step 3: Load schema documents and generate index.prebuilt.ts\n const schemaDocuments = loadSchemaDocuments(config.schemas);\n const prebuiltIndexPath = join(outdir, \"index.prebuilt.ts\");\n\n // Calculate import paths from index.prebuilt.ts to internal modules\n const internalModulePath = toImportSpecifier(prebuiltIndexPath, join(outdir, \"_internal.ts\"), importSpecifierOptions);\n const injectsModulePath = toImportSpecifier(prebuiltIndexPath, join(outdir, \"_internal-injects.ts\"), importSpecifierOptions);\n\n // Build injection config for generatePrebuiltModule\n const injection = new Map<string, { hasAdapter?: boolean }>();\n for (const [schemaName, schemaConfig] of Object.entries(config.schemas)) {\n injection.set(schemaName, {\n hasAdapter: !!schemaConfig.inject.adapter,\n });\n }\n\n const prebuilt = generatePrebuiltModule(schemaDocuments, {\n internalModulePath,\n injectsModulePath,\n injection,\n });\n\n // Write index.prebuilt.ts\n try {\n await writeModule(prebuiltIndexPath, prebuilt.indexCode);\n } catch (error) {\n return err(\n typegenErrors.emitFailed(\n prebuiltIndexPath,\n `Failed to write prebuilt index: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n }\n\n // Step 4: Build artifact using BuilderService\n const builderService = createBuilderService({\n config,\n });\n\n const artifactResult = await builderService.buildAsync();\n\n if (artifactResult.isErr()) {\n return err(typegenErrors.buildFailed(`Builder failed: ${artifactResult.error.message}`, artifactResult.error));\n }\n\n // Step 5: Extract field selections from intermediate elements\n const intermediateElements = builderService.getIntermediateElements();\n if (!intermediateElements) {\n return err(typegenErrors.buildFailed(\"No intermediate elements available after build\", undefined));\n }\n\n const fieldSelectionsResult = extractFieldSelections(intermediateElements as Record<CanonicalId, IntermediateArtifactElement>);\n const { selections: fieldSelections, warnings: extractWarnings } = fieldSelectionsResult;\n\n // Step 6: Emit types.prebuilt.ts\n // Reuse injectsModulePath from step 3 (same directory, same relative path)\n const emitResult = await emitPrebuiltTypes({\n schemas,\n fieldSelections,\n outdir,\n injectsModulePath,\n });\n\n if (emitResult.isErr()) {\n return err(emitResult.error);\n }\n\n const { path: prebuiltTypesPath, warnings: emitWarnings } = emitResult.value;\n\n // Step 7: Bundle prebuilt module\n try {\n await bundlePrebuiltModule(prebuiltIndexPath);\n } catch (error) {\n return err(\n typegenErrors.bundleFailed(\n prebuiltIndexPath,\n `Failed to bundle prebuilt module: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n }\n\n // Count fragments and operations\n let fragmentCount = 0;\n let operationCount = 0;\n for (const selection of fieldSelections.values()) {\n if (selection.type === \"fragment\" && selection.key) {\n fragmentCount++;\n } else if (selection.type === \"operation\") {\n operationCount++;\n }\n }\n\n const allWarnings = [...extractWarnings, ...emitWarnings];\n\n return ok({\n prebuiltIndexPath,\n prebuiltTypesPath,\n fragmentCount,\n operationCount,\n warnings: allWarnings,\n } satisfies TypegenSuccess);\n};\n"],"mappings":";;;;;;;;;;;;;AAqEA,MAAa,gBAAgB;CAC3B,kBAAkB,YAA0C;EAC1D,MAAM;EACN,SAAS,iDAAiD,OAAO;EACjE;EACD;CAED,mBAAmB,aAAgC,WAA2C;EAC5F,MAAM;EACN,SAAS,2BAA2B,YAAY,KAAK,KAAK;EAC1D;EACA;EACD;CAED,cAAc,SAAiB,WAA2C;EACxE,MAAM;EACN;EACA;EACD;CAED,aAAa,MAAc,SAAiB,WAA2C;EACrF,MAAM;EACN;EACA;EACA;EACD;CAED,eAAe,MAAc,SAAiB,WAA2C;EACvF,MAAM;EACN;EACA;EACA;EACD;CAED,qBACE,eAC0B;EAC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MAAM,aAAa,gBAAgB,QAAQ,EAAE;AAChD,MAAI,UAAU,SAAS,cAAc,UAAU,KAAK;AAClD;aACS,UAAU,SAAS,aAAa;AACzC;;;CAIJ,MAAM,cAAc,CAAC,GAAG,iBAAiB,GAAG,aAAa;AAEzD,2BAAU;EACR;EACA;EACA;EACA;EACA,UAAU;EACX,CAA0B"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["lines: string[]","warnings: string[]","missingKeyFragments: { canonicalId: string; typename: string; schemaLabel: string }[]","builderErrors","outputFormatters: TypeFormatters","inputFormatters: TypeFormatters","Kind","lines: string[]","formatters: TypeFormatters","adapterImports: string[]","extensionMap: Record<string, string>","withPrefix","currentExt"],"sources":["../src/errors.ts","../src/emitter.ts","../src/prebuilt-generator.ts","../src/runner.ts"],"sourcesContent":["/**\n * Error types for typegen package.\n *\n * @module\n */\n\nimport type { BuilderError } from \"@soda-gql/builder\";\n\n/**\n * Error codes specific to typegen operations.\n */\nexport type TypegenErrorCode =\n | \"TYPEGEN_CODEGEN_REQUIRED\"\n | \"TYPEGEN_SCHEMA_LOAD_FAILED\"\n | \"TYPEGEN_BUILD_FAILED\"\n | \"TYPEGEN_EMIT_FAILED\"\n | \"TYPEGEN_BUNDLE_FAILED\"\n | \"TYPEGEN_FRAGMENT_MISSING_KEY\";\n\n/**\n * Typegen-specific error type.\n */\nexport type TypegenSpecificError =\n | {\n readonly code: \"TYPEGEN_CODEGEN_REQUIRED\";\n readonly message: string;\n readonly outdir: string;\n }\n | {\n readonly code: \"TYPEGEN_SCHEMA_LOAD_FAILED\";\n readonly message: string;\n readonly schemaNames: readonly string[];\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_BUILD_FAILED\";\n readonly message: string;\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_EMIT_FAILED\";\n readonly message: string;\n readonly path: string;\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_BUNDLE_FAILED\";\n readonly message: string;\n readonly path: string;\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_FRAGMENT_MISSING_KEY\";\n readonly message: string;\n readonly fragments: readonly {\n readonly canonicalId: string;\n readonly typename: string;\n readonly schemaLabel: string;\n }[];\n };\n\n/**\n * Union of all typegen errors (specific + builder errors).\n */\nexport type TypegenError = TypegenSpecificError | BuilderError;\n\n/**\n * Error constructor helpers for concise error creation.\n */\nexport const typegenErrors = {\n codegenRequired: (outdir: string): TypegenSpecificError => ({\n code: \"TYPEGEN_CODEGEN_REQUIRED\",\n message: `Generated graphql-system module not found at '${outdir}'. Run 'soda-gql codegen' first.`,\n outdir,\n }),\n\n schemaLoadFailed: (schemaNames: readonly string[], cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_SCHEMA_LOAD_FAILED\",\n message: `Failed to load schemas: ${schemaNames.join(\", \")}`,\n schemaNames,\n cause,\n }),\n\n buildFailed: (message: string, cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_BUILD_FAILED\",\n message,\n cause,\n }),\n\n emitFailed: (path: string, message: string, cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_EMIT_FAILED\",\n message,\n path,\n cause,\n }),\n\n bundleFailed: (path: string, message: string, cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_BUNDLE_FAILED\",\n message,\n path,\n cause,\n }),\n\n fragmentMissingKey: (\n fragments: readonly { canonicalId: string; typename: string; schemaLabel: string }[],\n ): TypegenSpecificError => ({\n code: \"TYPEGEN_FRAGMENT_MISSING_KEY\",\n message: `${fragments.length} fragment(s) missing required 'key' property for prebuilt types`,\n fragments,\n }),\n} as const;\n\n/**\n * Format TypegenError for console output (human-readable).\n */\nexport const formatTypegenError = (error: TypegenError): string => {\n const lines: string[] = [];\n\n lines.push(`Error [${error.code}]: ${error.message}`);\n\n switch (error.code) {\n case \"TYPEGEN_CODEGEN_REQUIRED\":\n lines.push(` Output directory: ${error.outdir}`);\n lines.push(\" Hint: Run 'soda-gql codegen' to generate the graphql-system module first.\");\n break;\n case \"TYPEGEN_SCHEMA_LOAD_FAILED\":\n lines.push(` Schemas: ${error.schemaNames.join(\", \")}`);\n break;\n case \"TYPEGEN_EMIT_FAILED\":\n case \"TYPEGEN_BUNDLE_FAILED\":\n lines.push(` Path: ${error.path}`);\n break;\n case \"TYPEGEN_FRAGMENT_MISSING_KEY\":\n lines.push(\" Fragments missing 'key' property:\");\n for (const fragment of error.fragments) {\n lines.push(` - ${fragment.canonicalId} (${fragment.typename} on ${fragment.schemaLabel})`);\n }\n lines.push(\" Hint: Add a 'key' property to each fragment for prebuilt type resolution.\");\n break;\n }\n\n if (\"cause\" in error && error.cause) {\n lines.push(` Caused by: ${error.cause}`);\n }\n\n return lines.join(\"\\n\");\n};\n","/**\n * Prebuilt types emitter.\n *\n * Generates TypeScript type definitions for PrebuiltTypes registry\n * from field selection data and schema.\n *\n * ## Error Handling Strategy\n *\n * The emitter uses a partial failure approach for type calculation errors:\n *\n * **Recoverable errors** (result in warnings, element skipped):\n * - Type calculation failures (e.g., `calculateFieldsType` throws)\n * - Input type generation failures (e.g., `generateInputType` throws)\n * - These are caught per-element, logged as warnings, and the element is omitted\n *\n * **Fatal errors** (result in error result):\n * - `SCHEMA_NOT_FOUND`: Selection references non-existent schema\n * - `WRITE_FAILED`: Cannot write output file to disk\n *\n * This allows builds to succeed with partial type coverage when some elements\n * have issues, while providing visibility into problems via warnings.\n *\n * @module\n */\n\nimport { writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { type BuilderError, builderErrors, type FieldSelectionsMap } from \"@soda-gql/builder\";\nimport type { AnyGraphqlSchema, InputTypeSpecifiers, TypeFormatters } from \"@soda-gql/core\";\nimport { calculateFieldsType, generateInputObjectType, generateInputType, generateInputTypeFromSpecifiers } from \"@soda-gql/core\";\nimport { Kind, type TypeNode, type VariableDefinitionNode } from \"graphql\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport { type TypegenError, typegenErrors } from \"./errors\";\n\n/**\n * Options for emitting prebuilt types.\n */\nexport type PrebuiltTypesEmitterOptions = {\n /**\n * Schema definitions per schema name.\n * These come from the codegen output.\n */\n readonly schemas: Record<string, AnyGraphqlSchema>;\n /**\n * Field selections extracted from the builder.\n */\n readonly fieldSelections: FieldSelectionsMap;\n /**\n * Output directory (where prebuilt/types.ts should be written).\n * This should be the same as config.outdir.\n */\n readonly outdir: string;\n /**\n * Relative import path to _internal-injects.ts from types.prebuilt.ts.\n * Example: \"./_internal-injects\"\n */\n readonly injectsModulePath: string;\n};\n\ntype PrebuiltFragmentEntry = {\n readonly key: string;\n readonly typename: string;\n readonly inputType: string;\n readonly outputType: string;\n};\n\ntype PrebuiltOperationEntry = {\n readonly key: string;\n readonly inputType: string;\n readonly outputType: string;\n};\n\ntype SchemaGroup = {\n fragments: PrebuiltFragmentEntry[];\n operations: PrebuiltOperationEntry[];\n inputObjects: Set<string>;\n};\n\ntype GroupBySchemaResult = {\n readonly grouped: Map<string, SchemaGroup>;\n readonly warnings: string[];\n};\n\n/**\n * Group field selections by schema.\n * Uses the schemaLabel from each selection to group them correctly.\n *\n * In strict mode, all fragments must have a 'key' property. Fragments\n * without keys will cause an error.\n *\n * @returns Result containing grouped selections and warnings, or error if schema not found\n * or fragments are missing keys\n */\nconst groupBySchema = (\n fieldSelections: FieldSelectionsMap,\n schemas: Record<string, AnyGraphqlSchema>,\n): Result<GroupBySchemaResult, BuilderError | TypegenError> => {\n const grouped = new Map<string, SchemaGroup>();\n const warnings: string[] = [];\n const missingKeyFragments: { canonicalId: string; typename: string; schemaLabel: string }[] = [];\n\n // Initialize groups for each schema\n for (const schemaName of Object.keys(schemas)) {\n grouped.set(schemaName, { fragments: [], operations: [], inputObjects: new Set() });\n }\n\n for (const [canonicalId, selection] of fieldSelections) {\n // Use schemaLabel to determine which schema this selection belongs to\n const schemaName = selection.schemaLabel;\n const schema = schemas[schemaName];\n const group = grouped.get(schemaName);\n\n if (!schema || !group) {\n return err(builderErrors.schemaNotFound(schemaName, canonicalId));\n }\n\n // Create formatters for schema-specific type names\n const outputFormatters: TypeFormatters = {\n scalarOutput: (name) => `ScalarOutput_${schemaName}<\"${name}\">`,\n };\n const inputFormatters: TypeFormatters = {\n scalarInput: (name) => `ScalarInput_${schemaName}<\"${name}\">`,\n inputObject: (name) => `Input_${schemaName}_${name}`,\n };\n\n if (selection.type === \"fragment\") {\n // Strict mode: fragments must have keys\n if (!selection.key) {\n missingKeyFragments.push({\n canonicalId,\n typename: selection.typename,\n schemaLabel: selection.schemaLabel,\n });\n continue; // Continue collecting all errors before reporting\n }\n\n try {\n // Collect input objects used in fragment variables\n const usedInputObjects = collectUsedInputObjectsFromSpecifiers(schema, selection.variableDefinitions);\n for (const inputName of usedInputObjects) {\n group.inputObjects.add(inputName);\n }\n\n // Generate output type with schema-specific scalar names\n const outputType = calculateFieldsType(schema, selection.fields, outputFormatters);\n\n // Generate input type from variableDefinitions with schema-specific names\n const hasVariables = Object.keys(selection.variableDefinitions).length > 0;\n const inputType = hasVariables\n ? generateInputTypeFromSpecifiers(schema, selection.variableDefinitions, { formatters: inputFormatters })\n : \"void\";\n\n group.fragments.push({\n key: selection.key,\n typename: selection.typename,\n inputType,\n outputType,\n });\n } catch (error) {\n warnings.push(\n `[prebuilt] Failed to calculate type for fragment \"${selection.key}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n } else if (selection.type === \"operation\") {\n try {\n // Collect input objects used in this operation\n const usedInputObjects = collectUsedInputObjects(schema, selection.variableDefinitions);\n for (const inputName of usedInputObjects) {\n group.inputObjects.add(inputName);\n }\n\n // Generate output type with schema-specific scalar names\n const outputType = calculateFieldsType(schema, selection.fields, outputFormatters);\n\n // Generate input type with schema-specific scalar and input object names\n const inputType = generateInputType(schema, selection.variableDefinitions, inputFormatters);\n\n group.operations.push({\n key: selection.operationName,\n inputType,\n outputType,\n });\n } catch (error) {\n warnings.push(\n `[prebuilt] Failed to calculate type for operation \"${selection.operationName}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n }\n\n // Strict mode: error if any fragments are missing keys\n if (missingKeyFragments.length > 0) {\n return err(typegenErrors.fragmentMissingKey(missingKeyFragments));\n }\n\n return ok({ grouped, warnings });\n};\n\n/**\n * Extract input object names from a GraphQL TypeNode.\n */\nconst extractInputObjectsFromType = (schema: AnyGraphqlSchema, typeNode: TypeNode, inputObjects: Set<string>): void => {\n switch (typeNode.kind) {\n case Kind.NON_NULL_TYPE:\n extractInputObjectsFromType(schema, typeNode.type, inputObjects);\n break;\n case Kind.LIST_TYPE:\n extractInputObjectsFromType(schema, typeNode.type, inputObjects);\n break;\n case Kind.NAMED_TYPE: {\n const name = typeNode.name.value;\n // Check if it's an input object (not a scalar or enum)\n if (!schema.scalar[name] && !schema.enum[name] && schema.input[name]) {\n inputObjects.add(name);\n }\n break;\n }\n }\n};\n\n/**\n * Recursively collect nested input objects from schema definitions.\n * Takes a set of initial input names and expands to include all nested inputs.\n */\nconst collectNestedInputObjects = (schema: AnyGraphqlSchema, initialInputNames: Set<string>): Set<string> => {\n const inputObjects = new Set(initialInputNames);\n\n const collectNested = (inputName: string, seen: Set<string>): void => {\n if (seen.has(inputName)) {\n return;\n }\n seen.add(inputName);\n\n const inputDef = schema.input[inputName];\n if (!inputDef) {\n return;\n }\n\n for (const field of Object.values(inputDef.fields)) {\n if (field.kind === \"input\" && !inputObjects.has(field.name)) {\n inputObjects.add(field.name);\n collectNested(field.name, seen);\n }\n }\n };\n\n for (const inputName of Array.from(initialInputNames)) {\n collectNested(inputName, new Set());\n }\n\n return inputObjects;\n};\n\n/**\n * Collect all input object types used in variable definitions.\n * Recursively collects nested input objects from the schema.\n */\nconst collectUsedInputObjects = (\n schema: AnyGraphqlSchema,\n variableDefinitions: readonly VariableDefinitionNode[],\n): Set<string> => {\n const directInputs = new Set<string>();\n for (const varDef of variableDefinitions) {\n extractInputObjectsFromType(schema, varDef.type, directInputs);\n }\n return collectNestedInputObjects(schema, directInputs);\n};\n\n/**\n * Collect all input object types used in InputTypeSpecifiers.\n * Recursively collects nested input objects from the schema.\n */\nconst collectUsedInputObjectsFromSpecifiers = (schema: AnyGraphqlSchema, specifiers: InputTypeSpecifiers): Set<string> => {\n const directInputs = new Set<string>();\n for (const specifier of Object.values(specifiers)) {\n if (specifier.kind === \"input\" && schema.input[specifier.name]) {\n directInputs.add(specifier.name);\n }\n }\n return collectNestedInputObjects(schema, directInputs);\n};\n\n/**\n * Generate type definitions for input objects.\n */\nconst generateInputObjectTypeDefinitions = (schema: AnyGraphqlSchema, schemaName: string, inputNames: Set<string>): string[] => {\n const lines: string[] = [];\n\n // Get depth config from schema (optional properties defined in AnyGraphqlSchema)\n const defaultDepth = schema.__defaultInputDepth ?? 3;\n const depthOverrides = schema.__inputDepthOverrides ?? {};\n\n // Create formatters for schema-specific type names\n const formatters: TypeFormatters = {\n scalarInput: (name) => `ScalarInput_${schemaName}<\"${name}\">`,\n inputObject: (name) => `Input_${schemaName}_${name}`,\n };\n\n // Sort for deterministic output\n const sortedNames = Array.from(inputNames).sort();\n\n for (const inputName of sortedNames) {\n const typeString = generateInputObjectType(schema, inputName, {\n defaultDepth,\n depthOverrides,\n formatters,\n });\n\n lines.push(`type Input_${schemaName}_${inputName} = ${typeString};`);\n }\n\n return lines;\n};\n\n/**\n * Generate the TypeScript code for prebuilt types.\n */\nconst generateTypesCode = (\n grouped: Map<string, SchemaGroup>,\n schemas: Record<string, AnyGraphqlSchema>,\n injectsModulePath: string,\n): string => {\n const schemaNames = Object.keys(schemas);\n\n const lines: string[] = [\n \"/**\",\n \" * Prebuilt type registry.\",\n \" *\",\n \" * This file is auto-generated by @soda-gql/typegen.\",\n \" * Do not edit manually.\",\n \" *\",\n \" * @module\",\n \" * @generated\",\n \" */\",\n \"\",\n 'import type { PrebuiltTypeRegistry } from \"@soda-gql/core\";',\n ];\n\n // Generate import from _internal-injects.ts\n const scalarImports = schemaNames.map((name) => `scalar_${name}`).join(\", \");\n lines.push(`import type { ${scalarImports} } from \"${injectsModulePath}\";`);\n\n lines.push(\"\");\n\n // Generate ScalarInput and ScalarOutput helper types\n for (const schemaName of schemaNames) {\n lines.push(\n `type ScalarInput_${schemaName}<T extends keyof typeof scalar_${schemaName}> = ` +\n `typeof scalar_${schemaName}[T][\"$type\"][\"input\"];`,\n );\n lines.push(\n `type ScalarOutput_${schemaName}<T extends keyof typeof scalar_${schemaName}> = ` +\n `typeof scalar_${schemaName}[T][\"$type\"][\"output\"];`,\n );\n }\n\n lines.push(\"\");\n\n for (const [schemaName, { fragments, operations, inputObjects }] of grouped) {\n const schema = schemas[schemaName];\n\n // Generate input object type definitions if there are any\n if (inputObjects.size > 0 && schema) {\n lines.push(\"// Input object types\");\n const inputTypeLines = generateInputObjectTypeDefinitions(schema, schemaName, inputObjects);\n lines.push(...inputTypeLines);\n lines.push(\"\");\n }\n\n // Generate fragments type\n const fragmentEntries = fragments\n .sort((a, b) => a.key.localeCompare(b.key))\n .map(\n (f) =>\n ` readonly \"${f.key}\": { readonly typename: \"${f.typename}\"; readonly input: ${f.inputType}; readonly output: ${f.outputType} };`,\n );\n\n // Generate operations type\n const operationEntries = operations\n .sort((a, b) => a.key.localeCompare(b.key))\n .map((o) => ` readonly \"${o.key}\": { readonly input: ${o.inputType}; readonly output: ${o.outputType} };`);\n\n lines.push(`export type PrebuiltTypes_${schemaName} = {`);\n lines.push(\" readonly fragments: {\");\n if (fragmentEntries.length > 0) {\n lines.push(...fragmentEntries);\n }\n lines.push(\" };\");\n lines.push(\" readonly operations: {\");\n if (operationEntries.length > 0) {\n lines.push(...operationEntries);\n }\n lines.push(\" };\");\n lines.push(\"};\");\n lines.push(\"\");\n }\n\n return lines.join(\"\\n\");\n};\n\n/**\n * Result of emitting prebuilt types.\n */\nexport type PrebuiltTypesEmitResult = {\n readonly path: string;\n readonly warnings: readonly string[];\n};\n\n/**\n * Emit prebuilt types to the prebuilt/types.ts file.\n *\n * This function uses a partial failure strategy: if type calculation fails for\n * individual elements (e.g., due to invalid field selections or missing schema\n * types), those elements are skipped and warnings are collected rather than\n * failing the entire emission. This allows builds to succeed even when some\n * elements have issues, while still reporting problems via warnings.\n *\n * @param options - Emitter options including schemas, field selections, and output directory\n * @returns Result containing output path and warnings, or error if a hard failure occurs\n *\n * @example\n * ```typescript\n * const result = await emitPrebuiltTypes({\n * schemas: { mySchema: schema },\n * fieldSelections,\n * outdir: \"./generated\",\n * injects: { mySchema: { scalars: \"./scalars.ts\" } },\n * });\n *\n * if (result.isOk()) {\n * console.log(`Generated: ${result.value.path}`);\n * if (result.value.warnings.length > 0) {\n * console.warn(\"Warnings:\", result.value.warnings);\n * }\n * }\n * ```\n */\nexport const emitPrebuiltTypes = async (\n options: PrebuiltTypesEmitterOptions,\n): Promise<Result<PrebuiltTypesEmitResult, BuilderError | TypegenError>> => {\n const { schemas, fieldSelections, outdir, injectsModulePath } = options;\n\n // Group selections by schema\n const groupResult = groupBySchema(fieldSelections, schemas);\n if (groupResult.isErr()) {\n return err(groupResult.error);\n }\n const { grouped, warnings } = groupResult.value;\n\n // Generate the types code\n const code = generateTypesCode(grouped, schemas, injectsModulePath);\n\n // Write to types.prebuilt.ts\n const typesPath = join(outdir, \"types.prebuilt.ts\");\n\n try {\n await writeFile(typesPath, code, \"utf-8\");\n return ok({ path: typesPath, warnings });\n } catch (error) {\n return err(\n builderErrors.writeFailed(\n typesPath,\n `Failed to write prebuilt types: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n }\n};\n","/**\n * Prebuilt module generator for bundler-compatible type resolution.\n *\n * Generates index.prebuilt.ts in the output directory (flat layout).\n * This module creates prebuilt gql composers that use PrebuiltTypes\n * for type lookup instead of complex inference.\n *\n * Generated file structure (in outdir):\n * - index.prebuilt.ts: Prebuilt gql composers\n * - types.prebuilt.ts: Type registry (generated by emitter.ts)\n *\n * Type resolution strategy:\n * - Types are resolved at the fragment/operation builder level using TKey/TName\n * - No ResolvePrebuiltElement needed at composer level\n * - This enables proper typing for fields, metadata, and other builder arguments\n *\n * @module\n */\n\nimport type { DocumentNode } from \"graphql\";\n\nexport type PrebuiltGeneratorOptions = {\n /**\n * Relative import path to the internal module.\n * Example: \"./_internal\" (from index.prebuilt.ts to _internal.ts)\n */\n readonly internalModulePath: string;\n /**\n * Relative import path to the injects module.\n * Example: \"./_internal-injects\" (from index.prebuilt.ts to _internal-injects.ts)\n */\n readonly injectsModulePath: string;\n /**\n * Per-schema injection config.\n * Maps schema name to whether it has an adapter.\n */\n readonly injection?: Map<\n string,\n {\n readonly hasAdapter?: boolean;\n }\n >;\n};\n\nexport type PrebuiltGeneratedModule = {\n /** The generated code for index.prebuilt.ts */\n readonly indexCode: string;\n};\n\n/**\n * Generate the prebuilt index module code.\n *\n * Generates index.prebuilt.ts with builder-level type resolution.\n * Types are resolved at the fragment/operation builder level using TKey/TName,\n * eliminating the need for ResolvePrebuiltElement at the composer level.\n */\nexport const generatePrebuiltModule = (\n schemas: Map<string, DocumentNode>,\n options: PrebuiltGeneratorOptions,\n): PrebuiltGeneratedModule => {\n const schemaNames = Array.from(schemas.keys());\n const injection = options.injection ?? new Map();\n\n // Generate adapter imports from _internal-injects.ts\n const adapterImports: string[] = [];\n for (const name of schemaNames) {\n const config = injection.get(name);\n if (config?.hasAdapter) {\n adapterImports.push(`adapter_${name}`);\n }\n }\n\n // Generate internal imports (runtime values and types needed for composer creation)\n const internalImports = schemaNames.flatMap((name) => [\n `__schema_${name}`,\n `__inputTypeMethods_${name}`,\n `__directiveMethods_${name}`,\n ]);\n\n // Generic types (schema-independent, generated once)\n const genericTypes = `\n/**\n * Generic field factory for type-erased field access.\n * Returns a callable for nested field builders. Primitive fields can be spread directly.\n * Runtime behavior differs but spread works for both: ...f.id() and ...f.user()(...)\n */\ntype GenericFieldFactory = (\n ...args: unknown[]\n) => (nest: (tools: GenericFieldsBuilderTools) => AnyFields) => AnyFields;\n\n/**\n * Generic tools for fields builder callbacks.\n * Uses type-erased factory to allow any field access while maintaining strict mode compatibility.\n */\ntype GenericFieldsBuilderTools = {\n readonly f: Record<string, GenericFieldFactory>;\n readonly $: Record<string, unknown>;\n};\n`;\n\n // Generate resolver types and context types for each schema\n const contextTypes = schemaNames\n .map(\n (name) => `\n/**\n * Resolve fragment types at builder level using TKey.\n * If TKey is a known key in PrebuiltTypes, return resolved types.\n * Otherwise, return PrebuiltEntryNotFound.\n */\ntype ResolveFragmentAtBuilder_${name}<\n TKey extends string | undefined\n> = TKey extends keyof PrebuiltTypes_${name}[\"fragments\"]\n ? Fragment<\n PrebuiltTypes_${name}[\"fragments\"][TKey][\"typename\"],\n PrebuiltTypes_${name}[\"fragments\"][TKey][\"input\"] extends infer TInput\n ? TInput extends void ? void : Partial<TInput & object>\n : void,\n Partial<AnyFields>,\n PrebuiltTypes_${name}[\"fragments\"][TKey][\"output\"] & object\n >\n : TKey extends undefined\n ? Fragment<\"(unknown)\", PrebuiltEntryNotFound<\"(undefined)\", \"fragment\">, Partial<AnyFields>, PrebuiltEntryNotFound<\"(undefined)\", \"fragment\">>\n : Fragment<\"(unknown)\", PrebuiltEntryNotFound<TKey & string, \"fragment\">, Partial<AnyFields>, PrebuiltEntryNotFound<TKey & string, \"fragment\">>;\n\n/**\n * Resolve operation types at builder level using TName.\n */\ntype ResolveOperationAtBuilder_${name}<\n TOperationType extends OperationType,\n TName extends string\n> = TName extends keyof PrebuiltTypes_${name}[\"operations\"]\n ? Operation<\n TOperationType,\n TName,\n string[],\n PrebuiltTypes_${name}[\"operations\"][TName][\"input\"] & AnyConstAssignableInput,\n Partial<AnyFields>,\n PrebuiltTypes_${name}[\"operations\"][TName][\"output\"] & object\n >\n : Operation<\n TOperationType,\n TName,\n string[],\n PrebuiltEntryNotFound<TName, \"operation\">,\n Partial<AnyFields>,\n PrebuiltEntryNotFound<TName, \"operation\">\n >;\n\n/**\n * Fragment builder that resolves types at builder level using TKey.\n */\ntype PrebuiltFragmentBuilder_${name} = <TKey extends string | undefined = undefined>(\n options: {\n key?: TKey;\n fields: (tools: GenericFieldsBuilderTools) => AnyFields;\n variables?: Record<string, unknown>;\n metadata?: unknown;\n }\n) => ResolveFragmentAtBuilder_${name}<TKey>;\n\n/**\n * Operation builder that resolves types at builder level using TName.\n */\ntype PrebuiltOperationBuilder_${name}<TOperationType extends OperationType> = <TName extends string>(\n options: {\n name: TName;\n fields: (tools: GenericFieldsBuilderTools) => AnyFields;\n variables?: Record<string, unknown>;\n metadata?: unknown;\n }\n) => ResolveOperationAtBuilder_${name}<TOperationType, TName>;\n\n/**\n * Prebuilt context with builder-level type resolution for schema \"${name}\".\n */\ntype PrebuiltContext_${name} = {\n readonly fragment: { [K: string]: PrebuiltFragmentBuilder_${name} };\n readonly query: { readonly operation: PrebuiltOperationBuilder_${name}<\"query\"> };\n readonly mutation: { readonly operation: PrebuiltOperationBuilder_${name}<\"mutation\"> };\n readonly subscription: { readonly operation: PrebuiltOperationBuilder_${name}<\"subscription\"> };\n readonly $var: unknown;\n readonly $dir: StandardDirectives;\n readonly $colocate: unknown;\n};`,\n )\n .join(\"\\n\");\n\n // Generate gql entries using createGqlElementComposer with type cast\n const gqlEntries = schemaNames.map((name) => {\n const config = injection.get(name);\n const adapterLine = config?.hasAdapter ? `,\\n adapter: adapter_${name}` : \"\";\n\n return ` ${name}: createGqlElementComposer(\n __schema_${name} as AnyGraphqlSchema,\n {\n inputTypeMethods: __inputTypeMethods_${name},\n directiveMethods: __directiveMethods_${name}${adapterLine}\n }\n ) as unknown as GqlComposer_${name}`;\n });\n\n // Build injects import line\n const injectsImportSpecifiers = adapterImports.length > 0 ? adapterImports.join(\", \") : \"\";\n const injectsImportLine = injectsImportSpecifiers\n ? `import { ${injectsImportSpecifiers} } from \"${options.injectsModulePath}\";`\n : \"\";\n\n // Generate index.prebuilt.ts code with builder-level type resolution\n const indexCode = `\\\n/**\n * Prebuilt GQL module with builder-level type resolution.\n *\n * Types are resolved at the fragment/operation builder level using TKey/TName,\n * not at the composer level. This enables proper typing for builder arguments\n * and eliminates the need for ResolvePrebuiltElement.\n *\n * @module\n * @generated by @soda-gql/typegen\n */\n\nimport {\n createGqlElementComposer,\n type AnyConstAssignableInput,\n type AnyFields,\n type AnyGraphqlSchema,\n type Fragment,\n type Operation,\n type OperationType,\n type PrebuiltEntryNotFound,\n type StandardDirectives,\n} from \"@soda-gql/core\";\n${injectsImportLine}\nimport { ${internalImports.join(\", \")} } from \"${options.internalModulePath}\";\nimport type { ${schemaNames.map((name) => `PrebuiltTypes_${name}`).join(\", \")} } from \"./types.prebuilt\";\n${genericTypes}\n${contextTypes}\n\n// Export context types for explicit annotation\n${schemaNames.map((name) => `export type { PrebuiltContext_${name} };`).join(\"\\n\")}\n\n// Composer type - TResult already has resolved types from builders, no ResolvePrebuiltElement needed\n${schemaNames\n .map(\n (name) => `type GqlComposer_${name} = {\n <TResult>(composeElement: (context: PrebuiltContext_${name}) => TResult): TResult;\n readonly $schema: AnyGraphqlSchema;\n};`,\n )\n .join(\"\\n\")}\n\n/**\n * Prebuilt GQL composers with builder-level type resolution.\n *\n * These composers have the same runtime behavior as the base composers,\n * but their return types are resolved from the prebuilt type registry\n * at the builder level instead of using ResolvePrebuiltElement.\n */\nexport const gql: { ${schemaNames.map((name) => `${name}: GqlComposer_${name}`).join(\"; \")} } = {\n${gqlEntries.join(\",\\n\")}\n};\n`;\n\n return {\n indexCode,\n };\n};\n","/**\n * Main typegen runner.\n *\n * Orchestrates the prebuilt type generation process:\n * 1. Load schemas from generated CJS bundle\n * 2. Generate index.prebuilt.ts\n * 3. Build artifact to evaluate elements\n * 4. Extract field selections\n * 5. Emit types.prebuilt.ts\n * 6. Bundle prebuilt module\n *\n * @module\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, extname, join, relative, resolve } from \"node:path\";\nimport {\n createBuilderService,\n extractFieldSelections,\n type IntermediateArtifactElement,\n loadSchemasFromBundle,\n} from \"@soda-gql/builder\";\nimport type { CanonicalId } from \"@soda-gql/common\";\nimport type { ResolvedSodaGqlConfig } from \"@soda-gql/config\";\nimport { build } from \"esbuild\";\nimport { type DocumentNode, parse } from \"graphql\";\nimport { err, ok } from \"neverthrow\";\nimport { emitPrebuiltTypes } from \"./emitter\";\nimport { typegenErrors } from \"./errors\";\nimport { generatePrebuiltModule } from \"./prebuilt-generator\";\nimport type { TypegenResult, TypegenSuccess } from \"./types\";\n\n/**\n * Options for running typegen.\n */\nexport type RunTypegenOptions = {\n /**\n * Resolved soda-gql configuration.\n */\n readonly config: ResolvedSodaGqlConfig;\n};\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 `./${targetPath.slice(0, -sourceExt.length).split(\"/\").pop()}`;\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 ? targetPath.slice(0, -sourceExt.length).split(\"/\").pop() : targetPath.split(\"/\").pop();\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\n/**\n * Bundle the prebuilt module to CJS format.\n */\nconst bundlePrebuiltModule = async (sourcePath: string): Promise<{ cjsPath: string }> => {\n const sourceExt = extname(sourcePath);\n const baseName = sourcePath.slice(0, -sourceExt.length);\n const cjsPath = `${baseName}.cjs`;\n\n await build({\n entryPoints: [sourcePath],\n outfile: cjsPath,\n format: \"cjs\",\n platform: \"node\",\n bundle: true,\n external: [\"@soda-gql/core\", \"@soda-gql/runtime\"],\n sourcemap: false,\n minify: false,\n treeShaking: false,\n });\n\n return { cjsPath };\n};\n\n/**\n * Write a TypeScript module to disk.\n */\nconst writeModule = async (path: string, content: string): Promise<void> => {\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, content, \"utf-8\");\n};\n\n/**\n * Load GraphQL schema documents from schema paths.\n * This is needed for generatePrebuiltModule which expects DocumentNode.\n */\nconst loadSchemaDocuments = (schemasConfig: ResolvedSodaGqlConfig[\"schemas\"]): Map<string, DocumentNode> => {\n const documents = new Map<string, DocumentNode>();\n\n for (const [name, schemaConfig] of Object.entries(schemasConfig)) {\n const schemaPaths = Array.isArray(schemaConfig.schema) ? schemaConfig.schema : [schemaConfig.schema];\n\n // Concatenate all schema files\n let combinedSource = \"\";\n for (const schemaPath of schemaPaths) {\n combinedSource += `${readFileSync(schemaPath, \"utf-8\")}\\n`;\n }\n\n documents.set(name, parse(combinedSource));\n }\n\n return documents;\n};\n\n/**\n * Run the typegen process.\n *\n * This function:\n * 1. Loads schemas from the generated CJS bundle\n * 2. Generates index.prebuilt.ts using generatePrebuiltModule\n * 3. Creates a BuilderService and builds the artifact\n * 4. Extracts field selections from the artifact\n * 5. Emits types.prebuilt.ts using emitPrebuiltTypes\n * 6. Bundles the prebuilt module\n *\n * @param options - Typegen options including config\n * @returns Result containing success data or error\n */\nexport const runTypegen = async (options: RunTypegenOptions): Promise<TypegenResult> => {\n const { config } = options;\n const outdir = resolve(config.outdir);\n const cjsPath = join(outdir, \"index.cjs\");\n const importSpecifierOptions = { includeExtension: config.styles.importExtension };\n\n // Step 1: Check if codegen has been run\n if (!existsSync(cjsPath)) {\n return err(typegenErrors.codegenRequired(outdir));\n }\n\n // Step 2: Load schemas from CJS bundle\n const schemaNames = Object.keys(config.schemas);\n const schemasResult = loadSchemasFromBundle(cjsPath, schemaNames);\n if (schemasResult.isErr()) {\n return err(typegenErrors.schemaLoadFailed(schemaNames, schemasResult.error));\n }\n const schemas = schemasResult.value;\n\n // Step 3: Load schema documents and generate index.prebuilt.ts\n const schemaDocuments = loadSchemaDocuments(config.schemas);\n const prebuiltIndexPath = join(outdir, \"index.prebuilt.ts\");\n\n // Calculate import paths from index.prebuilt.ts to internal modules\n const internalModulePath = toImportSpecifier(prebuiltIndexPath, join(outdir, \"_internal.ts\"), importSpecifierOptions);\n const injectsModulePath = toImportSpecifier(prebuiltIndexPath, join(outdir, \"_internal-injects.ts\"), importSpecifierOptions);\n\n // Build injection config for generatePrebuiltModule\n const injection = new Map<string, { hasAdapter?: boolean }>();\n for (const [schemaName, schemaConfig] of Object.entries(config.schemas)) {\n injection.set(schemaName, {\n hasAdapter: !!schemaConfig.inject.adapter,\n });\n }\n\n const prebuilt = generatePrebuiltModule(schemaDocuments, {\n internalModulePath,\n injectsModulePath,\n injection,\n });\n\n // Write index.prebuilt.ts\n try {\n await writeModule(prebuiltIndexPath, prebuilt.indexCode);\n } catch (error) {\n return err(\n typegenErrors.emitFailed(\n prebuiltIndexPath,\n `Failed to write prebuilt index: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n }\n\n // Step 4: Build artifact using BuilderService\n const builderService = createBuilderService({\n config,\n });\n\n const artifactResult = await builderService.buildAsync();\n\n if (artifactResult.isErr()) {\n return err(typegenErrors.buildFailed(`Builder failed: ${artifactResult.error.message}`, artifactResult.error));\n }\n\n // Step 5: Extract field selections from intermediate elements\n const intermediateElements = builderService.getIntermediateElements();\n if (!intermediateElements) {\n return err(typegenErrors.buildFailed(\"No intermediate elements available after build\", undefined));\n }\n\n const fieldSelectionsResult = extractFieldSelections(intermediateElements as Record<CanonicalId, IntermediateArtifactElement>);\n const { selections: fieldSelections, warnings: extractWarnings } = fieldSelectionsResult;\n\n // Step 6: Emit types.prebuilt.ts\n // Reuse injectsModulePath from step 3 (same directory, same relative path)\n const emitResult = await emitPrebuiltTypes({\n schemas,\n fieldSelections,\n outdir,\n injectsModulePath,\n });\n\n if (emitResult.isErr()) {\n return err(emitResult.error);\n }\n\n const { path: prebuiltTypesPath, warnings: emitWarnings } = emitResult.value;\n\n // Step 7: Bundle prebuilt module\n try {\n await bundlePrebuiltModule(prebuiltIndexPath);\n } catch (error) {\n return err(\n typegenErrors.bundleFailed(\n prebuiltIndexPath,\n `Failed to bundle prebuilt module: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n }\n\n // Count fragments and operations\n let fragmentCount = 0;\n let operationCount = 0;\n for (const selection of fieldSelections.values()) {\n if (selection.type === \"fragment\" && selection.key) {\n fragmentCount++;\n } else if (selection.type === \"operation\") {\n operationCount++;\n }\n }\n\n const allWarnings = [...extractWarnings, ...emitWarnings];\n\n return ok({\n prebuiltIndexPath,\n prebuiltTypesPath,\n fragmentCount,\n operationCount,\n warnings: allWarnings,\n } satisfies TypegenSuccess);\n};\n"],"mappings":";;;;;;;;;;;;;AAqEA,MAAa,gBAAgB;CAC3B,kBAAkB,YAA0C;EAC1D,MAAM;EACN,SAAS,iDAAiD,OAAO;EACjE;EACD;CAED,mBAAmB,aAAgC,WAA2C;EAC5F,MAAM;EACN,SAAS,2BAA2B,YAAY,KAAK,KAAK;EAC1D;EACA;EACD;CAED,cAAc,SAAiB,WAA2C;EACxE,MAAM;EACN;EACA;EACD;CAED,aAAa,MAAc,SAAiB,WAA2C;EACrF,MAAM;EACN;EACA;EACA;EACD;CAED,eAAe,MAAc,SAAiB,WAA2C;EACvF,MAAM;EACN;EACA;EACA;EACD;CAED,qBACE,eAC0B;EAC1B,MAAM;EACN,S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AY;AAExD,KAAI,eAAe,OAAO,EAAE;AAC1B,6BAAW,cAAc,YAAY,mBAAmB,eAAe,MAAM,WAAW,eAAe,MAAM,CAAC;;CAIhH,MAAM,uBAAuB,eAAe,yBAAyB;AACrE,KAAI,CAAC,sBAAsB;AACzB,6BAAW,cAAc,YAAY,kDAAkD,UAAU,CAAC;;CAGpG,MAAM,uEAA+C,qBAAyE;CAC9H,MAAM,EAAE,YAAY,iBAAiB,UAAU,oBAAoB;CAInE,MAAM,aAAa,MAAM,kBAAkB;EACzC;EACA;EACA;EACA;EACD,CAAC;AAEF,KAAI,WAAW,OAAO,EAAE;AACtB,6BAAW,WAAW,MAAM;;CAG9B,MAAM,EAAE,MAAM,mBAAmB,UAAU,iBAAiB,WAAW;AAGvE,KAAI;AACF,QAAM,qBAAqB,kBAAkB;UACtC,OAAO;AACd,6BACE,cAAc,aACZ,mBACA,qCAAqC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IAC3F,MACD,CACF;;CAIH,IAAI,gBAAgB;CACpB,IAAI,iBAAiB;AACrB,MAAK,MAAM,aAAa,gBAAgB,QAAQ,EAAE;AAChD,MAAI,UAAU,SAAS,cAAc,UAAU,KAAK;AAClD;aACS,UAAU,SAAS,aAAa;AACzC;;;CAIJ,MAAM,cAAc,CAAC,GAAG,iBAAiB,GAAG,aAAa;AAEzD,2BAAU;EACR;EACA;EACA;EACA;EACA,UAAU;EACX,CAA0B"}
|
package/dist/index.d.cts
CHANGED
|
@@ -160,12 +160,9 @@ type PrebuiltGeneratedModule = {
|
|
|
160
160
|
/**
|
|
161
161
|
* Generate the prebuilt index module code.
|
|
162
162
|
*
|
|
163
|
-
* Generates index.prebuilt.ts with
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* - Adapters from _internal-injects.ts
|
|
167
|
-
* - Runtime values from _internal.ts
|
|
168
|
-
* - AnyGqlContext instead of heavy Context type inference
|
|
163
|
+
* Generates index.prebuilt.ts with builder-level type resolution.
|
|
164
|
+
* Types are resolved at the fragment/operation builder level using TKey/TName,
|
|
165
|
+
* eliminating the need for ResolvePrebuiltElement at the composer level.
|
|
169
166
|
*/
|
|
170
167
|
declare const generatePrebuiltModule: (schemas: Map<string, DocumentNode>, options: PrebuiltGeneratorOptions) => PrebuiltGeneratedModule;
|
|
171
168
|
//#endregion
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/errors.ts","../src/emitter.ts","../src/prebuilt-generator.ts","../src/types.ts","../src/runner.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAWA;AAWA;AA0CY,KArDA,gBAAA,GAqDe,0BAAuB,GAAA,4BAAY,GAAA,sBAAA,GAAA,qBAAA,GAAA,uBAAA,GAAA,8BAAA;AAK9D;;;AAcmD,KA7DvC,oBAAA,GA6DuC;EAMa,SAAA,IAAA,EAAA,0BAAA;EAOE,SAAA,OAAA,EAAA,MAAA;EAS7D,SAAA,MAAA,EAAA,MAAA;CAAoB,GAAA;EAUZ,SAAA,IAAA,EAAA,4BAA6B;;;;AC9E1C,CAAA,GAAY;EAKuB,SAAA,IAAA,EAAA,sBAAA;EAAf,SAAA,OAAA,EAAA,MAAA;EAIQ,SAAA,KAAA,CAAA,EAAA,OAAA;CAAkB,GAAA;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/errors.ts","../src/emitter.ts","../src/prebuilt-generator.ts","../src/types.ts","../src/runner.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAWA;AAWA;AA0CY,KArDA,gBAAA,GAqDe,0BAAuB,GAAA,4BAAY,GAAA,sBAAA,GAAA,qBAAA,GAAA,uBAAA,GAAA,8BAAA;AAK9D;;;AAcmD,KA7DvC,oBAAA,GA6DuC;EAMa,SAAA,IAAA,EAAA,0BAAA;EAOE,SAAA,OAAA,EAAA,MAAA;EAS7D,SAAA,MAAA,EAAA,MAAA;CAAoB,GAAA;EAUZ,SAAA,IA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,MCjCC,CDiCM,cC7BhB,ED6BgC,YC7BX,CAAA;;;;;;AJ2E3B,KI/ED,iBAAA,GJ8GX;;;;EC7GW,SAAA,MAAA,EGGO,qBHHoB;CAKJ;;;;AAyWnC;AAkCA;;;;;;;;;;cGrRa,sBAA6B,sBAAoB,QAAQ"}
|
package/dist/index.d.mts
CHANGED
|
@@ -160,12 +160,9 @@ type PrebuiltGeneratedModule = {
|
|
|
160
160
|
/**
|
|
161
161
|
* Generate the prebuilt index module code.
|
|
162
162
|
*
|
|
163
|
-
* Generates index.prebuilt.ts with
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* - Adapters from _internal-injects.ts
|
|
167
|
-
* - Runtime values from _internal.ts
|
|
168
|
-
* - AnyGqlContext instead of heavy Context type inference
|
|
163
|
+
* Generates index.prebuilt.ts with builder-level type resolution.
|
|
164
|
+
* Types are resolved at the fragment/operation builder level using TKey/TName,
|
|
165
|
+
* eliminating the need for ResolvePrebuiltElement at the composer level.
|
|
169
166
|
*/
|
|
170
167
|
declare const generatePrebuiltModule: (schemas: Map<string, DocumentNode>, options: PrebuiltGeneratorOptions) => PrebuiltGeneratedModule;
|
|
171
168
|
//#endregion
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/errors.ts","../src/emitter.ts","../src/prebuilt-generator.ts","../src/types.ts","../src/runner.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAWA;AAWA;AA0CY,KArDA,gBAAA,GAqDe,0BAAuB,GAAA,4BAAY,GAAA,sBAAA,GAAA,qBAAA,GAAA,uBAAA,GAAA,8BAAA;AAK9D;;;AAcmD,KA7DvC,oBAAA,GA6DuC;EAMa,SAAA,IAAA,EAAA,0BAAA;EAOE,SAAA,OAAA,EAAA,MAAA;EAS7D,SAAA,MAAA,EAAA,MAAA;CAAoB,GAAA;EAUZ,SAAA,IAAA,EAAA,4BAA6B;;;;AC9E1C,CAAA,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DH;AAWA;AA0CA;AAKa,KGzDD,cAAA,GHkGF;EAxC2B;;;;EA0B6B,SAAA,MAAA,EAAA,MAAA;EAS7D;;AAUL;;;;AC9EA;;EAKoB,SAAA,OAAA,EEdA,MFcA,CAAA,MAAA,EAAA;IAIQ,SAAA,OAAA,EAAA,MAAA;EAAkB,CAAA,CAAA;EAqWlC;AAkCZ;;EAEkB,SAAA,eAAA,CAAA,EAAA,OAAA;CAAyB;;;;AAAjC,KEhZE,cAAA,GFgZF;;;;EClaE,SAAA,iBAAA,EAAwB,MAAA;EAuBxB;AAYZ;;EACW,SAAA,iBAAA,EAAA,MAAA;EACA;;;;;;AC9CX;EA2BY,SAAA,cAAc,EAAA,MAAA;EA8Bd;;;EAAgB,SAAA,QAAA,EAAA,SAAA,MAAA,EAAA;CAAM;;;;ACjCtB,KDiCA,aAAA,GAAgB,MCjCC,CDiCM,cC7BhB,ED6BgC,YC7BX,CAAA;;;;;;AJ2E3B,KI/ED,iBAAA,GJ8GX;;;;EC7GW,SAAA,MAAA,EGGO,qBHHoB;CAKJ;;;;AAyWnC;AAkCA;;;;;;;;;;cGrRa,sBAA6B,sBAAoB,QAAQ"}
|
package/dist/index.mjs
CHANGED
|
@@ -156,6 +156,7 @@ const groupBySchema = (fieldSelections, schemas) => {
|
|
|
156
156
|
const inputType = hasVariables ? generateInputTypeFromSpecifiers(schema, selection.variableDefinitions, { formatters: inputFormatters }) : "void";
|
|
157
157
|
group.fragments.push({
|
|
158
158
|
key: selection.key,
|
|
159
|
+
typename: selection.typename,
|
|
159
160
|
inputType,
|
|
160
161
|
outputType
|
|
161
162
|
});
|
|
@@ -315,7 +316,7 @@ const generateTypesCode = (grouped, schemas, injectsModulePath) => {
|
|
|
315
316
|
lines.push(...inputTypeLines);
|
|
316
317
|
lines.push("");
|
|
317
318
|
}
|
|
318
|
-
const fragmentEntries = fragments.sort((a, b) => a.key.localeCompare(b.key)).map((f) => ` readonly "${f.key}": { readonly input: ${f.inputType}; readonly output: ${f.outputType} };`);
|
|
319
|
+
const fragmentEntries = fragments.sort((a, b) => a.key.localeCompare(b.key)).map((f) => ` readonly "${f.key}": { readonly typename: "${f.typename}"; readonly input: ${f.inputType}; readonly output: ${f.outputType} };`);
|
|
319
320
|
const operationEntries = operations.sort((a, b) => a.key.localeCompare(b.key)).map((o) => ` readonly "${o.key}": { readonly input: ${o.inputType}; readonly output: ${o.outputType} };`);
|
|
320
321
|
lines.push(`export type PrebuiltTypes_${schemaName} = {`);
|
|
321
322
|
lines.push(" readonly fragments: {");
|
|
@@ -328,7 +329,7 @@ const generateTypesCode = (grouped, schemas, injectsModulePath) => {
|
|
|
328
329
|
lines.push(...operationEntries);
|
|
329
330
|
}
|
|
330
331
|
lines.push(" };");
|
|
331
|
-
lines.push("}
|
|
332
|
+
lines.push("};");
|
|
332
333
|
lines.push("");
|
|
333
334
|
}
|
|
334
335
|
return lines.join("\n");
|
|
@@ -387,12 +388,9 @@ const emitPrebuiltTypes = async (options) => {
|
|
|
387
388
|
/**
|
|
388
389
|
* Generate the prebuilt index module code.
|
|
389
390
|
*
|
|
390
|
-
* Generates index.prebuilt.ts with
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
* - Adapters from _internal-injects.ts
|
|
394
|
-
* - Runtime values from _internal.ts
|
|
395
|
-
* - AnyGqlContext instead of heavy Context type inference
|
|
391
|
+
* Generates index.prebuilt.ts with builder-level type resolution.
|
|
392
|
+
* Types are resolved at the fragment/operation builder level using TKey/TName,
|
|
393
|
+
* eliminating the need for ResolvePrebuiltElement at the composer level.
|
|
396
394
|
*/
|
|
397
395
|
const generatePrebuiltModule = (schemas, options) => {
|
|
398
396
|
const schemaNames = Array.from(schemas.keys());
|
|
@@ -409,60 +407,165 @@ const generatePrebuiltModule = (schemas, options) => {
|
|
|
409
407
|
`__inputTypeMethods_${name}`,
|
|
410
408
|
`__directiveMethods_${name}`
|
|
411
409
|
]);
|
|
410
|
+
const genericTypes = `
|
|
411
|
+
/**
|
|
412
|
+
* Generic field factory for type-erased field access.
|
|
413
|
+
* Returns a callable for nested field builders. Primitive fields can be spread directly.
|
|
414
|
+
* Runtime behavior differs but spread works for both: ...f.id() and ...f.user()(...)
|
|
415
|
+
*/
|
|
416
|
+
type GenericFieldFactory = (
|
|
417
|
+
...args: unknown[]
|
|
418
|
+
) => (nest: (tools: GenericFieldsBuilderTools) => AnyFields) => AnyFields;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Generic tools for fields builder callbacks.
|
|
422
|
+
* Uses type-erased factory to allow any field access while maintaining strict mode compatibility.
|
|
423
|
+
*/
|
|
424
|
+
type GenericFieldsBuilderTools = {
|
|
425
|
+
readonly f: Record<string, GenericFieldFactory>;
|
|
426
|
+
readonly $: Record<string, unknown>;
|
|
427
|
+
};
|
|
428
|
+
`;
|
|
429
|
+
const contextTypes = schemaNames.map((name) => `
|
|
430
|
+
/**
|
|
431
|
+
* Resolve fragment types at builder level using TKey.
|
|
432
|
+
* If TKey is a known key in PrebuiltTypes, return resolved types.
|
|
433
|
+
* Otherwise, return PrebuiltEntryNotFound.
|
|
434
|
+
*/
|
|
435
|
+
type ResolveFragmentAtBuilder_${name}<
|
|
436
|
+
TKey extends string | undefined
|
|
437
|
+
> = TKey extends keyof PrebuiltTypes_${name}["fragments"]
|
|
438
|
+
? Fragment<
|
|
439
|
+
PrebuiltTypes_${name}["fragments"][TKey]["typename"],
|
|
440
|
+
PrebuiltTypes_${name}["fragments"][TKey]["input"] extends infer TInput
|
|
441
|
+
? TInput extends void ? void : Partial<TInput & object>
|
|
442
|
+
: void,
|
|
443
|
+
Partial<AnyFields>,
|
|
444
|
+
PrebuiltTypes_${name}["fragments"][TKey]["output"] & object
|
|
445
|
+
>
|
|
446
|
+
: TKey extends undefined
|
|
447
|
+
? Fragment<"(unknown)", PrebuiltEntryNotFound<"(undefined)", "fragment">, Partial<AnyFields>, PrebuiltEntryNotFound<"(undefined)", "fragment">>
|
|
448
|
+
: Fragment<"(unknown)", PrebuiltEntryNotFound<TKey & string, "fragment">, Partial<AnyFields>, PrebuiltEntryNotFound<TKey & string, "fragment">>;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Resolve operation types at builder level using TName.
|
|
452
|
+
*/
|
|
453
|
+
type ResolveOperationAtBuilder_${name}<
|
|
454
|
+
TOperationType extends OperationType,
|
|
455
|
+
TName extends string
|
|
456
|
+
> = TName extends keyof PrebuiltTypes_${name}["operations"]
|
|
457
|
+
? Operation<
|
|
458
|
+
TOperationType,
|
|
459
|
+
TName,
|
|
460
|
+
string[],
|
|
461
|
+
PrebuiltTypes_${name}["operations"][TName]["input"] & AnyConstAssignableInput,
|
|
462
|
+
Partial<AnyFields>,
|
|
463
|
+
PrebuiltTypes_${name}["operations"][TName]["output"] & object
|
|
464
|
+
>
|
|
465
|
+
: Operation<
|
|
466
|
+
TOperationType,
|
|
467
|
+
TName,
|
|
468
|
+
string[],
|
|
469
|
+
PrebuiltEntryNotFound<TName, "operation">,
|
|
470
|
+
Partial<AnyFields>,
|
|
471
|
+
PrebuiltEntryNotFound<TName, "operation">
|
|
472
|
+
>;
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Fragment builder that resolves types at builder level using TKey.
|
|
476
|
+
*/
|
|
477
|
+
type PrebuiltFragmentBuilder_${name} = <TKey extends string | undefined = undefined>(
|
|
478
|
+
options: {
|
|
479
|
+
key?: TKey;
|
|
480
|
+
fields: (tools: GenericFieldsBuilderTools) => AnyFields;
|
|
481
|
+
variables?: Record<string, unknown>;
|
|
482
|
+
metadata?: unknown;
|
|
483
|
+
}
|
|
484
|
+
) => ResolveFragmentAtBuilder_${name}<TKey>;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Operation builder that resolves types at builder level using TName.
|
|
488
|
+
*/
|
|
489
|
+
type PrebuiltOperationBuilder_${name}<TOperationType extends OperationType> = <TName extends string>(
|
|
490
|
+
options: {
|
|
491
|
+
name: TName;
|
|
492
|
+
fields: (tools: GenericFieldsBuilderTools) => AnyFields;
|
|
493
|
+
variables?: Record<string, unknown>;
|
|
494
|
+
metadata?: unknown;
|
|
495
|
+
}
|
|
496
|
+
) => ResolveOperationAtBuilder_${name}<TOperationType, TName>;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Prebuilt context with builder-level type resolution for schema "${name}".
|
|
500
|
+
*/
|
|
501
|
+
type PrebuiltContext_${name} = {
|
|
502
|
+
readonly fragment: { [K: string]: PrebuiltFragmentBuilder_${name} };
|
|
503
|
+
readonly query: { readonly operation: PrebuiltOperationBuilder_${name}<"query"> };
|
|
504
|
+
readonly mutation: { readonly operation: PrebuiltOperationBuilder_${name}<"mutation"> };
|
|
505
|
+
readonly subscription: { readonly operation: PrebuiltOperationBuilder_${name}<"subscription"> };
|
|
506
|
+
readonly $var: unknown;
|
|
507
|
+
readonly $dir: StandardDirectives;
|
|
508
|
+
readonly $colocate: unknown;
|
|
509
|
+
};`).join("\n");
|
|
412
510
|
const gqlEntries = schemaNames.map((name) => {
|
|
413
511
|
const config = injection.get(name);
|
|
414
|
-
const
|
|
415
|
-
return ` ${name}:
|
|
416
|
-
AnyGraphqlSchema,
|
|
417
|
-
PrebuiltTypes_${name},
|
|
418
|
-
Record<string, unknown>,
|
|
419
|
-
StandardDirectives,
|
|
420
|
-
AnyGqlContext
|
|
421
|
-
>(
|
|
512
|
+
const adapterLine = config?.hasAdapter ? `,\n adapter: adapter_${name}` : "";
|
|
513
|
+
return ` ${name}: createGqlElementComposer(
|
|
422
514
|
__schema_${name} as AnyGraphqlSchema,
|
|
423
515
|
{
|
|
424
516
|
inputTypeMethods: __inputTypeMethods_${name},
|
|
425
|
-
directiveMethods: __directiveMethods_${name}
|
|
426
|
-
${adapterArg}
|
|
517
|
+
directiveMethods: __directiveMethods_${name}${adapterLine}
|
|
427
518
|
}
|
|
428
|
-
)`;
|
|
519
|
+
) as unknown as GqlComposer_${name}`;
|
|
429
520
|
});
|
|
430
521
|
const injectsImportSpecifiers = adapterImports.length > 0 ? adapterImports.join(", ") : "";
|
|
431
522
|
const injectsImportLine = injectsImportSpecifiers ? `import { ${injectsImportSpecifiers} } from "${options.injectsModulePath}";` : "";
|
|
432
523
|
const indexCode = `\
|
|
433
524
|
/**
|
|
434
|
-
* Prebuilt GQL module
|
|
525
|
+
* Prebuilt GQL module with builder-level type resolution.
|
|
435
526
|
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
* Uses lightweight imports:
|
|
440
|
-
* - Adapters from _internal-injects.ts
|
|
441
|
-
* - Runtime values from _internal.ts
|
|
442
|
-
* - AnyGqlContext instead of heavy Context type inference
|
|
527
|
+
* Types are resolved at the fragment/operation builder level using TKey/TName,
|
|
528
|
+
* not at the composer level. This enables proper typing for builder arguments
|
|
529
|
+
* and eliminates the need for ResolvePrebuiltElement.
|
|
443
530
|
*
|
|
444
531
|
* @module
|
|
445
532
|
* @generated by @soda-gql/typegen
|
|
446
533
|
*/
|
|
447
534
|
|
|
448
535
|
import {
|
|
449
|
-
|
|
450
|
-
type
|
|
536
|
+
createGqlElementComposer,
|
|
537
|
+
type AnyConstAssignableInput,
|
|
538
|
+
type AnyFields,
|
|
451
539
|
type AnyGraphqlSchema,
|
|
540
|
+
type Fragment,
|
|
541
|
+
type Operation,
|
|
542
|
+
type OperationType,
|
|
543
|
+
type PrebuiltEntryNotFound,
|
|
452
544
|
type StandardDirectives,
|
|
453
545
|
} from "@soda-gql/core";
|
|
454
546
|
${injectsImportLine}
|
|
455
547
|
import { ${internalImports.join(", ")} } from "${options.internalModulePath}";
|
|
456
548
|
import type { ${schemaNames.map((name) => `PrebuiltTypes_${name}`).join(", ")} } from "./types.prebuilt";
|
|
549
|
+
${genericTypes}
|
|
550
|
+
${contextTypes}
|
|
551
|
+
|
|
552
|
+
// Export context types for explicit annotation
|
|
553
|
+
${schemaNames.map((name) => `export type { PrebuiltContext_${name} };`).join("\n")}
|
|
554
|
+
|
|
555
|
+
// Composer type - TResult already has resolved types from builders, no ResolvePrebuiltElement needed
|
|
556
|
+
${schemaNames.map((name) => `type GqlComposer_${name} = {
|
|
557
|
+
<TResult>(composeElement: (context: PrebuiltContext_${name}) => TResult): TResult;
|
|
558
|
+
readonly $schema: AnyGraphqlSchema;
|
|
559
|
+
};`).join("\n")}
|
|
457
560
|
|
|
458
561
|
/**
|
|
459
|
-
* Prebuilt GQL composers with
|
|
562
|
+
* Prebuilt GQL composers with builder-level type resolution.
|
|
460
563
|
*
|
|
461
564
|
* These composers have the same runtime behavior as the base composers,
|
|
462
565
|
* but their return types are resolved from the prebuilt type registry
|
|
463
|
-
* instead of using
|
|
566
|
+
* at the builder level instead of using ResolvePrebuiltElement.
|
|
464
567
|
*/
|
|
465
|
-
export const gql = {
|
|
568
|
+
export const gql: { ${schemaNames.map((name) => `${name}: GqlComposer_${name}`).join("; ")} } = {
|
|
466
569
|
${gqlEntries.join(",\n")}
|
|
467
570
|
};
|
|
468
571
|
`;
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["lines: string[]","warnings: string[]","missingKeyFragments: { canonicalId: string; typename: string; schemaLabel: string }[]","outputFormatters: TypeFormatters","inputFormatters: TypeFormatters","lines: string[]","formatters: TypeFormatters","adapterImports: string[]","extensionMap: Record<string, string>","withPrefix","currentExt"],"sources":["../src/errors.ts","../src/emitter.ts","../src/prebuilt-generator.ts","../src/runner.ts"],"sourcesContent":["/**\n * Error types for typegen package.\n *\n * @module\n */\n\nimport type { BuilderError } from \"@soda-gql/builder\";\n\n/**\n * Error codes specific to typegen operations.\n */\nexport type TypegenErrorCode =\n | \"TYPEGEN_CODEGEN_REQUIRED\"\n | \"TYPEGEN_SCHEMA_LOAD_FAILED\"\n | \"TYPEGEN_BUILD_FAILED\"\n | \"TYPEGEN_EMIT_FAILED\"\n | \"TYPEGEN_BUNDLE_FAILED\"\n | \"TYPEGEN_FRAGMENT_MISSING_KEY\";\n\n/**\n * Typegen-specific error type.\n */\nexport type TypegenSpecificError =\n | {\n readonly code: \"TYPEGEN_CODEGEN_REQUIRED\";\n readonly message: string;\n readonly outdir: string;\n }\n | {\n readonly code: \"TYPEGEN_SCHEMA_LOAD_FAILED\";\n readonly message: string;\n readonly schemaNames: readonly string[];\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_BUILD_FAILED\";\n readonly message: string;\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_EMIT_FAILED\";\n readonly message: string;\n readonly path: string;\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_BUNDLE_FAILED\";\n readonly message: string;\n readonly path: string;\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_FRAGMENT_MISSING_KEY\";\n readonly message: string;\n readonly fragments: readonly {\n readonly canonicalId: string;\n readonly typename: string;\n readonly schemaLabel: string;\n }[];\n };\n\n/**\n * Union of all typegen errors (specific + builder errors).\n */\nexport type TypegenError = TypegenSpecificError | BuilderError;\n\n/**\n * Error constructor helpers for concise error creation.\n */\nexport const typegenErrors = {\n codegenRequired: (outdir: string): TypegenSpecificError => ({\n code: \"TYPEGEN_CODEGEN_REQUIRED\",\n message: `Generated graphql-system module not found at '${outdir}'. Run 'soda-gql codegen' first.`,\n outdir,\n }),\n\n schemaLoadFailed: (schemaNames: readonly string[], cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_SCHEMA_LOAD_FAILED\",\n message: `Failed to load schemas: ${schemaNames.join(\", \")}`,\n schemaNames,\n cause,\n }),\n\n buildFailed: (message: string, cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_BUILD_FAILED\",\n message,\n cause,\n }),\n\n emitFailed: (path: string, message: string, cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_EMIT_FAILED\",\n message,\n path,\n cause,\n }),\n\n bundleFailed: (path: string, message: string, cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_BUNDLE_FAILED\",\n message,\n path,\n cause,\n }),\n\n fragmentMissingKey: (\n fragments: readonly { canonicalId: string; typename: string; schemaLabel: string }[],\n ): TypegenSpecificError => ({\n code: \"TYPEGEN_FRAGMENT_MISSING_KEY\",\n message: `${fragments.length} fragment(s) missing required 'key' property for prebuilt types`,\n fragments,\n }),\n} as const;\n\n/**\n * Format TypegenError for console output (human-readable).\n */\nexport const formatTypegenError = (error: TypegenError): string => {\n const lines: string[] = [];\n\n lines.push(`Error [${error.code}]: ${error.message}`);\n\n switch (error.code) {\n case \"TYPEGEN_CODEGEN_REQUIRED\":\n lines.push(` Output directory: ${error.outdir}`);\n lines.push(\" Hint: Run 'soda-gql codegen' to generate the graphql-system module first.\");\n break;\n case \"TYPEGEN_SCHEMA_LOAD_FAILED\":\n lines.push(` Schemas: ${error.schemaNames.join(\", \")}`);\n break;\n case \"TYPEGEN_EMIT_FAILED\":\n case \"TYPEGEN_BUNDLE_FAILED\":\n lines.push(` Path: ${error.path}`);\n break;\n case \"TYPEGEN_FRAGMENT_MISSING_KEY\":\n lines.push(\" Fragments missing 'key' property:\");\n for (const fragment of error.fragments) {\n lines.push(` - ${fragment.canonicalId} (${fragment.typename} on ${fragment.schemaLabel})`);\n }\n lines.push(\" Hint: Add a 'key' property to each fragment for prebuilt type resolution.\");\n break;\n }\n\n if (\"cause\" in error && error.cause) {\n lines.push(` Caused by: ${error.cause}`);\n }\n\n return lines.join(\"\\n\");\n};\n","/**\n * Prebuilt types emitter.\n *\n * Generates TypeScript type definitions for PrebuiltTypes registry\n * from field selection data and schema.\n *\n * ## Error Handling Strategy\n *\n * The emitter uses a partial failure approach for type calculation errors:\n *\n * **Recoverable errors** (result in warnings, element skipped):\n * - Type calculation failures (e.g., `calculateFieldsType` throws)\n * - Input type generation failures (e.g., `generateInputType` throws)\n * - These are caught per-element, logged as warnings, and the element is omitted\n *\n * **Fatal errors** (result in error result):\n * - `SCHEMA_NOT_FOUND`: Selection references non-existent schema\n * - `WRITE_FAILED`: Cannot write output file to disk\n *\n * This allows builds to succeed with partial type coverage when some elements\n * have issues, while providing visibility into problems via warnings.\n *\n * @module\n */\n\nimport { writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { type BuilderError, builderErrors, type FieldSelectionsMap } from \"@soda-gql/builder\";\nimport type { AnyGraphqlSchema, InputTypeSpecifiers, TypeFormatters } from \"@soda-gql/core\";\nimport { calculateFieldsType, generateInputObjectType, generateInputType, generateInputTypeFromSpecifiers } from \"@soda-gql/core\";\nimport { Kind, type TypeNode, type VariableDefinitionNode } from \"graphql\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport { type TypegenError, typegenErrors } from \"./errors\";\n\n/**\n * Options for emitting prebuilt types.\n */\nexport type PrebuiltTypesEmitterOptions = {\n /**\n * Schema definitions per schema name.\n * These come from the codegen output.\n */\n readonly schemas: Record<string, AnyGraphqlSchema>;\n /**\n * Field selections extracted from the builder.\n */\n readonly fieldSelections: FieldSelectionsMap;\n /**\n * Output directory (where prebuilt/types.ts should be written).\n * This should be the same as config.outdir.\n */\n readonly outdir: string;\n /**\n * Relative import path to _internal-injects.ts from types.prebuilt.ts.\n * Example: \"./_internal-injects\"\n */\n readonly injectsModulePath: string;\n};\n\ntype PrebuiltTypeEntry = {\n readonly key: string;\n readonly inputType: string;\n readonly outputType: string;\n};\n\ntype SchemaGroup = {\n fragments: PrebuiltTypeEntry[];\n operations: PrebuiltTypeEntry[];\n inputObjects: Set<string>;\n};\n\ntype GroupBySchemaResult = {\n readonly grouped: Map<string, SchemaGroup>;\n readonly warnings: string[];\n};\n\n/**\n * Group field selections by schema.\n * Uses the schemaLabel from each selection to group them correctly.\n *\n * In strict mode, all fragments must have a 'key' property. Fragments\n * without keys will cause an error.\n *\n * @returns Result containing grouped selections and warnings, or error if schema not found\n * or fragments are missing keys\n */\nconst groupBySchema = (\n fieldSelections: FieldSelectionsMap,\n schemas: Record<string, AnyGraphqlSchema>,\n): Result<GroupBySchemaResult, BuilderError | TypegenError> => {\n const grouped = new Map<string, SchemaGroup>();\n const warnings: string[] = [];\n const missingKeyFragments: { canonicalId: string; typename: string; schemaLabel: string }[] = [];\n\n // Initialize groups for each schema\n for (const schemaName of Object.keys(schemas)) {\n grouped.set(schemaName, { fragments: [], operations: [], inputObjects: new Set() });\n }\n\n for (const [canonicalId, selection] of fieldSelections) {\n // Use schemaLabel to determine which schema this selection belongs to\n const schemaName = selection.schemaLabel;\n const schema = schemas[schemaName];\n const group = grouped.get(schemaName);\n\n if (!schema || !group) {\n return err(builderErrors.schemaNotFound(schemaName, canonicalId));\n }\n\n // Create formatters for schema-specific type names\n const outputFormatters: TypeFormatters = {\n scalarOutput: (name) => `ScalarOutput_${schemaName}<\"${name}\">`,\n };\n const inputFormatters: TypeFormatters = {\n scalarInput: (name) => `ScalarInput_${schemaName}<\"${name}\">`,\n inputObject: (name) => `Input_${schemaName}_${name}`,\n };\n\n if (selection.type === \"fragment\") {\n // Strict mode: fragments must have keys\n if (!selection.key) {\n missingKeyFragments.push({\n canonicalId,\n typename: selection.typename,\n schemaLabel: selection.schemaLabel,\n });\n continue; // Continue collecting all errors before reporting\n }\n\n try {\n // Collect input objects used in fragment variables\n const usedInputObjects = collectUsedInputObjectsFromSpecifiers(schema, selection.variableDefinitions);\n for (const inputName of usedInputObjects) {\n group.inputObjects.add(inputName);\n }\n\n // Generate output type with schema-specific scalar names\n const outputType = calculateFieldsType(schema, selection.fields, outputFormatters);\n\n // Generate input type from variableDefinitions with schema-specific names\n const hasVariables = Object.keys(selection.variableDefinitions).length > 0;\n const inputType = hasVariables\n ? generateInputTypeFromSpecifiers(schema, selection.variableDefinitions, { formatters: inputFormatters })\n : \"void\";\n\n group.fragments.push({\n key: selection.key,\n inputType,\n outputType,\n });\n } catch (error) {\n warnings.push(\n `[prebuilt] Failed to calculate type for fragment \"${selection.key}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n } else if (selection.type === \"operation\") {\n try {\n // Collect input objects used in this operation\n const usedInputObjects = collectUsedInputObjects(schema, selection.variableDefinitions);\n for (const inputName of usedInputObjects) {\n group.inputObjects.add(inputName);\n }\n\n // Generate output type with schema-specific scalar names\n const outputType = calculateFieldsType(schema, selection.fields, outputFormatters);\n\n // Generate input type with schema-specific scalar and input object names\n const inputType = generateInputType(schema, selection.variableDefinitions, inputFormatters);\n\n group.operations.push({\n key: selection.operationName,\n inputType,\n outputType,\n });\n } catch (error) {\n warnings.push(\n `[prebuilt] Failed to calculate type for operation \"${selection.operationName}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n }\n\n // Strict mode: error if any fragments are missing keys\n if (missingKeyFragments.length > 0) {\n return err(typegenErrors.fragmentMissingKey(missingKeyFragments));\n }\n\n return ok({ grouped, warnings });\n};\n\n/**\n * Extract input object names from a GraphQL TypeNode.\n */\nconst extractInputObjectsFromType = (schema: AnyGraphqlSchema, typeNode: TypeNode, inputObjects: Set<string>): void => {\n switch (typeNode.kind) {\n case Kind.NON_NULL_TYPE:\n extractInputObjectsFromType(schema, typeNode.type, inputObjects);\n break;\n case Kind.LIST_TYPE:\n extractInputObjectsFromType(schema, typeNode.type, inputObjects);\n break;\n case Kind.NAMED_TYPE: {\n const name = typeNode.name.value;\n // Check if it's an input object (not a scalar or enum)\n if (!schema.scalar[name] && !schema.enum[name] && schema.input[name]) {\n inputObjects.add(name);\n }\n break;\n }\n }\n};\n\n/**\n * Recursively collect nested input objects from schema definitions.\n * Takes a set of initial input names and expands to include all nested inputs.\n */\nconst collectNestedInputObjects = (schema: AnyGraphqlSchema, initialInputNames: Set<string>): Set<string> => {\n const inputObjects = new Set(initialInputNames);\n\n const collectNested = (inputName: string, seen: Set<string>): void => {\n if (seen.has(inputName)) {\n return;\n }\n seen.add(inputName);\n\n const inputDef = schema.input[inputName];\n if (!inputDef) {\n return;\n }\n\n for (const field of Object.values(inputDef.fields)) {\n if (field.kind === \"input\" && !inputObjects.has(field.name)) {\n inputObjects.add(field.name);\n collectNested(field.name, seen);\n }\n }\n };\n\n for (const inputName of Array.from(initialInputNames)) {\n collectNested(inputName, new Set());\n }\n\n return inputObjects;\n};\n\n/**\n * Collect all input object types used in variable definitions.\n * Recursively collects nested input objects from the schema.\n */\nconst collectUsedInputObjects = (\n schema: AnyGraphqlSchema,\n variableDefinitions: readonly VariableDefinitionNode[],\n): Set<string> => {\n const directInputs = new Set<string>();\n for (const varDef of variableDefinitions) {\n extractInputObjectsFromType(schema, varDef.type, directInputs);\n }\n return collectNestedInputObjects(schema, directInputs);\n};\n\n/**\n * Collect all input object types used in InputTypeSpecifiers.\n * Recursively collects nested input objects from the schema.\n */\nconst collectUsedInputObjectsFromSpecifiers = (schema: AnyGraphqlSchema, specifiers: InputTypeSpecifiers): Set<string> => {\n const directInputs = new Set<string>();\n for (const specifier of Object.values(specifiers)) {\n if (specifier.kind === \"input\" && schema.input[specifier.name]) {\n directInputs.add(specifier.name);\n }\n }\n return collectNestedInputObjects(schema, directInputs);\n};\n\n/**\n * Generate type definitions for input objects.\n */\nconst generateInputObjectTypeDefinitions = (schema: AnyGraphqlSchema, schemaName: string, inputNames: Set<string>): string[] => {\n const lines: string[] = [];\n\n // Get depth config from schema (optional properties defined in AnyGraphqlSchema)\n const defaultDepth = schema.__defaultInputDepth ?? 3;\n const depthOverrides = schema.__inputDepthOverrides ?? {};\n\n // Create formatters for schema-specific type names\n const formatters: TypeFormatters = {\n scalarInput: (name) => `ScalarInput_${schemaName}<\"${name}\">`,\n inputObject: (name) => `Input_${schemaName}_${name}`,\n };\n\n // Sort for deterministic output\n const sortedNames = Array.from(inputNames).sort();\n\n for (const inputName of sortedNames) {\n const typeString = generateInputObjectType(schema, inputName, {\n defaultDepth,\n depthOverrides,\n formatters,\n });\n\n lines.push(`type Input_${schemaName}_${inputName} = ${typeString};`);\n }\n\n return lines;\n};\n\n/**\n * Generate the TypeScript code for prebuilt types.\n */\nconst generateTypesCode = (\n grouped: Map<string, SchemaGroup>,\n schemas: Record<string, AnyGraphqlSchema>,\n injectsModulePath: string,\n): string => {\n const schemaNames = Object.keys(schemas);\n\n const lines: string[] = [\n \"/**\",\n \" * Prebuilt type registry.\",\n \" *\",\n \" * This file is auto-generated by @soda-gql/typegen.\",\n \" * Do not edit manually.\",\n \" *\",\n \" * @module\",\n \" * @generated\",\n \" */\",\n \"\",\n 'import type { PrebuiltTypeRegistry } from \"@soda-gql/core\";',\n ];\n\n // Generate import from _internal-injects.ts\n const scalarImports = schemaNames.map((name) => `scalar_${name}`).join(\", \");\n lines.push(`import type { ${scalarImports} } from \"${injectsModulePath}\";`);\n\n lines.push(\"\");\n\n // Generate ScalarInput and ScalarOutput helper types\n for (const schemaName of schemaNames) {\n lines.push(\n `type ScalarInput_${schemaName}<T extends keyof typeof scalar_${schemaName}> = ` +\n `typeof scalar_${schemaName}[T][\"$type\"][\"input\"];`,\n );\n lines.push(\n `type ScalarOutput_${schemaName}<T extends keyof typeof scalar_${schemaName}> = ` +\n `typeof scalar_${schemaName}[T][\"$type\"][\"output\"];`,\n );\n }\n\n lines.push(\"\");\n\n for (const [schemaName, { fragments, operations, inputObjects }] of grouped) {\n const schema = schemas[schemaName];\n\n // Generate input object type definitions if there are any\n if (inputObjects.size > 0 && schema) {\n lines.push(\"// Input object types\");\n const inputTypeLines = generateInputObjectTypeDefinitions(schema, schemaName, inputObjects);\n lines.push(...inputTypeLines);\n lines.push(\"\");\n }\n\n // Generate fragments type\n const fragmentEntries = fragments\n .sort((a, b) => a.key.localeCompare(b.key))\n .map((f) => ` readonly \"${f.key}\": { readonly input: ${f.inputType}; readonly output: ${f.outputType} };`);\n\n // Generate operations type\n const operationEntries = operations\n .sort((a, b) => a.key.localeCompare(b.key))\n .map((o) => ` readonly \"${o.key}\": { readonly input: ${o.inputType}; readonly output: ${o.outputType} };`);\n\n lines.push(`export type PrebuiltTypes_${schemaName} = {`);\n lines.push(\" readonly fragments: {\");\n if (fragmentEntries.length > 0) {\n lines.push(...fragmentEntries);\n }\n lines.push(\" };\");\n lines.push(\" readonly operations: {\");\n if (operationEntries.length > 0) {\n lines.push(...operationEntries);\n }\n lines.push(\" };\");\n lines.push(\"} satisfies PrebuiltTypeRegistry;\");\n lines.push(\"\");\n }\n\n return lines.join(\"\\n\");\n};\n\n/**\n * Result of emitting prebuilt types.\n */\nexport type PrebuiltTypesEmitResult = {\n readonly path: string;\n readonly warnings: readonly string[];\n};\n\n/**\n * Emit prebuilt types to the prebuilt/types.ts file.\n *\n * This function uses a partial failure strategy: if type calculation fails for\n * individual elements (e.g., due to invalid field selections or missing schema\n * types), those elements are skipped and warnings are collected rather than\n * failing the entire emission. This allows builds to succeed even when some\n * elements have issues, while still reporting problems via warnings.\n *\n * @param options - Emitter options including schemas, field selections, and output directory\n * @returns Result containing output path and warnings, or error if a hard failure occurs\n *\n * @example\n * ```typescript\n * const result = await emitPrebuiltTypes({\n * schemas: { mySchema: schema },\n * fieldSelections,\n * outdir: \"./generated\",\n * injects: { mySchema: { scalars: \"./scalars.ts\" } },\n * });\n *\n * if (result.isOk()) {\n * console.log(`Generated: ${result.value.path}`);\n * if (result.value.warnings.length > 0) {\n * console.warn(\"Warnings:\", result.value.warnings);\n * }\n * }\n * ```\n */\nexport const emitPrebuiltTypes = async (\n options: PrebuiltTypesEmitterOptions,\n): Promise<Result<PrebuiltTypesEmitResult, BuilderError | TypegenError>> => {\n const { schemas, fieldSelections, outdir, injectsModulePath } = options;\n\n // Group selections by schema\n const groupResult = groupBySchema(fieldSelections, schemas);\n if (groupResult.isErr()) {\n return err(groupResult.error);\n }\n const { grouped, warnings } = groupResult.value;\n\n // Generate the types code\n const code = generateTypesCode(grouped, schemas, injectsModulePath);\n\n // Write to types.prebuilt.ts\n const typesPath = join(outdir, \"types.prebuilt.ts\");\n\n try {\n await writeFile(typesPath, code, \"utf-8\");\n return ok({ path: typesPath, warnings });\n } catch (error) {\n return err(\n builderErrors.writeFailed(\n typesPath,\n `Failed to write prebuilt types: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n }\n};\n","/**\n * Prebuilt module generator for bundler-compatible type resolution.\n *\n * Generates index.prebuilt.ts in the output directory (flat layout).\n * This module creates prebuilt gql composers that use PrebuiltTypes\n * for type lookup instead of complex inference.\n *\n * Generated file structure (in outdir):\n * - index.prebuilt.ts: Prebuilt gql composers\n * - types.prebuilt.ts: Type registry (generated by emitter.ts)\n *\n * Import strategy for lightweight type serialization:\n * - Adapters from _internal-injects.ts (scalar, adapter)\n * - Runtime values from _internal.ts (__schema_*, etc.)\n * - Uses AnyGqlContext instead of heavy Context type inference\n *\n * @module\n */\n\nimport type { DocumentNode } from \"graphql\";\n\nexport type PrebuiltGeneratorOptions = {\n /**\n * Relative import path to the internal module.\n * Example: \"./_internal\" (from index.prebuilt.ts to _internal.ts)\n */\n readonly internalModulePath: string;\n /**\n * Relative import path to the injects module.\n * Example: \"./_internal-injects\" (from index.prebuilt.ts to _internal-injects.ts)\n */\n readonly injectsModulePath: string;\n /**\n * Per-schema injection config.\n * Maps schema name to whether it has an adapter.\n */\n readonly injection?: Map<\n string,\n {\n readonly hasAdapter?: boolean;\n }\n >;\n};\n\nexport type PrebuiltGeneratedModule = {\n /** The generated code for index.prebuilt.ts */\n readonly indexCode: string;\n};\n\n/**\n * Generate the prebuilt index module code.\n *\n * Generates index.prebuilt.ts with prebuilt gql composers using\n * createPrebuiltGqlElementComposer. The generated module uses\n * lightweight imports for type serialization compatibility:\n * - Adapters from _internal-injects.ts\n * - Runtime values from _internal.ts\n * - AnyGqlContext instead of heavy Context type inference\n */\nexport const generatePrebuiltModule = (\n schemas: Map<string, DocumentNode>,\n options: PrebuiltGeneratorOptions,\n): PrebuiltGeneratedModule => {\n const schemaNames = Array.from(schemas.keys());\n const injection = options.injection ?? new Map();\n\n // Generate adapter imports from _internal-injects.ts\n const adapterImports: string[] = [];\n for (const name of schemaNames) {\n const config = injection.get(name);\n if (config?.hasAdapter) {\n adapterImports.push(`adapter_${name}`);\n }\n }\n\n // Generate internal imports (runtime values needed for composer creation)\n const internalImports = schemaNames.flatMap((name) => [\n `__schema_${name}`,\n `__inputTypeMethods_${name}`,\n `__directiveMethods_${name}`,\n ]);\n\n // Generate gql entries using createPrebuiltGqlElementComposer\n const gqlEntries = schemaNames.map((name) => {\n const config = injection.get(name);\n const adapterArg = config?.hasAdapter ? `adapter: adapter_${name},` : \"\";\n\n return ` ${name}: createPrebuiltGqlElementComposer<\n AnyGraphqlSchema,\n PrebuiltTypes_${name},\n Record<string, unknown>,\n StandardDirectives,\n AnyGqlContext\n >(\n __schema_${name} as AnyGraphqlSchema,\n {\n inputTypeMethods: __inputTypeMethods_${name},\n directiveMethods: __directiveMethods_${name},\n ${adapterArg}\n }\n )`;\n });\n\n // Build injects import line\n const injectsImportSpecifiers = adapterImports.length > 0 ? adapterImports.join(\", \") : \"\";\n const injectsImportLine = injectsImportSpecifiers\n ? `import { ${injectsImportSpecifiers} } from \"${options.injectsModulePath}\";`\n : \"\";\n\n // Generate index.prebuilt.ts code with lightweight imports\n const indexCode = `\\\n/**\n * Prebuilt GQL module for bundler-compatible type resolution.\n *\n * This module creates prebuilt composers using createPrebuiltGqlElementComposer\n * that look up types from PrebuiltTypes instead of complex inference.\n *\n * Uses lightweight imports:\n * - Adapters from _internal-injects.ts\n * - Runtime values from _internal.ts\n * - AnyGqlContext instead of heavy Context type inference\n *\n * @module\n * @generated by @soda-gql/typegen\n */\n\nimport {\n createPrebuiltGqlElementComposer,\n type AnyGqlContext,\n type AnyGraphqlSchema,\n type StandardDirectives,\n} from \"@soda-gql/core\";\n${injectsImportLine}\nimport { ${internalImports.join(\", \")} } from \"${options.internalModulePath}\";\nimport type { ${schemaNames.map((name) => `PrebuiltTypes_${name}`).join(\", \")} } from \"./types.prebuilt\";\n\n/**\n * Prebuilt GQL composers with strict type resolution from PrebuiltTypeRegistry.\n *\n * These composers have the same runtime behavior as the base composers,\n * but their return types are resolved from the prebuilt type registry\n * instead of using complex type inference.\n */\nexport const gql = {\n${gqlEntries.join(\",\\n\")}\n};\n`;\n\n return {\n indexCode,\n };\n};\n","/**\n * Main typegen runner.\n *\n * Orchestrates the prebuilt type generation process:\n * 1. Load schemas from generated CJS bundle\n * 2. Generate index.prebuilt.ts\n * 3. Build artifact to evaluate elements\n * 4. Extract field selections\n * 5. Emit types.prebuilt.ts\n * 6. Bundle prebuilt module\n *\n * @module\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, extname, join, relative, resolve } from \"node:path\";\nimport {\n createBuilderService,\n extractFieldSelections,\n type IntermediateArtifactElement,\n loadSchemasFromBundle,\n} from \"@soda-gql/builder\";\nimport type { CanonicalId } from \"@soda-gql/common\";\nimport type { ResolvedSodaGqlConfig } from \"@soda-gql/config\";\nimport { build } from \"esbuild\";\nimport { type DocumentNode, parse } from \"graphql\";\nimport { err, ok } from \"neverthrow\";\nimport { emitPrebuiltTypes } from \"./emitter\";\nimport { typegenErrors } from \"./errors\";\nimport { generatePrebuiltModule } from \"./prebuilt-generator\";\nimport type { TypegenResult, TypegenSuccess } from \"./types\";\n\n/**\n * Options for running typegen.\n */\nexport type RunTypegenOptions = {\n /**\n * Resolved soda-gql configuration.\n */\n readonly config: ResolvedSodaGqlConfig;\n};\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 `./${targetPath.slice(0, -sourceExt.length).split(\"/\").pop()}`;\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 ? targetPath.slice(0, -sourceExt.length).split(\"/\").pop() : targetPath.split(\"/\").pop();\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\n/**\n * Bundle the prebuilt module to CJS format.\n */\nconst bundlePrebuiltModule = async (sourcePath: string): Promise<{ cjsPath: string }> => {\n const sourceExt = extname(sourcePath);\n const baseName = sourcePath.slice(0, -sourceExt.length);\n const cjsPath = `${baseName}.cjs`;\n\n await build({\n entryPoints: [sourcePath],\n outfile: cjsPath,\n format: \"cjs\",\n platform: \"node\",\n bundle: true,\n external: [\"@soda-gql/core\", \"@soda-gql/runtime\"],\n sourcemap: false,\n minify: false,\n treeShaking: false,\n });\n\n return { cjsPath };\n};\n\n/**\n * Write a TypeScript module to disk.\n */\nconst writeModule = async (path: string, content: string): Promise<void> => {\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, content, \"utf-8\");\n};\n\n/**\n * Load GraphQL schema documents from schema paths.\n * This is needed for generatePrebuiltModule which expects DocumentNode.\n */\nconst loadSchemaDocuments = (schemasConfig: ResolvedSodaGqlConfig[\"schemas\"]): Map<string, DocumentNode> => {\n const documents = new Map<string, DocumentNode>();\n\n for (const [name, schemaConfig] of Object.entries(schemasConfig)) {\n const schemaPaths = Array.isArray(schemaConfig.schema) ? schemaConfig.schema : [schemaConfig.schema];\n\n // Concatenate all schema files\n let combinedSource = \"\";\n for (const schemaPath of schemaPaths) {\n combinedSource += `${readFileSync(schemaPath, \"utf-8\")}\\n`;\n }\n\n documents.set(name, parse(combinedSource));\n }\n\n return documents;\n};\n\n/**\n * Run the typegen process.\n *\n * This function:\n * 1. Loads schemas from the generated CJS bundle\n * 2. Generates index.prebuilt.ts using generatePrebuiltModule\n * 3. Creates a BuilderService and builds the artifact\n * 4. Extracts field selections from the artifact\n * 5. Emits types.prebuilt.ts using emitPrebuiltTypes\n * 6. Bundles the prebuilt module\n *\n * @param options - Typegen options including config\n * @returns Result containing success data or error\n */\nexport const runTypegen = async (options: RunTypegenOptions): Promise<TypegenResult> => {\n const { config } = options;\n const outdir = resolve(config.outdir);\n const cjsPath = join(outdir, \"index.cjs\");\n const importSpecifierOptions = { includeExtension: config.styles.importExtension };\n\n // Step 1: Check if codegen has been run\n if (!existsSync(cjsPath)) {\n return err(typegenErrors.codegenRequired(outdir));\n }\n\n // Step 2: Load schemas from CJS bundle\n const schemaNames = Object.keys(config.schemas);\n const schemasResult = loadSchemasFromBundle(cjsPath, schemaNames);\n if (schemasResult.isErr()) {\n return err(typegenErrors.schemaLoadFailed(schemaNames, schemasResult.error));\n }\n const schemas = schemasResult.value;\n\n // Step 3: Load schema documents and generate index.prebuilt.ts\n const schemaDocuments = loadSchemaDocuments(config.schemas);\n const prebuiltIndexPath = join(outdir, \"index.prebuilt.ts\");\n\n // Calculate import paths from index.prebuilt.ts to internal modules\n const internalModulePath = toImportSpecifier(prebuiltIndexPath, join(outdir, \"_internal.ts\"), importSpecifierOptions);\n const injectsModulePath = toImportSpecifier(prebuiltIndexPath, join(outdir, \"_internal-injects.ts\"), importSpecifierOptions);\n\n // Build injection config for generatePrebuiltModule\n const injection = new Map<string, { hasAdapter?: boolean }>();\n for (const [schemaName, schemaConfig] of Object.entries(config.schemas)) {\n injection.set(schemaName, {\n hasAdapter: !!schemaConfig.inject.adapter,\n });\n }\n\n const prebuilt = generatePrebuiltModule(schemaDocuments, {\n internalModulePath,\n injectsModulePath,\n injection,\n });\n\n // Write index.prebuilt.ts\n try {\n await writeModule(prebuiltIndexPath, prebuilt.indexCode);\n } catch (error) {\n return err(\n typegenErrors.emitFailed(\n prebuiltIndexPath,\n `Failed to write prebuilt index: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n }\n\n // Step 4: Build artifact using BuilderService\n const builderService = createBuilderService({\n config,\n });\n\n const artifactResult = await builderService.buildAsync();\n\n if (artifactResult.isErr()) {\n return err(typegenErrors.buildFailed(`Builder failed: ${artifactResult.error.message}`, artifactResult.error));\n }\n\n // Step 5: Extract field selections from intermediate elements\n const intermediateElements = builderService.getIntermediateElements();\n if (!intermediateElements) {\n return err(typegenErrors.buildFailed(\"No intermediate elements available after build\", undefined));\n }\n\n const fieldSelectionsResult = extractFieldSelections(intermediateElements as Record<CanonicalId, IntermediateArtifactElement>);\n const { selections: fieldSelections, warnings: extractWarnings } = fieldSelectionsResult;\n\n // Step 6: Emit types.prebuilt.ts\n // Reuse injectsModulePath from step 3 (same directory, same relative path)\n const emitResult = await emitPrebuiltTypes({\n schemas,\n fieldSelections,\n outdir,\n injectsModulePath,\n });\n\n if (emitResult.isErr()) {\n return err(emitResult.error);\n }\n\n const { path: prebuiltTypesPath, warnings: emitWarnings } = emitResult.value;\n\n // Step 7: Bundle prebuilt module\n try {\n await bundlePrebuiltModule(prebuiltIndexPath);\n } catch (error) {\n return err(\n typegenErrors.bundleFailed(\n prebuiltIndexPath,\n `Failed to bundle prebuilt module: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n }\n\n // Count fragments and operations\n let fragmentCount = 0;\n let operationCount = 0;\n for (const selection of fieldSelections.values()) {\n if (selection.type === \"fragment\" && selection.key) {\n fragmentCount++;\n } else if (selection.type === \"operation\") {\n operationCount++;\n }\n }\n\n const allWarnings = [...extractWarnings, ...emitWarnings];\n\n return ok({\n prebuiltIndexPath,\n prebuiltTypesPath,\n fragmentCount,\n operationCount,\n warnings: allWarnings,\n } satisfies TypegenSuccess);\n};\n"],"mappings":";;;;;;;;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,CAAC;;CAIhH,MAAM,uBAAuB,eAAe,yBAAyB;AACrE,KAAI,CAAC,sBAAsB;AACzB,SAAO,IAAI,cAAc,YAAY,kDAAkD,UAAU,CAAC;;CAGpG,MAAM,wBAAwB,uBAAuB,qBAAyE;CAC9H,MAAM,EAAE,YAAY,iBAAiB,UAAU,oBAAoB;CAInE,MAAM,aAAa,MAAM,kBAAkB;EACzC;EACA;EACA;EACA;EACD,CAAC;AAEF,KAAI,WAAW,OAAO,EAAE;AACtB,SAAO,IAAI,WAAW,MAAM;;CAG9B,MAAM,EAAE,MAAM,mBAAmB,UAAU,iBAAiB,WAAW;AAGvE,KAAI;AACF,QAAM,qBAAqB,kBAAkB;UACtC,OAAO;AACd,SAAO,IACL,cAAc,aACZ,mBACA,qCAAqC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IAC3F,MACD,CACF;;CAIH,IAAI,gBAAgB;CACpB,IAAI,iBAAiB;AACrB,MAAK,MAAM,aAAa,gBAAgB,QAAQ,EAAE;AAChD,MAAI,UAAU,SAAS,cAAc,UAAU,KAAK;AAClD;aACS,UAAU,SAAS,aAAa;AACzC;;;CAIJ,MAAM,cAAc,CAAC,GAAG,iBAAiB,GAAG,aAAa;AAEzD,QAAO,GAAG;EACR;EACA;EACA;EACA;EACA,UAAU;EACX,CAA0B"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["lines: string[]","warnings: string[]","missingKeyFragments: { canonicalId: string; typename: string; schemaLabel: string }[]","outputFormatters: TypeFormatters","inputFormatters: TypeFormatters","lines: string[]","formatters: TypeFormatters","adapterImports: string[]","extensionMap: Record<string, string>","withPrefix","currentExt"],"sources":["../src/errors.ts","../src/emitter.ts","../src/prebuilt-generator.ts","../src/runner.ts"],"sourcesContent":["/**\n * Error types for typegen package.\n *\n * @module\n */\n\nimport type { BuilderError } from \"@soda-gql/builder\";\n\n/**\n * Error codes specific to typegen operations.\n */\nexport type TypegenErrorCode =\n | \"TYPEGEN_CODEGEN_REQUIRED\"\n | \"TYPEGEN_SCHEMA_LOAD_FAILED\"\n | \"TYPEGEN_BUILD_FAILED\"\n | \"TYPEGEN_EMIT_FAILED\"\n | \"TYPEGEN_BUNDLE_FAILED\"\n | \"TYPEGEN_FRAGMENT_MISSING_KEY\";\n\n/**\n * Typegen-specific error type.\n */\nexport type TypegenSpecificError =\n | {\n readonly code: \"TYPEGEN_CODEGEN_REQUIRED\";\n readonly message: string;\n readonly outdir: string;\n }\n | {\n readonly code: \"TYPEGEN_SCHEMA_LOAD_FAILED\";\n readonly message: string;\n readonly schemaNames: readonly string[];\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_BUILD_FAILED\";\n readonly message: string;\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_EMIT_FAILED\";\n readonly message: string;\n readonly path: string;\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_BUNDLE_FAILED\";\n readonly message: string;\n readonly path: string;\n readonly cause?: unknown;\n }\n | {\n readonly code: \"TYPEGEN_FRAGMENT_MISSING_KEY\";\n readonly message: string;\n readonly fragments: readonly {\n readonly canonicalId: string;\n readonly typename: string;\n readonly schemaLabel: string;\n }[];\n };\n\n/**\n * Union of all typegen errors (specific + builder errors).\n */\nexport type TypegenError = TypegenSpecificError | BuilderError;\n\n/**\n * Error constructor helpers for concise error creation.\n */\nexport const typegenErrors = {\n codegenRequired: (outdir: string): TypegenSpecificError => ({\n code: \"TYPEGEN_CODEGEN_REQUIRED\",\n message: `Generated graphql-system module not found at '${outdir}'. Run 'soda-gql codegen' first.`,\n outdir,\n }),\n\n schemaLoadFailed: (schemaNames: readonly string[], cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_SCHEMA_LOAD_FAILED\",\n message: `Failed to load schemas: ${schemaNames.join(\", \")}`,\n schemaNames,\n cause,\n }),\n\n buildFailed: (message: string, cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_BUILD_FAILED\",\n message,\n cause,\n }),\n\n emitFailed: (path: string, message: string, cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_EMIT_FAILED\",\n message,\n path,\n cause,\n }),\n\n bundleFailed: (path: string, message: string, cause?: unknown): TypegenSpecificError => ({\n code: \"TYPEGEN_BUNDLE_FAILED\",\n message,\n path,\n cause,\n }),\n\n fragmentMissingKey: (\n fragments: readonly { canonicalId: string; typename: string; schemaLabel: string }[],\n ): TypegenSpecificError => ({\n code: \"TYPEGEN_FRAGMENT_MISSING_KEY\",\n message: `${fragments.length} fragment(s) missing required 'key' property for prebuilt types`,\n fragments,\n }),\n} as const;\n\n/**\n * Format TypegenError for console output (human-readable).\n */\nexport const formatTypegenError = (error: TypegenError): string => {\n const lines: string[] = [];\n\n lines.push(`Error [${error.code}]: ${error.message}`);\n\n switch (error.code) {\n case \"TYPEGEN_CODEGEN_REQUIRED\":\n lines.push(` Output directory: ${error.outdir}`);\n lines.push(\" Hint: Run 'soda-gql codegen' to generate the graphql-system module first.\");\n break;\n case \"TYPEGEN_SCHEMA_LOAD_FAILED\":\n lines.push(` Schemas: ${error.schemaNames.join(\", \")}`);\n break;\n case \"TYPEGEN_EMIT_FAILED\":\n case \"TYPEGEN_BUNDLE_FAILED\":\n lines.push(` Path: ${error.path}`);\n break;\n case \"TYPEGEN_FRAGMENT_MISSING_KEY\":\n lines.push(\" Fragments missing 'key' property:\");\n for (const fragment of error.fragments) {\n lines.push(` - ${fragment.canonicalId} (${fragment.typename} on ${fragment.schemaLabel})`);\n }\n lines.push(\" Hint: Add a 'key' property to each fragment for prebuilt type resolution.\");\n break;\n }\n\n if (\"cause\" in error && error.cause) {\n lines.push(` Caused by: ${error.cause}`);\n }\n\n return lines.join(\"\\n\");\n};\n","/**\n * Prebuilt types emitter.\n *\n * Generates TypeScript type definitions for PrebuiltTypes registry\n * from field selection data and schema.\n *\n * ## Error Handling Strategy\n *\n * The emitter uses a partial failure approach for type calculation errors:\n *\n * **Recoverable errors** (result in warnings, element skipped):\n * - Type calculation failures (e.g., `calculateFieldsType` throws)\n * - Input type generation failures (e.g., `generateInputType` throws)\n * - These are caught per-element, logged as warnings, and the element is omitted\n *\n * **Fatal errors** (result in error result):\n * - `SCHEMA_NOT_FOUND`: Selection references non-existent schema\n * - `WRITE_FAILED`: Cannot write output file to disk\n *\n * This allows builds to succeed with partial type coverage when some elements\n * have issues, while providing visibility into problems via warnings.\n *\n * @module\n */\n\nimport { writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { type BuilderError, builderErrors, type FieldSelectionsMap } from \"@soda-gql/builder\";\nimport type { AnyGraphqlSchema, InputTypeSpecifiers, TypeFormatters } from \"@soda-gql/core\";\nimport { calculateFieldsType, generateInputObjectType, generateInputType, generateInputTypeFromSpecifiers } from \"@soda-gql/core\";\nimport { Kind, type TypeNode, type VariableDefinitionNode } from \"graphql\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport { type TypegenError, typegenErrors } from \"./errors\";\n\n/**\n * Options for emitting prebuilt types.\n */\nexport type PrebuiltTypesEmitterOptions = {\n /**\n * Schema definitions per schema name.\n * These come from the codegen output.\n */\n readonly schemas: Record<string, AnyGraphqlSchema>;\n /**\n * Field selections extracted from the builder.\n */\n readonly fieldSelections: FieldSelectionsMap;\n /**\n * Output directory (where prebuilt/types.ts should be written).\n * This should be the same as config.outdir.\n */\n readonly outdir: string;\n /**\n * Relative import path to _internal-injects.ts from types.prebuilt.ts.\n * Example: \"./_internal-injects\"\n */\n readonly injectsModulePath: string;\n};\n\ntype PrebuiltFragmentEntry = {\n readonly key: string;\n readonly typename: string;\n readonly inputType: string;\n readonly outputType: string;\n};\n\ntype PrebuiltOperationEntry = {\n readonly key: string;\n readonly inputType: string;\n readonly outputType: string;\n};\n\ntype SchemaGroup = {\n fragments: PrebuiltFragmentEntry[];\n operations: PrebuiltOperationEntry[];\n inputObjects: Set<string>;\n};\n\ntype GroupBySchemaResult = {\n readonly grouped: Map<string, SchemaGroup>;\n readonly warnings: string[];\n};\n\n/**\n * Group field selections by schema.\n * Uses the schemaLabel from each selection to group them correctly.\n *\n * In strict mode, all fragments must have a 'key' property. Fragments\n * without keys will cause an error.\n *\n * @returns Result containing grouped selections and warnings, or error if schema not found\n * or fragments are missing keys\n */\nconst groupBySchema = (\n fieldSelections: FieldSelectionsMap,\n schemas: Record<string, AnyGraphqlSchema>,\n): Result<GroupBySchemaResult, BuilderError | TypegenError> => {\n const grouped = new Map<string, SchemaGroup>();\n const warnings: string[] = [];\n const missingKeyFragments: { canonicalId: string; typename: string; schemaLabel: string }[] = [];\n\n // Initialize groups for each schema\n for (const schemaName of Object.keys(schemas)) {\n grouped.set(schemaName, { fragments: [], operations: [], inputObjects: new Set() });\n }\n\n for (const [canonicalId, selection] of fieldSelections) {\n // Use schemaLabel to determine which schema this selection belongs to\n const schemaName = selection.schemaLabel;\n const schema = schemas[schemaName];\n const group = grouped.get(schemaName);\n\n if (!schema || !group) {\n return err(builderErrors.schemaNotFound(schemaName, canonicalId));\n }\n\n // Create formatters for schema-specific type names\n const outputFormatters: TypeFormatters = {\n scalarOutput: (name) => `ScalarOutput_${schemaName}<\"${name}\">`,\n };\n const inputFormatters: TypeFormatters = {\n scalarInput: (name) => `ScalarInput_${schemaName}<\"${name}\">`,\n inputObject: (name) => `Input_${schemaName}_${name}`,\n };\n\n if (selection.type === \"fragment\") {\n // Strict mode: fragments must have keys\n if (!selection.key) {\n missingKeyFragments.push({\n canonicalId,\n typename: selection.typename,\n schemaLabel: selection.schemaLabel,\n });\n continue; // Continue collecting all errors before reporting\n }\n\n try {\n // Collect input objects used in fragment variables\n const usedInputObjects = collectUsedInputObjectsFromSpecifiers(schema, selection.variableDefinitions);\n for (const inputName of usedInputObjects) {\n group.inputObjects.add(inputName);\n }\n\n // Generate output type with schema-specific scalar names\n const outputType = calculateFieldsType(schema, selection.fields, outputFormatters);\n\n // Generate input type from variableDefinitions with schema-specific names\n const hasVariables = Object.keys(selection.variableDefinitions).length > 0;\n const inputType = hasVariables\n ? generateInputTypeFromSpecifiers(schema, selection.variableDefinitions, { formatters: inputFormatters })\n : \"void\";\n\n group.fragments.push({\n key: selection.key,\n typename: selection.typename,\n inputType,\n outputType,\n });\n } catch (error) {\n warnings.push(\n `[prebuilt] Failed to calculate type for fragment \"${selection.key}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n } else if (selection.type === \"operation\") {\n try {\n // Collect input objects used in this operation\n const usedInputObjects = collectUsedInputObjects(schema, selection.variableDefinitions);\n for (const inputName of usedInputObjects) {\n group.inputObjects.add(inputName);\n }\n\n // Generate output type with schema-specific scalar names\n const outputType = calculateFieldsType(schema, selection.fields, outputFormatters);\n\n // Generate input type with schema-specific scalar and input object names\n const inputType = generateInputType(schema, selection.variableDefinitions, inputFormatters);\n\n group.operations.push({\n key: selection.operationName,\n inputType,\n outputType,\n });\n } catch (error) {\n warnings.push(\n `[prebuilt] Failed to calculate type for operation \"${selection.operationName}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n }\n\n // Strict mode: error if any fragments are missing keys\n if (missingKeyFragments.length > 0) {\n return err(typegenErrors.fragmentMissingKey(missingKeyFragments));\n }\n\n return ok({ grouped, warnings });\n};\n\n/**\n * Extract input object names from a GraphQL TypeNode.\n */\nconst extractInputObjectsFromType = (schema: AnyGraphqlSchema, typeNode: TypeNode, inputObjects: Set<string>): void => {\n switch (typeNode.kind) {\n case Kind.NON_NULL_TYPE:\n extractInputObjectsFromType(schema, typeNode.type, inputObjects);\n break;\n case Kind.LIST_TYPE:\n extractInputObjectsFromType(schema, typeNode.type, inputObjects);\n break;\n case Kind.NAMED_TYPE: {\n const name = typeNode.name.value;\n // Check if it's an input object (not a scalar or enum)\n if (!schema.scalar[name] && !schema.enum[name] && schema.input[name]) {\n inputObjects.add(name);\n }\n break;\n }\n }\n};\n\n/**\n * Recursively collect nested input objects from schema definitions.\n * Takes a set of initial input names and expands to include all nested inputs.\n */\nconst collectNestedInputObjects = (schema: AnyGraphqlSchema, initialInputNames: Set<string>): Set<string> => {\n const inputObjects = new Set(initialInputNames);\n\n const collectNested = (inputName: string, seen: Set<string>): void => {\n if (seen.has(inputName)) {\n return;\n }\n seen.add(inputName);\n\n const inputDef = schema.input[inputName];\n if (!inputDef) {\n return;\n }\n\n for (const field of Object.values(inputDef.fields)) {\n if (field.kind === \"input\" && !inputObjects.has(field.name)) {\n inputObjects.add(field.name);\n collectNested(field.name, seen);\n }\n }\n };\n\n for (const inputName of Array.from(initialInputNames)) {\n collectNested(inputName, new Set());\n }\n\n return inputObjects;\n};\n\n/**\n * Collect all input object types used in variable definitions.\n * Recursively collects nested input objects from the schema.\n */\nconst collectUsedInputObjects = (\n schema: AnyGraphqlSchema,\n variableDefinitions: readonly VariableDefinitionNode[],\n): Set<string> => {\n const directInputs = new Set<string>();\n for (const varDef of variableDefinitions) {\n extractInputObjectsFromType(schema, varDef.type, directInputs);\n }\n return collectNestedInputObjects(schema, directInputs);\n};\n\n/**\n * Collect all input object types used in InputTypeSpecifiers.\n * Recursively collects nested input objects from the schema.\n */\nconst collectUsedInputObjectsFromSpecifiers = (schema: AnyGraphqlSchema, specifiers: InputTypeSpecifiers): Set<string> => {\n const directInputs = new Set<string>();\n for (const specifier of Object.values(specifiers)) {\n if (specifier.kind === \"input\" && schema.input[specifier.name]) {\n directInputs.add(specifier.name);\n }\n }\n return collectNestedInputObjects(schema, directInputs);\n};\n\n/**\n * Generate type definitions for input objects.\n */\nconst generateInputObjectTypeDefinitions = (schema: AnyGraphqlSchema, schemaName: string, inputNames: Set<string>): string[] => {\n const lines: string[] = [];\n\n // Get depth config from schema (optional properties defined in AnyGraphqlSchema)\n const defaultDepth = schema.__defaultInputDepth ?? 3;\n const depthOverrides = schema.__inputDepthOverrides ?? {};\n\n // Create formatters for schema-specific type names\n const formatters: TypeFormatters = {\n scalarInput: (name) => `ScalarInput_${schemaName}<\"${name}\">`,\n inputObject: (name) => `Input_${schemaName}_${name}`,\n };\n\n // Sort for deterministic output\n const sortedNames = Array.from(inputNames).sort();\n\n for (const inputName of sortedNames) {\n const typeString = generateInputObjectType(schema, inputName, {\n defaultDepth,\n depthOverrides,\n formatters,\n });\n\n lines.push(`type Input_${schemaName}_${inputName} = ${typeString};`);\n }\n\n return lines;\n};\n\n/**\n * Generate the TypeScript code for prebuilt types.\n */\nconst generateTypesCode = (\n grouped: Map<string, SchemaGroup>,\n schemas: Record<string, AnyGraphqlSchema>,\n injectsModulePath: string,\n): string => {\n const schemaNames = Object.keys(schemas);\n\n const lines: string[] = [\n \"/**\",\n \" * Prebuilt type registry.\",\n \" *\",\n \" * This file is auto-generated by @soda-gql/typegen.\",\n \" * Do not edit manually.\",\n \" *\",\n \" * @module\",\n \" * @generated\",\n \" */\",\n \"\",\n 'import type { PrebuiltTypeRegistry } from \"@soda-gql/core\";',\n ];\n\n // Generate import from _internal-injects.ts\n const scalarImports = schemaNames.map((name) => `scalar_${name}`).join(\", \");\n lines.push(`import type { ${scalarImports} } from \"${injectsModulePath}\";`);\n\n lines.push(\"\");\n\n // Generate ScalarInput and ScalarOutput helper types\n for (const schemaName of schemaNames) {\n lines.push(\n `type ScalarInput_${schemaName}<T extends keyof typeof scalar_${schemaName}> = ` +\n `typeof scalar_${schemaName}[T][\"$type\"][\"input\"];`,\n );\n lines.push(\n `type ScalarOutput_${schemaName}<T extends keyof typeof scalar_${schemaName}> = ` +\n `typeof scalar_${schemaName}[T][\"$type\"][\"output\"];`,\n );\n }\n\n lines.push(\"\");\n\n for (const [schemaName, { fragments, operations, inputObjects }] of grouped) {\n const schema = schemas[schemaName];\n\n // Generate input object type definitions if there are any\n if (inputObjects.size > 0 && schema) {\n lines.push(\"// Input object types\");\n const inputTypeLines = generateInputObjectTypeDefinitions(schema, schemaName, inputObjects);\n lines.push(...inputTypeLines);\n lines.push(\"\");\n }\n\n // Generate fragments type\n const fragmentEntries = fragments\n .sort((a, b) => a.key.localeCompare(b.key))\n .map(\n (f) =>\n ` readonly \"${f.key}\": { readonly typename: \"${f.typename}\"; readonly input: ${f.inputType}; readonly output: ${f.outputType} };`,\n );\n\n // Generate operations type\n const operationEntries = operations\n .sort((a, b) => a.key.localeCompare(b.key))\n .map((o) => ` readonly \"${o.key}\": { readonly input: ${o.inputType}; readonly output: ${o.outputType} };`);\n\n lines.push(`export type PrebuiltTypes_${schemaName} = {`);\n lines.push(\" readonly fragments: {\");\n if (fragmentEntries.length > 0) {\n lines.push(...fragmentEntries);\n }\n lines.push(\" };\");\n lines.push(\" readonly operations: {\");\n if (operationEntries.length > 0) {\n lines.push(...operationEntries);\n }\n lines.push(\" };\");\n lines.push(\"};\");\n lines.push(\"\");\n }\n\n return lines.join(\"\\n\");\n};\n\n/**\n * Result of emitting prebuilt types.\n */\nexport type PrebuiltTypesEmitResult = {\n readonly path: string;\n readonly warnings: readonly string[];\n};\n\n/**\n * Emit prebuilt types to the prebuilt/types.ts file.\n *\n * This function uses a partial failure strategy: if type calculation fails for\n * individual elements (e.g., due to invalid field selections or missing schema\n * types), those elements are skipped and warnings are collected rather than\n * failing the entire emission. This allows builds to succeed even when some\n * elements have issues, while still reporting problems via warnings.\n *\n * @param options - Emitter options including schemas, field selections, and output directory\n * @returns Result containing output path and warnings, or error if a hard failure occurs\n *\n * @example\n * ```typescript\n * const result = await emitPrebuiltTypes({\n * schemas: { mySchema: schema },\n * fieldSelections,\n * outdir: \"./generated\",\n * injects: { mySchema: { scalars: \"./scalars.ts\" } },\n * });\n *\n * if (result.isOk()) {\n * console.log(`Generated: ${result.value.path}`);\n * if (result.value.warnings.length > 0) {\n * console.warn(\"Warnings:\", result.value.warnings);\n * }\n * }\n * ```\n */\nexport const emitPrebuiltTypes = async (\n options: PrebuiltTypesEmitterOptions,\n): Promise<Result<PrebuiltTypesEmitResult, BuilderError | TypegenError>> => {\n const { schemas, fieldSelections, outdir, injectsModulePath } = options;\n\n // Group selections by schema\n const groupResult = groupBySchema(fieldSelections, schemas);\n if (groupResult.isErr()) {\n return err(groupResult.error);\n }\n const { grouped, warnings } = groupResult.value;\n\n // Generate the types code\n const code = generateTypesCode(grouped, schemas, injectsModulePath);\n\n // Write to types.prebuilt.ts\n const typesPath = join(outdir, \"types.prebuilt.ts\");\n\n try {\n await writeFile(typesPath, code, \"utf-8\");\n return ok({ path: typesPath, warnings });\n } catch (error) {\n return err(\n builderErrors.writeFailed(\n typesPath,\n `Failed to write prebuilt types: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n }\n};\n","/**\n * Prebuilt module generator for bundler-compatible type resolution.\n *\n * Generates index.prebuilt.ts in the output directory (flat layout).\n * This module creates prebuilt gql composers that use PrebuiltTypes\n * for type lookup instead of complex inference.\n *\n * Generated file structure (in outdir):\n * - index.prebuilt.ts: Prebuilt gql composers\n * - types.prebuilt.ts: Type registry (generated by emitter.ts)\n *\n * Type resolution strategy:\n * - Types are resolved at the fragment/operation builder level using TKey/TName\n * - No ResolvePrebuiltElement needed at composer level\n * - This enables proper typing for fields, metadata, and other builder arguments\n *\n * @module\n */\n\nimport type { DocumentNode } from \"graphql\";\n\nexport type PrebuiltGeneratorOptions = {\n /**\n * Relative import path to the internal module.\n * Example: \"./_internal\" (from index.prebuilt.ts to _internal.ts)\n */\n readonly internalModulePath: string;\n /**\n * Relative import path to the injects module.\n * Example: \"./_internal-injects\" (from index.prebuilt.ts to _internal-injects.ts)\n */\n readonly injectsModulePath: string;\n /**\n * Per-schema injection config.\n * Maps schema name to whether it has an adapter.\n */\n readonly injection?: Map<\n string,\n {\n readonly hasAdapter?: boolean;\n }\n >;\n};\n\nexport type PrebuiltGeneratedModule = {\n /** The generated code for index.prebuilt.ts */\n readonly indexCode: string;\n};\n\n/**\n * Generate the prebuilt index module code.\n *\n * Generates index.prebuilt.ts with builder-level type resolution.\n * Types are resolved at the fragment/operation builder level using TKey/TName,\n * eliminating the need for ResolvePrebuiltElement at the composer level.\n */\nexport const generatePrebuiltModule = (\n schemas: Map<string, DocumentNode>,\n options: PrebuiltGeneratorOptions,\n): PrebuiltGeneratedModule => {\n const schemaNames = Array.from(schemas.keys());\n const injection = options.injection ?? new Map();\n\n // Generate adapter imports from _internal-injects.ts\n const adapterImports: string[] = [];\n for (const name of schemaNames) {\n const config = injection.get(name);\n if (config?.hasAdapter) {\n adapterImports.push(`adapter_${name}`);\n }\n }\n\n // Generate internal imports (runtime values and types needed for composer creation)\n const internalImports = schemaNames.flatMap((name) => [\n `__schema_${name}`,\n `__inputTypeMethods_${name}`,\n `__directiveMethods_${name}`,\n ]);\n\n // Generic types (schema-independent, generated once)\n const genericTypes = `\n/**\n * Generic field factory for type-erased field access.\n * Returns a callable for nested field builders. Primitive fields can be spread directly.\n * Runtime behavior differs but spread works for both: ...f.id() and ...f.user()(...)\n */\ntype GenericFieldFactory = (\n ...args: unknown[]\n) => (nest: (tools: GenericFieldsBuilderTools) => AnyFields) => AnyFields;\n\n/**\n * Generic tools for fields builder callbacks.\n * Uses type-erased factory to allow any field access while maintaining strict mode compatibility.\n */\ntype GenericFieldsBuilderTools = {\n readonly f: Record<string, GenericFieldFactory>;\n readonly $: Record<string, unknown>;\n};\n`;\n\n // Generate resolver types and context types for each schema\n const contextTypes = schemaNames\n .map(\n (name) => `\n/**\n * Resolve fragment types at builder level using TKey.\n * If TKey is a known key in PrebuiltTypes, return resolved types.\n * Otherwise, return PrebuiltEntryNotFound.\n */\ntype ResolveFragmentAtBuilder_${name}<\n TKey extends string | undefined\n> = TKey extends keyof PrebuiltTypes_${name}[\"fragments\"]\n ? Fragment<\n PrebuiltTypes_${name}[\"fragments\"][TKey][\"typename\"],\n PrebuiltTypes_${name}[\"fragments\"][TKey][\"input\"] extends infer TInput\n ? TInput extends void ? void : Partial<TInput & object>\n : void,\n Partial<AnyFields>,\n PrebuiltTypes_${name}[\"fragments\"][TKey][\"output\"] & object\n >\n : TKey extends undefined\n ? Fragment<\"(unknown)\", PrebuiltEntryNotFound<\"(undefined)\", \"fragment\">, Partial<AnyFields>, PrebuiltEntryNotFound<\"(undefined)\", \"fragment\">>\n : Fragment<\"(unknown)\", PrebuiltEntryNotFound<TKey & string, \"fragment\">, Partial<AnyFields>, PrebuiltEntryNotFound<TKey & string, \"fragment\">>;\n\n/**\n * Resolve operation types at builder level using TName.\n */\ntype ResolveOperationAtBuilder_${name}<\n TOperationType extends OperationType,\n TName extends string\n> = TName extends keyof PrebuiltTypes_${name}[\"operations\"]\n ? Operation<\n TOperationType,\n TName,\n string[],\n PrebuiltTypes_${name}[\"operations\"][TName][\"input\"] & AnyConstAssignableInput,\n Partial<AnyFields>,\n PrebuiltTypes_${name}[\"operations\"][TName][\"output\"] & object\n >\n : Operation<\n TOperationType,\n TName,\n string[],\n PrebuiltEntryNotFound<TName, \"operation\">,\n Partial<AnyFields>,\n PrebuiltEntryNotFound<TName, \"operation\">\n >;\n\n/**\n * Fragment builder that resolves types at builder level using TKey.\n */\ntype PrebuiltFragmentBuilder_${name} = <TKey extends string | undefined = undefined>(\n options: {\n key?: TKey;\n fields: (tools: GenericFieldsBuilderTools) => AnyFields;\n variables?: Record<string, unknown>;\n metadata?: unknown;\n }\n) => ResolveFragmentAtBuilder_${name}<TKey>;\n\n/**\n * Operation builder that resolves types at builder level using TName.\n */\ntype PrebuiltOperationBuilder_${name}<TOperationType extends OperationType> = <TName extends string>(\n options: {\n name: TName;\n fields: (tools: GenericFieldsBuilderTools) => AnyFields;\n variables?: Record<string, unknown>;\n metadata?: unknown;\n }\n) => ResolveOperationAtBuilder_${name}<TOperationType, TName>;\n\n/**\n * Prebuilt context with builder-level type resolution for schema \"${name}\".\n */\ntype PrebuiltContext_${name} = {\n readonly fragment: { [K: string]: PrebuiltFragmentBuilder_${name} };\n readonly query: { readonly operation: PrebuiltOperationBuilder_${name}<\"query\"> };\n readonly mutation: { readonly operation: PrebuiltOperationBuilder_${name}<\"mutation\"> };\n readonly subscription: { readonly operation: PrebuiltOperationBuilder_${name}<\"subscription\"> };\n readonly $var: unknown;\n readonly $dir: StandardDirectives;\n readonly $colocate: unknown;\n};`,\n )\n .join(\"\\n\");\n\n // Generate gql entries using createGqlElementComposer with type cast\n const gqlEntries = schemaNames.map((name) => {\n const config = injection.get(name);\n const adapterLine = config?.hasAdapter ? `,\\n adapter: adapter_${name}` : \"\";\n\n return ` ${name}: createGqlElementComposer(\n __schema_${name} as AnyGraphqlSchema,\n {\n inputTypeMethods: __inputTypeMethods_${name},\n directiveMethods: __directiveMethods_${name}${adapterLine}\n }\n ) as unknown as GqlComposer_${name}`;\n });\n\n // Build injects import line\n const injectsImportSpecifiers = adapterImports.length > 0 ? adapterImports.join(\", \") : \"\";\n const injectsImportLine = injectsImportSpecifiers\n ? `import { ${injectsImportSpecifiers} } from \"${options.injectsModulePath}\";`\n : \"\";\n\n // Generate index.prebuilt.ts code with builder-level type resolution\n const indexCode = `\\\n/**\n * Prebuilt GQL module with builder-level type resolution.\n *\n * Types are resolved at the fragment/operation builder level using TKey/TName,\n * not at the composer level. This enables proper typing for builder arguments\n * and eliminates the need for ResolvePrebuiltElement.\n *\n * @module\n * @generated by @soda-gql/typegen\n */\n\nimport {\n createGqlElementComposer,\n type AnyConstAssignableInput,\n type AnyFields,\n type AnyGraphqlSchema,\n type Fragment,\n type Operation,\n type OperationType,\n type PrebuiltEntryNotFound,\n type StandardDirectives,\n} from \"@soda-gql/core\";\n${injectsImportLine}\nimport { ${internalImports.join(\", \")} } from \"${options.internalModulePath}\";\nimport type { ${schemaNames.map((name) => `PrebuiltTypes_${name}`).join(\", \")} } from \"./types.prebuilt\";\n${genericTypes}\n${contextTypes}\n\n// Export context types for explicit annotation\n${schemaNames.map((name) => `export type { PrebuiltContext_${name} };`).join(\"\\n\")}\n\n// Composer type - TResult already has resolved types from builders, no ResolvePrebuiltElement needed\n${schemaNames\n .map(\n (name) => `type GqlComposer_${name} = {\n <TResult>(composeElement: (context: PrebuiltContext_${name}) => TResult): TResult;\n readonly $schema: AnyGraphqlSchema;\n};`,\n )\n .join(\"\\n\")}\n\n/**\n * Prebuilt GQL composers with builder-level type resolution.\n *\n * These composers have the same runtime behavior as the base composers,\n * but their return types are resolved from the prebuilt type registry\n * at the builder level instead of using ResolvePrebuiltElement.\n */\nexport const gql: { ${schemaNames.map((name) => `${name}: GqlComposer_${name}`).join(\"; \")} } = {\n${gqlEntries.join(\",\\n\")}\n};\n`;\n\n return {\n indexCode,\n };\n};\n","/**\n * Main typegen runner.\n *\n * Orchestrates the prebuilt type generation process:\n * 1. Load schemas from generated CJS bundle\n * 2. Generate index.prebuilt.ts\n * 3. Build artifact to evaluate elements\n * 4. Extract field selections\n * 5. Emit types.prebuilt.ts\n * 6. Bundle prebuilt module\n *\n * @module\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, extname, join, relative, resolve } from \"node:path\";\nimport {\n createBuilderService,\n extractFieldSelections,\n type IntermediateArtifactElement,\n loadSchemasFromBundle,\n} from \"@soda-gql/builder\";\nimport type { CanonicalId } from \"@soda-gql/common\";\nimport type { ResolvedSodaGqlConfig } from \"@soda-gql/config\";\nimport { build } from \"esbuild\";\nimport { type DocumentNode, parse } from \"graphql\";\nimport { err, ok } from \"neverthrow\";\nimport { emitPrebuiltTypes } from \"./emitter\";\nimport { typegenErrors } from \"./errors\";\nimport { generatePrebuiltModule } from \"./prebuilt-generator\";\nimport type { TypegenResult, TypegenSuccess } from \"./types\";\n\n/**\n * Options for running typegen.\n */\nexport type RunTypegenOptions = {\n /**\n * Resolved soda-gql configuration.\n */\n readonly config: ResolvedSodaGqlConfig;\n};\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 `./${targetPath.slice(0, -sourceExt.length).split(\"/\").pop()}`;\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 ? targetPath.slice(0, -sourceExt.length).split(\"/\").pop() : targetPath.split(\"/\").pop();\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\n/**\n * Bundle the prebuilt module to CJS format.\n */\nconst bundlePrebuiltModule = async (sourcePath: string): Promise<{ cjsPath: string }> => {\n const sourceExt = extname(sourcePath);\n const baseName = sourcePath.slice(0, -sourceExt.length);\n const cjsPath = `${baseName}.cjs`;\n\n await build({\n entryPoints: [sourcePath],\n outfile: cjsPath,\n format: \"cjs\",\n platform: \"node\",\n bundle: true,\n external: [\"@soda-gql/core\", \"@soda-gql/runtime\"],\n sourcemap: false,\n minify: false,\n treeShaking: false,\n });\n\n return { cjsPath };\n};\n\n/**\n * Write a TypeScript module to disk.\n */\nconst writeModule = async (path: string, content: string): Promise<void> => {\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, content, \"utf-8\");\n};\n\n/**\n * Load GraphQL schema documents from schema paths.\n * This is needed for generatePrebuiltModule which expects DocumentNode.\n */\nconst loadSchemaDocuments = (schemasConfig: ResolvedSodaGqlConfig[\"schemas\"]): Map<string, DocumentNode> => {\n const documents = new Map<string, DocumentNode>();\n\n for (const [name, schemaConfig] of Object.entries(schemasConfig)) {\n const schemaPaths = Array.isArray(schemaConfig.schema) ? schemaConfig.schema : [schemaConfig.schema];\n\n // Concatenate all schema files\n let combinedSource = \"\";\n for (const schemaPath of schemaPaths) {\n combinedSource += `${readFileSync(schemaPath, \"utf-8\")}\\n`;\n }\n\n documents.set(name, parse(combinedSource));\n }\n\n return documents;\n};\n\n/**\n * Run the typegen process.\n *\n * This function:\n * 1. Loads schemas from the generated CJS bundle\n * 2. Generates index.prebuilt.ts using generatePrebuiltModule\n * 3. Creates a BuilderService and builds the artifact\n * 4. Extracts field selections from the artifact\n * 5. Emits types.prebuilt.ts using emitPrebuiltTypes\n * 6. Bundles the prebuilt module\n *\n * @param options - Typegen options including config\n * @returns Result containing success data or error\n */\nexport const runTypegen = async (options: RunTypegenOptions): Promise<TypegenResult> => {\n const { config } = options;\n const outdir = resolve(config.outdir);\n const cjsPath = join(outdir, \"index.cjs\");\n const importSpecifierOptions = { includeExtension: config.styles.importExtension };\n\n // Step 1: Check if codegen has been run\n if (!existsSync(cjsPath)) {\n return err(typegenErrors.codegenRequired(outdir));\n }\n\n // Step 2: Load schemas from CJS bundle\n const schemaNames = Object.keys(config.schemas);\n const schemasResult = loadSchemasFromBundle(cjsPath, schemaNames);\n if (schemasResult.isErr()) {\n return err(typegenErrors.schemaLoadFailed(schemaNames, schemasResult.error));\n }\n const schemas = schemasResult.value;\n\n // Step 3: Load schema documents and generate index.prebuilt.ts\n const schemaDocuments = loadSchemaDocuments(config.schemas);\n const prebuiltIndexPath = join(outdir, \"index.prebuilt.ts\");\n\n // Calculate import paths from index.prebuilt.ts to internal modules\n const internalModulePath = toImportSpecifier(prebuiltIndexPath, join(outdir, \"_internal.ts\"), importSpecifierOptions);\n const injectsModulePath = toImportSpecifier(prebuiltIndexPath, join(outdir, \"_internal-injects.ts\"), importSpecifierOptions);\n\n // Build injection config for generatePrebuiltModule\n const injection = new Map<string, { hasAdapter?: boolean }>();\n for (const [schemaName, schemaConfig] of Object.entries(config.schemas)) {\n injection.set(schemaName, {\n hasAdapter: !!schemaConfig.inject.adapter,\n });\n }\n\n const prebuilt = generatePrebuiltModule(schemaDocuments, {\n internalModulePath,\n injectsModulePath,\n injection,\n });\n\n // Write index.prebuilt.ts\n try {\n await writeModule(prebuiltIndexPath, prebuilt.indexCode);\n } catch (error) {\n return err(\n typegenErrors.emitFailed(\n prebuiltIndexPath,\n `Failed to write prebuilt index: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n }\n\n // Step 4: Build artifact using BuilderService\n const builderService = createBuilderService({\n config,\n });\n\n const artifactResult = await builderService.buildAsync();\n\n if (artifactResult.isErr()) {\n return err(typegenErrors.buildFailed(`Builder failed: ${artifactResult.error.message}`, artifactResult.error));\n }\n\n // Step 5: Extract field selections from intermediate elements\n const intermediateElements = builderService.getIntermediateElements();\n if (!intermediateElements) {\n return err(typegenErrors.buildFailed(\"No intermediate elements available after build\", undefined));\n }\n\n const fieldSelectionsResult = extractFieldSelections(intermediateElements as Record<CanonicalId, IntermediateArtifactElement>);\n const { selections: fieldSelections, warnings: extractWarnings } = fieldSelectionsResult;\n\n // Step 6: Emit types.prebuilt.ts\n // Reuse injectsModulePath from step 3 (same directory, same relative path)\n const emitResult = await emitPrebuiltTypes({\n schemas,\n fieldSelections,\n outdir,\n injectsModulePath,\n });\n\n if (emitResult.isErr()) {\n return err(emitResult.error);\n }\n\n const { path: prebuiltTypesPath, warnings: emitWarnings } = emitResult.value;\n\n // Step 7: Bundle prebuilt module\n try {\n await bundlePrebuiltModule(prebuiltIndexPath);\n } catch (error) {\n return err(\n typegenErrors.bundleFailed(\n prebuiltIndexPath,\n `Failed to bundle prebuilt module: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n }\n\n // Count fragments and operations\n let fragmentCount = 0;\n let operationCount = 0;\n for (const selection of fieldSelections.values()) {\n if (selection.type === \"fragment\" && selection.key) {\n fragmentCount++;\n } else if (selection.type === \"operation\") {\n operationCount++;\n }\n }\n\n const allWarnings = [...extractWarnings, ...emitWarnings];\n\n return ok({\n prebuiltIndexPath,\n prebuiltTypesPath,\n fragmentCount,\n operationCount,\n warnings: allWarnings,\n } satisfies TypegenSuccess);\n};\n"],"mappings":";;;;;;;;;;;;;AAqEA,MAAa,gBAAgB;CAC3B,kBAAkB,YAA0C;EAC1D,MAAM;EACN,SAAS,iDAAiD,OAAO;EACjE;EACD;CAED,mBAAmB,aAAgC,WAA2C;EAC5F,MAAM;EACN,SAAS,2BAA2B,YAAY,KAAK,KAAK;EAC1D;EACA;EACD;CAED,cAAc,SAAiB,WAA2C;EACxE,MAAM;EACN;EACA;EACD;CAED,aAAa,MAAc,SAAiB,WAA2C;EACrF,MAAM;EACN;EACA;EACA;EACD;CAED,eAAe,MAAc,SAAiB,WAA2C;EACvF,MAAM;EACN;EACA;EACA;EACD;CAED,qBACE,eAC0B;EAC1B,MAAM;EACN,SAAS,GAAG,UAAU,OAAO;EAC7B;EACD;CACF;;;;AAKD,MAAa,sBAAsB,UAAgC;CACjE,MAAMA,QAAkB,EAAE;AAE1B,OAAM,KAAK,UAAU,MAAM,KAAK,KAAK,MAAM,UAAU;AAErD,SAAQ,MAAM,MAAd;EACE,KAAK;AACH,SAAM,KAAK,uBAAuB,MAAM,SAAS;AACjD,SAAM,KAAK,8EAA8E;AACzF;EACF,KAAK;AACH,SAAM,KAAK,cAAc,MAAM,YAAY,KAAK,KAAK,GAAG;AACxD;EACF,KAAK;EACL,KAAK;AACH,SAAM,KAAK,WAAW,MAAM,OAAO;AACnC;EACF,KAAK;AACH,SAAM,KAAK,sCAAsC;AACjD,QAAK,MAAM,YAAY,MAAM,WAAW;AACtC,UAAM,KAAK,SAAS,SAAS,YAAY,IAAI,SAAS,SAAS,MAAM,SAAS,YAAY,GAAG;;AAE/F,SAAM,KAAK,8EAA8E;AACzF;;AAGJ,KAAI,WAAW,SAAS,MAAM,OAAO;AACnC,QAAM,KAAK,gBAAgB,MAA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AAU,iBAAiB,WAAW;AAGvE,KAAI;AACF,QAAM,qBAAqB,kBAAkB;UACtC,OAAO;AACd,SAAO,IACL,cAAc,aACZ,mBACA,qCAAqC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IAC3F,MACD,CACF;;CAIH,IAAI,gBAAgB;CACpB,IAAI,iBAAiB;AACrB,MAAK,MAAM,aAAa,gBAAgB,QAAQ,EAAE;AAChD,MAAI,UAAU,SAAS,cAAc,UAAU,KAAK;AAClD;aACS,UAAU,SAAS,aAAa;AACzC;;;CAIJ,MAAM,cAAc,CAAC,GAAG,iBAAiB,GAAG,aAAa;AAEzD,QAAO,GAAG;EACR;EACA;EACA;EACA;EACA,UAAU;EACX,CAA0B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soda-gql/typegen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Prebuilt type generation for soda-gql",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"./package.json": "./package.json"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@soda-gql/builder": "0.
|
|
51
|
-
"@soda-gql/common": "0.
|
|
52
|
-
"@soda-gql/config": "0.
|
|
53
|
-
"@soda-gql/core": "0.
|
|
50
|
+
"@soda-gql/builder": "0.11.0",
|
|
51
|
+
"@soda-gql/common": "0.11.0",
|
|
52
|
+
"@soda-gql/config": "0.11.0",
|
|
53
|
+
"@soda-gql/core": "0.11.0",
|
|
54
54
|
"esbuild": "^0.24.0",
|
|
55
55
|
"graphql": "^16.8.1",
|
|
56
56
|
"neverthrow": "^8.1.1"
|