@soda-gql/codegen 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/dist/{generator-D3aMXV0i.mjs → generator-BEIrzINv.mjs} +45 -50
- package/dist/generator-BEIrzINv.mjs.map +1 -0
- package/dist/{generator-BFFlsKNR.cjs → generator-CMKkXhGP.cjs} +46 -50
- package/dist/generator-CMKkXhGP.cjs.map +1 -0
- package/dist/{generator-BSnmtzFQ.cjs → generator-Djrw_0F1.cjs} +1 -1
- package/dist/generator-slr91UMQ.mjs +3 -0
- package/dist/index.cjs +64 -131
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +11 -23
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +11 -23
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +62 -130
- package/dist/index.mjs.map +1 -1
- package/package.json +26 -6
- package/dist/generator-D3aMXV0i.mjs.map +0 -1
- package/dist/generator-k_t6Ewc7.mjs +0 -3
package/dist/index.mjs
CHANGED
|
@@ -1,47 +1,22 @@
|
|
|
1
|
-
import { n as generateMultiSchemaModule } from "./generator-
|
|
1
|
+
import { n as generateMultiSchemaModule } from "./generator-BEIrzINv.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";
|
|
5
|
+
import { build } from "esbuild";
|
|
5
6
|
import { parse, print } from "graphql";
|
|
6
7
|
import { createHash } from "node:crypto";
|
|
7
|
-
import { build } from "tsdown";
|
|
8
8
|
|
|
9
9
|
//#region packages/codegen/src/inject-template.ts
|
|
10
10
|
const templateContents = `\
|
|
11
11
|
import { defineScalar } from "@soda-gql/core";
|
|
12
|
-
import { createRuntimeAdapter } from "@soda-gql/runtime";
|
|
13
12
|
|
|
14
13
|
export const scalar = {
|
|
15
|
-
...defineScalar
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
...defineScalar("String", ({ type }) => ({
|
|
21
|
-
input: type<string>(),
|
|
22
|
-
output: type<string>(),
|
|
23
|
-
directives: {},
|
|
24
|
-
})),
|
|
25
|
-
...defineScalar("Int", ({ type }) => ({
|
|
26
|
-
input: type<number>(),
|
|
27
|
-
output: type<number>(),
|
|
28
|
-
directives: {},
|
|
29
|
-
})),
|
|
30
|
-
...defineScalar("Float", ({ type }) => ({
|
|
31
|
-
input: type<number>(),
|
|
32
|
-
output: type<number>(),
|
|
33
|
-
directives: {},
|
|
34
|
-
})),
|
|
35
|
-
...defineScalar("Boolean", ({ type }) => ({
|
|
36
|
-
input: type<boolean>(),
|
|
37
|
-
output: type<boolean>(),
|
|
38
|
-
directives: {},
|
|
39
|
-
})),
|
|
14
|
+
...defineScalar<"ID", string, string>("ID"),
|
|
15
|
+
...defineScalar<"String", string, string>("String"),
|
|
16
|
+
...defineScalar<"Int", number, number>("Int"),
|
|
17
|
+
...defineScalar<"Float", number, number>("Float"),
|
|
18
|
+
...defineScalar<"Boolean", boolean, boolean>("Boolean"),
|
|
40
19
|
} as const;
|
|
41
|
-
|
|
42
|
-
export const adapter = createRuntimeAdapter(({ type }) => ({
|
|
43
|
-
nonGraphqlErrorType: type<{ type: "non-graphql-error"; cause: unknown }>(),
|
|
44
|
-
}));
|
|
45
20
|
`;
|
|
46
21
|
const writeInjectTemplate = (outPath) => {
|
|
47
22
|
const targetPath = resolve(outPath);
|
|
@@ -67,6 +42,37 @@ const writeInjectTemplate = (outPath) => {
|
|
|
67
42
|
};
|
|
68
43
|
const getInjectTemplate = () => `${templateContents}\n`;
|
|
69
44
|
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region packages/codegen/src/bundler/esbuild.ts
|
|
47
|
+
const esbuildBundler = {
|
|
48
|
+
name: "esbuild",
|
|
49
|
+
bundle: async ({ sourcePath, external }) => {
|
|
50
|
+
try {
|
|
51
|
+
const sourceExt = extname(sourcePath);
|
|
52
|
+
const baseName = sourcePath.slice(0, -sourceExt.length);
|
|
53
|
+
const cjsPath = `${baseName}.cjs`;
|
|
54
|
+
await build({
|
|
55
|
+
entryPoints: [sourcePath],
|
|
56
|
+
outfile: cjsPath,
|
|
57
|
+
format: "cjs",
|
|
58
|
+
platform: "node",
|
|
59
|
+
bundle: true,
|
|
60
|
+
external: [...external],
|
|
61
|
+
sourcemap: false,
|
|
62
|
+
minify: false,
|
|
63
|
+
treeShaking: false
|
|
64
|
+
});
|
|
65
|
+
return ok({ cjsPath });
|
|
66
|
+
} catch (error) {
|
|
67
|
+
return err({
|
|
68
|
+
code: "EMIT_FAILED",
|
|
69
|
+
message: `[esbuild] Failed to bundle: ${error instanceof Error ? error.message : String(error)}`,
|
|
70
|
+
outPath: sourcePath
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
70
76
|
//#endregion
|
|
71
77
|
//#region packages/codegen/src/file.ts
|
|
72
78
|
const writeModule = (outPath, contents) => {
|
|
@@ -111,38 +117,6 @@ const loadSchema = (schemaPath) => {
|
|
|
111
117
|
};
|
|
112
118
|
const hashSchema = (document) => createHash("sha256").update(print(document)).digest("hex");
|
|
113
119
|
|
|
114
|
-
//#endregion
|
|
115
|
-
//#region packages/codegen/src/tsdown-bundle.ts
|
|
116
|
-
const bundleGraphqlSystem = async (sourcePath) => {
|
|
117
|
-
try {
|
|
118
|
-
const sourceDir = dirname(sourcePath);
|
|
119
|
-
const sourceExt = extname(sourcePath);
|
|
120
|
-
const baseName = sourcePath.slice(0, -sourceExt.length);
|
|
121
|
-
await build({
|
|
122
|
-
config: false,
|
|
123
|
-
entry: sourcePath,
|
|
124
|
-
format: ["cjs"],
|
|
125
|
-
platform: "node",
|
|
126
|
-
external: ["@soda-gql/core", "@soda-gql/runtime"],
|
|
127
|
-
dts: false,
|
|
128
|
-
outDir: sourceDir,
|
|
129
|
-
fixedExtension: true,
|
|
130
|
-
clean: false,
|
|
131
|
-
minify: false,
|
|
132
|
-
sourcemap: false,
|
|
133
|
-
treeshake: false
|
|
134
|
-
});
|
|
135
|
-
const cjsPath = `${baseName}.cjs`;
|
|
136
|
-
return ok({ cjsPath });
|
|
137
|
-
} catch (error) {
|
|
138
|
-
return err({
|
|
139
|
-
code: "EMIT_FAILED",
|
|
140
|
-
message: `Failed to bundle graphql-system: ${error instanceof Error ? error.message : String(error)}`,
|
|
141
|
-
outPath: sourcePath
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
|
|
146
120
|
//#endregion
|
|
147
121
|
//#region packages/codegen/src/runner.ts
|
|
148
122
|
const extensionMap = {
|
|
@@ -182,94 +156,49 @@ const toImportSpecifier = (fromPath, targetPath, options) => {
|
|
|
182
156
|
const withoutExt = currentExt ? withPrefix.slice(0, -currentExt.length) : withPrefix;
|
|
183
157
|
return `${withoutExt}${runtimeExt}`;
|
|
184
158
|
};
|
|
185
|
-
const
|
|
159
|
+
const runCodegen = async (options) => {
|
|
186
160
|
const outPath = resolve(options.outPath);
|
|
187
|
-
const
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const metadataAdapterPaths = new Map();
|
|
192
|
-
const helpersPaths = new Map();
|
|
193
|
-
for (const [schemaName, adapterPath] of Object.entries(runtimeAdapters)) {
|
|
194
|
-
const resolvedPath = resolve(adapterPath);
|
|
195
|
-
if (!existsSync(resolvedPath)) {
|
|
161
|
+
const importSpecifierOptions = { includeExtension: options.importExtension };
|
|
162
|
+
for (const [schemaName, schemaConfig] of Object.entries(options.schemas)) {
|
|
163
|
+
const scalarPath = resolve(schemaConfig.inject.scalars);
|
|
164
|
+
if (!existsSync(scalarPath)) {
|
|
196
165
|
return err({
|
|
197
166
|
code: "INJECT_MODULE_NOT_FOUND",
|
|
198
|
-
message: `
|
|
199
|
-
injectPath:
|
|
167
|
+
message: `Scalar module not found for schema '${schemaName}': ${scalarPath}`,
|
|
168
|
+
injectPath: scalarPath
|
|
200
169
|
});
|
|
201
170
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const resolvedPath = resolve(scalarPath);
|
|
206
|
-
if (!existsSync(resolvedPath)) {
|
|
207
|
-
return err({
|
|
208
|
-
code: "INJECT_MODULE_NOT_FOUND",
|
|
209
|
-
message: `Scalar module not found for schema '${schemaName}': ${resolvedPath}`,
|
|
210
|
-
injectPath: resolvedPath
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
scalarPaths.set(schemaName, resolvedPath);
|
|
214
|
-
}
|
|
215
|
-
if (options.metadataAdapters) {
|
|
216
|
-
for (const [schemaName, metadataAdapterPath] of Object.entries(options.metadataAdapters)) {
|
|
217
|
-
const resolvedPath = resolve(metadataAdapterPath);
|
|
218
|
-
if (!existsSync(resolvedPath)) {
|
|
171
|
+
if (schemaConfig.inject.adapter) {
|
|
172
|
+
const adapterPath = resolve(schemaConfig.inject.adapter);
|
|
173
|
+
if (!existsSync(adapterPath)) {
|
|
219
174
|
return err({
|
|
220
175
|
code: "INJECT_MODULE_NOT_FOUND",
|
|
221
|
-
message: `
|
|
222
|
-
injectPath:
|
|
176
|
+
message: `Adapter module not found for schema '${schemaName}': ${adapterPath}`,
|
|
177
|
+
injectPath: adapterPath
|
|
223
178
|
});
|
|
224
179
|
}
|
|
225
|
-
metadataAdapterPaths.set(schemaName, resolvedPath);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if (options.helpers) {
|
|
229
|
-
for (const [schemaName, helpersPath] of Object.entries(options.helpers)) {
|
|
230
|
-
const resolvedPath = resolve(helpersPath);
|
|
231
|
-
if (!existsSync(resolvedPath)) {
|
|
232
|
-
return err({
|
|
233
|
-
code: "INJECT_MODULE_NOT_FOUND",
|
|
234
|
-
message: `Helpers module not found for schema '${schemaName}': ${resolvedPath}`,
|
|
235
|
-
injectPath: resolvedPath
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
helpersPaths.set(schemaName, resolvedPath);
|
|
239
180
|
}
|
|
240
181
|
}
|
|
241
182
|
const schemas = new Map();
|
|
242
183
|
const schemaHashes = {};
|
|
243
|
-
for (const [name,
|
|
244
|
-
const result = await loadSchema(
|
|
184
|
+
for (const [name, schemaConfig] of Object.entries(options.schemas)) {
|
|
185
|
+
const result = await loadSchema(schemaConfig.schema).match((doc) => Promise.resolve(ok(doc)), (error) => Promise.resolve(err(error)));
|
|
245
186
|
if (result.isErr()) {
|
|
246
187
|
return err(result.error);
|
|
247
188
|
}
|
|
248
189
|
schemas.set(name, result.value);
|
|
249
190
|
}
|
|
250
191
|
const injectionConfig = new Map();
|
|
251
|
-
for (const schemaName of
|
|
252
|
-
const
|
|
253
|
-
const scalarPath = scalarPaths.get(schemaName);
|
|
254
|
-
if (!adapterPath || !scalarPath) {
|
|
255
|
-
return err({
|
|
256
|
-
code: "INJECT_MODULE_REQUIRED",
|
|
257
|
-
message: `Missing adapter or scalar configuration for schema '${schemaName}'`
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
const importSpecifierOptions = { includeExtension: options.importExtension };
|
|
261
|
-
const metadataAdapterPath = metadataAdapterPaths.get(schemaName);
|
|
262
|
-
const helpersPath = helpersPaths.get(schemaName);
|
|
192
|
+
for (const [schemaName, schemaConfig] of Object.entries(options.schemas)) {
|
|
193
|
+
const injectConfig = schemaConfig.inject;
|
|
263
194
|
injectionConfig.set(schemaName, {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
...metadataAdapterPath ? { metadataAdapterImportPath: toImportSpecifier(outPath, metadataAdapterPath, importSpecifierOptions) } : {},
|
|
267
|
-
...helpersPath ? { helpersImportPath: toImportSpecifier(outPath, helpersPath, importSpecifierOptions) } : {}
|
|
195
|
+
scalarImportPath: toImportSpecifier(outPath, resolve(injectConfig.scalars), importSpecifierOptions),
|
|
196
|
+
...injectConfig.adapter ? { adapterImportPath: toImportSpecifier(outPath, resolve(injectConfig.adapter), importSpecifierOptions) } : {}
|
|
268
197
|
});
|
|
269
198
|
}
|
|
270
199
|
const { code } = generateMultiSchemaModule(schemas, { injection: injectionConfig });
|
|
271
200
|
for (const [name, document] of schemas.entries()) {
|
|
272
|
-
const schemaIndex = (await import("./generator-
|
|
201
|
+
const schemaIndex = (await import("./generator-slr91UMQ.mjs")).createSchemaIndex(document);
|
|
273
202
|
const objects = Array.from(schemaIndex.objects.keys()).filter((n) => !n.startsWith("__")).length;
|
|
274
203
|
const enums = Array.from(schemaIndex.enums.keys()).filter((n) => !n.startsWith("__")).length;
|
|
275
204
|
const inputs = Array.from(schemaIndex.inputs.keys()).filter((n) => !n.startsWith("__")).length;
|
|
@@ -286,7 +215,10 @@ const runMultiSchemaCodegen = async (options) => {
|
|
|
286
215
|
if (writeResult.isErr()) {
|
|
287
216
|
return err(writeResult.error);
|
|
288
217
|
}
|
|
289
|
-
const bundleOutcome = await
|
|
218
|
+
const bundleOutcome = await esbuildBundler.bundle({
|
|
219
|
+
sourcePath: outPath,
|
|
220
|
+
external: ["@soda-gql/core", "@soda-gql/runtime"]
|
|
221
|
+
});
|
|
290
222
|
const bundleResult = bundleOutcome.match((result) => ok(result), (error) => err(error));
|
|
291
223
|
if (bundleResult.isErr()) {
|
|
292
224
|
return err(bundleResult.error);
|
|
@@ -299,5 +231,5 @@ const runMultiSchemaCodegen = async (options) => {
|
|
|
299
231
|
};
|
|
300
232
|
|
|
301
233
|
//#endregion
|
|
302
|
-
export { hashSchema, loadSchema,
|
|
234
|
+
export { hashSchema, loadSchema, runCodegen, writeInjectTemplate };
|
|
303
235
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["extensionMap: Record<string, string>","withPrefix","currentExt","schemaHashes: Record<string, { schemaHash: string; objects: number; enums: number; inputs: number; unions: number }>"],"sources":["../src/inject-template.ts","../src/file.ts","../src/schema.ts","../src/tsdown-bundle.ts","../src/runner.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nconst templateContents = `\\\nimport { defineScalar } from \"@soda-gql/core\";\nimport { createRuntimeAdapter } from \"@soda-gql/runtime\";\n\nexport const scalar = {\n ...defineScalar(\"ID\", ({ type }) => ({\n input: type<string>(),\n output: type<string>(),\n directives: {},\n })),\n ...defineScalar(\"String\", ({ type }) => ({\n input: type<string>(),\n output: type<string>(),\n directives: {},\n })),\n ...defineScalar(\"Int\", ({ type }) => ({\n input: type<number>(),\n output: type<number>(),\n directives: {},\n })),\n ...defineScalar(\"Float\", ({ type }) => ({\n input: type<number>(),\n output: type<number>(),\n directives: {},\n })),\n ...defineScalar(\"Boolean\", ({ type }) => ({\n input: type<boolean>(),\n output: type<boolean>(),\n directives: {},\n })),\n} as const;\n\nexport const adapter = createRuntimeAdapter(({ type }) => ({\n nonGraphqlErrorType: type<{ type: \"non-graphql-error\"; cause: unknown }>(),\n}));\n`;\n\nexport const writeInjectTemplate = (outPath: string) => {\n const targetPath = resolve(outPath);\n\n try {\n if (existsSync(targetPath)) {\n return err<void, CodegenError>({\n code: \"INJECT_TEMPLATE_EXISTS\",\n message: `Inject module already exists: ${targetPath}`,\n outPath: targetPath,\n });\n }\n\n mkdirSync(dirname(targetPath), { recursive: true });\n writeFileSync(targetPath, `${templateContents}\\n`);\n return ok<void, CodegenError>(undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<void, CodegenError>({\n code: \"INJECT_TEMPLATE_FAILED\",\n message,\n outPath: targetPath,\n });\n }\n};\n\nexport const getInjectTemplate = (): string => `${templateContents}\\n`;\n","import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nexport const writeModule = (outPath: string, contents: string) => {\n const targetPath = resolve(outPath);\n\n try {\n mkdirSync(dirname(targetPath), { recursive: true });\n writeFileSync(targetPath, contents);\n return ok<void, CodegenError>(undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<void, CodegenError>({\n code: \"EMIT_FAILED\",\n message,\n outPath: targetPath,\n });\n }\n};\n","import { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { type DocumentNode, parse, print } from \"graphql\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nexport const loadSchema = (schemaPath: string) => {\n const resolvedPath = resolve(schemaPath);\n\n if (!existsSync(resolvedPath)) {\n return err<DocumentNode, CodegenError>({\n code: \"SCHEMA_NOT_FOUND\",\n message: `Schema file not found at ${resolvedPath}`,\n schemaPath: resolvedPath,\n });\n }\n\n try {\n const schemaSource = readFileSync(resolvedPath, \"utf8\");\n const document = parse(schemaSource);\n return ok<DocumentNode, CodegenError>(document);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<DocumentNode, CodegenError>({\n code: \"SCHEMA_INVALID\",\n message: `SchemaValidationError: ${message}`,\n schemaPath: resolvedPath,\n });\n }\n};\n\nexport const hashSchema = (document: DocumentNode): string => createHash(\"sha256\").update(print(document)).digest(\"hex\");\n","import { dirname, extname } from \"node:path\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport { build, type Options } from \"tsdown\";\nimport type { CodegenError } from \"./types\";\n\nexport type BundleResult = {\n readonly cjsPath: string;\n};\n\nexport const bundleGraphqlSystem = async (sourcePath: string): Promise<Result<BundleResult, CodegenError>> => {\n try {\n const sourceDir = dirname(sourcePath);\n const sourceExt = extname(sourcePath);\n const baseName = sourcePath.slice(0, -sourceExt.length);\n\n await build({\n config: false,\n entry: sourcePath,\n format: [\"cjs\"],\n platform: \"node\",\n external: [\"@soda-gql/core\", \"@soda-gql/runtime\"],\n dts: false,\n outDir: sourceDir,\n fixedExtension: true,\n clean: false,\n minify: false,\n sourcemap: false,\n treeshake: false,\n } satisfies Options);\n\n const cjsPath = `${baseName}.cjs`;\n\n return ok({ cjsPath });\n } catch (error) {\n return err({\n code: \"EMIT_FAILED\",\n message: `Failed to bundle graphql-system: ${error instanceof Error ? error.message : String(error)}`,\n outPath: sourcePath,\n });\n }\n};\n","import { existsSync } from \"node:fs\";\nimport { basename, dirname, extname, relative, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\nimport { writeModule } from \"./file\";\nimport { generateMultiSchemaModule } from \"./generator\";\nimport { hashSchema, loadSchema } from \"./schema\";\nimport { bundleGraphqlSystem } from \"./tsdown-bundle\";\nimport type { MultiSchemaCodegenOptions, MultiSchemaCodegenResult, MultiSchemaCodegenSuccess } from \"./types\";\n\nconst extensionMap: Record<string, string> = {\n \".ts\": \".js\",\n \".tsx\": \".js\",\n \".mts\": \".mjs\",\n \".cts\": \".cjs\",\n \".js\": \".js\",\n \".mjs\": \".mjs\",\n \".cjs\": \".cjs\",\n};\n\ntype ImportSpecifierOptions = {\n includeExtension?: boolean;\n};\n\nconst toImportSpecifier = (fromPath: string, targetPath: string, options?: ImportSpecifierOptions): string => {\n const fromDir = dirname(fromPath);\n const normalized = relative(fromDir, targetPath).replace(/\\\\/g, \"/\");\n const sourceExt = extname(targetPath);\n\n // When includeExtension is false (default), strip the extension entirely\n if (!options?.includeExtension) {\n if (normalized.length === 0) {\n return `./${basename(targetPath, sourceExt)}`;\n }\n const withPrefix = normalized.startsWith(\".\") ? normalized : `./${normalized}`;\n const currentExt = extname(withPrefix);\n return currentExt ? withPrefix.slice(0, -currentExt.length) : withPrefix;\n }\n\n // When includeExtension is true, convert to runtime extension\n const runtimeExt = extensionMap[sourceExt] ?? sourceExt;\n\n if (normalized.length === 0) {\n const base = runtimeExt !== sourceExt ? basename(targetPath, sourceExt) : basename(targetPath);\n return `./${base}${runtimeExt}`;\n }\n\n const withPrefix = normalized.startsWith(\".\") ? normalized : `./${normalized}`;\n if (!runtimeExt) {\n return withPrefix;\n }\n if (withPrefix.endsWith(runtimeExt)) {\n return withPrefix;\n }\n\n const currentExt = extname(withPrefix);\n const withoutExt = currentExt ? withPrefix.slice(0, -currentExt.length) : withPrefix;\n return `${withoutExt}${runtimeExt}`;\n};\n\nexport const runMultiSchemaCodegen = async (options: MultiSchemaCodegenOptions): Promise<MultiSchemaCodegenResult> => {\n const outPath = resolve(options.outPath);\n\n // Handle legacy injectFromPath for backward compatibility\n const runtimeAdapters = options.runtimeAdapters ?? (options.injectFromPath ? { default: options.injectFromPath } : {});\n const scalars = options.scalars ?? (options.injectFromPath ? { default: options.injectFromPath } : {});\n\n // Validate that all adapter and scalar files exist\n const adapterPaths = new Map<string, string>();\n const scalarPaths = new Map<string, string>();\n const metadataAdapterPaths = new Map<string, string>();\n const helpersPaths = 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 // Validate optional metadataAdapters\n if (options.metadataAdapters) {\n for (const [schemaName, metadataAdapterPath] of Object.entries(options.metadataAdapters)) {\n const resolvedPath = resolve(metadataAdapterPath);\n if (!existsSync(resolvedPath)) {\n return err({\n code: \"INJECT_MODULE_NOT_FOUND\",\n message: `Metadata adapter module not found for schema '${schemaName}': ${resolvedPath}`,\n injectPath: resolvedPath,\n });\n }\n metadataAdapterPaths.set(schemaName, resolvedPath);\n }\n }\n\n // Validate optional helpers\n if (options.helpers) {\n for (const [schemaName, helpersPath] of Object.entries(options.helpers)) {\n const resolvedPath = resolve(helpersPath);\n if (!existsSync(resolvedPath)) {\n return err({\n code: \"INJECT_MODULE_NOT_FOUND\",\n message: `Helpers module not found for schema '${schemaName}': ${resolvedPath}`,\n injectPath: resolvedPath,\n });\n }\n helpersPaths.set(schemaName, resolvedPath);\n }\n }\n\n // Load all schemas\n const schemas = new Map<string, import(\"graphql\").DocumentNode>();\n const schemaHashes: Record<string, { schemaHash: string; objects: number; enums: number; inputs: number; unions: number }> = {};\n\n for (const [name, 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<\n string,\n {\n adapterImportPath: string;\n scalarImportPath: string;\n metadataAdapterImportPath?: string;\n helpersImportPath?: string;\n }\n >();\n\n for (const schemaName of schemas.keys()) {\n const adapterPath = adapterPaths.get(schemaName);\n const scalarPath = scalarPaths.get(schemaName);\n\n if (!adapterPath || !scalarPath) {\n return err({\n code: \"INJECT_MODULE_REQUIRED\",\n message: `Missing adapter or scalar configuration for schema '${schemaName}'`,\n });\n }\n\n const importSpecifierOptions = { includeExtension: options.importExtension };\n const metadataAdapterPath = metadataAdapterPaths.get(schemaName);\n const helpersPath = helpersPaths.get(schemaName);\n\n injectionConfig.set(schemaName, {\n adapterImportPath: toImportSpecifier(outPath, adapterPath, importSpecifierOptions),\n scalarImportPath: toImportSpecifier(outPath, scalarPath, importSpecifierOptions),\n ...(metadataAdapterPath\n ? { metadataAdapterImportPath: toImportSpecifier(outPath, metadataAdapterPath, importSpecifierOptions) }\n : {}),\n ...(helpersPath ? { helpersImportPath: toImportSpecifier(outPath, helpersPath, importSpecifierOptions) } : {}),\n });\n }\n\n // Generate multi-schema module\n const { code } = generateMultiSchemaModule(schemas, {\n injection: injectionConfig,\n });\n\n // Calculate individual schema stats and hashes\n for (const [name, document] of schemas.entries()) {\n const schemaIndex = (await import(\"./generator\")).createSchemaIndex(document);\n const objects = Array.from(schemaIndex.objects.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const enums = Array.from(schemaIndex.enums.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const inputs = Array.from(schemaIndex.inputs.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const unions = Array.from(schemaIndex.unions.keys()).filter((n) => !n.startsWith(\"__\")).length;\n\n schemaHashes[name] = {\n schemaHash: hashSchema(document),\n objects,\n enums,\n inputs,\n unions,\n };\n }\n\n // Write the module\n const writeResult = await writeModule(outPath, code).match(\n () => Promise.resolve(ok(undefined)),\n (error) => Promise.resolve(err(error)),\n );\n\n if (writeResult.isErr()) {\n return err(writeResult.error);\n }\n\n // Bundle the generated module with tsdown\n const bundleOutcome = await bundleGraphqlSystem(outPath);\n const bundleResult = bundleOutcome.match(\n (result) => ok(result),\n (error) => err(error),\n );\n\n if (bundleResult.isErr()) {\n return err(bundleResult.error);\n }\n\n return ok({\n schemas: schemaHashes,\n outPath,\n cjsPath: bundleResult.value.cjsPath,\n } satisfies MultiSchemaCodegenSuccess);\n};\n"],"mappings":";;;;;;;;;AAMA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCzB,MAAa,uBAAuB,YAAoB;CACtD,MAAM,aAAa,QAAQ,QAAQ;AAEnC,KAAI;AACF,MAAI,WAAW,WAAW,EAAE;AAC1B,UAAO,IAAwB;IAC7B,MAAM;IACN,SAAS,iCAAiC;IAC1C,SAAS;IACV,CAAC;;AAGJ,YAAU,QAAQ,WAAW,EAAE,EAAE,WAAW,MAAM,CAAC;AACnD,gBAAc,YAAY,GAAG,iBAAiB,IAAI;AAClD,SAAO,GAAuB,UAAU;UACjC,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,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undler: Bundler","extensionMap: Record<string, string>","withPrefix","currentExt","schemaHashes: Record<string, { schemaHash: string; objects: number; enums: number; inputs: number; unions: number }>","defaultBundler"],"sources":["../src/inject-template.ts","../src/bundler/esbuild.ts","../src/file.ts","../src/schema.ts","../src/runner.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\n\nimport type { CodegenError } from \"./types\";\n\nconst templateContents = `\\\nimport { defineScalar } from \"@soda-gql/core\";\n\nexport const scalar = {\n ...defineScalar<\"ID\", string, string>(\"ID\"),\n ...defineScalar<\"String\", string, string>(\"String\"),\n ...defineScalar<\"Int\", number, number>(\"Int\"),\n ...defineScalar<\"Float\", number, number>(\"Float\"),\n ...defineScalar<\"Boolean\", boolean, boolean>(\"Boolean\"),\n} as const;\n`;\n\nexport const writeInjectTemplate = (outPath: string) => {\n const targetPath = resolve(outPath);\n\n try {\n if (existsSync(targetPath)) {\n return err<void, CodegenError>({\n code: \"INJECT_TEMPLATE_EXISTS\",\n message: `Inject module already exists: ${targetPath}`,\n outPath: targetPath,\n });\n }\n\n mkdirSync(dirname(targetPath), { recursive: true });\n writeFileSync(targetPath, `${templateContents}\\n`);\n return ok<void, CodegenError>(undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err<void, CodegenError>({\n code: \"INJECT_TEMPLATE_FAILED\",\n message,\n outPath: targetPath,\n });\n }\n};\n\nexport const getInjectTemplate = (): string => `${templateContents}\\n`;\n","import { extname } from \"node:path\";\nimport { build } from \"esbuild\";\nimport { err, ok } from \"neverthrow\";\nimport type { Bundler } from \"./types\";\n\nexport const esbuildBundler: Bundler = {\n name: \"esbuild\",\n bundle: async ({ sourcePath, external }) => {\n try {\n const sourceExt = extname(sourcePath);\n const baseName = sourcePath.slice(0, -sourceExt.length);\n const cjsPath = `${baseName}.cjs`;\n\n await build({\n entryPoints: [sourcePath],\n outfile: cjsPath,\n format: \"cjs\",\n platform: \"node\",\n bundle: true,\n external: [...external],\n sourcemap: false,\n minify: false,\n treeShaking: false,\n });\n\n return ok({ cjsPath });\n } catch (error) {\n return err({\n code: \"EMIT_FAILED\" as const,\n message: `[esbuild] Failed to bundle: ${error instanceof Error ? error.message : String(error)}`,\n outPath: sourcePath,\n });\n }\n },\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 { existsSync } from \"node:fs\";\nimport { basename, dirname, extname, relative, resolve } from \"node:path\";\nimport { err, ok } from \"neverthrow\";\nimport { defaultBundler } from \"./bundler\";\nimport { writeModule } from \"./file\";\nimport { generateMultiSchemaModule } from \"./generator\";\nimport { hashSchema, loadSchema } from \"./schema\";\nimport type { CodegenOptions, CodegenResult, CodegenSuccess } from \"./types\";\n\nconst extensionMap: Record<string, string> = {\n \".ts\": \".js\",\n \".tsx\": \".js\",\n \".mts\": \".mjs\",\n \".cts\": \".cjs\",\n \".js\": \".js\",\n \".mjs\": \".mjs\",\n \".cjs\": \".cjs\",\n};\n\ntype ImportSpecifierOptions = {\n includeExtension?: boolean;\n};\n\nconst toImportSpecifier = (fromPath: string, targetPath: string, options?: ImportSpecifierOptions): string => {\n const fromDir = dirname(fromPath);\n const normalized = relative(fromDir, targetPath).replace(/\\\\/g, \"/\");\n const sourceExt = extname(targetPath);\n\n // When includeExtension is false (default), strip the extension entirely\n if (!options?.includeExtension) {\n if (normalized.length === 0) {\n return `./${basename(targetPath, sourceExt)}`;\n }\n const withPrefix = normalized.startsWith(\".\") ? normalized : `./${normalized}`;\n const currentExt = extname(withPrefix);\n return currentExt ? withPrefix.slice(0, -currentExt.length) : withPrefix;\n }\n\n // When includeExtension is true, convert to runtime extension\n const runtimeExt = extensionMap[sourceExt] ?? sourceExt;\n\n if (normalized.length === 0) {\n const base = runtimeExt !== sourceExt ? basename(targetPath, sourceExt) : basename(targetPath);\n return `./${base}${runtimeExt}`;\n }\n\n const withPrefix = normalized.startsWith(\".\") ? normalized : `./${normalized}`;\n if (!runtimeExt) {\n return withPrefix;\n }\n if (withPrefix.endsWith(runtimeExt)) {\n return withPrefix;\n }\n\n const currentExt = extname(withPrefix);\n const withoutExt = currentExt ? withPrefix.slice(0, -currentExt.length) : withPrefix;\n return `${withoutExt}${runtimeExt}`;\n};\n\nexport const runCodegen = async (options: CodegenOptions): Promise<CodegenResult> => {\n const outPath = resolve(options.outPath);\n const importSpecifierOptions = { includeExtension: options.importExtension };\n\n // Validate that all schema and inject files exist\n for (const [schemaName, schemaConfig] of Object.entries(options.schemas)) {\n const scalarPath = resolve(schemaConfig.inject.scalars);\n if (!existsSync(scalarPath)) {\n return err({\n code: \"INJECT_MODULE_NOT_FOUND\",\n message: `Scalar module not found for schema '${schemaName}': ${scalarPath}`,\n injectPath: scalarPath,\n });\n }\n\n if (schemaConfig.inject.adapter) {\n const adapterPath = resolve(schemaConfig.inject.adapter);\n if (!existsSync(adapterPath)) {\n return err({\n code: \"INJECT_MODULE_NOT_FOUND\",\n message: `Adapter module not found for schema '${schemaName}': ${adapterPath}`,\n injectPath: adapterPath,\n });\n }\n }\n }\n\n // Load all schemas\n const schemas = new Map<string, import(\"graphql\").DocumentNode>();\n const schemaHashes: Record<string, { schemaHash: string; objects: number; enums: number; inputs: number; unions: number }> = {};\n\n for (const [name, schemaConfig] of Object.entries(options.schemas)) {\n const result = await loadSchema(schemaConfig.schema).match(\n (doc) => Promise.resolve(ok(doc)),\n (error) => Promise.resolve(err(error)),\n );\n\n if (result.isErr()) {\n return err(result.error);\n }\n\n schemas.set(name, result.value);\n }\n\n // Build injection config for each schema\n const injectionConfig = new Map<\n string,\n {\n scalarImportPath: string;\n adapterImportPath?: string;\n }\n >();\n\n for (const [schemaName, schemaConfig] of Object.entries(options.schemas)) {\n const injectConfig = schemaConfig.inject;\n\n injectionConfig.set(schemaName, {\n scalarImportPath: toImportSpecifier(outPath, resolve(injectConfig.scalars), importSpecifierOptions),\n ...(injectConfig.adapter\n ? { adapterImportPath: toImportSpecifier(outPath, resolve(injectConfig.adapter), importSpecifierOptions) }\n : {}),\n });\n }\n\n // Generate multi-schema module\n const { code } = generateMultiSchemaModule(schemas, {\n injection: injectionConfig,\n });\n\n // Calculate individual schema stats and hashes\n for (const [name, document] of schemas.entries()) {\n const schemaIndex = (await import(\"./generator\")).createSchemaIndex(document);\n const objects = Array.from(schemaIndex.objects.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const enums = Array.from(schemaIndex.enums.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const inputs = Array.from(schemaIndex.inputs.keys()).filter((n) => !n.startsWith(\"__\")).length;\n const unions = Array.from(schemaIndex.unions.keys()).filter((n) => !n.startsWith(\"__\")).length;\n\n schemaHashes[name] = {\n schemaHash: hashSchema(document),\n objects,\n enums,\n inputs,\n unions,\n };\n }\n\n // Write the module\n const writeResult = await writeModule(outPath, code).match(\n () => Promise.resolve(ok(undefined)),\n (error) => Promise.resolve(err(error)),\n );\n\n if (writeResult.isErr()) {\n return err(writeResult.error);\n }\n\n // Bundle the generated module\n const bundleOutcome = await defaultBundler.bundle({\n sourcePath: outPath,\n external: [\"@soda-gql/core\", \"@soda-gql/runtime\"],\n });\n const bundleResult = bundleOutcome.match(\n (result) => ok(result),\n (error) => err(error),\n );\n\n if (bundleResult.isErr()) {\n return err(bundleResult.error);\n }\n\n return ok({\n schemas: schemaHashes,\n outPath,\n cjsPath: bundleResult.value.cjsPath,\n } satisfies CodegenSuccess);\n};\n"],"mappings":";;;;;;;;;AAMA,MAAM,mBAAmB;;;;;;;;;;;AAYzB,MAAa,uBAAuB,YAAoB;CACtD,MAAM,aAAa,QAAQ,QAAQ;AAEnC,KAAI;AACF,MAAI,WAAW,WAAW,EAAE;AAC1B,UAAO,IAAwB;IAC7B,MAAM;IACN,SAAS,iCAAiC;IAC1C,SAAS;IACV,CAAC;;AAGJ,YAAU,QAAQ,WAAW,EAAE,EAAE,WAAW,MAAM,CAAC;AACnD,gBAAc,YAAY,GAAG,iBAAiB,IAAI;AAClD,SAAO,GAAuB,UAAU;UACjC,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AACtE,SAAO,IAAwB;GAC7B,MAAM;GACN;GACA,SAAS;GACV,CAAC;;;AAIN,MAAa,0BAAkC,GAAG,iBAAiB;;;;ACtCnE,MAAaA,iBAA0B;CACrC,MAAM;CACN,QAAQ,OAAO,EAAE,YAAY,eAAe;AAC1C,MAAI;GACF,MAAM,YAAY,QAAQ,WAAW;GACrC,M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CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;EAC1F,MAAM,QAAQ,MAAM,KAAK,YAAY,MAAM,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;EACtF,MAAM,SAAS,MAAM,KAAK,YAAY,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;EACxF,MAAM,SAAS,MAAM,KAAK,YAAY,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;AAExF,eAAa,QAAQ;GACnB,YAAY,WAAW,SAAS;GAChC;GACA;GACA;GACA;GACD;;CAIH,MAAM,cAAc,MAAM,YAAY,SAAS,KAAK,CAAC,YAC7C,QAAQ,QAAQ,GAAG,UAAU,CAAC,GACnC,UAAU,QAAQ,QAAQ,IAAI,MAAM,CAAC,CACvC;AAED,KAAI,YAAY,OAAO,EAAE;AACvB,SAAO,IAAI,YAAY,MAAM;;CAI/B,MAAM,gBAAgB,MAAMC,eAAe,OAAO;EAChD,YAAY;EACZ,UAAU,CAAC,kBAAkB,oBAAoB;EAClD,CAAC;CACF,MAAM,eAAe,cAAc,OAChC,WAAW,GAAG,OAAO,GACrB,UAAU,IAAI,MAAM,CACtB;AAED,KAAI,aAAa,OAAO,EAAE;AACxB,SAAO,IAAI,aAAa,MAAM;;AAGhC,QAAO,GAAG;EACR,SAAS;EACT;EACA,SAAS,aAAa,MAAM;EAC7B,CAA0B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soda-gql/codegen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "GraphQL schema code generation for soda-gql",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"private": false,
|
|
6
7
|
"license": "MIT",
|
|
@@ -12,12 +13,31 @@
|
|
|
12
13
|
"email": "shota.hatada@whatasoda.me",
|
|
13
14
|
"url": "https://github.com/whatasoda"
|
|
14
15
|
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"graphql",
|
|
18
|
+
"codegen",
|
|
19
|
+
"zero-runtime",
|
|
20
|
+
"typescript",
|
|
21
|
+
"schema"
|
|
22
|
+
],
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/whatasoda/soda-gql.git",
|
|
26
|
+
"directory": "packages/codegen"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/whatasoda/soda-gql#readme",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/whatasoda/soda-gql/issues"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
},
|
|
15
35
|
"main": "./dist/index.mjs",
|
|
16
36
|
"module": "./dist/index.mjs",
|
|
17
37
|
"types": "./dist/index.d.mts",
|
|
18
38
|
"exports": {
|
|
19
39
|
".": {
|
|
20
|
-
"@soda-gql": "
|
|
40
|
+
"@soda-gql": "./@x-index.ts",
|
|
21
41
|
"types": "./dist/index.d.mts",
|
|
22
42
|
"import": "./dist/index.mjs",
|
|
23
43
|
"require": "./dist/index.cjs",
|
|
@@ -26,11 +46,11 @@
|
|
|
26
46
|
"./package.json": "./package.json"
|
|
27
47
|
},
|
|
28
48
|
"dependencies": {
|
|
29
|
-
"@soda-gql/core": "0.
|
|
30
|
-
"@soda-gql/runtime": "0.
|
|
49
|
+
"@soda-gql/core": "0.3.0",
|
|
50
|
+
"@soda-gql/runtime": "0.3.0",
|
|
51
|
+
"esbuild": "^0.24.0",
|
|
31
52
|
"graphql": "^16.8.1",
|
|
32
|
-
"neverthrow": "^8.1.1"
|
|
33
|
-
"tsdown": "^0.15.7"
|
|
53
|
+
"neverthrow": "^8.1.1"
|
|
34
54
|
},
|
|
35
55
|
"devDependencies": {},
|
|
36
56
|
"peerDependencies": {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generator-D3aMXV0i.mjs","names":["operationTypes: OperationTypeNames","modifier: TypeModifier","imports: string[]","schemaBlocks: string[]","gqlEntries: string[]","optionsEntries: 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 readonly metadataAdapterImportPath?: string;\n readonly helpersImportPath?: 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 const metadataAdapterAliases = new Map<string, string>();\n const helpersAliases = new Map<string, string>();\n\n if ($$.injection.mode === \"inject\") {\n // Group imports by file path\n const importsByPath = new Map<string, string[]>();\n\n for (const [schemaName, injection] of $$.injection.perSchema) {\n const adapterAlias = `adapter_${schemaName}`;\n const scalarAlias = `scalar_${schemaName}`;\n adapterAliases.set(schemaName, adapterAlias);\n scalarAliases.set(schemaName, scalarAlias);\n\n // Group adapter import\n const adapterSpecifiers = importsByPath.get(injection.adapterImportPath) ?? [];\n if (!importsByPath.has(injection.adapterImportPath)) {\n importsByPath.set(injection.adapterImportPath, adapterSpecifiers);\n }\n adapterSpecifiers.push(`adapter as ${adapterAlias}`);\n\n // Group scalar import (may be same file as adapter)\n const scalarSpecifiers = importsByPath.get(injection.scalarImportPath) ?? [];\n if (!importsByPath.has(injection.scalarImportPath)) {\n importsByPath.set(injection.scalarImportPath, scalarSpecifiers);\n }\n scalarSpecifiers.push(`scalar as ${scalarAlias}`);\n\n // Group metadataAdapter import (optional)\n if (injection.metadataAdapterImportPath) {\n const metadataAdapterAlias = `metadataAdapter_${schemaName}`;\n metadataAdapterAliases.set(schemaName, metadataAdapterAlias);\n const metadataAdapterSpecifiers = importsByPath.get(injection.metadataAdapterImportPath) ?? [];\n if (!importsByPath.has(injection.metadataAdapterImportPath)) {\n importsByPath.set(injection.metadataAdapterImportPath, metadataAdapterSpecifiers);\n }\n metadataAdapterSpecifiers.push(`metadataAdapter as ${metadataAdapterAlias}`);\n }\n\n // Group helpers import (optional)\n if (injection.helpersImportPath) {\n const helpersAlias = `helpers_${schemaName}`;\n helpersAliases.set(schemaName, helpersAlias);\n const helpersSpecifiers = importsByPath.get(injection.helpersImportPath) ?? [];\n if (!importsByPath.has(injection.helpersImportPath)) {\n importsByPath.set(injection.helpersImportPath, helpersSpecifiers);\n }\n helpersSpecifiers.push(`helpers as ${helpersAlias}`);\n }\n }\n\n // Generate grouped imports\n for (const [path, specifiers] of importsByPath) {\n if (specifiers.length === 1) {\n imports.push(`import { ${specifiers[0]} } from \"${path}\";`);\n } else {\n imports.push(`import {\\n ${specifiers.join(\",\\n \")},\\n} from \"${path}\";`);\n }\n }\n }\n\n const extraImports = imports.length > 0 ? `${imports.join(\"\\n\")}\\n` : \"\";\n\n // Generate per-schema definitions\n const schemaBlocks: string[] = [];\n const gqlEntries: string[] = [];\n\n for (const [name, config] of Object.entries($$.schemas)) {\n const schemaVar = `${name}Schema`;\n const 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 // Get optional adapters\n const metadataAdapterVar = metadataAdapterAliases.get(name);\n const helpersVar = helpersAliases.get(name);\n\n // Build type exports\n const typeExports = [\n `export type Schema_${name} = typeof ${schemaVar} & { _?: never };`,\n `export type Adapter_${name} = typeof ${adapterVar} & { _?: never };`,\n ];\n if (helpersVar) {\n typeExports.push(`export type Helpers_${name} = typeof ${helpersVar} & { _?: never };`);\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\n${typeExports.join(\"\\n\")}`);\n\n // Build gql entry with options if needed\n const hasOptions = metadataAdapterVar || helpersVar;\n if (hasOptions) {\n const optionsEntries: string[] = [];\n if (metadataAdapterVar) {\n optionsEntries.push(`metadataAdapter: ${metadataAdapterVar}`);\n }\n if (helpersVar) {\n optionsEntries.push(`helpers: ${helpersVar}`);\n }\n const helpersGeneric = helpersVar ? `, Helpers_${name}` : \"\";\n gqlEntries.push(\n ` ${name}: createGqlElementComposer<Schema_${name}, Adapter_${name}${helpersGeneric}>(${schemaVar}, { ${optionsEntries.join(\", \")} })`,\n );\n } else {\n gqlEntries.push(` ${name}: createGqlElementComposer<Schema_${name}, Adapter_${name}>(${schemaVar})`);\n }\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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