@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.cjs
CHANGED
|
@@ -1,47 +1,22 @@
|
|
|
1
|
-
const require_generator = require('./generator-
|
|
1
|
+
const require_generator = require('./generator-CMKkXhGP.cjs');
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
let neverthrow = require("neverthrow");
|
|
5
|
+
let esbuild = require("esbuild");
|
|
5
6
|
let graphql = require("graphql");
|
|
6
7
|
let node_crypto = require("node:crypto");
|
|
7
|
-
let tsdown = require("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 = (0, node_path.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 = (0, node_path.extname)(sourcePath);
|
|
52
|
+
const baseName = sourcePath.slice(0, -sourceExt.length);
|
|
53
|
+
const cjsPath = `${baseName}.cjs`;
|
|
54
|
+
await (0, esbuild.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 (0, neverthrow.ok)({ cjsPath });
|
|
66
|
+
} catch (error) {
|
|
67
|
+
return (0, neverthrow.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) => (0, node_crypto.createHash)("sha256").update((0, graphql.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 = (0, node_path.dirname)(sourcePath);
|
|
119
|
-
const sourceExt = (0, node_path.extname)(sourcePath);
|
|
120
|
-
const baseName = sourcePath.slice(0, -sourceExt.length);
|
|
121
|
-
await (0, tsdown.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 (0, neverthrow.ok)({ cjsPath });
|
|
137
|
-
} catch (error) {
|
|
138
|
-
return (0, neverthrow.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 = (0, node_path.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 = (0, node_path.resolve)(adapterPath);
|
|
195
|
-
if (!(0, node_fs.existsSync)(resolvedPath)) {
|
|
161
|
+
const importSpecifierOptions = { includeExtension: options.importExtension };
|
|
162
|
+
for (const [schemaName, schemaConfig] of Object.entries(options.schemas)) {
|
|
163
|
+
const scalarPath = (0, node_path.resolve)(schemaConfig.inject.scalars);
|
|
164
|
+
if (!(0, node_fs.existsSync)(scalarPath)) {
|
|
196
165
|
return (0, neverthrow.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 = (0, node_path.resolve)(scalarPath);
|
|
206
|
-
if (!(0, node_fs.existsSync)(resolvedPath)) {
|
|
207
|
-
return (0, neverthrow.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 = (0, node_path.resolve)(metadataAdapterPath);
|
|
218
|
-
if (!(0, node_fs.existsSync)(resolvedPath)) {
|
|
171
|
+
if (schemaConfig.inject.adapter) {
|
|
172
|
+
const adapterPath = (0, node_path.resolve)(schemaConfig.inject.adapter);
|
|
173
|
+
if (!(0, node_fs.existsSync)(adapterPath)) {
|
|
219
174
|
return (0, neverthrow.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 = (0, node_path.resolve)(helpersPath);
|
|
231
|
-
if (!(0, node_fs.existsSync)(resolvedPath)) {
|
|
232
|
-
return (0, neverthrow.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((0, neverthrow.ok)(doc)), (error) => Promise.resolve((0, neverthrow.err)(error)));
|
|
245
186
|
if (result.isErr()) {
|
|
246
187
|
return (0, neverthrow.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 (0, neverthrow.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, (0, node_path.resolve)(injectConfig.scalars), importSpecifierOptions),
|
|
196
|
+
...injectConfig.adapter ? { adapterImportPath: toImportSpecifier(outPath, (0, node_path.resolve)(injectConfig.adapter), importSpecifierOptions) } : {}
|
|
268
197
|
});
|
|
269
198
|
}
|
|
270
199
|
const { code } = require_generator.generateMultiSchemaModule(schemas, { injection: injectionConfig });
|
|
271
200
|
for (const [name, document] of schemas.entries()) {
|
|
272
|
-
const schemaIndex = (await Promise.resolve().then(() => require("./generator-
|
|
201
|
+
const schemaIndex = (await Promise.resolve().then(() => require("./generator-Djrw_0F1.cjs"))).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 (0, neverthrow.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) => (0, neverthrow.ok)(result), (error) => (0, neverthrow.err)(error));
|
|
291
223
|
if (bundleResult.isErr()) {
|
|
292
224
|
return (0, neverthrow.err)(bundleResult.error);
|
|
@@ -301,5 +233,6 @@ const runMultiSchemaCodegen = async (options) => {
|
|
|
301
233
|
//#endregion
|
|
302
234
|
exports.hashSchema = hashSchema;
|
|
303
235
|
exports.loadSchema = loadSchema;
|
|
304
|
-
exports.
|
|
305
|
-
exports.writeInjectTemplate = writeInjectTemplate;
|
|
236
|
+
exports.runCodegen = runCodegen;
|
|
237
|
+
exports.writeInjectTemplate = writeInjectTemplate;
|
|
238
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["esbuildBundler: Bundler","extensionMap: Record<string, string>","withPrefix","currentExt","schemaHashes: Record<string, { schemaHash: string; objects: number; enums: number; inputs: number; unions: number }>","generateMultiSchemaModule","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,oCAAqB,QAAQ;AAEnC,KAAI;AACF,8BAAe,WAAW,EAAE;AAC1B,8BAA+B;IAC7B,MAAM;IACN,SAAS,iCAAiC;IAC1C,SAAS;IACV,CAAC;;AAGJ,gDAAkB,WAAW,EAAE,EAAE,WAAW,MAAM,CAAC;AACnD,6BAAc,YAAY,GAAG,iBAAiB,IAAI;A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a,QAAQ,SAAS,EAAE;EAChD,MAAM,eAAe,2CAAM,8BAAuB,kBAAkB,SAAS;EAC7E,MAAM,UAAU,MAAM,KAAK,YAAY,QAAQ,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;EAC1F,MAAM,QAAQ,MAAM,KAAK,YAAY,MAAM,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;EACtF,MAAM,SAAS,MAAM,KAAK,YAAY,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;EACxF,MAAM,SAAS,MAAM,KAAK,YAAY,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;AAExF,eAAa,QAAQ;GACnB,YAAY,WAAW,SAAS;GAChC;GACA;GACA;GACA;GACD;;CAIH,MAAM,cAAc,MAAM,YAAY,SAAS,KAAK,CAAC,YAC7C,QAAQ,2BAAW,UAAU,CAAC,GACnC,UAAU,QAAQ,4BAAY,MAAM,CAAC,CACvC;AAED,KAAI,YAAY,OAAO,EAAE;AACvB,6BAAW,YAAY,MAAM;;CAI/B,MAAM,gBAAgB,MAAMC,eAAe,OAAO;EAChD,YAAY;EACZ,UAAU,CAAC,kBAAkB,oBAAoB;EAClD,CAAC;CACF,MAAM,eAAe,cAAc,OAChC,8BAAc,OAAO,GACrB,8BAAc,MAAM,CACtB;AAED,KAAI,aAAa,OAAO,EAAE;AACxB,6BAAW,aAAa,MAAM;;AAGhC,2BAAU;EACR,SAAS;EACT;EACA,SAAS,aAAa,MAAM;EAC7B,CAA0B"}
|
package/dist/index.d.cts
CHANGED
|
@@ -4,21 +4,18 @@ import { DocumentNode } from "graphql";
|
|
|
4
4
|
|
|
5
5
|
//#region packages/codegen/src/types.d.ts
|
|
6
6
|
type CodegenFormat = "json" | "human";
|
|
7
|
-
type
|
|
8
|
-
readonly
|
|
9
|
-
readonly
|
|
10
|
-
readonly format: CodegenFormat;
|
|
11
|
-
readonly injectFromPath: string;
|
|
7
|
+
type CodegenInjectConfig = {
|
|
8
|
+
readonly scalars: string;
|
|
9
|
+
readonly adapter?: string;
|
|
12
10
|
};
|
|
13
|
-
type
|
|
14
|
-
readonly
|
|
11
|
+
type CodegenSchemaConfig = {
|
|
12
|
+
readonly schema: string;
|
|
13
|
+
readonly inject: CodegenInjectConfig;
|
|
14
|
+
};
|
|
15
|
+
type CodegenOptions = {
|
|
16
|
+
readonly schemas: Record<string, CodegenSchemaConfig>;
|
|
15
17
|
readonly outPath: string;
|
|
16
18
|
readonly format: CodegenFormat;
|
|
17
|
-
readonly runtimeAdapters?: Record<string, string>;
|
|
18
|
-
readonly scalars?: Record<string, string>;
|
|
19
|
-
readonly metadataAdapters?: Record<string, string>;
|
|
20
|
-
readonly helpers?: Record<string, string>;
|
|
21
|
-
readonly injectFromPath?: string;
|
|
22
19
|
readonly importExtension?: boolean;
|
|
23
20
|
};
|
|
24
21
|
type CodegenCliCommand = {
|
|
@@ -58,14 +55,6 @@ type CodegenError = {
|
|
|
58
55
|
readonly outPath: string;
|
|
59
56
|
};
|
|
60
57
|
type CodegenSuccess = {
|
|
61
|
-
readonly schemaHash: string;
|
|
62
|
-
readonly outPath: string;
|
|
63
|
-
readonly objects: number;
|
|
64
|
-
readonly enums: number;
|
|
65
|
-
readonly inputs: number;
|
|
66
|
-
readonly unions: number;
|
|
67
|
-
};
|
|
68
|
-
type MultiSchemaCodegenSuccess = {
|
|
69
58
|
readonly schemas: Record<string, {
|
|
70
59
|
readonly schemaHash: string;
|
|
71
60
|
readonly objects: number;
|
|
@@ -77,18 +66,17 @@ type MultiSchemaCodegenSuccess = {
|
|
|
77
66
|
readonly cjsPath: string;
|
|
78
67
|
};
|
|
79
68
|
type CodegenResult = Result<CodegenSuccess, CodegenError>;
|
|
80
|
-
type MultiSchemaCodegenResult = Result<MultiSchemaCodegenSuccess, CodegenError>;
|
|
81
69
|
//#endregion
|
|
82
70
|
//#region packages/codegen/src/inject-template.d.ts
|
|
83
71
|
declare const writeInjectTemplate: (outPath: string) => neverthrow0.Err<void, CodegenError> | neverthrow0.Ok<void, CodegenError>;
|
|
84
72
|
declare const getInjectTemplate: () => string;
|
|
85
73
|
//#endregion
|
|
86
74
|
//#region packages/codegen/src/runner.d.ts
|
|
87
|
-
declare const
|
|
75
|
+
declare const runCodegen: (options: CodegenOptions) => Promise<CodegenResult>;
|
|
88
76
|
//#endregion
|
|
89
77
|
//#region packages/codegen/src/schema.d.ts
|
|
90
78
|
declare const loadSchema: (schemaPath: string) => neverthrow0.Err<DocumentNode, CodegenError> | neverthrow0.Ok<DocumentNode, CodegenError>;
|
|
91
79
|
declare const hashSchema: (document: DocumentNode) => string;
|
|
92
80
|
//#endregion
|
|
93
|
-
export { type CodegenCliCommand, type CodegenError, type CodegenFormat, type
|
|
81
|
+
export { type CodegenCliCommand, type CodegenError, type CodegenFormat, type CodegenInjectConfig, type CodegenOptions, type CodegenResult, type CodegenSchemaConfig, type CodegenSuccess, hashSchema, loadSchema, runCodegen, writeInjectTemplate };
|
|
94
82
|
//# sourceMappingURL=index.d.cts.map
|
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;
|
|
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;KAGA,mBAAA;;;AAHZ,CAAA;AAGY,KAMA,mBAAA,GANmB;EAMnB,SAAA,MAAA,EAAA,MAAmB;EAKnB,SAAA,MAAA,EAHO,mBAGO;CACS;AAAf,KADR,cAAA,GACQ;EAED,SAAA,OAAA,EAFC,MAED,CAAA,MAAA,EAFgB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packages/codegen/src/types.d.ts
|
|
6
6
|
type CodegenFormat = "json" | "human";
|
|
7
|
-
type
|
|
8
|
-
readonly
|
|
9
|
-
readonly
|
|
10
|
-
readonly format: CodegenFormat;
|
|
11
|
-
readonly injectFromPath: string;
|
|
7
|
+
type CodegenInjectConfig = {
|
|
8
|
+
readonly scalars: string;
|
|
9
|
+
readonly adapter?: string;
|
|
12
10
|
};
|
|
13
|
-
type
|
|
14
|
-
readonly
|
|
11
|
+
type CodegenSchemaConfig = {
|
|
12
|
+
readonly schema: string;
|
|
13
|
+
readonly inject: CodegenInjectConfig;
|
|
14
|
+
};
|
|
15
|
+
type CodegenOptions = {
|
|
16
|
+
readonly schemas: Record<string, CodegenSchemaConfig>;
|
|
15
17
|
readonly outPath: string;
|
|
16
18
|
readonly format: CodegenFormat;
|
|
17
|
-
readonly runtimeAdapters?: Record<string, string>;
|
|
18
|
-
readonly scalars?: Record<string, string>;
|
|
19
|
-
readonly metadataAdapters?: Record<string, string>;
|
|
20
|
-
readonly helpers?: Record<string, string>;
|
|
21
|
-
readonly injectFromPath?: string;
|
|
22
19
|
readonly importExtension?: boolean;
|
|
23
20
|
};
|
|
24
21
|
type CodegenCliCommand = {
|
|
@@ -58,14 +55,6 @@ type CodegenError = {
|
|
|
58
55
|
readonly outPath: string;
|
|
59
56
|
};
|
|
60
57
|
type CodegenSuccess = {
|
|
61
|
-
readonly schemaHash: string;
|
|
62
|
-
readonly outPath: string;
|
|
63
|
-
readonly objects: number;
|
|
64
|
-
readonly enums: number;
|
|
65
|
-
readonly inputs: number;
|
|
66
|
-
readonly unions: number;
|
|
67
|
-
};
|
|
68
|
-
type MultiSchemaCodegenSuccess = {
|
|
69
58
|
readonly schemas: Record<string, {
|
|
70
59
|
readonly schemaHash: string;
|
|
71
60
|
readonly objects: number;
|
|
@@ -77,18 +66,17 @@ type MultiSchemaCodegenSuccess = {
|
|
|
77
66
|
readonly cjsPath: string;
|
|
78
67
|
};
|
|
79
68
|
type CodegenResult = Result<CodegenSuccess, CodegenError>;
|
|
80
|
-
type MultiSchemaCodegenResult = Result<MultiSchemaCodegenSuccess, CodegenError>;
|
|
81
69
|
//#endregion
|
|
82
70
|
//#region packages/codegen/src/inject-template.d.ts
|
|
83
71
|
declare const writeInjectTemplate: (outPath: string) => neverthrow0.Err<void, CodegenError> | neverthrow0.Ok<void, CodegenError>;
|
|
84
72
|
declare const getInjectTemplate: () => string;
|
|
85
73
|
//#endregion
|
|
86
74
|
//#region packages/codegen/src/runner.d.ts
|
|
87
|
-
declare const
|
|
75
|
+
declare const runCodegen: (options: CodegenOptions) => Promise<CodegenResult>;
|
|
88
76
|
//#endregion
|
|
89
77
|
//#region packages/codegen/src/schema.d.ts
|
|
90
78
|
declare const loadSchema: (schemaPath: string) => neverthrow0.Err<DocumentNode, CodegenError> | neverthrow0.Ok<DocumentNode, CodegenError>;
|
|
91
79
|
declare const hashSchema: (document: DocumentNode) => string;
|
|
92
80
|
//#endregion
|
|
93
|
-
export { type CodegenCliCommand, type CodegenError, type CodegenFormat, type
|
|
81
|
+
export { type CodegenCliCommand, type CodegenError, type CodegenFormat, type CodegenInjectConfig, type CodegenOptions, type CodegenResult, type CodegenSchemaConfig, type CodegenSuccess, hashSchema, loadSchema, runCodegen, writeInjectTemplate };
|
|
94
82
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/inject-template.ts","../src/runner.ts","../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;KAEY,aAAA;
|
|
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;KAGA,mBAAA;;;AAHZ,CAAA;AAGY,KAMA,mBAAA,GANmB;EAMnB,SAAA,MAAA,EAAA,MAAmB;EAKnB,SAAA,MAAA,EAHO,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