@soda-gql/codegen 0.0.1 → 0.0.3
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/{generator-DudCa3Gz.cjs → generator-C2PYxsdV.cjs} +1 -1
- package/dist/{generator-BgvqYNQA.js → generator-CVAppANp.mjs} +20 -21
- package/dist/generator-CVAppANp.mjs.map +1 -0
- package/dist/{generator-t_NByvnv.cjs → generator-CoK2jtNh.cjs} +18 -49
- package/dist/generator-D-iGYq3g.mjs +3 -0
- package/dist/index.cjs +2 -8
- package/dist/index.d.cts.map +1 -1
- package/dist/{index.d.ts → index.d.mts} +4 -4
- package/dist/index.d.mts.map +1 -0
- package/dist/{index.js → index.mjs} +3 -3
- package/dist/index.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/generator-BgvqYNQA.js.map +0 -1
- package/dist/generator-DLeYPsgP.js +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_generator = require('./generator-
|
|
1
|
+
const require_generator = require('./generator-CoK2jtNh.cjs');
|
|
2
2
|
|
|
3
3
|
exports.createSchemaIndex = require_generator.createSchemaIndex;
|
|
4
4
|
exports.generateMultiSchemaModule = require_generator.generateMultiSchemaModule;
|
|
@@ -199,17 +199,16 @@ const collectTypeLevels = (type, nonNull = false, levels = []) => {
|
|
|
199
199
|
};
|
|
200
200
|
};
|
|
201
201
|
const buildTypeModifier = (levels) => {
|
|
202
|
-
let modifier = "";
|
|
202
|
+
let modifier = "?";
|
|
203
203
|
for (const level of levels.slice().reverse()) {
|
|
204
204
|
if (level.kind === "named") {
|
|
205
|
-
modifier = level.nonNull ? "!" : "";
|
|
205
|
+
modifier = level.nonNull ? "!" : "?";
|
|
206
206
|
continue;
|
|
207
207
|
}
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
modifier = level.nonNull ? `${base}!` : base;
|
|
208
|
+
const listSuffix = level.nonNull ? "[]!" : "[]?";
|
|
209
|
+
modifier = `${modifier}${listSuffix}`;
|
|
211
210
|
}
|
|
212
|
-
return modifier
|
|
211
|
+
return modifier;
|
|
213
212
|
};
|
|
214
213
|
const parseTypeReference = (type) => {
|
|
215
214
|
const { name, levels } = collectTypeLevels(type);
|
|
@@ -277,24 +276,23 @@ const renderArgumentMap = (schema, args) => {
|
|
|
277
276
|
indentSize: 8
|
|
278
277
|
});
|
|
279
278
|
};
|
|
280
|
-
const renderOutputRef = (schema, type, args
|
|
279
|
+
const renderOutputRef = (schema, type, args) => {
|
|
281
280
|
const { name, modifier } = parseTypeReference(type);
|
|
282
281
|
const modifiedType = renderType(name, modifier);
|
|
283
282
|
const argumentMap = renderArgumentMap(schema, args);
|
|
284
|
-
const directiveMap = renderDirectives(directives);
|
|
285
283
|
if (isScalarName(schema, name)) {
|
|
286
|
-
return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap}
|
|
284
|
+
return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap} })`;
|
|
287
285
|
}
|
|
288
286
|
if (isEnumName(schema, name)) {
|
|
289
|
-
return `unsafeOutputType.enum(${modifiedType}, { arguments: ${argumentMap}
|
|
287
|
+
return `unsafeOutputType.enum(${modifiedType}, { arguments: ${argumentMap} })`;
|
|
290
288
|
}
|
|
291
289
|
if (isUnionName(schema, name)) {
|
|
292
|
-
return `unsafeOutputType.union(${modifiedType}, { arguments: ${argumentMap}
|
|
290
|
+
return `unsafeOutputType.union(${modifiedType}, { arguments: ${argumentMap} })`;
|
|
293
291
|
}
|
|
294
292
|
if (isObjectName(schema, name)) {
|
|
295
|
-
return `unsafeOutputType.object(${modifiedType}, { arguments: ${argumentMap}
|
|
293
|
+
return `unsafeOutputType.object(${modifiedType}, { arguments: ${argumentMap} })`;
|
|
296
294
|
}
|
|
297
|
-
return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap}
|
|
295
|
+
return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap} })`;
|
|
298
296
|
};
|
|
299
297
|
const renderPropertyLines = ({ entries, indentSize }) => {
|
|
300
298
|
if (entries.length === 0) {
|
|
@@ -309,7 +307,7 @@ const renderPropertyLines = ({ entries, indentSize }) => {
|
|
|
309
307
|
].join(`\n`);
|
|
310
308
|
};
|
|
311
309
|
const renderObjectFields = (schema, fields) => {
|
|
312
|
-
const entries = Array.from(fields.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((field) => `${field.name.value}: ${renderOutputRef(schema, field.type, field.arguments
|
|
310
|
+
const entries = Array.from(fields.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((field) => `${field.name.value}: ${renderOutputRef(schema, field.type, field.arguments)}`);
|
|
313
311
|
return renderPropertyLines({
|
|
314
312
|
entries,
|
|
315
313
|
indentSize: 6
|
|
@@ -328,7 +326,7 @@ const renderScalarDefinition = (record) => {
|
|
|
328
326
|
output: "string"
|
|
329
327
|
};
|
|
330
328
|
const scalarType = `type<{ input: ${typeInfo.input}; output: ${typeInfo.output} }>()`;
|
|
331
|
-
return `${record.name}: define("${record.name}").scalar(${scalarType}
|
|
329
|
+
return `${record.name}: define("${record.name}").scalar(${scalarType})`;
|
|
332
330
|
};
|
|
333
331
|
const renderObjectDefinition = (schema, typeName) => {
|
|
334
332
|
const record = schema.objects.get(typeName);
|
|
@@ -336,7 +334,7 @@ const renderObjectDefinition = (schema, typeName) => {
|
|
|
336
334
|
return "";
|
|
337
335
|
}
|
|
338
336
|
const fields = renderObjectFields(schema, record.fields);
|
|
339
|
-
return `${record.name}: define("${record.name}").object(${fields}
|
|
337
|
+
return `${record.name}: define("${record.name}").object(${fields})`;
|
|
340
338
|
};
|
|
341
339
|
const renderInputDefinition = (schema, typeName) => {
|
|
342
340
|
const record = schema.inputs.get(typeName);
|
|
@@ -344,7 +342,7 @@ const renderInputDefinition = (schema, typeName) => {
|
|
|
344
342
|
return "";
|
|
345
343
|
}
|
|
346
344
|
const fields = renderInputFields(schema, record.fields);
|
|
347
|
-
return `${record.name}: define("${record.name}").input(${fields}
|
|
345
|
+
return `${record.name}: define("${record.name}").input(${fields})`;
|
|
348
346
|
};
|
|
349
347
|
const renderEnumDefinition = (schema, typeName) => {
|
|
350
348
|
const record = schema.enums.get(typeName);
|
|
@@ -353,7 +351,7 @@ const renderEnumDefinition = (schema, typeName) => {
|
|
|
353
351
|
}
|
|
354
352
|
const values = Array.from(record.values.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((value) => `${value.name.value}: true`).join(", ");
|
|
355
353
|
const body = values.length === 0 ? "{}" : `{ ${values} }`;
|
|
356
|
-
return `${record.name}: define("${record.name}").enum(${body}
|
|
354
|
+
return `${record.name}: define("${record.name}").enum(${body})`;
|
|
357
355
|
};
|
|
358
356
|
const renderUnionDefinition = (schema, typeName) => {
|
|
359
357
|
const record = schema.unions.get(typeName);
|
|
@@ -362,7 +360,7 @@ const renderUnionDefinition = (schema, typeName) => {
|
|
|
362
360
|
}
|
|
363
361
|
const members = Array.from(record.members.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((member) => `${member.name.value}: true`).join(", ");
|
|
364
362
|
const body = members.length === 0 ? "{}" : `{ ${members} }`;
|
|
365
|
-
return `${record.name}: define("${record.name}").union(${body}
|
|
363
|
+
return `${record.name}: define("${record.name}").union(${body})`;
|
|
366
364
|
};
|
|
367
365
|
const collectObjectTypeNames = (schema) => Array.from(schema.objects.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
|
|
368
366
|
const collectInputTypeNames = (schema) => Array.from(schema.inputs.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
|
|
@@ -393,6 +391,7 @@ const multiRuntimeTemplate = ($$) => {
|
|
|
393
391
|
const adapterDefinition = $$.injection.mode === "inject" ? "" : `const ${adapterVar} = createRuntimeAdapter(({ type }) => ({\n nonGraphqlErrorType: type<{ type: "non-graphql-error"; cause: unknown }>(),\n}));\n`;
|
|
394
392
|
schemaBlocks.push(`${adapterDefinition}
|
|
395
393
|
const ${schemaVar} = {
|
|
394
|
+
label: "${name}" as const,
|
|
396
395
|
operations: defineOperationRoots({
|
|
397
396
|
query: "${config.queryType}",
|
|
398
397
|
mutation: "${config.mutationType}",
|
|
@@ -507,5 +506,5 @@ const generateMultiSchemaModule = (schemas, options) => {
|
|
|
507
506
|
};
|
|
508
507
|
|
|
509
508
|
//#endregion
|
|
510
|
-
export {
|
|
511
|
-
//# sourceMappingURL=generator-
|
|
509
|
+
export { generateMultiSchemaModule as n, createSchemaIndex as t };
|
|
510
|
+
//# sourceMappingURL=generator-CVAppANp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator-CVAppANp.mjs","names":["operationTypes: OperationTypeNames","modifier: TypeModifier","imports: string[]","schemaBlocks: string[]","gqlEntries: string[]","schemaConfigs: Record<string, any>","name","injection: RuntimeTemplateInjection"],"sources":["../src/generator.ts"],"sourcesContent":["import type { TypeModifier } from \"@soda-gql/core\";\nimport {\n type ConstDirectiveNode,\n type ConstValueNode,\n type DocumentNode,\n type EnumValueDefinitionNode,\n type FieldDefinitionNode,\n type InputValueDefinitionNode,\n Kind,\n type NamedTypeNode,\n type SchemaDefinitionNode,\n type SchemaExtensionNode,\n type TypeNode,\n} from \"graphql\";\n\nconst builtinScalarTypes = new Map<string, { readonly input: string; readonly output: string }>([\n [\"ID\", { input: \"string\", output: \"string\" }],\n [\"String\", { input: \"string\", output: \"string\" }],\n [\"Int\", { input: \"number\", output: \"number\" }],\n [\"Float\", { input: \"number\", output: \"number\" }],\n [\"Boolean\", { input: \"boolean\", output: \"boolean\" }],\n]);\n\ntype OperationTypeNames = {\n query?: string;\n mutation?: string;\n subscription?: string;\n};\n\ntype ObjectRecord = {\n readonly name: string;\n readonly fields: Map<string, FieldDefinitionNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype InputRecord = {\n readonly name: string;\n readonly fields: Map<string, InputValueDefinitionNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype EnumRecord = {\n readonly name: string;\n readonly values: Map<string, EnumValueDefinitionNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype UnionRecord = {\n readonly name: string;\n readonly members: Map<string, NamedTypeNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype ScalarRecord = {\n readonly name: string;\n directives: ConstDirectiveNode[];\n};\n\ntype SchemaIndex = {\n readonly objects: Map<string, ObjectRecord>;\n readonly inputs: Map<string, InputRecord>;\n readonly enums: Map<string, EnumRecord>;\n readonly unions: Map<string, UnionRecord>;\n readonly scalars: Map<string, ScalarRecord>;\n readonly operationTypes: OperationTypeNames;\n};\n\nconst ensureRecord = <T>(collection: Map<string, T>, key: string, factory: (name: string) => T): T => {\n const existing = collection.get(key);\n if (existing) {\n return existing;\n }\n\n const created = factory(key);\n collection.set(key, created);\n return created;\n};\n\nconst addObjectFields = (target: Map<string, FieldDefinitionNode>, fields: readonly FieldDefinitionNode[] | undefined): void => {\n if (!fields) {\n return;\n }\n\n for (const field of fields) {\n target.set(field.name.value, field);\n }\n};\n\nconst addInputFields = (\n target: Map<string, InputValueDefinitionNode>,\n fields: readonly InputValueDefinitionNode[] | undefined,\n): void => {\n if (!fields) {\n return;\n }\n\n for (const field of fields) {\n target.set(field.name.value, field);\n }\n};\n\nconst addEnumValues = (\n target: Map<string, EnumValueDefinitionNode>,\n values: readonly EnumValueDefinitionNode[] | undefined,\n): void => {\n if (!values) {\n return;\n }\n\n for (const value of values) {\n target.set(value.name.value, value);\n }\n};\n\nconst addUnionMembers = (target: Map<string, NamedTypeNode>, members: readonly NamedTypeNode[] | undefined): void => {\n if (!members) {\n return;\n }\n\n for (const member of members) {\n target.set(member.name.value, member);\n }\n};\n\nconst mergeDirectives = (\n existing: ConstDirectiveNode[] | undefined,\n incoming: readonly ConstDirectiveNode[] | undefined,\n precedence: \"definition\" | \"extension\",\n): ConstDirectiveNode[] => {\n const current = existing ?? [];\n const next = incoming ? Array.from(incoming) : [];\n return precedence === \"definition\" ? [...next, ...current] : [...current, ...next];\n};\n\nconst updateOperationTypes = (\n operationTypes: OperationTypeNames,\n definition: SchemaDefinitionNode | SchemaExtensionNode,\n): void => {\n for (const operation of definition.operationTypes ?? []) {\n const typeName = operation.type.name.value;\n switch (operation.operation) {\n case \"query\":\n operationTypes.query = typeName;\n break;\n case \"mutation\":\n operationTypes.mutation = typeName;\n break;\n case \"subscription\":\n operationTypes.subscription = typeName;\n break;\n default:\n break;\n }\n }\n};\n\nexport const createSchemaIndex = (document: DocumentNode): SchemaIndex => {\n const objects = new Map<string, ObjectRecord>();\n const inputs = new Map<string, InputRecord>();\n const enums = new Map<string, EnumRecord>();\n const unions = new Map<string, UnionRecord>();\n const scalars = new Map<string, ScalarRecord>();\n const operationTypes: OperationTypeNames = {};\n\n for (const definition of document.definitions) {\n switch (definition.kind) {\n case Kind.OBJECT_TYPE_DEFINITION:\n case Kind.OBJECT_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.OBJECT_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(objects, definition.name.value, (name) => ({\n name,\n fields: new Map<string, FieldDefinitionNode>(),\n directives: [],\n }));\n addObjectFields(record.fields, definition.fields);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.INPUT_OBJECT_TYPE_DEFINITION:\n case Kind.INPUT_OBJECT_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(inputs, definition.name.value, (name) => ({\n name,\n fields: new Map<string, InputValueDefinitionNode>(),\n directives: [],\n }));\n addInputFields(record.fields, definition.fields);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.ENUM_TYPE_DEFINITION:\n case Kind.ENUM_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.ENUM_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(enums, definition.name.value, (name) => ({\n name,\n values: new Map<string, EnumValueDefinitionNode>(),\n directives: [],\n }));\n addEnumValues(record.values, definition.values);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.UNION_TYPE_DEFINITION:\n case Kind.UNION_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.UNION_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(unions, definition.name.value, (name) => ({\n name,\n members: new Map<string, NamedTypeNode>(),\n directives: [],\n }));\n addUnionMembers(record.members, definition.types);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.SCALAR_TYPE_DEFINITION:\n case Kind.SCALAR_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.SCALAR_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(scalars, definition.name.value, (name) => ({\n name,\n directives: [],\n }));\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.SCHEMA_DEFINITION:\n case Kind.SCHEMA_EXTENSION:\n updateOperationTypes(operationTypes, definition);\n break;\n default:\n break;\n }\n }\n\n if (!operationTypes.query && objects.has(\"Query\")) {\n operationTypes.query = \"Query\";\n }\n if (!operationTypes.mutation && objects.has(\"Mutation\")) {\n operationTypes.mutation = \"Mutation\";\n }\n if (!operationTypes.subscription && objects.has(\"Subscription\")) {\n operationTypes.subscription = \"Subscription\";\n }\n\n return {\n objects,\n inputs,\n enums,\n unions,\n scalars,\n operationTypes,\n } satisfies SchemaIndex;\n};\n\ntype TypeLevel = {\n readonly kind: \"list\" | \"named\";\n readonly nonNull: boolean;\n};\n\nconst collectTypeLevels = (\n type: TypeNode,\n nonNull = false,\n levels: TypeLevel[] = [],\n): { readonly name: string; readonly levels: TypeLevel[] } => {\n if (type.kind === Kind.NON_NULL_TYPE) {\n return collectTypeLevels(type.type, true, levels);\n }\n\n if (type.kind === Kind.LIST_TYPE) {\n levels.push({ kind: \"list\", nonNull });\n return collectTypeLevels(type.type, false, levels);\n }\n\n levels.push({ kind: \"named\", nonNull });\n return { name: type.name.value, levels };\n};\n\nconst buildTypeModifier = (levels: TypeLevel[]): TypeModifier => {\n let modifier: TypeModifier = \"?\";\n\n for (const level of levels.slice().reverse()) {\n if (level.kind === \"named\") {\n // Inner type: always explicit nullable marker\n modifier = level.nonNull ? \"!\" : \"?\";\n continue;\n }\n\n // List type: append []? or []! based on list's nullability\n const listSuffix = level.nonNull ? \"[]!\" : \"[]?\";\n modifier = `${modifier}${listSuffix}` as TypeModifier;\n }\n\n return modifier;\n};\n\nconst parseTypeReference = (type: TypeNode): { readonly name: string; readonly modifier: string } => {\n const { name, levels } = collectTypeLevels(type);\n return { name, modifier: buildTypeModifier(levels) };\n};\n\nconst renderType = (name: string, modifier: string): string => JSON.stringify(`${name}:${modifier}`);\n\nconst isScalarName = (schema: SchemaIndex, name: string): boolean => builtinScalarTypes.has(name) || schema.scalars.has(name);\nconst isEnumName = (schema: SchemaIndex, name: string): boolean => schema.enums.has(name);\nconst _isInputName = (schema: SchemaIndex, name: string): boolean => schema.inputs.has(name);\nconst isUnionName = (schema: SchemaIndex, name: string): boolean => schema.unions.has(name);\nconst isObjectName = (schema: SchemaIndex, name: string): boolean => schema.objects.has(name);\n\nconst renderConstValue = (value: ConstValueNode): string => {\n switch (value.kind) {\n case Kind.NULL:\n return \"null\";\n case Kind.INT:\n case Kind.FLOAT:\n return value.value;\n case Kind.STRING:\n case Kind.ENUM:\n return JSON.stringify(value.value);\n case Kind.BOOLEAN:\n return value.value ? \"true\" : \"false\";\n case Kind.LIST:\n return `[${value.values.map((item) => renderConstValue(item)).join(\", \")}]`;\n case Kind.OBJECT: {\n if (value.fields.length === 0) {\n return \"{}\";\n }\n const entries = value.fields.map((field) => `${field.name.value}: ${renderConstValue(field.value)}`);\n return `{ ${entries.join(\", \")} }`;\n }\n }\n};\n\nconst renderConstArgumentMap = (\n args: readonly { readonly name: { readonly value: string }; readonly value: ConstValueNode }[] | undefined,\n): string => {\n const entries = (args ?? []).map((arg) => `${arg.name.value}: ${renderConstValue(arg.value)}`);\n return renderPropertyLines({ entries, indentSize: 8 });\n};\n\nconst renderDirectives = (directives: readonly ConstDirectiveNode[] | undefined): string => {\n const entries = (directives ?? []).map(\n (directive) => `${directive.name.value}: ${renderConstArgumentMap(directive.arguments)}`,\n );\n return renderPropertyLines({ entries, indentSize: 8 });\n};\n\nconst renderDefaultValue = (value: ConstValueNode | null | undefined): string =>\n value ? `() => (${renderConstValue(value)})` : \"null\";\n\nconst renderInputRef = (schema: SchemaIndex, definition: InputValueDefinitionNode): string => {\n const { name, modifier } = parseTypeReference(definition.type);\n const tuple = renderType(name, modifier);\n const defaultValue = renderDefaultValue(definition.defaultValue ?? null);\n const directives = renderDirectives(definition.directives);\n\n if (isScalarName(schema, name)) {\n return `unsafeInputType.scalar(${tuple}, { default: ${defaultValue}, directives: ${directives} })`;\n }\n\n if (isEnumName(schema, name)) {\n return `unsafeInputType.enum(${tuple}, { default: ${defaultValue}, directives: ${directives} })`;\n }\n\n return `unsafeInputType.input(${tuple}, { default: ${defaultValue}, directives: ${directives} })`;\n};\n\nconst renderArgumentMap = (schema: SchemaIndex, args: readonly InputValueDefinitionNode[] | undefined): string => {\n const entries = [...(args ?? [])]\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((arg) => `${arg.name.value}: ${renderInputRef(schema, arg)}`);\n\n return renderPropertyLines({ entries, indentSize: 8 });\n};\n\nconst renderOutputRef = (schema: SchemaIndex, type: TypeNode, args: readonly InputValueDefinitionNode[] | undefined): string => {\n const { name, modifier } = parseTypeReference(type);\n const modifiedType = renderType(name, modifier);\n const argumentMap = renderArgumentMap(schema, args);\n\n if (isScalarName(schema, name)) {\n return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n if (isEnumName(schema, name)) {\n return `unsafeOutputType.enum(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n if (isUnionName(schema, name)) {\n return `unsafeOutputType.union(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n if (isObjectName(schema, name)) {\n return `unsafeOutputType.object(${modifiedType}, { arguments: ${argumentMap} })`;\n }\n\n return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap} })`;\n};\n\nconst renderPropertyLines = ({ entries, indentSize }: { entries: string[]; indentSize: number }) => {\n if (entries.length === 0) {\n return \"{}\";\n }\n\n const indent = \" \".repeat(indentSize);\n const lastIndent = \" \".repeat(indentSize - 2);\n return [\"{\", `${indent}${entries.join(`,\\n${indent}`)},`, `${lastIndent}}`].join(`\\n`);\n};\n\nconst renderObjectFields = (schema: SchemaIndex, fields: Map<string, FieldDefinitionNode>): string => {\n const entries = Array.from(fields.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((field) => `${field.name.value}: ${renderOutputRef(schema, field.type, field.arguments)}`);\n\n return renderPropertyLines({ entries, indentSize: 6 });\n};\n\nconst renderInputFields = (schema: SchemaIndex, fields: Map<string, InputValueDefinitionNode>): string => {\n const entries = Array.from(fields.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((field) => `${field.name.value}: ${renderInputRef(schema, field)}`);\n\n return renderPropertyLines({ entries, indentSize: 6 });\n};\n\nconst renderScalarDefinition = (record: ScalarRecord): string => {\n const typeInfo = builtinScalarTypes.get(record.name) ?? { input: \"string\", output: \"string\" };\n const scalarType = `type<{ input: ${typeInfo.input}; output: ${typeInfo.output} }>()`;\n return `${record.name}: define(\"${record.name}\").scalar(${scalarType})`;\n};\n\nconst renderObjectDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.objects.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const fields = renderObjectFields(schema, record.fields);\n return `${record.name}: define(\"${record.name}\").object(${fields})`;\n};\n\nconst renderInputDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.inputs.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const fields = renderInputFields(schema, record.fields);\n return `${record.name}: define(\"${record.name}\").input(${fields})`;\n};\n\nconst renderEnumDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.enums.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const values = Array.from(record.values.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((value) => `${value.name.value}: true`)\n .join(\", \");\n const body = values.length === 0 ? \"{}\" : `{ ${values} }`;\n\n return `${record.name}: define(\"${record.name}\").enum(${body})`;\n};\n\nconst renderUnionDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.unions.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const members = Array.from(record.members.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((member) => `${member.name.value}: true`)\n .join(\", \");\n const body = members.length === 0 ? \"{}\" : `{ ${members} }`;\n\n return `${record.name}: define(\"${record.name}\").union(${body})`;\n};\n\nconst collectObjectTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.objects.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectInputTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.inputs.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectEnumTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.enums.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectUnionTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.unions.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectScalarNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.scalars.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nexport type GeneratedModule = {\n readonly code: string;\n readonly stats: {\n readonly objects: number;\n readonly enums: number;\n readonly inputs: number;\n readonly unions: number;\n };\n};\n\ntype PerSchemaInjection = {\n readonly adapterImportPath: string;\n readonly scalarImportPath: string;\n};\n\ntype RuntimeTemplateInjection =\n | { readonly mode: \"inline\" }\n | {\n readonly mode: \"inject\";\n readonly perSchema: Map<string, PerSchemaInjection>;\n };\n\nexport type RuntimeGenerationOptions = {\n readonly injection?: Map<string, PerSchemaInjection>;\n};\n\ntype MultiRuntimeTemplateOptions = {\n readonly schemas: Record<\n string,\n {\n readonly queryType: string;\n readonly mutationType: string;\n readonly subscriptionType: string;\n readonly scalarBlock: string;\n readonly enumBlock: string;\n readonly inputBlock: string;\n readonly objectBlock: string;\n readonly unionBlock: string;\n }\n >;\n readonly injection: RuntimeTemplateInjection;\n};\n\nconst multiRuntimeTemplate = ($$: MultiRuntimeTemplateOptions) => {\n // Build imports based on injection mode\n const imports: string[] = [];\n const adapterAliases = new Map<string, string>();\n const scalarAliases = new Map<string, string>();\n\n if ($$.injection.mode === \"inject\") {\n // Generate per-schema imports\n for (const [schemaName, injection] of $$.injection.perSchema) {\n const adapterAlias = `adapter_${schemaName}`;\n const scalarAlias = `scalar_${schemaName}`;\n adapterAliases.set(schemaName, adapterAlias);\n scalarAliases.set(schemaName, scalarAlias);\n\n imports.push(`import { adapter as ${adapterAlias} } from \"${injection.adapterImportPath}\";`);\n imports.push(`import { scalar as ${scalarAlias} } from \"${injection.scalarImportPath}\";`);\n }\n }\n\n const extraImports = imports.length > 0 ? `${imports.join(\"\\n\")}\\n` : \"\";\n\n // Generate per-schema definitions\n const schemaBlocks: string[] = [];\n const gqlEntries: string[] = [];\n\n for (const [name, config] of Object.entries($$.schemas)) {\n const schemaVar = `${name}Schema`;\n const adapterVar = $$.injection.mode === \"inject\" ? adapterAliases.get(name) : `adapter_${name}`;\n const scalarBlock = $$.injection.mode === \"inject\" ? scalarAliases.get(name) : config.scalarBlock;\n\n // Generate adapter if inline mode\n const adapterDefinition =\n $$.injection.mode === \"inject\"\n ? \"\"\n : `const ${adapterVar} = createRuntimeAdapter(({ type }) => ({\\n nonGraphqlErrorType: type<{ type: \"non-graphql-error\"; cause: unknown }>(),\\n}));\\n`;\n\n schemaBlocks.push(`${adapterDefinition}\nconst ${schemaVar} = {\n label: \"${name}\" as const,\n operations: defineOperationRoots({\n query: \"${config.queryType}\",\n mutation: \"${config.mutationType}\",\n subscription: \"${config.subscriptionType}\",\n }),\n scalar: ${scalarBlock},\n enum: ${config.enumBlock},\n input: ${config.inputBlock},\n object: ${config.objectBlock},\n union: ${config.unionBlock},\n} satisfies AnyGraphqlSchema;\n\nexport type Schema_${name} = typeof ${schemaVar} & { _?: never };\nexport type Adapter_${name} = typeof ${adapterVar} & { _?: never };`);\n\n gqlEntries.push(` ${name}: createGqlElementComposer<Schema_${name}, Adapter_${name}>(${schemaVar})`);\n }\n\n // Include createRuntimeAdapter import only in inline mode\n const runtimeImport = $$.injection.mode === \"inline\" ? '\\nimport { createRuntimeAdapter } from \"@soda-gql/runtime\";' : \"\";\n\n return `\\\nimport {\n type AnyGraphqlSchema,\n createGqlElementComposer,\n define,\n defineOperationRoots,\n unsafeInputType,\n unsafeOutputType,\n} from \"@soda-gql/core\";${runtimeImport}\n${extraImports}\n${schemaBlocks.join(\"\\n\")}\n\nexport const gql = {\n${gqlEntries.join(\",\\n\")}\n};\n`;\n};\n\nexport const generateMultiSchemaModule = (\n schemas: Map<string, DocumentNode>,\n options?: RuntimeGenerationOptions,\n): GeneratedModule => {\n // biome-ignore lint/suspicious/noExplicitAny: complex schema config type\n const schemaConfigs: Record<string, any> = {};\n const allStats = {\n objects: 0,\n enums: 0,\n inputs: 0,\n unions: 0,\n };\n\n for (const [name, document] of schemas.entries()) {\n const schema = createSchemaIndex(document);\n\n const builtinScalarDefinitions = Array.from(builtinScalarTypes.keys()).map((name) =>\n renderScalarDefinition(schema.scalars.get(name) ?? { name, directives: [] }),\n );\n\n const customScalarDefinitions = collectScalarNames(schema)\n .filter((name) => !builtinScalarTypes.has(name))\n .map((name) => {\n const record = schema.scalars.get(name);\n return record ? renderScalarDefinition(record) : \"\";\n })\n .filter((definition) => definition.length > 0);\n\n const allScalarDefinitions = builtinScalarDefinitions.concat(customScalarDefinitions);\n\n const objectTypeNames = collectObjectTypeNames(schema);\n const enumTypeNames = collectEnumTypeNames(schema);\n const inputTypeNames = collectInputTypeNames(schema);\n const unionTypeNames = collectUnionTypeNames(schema);\n\n const scalarBlock = renderPropertyLines({ entries: allScalarDefinitions, indentSize: 4 });\n const enumDefinitions = enumTypeNames\n .map((name) => renderEnumDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const enumBlock = renderPropertyLines({ entries: enumDefinitions, indentSize: 4 });\n const inputDefinitions = inputTypeNames\n .map((name) => renderInputDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const inputBlock = renderPropertyLines({ entries: inputDefinitions, indentSize: 4 });\n const objectDefinitions = objectTypeNames\n .map((name) => renderObjectDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const objectBlock = renderPropertyLines({ entries: objectDefinitions, indentSize: 4 });\n const unionDefinitions = unionTypeNames\n .map((name) => renderUnionDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const unionBlock = renderPropertyLines({ entries: unionDefinitions, indentSize: 4 });\n\n const queryType = schema.operationTypes.query ?? \"Query\";\n const mutationType = schema.operationTypes.mutation ?? \"Mutation\";\n const subscriptionType = schema.operationTypes.subscription ?? \"Subscription\";\n\n schemaConfigs[name] = {\n queryType,\n mutationType,\n subscriptionType,\n scalarBlock,\n enumBlock,\n inputBlock,\n objectBlock,\n unionBlock,\n };\n\n // Accumulate stats\n allStats.objects += objectDefinitions.length;\n allStats.enums += enumDefinitions.length;\n allStats.inputs += inputDefinitions.length;\n allStats.unions += unionDefinitions.length;\n }\n\n const injection: RuntimeTemplateInjection = options?.injection\n ? { mode: \"inject\", perSchema: options.injection }\n : { mode: \"inline\" };\n\n const code = multiRuntimeTemplate({\n schemas: schemaConfigs,\n injection,\n });\n\n return {\n code,\n stats: allStats,\n };\n};\n"],"mappings":";;;AAeA,MAAM,qBAAqB,IAAI,IAAiE;CAC9F,CAAC,MAAM;EA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MAAM;EAAU,WAAW,QAAQ;EAAW,GAChD,EAAE,MAAM,UAAU;CAEtB,MAAM,OAAO,qBAAqB;EAChC,SAAS;EACT;EACD,CAAC;AAEF,QAAO;EACL;EACA,OAAO;EACR"}
|
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
1
|
let graphql = require("graphql");
|
|
25
|
-
graphql = __toESM(graphql);
|
|
26
2
|
|
|
27
3
|
//#region packages/codegen/src/generator.ts
|
|
28
4
|
const builtinScalarTypes = new Map([
|
|
@@ -223,17 +199,16 @@ const collectTypeLevels = (type, nonNull = false, levels = []) => {
|
|
|
223
199
|
};
|
|
224
200
|
};
|
|
225
201
|
const buildTypeModifier = (levels) => {
|
|
226
|
-
let modifier = "";
|
|
202
|
+
let modifier = "?";
|
|
227
203
|
for (const level of levels.slice().reverse()) {
|
|
228
204
|
if (level.kind === "named") {
|
|
229
|
-
modifier = level.nonNull ? "!" : "";
|
|
205
|
+
modifier = level.nonNull ? "!" : "?";
|
|
230
206
|
continue;
|
|
231
207
|
}
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
modifier = level.nonNull ? `${base}!` : base;
|
|
208
|
+
const listSuffix = level.nonNull ? "[]!" : "[]?";
|
|
209
|
+
modifier = `${modifier}${listSuffix}`;
|
|
235
210
|
}
|
|
236
|
-
return modifier
|
|
211
|
+
return modifier;
|
|
237
212
|
};
|
|
238
213
|
const parseTypeReference = (type) => {
|
|
239
214
|
const { name, levels } = collectTypeLevels(type);
|
|
@@ -301,24 +276,23 @@ const renderArgumentMap = (schema, args) => {
|
|
|
301
276
|
indentSize: 8
|
|
302
277
|
});
|
|
303
278
|
};
|
|
304
|
-
const renderOutputRef = (schema, type, args
|
|
279
|
+
const renderOutputRef = (schema, type, args) => {
|
|
305
280
|
const { name, modifier } = parseTypeReference(type);
|
|
306
281
|
const modifiedType = renderType(name, modifier);
|
|
307
282
|
const argumentMap = renderArgumentMap(schema, args);
|
|
308
|
-
const directiveMap = renderDirectives(directives);
|
|
309
283
|
if (isScalarName(schema, name)) {
|
|
310
|
-
return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap}
|
|
284
|
+
return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap} })`;
|
|
311
285
|
}
|
|
312
286
|
if (isEnumName(schema, name)) {
|
|
313
|
-
return `unsafeOutputType.enum(${modifiedType}, { arguments: ${argumentMap}
|
|
287
|
+
return `unsafeOutputType.enum(${modifiedType}, { arguments: ${argumentMap} })`;
|
|
314
288
|
}
|
|
315
289
|
if (isUnionName(schema, name)) {
|
|
316
|
-
return `unsafeOutputType.union(${modifiedType}, { arguments: ${argumentMap}
|
|
290
|
+
return `unsafeOutputType.union(${modifiedType}, { arguments: ${argumentMap} })`;
|
|
317
291
|
}
|
|
318
292
|
if (isObjectName(schema, name)) {
|
|
319
|
-
return `unsafeOutputType.object(${modifiedType}, { arguments: ${argumentMap}
|
|
293
|
+
return `unsafeOutputType.object(${modifiedType}, { arguments: ${argumentMap} })`;
|
|
320
294
|
}
|
|
321
|
-
return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap}
|
|
295
|
+
return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap} })`;
|
|
322
296
|
};
|
|
323
297
|
const renderPropertyLines = ({ entries, indentSize }) => {
|
|
324
298
|
if (entries.length === 0) {
|
|
@@ -333,7 +307,7 @@ const renderPropertyLines = ({ entries, indentSize }) => {
|
|
|
333
307
|
].join(`\n`);
|
|
334
308
|
};
|
|
335
309
|
const renderObjectFields = (schema, fields) => {
|
|
336
|
-
const entries = Array.from(fields.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((field) => `${field.name.value}: ${renderOutputRef(schema, field.type, field.arguments
|
|
310
|
+
const entries = Array.from(fields.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((field) => `${field.name.value}: ${renderOutputRef(schema, field.type, field.arguments)}`);
|
|
337
311
|
return renderPropertyLines({
|
|
338
312
|
entries,
|
|
339
313
|
indentSize: 6
|
|
@@ -352,7 +326,7 @@ const renderScalarDefinition = (record) => {
|
|
|
352
326
|
output: "string"
|
|
353
327
|
};
|
|
354
328
|
const scalarType = `type<{ input: ${typeInfo.input}; output: ${typeInfo.output} }>()`;
|
|
355
|
-
return `${record.name}: define("${record.name}").scalar(${scalarType}
|
|
329
|
+
return `${record.name}: define("${record.name}").scalar(${scalarType})`;
|
|
356
330
|
};
|
|
357
331
|
const renderObjectDefinition = (schema, typeName) => {
|
|
358
332
|
const record = schema.objects.get(typeName);
|
|
@@ -360,7 +334,7 @@ const renderObjectDefinition = (schema, typeName) => {
|
|
|
360
334
|
return "";
|
|
361
335
|
}
|
|
362
336
|
const fields = renderObjectFields(schema, record.fields);
|
|
363
|
-
return `${record.name}: define("${record.name}").object(${fields}
|
|
337
|
+
return `${record.name}: define("${record.name}").object(${fields})`;
|
|
364
338
|
};
|
|
365
339
|
const renderInputDefinition = (schema, typeName) => {
|
|
366
340
|
const record = schema.inputs.get(typeName);
|
|
@@ -368,7 +342,7 @@ const renderInputDefinition = (schema, typeName) => {
|
|
|
368
342
|
return "";
|
|
369
343
|
}
|
|
370
344
|
const fields = renderInputFields(schema, record.fields);
|
|
371
|
-
return `${record.name}: define("${record.name}").input(${fields}
|
|
345
|
+
return `${record.name}: define("${record.name}").input(${fields})`;
|
|
372
346
|
};
|
|
373
347
|
const renderEnumDefinition = (schema, typeName) => {
|
|
374
348
|
const record = schema.enums.get(typeName);
|
|
@@ -377,7 +351,7 @@ const renderEnumDefinition = (schema, typeName) => {
|
|
|
377
351
|
}
|
|
378
352
|
const values = Array.from(record.values.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((value) => `${value.name.value}: true`).join(", ");
|
|
379
353
|
const body = values.length === 0 ? "{}" : `{ ${values} }`;
|
|
380
|
-
return `${record.name}: define("${record.name}").enum(${body}
|
|
354
|
+
return `${record.name}: define("${record.name}").enum(${body})`;
|
|
381
355
|
};
|
|
382
356
|
const renderUnionDefinition = (schema, typeName) => {
|
|
383
357
|
const record = schema.unions.get(typeName);
|
|
@@ -386,7 +360,7 @@ const renderUnionDefinition = (schema, typeName) => {
|
|
|
386
360
|
}
|
|
387
361
|
const members = Array.from(record.members.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((member) => `${member.name.value}: true`).join(", ");
|
|
388
362
|
const body = members.length === 0 ? "{}" : `{ ${members} }`;
|
|
389
|
-
return `${record.name}: define("${record.name}").union(${body}
|
|
363
|
+
return `${record.name}: define("${record.name}").union(${body})`;
|
|
390
364
|
};
|
|
391
365
|
const collectObjectTypeNames = (schema) => Array.from(schema.objects.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
|
|
392
366
|
const collectInputTypeNames = (schema) => Array.from(schema.inputs.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
|
|
@@ -417,6 +391,7 @@ const multiRuntimeTemplate = ($$) => {
|
|
|
417
391
|
const adapterDefinition = $$.injection.mode === "inject" ? "" : `const ${adapterVar} = createRuntimeAdapter(({ type }) => ({\n nonGraphqlErrorType: type<{ type: "non-graphql-error"; cause: unknown }>(),\n}));\n`;
|
|
418
392
|
schemaBlocks.push(`${adapterDefinition}
|
|
419
393
|
const ${schemaVar} = {
|
|
394
|
+
label: "${name}" as const,
|
|
420
395
|
operations: defineOperationRoots({
|
|
421
396
|
query: "${config.queryType}",
|
|
422
397
|
mutation: "${config.mutationType}",
|
|
@@ -531,12 +506,6 @@ const generateMultiSchemaModule = (schemas, options) => {
|
|
|
531
506
|
};
|
|
532
507
|
|
|
533
508
|
//#endregion
|
|
534
|
-
Object.defineProperty(exports, '__toESM', {
|
|
535
|
-
enumerable: true,
|
|
536
|
-
get: function () {
|
|
537
|
-
return __toESM;
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
509
|
Object.defineProperty(exports, 'createSchemaIndex', {
|
|
541
510
|
enumerable: true,
|
|
542
511
|
get: function () {
|
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
const require_generator = require('./generator-
|
|
1
|
+
const require_generator = require('./generator-CoK2jtNh.cjs');
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
|
-
node_fs = require_generator.__toESM(node_fs);
|
|
4
3
|
let node_path = require("node:path");
|
|
5
|
-
node_path = require_generator.__toESM(node_path);
|
|
6
4
|
let neverthrow = require("neverthrow");
|
|
7
|
-
neverthrow = require_generator.__toESM(neverthrow);
|
|
8
5
|
let graphql = require("graphql");
|
|
9
|
-
graphql = require_generator.__toESM(graphql);
|
|
10
6
|
let node_crypto = require("node:crypto");
|
|
11
|
-
node_crypto = require_generator.__toESM(node_crypto);
|
|
12
7
|
let tsdown = require("tsdown");
|
|
13
|
-
tsdown = require_generator.__toESM(tsdown);
|
|
14
8
|
|
|
15
9
|
//#region packages/codegen/src/inject-template.ts
|
|
16
10
|
const templateContents = `\
|
|
@@ -234,7 +228,7 @@ const runMultiSchemaCodegen = async (options) => {
|
|
|
234
228
|
}
|
|
235
229
|
const { code } = require_generator.generateMultiSchemaModule(schemas, { injection: injectionConfig });
|
|
236
230
|
for (const [name, document] of schemas.entries()) {
|
|
237
|
-
const schemaIndex = (await Promise.resolve().then(() => require("./generator-
|
|
231
|
+
const schemaIndex = (await Promise.resolve().then(() => require("./generator-C2PYxsdV.cjs"))).createSchemaIndex(document);
|
|
238
232
|
const objects = Array.from(schemaIndex.objects.keys()).filter((n) => !n.startsWith("__")).length;
|
|
239
233
|
const enums = Array.from(schemaIndex.enums.keys()).filter((n) => !n.startsWith("__")).length;
|
|
240
234
|
const inputs = Array.from(schemaIndex.inputs.keys()).filter((n) => !n.startsWith("__")).length;
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/inject-template.ts","../src/runner.ts","../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;KAEY,aAAA;KAEA,cAAA;;;EAFA,SAAA,MAAA,EAKO,aALM;EAEb,SAAA,cAAc,EAAA,MAGP;AAInB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/inject-template.ts","../src/runner.ts","../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;KAEY,aAAA;KAEA,cAAA;;;EAFA,SAAA,MAAA,EAKO,aALM;EAEb,SAAA,cAAc,EAAA,MAGP;AAInB,CAAA;AACoB,KADR,yBAAA,GACQ;EAED,SAAA,OAAA,EAFC,MAED,CAAA,MAAA,EAAA,MAAA,CAAA;EACU,SAAA,OAAA,EAAA,MAAA;EACR,SAAA,MAAA,EAFF,aAEE;EAAM,SAAA,eAAA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AyBtC;;;cCzBA,iCAAwC,8BAA4B,QAAQ;;;cCnC5E,oCAAgC,WAAA,CAAA,IAAA,cAAA,gBAAA,WAAA,CAAA,GAAA,cAAA;cAyBhC,uBAAwB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as neverthrow0 from "neverthrow";
|
|
2
2
|
import { Result } from "neverthrow";
|
|
3
3
|
import { DocumentNode } from "graphql";
|
|
4
4
|
|
|
@@ -77,15 +77,15 @@ type CodegenResult = Result<CodegenSuccess, CodegenError>;
|
|
|
77
77
|
type MultiSchemaCodegenResult = Result<MultiSchemaCodegenSuccess, CodegenError>;
|
|
78
78
|
//#endregion
|
|
79
79
|
//#region packages/codegen/src/inject-template.d.ts
|
|
80
|
-
declare const writeInjectTemplate: (outPath: string) =>
|
|
80
|
+
declare const writeInjectTemplate: (outPath: string) => neverthrow0.Err<void, CodegenError> | neverthrow0.Ok<void, CodegenError>;
|
|
81
81
|
declare const getInjectTemplate: () => string;
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region packages/codegen/src/runner.d.ts
|
|
84
84
|
declare const runMultiSchemaCodegen: (options: MultiSchemaCodegenOptions) => Promise<MultiSchemaCodegenResult>;
|
|
85
85
|
//#endregion
|
|
86
86
|
//#region packages/codegen/src/schema.d.ts
|
|
87
|
-
declare const loadSchema: (schemaPath: string) =>
|
|
87
|
+
declare const loadSchema: (schemaPath: string) => neverthrow0.Err<DocumentNode, CodegenError> | neverthrow0.Ok<DocumentNode, CodegenError>;
|
|
88
88
|
declare const hashSchema: (document: DocumentNode) => string;
|
|
89
89
|
//#endregion
|
|
90
90
|
export { type CodegenCliCommand, type CodegenError, type CodegenFormat, type MultiSchemaCodegenOptions, type MultiSchemaCodegenResult, type MultiSchemaCodegenSuccess, hashSchema, loadSchema, runMultiSchemaCodegen, writeInjectTemplate };
|
|
91
|
-
//# sourceMappingURL=index.d.
|
|
91
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/inject-template.ts","../src/runner.ts","../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;KAEY,aAAA;KAEA,cAAA;;;EAFA,SAAA,MAAA,EAKO,aALM;EAEb,SAAA,cAAc,EAAA,MAGP;AAInB,CAAA;AACoB,KADR,yBAAA,GACQ;EAED,SAAA,OAAA,EAFC,MAED,CAAA,MAAA,EAAA,MAAA,CAAA;EACU,SAAA,OAAA,EAAA,MAAA;EACR,SAAA,MAAA,EAFF,aAEE;EAAM,SAAA,eAAA,CAAA,EADE,MACF,CAAA,MAAA,EAAA,MAAA,CAAA;EAIf,SAAA,OAAA,CAAA,EAJS,MAIQ,CAAA,MAGL,EAAA,MAAA,CAAA;EAQZ,SAAA,cAAY,CAAA,EAAA,MAAA;AAoCxB,CAAA;AASY,KAxDA,iBAAA,GAwDyB;EAezB,SAAA,IAAA,EAAA,UAAa;EAAU,SAAA,OAAA,EApEX,cAoEW;CAAgB,GAAA;EAAvB,SAAA,IAAA,EAAA,oBAAA;EAAM,SAAA,OAAA,EAAA,MAAA;EACtB,SAAA,MAAA,EAhEW,aAgEa;CAAU;AAA2B,KA7D7D,YAAA,GA6D6D;EAAlC,SAAA,IAAA,EAAA,kBAAA;EAAM,SAAA,OAAA,EAAA,MAAA;;;;ECjDhC,SAAA,OAAA,EAAA,MAuBZ;EAvBkD,SAAA,UAAA,EAAA,MAAA;CAAA,GAAA;EAAA,SAAA,IAAA,EAAA,aAAA;EAAA,SAAA,OAAA,EAAA,MAAA;EAAA,SAAA,OAAA,EAAA,MAAA;AAyBnD,CAAA,GAAa;;;;ECzBA,SAAA,IAAA,EAAA,yBAwHZ;EAxHoD,SAAA,OAAA,EAAA,MAAA;EAAoC,SAAA,UAAA,EAAA,MAAA;CAAR,GAAA;EAAO,SAAA,IAAA,EAAA,wBAAA;;;;ECnC3E,SAAA,IAuBZ,EAAA,wBAAA;EAvB4C,SAAA,OAAA,EAAA,MAAA;EAAA,SAAA,OAAA,EAAA,MAAA;CAAA;AAAA,KH2DjC,cAAA,GG3DiC;EAAA,SAAA,UAAA,EAAA,MAAA;EAAA,SAAA,OAAA,EAAA,MAAA;EAAA,SAAA,OAAA,EAAA,MAAA;EAyBhC,SAAA,KAA2G,EAAA,MAAA;;;;KH2C5G,yBAAA;oBACQ;;;;;;;;;;KAcR,aAAA,GAAgB,OAAO,gBAAgB;KACvC,wBAAA,GAA2B,OAAO,2BAA2B;;;cCjD5D,0CAAsC,WAAA,CAAA,UAAA,gBAAA,WAAA,CAAA,SAAA;cAyBtC;;;cCzBA,iCAAwC,8BAA4B,QAAQ;;;cCnC5E,oCAAgC,WAAA,CAAA,IAAA,cAAA,gBAAA,WAAA,CAAA,GAAA,cAAA;cAyBhC,uBAAwB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generateMultiSchemaModule } from "./generator-
|
|
1
|
+
import { n as generateMultiSchemaModule } from "./generator-CVAppANp.mjs";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, extname, relative, resolve } from "node:path";
|
|
4
4
|
import { err, ok } from "neverthrow";
|
|
@@ -228,7 +228,7 @@ const runMultiSchemaCodegen = async (options) => {
|
|
|
228
228
|
}
|
|
229
229
|
const { code } = generateMultiSchemaModule(schemas, { injection: injectionConfig });
|
|
230
230
|
for (const [name, document] of schemas.entries()) {
|
|
231
|
-
const schemaIndex = (await import("./generator-
|
|
231
|
+
const schemaIndex = (await import("./generator-D-iGYq3g.mjs")).createSchemaIndex(document);
|
|
232
232
|
const objects = Array.from(schemaIndex.objects.keys()).filter((n) => !n.startsWith("__")).length;
|
|
233
233
|
const enums = Array.from(schemaIndex.enums.keys()).filter((n) => !n.startsWith("__")).length;
|
|
234
234
|
const inputs = Array.from(schemaIndex.inputs.keys()).filter((n) => !n.startsWith("__")).length;
|
|
@@ -259,4 +259,4 @@ const runMultiSchemaCodegen = async (options) => {
|
|
|
259
259
|
|
|
260
260
|
//#endregion
|
|
261
261
|
export { hashSchema, loadSchema, runMultiSchemaCodegen, writeInjectTemplate };
|
|
262
|
-
//# sourceMappingURL=index.
|
|
262
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["extensionMap: Record<string, string>","schemaHashes: Record<string, { schemaHash: string; objects: number; enums: number; inputs: number; unions: number }>"],"sources":["../src/inject-template.ts","../src/file.ts","../src/schema.ts","../src/tsdown-bundle.ts","../src/runner.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nconst templateContents = `\\\nimport { defineScalar } from \"@soda-gql/core\";\nimport { createRuntimeAdapter } from \"@soda-gql/runtime\";\n\nexport const scalar = {\n ...defineScalar(\"ID\", ({ type }) => ({\n input: type<string>(),\n output: type<string>(),\n directives: {},\n })),\n ...defineScalar(\"String\", ({ type }) => ({\n input: type<string>(),\n output: type<string>(),\n directives: {},\n })),\n ...defineScalar(\"Int\", ({ type }) => ({\n input: type<number>(),\n output: type<number>(),\n directives: {},\n })),\n ...defineScalar(\"Float\", ({ type }) => ({\n input: type<number>(),\n output: type<number>(),\n directives: {},\n })),\n ...defineScalar(\"Boolean\", ({ type }) => ({\n input: type<boolean>(),\n output: type<boolean>(),\n directives: {},\n })),\n} as const;\n\nexport const adapter = createRuntimeAdapter(({ type }) => ({\n nonGraphqlErrorType: type<{ type: \"non-graphql-error\"; cause: unknown }>(),\n}));\n`;\n\nexport const writeInjectTemplate = (outPath: string) => {\n const targetPath = resolve(outPath);\n\n try {\n if (existsSync(targetPath)) {\n return err<void, CodegenError>({\n code: \"INJECT_TEMPLATE_EXISTS\",\n message: `Inject module already exists: ${targetPath}`,\n outPath: targetPath,\n });\n }\n\n mkdirSync(dirname(targetPath), { recursive: true });\n writeFileSync(targetPath, `${templateContents}\\n`);\n return ok<void, CodegenError>(undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<void, CodegenError>({\n code: \"INJECT_TEMPLATE_FAILED\",\n message,\n outPath: targetPath,\n });\n }\n};\n\nexport const getInjectTemplate = (): string => `${templateContents}\\n`;\n","import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nexport const writeModule = (outPath: string, contents: string) => {\n const targetPath = resolve(outPath);\n\n try {\n mkdirSync(dirname(targetPath), { recursive: true });\n writeFileSync(targetPath, contents);\n return ok<void, CodegenError>(undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<void, CodegenError>({\n code: \"EMIT_FAILED\",\n message,\n outPath: targetPath,\n });\n }\n};\n","import { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { type DocumentNode, parse, print } from \"graphql\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nexport const loadSchema = (schemaPath: string) => {\n const resolvedPath = resolve(schemaPath);\n\n if (!existsSync(resolvedPath)) {\n return err<DocumentNode, CodegenError>({\n code: \"SCHEMA_NOT_FOUND\",\n message: `Schema file not found at ${resolvedPath}`,\n schemaPath: resolvedPath,\n });\n }\n\n try {\n const schemaSource = readFileSync(resolvedPath, \"utf8\");\n const document = parse(schemaSource);\n return ok<DocumentNode, CodegenError>(document);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<DocumentNode, CodegenError>({\n code: \"SCHEMA_INVALID\",\n message: `SchemaValidationError: ${message}`,\n schemaPath: resolvedPath,\n });\n }\n};\n\nexport const hashSchema = (document: DocumentNode): string => createHash(\"sha256\").update(print(document)).digest(\"hex\");\n","import { dirname, extname } from \"node:path\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport { build, type Options } from \"tsdown\";\nimport type { CodegenError } from \"./types\";\n\nexport type BundleResult = {\n readonly cjsPath: string;\n};\n\nexport const bundleGraphqlSystem = async (sourcePath: string): Promise<Result<BundleResult, CodegenError>> => {\n try {\n const sourceDir = dirname(sourcePath);\n const sourceExt = extname(sourcePath);\n const baseName = sourcePath.slice(0, -sourceExt.length);\n\n await build({\n config: false,\n entry: sourcePath,\n format: [\"cjs\"],\n platform: \"node\",\n external: [\"@soda-gql/core\", \"@soda-gql/runtime\"],\n dts: false,\n outDir: sourceDir,\n fixedExtension: true,\n clean: false,\n minify: false,\n sourcemap: false,\n treeshake: false,\n } satisfies Options);\n\n const cjsPath = `${baseName}.cjs`;\n\n return ok({ cjsPath });\n } catch (error) {\n return err({\n code: \"EMIT_FAILED\",\n message: `Failed to bundle graphql-system: ${error instanceof Error ? error.message : String(error)}`,\n outPath: sourcePath,\n });\n }\n};\n","import { existsSync } from \"node:fs\";\nimport { basename, dirname, extname, relative, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\nimport { writeModule } from \"./file\";\nimport { generateMultiSchemaModule } from \"./generator\";\nimport { hashSchema, loadSchema } from \"./schema\";\nimport { bundleGraphqlSystem } from \"./tsdown-bundle\";\nimport type { MultiSchemaCodegenOptions, MultiSchemaCodegenResult, MultiSchemaCodegenSuccess } from \"./types\";\n\nconst extensionMap: Record<string, string> = {\n \".ts\": \".js\",\n \".tsx\": \".js\",\n \".mts\": \".mjs\",\n \".cts\": \".cjs\",\n \".js\": \".js\",\n \".mjs\": \".mjs\",\n \".cjs\": \".cjs\",\n};\n\nconst toImportSpecifier = (fromPath: string, targetPath: string): string => {\n const fromDir = dirname(fromPath);\n const normalized = relative(fromDir, targetPath).replace(/\\\\/g, \"/\");\n const sourceExt = extname(targetPath);\n const runtimeExt = extensionMap[sourceExt] ?? sourceExt;\n\n if (normalized.length === 0) {\n const base = runtimeExt !== sourceExt ? basename(targetPath, sourceExt) : basename(targetPath);\n return `./${base}${runtimeExt}`;\n }\n\n const withPrefix = normalized.startsWith(\".\") ? normalized : `./${normalized}`;\n if (!runtimeExt) {\n return withPrefix;\n }\n if (withPrefix.endsWith(runtimeExt)) {\n return withPrefix;\n }\n\n const currentExt = extname(withPrefix);\n const withoutExt = currentExt ? withPrefix.slice(0, -currentExt.length) : withPrefix;\n return `${withoutExt}${runtimeExt}`;\n};\n\nexport const runMultiSchemaCodegen = async (options: MultiSchemaCodegenOptions): Promise<MultiSchemaCodegenResult> => {\n const outPath = resolve(options.outPath);\n\n // Handle legacy injectFromPath for backward compatibility\n const runtimeAdapters = options.runtimeAdapters ?? (options.injectFromPath ? { default: options.injectFromPath } : {});\n const scalars = options.scalars ?? (options.injectFromPath ? { default: options.injectFromPath } : {});\n\n // Validate that all adapter and scalar files exist\n const adapterPaths = new Map<string, string>();\n const scalarPaths = new Map<string, string>();\n\n for (const [schemaName, adapterPath] of Object.entries(runtimeAdapters)) {\n const resolvedPath = resolve(adapterPath);\n if (!existsSync(resolvedPath)) {\n return err({\n code: \"INJECT_MODULE_NOT_FOUND\",\n message: `Runtime adapter module not found for schema '${schemaName}': ${resolvedPath}`,\n injectPath: resolvedPath,\n });\n }\n adapterPaths.set(schemaName, resolvedPath);\n }\n\n for (const [schemaName, scalarPath] of Object.entries(scalars)) {\n const resolvedPath = resolve(scalarPath);\n if (!existsSync(resolvedPath)) {\n return err({\n code: \"INJECT_MODULE_NOT_FOUND\",\n message: `Scalar module not found for schema '${schemaName}': ${resolvedPath}`,\n injectPath: resolvedPath,\n });\n }\n scalarPaths.set(schemaName, resolvedPath);\n }\n\n // Load all schemas\n const schemas = new Map<string, import(\"graphql\").DocumentNode>();\n const schemaHashes: Record<string, { schemaHash: string; objects: number; enums: number; inputs: number; unions: number }> = {};\n\n for (const [name, schemaPath] of Object.entries(options.schemas)) {\n const result = await loadSchema(schemaPath).match(\n (doc) => Promise.resolve(ok(doc)),\n (error) => Promise.resolve(err(error)),\n );\n\n if (result.isErr()) {\n return err(result.error);\n }\n\n schemas.set(name, result.value);\n }\n\n // Build injection config for each schema\n const injectionConfig = new Map<string, { adapterImportPath: string; scalarImportPath: string }>();\n\n for (const schemaName of schemas.keys()) {\n const adapterPath = adapterPaths.get(schemaName);\n const scalarPath = scalarPaths.get(schemaName);\n\n if (!adapterPath || !scalarPath) {\n return err({\n code: \"INJECT_MODULE_REQUIRED\",\n message: `Missing adapter or scalar configuration for schema '${schemaName}'`,\n });\n }\n\n injectionConfig.set(schemaName, {\n adapterImportPath: toImportSpecifier(outPath, adapterPath),\n scalarImportPath: toImportSpecifier(outPath, scalarPath),\n });\n }\n\n // Generate multi-schema module\n const { code } = generateMultiSchemaModule(schemas, {\n injection: injectionConfig,\n });\n\n // Calculate individual schema stats and hashes\n for (const [name, document] of schemas.entries()) {\n const schemaIndex = (await import(\"./generator\")).createSchemaIndex(document);\n const objects = Array.from(schemaIndex.objects.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const enums = Array.from(schemaIndex.enums.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const inputs = Array.from(schemaIndex.inputs.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const unions = Array.from(schemaIndex.unions.keys()).filter((n) => !n.startsWith(\"__\")).length;\n\n schemaHashes[name] = {\n schemaHash: hashSchema(document),\n objects,\n enums,\n inputs,\n unions,\n };\n }\n\n // Write the module\n const writeResult = await writeModule(outPath, code).match(\n () => Promise.resolve(ok(undefined)),\n (error) => Promise.resolve(err(error)),\n );\n\n if (writeResult.isErr()) {\n return err(writeResult.error);\n }\n\n // Bundle the generated module with tsdown\n const bundleOutcome = await bundleGraphqlSystem(outPath);\n const bundleResult = bundleOutcome.match(\n (result) => ok(result),\n (error) => err(error),\n );\n\n if (bundleResult.isErr()) {\n return err(bundleResult.error);\n }\n\n return ok({\n schemas: schemaHashes,\n outPath,\n cjsPath: bundleResult.value.cjsPath,\n } satisfies MultiSchemaCodegenSuccess);\n};\n"],"mappings":";;;;;;;;;AAMA,MAAM,mBAAmB;;;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nC,UAAU,QAAQ,QAAQ,IAAI,MAAM,CAAC,CACvC;AAED,KAAI,YAAY,OAAO,EAAE;AACvB,SAAO,IAAI,YAAY,MAAM;;CAI/B,MAAM,gBAAgB,MAAM,oBAAoB,QAAQ;CACxD,MAAM,eAAe,cAAc,OAChC,WAAW,GAAG,OAAO,GACrB,UAAU,IAAI,MAAM,CACtB;AAED,KAAI,aAAa,OAAO,EAAE;AACxB,SAAO,IAAI,aAAa,MAAM;;AAGhC,QAAO,GAAG;EACR,SAAS;EACT;EACA,SAAS,aAAa,MAAM;EAC7B,CAAqC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soda-gql/codegen",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@soda-gql/core": "0.0.
|
|
30
|
-
"@soda-gql/runtime": "0.0.
|
|
29
|
+
"@soda-gql/core": "0.0.3",
|
|
30
|
+
"@soda-gql/runtime": "0.0.3",
|
|
31
31
|
"graphql": "^16.8.1",
|
|
32
32
|
"neverthrow": "^8.1.1",
|
|
33
33
|
"tsdown": "^0.15.7"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generator-BgvqYNQA.js","names":["operationTypes: OperationTypeNames","modifier: TypeModifier | \"\"","rest: TypeModifier | \"\"","base: TypeModifier","imports: string[]","schemaBlocks: string[]","gqlEntries: string[]","schemaConfigs: Record<string, any>","name","injection: RuntimeTemplateInjection"],"sources":["../src/generator.ts"],"sourcesContent":["import type { TypeModifier } from \"@soda-gql/core\";\nimport {\n type ConstDirectiveNode,\n type ConstValueNode,\n type DocumentNode,\n type EnumValueDefinitionNode,\n type FieldDefinitionNode,\n type InputValueDefinitionNode,\n Kind,\n type NamedTypeNode,\n type SchemaDefinitionNode,\n type SchemaExtensionNode,\n type TypeNode,\n} from \"graphql\";\n\nconst builtinScalarTypes = new Map<string, { readonly input: string; readonly output: string }>([\n [\"ID\", { input: \"string\", output: \"string\" }],\n [\"String\", { input: \"string\", output: \"string\" }],\n [\"Int\", { input: \"number\", output: \"number\" }],\n [\"Float\", { input: \"number\", output: \"number\" }],\n [\"Boolean\", { input: \"boolean\", output: \"boolean\" }],\n]);\n\ntype OperationTypeNames = {\n query?: string;\n mutation?: string;\n subscription?: string;\n};\n\ntype ObjectRecord = {\n readonly name: string;\n readonly fields: Map<string, FieldDefinitionNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype InputRecord = {\n readonly name: string;\n readonly fields: Map<string, InputValueDefinitionNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype EnumRecord = {\n readonly name: string;\n readonly values: Map<string, EnumValueDefinitionNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype UnionRecord = {\n readonly name: string;\n readonly members: Map<string, NamedTypeNode>;\n directives: ConstDirectiveNode[];\n};\n\ntype ScalarRecord = {\n readonly name: string;\n directives: ConstDirectiveNode[];\n};\n\ntype SchemaIndex = {\n readonly objects: Map<string, ObjectRecord>;\n readonly inputs: Map<string, InputRecord>;\n readonly enums: Map<string, EnumRecord>;\n readonly unions: Map<string, UnionRecord>;\n readonly scalars: Map<string, ScalarRecord>;\n readonly operationTypes: OperationTypeNames;\n};\n\nconst ensureRecord = <T>(collection: Map<string, T>, key: string, factory: (name: string) => T): T => {\n const existing = collection.get(key);\n if (existing) {\n return existing;\n }\n\n const created = factory(key);\n collection.set(key, created);\n return created;\n};\n\nconst addObjectFields = (target: Map<string, FieldDefinitionNode>, fields: readonly FieldDefinitionNode[] | undefined): void => {\n if (!fields) {\n return;\n }\n\n for (const field of fields) {\n target.set(field.name.value, field);\n }\n};\n\nconst addInputFields = (\n target: Map<string, InputValueDefinitionNode>,\n fields: readonly InputValueDefinitionNode[] | undefined,\n): void => {\n if (!fields) {\n return;\n }\n\n for (const field of fields) {\n target.set(field.name.value, field);\n }\n};\n\nconst addEnumValues = (\n target: Map<string, EnumValueDefinitionNode>,\n values: readonly EnumValueDefinitionNode[] | undefined,\n): void => {\n if (!values) {\n return;\n }\n\n for (const value of values) {\n target.set(value.name.value, value);\n }\n};\n\nconst addUnionMembers = (target: Map<string, NamedTypeNode>, members: readonly NamedTypeNode[] | undefined): void => {\n if (!members) {\n return;\n }\n\n for (const member of members) {\n target.set(member.name.value, member);\n }\n};\n\nconst mergeDirectives = (\n existing: ConstDirectiveNode[] | undefined,\n incoming: readonly ConstDirectiveNode[] | undefined,\n precedence: \"definition\" | \"extension\",\n): ConstDirectiveNode[] => {\n const current = existing ?? [];\n const next = incoming ? Array.from(incoming) : [];\n return precedence === \"definition\" ? [...next, ...current] : [...current, ...next];\n};\n\nconst updateOperationTypes = (\n operationTypes: OperationTypeNames,\n definition: SchemaDefinitionNode | SchemaExtensionNode,\n): void => {\n for (const operation of definition.operationTypes ?? []) {\n const typeName = operation.type.name.value;\n switch (operation.operation) {\n case \"query\":\n operationTypes.query = typeName;\n break;\n case \"mutation\":\n operationTypes.mutation = typeName;\n break;\n case \"subscription\":\n operationTypes.subscription = typeName;\n break;\n default:\n break;\n }\n }\n};\n\nexport const createSchemaIndex = (document: DocumentNode): SchemaIndex => {\n const objects = new Map<string, ObjectRecord>();\n const inputs = new Map<string, InputRecord>();\n const enums = new Map<string, EnumRecord>();\n const unions = new Map<string, UnionRecord>();\n const scalars = new Map<string, ScalarRecord>();\n const operationTypes: OperationTypeNames = {};\n\n for (const definition of document.definitions) {\n switch (definition.kind) {\n case Kind.OBJECT_TYPE_DEFINITION:\n case Kind.OBJECT_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.OBJECT_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(objects, definition.name.value, (name) => ({\n name,\n fields: new Map<string, FieldDefinitionNode>(),\n directives: [],\n }));\n addObjectFields(record.fields, definition.fields);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.INPUT_OBJECT_TYPE_DEFINITION:\n case Kind.INPUT_OBJECT_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(inputs, definition.name.value, (name) => ({\n name,\n fields: new Map<string, InputValueDefinitionNode>(),\n directives: [],\n }));\n addInputFields(record.fields, definition.fields);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.ENUM_TYPE_DEFINITION:\n case Kind.ENUM_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.ENUM_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(enums, definition.name.value, (name) => ({\n name,\n values: new Map<string, EnumValueDefinitionNode>(),\n directives: [],\n }));\n addEnumValues(record.values, definition.values);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.UNION_TYPE_DEFINITION:\n case Kind.UNION_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.UNION_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(unions, definition.name.value, (name) => ({\n name,\n members: new Map<string, NamedTypeNode>(),\n directives: [],\n }));\n addUnionMembers(record.members, definition.types);\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.SCALAR_TYPE_DEFINITION:\n case Kind.SCALAR_TYPE_EXTENSION: {\n const precedence = definition.kind === Kind.SCALAR_TYPE_DEFINITION ? \"definition\" : \"extension\";\n const record = ensureRecord(scalars, definition.name.value, (name) => ({\n name,\n directives: [],\n }));\n record.directives = mergeDirectives(record.directives, definition.directives, precedence);\n break;\n }\n case Kind.SCHEMA_DEFINITION:\n case Kind.SCHEMA_EXTENSION:\n updateOperationTypes(operationTypes, definition);\n break;\n default:\n break;\n }\n }\n\n if (!operationTypes.query && objects.has(\"Query\")) {\n operationTypes.query = \"Query\";\n }\n if (!operationTypes.mutation && objects.has(\"Mutation\")) {\n operationTypes.mutation = \"Mutation\";\n }\n if (!operationTypes.subscription && objects.has(\"Subscription\")) {\n operationTypes.subscription = \"Subscription\";\n }\n\n return {\n objects,\n inputs,\n enums,\n unions,\n scalars,\n operationTypes,\n } satisfies SchemaIndex;\n};\n\ntype TypeLevel = {\n readonly kind: \"list\" | \"named\";\n readonly nonNull: boolean;\n};\n\nconst collectTypeLevels = (\n type: TypeNode,\n nonNull = false,\n levels: TypeLevel[] = [],\n): { readonly name: string; readonly levels: TypeLevel[] } => {\n if (type.kind === Kind.NON_NULL_TYPE) {\n return collectTypeLevels(type.type, true, levels);\n }\n\n if (type.kind === Kind.LIST_TYPE) {\n levels.push({ kind: \"list\", nonNull });\n return collectTypeLevels(type.type, false, levels);\n }\n\n levels.push({ kind: \"named\", nonNull });\n return { name: type.name.value, levels };\n};\n\nconst buildTypeModifier = (levels: TypeLevel[]): TypeModifier => {\n let modifier: TypeModifier | \"\" = \"\";\n\n for (const level of levels.slice().reverse()) {\n if (level.kind === \"named\") {\n modifier = level.nonNull ? \"!\" : \"\";\n continue;\n }\n\n const rest: TypeModifier | \"\" = modifier;\n const base: TypeModifier = rest.startsWith(\"!\") ? `![]${rest.slice(1)}` : `[]${rest}`;\n modifier = level.nonNull ? `${base}!` : base;\n }\n\n return modifier || \"?\";\n};\n\nconst parseTypeReference = (type: TypeNode): { readonly name: string; readonly modifier: string } => {\n const { name, levels } = collectTypeLevels(type);\n return { name, modifier: buildTypeModifier(levels) };\n};\n\nconst renderType = (name: string, modifier: string): string => JSON.stringify(`${name}:${modifier}`);\n\nconst isScalarName = (schema: SchemaIndex, name: string): boolean => builtinScalarTypes.has(name) || schema.scalars.has(name);\nconst isEnumName = (schema: SchemaIndex, name: string): boolean => schema.enums.has(name);\nconst _isInputName = (schema: SchemaIndex, name: string): boolean => schema.inputs.has(name);\nconst isUnionName = (schema: SchemaIndex, name: string): boolean => schema.unions.has(name);\nconst isObjectName = (schema: SchemaIndex, name: string): boolean => schema.objects.has(name);\n\nconst renderConstValue = (value: ConstValueNode): string => {\n switch (value.kind) {\n case Kind.NULL:\n return \"null\";\n case Kind.INT:\n case Kind.FLOAT:\n return value.value;\n case Kind.STRING:\n case Kind.ENUM:\n return JSON.stringify(value.value);\n case Kind.BOOLEAN:\n return value.value ? \"true\" : \"false\";\n case Kind.LIST:\n return `[${value.values.map((item) => renderConstValue(item)).join(\", \")}]`;\n case Kind.OBJECT: {\n if (value.fields.length === 0) {\n return \"{}\";\n }\n const entries = value.fields.map((field) => `${field.name.value}: ${renderConstValue(field.value)}`);\n return `{ ${entries.join(\", \")} }`;\n }\n }\n};\n\nconst renderConstArgumentMap = (\n args: readonly { readonly name: { readonly value: string }; readonly value: ConstValueNode }[] | undefined,\n): string => {\n const entries = (args ?? []).map((arg) => `${arg.name.value}: ${renderConstValue(arg.value)}`);\n return renderPropertyLines({ entries, indentSize: 8 });\n};\n\nconst renderDirectives = (directives: readonly ConstDirectiveNode[] | undefined): string => {\n const entries = (directives ?? []).map(\n (directive) => `${directive.name.value}: ${renderConstArgumentMap(directive.arguments)}`,\n );\n return renderPropertyLines({ entries, indentSize: 8 });\n};\n\nconst renderDefaultValue = (value: ConstValueNode | null | undefined): string =>\n value ? `() => (${renderConstValue(value)})` : \"null\";\n\nconst renderInputRef = (schema: SchemaIndex, definition: InputValueDefinitionNode): string => {\n const { name, modifier } = parseTypeReference(definition.type);\n const tuple = renderType(name, modifier);\n const defaultValue = renderDefaultValue(definition.defaultValue ?? null);\n const directives = renderDirectives(definition.directives);\n\n if (isScalarName(schema, name)) {\n return `unsafeInputType.scalar(${tuple}, { default: ${defaultValue}, directives: ${directives} })`;\n }\n\n if (isEnumName(schema, name)) {\n return `unsafeInputType.enum(${tuple}, { default: ${defaultValue}, directives: ${directives} })`;\n }\n\n return `unsafeInputType.input(${tuple}, { default: ${defaultValue}, directives: ${directives} })`;\n};\n\nconst renderArgumentMap = (schema: SchemaIndex, args: readonly InputValueDefinitionNode[] | undefined): string => {\n const entries = [...(args ?? [])]\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((arg) => `${arg.name.value}: ${renderInputRef(schema, arg)}`);\n\n return renderPropertyLines({ entries, indentSize: 8 });\n};\n\nconst renderOutputRef = (\n schema: SchemaIndex,\n type: TypeNode,\n args: readonly InputValueDefinitionNode[] | undefined,\n directives: readonly ConstDirectiveNode[] | undefined,\n): string => {\n const { name, modifier } = parseTypeReference(type);\n const modifiedType = renderType(name, modifier);\n const argumentMap = renderArgumentMap(schema, args);\n const directiveMap = renderDirectives(directives);\n\n if (isScalarName(schema, name)) {\n return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap}, directives: ${directiveMap} })`;\n }\n\n if (isEnumName(schema, name)) {\n return `unsafeOutputType.enum(${modifiedType}, { arguments: ${argumentMap}, directives: ${directiveMap} })`;\n }\n\n if (isUnionName(schema, name)) {\n return `unsafeOutputType.union(${modifiedType}, { arguments: ${argumentMap}, directives: ${directiveMap} })`;\n }\n\n if (isObjectName(schema, name)) {\n return `unsafeOutputType.object(${modifiedType}, { arguments: ${argumentMap}, directives: ${directiveMap} })`;\n }\n\n return `unsafeOutputType.scalar(${modifiedType}, { arguments: ${argumentMap}, directives: ${directiveMap} })`;\n};\n\nconst renderPropertyLines = ({ entries, indentSize }: { entries: string[]; indentSize: number }) => {\n if (entries.length === 0) {\n return \"{}\";\n }\n\n const indent = \" \".repeat(indentSize);\n const lastIndent = \" \".repeat(indentSize - 2);\n return [\"{\", `${indent}${entries.join(`,\\n${indent}`)},`, `${lastIndent}}`].join(`\\n`);\n};\n\nconst renderObjectFields = (schema: SchemaIndex, fields: Map<string, FieldDefinitionNode>): string => {\n const entries = Array.from(fields.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((field) => `${field.name.value}: ${renderOutputRef(schema, field.type, field.arguments, field.directives)}`);\n\n return renderPropertyLines({ entries, indentSize: 6 });\n};\n\nconst renderInputFields = (schema: SchemaIndex, fields: Map<string, InputValueDefinitionNode>): string => {\n const entries = Array.from(fields.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((field) => `${field.name.value}: ${renderInputRef(schema, field)}`);\n\n return renderPropertyLines({ entries, indentSize: 6 });\n};\n\nconst renderScalarDefinition = (record: ScalarRecord): string => {\n const typeInfo = builtinScalarTypes.get(record.name) ?? { input: \"string\", output: \"string\" };\n const scalarType = `type<{ input: ${typeInfo.input}; output: ${typeInfo.output} }>()`;\n return `${record.name}: define(\"${record.name}\").scalar(${scalarType}, ${renderDirectives(record.directives)})`;\n};\n\nconst renderObjectDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.objects.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const fields = renderObjectFields(schema, record.fields);\n return `${record.name}: define(\"${record.name}\").object(${fields}, ${renderDirectives(record.directives)})`;\n};\n\nconst renderInputDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.inputs.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const fields = renderInputFields(schema, record.fields);\n return `${record.name}: define(\"${record.name}\").input(${fields}, ${renderDirectives(record.directives)})`;\n};\n\nconst renderEnumDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.enums.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const values = Array.from(record.values.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((value) => `${value.name.value}: true`)\n .join(\", \");\n const body = values.length === 0 ? \"{}\" : `{ ${values} }`;\n\n return `${record.name}: define(\"${record.name}\").enum(${body}, ${renderDirectives(record.directives)})`;\n};\n\nconst renderUnionDefinition = (schema: SchemaIndex, typeName: string): string => {\n const record = schema.unions.get(typeName);\n if (!record) {\n return \"\";\n }\n\n const members = Array.from(record.members.values())\n .sort((left, right) => left.name.value.localeCompare(right.name.value))\n .map((member) => `${member.name.value}: true`)\n .join(\", \");\n const body = members.length === 0 ? \"{}\" : `{ ${members} }`;\n\n return `${record.name}: define(\"${record.name}\").union(${body}, ${renderDirectives(record.directives)})`;\n};\n\nconst collectObjectTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.objects.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectInputTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.inputs.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectEnumTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.enums.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectUnionTypeNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.unions.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nconst collectScalarNames = (schema: SchemaIndex): string[] =>\n Array.from(schema.scalars.keys())\n .filter((name) => !name.startsWith(\"__\"))\n .sort((left, right) => left.localeCompare(right));\n\nexport type GeneratedModule = {\n readonly code: string;\n readonly stats: {\n readonly objects: number;\n readonly enums: number;\n readonly inputs: number;\n readonly unions: number;\n };\n};\n\ntype PerSchemaInjection = {\n readonly adapterImportPath: string;\n readonly scalarImportPath: string;\n};\n\ntype RuntimeTemplateInjection =\n | { readonly mode: \"inline\" }\n | {\n readonly mode: \"inject\";\n readonly perSchema: Map<string, PerSchemaInjection>;\n };\n\nexport type RuntimeGenerationOptions = {\n readonly injection?: Map<string, PerSchemaInjection>;\n};\n\ntype MultiRuntimeTemplateOptions = {\n readonly schemas: Record<\n string,\n {\n readonly queryType: string;\n readonly mutationType: string;\n readonly subscriptionType: string;\n readonly scalarBlock: string;\n readonly enumBlock: string;\n readonly inputBlock: string;\n readonly objectBlock: string;\n readonly unionBlock: string;\n }\n >;\n readonly injection: RuntimeTemplateInjection;\n};\n\nconst multiRuntimeTemplate = ($$: MultiRuntimeTemplateOptions) => {\n // Build imports based on injection mode\n const imports: string[] = [];\n const adapterAliases = new Map<string, string>();\n const scalarAliases = new Map<string, string>();\n\n if ($$.injection.mode === \"inject\") {\n // Generate per-schema imports\n for (const [schemaName, injection] of $$.injection.perSchema) {\n const adapterAlias = `adapter_${schemaName}`;\n const scalarAlias = `scalar_${schemaName}`;\n adapterAliases.set(schemaName, adapterAlias);\n scalarAliases.set(schemaName, scalarAlias);\n\n imports.push(`import { adapter as ${adapterAlias} } from \"${injection.adapterImportPath}\";`);\n imports.push(`import { scalar as ${scalarAlias} } from \"${injection.scalarImportPath}\";`);\n }\n }\n\n const extraImports = imports.length > 0 ? `${imports.join(\"\\n\")}\\n` : \"\";\n\n // Generate per-schema definitions\n const schemaBlocks: string[] = [];\n const gqlEntries: string[] = [];\n\n for (const [name, config] of Object.entries($$.schemas)) {\n const schemaVar = `${name}Schema`;\n const adapterVar = $$.injection.mode === \"inject\" ? adapterAliases.get(name) : `adapter_${name}`;\n const scalarBlock = $$.injection.mode === \"inject\" ? scalarAliases.get(name) : config.scalarBlock;\n\n // Generate adapter if inline mode\n const adapterDefinition =\n $$.injection.mode === \"inject\"\n ? \"\"\n : `const ${adapterVar} = createRuntimeAdapter(({ type }) => ({\\n nonGraphqlErrorType: type<{ type: \"non-graphql-error\"; cause: unknown }>(),\\n}));\\n`;\n\n schemaBlocks.push(`${adapterDefinition}\nconst ${schemaVar} = {\n operations: defineOperationRoots({\n query: \"${config.queryType}\",\n mutation: \"${config.mutationType}\",\n subscription: \"${config.subscriptionType}\",\n }),\n scalar: ${scalarBlock},\n enum: ${config.enumBlock},\n input: ${config.inputBlock},\n object: ${config.objectBlock},\n union: ${config.unionBlock},\n} satisfies AnyGraphqlSchema;\n\nexport type Schema_${name} = typeof ${schemaVar} & { _?: never };\nexport type Adapter_${name} = typeof ${adapterVar} & { _?: never };`);\n\n gqlEntries.push(` ${name}: createGqlElementComposer<Schema_${name}, Adapter_${name}>(${schemaVar})`);\n }\n\n // Include createRuntimeAdapter import only in inline mode\n const runtimeImport = $$.injection.mode === \"inline\" ? '\\nimport { createRuntimeAdapter } from \"@soda-gql/runtime\";' : \"\";\n\n return `\\\nimport {\n type AnyGraphqlSchema,\n createGqlElementComposer,\n define,\n defineOperationRoots,\n unsafeInputType,\n unsafeOutputType,\n} from \"@soda-gql/core\";${runtimeImport}\n${extraImports}\n${schemaBlocks.join(\"\\n\")}\n\nexport const gql = {\n${gqlEntries.join(\",\\n\")}\n};\n`;\n};\n\nexport const generateMultiSchemaModule = (\n schemas: Map<string, DocumentNode>,\n options?: RuntimeGenerationOptions,\n): GeneratedModule => {\n // biome-ignore lint/suspicious/noExplicitAny: complex schema config type\n const schemaConfigs: Record<string, any> = {};\n const allStats = {\n objects: 0,\n enums: 0,\n inputs: 0,\n unions: 0,\n };\n\n for (const [name, document] of schemas.entries()) {\n const schema = createSchemaIndex(document);\n\n const builtinScalarDefinitions = Array.from(builtinScalarTypes.keys()).map((name) =>\n renderScalarDefinition(schema.scalars.get(name) ?? { name, directives: [] }),\n );\n\n const customScalarDefinitions = collectScalarNames(schema)\n .filter((name) => !builtinScalarTypes.has(name))\n .map((name) => {\n const record = schema.scalars.get(name);\n return record ? renderScalarDefinition(record) : \"\";\n })\n .filter((definition) => definition.length > 0);\n\n const allScalarDefinitions = builtinScalarDefinitions.concat(customScalarDefinitions);\n\n const objectTypeNames = collectObjectTypeNames(schema);\n const enumTypeNames = collectEnumTypeNames(schema);\n const inputTypeNames = collectInputTypeNames(schema);\n const unionTypeNames = collectUnionTypeNames(schema);\n\n const scalarBlock = renderPropertyLines({ entries: allScalarDefinitions, indentSize: 4 });\n const enumDefinitions = enumTypeNames\n .map((name) => renderEnumDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const enumBlock = renderPropertyLines({ entries: enumDefinitions, indentSize: 4 });\n const inputDefinitions = inputTypeNames\n .map((name) => renderInputDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const inputBlock = renderPropertyLines({ entries: inputDefinitions, indentSize: 4 });\n const objectDefinitions = objectTypeNames\n .map((name) => renderObjectDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const objectBlock = renderPropertyLines({ entries: objectDefinitions, indentSize: 4 });\n const unionDefinitions = unionTypeNames\n .map((name) => renderUnionDefinition(schema, name))\n .filter((definition) => definition.length > 0);\n const unionBlock = renderPropertyLines({ entries: unionDefinitions, indentSize: 4 });\n\n const queryType = schema.operationTypes.query ?? \"Query\";\n const mutationType = schema.operationTypes.mutation ?? \"Mutation\";\n const subscriptionType = schema.operationTypes.subscription ?? \"Subscription\";\n\n schemaConfigs[name] = {\n queryType,\n mutationType,\n subscriptionType,\n scalarBlock,\n enumBlock,\n inputBlock,\n objectBlock,\n unionBlock,\n };\n\n // Accumulate stats\n allStats.objects += objectDefinitions.length;\n allStats.enums += enumDefinitions.length;\n allStats.inputs += inputDefinitions.length;\n allStats.unions += unionDefinitions.length;\n }\n\n const injection: RuntimeTemplateInjection = options?.injection\n ? { mode: \"inject\", perSchema: options.injection }\n : { mode: \"inline\" };\n\n const code = multiRuntimeTemplate({\n schemas: schemaConfigs,\n injection,\n });\n\n return {\n code,\n stats: allStats,\n };\n};\n"],"mappings":";;;AAeA,MAAM,qBAAqB,IAAI,IAAiE;CAC9F,CAAC,MAAM;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CAC7C,CAAC,UAAU;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CACjD,CAAC,OAAO;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CAC9C,CAAC,SAAS;EAAE,OAAO;EAAU,QAAQ;EAAU,CAAC;CAChD,CAAC,WAAW;EAAE,OAAO;EAAW,QAAQ;EAAW,CAAC;CACrD,CAAC;AA8CF,MAAM,gBAAmB,YAA4B,KAAa,YAAoC;CACpG,MAAM,WAAW,WAAW,IAAI,IAAI;AACpC,KAAI,UAAU;AACZ,SAAO;;CAGT,MAAM,UAAU,QAAQ,IAAI;AAC5B,YAAW,IAAI,KAAK,QAAQ;AAC5B,QAAO;;AAGT,MAAM,mBAAmB,QAA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,OAAO;EACR"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/inject-template.ts","../src/runner.ts","../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;KAEY,aAAA;KAEA,cAAA;;;EAFA,SAAA,MAAA,EAKO,aALM;EAEb,SAAA,cAAc,EAAA,MAGP;AAInB,CAAA;AAAqC,KAAzB,yBAAA,GAAyB;WACjB,OAAA,EAAA,MAAA,CAAA,MAAA,EAAA,MAAA,CAAA;WAED,OAAA,EAAA,MAAA;WACU,MAAA,EADV,aACU;WACR,eAAA,CAAA,EADQ,MACR,CAAA,MAAA,EAAA,MAAA,CAAA;EAAM,SAAA,OAAA,CAAA,EAAN,MAAM,CAAA,MAAA,EAAA,MAAA,CAAA;EAIf,SAAA,cAAiB,CAAA,EAAA,MAAA;CAAA;AAGL,KAHZ,iBAAA,GAGY;WAKD,IAAA,EAAA,UAAA;EAAa,SAAA,OAAA,EALZ,cAKY;AAGpC,CAAA,GAAY;EAoCA,SAAA,IAAA,EAAA,oBAAc;EASd,SAAA,OAAA,EAAA,MAAA;EAeA,SAAA,MAAA,EA/DW,aA+DE;CAAA;AAAU,KA5DvB,YAAA,GA4DuB;WAAgB,IAAA,EAAA,kBAAA;WAAvB,OAAA,EAAA,MAAA;EAAM,SAAA,UAAA,EAAA,MAAA;AAClC,CAAA,GAAY;EAAwB,SAAA,IAAA,EAAA,gBAAA;WAAU,OAAA,EAAA,MAAA;WAA2B,UAAA,EAAA,MAAA;;EAA5B,SAAA,IAAA,EAAA,aAAA;;;;ECjDhC,SAAA,IAAA,EAAA,wBAuBZ;EAAA,SAAA,OAAA,EAAA,MAAA;;WAvBkD,IAAA,EAAA,yBAAA;WAAA,OAAA,EAAA,MAAA;WAAA,UAAA,EAAA,MAAA;CAAA,GAAA;EAyBtC,SAAA,IAAA,EAAA,wBAAyD;;;;ECzBzD,SAAA,IAAA,EAAA,wBAwHZ;EAAA,SAAA,OAAA,EAAA,MAAA;WAxHoD,OAAA,EAAA,MAAA;;AAA4B,KFwBrE,cAAA,GExBqE;EAAO,SAAA,UAAA,EAAA,MAAA;;;;ECnC3E,SAAA,MAuBZ,EAAA,MAAA;EAAA,SAAA,MAAA,EAAA,MAAA;;AAvB4C,KHoEjC,yBAAA,GGpEiC;WAAA,OAAA,EHqEzB,MGrEyB,CAAA,MAAA,EAAA;IAAA,SAAA,UAAA,EAAA,MAAA;IAAA,SAAA,OAAA,EAAA,MAAA;IAAA,SAAA,KAAA,EAAA,MAAA;IAAA,SAAA,MAAA,EAAA,MAAA;IAyBhC,SAA2G,MAAA,EAAA,MAAnF;;;;;KH0DzB,aAAA,GAAgB,OAAO,gBAAgB;KACvC,wBAAA,GAA2B,OAAO,2BAA2B;;;cCjD5D,0CAAsC,WAAA,CAAA,UAAA,gBAAA,WAAA,CAAA,SAAA;cAyBtC;;;cCzBA,iCAAwC,8BAA4B,QAAQ;;;cCnC5E,oCAAgC,WAAA,CAAA,IAAA,cAAA,gBAAA,WAAA,CAAA,GAAA,cAAA;cAyBhC,uBAAwB"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["extensionMap: Record<string, string>","schemaHashes: Record<string, { schemaHash: string; objects: number; enums: number; inputs: number; unions: number }>"],"sources":["../src/inject-template.ts","../src/file.ts","../src/schema.ts","../src/tsdown-bundle.ts","../src/runner.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nconst templateContents = `\\\nimport { defineScalar } from \"@soda-gql/core\";\nimport { createRuntimeAdapter } from \"@soda-gql/runtime\";\n\nexport const scalar = {\n ...defineScalar(\"ID\", ({ type }) => ({\n input: type<string>(),\n output: type<string>(),\n directives: {},\n })),\n ...defineScalar(\"String\", ({ type }) => ({\n input: type<string>(),\n output: type<string>(),\n directives: {},\n })),\n ...defineScalar(\"Int\", ({ type }) => ({\n input: type<number>(),\n output: type<number>(),\n directives: {},\n })),\n ...defineScalar(\"Float\", ({ type }) => ({\n input: type<number>(),\n output: type<number>(),\n directives: {},\n })),\n ...defineScalar(\"Boolean\", ({ type }) => ({\n input: type<boolean>(),\n output: type<boolean>(),\n directives: {},\n })),\n} as const;\n\nexport const adapter = createRuntimeAdapter(({ type }) => ({\n nonGraphqlErrorType: type<{ type: \"non-graphql-error\"; cause: unknown }>(),\n}));\n`;\n\nexport const writeInjectTemplate = (outPath: string) => {\n const targetPath = resolve(outPath);\n\n try {\n if (existsSync(targetPath)) {\n return err<void, CodegenError>({\n code: \"INJECT_TEMPLATE_EXISTS\",\n message: `Inject module already exists: ${targetPath}`,\n outPath: targetPath,\n });\n }\n\n mkdirSync(dirname(targetPath), { recursive: true });\n writeFileSync(targetPath, `${templateContents}\\n`);\n return ok<void, CodegenError>(undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<void, CodegenError>({\n code: \"INJECT_TEMPLATE_FAILED\",\n message,\n outPath: targetPath,\n });\n }\n};\n\nexport const getInjectTemplate = (): string => `${templateContents}\\n`;\n","import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nexport const writeModule = (outPath: string, contents: string) => {\n const targetPath = resolve(outPath);\n\n try {\n mkdirSync(dirname(targetPath), { recursive: true });\n writeFileSync(targetPath, contents);\n return ok<void, CodegenError>(undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<void, CodegenError>({\n code: \"EMIT_FAILED\",\n message,\n outPath: targetPath,\n });\n }\n};\n","import { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { type DocumentNode, parse, print } from \"graphql\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nexport const loadSchema = (schemaPath: string) => {\n const resolvedPath = resolve(schemaPath);\n\n if (!existsSync(resolvedPath)) {\n return err<DocumentNode, CodegenError>({\n code: \"SCHEMA_NOT_FOUND\",\n message: `Schema file not found at ${resolvedPath}`,\n schemaPath: resolvedPath,\n });\n }\n\n try {\n const schemaSource = readFileSync(resolvedPath, \"utf8\");\n const document = parse(schemaSource);\n return ok<DocumentNode, CodegenError>(document);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<DocumentNode, CodegenError>({\n code: \"SCHEMA_INVALID\",\n message: `SchemaValidationError: ${message}`,\n schemaPath: resolvedPath,\n });\n }\n};\n\nexport const hashSchema = (document: DocumentNode): string => createHash(\"sha256\").update(print(document)).digest(\"hex\");\n","import { dirname, extname } from \"node:path\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport { build, type Options } from \"tsdown\";\nimport type { CodegenError } from \"./types\";\n\nexport type BundleResult = {\n readonly cjsPath: string;\n};\n\nexport const bundleGraphqlSystem = async (sourcePath: string): Promise<Result<BundleResult, CodegenError>> => {\n try {\n const sourceDir = dirname(sourcePath);\n const sourceExt = extname(sourcePath);\n const baseName = sourcePath.slice(0, -sourceExt.length);\n\n await build({\n config: false,\n entry: sourcePath,\n format: [\"cjs\"],\n platform: \"node\",\n external: [\"@soda-gql/core\", \"@soda-gql/runtime\"],\n dts: false,\n outDir: sourceDir,\n fixedExtension: true,\n clean: false,\n minify: false,\n sourcemap: false,\n treeshake: false,\n } satisfies Options);\n\n const cjsPath = `${baseName}.cjs`;\n\n return ok({ cjsPath });\n } catch (error) {\n return err({\n code: \"EMIT_FAILED\",\n message: `Failed to bundle graphql-system: ${error instanceof Error ? error.message : String(error)}`,\n outPath: sourcePath,\n });\n }\n};\n","import { existsSync } from \"node:fs\";\nimport { basename, dirname, extname, relative, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\nimport { writeModule } from \"./file\";\nimport { generateMultiSchemaModule } from \"./generator\";\nimport { hashSchema, loadSchema } from \"./schema\";\nimport { bundleGraphqlSystem } from \"./tsdown-bundle\";\nimport type { MultiSchemaCodegenOptions, MultiSchemaCodegenResult, MultiSchemaCodegenSuccess } from \"./types\";\n\nconst extensionMap: Record<string, string> = {\n \".ts\": \".js\",\n \".tsx\": \".js\",\n \".mts\": \".mjs\",\n \".cts\": \".cjs\",\n \".js\": \".js\",\n \".mjs\": \".mjs\",\n \".cjs\": \".cjs\",\n};\n\nconst toImportSpecifier = (fromPath: string, targetPath: string): string => {\n const fromDir = dirname(fromPath);\n const normalized = relative(fromDir, targetPath).replace(/\\\\/g, \"/\");\n const sourceExt = extname(targetPath);\n const runtimeExt = extensionMap[sourceExt] ?? sourceExt;\n\n if (normalized.length === 0) {\n const base = runtimeExt !== sourceExt ? basename(targetPath, sourceExt) : basename(targetPath);\n return `./${base}${runtimeExt}`;\n }\n\n const withPrefix = normalized.startsWith(\".\") ? normalized : `./${normalized}`;\n if (!runtimeExt) {\n return withPrefix;\n }\n if (withPrefix.endsWith(runtimeExt)) {\n return withPrefix;\n }\n\n const currentExt = extname(withPrefix);\n const withoutExt = currentExt ? withPrefix.slice(0, -currentExt.length) : withPrefix;\n return `${withoutExt}${runtimeExt}`;\n};\n\nexport const runMultiSchemaCodegen = async (options: MultiSchemaCodegenOptions): Promise<MultiSchemaCodegenResult> => {\n const outPath = resolve(options.outPath);\n\n // Handle legacy injectFromPath for backward compatibility\n const runtimeAdapters = options.runtimeAdapters ?? (options.injectFromPath ? { default: options.injectFromPath } : {});\n const scalars = options.scalars ?? (options.injectFromPath ? { default: options.injectFromPath } : {});\n\n // Validate that all adapter and scalar files exist\n const adapterPaths = new Map<string, string>();\n const scalarPaths = new Map<string, string>();\n\n for (const [schemaName, adapterPath] of Object.entries(runtimeAdapters)) {\n const resolvedPath = resolve(adapterPath);\n if (!existsSync(resolvedPath)) {\n return err({\n code: \"INJECT_MODULE_NOT_FOUND\",\n message: `Runtime adapter module not found for schema '${schemaName}': ${resolvedPath}`,\n injectPath: resolvedPath,\n });\n }\n adapterPaths.set(schemaName, resolvedPath);\n }\n\n for (const [schemaName, scalarPath] of Object.entries(scalars)) {\n const resolvedPath = resolve(scalarPath);\n if (!existsSync(resolvedPath)) {\n return err({\n code: \"INJECT_MODULE_NOT_FOUND\",\n message: `Scalar module not found for schema '${schemaName}': ${resolvedPath}`,\n injectPath: resolvedPath,\n });\n }\n scalarPaths.set(schemaName, resolvedPath);\n }\n\n // Load all schemas\n const schemas = new Map<string, import(\"graphql\").DocumentNode>();\n const schemaHashes: Record<string, { schemaHash: string; objects: number; enums: number; inputs: number; unions: number }> = {};\n\n for (const [name, schemaPath] of Object.entries(options.schemas)) {\n const result = await loadSchema(schemaPath).match(\n (doc) => Promise.resolve(ok(doc)),\n (error) => Promise.resolve(err(error)),\n );\n\n if (result.isErr()) {\n return err(result.error);\n }\n\n schemas.set(name, result.value);\n }\n\n // Build injection config for each schema\n const injectionConfig = new Map<string, { adapterImportPath: string; scalarImportPath: string }>();\n\n for (const schemaName of schemas.keys()) {\n const adapterPath = adapterPaths.get(schemaName);\n const scalarPath = scalarPaths.get(schemaName);\n\n if (!adapterPath || !scalarPath) {\n return err({\n code: \"INJECT_MODULE_REQUIRED\",\n message: `Missing adapter or scalar configuration for schema '${schemaName}'`,\n });\n }\n\n injectionConfig.set(schemaName, {\n adapterImportPath: toImportSpecifier(outPath, adapterPath),\n scalarImportPath: toImportSpecifier(outPath, scalarPath),\n });\n }\n\n // Generate multi-schema module\n const { code } = generateMultiSchemaModule(schemas, {\n injection: injectionConfig,\n });\n\n // Calculate individual schema stats and hashes\n for (const [name, document] of schemas.entries()) {\n const schemaIndex = (await import(\"./generator\")).createSchemaIndex(document);\n const objects = Array.from(schemaIndex.objects.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const enums = Array.from(schemaIndex.enums.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const inputs = Array.from(schemaIndex.inputs.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const unions = Array.from(schemaIndex.unions.keys()).filter((n) => !n.startsWith(\"__\")).length;\n\n schemaHashes[name] = {\n schemaHash: hashSchema(document),\n objects,\n enums,\n inputs,\n unions,\n };\n }\n\n // Write the module\n const writeResult = await writeModule(outPath, code).match(\n () => Promise.resolve(ok(undefined)),\n (error) => Promise.resolve(err(error)),\n );\n\n if (writeResult.isErr()) {\n return err(writeResult.error);\n }\n\n // Bundle the generated module with tsdown\n const bundleOutcome = await bundleGraphqlSystem(outPath);\n const bundleResult = bundleOutcome.match(\n (result) => ok(result),\n (error) => err(error),\n );\n\n if (bundleResult.isErr()) {\n return err(bundleResult.error);\n }\n\n return ok({\n schemas: schemaHashes,\n outPath,\n cjsPath: bundleResult.value.cjsPath,\n } satisfies MultiSchemaCodegenSuccess);\n};\n"],"mappings":";;;;;;;;;AAMA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCzB,MAAa,uBAAuB,YAAoB;CACtD,MAAM,aAAa,QAAQ,QAAQ;AAEnC,KAAI;AACF,MAAI,WAAW,WAAW,EAAE;AAC1B,UAAO,IAAwB;IAC7B,MAAM;IACN,SAAS,iCAAiC;IAC1C,SAAS;IACV,CAAC;;AAGJ,YAAU,QAAQ,WAAW,EAAE,EAAE,WAAW,MAAM,CAAC;AACnD,gBAAc,YAAY,GAAG,iBAAiB,IAAI;AAClD,SAAO,GAAuB,UAAU;UACjC,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AACtE,SAAO,IAAwB;GAC7B,MAAM;GACN;GACA,SAAS;GACV,CAAC;;;AAIN,MAAa,0BAAkC,GAAG,iBAAiB;;;;AC9DnE,MAAa,eAAe,SAAiB,aAAqB;CAChE,MAAM,aAAa,QAAQ,QAAQ;AAEnC,KAAI;AACF,YAAU,QAAQ,WAAW,EAAE,EAAE,WAAW,MAAM,CAAC;AACnD,gBAAc,YAAY,SAAS;AACnC,SAA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