@soda-gql/config 0.11.26 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +99 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +39 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +99 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -47,7 +47,6 @@ let node_path = require("node:path");
|
|
|
47
47
|
let node_module = require("node:module");
|
|
48
48
|
let node_path_posix = require("node:path/posix");
|
|
49
49
|
let node_vm = require("node:vm");
|
|
50
|
-
let __swc_core = require("@swc/core");
|
|
51
50
|
|
|
52
51
|
//#region packages/config/src/errors.ts
|
|
53
52
|
const configError = ({ code, message, filePath, cause }) => ({
|
|
@@ -109,6 +108,11 @@ const SchemaConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({
|
|
|
109
108
|
});
|
|
110
109
|
const StylesConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({ importExtension: zod.default.boolean().optional() });
|
|
111
110
|
const CodegenConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({ chunkSize: zod.default.number().int().positive().optional() });
|
|
111
|
+
const GraphqlCompatConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({
|
|
112
|
+
input: zod.default.array(zod.default.string().min(1)),
|
|
113
|
+
schema: zod.default.string().min(1).optional(),
|
|
114
|
+
suffix: zod.default.string().min(1).optional()
|
|
115
|
+
});
|
|
112
116
|
const ArtifactConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({ path: zod.default.string().min(1).optional() });
|
|
113
117
|
const SodaGqlConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({
|
|
114
118
|
analyzer: zod.default.enum(["ts", "swc"]).optional(),
|
|
@@ -121,6 +125,7 @@ const SodaGqlConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({
|
|
|
121
125
|
styles: StylesConfigSchema.optional(),
|
|
122
126
|
codegen: CodegenConfigSchema.optional(),
|
|
123
127
|
plugins: zod.default.record(zod.default.string(), zod.default.unknown()).optional(),
|
|
128
|
+
graphqlCompat: GraphqlCompatConfigSchema.optional(),
|
|
124
129
|
artifact: ArtifactConfigSchema.optional()
|
|
125
130
|
});
|
|
126
131
|
function validateConfig(config) {
|
|
@@ -136,14 +141,28 @@ function validateConfig(config) {
|
|
|
136
141
|
|
|
137
142
|
//#endregion
|
|
138
143
|
//#region packages/config/src/evaluation.ts
|
|
144
|
+
/** Lazily resolve @swc/core from the config file's directory, falling back to package resolution. */
|
|
145
|
+
const resolveSwc = (configPath) => {
|
|
146
|
+
try {
|
|
147
|
+
const localRequire = (0, node_module.createRequire)(configPath);
|
|
148
|
+
return localRequire("@swc/core").transformSync;
|
|
149
|
+
} catch (primaryError) {
|
|
150
|
+
if (typeof require("url").pathToFileURL(__filename).href !== "string") {
|
|
151
|
+
throw primaryError;
|
|
152
|
+
}
|
|
153
|
+
const packageRequire = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
154
|
+
return packageRequire("@swc/core").transformSync;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
139
157
|
/**
|
|
140
158
|
* Load and execute TypeScript config file synchronously using SWC + VM.
|
|
141
159
|
*/
|
|
142
160
|
function executeConfigFile(configPath) {
|
|
143
161
|
const filePath = (0, node_path_posix.resolve)(configPath);
|
|
144
162
|
try {
|
|
163
|
+
const transformSync = resolveSwc(filePath);
|
|
145
164
|
const source = (0, node_fs.readFileSync)(filePath, "utf-8");
|
|
146
|
-
const result =
|
|
165
|
+
const result = transformSync(source, {
|
|
147
166
|
filename: filePath,
|
|
148
167
|
jsc: { parser: { syntax: "typescript" } },
|
|
149
168
|
module: { type: "commonjs" },
|
|
@@ -183,9 +202,10 @@ function executeConfigFile(configPath) {
|
|
|
183
202
|
}
|
|
184
203
|
return (0, neverthrow.ok)(config);
|
|
185
204
|
} catch (error) {
|
|
205
|
+
const message = error instanceof Error && error.message.includes("Cannot find module '@swc/core'") ? "@swc/core not found. Install it in your project: bun add -D @swc/core" : `Failed to load config: ${error instanceof Error ? error.message : String(error)}`;
|
|
186
206
|
return (0, neverthrow.err)(configError({
|
|
187
207
|
code: "CONFIG_LOAD_FAILED",
|
|
188
|
-
message
|
|
208
|
+
message,
|
|
189
209
|
filePath,
|
|
190
210
|
cause: error
|
|
191
211
|
}));
|
|
@@ -271,6 +291,36 @@ function normalizeTsconfigPaths(tsconfigPath, configDir) {
|
|
|
271
291
|
return (0, neverthrow.ok)(result.value);
|
|
272
292
|
}
|
|
273
293
|
/**
|
|
294
|
+
* Normalize graphql-compat config to resolved form.
|
|
295
|
+
* Resolves glob patterns and validates schema name.
|
|
296
|
+
*/
|
|
297
|
+
function normalizeGraphqlCompat(graphqlCompat, schemaNames, configDir) {
|
|
298
|
+
if (!graphqlCompat) {
|
|
299
|
+
return (0, neverthrow.ok)(undefined);
|
|
300
|
+
}
|
|
301
|
+
let schemaName = graphqlCompat.schema;
|
|
302
|
+
if (!schemaName) {
|
|
303
|
+
if (schemaNames.length !== 1 || !schemaNames[0]) {
|
|
304
|
+
return (0, neverthrow.err)(configError({
|
|
305
|
+
code: "CONFIG_VALIDATION_FAILED",
|
|
306
|
+
message: "graphqlCompat.schema is required when multiple schemas are configured"
|
|
307
|
+
}));
|
|
308
|
+
}
|
|
309
|
+
schemaName = schemaNames[0];
|
|
310
|
+
}
|
|
311
|
+
if (!schemaNames.includes(schemaName)) {
|
|
312
|
+
return (0, neverthrow.err)(configError({
|
|
313
|
+
code: "CONFIG_VALIDATION_FAILED",
|
|
314
|
+
message: `graphqlCompat.schema "${schemaName}" not found in schemas config`
|
|
315
|
+
}));
|
|
316
|
+
}
|
|
317
|
+
return (0, neverthrow.ok)({
|
|
318
|
+
input: graphqlCompat.input.map((p) => resolvePattern(p, configDir)),
|
|
319
|
+
schema: schemaName,
|
|
320
|
+
suffix: graphqlCompat.suffix ?? ".compat.ts"
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
274
324
|
* Normalize codegen config to resolved form with defaults.
|
|
275
325
|
*/
|
|
276
326
|
function normalizeCodegen(codegen) {
|
|
@@ -303,6 +353,12 @@ function normalizeConfig(config, configPath) {
|
|
|
303
353
|
return (0, neverthrow.err)(combinedResult.error);
|
|
304
354
|
}
|
|
305
355
|
const normalizedSchemas = Object.fromEntries(combinedResult.value);
|
|
356
|
+
const schemaNames = Object.keys(config.schemas);
|
|
357
|
+
const graphqlCompatResult = normalizeGraphqlCompat(config.graphqlCompat, schemaNames, configDir);
|
|
358
|
+
if (graphqlCompatResult.isErr()) {
|
|
359
|
+
return (0, neverthrow.err)(graphqlCompatResult.error);
|
|
360
|
+
}
|
|
361
|
+
const graphqlCompat = graphqlCompatResult.value;
|
|
306
362
|
const resolved = {
|
|
307
363
|
analyzer,
|
|
308
364
|
baseDir: configDir,
|
|
@@ -314,6 +370,7 @@ function normalizeConfig(config, configPath) {
|
|
|
314
370
|
styles: { importExtension: config.styles?.importExtension ?? false },
|
|
315
371
|
codegen: normalizeCodegen(config.codegen),
|
|
316
372
|
plugins: config.plugins ?? {},
|
|
373
|
+
...graphqlCompat ? { graphqlCompat } : {},
|
|
317
374
|
...artifact ? { artifact } : {},
|
|
318
375
|
...tsconfigPaths ? { tsconfigPaths } : {}
|
|
319
376
|
};
|
|
@@ -344,6 +401,43 @@ function findConfigFile(startDir = process.cwd()) {
|
|
|
344
401
|
}
|
|
345
402
|
return null;
|
|
346
403
|
}
|
|
404
|
+
const SKIP_DIRS = new Set(["node_modules", "dist"]);
|
|
405
|
+
/**
|
|
406
|
+
* Find all config files by walking down from rootDir.
|
|
407
|
+
* Discovers every soda-gql config file in the directory tree,
|
|
408
|
+
* skipping node_modules, dist, and dot-prefixed directories.
|
|
409
|
+
*/
|
|
410
|
+
function findAllConfigFiles(rootDir) {
|
|
411
|
+
const results = [];
|
|
412
|
+
const walk = (dir) => {
|
|
413
|
+
for (const filename of DEFAULT_CONFIG_FILENAMES) {
|
|
414
|
+
const configPath = (0, node_path.join)(dir, filename);
|
|
415
|
+
if ((0, node_fs.existsSync)(configPath)) {
|
|
416
|
+
results.push(configPath);
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
let entries;
|
|
421
|
+
try {
|
|
422
|
+
entries = (0, node_fs.readdirSync)(dir);
|
|
423
|
+
} catch {
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
for (const entry of entries) {
|
|
427
|
+
if (SKIP_DIRS.has(entry) || entry.startsWith(".")) {
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
const fullPath = (0, node_path.join)(dir, entry);
|
|
431
|
+
try {
|
|
432
|
+
if ((0, node_fs.statSync)(fullPath).isDirectory()) {
|
|
433
|
+
walk(fullPath);
|
|
434
|
+
}
|
|
435
|
+
} catch {}
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
walk(rootDir);
|
|
439
|
+
return results;
|
|
440
|
+
}
|
|
347
441
|
/**
|
|
348
442
|
* Load config with Result type (for library use).
|
|
349
443
|
*/
|
|
@@ -383,6 +477,7 @@ function loadConfigFrom(dir) {
|
|
|
383
477
|
var src_exports = /* @__PURE__ */ __export({
|
|
384
478
|
configError: () => configError,
|
|
385
479
|
defineConfig: () => defineConfig,
|
|
480
|
+
findAllConfigFiles: () => findAllConfigFiles,
|
|
386
481
|
findConfigFile: () => findConfigFile,
|
|
387
482
|
loadConfig: () => loadConfig,
|
|
388
483
|
loadConfigFrom: () => loadConfigFrom,
|
|
@@ -393,6 +488,7 @@ var src_exports = /* @__PURE__ */ __export({
|
|
|
393
488
|
//#endregion
|
|
394
489
|
exports.configError = configError;
|
|
395
490
|
exports.defineConfig = defineConfig;
|
|
491
|
+
exports.findAllConfigFiles = findAllConfigFiles;
|
|
396
492
|
exports.findConfigFile = findConfigFile;
|
|
397
493
|
exports.loadConfig = loadConfig;
|
|
398
494
|
exports.loadConfigFrom = loadConfigFrom;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["config: SodaGqlConfig","InjectConfigSchema: z.ZodType<InjectConfig>","z","SchemaInputSchema: z.ZodType<SchemaInput>","TypeFilterConfigSchema: z.ZodType<TypeFilterConfig | undefined>","mod: { exports: unknown }","require","configModule","Script","Result","resolved: ResolvedSodaGqlConfig"],"sources":["../src/errors.ts","../src/helper.ts","../src/evaluation.ts","../src/normalize.ts","../src/loader.ts","../src/index.ts"],"sourcesContent":["export type ConfigErrorCode = \"CONFIG_NOT_FOUND\" | \"CONFIG_LOAD_FAILED\" | \"CONFIG_VALIDATION_FAILED\" | \"CONFIG_INVALID_PATH\";\n\nexport type ConfigError = {\n readonly code: ConfigErrorCode;\n readonly message: string;\n readonly filePath?: string;\n readonly cause?: unknown;\n};\n\nexport const configError = ({\n code,\n message,\n filePath,\n cause,\n}: {\n code: ConfigErrorCode;\n message: string;\n filePath?: string;\n cause?: unknown;\n}): ConfigError => ({\n code,\n message,\n filePath,\n cause,\n});\n","import { defineSchemaFor } from \"@soda-gql/common\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport z from \"zod\";\nimport { type ConfigError, configError } from \"./errors\";\nimport type {\n ArtifactConfig,\n CodegenConfig,\n InjectConfig,\n SchemaConfig,\n SchemaInput,\n SodaGqlConfig,\n StylesConfig,\n TypeFilterConfig,\n} from \"./types\";\n\n/**\n * Thin wrapper class to simplify the validation of exported value from config file.\n * As we use SWC + VM to execute the config file, the exported value is not typed.\n * This wrapper class ensures the exported value is a valid soda-gql config object.\n */\nexport class SodaGqlConfigContainer {\n private constructor(public readonly config: SodaGqlConfig) {}\n\n public static create(config: SodaGqlConfig): SodaGqlConfigContainer {\n return new SodaGqlConfigContainer(config);\n }\n}\n\n/**\n * Type-safe helper for defining soda-gql configuration.\n * Supports both static and dynamic (async) configs.\n *\n * @example Static config with object inject\n * ```ts\n * import { defineConfig } from \"@soda-gql/config\";\n *\n * export default defineConfig({\n * outdir: \"./graphql-system\",\n * include: [\"./src/**\\/*.ts\"],\n * schemas: {\n * default: {\n * schema: \"./schema.graphql\",\n * inject: { scalars: \"./scalars.ts\" },\n * },\n * },\n * });\n * ```\n *\n * @example Static config with string inject (single file)\n * ```ts\n * export default defineConfig({\n * outdir: \"./graphql-system\",\n * include: [\"./src/**\\/*.ts\"],\n * schemas: {\n * default: {\n * schema: \"./schema.graphql\",\n * inject: \"./inject.ts\", // exports scalar, adapter?\n * },\n * },\n * });\n * ```\n */\nexport function defineConfig(config: SodaGqlConfig): SodaGqlConfigContainer;\nexport function defineConfig(config: () => SodaGqlConfig): SodaGqlConfigContainer;\nexport function defineConfig(config: SodaGqlConfig | (() => SodaGqlConfig)): SodaGqlConfigContainer {\n const validated = validateConfig(typeof config === \"function\" ? config() : config);\n if (validated.isErr()) {\n throw validated.error;\n }\n return SodaGqlConfigContainer.create(validated.value);\n}\n\n// InjectConfig is a union type (string | object), so we define the schema directly\n// rather than using defineSchemaFor which requires object types\nconst InjectConfigSchema: z.ZodType<InjectConfig> = z.union([\n z.string().min(1),\n z.object({\n scalars: z.string().min(1),\n adapter: z.string().min(1).optional(),\n }),\n]);\n\n// SchemaInput supports string, array of strings, or function returning array of strings\n// Function return value validation is deferred to normalize time\nconst SchemaInputSchema: z.ZodType<SchemaInput> = z.union([\n z.string().min(1),\n z.array(z.string().min(1)).min(1),\n z.custom<() => readonly string[]>((val) => typeof val === \"function\"),\n]);\n\n// TypeCategory enum for type filtering\nconst TypeCategorySchema = z.enum([\"object\", \"input\", \"enum\", \"union\", \"scalar\"]);\n\n// TypeFilterRule validates pattern and optional category\nconst TypeFilterRuleSchema = z.object({\n pattern: z.string().min(1),\n category: z.union([TypeCategorySchema, z.array(TypeCategorySchema).min(1)]).optional(),\n});\n\n// TypeFilterConfig supports function or object with exclude rules\n// Function signature validation is deferred to runtime (compileTypeFilter)\nconst TypeFilterConfigSchema: z.ZodType<TypeFilterConfig | undefined> = z\n .union([\n z.custom<TypeFilterConfig>((val) => typeof val === \"function\"),\n z.object({\n exclude: z.array(TypeFilterRuleSchema).min(1),\n }),\n ])\n .optional();\n\nconst SchemaConfigSchema = defineSchemaFor<SchemaConfig>()({\n schema: SchemaInputSchema,\n inject: InjectConfigSchema,\n defaultInputDepth: z.number().int().positive().max(10).optional(),\n inputDepthOverrides: z.record(z.string(), z.number().int().positive()).optional(),\n typeFilter: TypeFilterConfigSchema,\n});\n\nconst StylesConfigSchema = defineSchemaFor<StylesConfig>()({\n importExtension: z.boolean().optional(),\n});\n\nconst CodegenConfigSchema = defineSchemaFor<CodegenConfig>()({\n chunkSize: z.number().int().positive().optional(),\n});\n\nconst ArtifactConfigSchema = defineSchemaFor<ArtifactConfig>()({\n path: z.string().min(1).optional(),\n});\n\nconst SodaGqlConfigSchema = defineSchemaFor<SodaGqlConfig>()({\n analyzer: z.enum([\"ts\", \"swc\"]).optional(),\n outdir: z.string().min(1),\n graphqlSystemAliases: z.array(z.string()).optional(),\n tsconfigPath: z.string().min(1).optional(),\n include: z.array(z.string().min(1)),\n exclude: z.array(z.string().min(1)).optional(),\n schemas: z.record(z.string(), SchemaConfigSchema),\n styles: StylesConfigSchema.optional(),\n codegen: CodegenConfigSchema.optional(),\n plugins: z.record(z.string(), z.unknown()).optional(),\n artifact: ArtifactConfigSchema.optional(),\n});\n\nexport function validateConfig(config: unknown): Result<SodaGqlConfig, ConfigError> {\n const result = SodaGqlConfigSchema.safeParse(config);\n\n if (!result.success) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: `Invalid config: ${result.error.message}`,\n }),\n );\n }\n\n return ok(result.data satisfies SodaGqlConfig);\n}\n","import { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path/posix\";\nimport { Script } from \"node:vm\";\nimport { resolveRelativeImportWithExistenceCheck } from \"@soda-gql/common\";\nimport { transformSync } from \"@swc/core\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport { type ConfigError, configError } from \"./errors\";\nimport { SodaGqlConfigContainer } from \"./helper\";\n// TODO: split config package into definition and evaluation parts\nimport * as configModule from \"./index\";\nimport type { SodaGqlConfig } from \"./types\";\n\n/**\n * Load and execute TypeScript config file synchronously using SWC + VM.\n */\nexport function executeConfigFile(configPath: string): Result<SodaGqlConfig, ConfigError> {\n const filePath = resolve(configPath);\n try {\n // Read the config file\n const source = readFileSync(filePath, \"utf-8\");\n\n // Transform TypeScript to CommonJS using SWC\n const result = transformSync(source, {\n filename: filePath,\n jsc: {\n parser: {\n syntax: \"typescript\",\n },\n },\n module: {\n type: \"commonjs\",\n },\n sourceMaps: false,\n minify: false,\n });\n\n // Create CommonJS context\n const mod: { exports: unknown } = { exports: {} };\n\n const requireInner = createRequire(filePath);\n const require = (specifier: string) => {\n if (specifier === \"@soda-gql/config\") {\n return configModule;\n }\n\n // Handle external modules normally\n if (!specifier.startsWith(\".\")) {\n return requireInner(specifier);\n }\n\n // Resolve relative imports with existence check\n const resolvedPath = resolveRelativeImportWithExistenceCheck({ filePath, specifier });\n if (!resolvedPath) {\n throw new Error(`Module not found: ${specifier}`);\n }\n return requireInner(resolvedPath);\n };\n\n // Execute in VM context\n new Script(result.code, { filename: filePath }).runInNewContext({\n require,\n module: mod,\n exports: mod.exports,\n __dirname: dirname(filePath),\n __filename: filePath,\n console,\n process,\n });\n\n const config =\n mod.exports &&\n typeof mod.exports === \"object\" &&\n \"default\" in mod.exports &&\n mod.exports.default instanceof SodaGqlConfigContainer\n ? mod.exports.default.config\n : null;\n\n if (!config) {\n throw new Error(\"Invalid config module\");\n }\n\n return ok(config);\n } catch (error) {\n return err(\n configError({\n code: \"CONFIG_LOAD_FAILED\",\n message: `Failed to load config: ${error instanceof Error ? error.message : String(error)}`,\n filePath: filePath,\n cause: error,\n }),\n );\n }\n}\n","import { dirname, resolve } from \"node:path\";\nimport { readTsconfigPaths } from \"@soda-gql/common\";\nimport { err, ok, Result } from \"neverthrow\";\nimport { type ConfigError, configError } from \"./errors\";\nimport type {\n InjectConfig,\n ResolvedArtifactConfig,\n ResolvedCodegenConfig,\n ResolvedInjectConfig,\n ResolvedSodaGqlConfig,\n ResolvedTsconfigPaths,\n SchemaInput,\n SodaGqlConfig,\n} from \"./types\";\n\n/**\n * Normalize schema input to resolved array form.\n * String is converted to single-element array.\n * Function is executed to get the array.\n * All paths are resolved relative to config directory.\n */\nfunction normalizeSchemaInput(schema: SchemaInput, configDir: string): Result<readonly string[], ConfigError> {\n // Execute function if provided\n const paths = typeof schema === \"function\" ? schema() : schema;\n // Normalize single string to array\n const pathArray = typeof paths === \"string\" ? [paths] : paths;\n\n // Runtime validation: empty array check\n if (pathArray.length === 0) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: \"Schema paths cannot be empty\",\n }),\n );\n }\n\n return ok(pathArray.map((p) => resolve(configDir, p)));\n}\n\n/**\n * Normalize inject config to resolved object form.\n * String form is converted to object with same path for all fields.\n */\nfunction normalizeInject(inject: InjectConfig, configDir: string): ResolvedInjectConfig {\n if (typeof inject === \"string\") {\n const resolvedPath = resolve(configDir, inject);\n return {\n scalars: resolvedPath,\n adapter: resolvedPath,\n };\n }\n return {\n scalars: resolve(configDir, inject.scalars),\n ...(inject.adapter ? { adapter: resolve(configDir, inject.adapter) } : {}),\n };\n}\n\n/**\n * Resolve a glob pattern relative to the config directory.\n * Handles negation patterns (e.g., \"!./path/to/exclude\") by preserving the \"!\" prefix.\n */\nfunction resolvePattern(pattern: string, configDir: string): string {\n if (pattern.startsWith(\"!\")) {\n // Preserve the negation prefix, resolve the rest\n return `!${resolve(configDir, pattern.slice(1))}`;\n }\n return resolve(configDir, pattern);\n}\n\n/**\n * Normalize artifact config to resolved form.\n * Returns undefined if no path is specified.\n */\nfunction normalizeArtifact(artifact: SodaGqlConfig[\"artifact\"], configDir: string): ResolvedArtifactConfig | undefined {\n if (!artifact?.path) {\n return undefined;\n }\n return {\n path: resolve(configDir, artifact.path),\n };\n}\n\n/**\n * Normalize tsconfig paths configuration.\n * Reads tsconfig.json and extracts paths if defined.\n * Returns undefined if no tsconfigPath is specified or no paths are defined.\n */\nfunction normalizeTsconfigPaths(\n tsconfigPath: string | undefined,\n configDir: string,\n): Result<ResolvedTsconfigPaths | undefined, ConfigError> {\n if (!tsconfigPath) {\n return ok(undefined);\n }\n\n const resolvedPath = resolve(configDir, tsconfigPath);\n const result = readTsconfigPaths(resolvedPath);\n\n if (result.isErr()) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: result.error.message,\n }),\n );\n }\n\n // Return undefined if no paths defined in tsconfig\n if (result.value === null) {\n return ok(undefined);\n }\n\n return ok(result.value);\n}\n\n/**\n * Normalize codegen config to resolved form with defaults.\n */\nfunction normalizeCodegen(codegen: SodaGqlConfig[\"codegen\"]): ResolvedCodegenConfig {\n return {\n chunkSize: codegen?.chunkSize ?? 100,\n };\n}\n\n/**\n * Resolve and normalize config with defaults.\n * Paths in the config are resolved relative to the config file's directory.\n */\nexport function normalizeConfig(config: SodaGqlConfig, configPath: string): Result<ResolvedSodaGqlConfig, ConfigError> {\n const configDir = dirname(configPath);\n // Default analyzer to \"ts\"\n const analyzer = config.analyzer ?? \"ts\";\n\n // Default graphqlSystemAliases to [\"@/graphql-system\"]\n const graphqlSystemAliases = config.graphqlSystemAliases ?? [\"@/graphql-system\"];\n\n // Default exclude to empty array\n const exclude = config.exclude ?? [];\n\n // Normalize artifact config (only if path is specified)\n const artifact = normalizeArtifact(config.artifact, configDir);\n\n // Normalize tsconfig paths (only if path is specified and paths exist)\n const tsconfigPathsResult = normalizeTsconfigPaths(config.tsconfigPath, configDir);\n if (tsconfigPathsResult.isErr()) {\n return err(tsconfigPathsResult.error);\n }\n const tsconfigPaths = tsconfigPathsResult.value;\n\n // Normalize schemas with error handling\n const schemaEntries = Object.entries(config.schemas).map(([name, schemaConfig]) =>\n normalizeSchemaInput(schemaConfig.schema, configDir).map(\n (schema) =>\n [\n name,\n {\n schema,\n inject: normalizeInject(schemaConfig.inject, configDir),\n defaultInputDepth: schemaConfig.defaultInputDepth ?? 3,\n inputDepthOverrides: schemaConfig.inputDepthOverrides ?? {},\n ...(schemaConfig.typeFilter ? { typeFilter: schemaConfig.typeFilter } : {}),\n },\n ] as const,\n ),\n );\n\n const combinedResult = Result.combine(schemaEntries);\n if (combinedResult.isErr()) {\n return err(combinedResult.error);\n }\n const normalizedSchemas = Object.fromEntries(combinedResult.value);\n\n const resolved: ResolvedSodaGqlConfig = {\n analyzer,\n baseDir: configDir,\n outdir: resolve(configDir, config.outdir),\n graphqlSystemAliases,\n include: config.include.map((pattern) => resolvePattern(pattern, configDir)),\n exclude: exclude.map((pattern) => resolvePattern(pattern, configDir)),\n schemas: normalizedSchemas,\n styles: {\n importExtension: config.styles?.importExtension ?? false,\n },\n codegen: normalizeCodegen(config.codegen),\n plugins: config.plugins ?? {},\n ...(artifact ? { artifact } : {}),\n ...(tsconfigPaths ? { tsconfigPaths } : {}),\n };\n\n return ok(resolved);\n}\n","import { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport type { Result } from \"neverthrow\";\nimport { err } from \"neverthrow\";\nimport type { ConfigError } from \"./errors\";\nimport { configError } from \"./errors\";\nimport { executeConfigFile } from \"./evaluation\";\nimport { normalizeConfig } from \"./normalize\";\nimport type { ResolvedSodaGqlConfig } from \"./types\";\n\nexport const DEFAULT_CONFIG_FILENAMES = [\n \"soda-gql.config.ts\",\n \"soda-gql.config.mts\",\n \"soda-gql.config.js\",\n \"soda-gql.config.mjs\",\n] as const;\n\n/**\n * Find config file by walking up directory tree.\n */\nexport function findConfigFile(startDir: string = process.cwd()): string | null {\n let currentDir = startDir;\n while (currentDir !== dirname(currentDir)) {\n for (const filename of DEFAULT_CONFIG_FILENAMES) {\n const configPath = join(currentDir, filename);\n if (existsSync(configPath)) {\n return configPath;\n }\n }\n currentDir = dirname(currentDir);\n }\n return null;\n}\n\n/**\n * Load config with Result type (for library use).\n */\nexport function loadConfig(configPath: string | undefined): Result<ResolvedSodaGqlConfig, ConfigError> {\n const resolvedPath = configPath ?? findConfigFile();\n\n if (!resolvedPath) {\n return err(configError({ code: \"CONFIG_NOT_FOUND\", message: \"Config file not found\" }));\n }\n\n try {\n const result = executeConfigFile(resolvedPath);\n if (result.isErr()) {\n return err(result.error);\n }\n return normalizeConfig(result.value, resolvedPath);\n } catch (error) {\n return err(\n configError({\n code: \"CONFIG_LOAD_FAILED\",\n message: `Failed to load config: ${error instanceof Error ? error.message : String(error)}`,\n filePath: resolvedPath,\n cause: error,\n }),\n );\n }\n}\n\n/**\n * Load config from specific directory.\n */\nexport function loadConfigFrom(dir: string): Result<ResolvedSodaGqlConfig, ConfigError> {\n const configPath = findConfigFile(dir);\n return loadConfig(configPath ?? undefined);\n}\n","export type { ConfigError, ConfigErrorCode } from \"./errors\";\nexport { configError } from \"./errors\";\nexport {\n defineConfig,\n type SodaGqlConfigContainer,\n validateConfig,\n} from \"./helper\";\nexport { findConfigFile, loadConfig, loadConfigFrom } from \"./loader\";\nexport { normalizeConfig } from \"./normalize\";\nexport type {\n ArtifactConfig,\n PluginConfig,\n ResolvedArtifactConfig,\n ResolvedSodaGqlConfig,\n ResolvedTsconfigPaths,\n SchemaConfig,\n SodaGqlConfig,\n TypeCategory,\n TypeFilterConfig,\n TypeFilterRule,\n} from \"./types\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAa,eAAe,EAC1B,MACA,SACA,UACA,aAMkB;CAClB;CACA;CACA;CACA;CACD;;;;;;;;;ACJD,IAAa,yBAAb,MAAa,uBAAuB;CAClC,AAAQ,YAAY,AAAgBA,QAAuB;EAAvB;;CAEpC,OAAc,OAAO,QAA+C;AAClE,SAAO,IAAI,uBAAuB,OAAO;;;AAwC7C,SAAgB,aAAa,QAAuE;CAClG,MAAM,YAAY,eAAe,OAAO,WAAW,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AAY,0BAA0B;GAC/C,MAAM,iCAAkB,YAAY,SAAS;AAC7C,+BAAe,WAAW,EAAE;AAC1B,WAAO;;;AAGX,sCAAqB,WAAW;;AAElC,QAAO;;;;;AAMT,SAAgB,WAAW,YAA4E;CACrG,MAAM,eAAe,cAAc,gBAAgB;AAEnD,KAAI,CAAC,cAAc;AACjB,6BAAW,YAAY;GAAE,MAAM;GAAoB,SAAS;GAAyB,CAAC,CAAC;;AAGzF,KAAI;EACF,MAAM,SAAS,kBAAkB,aAAa;AAC9C,MAAI,OAAO,OAAO,EAAE;AAClB,8BAAW,OAAO,MAAM;;AAE1B,SAAO,gBAAgB,OAAO,OAAO,aAAa;UAC3C,OAAO;AACd,6BACE,YAAY;GACV,MAAM;GACN,SAAS,0BAA0B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;GACzF,UAAU;GACV,OAAO;GACR,CAAC,CACH;;;;;;AAOL,SAAgB,eAAe,KAAyD;CACtF,MAAM,aAAa,eAAe,IAAI;AACtC,QAAO,WAAW,cAAc,UAAU"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["config: SodaGqlConfig","InjectConfigSchema: z.ZodType<InjectConfig>","z","SchemaInputSchema: z.ZodType<SchemaInput>","TypeFilterConfigSchema: z.ZodType<TypeFilterConfig | undefined>","mod: { exports: unknown }","require","configModule","Script","Result","resolved: ResolvedSodaGqlConfig","results: string[]","entries: string[]"],"sources":["../src/errors.ts","../src/helper.ts","../src/evaluation.ts","../src/normalize.ts","../src/loader.ts","../src/index.ts"],"sourcesContent":["export type ConfigErrorCode = \"CONFIG_NOT_FOUND\" | \"CONFIG_LOAD_FAILED\" | \"CONFIG_VALIDATION_FAILED\" | \"CONFIG_INVALID_PATH\";\n\nexport type ConfigError = {\n readonly code: ConfigErrorCode;\n readonly message: string;\n readonly filePath?: string;\n readonly cause?: unknown;\n};\n\nexport const configError = ({\n code,\n message,\n filePath,\n cause,\n}: {\n code: ConfigErrorCode;\n message: string;\n filePath?: string;\n cause?: unknown;\n}): ConfigError => ({\n code,\n message,\n filePath,\n cause,\n});\n","import { defineSchemaFor } from \"@soda-gql/common\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport z from \"zod\";\nimport { type ConfigError, configError } from \"./errors\";\nimport type {\n ArtifactConfig,\n CodegenConfig,\n GraphqlCompatConfig,\n InjectConfig,\n SchemaConfig,\n SchemaInput,\n SodaGqlConfig,\n StylesConfig,\n TypeFilterConfig,\n} from \"./types\";\n\n/**\n * Thin wrapper class to simplify the validation of exported value from config file.\n * As we use SWC + VM to execute the config file, the exported value is not typed.\n * This wrapper class ensures the exported value is a valid soda-gql config object.\n */\nexport class SodaGqlConfigContainer {\n private constructor(public readonly config: SodaGqlConfig) {}\n\n public static create(config: SodaGqlConfig): SodaGqlConfigContainer {\n return new SodaGqlConfigContainer(config);\n }\n}\n\n/**\n * Type-safe helper for defining soda-gql configuration.\n * Supports both static and dynamic (async) configs.\n *\n * @example Static config with object inject\n * ```ts\n * import { defineConfig } from \"@soda-gql/config\";\n *\n * export default defineConfig({\n * outdir: \"./graphql-system\",\n * include: [\"./src/**\\/*.ts\"],\n * schemas: {\n * default: {\n * schema: \"./schema.graphql\",\n * inject: { scalars: \"./scalars.ts\" },\n * },\n * },\n * });\n * ```\n *\n * @example Static config with string inject (single file)\n * ```ts\n * export default defineConfig({\n * outdir: \"./graphql-system\",\n * include: [\"./src/**\\/*.ts\"],\n * schemas: {\n * default: {\n * schema: \"./schema.graphql\",\n * inject: \"./inject.ts\", // exports scalar, adapter?\n * },\n * },\n * });\n * ```\n */\nexport function defineConfig(config: SodaGqlConfig): SodaGqlConfigContainer;\nexport function defineConfig(config: () => SodaGqlConfig): SodaGqlConfigContainer;\nexport function defineConfig(config: SodaGqlConfig | (() => SodaGqlConfig)): SodaGqlConfigContainer {\n const validated = validateConfig(typeof config === \"function\" ? config() : config);\n if (validated.isErr()) {\n throw validated.error;\n }\n return SodaGqlConfigContainer.create(validated.value);\n}\n\n// InjectConfig is a union type (string | object), so we define the schema directly\n// rather than using defineSchemaFor which requires object types\nconst InjectConfigSchema: z.ZodType<InjectConfig> = z.union([\n z.string().min(1),\n z.object({\n scalars: z.string().min(1),\n adapter: z.string().min(1).optional(),\n }),\n]);\n\n// SchemaInput supports string, array of strings, or function returning array of strings\n// Function return value validation is deferred to normalize time\nconst SchemaInputSchema: z.ZodType<SchemaInput> = z.union([\n z.string().min(1),\n z.array(z.string().min(1)).min(1),\n z.custom<() => readonly string[]>((val) => typeof val === \"function\"),\n]);\n\n// TypeCategory enum for type filtering\nconst TypeCategorySchema = z.enum([\"object\", \"input\", \"enum\", \"union\", \"scalar\"]);\n\n// TypeFilterRule validates pattern and optional category\nconst TypeFilterRuleSchema = z.object({\n pattern: z.string().min(1),\n category: z.union([TypeCategorySchema, z.array(TypeCategorySchema).min(1)]).optional(),\n});\n\n// TypeFilterConfig supports function or object with exclude rules\n// Function signature validation is deferred to runtime (compileTypeFilter)\nconst TypeFilterConfigSchema: z.ZodType<TypeFilterConfig | undefined> = z\n .union([\n z.custom<TypeFilterConfig>((val) => typeof val === \"function\"),\n z.object({\n exclude: z.array(TypeFilterRuleSchema).min(1),\n }),\n ])\n .optional();\n\nconst SchemaConfigSchema = defineSchemaFor<SchemaConfig>()({\n schema: SchemaInputSchema,\n inject: InjectConfigSchema,\n defaultInputDepth: z.number().int().positive().max(10).optional(),\n inputDepthOverrides: z.record(z.string(), z.number().int().positive()).optional(),\n typeFilter: TypeFilterConfigSchema,\n});\n\nconst StylesConfigSchema = defineSchemaFor<StylesConfig>()({\n importExtension: z.boolean().optional(),\n});\n\nconst CodegenConfigSchema = defineSchemaFor<CodegenConfig>()({\n chunkSize: z.number().int().positive().optional(),\n});\n\nconst GraphqlCompatConfigSchema = defineSchemaFor<GraphqlCompatConfig>()({\n input: z.array(z.string().min(1)),\n schema: z.string().min(1).optional(),\n suffix: z.string().min(1).optional(),\n});\n\nconst ArtifactConfigSchema = defineSchemaFor<ArtifactConfig>()({\n path: z.string().min(1).optional(),\n});\n\nconst SodaGqlConfigSchema = defineSchemaFor<SodaGqlConfig>()({\n analyzer: z.enum([\"ts\", \"swc\"]).optional(),\n outdir: z.string().min(1),\n graphqlSystemAliases: z.array(z.string()).optional(),\n tsconfigPath: z.string().min(1).optional(),\n include: z.array(z.string().min(1)),\n exclude: z.array(z.string().min(1)).optional(),\n schemas: z.record(z.string(), SchemaConfigSchema),\n styles: StylesConfigSchema.optional(),\n codegen: CodegenConfigSchema.optional(),\n plugins: z.record(z.string(), z.unknown()).optional(),\n graphqlCompat: GraphqlCompatConfigSchema.optional(),\n artifact: ArtifactConfigSchema.optional(),\n});\n\nexport function validateConfig(config: unknown): Result<SodaGqlConfig, ConfigError> {\n const result = SodaGqlConfigSchema.safeParse(config);\n\n if (!result.success) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: `Invalid config: ${result.error.message}`,\n }),\n );\n }\n\n return ok(result.data satisfies SodaGqlConfig);\n}\n","import { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path/posix\";\nimport { Script } from \"node:vm\";\nimport { resolveRelativeImportWithExistenceCheck } from \"@soda-gql/common\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport { type ConfigError, configError } from \"./errors\";\nimport { SodaGqlConfigContainer } from \"./helper\";\n// TODO: split config package into definition and evaluation parts\nimport * as configModule from \"./index\";\nimport type { SodaGqlConfig } from \"./types\";\n\ntype TransformSync = typeof import(\"@swc/core\").transformSync;\n\n/** Lazily resolve @swc/core from the config file's directory, falling back to package resolution. */\nconst resolveSwc = (configPath: string): TransformSync => {\n try {\n const localRequire = createRequire(configPath);\n return localRequire(\"@swc/core\").transformSync;\n } catch (primaryError) {\n // import.meta.url is undefined in CJS bundles (esbuild replaces import.meta with {})\n if (typeof import.meta.url !== \"string\") {\n throw primaryError;\n }\n // Fall back to package-level resolution (e.g., during tests or when user relies on bundled swc)\n const packageRequire = createRequire(import.meta.url);\n return packageRequire(\"@swc/core\").transformSync;\n }\n};\n\n/**\n * Load and execute TypeScript config file synchronously using SWC + VM.\n */\nexport function executeConfigFile(configPath: string): Result<SodaGqlConfig, ConfigError> {\n const filePath = resolve(configPath);\n try {\n const transformSync = resolveSwc(filePath);\n\n // Read the config file\n const source = readFileSync(filePath, \"utf-8\");\n\n // Transform TypeScript to CommonJS using SWC\n const result = transformSync(source, {\n filename: filePath,\n jsc: {\n parser: {\n syntax: \"typescript\",\n },\n },\n module: {\n type: \"commonjs\",\n },\n sourceMaps: false,\n minify: false,\n });\n\n // Create CommonJS context\n const mod: { exports: unknown } = { exports: {} };\n\n const requireInner = createRequire(filePath);\n const require = (specifier: string) => {\n if (specifier === \"@soda-gql/config\") {\n return configModule;\n }\n\n // Handle external modules normally\n if (!specifier.startsWith(\".\")) {\n return requireInner(specifier);\n }\n\n // Resolve relative imports with existence check\n const resolvedPath = resolveRelativeImportWithExistenceCheck({ filePath, specifier });\n if (!resolvedPath) {\n throw new Error(`Module not found: ${specifier}`);\n }\n return requireInner(resolvedPath);\n };\n\n // Execute in VM context\n new Script(result.code, { filename: filePath }).runInNewContext({\n require,\n module: mod,\n exports: mod.exports,\n __dirname: dirname(filePath),\n __filename: filePath,\n console,\n process,\n });\n\n const config =\n mod.exports &&\n typeof mod.exports === \"object\" &&\n \"default\" in mod.exports &&\n mod.exports.default instanceof SodaGqlConfigContainer\n ? mod.exports.default.config\n : null;\n\n if (!config) {\n throw new Error(\"Invalid config module\");\n }\n\n return ok(config);\n } catch (error) {\n const message =\n error instanceof Error && error.message.includes(\"Cannot find module '@swc/core'\")\n ? \"@swc/core not found. Install it in your project: bun add -D @swc/core\"\n : `Failed to load config: ${error instanceof Error ? error.message : String(error)}`;\n return err(\n configError({\n code: \"CONFIG_LOAD_FAILED\",\n message,\n filePath: filePath,\n cause: error,\n }),\n );\n }\n}\n","import { dirname, resolve } from \"node:path\";\nimport { readTsconfigPaths } from \"@soda-gql/common\";\nimport { err, ok, Result } from \"neverthrow\";\nimport { type ConfigError, configError } from \"./errors\";\nimport type {\n GraphqlCompatConfig,\n InjectConfig,\n ResolvedArtifactConfig,\n ResolvedCodegenConfig,\n ResolvedGraphqlCompatConfig,\n ResolvedInjectConfig,\n ResolvedSodaGqlConfig,\n ResolvedTsconfigPaths,\n SchemaInput,\n SodaGqlConfig,\n} from \"./types\";\n\n/**\n * Normalize schema input to resolved array form.\n * String is converted to single-element array.\n * Function is executed to get the array.\n * All paths are resolved relative to config directory.\n */\nfunction normalizeSchemaInput(schema: SchemaInput, configDir: string): Result<readonly string[], ConfigError> {\n // Execute function if provided\n const paths = typeof schema === \"function\" ? schema() : schema;\n // Normalize single string to array\n const pathArray = typeof paths === \"string\" ? [paths] : paths;\n\n // Runtime validation: empty array check\n if (pathArray.length === 0) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: \"Schema paths cannot be empty\",\n }),\n );\n }\n\n return ok(pathArray.map((p) => resolve(configDir, p)));\n}\n\n/**\n * Normalize inject config to resolved object form.\n * String form is converted to object with same path for all fields.\n */\nfunction normalizeInject(inject: InjectConfig, configDir: string): ResolvedInjectConfig {\n if (typeof inject === \"string\") {\n const resolvedPath = resolve(configDir, inject);\n return {\n scalars: resolvedPath,\n adapter: resolvedPath,\n };\n }\n return {\n scalars: resolve(configDir, inject.scalars),\n ...(inject.adapter ? { adapter: resolve(configDir, inject.adapter) } : {}),\n };\n}\n\n/**\n * Resolve a glob pattern relative to the config directory.\n * Handles negation patterns (e.g., \"!./path/to/exclude\") by preserving the \"!\" prefix.\n */\nfunction resolvePattern(pattern: string, configDir: string): string {\n if (pattern.startsWith(\"!\")) {\n // Preserve the negation prefix, resolve the rest\n return `!${resolve(configDir, pattern.slice(1))}`;\n }\n return resolve(configDir, pattern);\n}\n\n/**\n * Normalize artifact config to resolved form.\n * Returns undefined if no path is specified.\n */\nfunction normalizeArtifact(artifact: SodaGqlConfig[\"artifact\"], configDir: string): ResolvedArtifactConfig | undefined {\n if (!artifact?.path) {\n return undefined;\n }\n return {\n path: resolve(configDir, artifact.path),\n };\n}\n\n/**\n * Normalize tsconfig paths configuration.\n * Reads tsconfig.json and extracts paths if defined.\n * Returns undefined if no tsconfigPath is specified or no paths are defined.\n */\nfunction normalizeTsconfigPaths(\n tsconfigPath: string | undefined,\n configDir: string,\n): Result<ResolvedTsconfigPaths | undefined, ConfigError> {\n if (!tsconfigPath) {\n return ok(undefined);\n }\n\n const resolvedPath = resolve(configDir, tsconfigPath);\n const result = readTsconfigPaths(resolvedPath);\n\n if (result.isErr()) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: result.error.message,\n }),\n );\n }\n\n // Return undefined if no paths defined in tsconfig\n if (result.value === null) {\n return ok(undefined);\n }\n\n return ok(result.value);\n}\n\n/**\n * Normalize graphql-compat config to resolved form.\n * Resolves glob patterns and validates schema name.\n */\nfunction normalizeGraphqlCompat(\n graphqlCompat: GraphqlCompatConfig | undefined,\n schemaNames: readonly string[],\n configDir: string,\n): Result<ResolvedGraphqlCompatConfig | undefined, ConfigError> {\n if (!graphqlCompat) {\n return ok(undefined);\n }\n\n let schemaName = graphqlCompat.schema;\n if (!schemaName) {\n if (schemaNames.length !== 1 || !schemaNames[0]) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: \"graphqlCompat.schema is required when multiple schemas are configured\",\n }),\n );\n }\n schemaName = schemaNames[0];\n }\n\n if (!schemaNames.includes(schemaName)) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: `graphqlCompat.schema \"${schemaName}\" not found in schemas config`,\n }),\n );\n }\n\n return ok({\n input: graphqlCompat.input.map((p) => resolvePattern(p, configDir)),\n schema: schemaName,\n suffix: graphqlCompat.suffix ?? \".compat.ts\",\n });\n}\n\n/**\n * Normalize codegen config to resolved form with defaults.\n */\nfunction normalizeCodegen(codegen: SodaGqlConfig[\"codegen\"]): ResolvedCodegenConfig {\n return {\n chunkSize: codegen?.chunkSize ?? 100,\n };\n}\n\n/**\n * Resolve and normalize config with defaults.\n * Paths in the config are resolved relative to the config file's directory.\n */\nexport function normalizeConfig(config: SodaGqlConfig, configPath: string): Result<ResolvedSodaGqlConfig, ConfigError> {\n const configDir = dirname(configPath);\n // Default analyzer to \"ts\"\n const analyzer = config.analyzer ?? \"ts\";\n\n // Default graphqlSystemAliases to [\"@/graphql-system\"]\n const graphqlSystemAliases = config.graphqlSystemAliases ?? [\"@/graphql-system\"];\n\n // Default exclude to empty array\n const exclude = config.exclude ?? [];\n\n // Normalize artifact config (only if path is specified)\n const artifact = normalizeArtifact(config.artifact, configDir);\n\n // Normalize tsconfig paths (only if path is specified and paths exist)\n const tsconfigPathsResult = normalizeTsconfigPaths(config.tsconfigPath, configDir);\n if (tsconfigPathsResult.isErr()) {\n return err(tsconfigPathsResult.error);\n }\n const tsconfigPaths = tsconfigPathsResult.value;\n\n // Normalize schemas with error handling\n const schemaEntries = Object.entries(config.schemas).map(([name, schemaConfig]) =>\n normalizeSchemaInput(schemaConfig.schema, configDir).map(\n (schema) =>\n [\n name,\n {\n schema,\n inject: normalizeInject(schemaConfig.inject, configDir),\n defaultInputDepth: schemaConfig.defaultInputDepth ?? 3,\n inputDepthOverrides: schemaConfig.inputDepthOverrides ?? {},\n ...(schemaConfig.typeFilter ? { typeFilter: schemaConfig.typeFilter } : {}),\n },\n ] as const,\n ),\n );\n\n const combinedResult = Result.combine(schemaEntries);\n if (combinedResult.isErr()) {\n return err(combinedResult.error);\n }\n const normalizedSchemas = Object.fromEntries(combinedResult.value);\n\n // Normalize graphql-compat config\n const schemaNames = Object.keys(config.schemas);\n const graphqlCompatResult = normalizeGraphqlCompat(config.graphqlCompat, schemaNames, configDir);\n if (graphqlCompatResult.isErr()) {\n return err(graphqlCompatResult.error);\n }\n const graphqlCompat = graphqlCompatResult.value;\n\n const resolved: ResolvedSodaGqlConfig = {\n analyzer,\n baseDir: configDir,\n outdir: resolve(configDir, config.outdir),\n graphqlSystemAliases,\n include: config.include.map((pattern) => resolvePattern(pattern, configDir)),\n exclude: exclude.map((pattern) => resolvePattern(pattern, configDir)),\n schemas: normalizedSchemas,\n styles: {\n importExtension: config.styles?.importExtension ?? false,\n },\n codegen: normalizeCodegen(config.codegen),\n plugins: config.plugins ?? {},\n ...(graphqlCompat ? { graphqlCompat } : {}),\n ...(artifact ? { artifact } : {}),\n ...(tsconfigPaths ? { tsconfigPaths } : {}),\n };\n\n return ok(resolved);\n}\n","import { existsSync, readdirSync, statSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport type { Result } from \"neverthrow\";\nimport { err } from \"neverthrow\";\nimport type { ConfigError } from \"./errors\";\nimport { configError } from \"./errors\";\nimport { executeConfigFile } from \"./evaluation\";\nimport { normalizeConfig } from \"./normalize\";\nimport type { ResolvedSodaGqlConfig } from \"./types\";\n\nexport const DEFAULT_CONFIG_FILENAMES = [\n \"soda-gql.config.ts\",\n \"soda-gql.config.mts\",\n \"soda-gql.config.js\",\n \"soda-gql.config.mjs\",\n] as const;\n\n/**\n * Find config file by walking up directory tree.\n */\nexport function findConfigFile(startDir: string = process.cwd()): string | null {\n let currentDir = startDir;\n while (currentDir !== dirname(currentDir)) {\n for (const filename of DEFAULT_CONFIG_FILENAMES) {\n const configPath = join(currentDir, filename);\n if (existsSync(configPath)) {\n return configPath;\n }\n }\n currentDir = dirname(currentDir);\n }\n return null;\n}\n\nconst SKIP_DIRS = new Set([\"node_modules\", \"dist\"]);\n\n/**\n * Find all config files by walking down from rootDir.\n * Discovers every soda-gql config file in the directory tree,\n * skipping node_modules, dist, and dot-prefixed directories.\n */\nexport function findAllConfigFiles(rootDir: string): readonly string[] {\n const results: string[] = [];\n\n const walk = (dir: string): void => {\n for (const filename of DEFAULT_CONFIG_FILENAMES) {\n const configPath = join(dir, filename);\n if (existsSync(configPath)) {\n results.push(configPath);\n break; // Only one config per directory\n }\n }\n\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const entry of entries) {\n if (SKIP_DIRS.has(entry) || entry.startsWith(\".\")) {\n continue;\n }\n const fullPath = join(dir, entry);\n try {\n if (statSync(fullPath).isDirectory()) {\n walk(fullPath);\n }\n } catch {\n // Skip inaccessible entries\n }\n }\n };\n\n walk(rootDir);\n return results;\n}\n\n/**\n * Load config with Result type (for library use).\n */\nexport function loadConfig(configPath: string | undefined): Result<ResolvedSodaGqlConfig, ConfigError> {\n const resolvedPath = configPath ?? findConfigFile();\n\n if (!resolvedPath) {\n return err(configError({ code: \"CONFIG_NOT_FOUND\", message: \"Config file not found\" }));\n }\n\n try {\n const result = executeConfigFile(resolvedPath);\n if (result.isErr()) {\n return err(result.error);\n }\n return normalizeConfig(result.value, resolvedPath);\n } catch (error) {\n return err(\n configError({\n code: \"CONFIG_LOAD_FAILED\",\n message: `Failed to load config: ${error instanceof Error ? error.message : String(error)}`,\n filePath: resolvedPath,\n cause: error,\n }),\n );\n }\n}\n\n/**\n * Load config from specific directory.\n */\nexport function loadConfigFrom(dir: string): Result<ResolvedSodaGqlConfig, ConfigError> {\n const configPath = findConfigFile(dir);\n return loadConfig(configPath ?? undefined);\n}\n","export type { ConfigError, ConfigErrorCode } from \"./errors\";\nexport { configError } from \"./errors\";\nexport {\n defineConfig,\n type SodaGqlConfigContainer,\n validateConfig,\n} from \"./helper\";\nexport { findAllConfigFiles, findConfigFile, loadConfig, loadConfigFrom } from \"./loader\";\nexport { normalizeConfig } from \"./normalize\";\nexport type {\n ArtifactConfig,\n GraphqlCompatConfig,\n PluginConfig,\n ResolvedArtifactConfig,\n ResolvedGraphqlCompatConfig,\n ResolvedSodaGqlConfig,\n ResolvedTsconfigPaths,\n SchemaConfig,\n SodaGqlConfig,\n TypeCategory,\n TypeFilterConfig,\n TypeFilterRule,\n} from \"./types\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAa,eAAe,EAC1B,MACA,SACA,UACA,aAMkB;CAClB;CACA;CACA;CACA;CAC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AAgB,OAAO,OAAO,aAAa;UAC3C,OAAO;AACd,6BACE,YAAY;GACV,MAAM;GACN,SAAS,0BAA0B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;GACzF,UAAU;GACV,OAAO;GACR,CAAC,CACH;;;;;;AAOL,SAAgB,eAAe,KAAyD;CACtF,MAAM,aAAa,eAAe,IAAI;AACtC,QAAO,WAAW,cAAc,UAAU"}
|
package/dist/index.d.cts
CHANGED
|
@@ -103,6 +103,18 @@ type TypeFilterConfig = ((context: {
|
|
|
103
103
|
}) => boolean) | {
|
|
104
104
|
readonly exclude: readonly TypeFilterRule[];
|
|
105
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* Configuration for graphql-compat code generation.
|
|
108
|
+
* When specified, `codegen` will generate `.compat.ts` files from `.graphql` files.
|
|
109
|
+
*/
|
|
110
|
+
type GraphqlCompatConfig = {
|
|
111
|
+
/** Glob patterns for .graphql/.gql files */
|
|
112
|
+
readonly input: readonly string[];
|
|
113
|
+
/** Schema name to use (required if multiple schemas configured) */
|
|
114
|
+
readonly schema?: string;
|
|
115
|
+
/** Output file suffix (default: ".compat.ts") */
|
|
116
|
+
readonly suffix?: string;
|
|
117
|
+
};
|
|
106
118
|
type StylesConfig = {
|
|
107
119
|
/**
|
|
108
120
|
* Whether to include file extensions in import paths.
|
|
@@ -212,6 +224,16 @@ type SodaGqlConfig = {
|
|
|
212
224
|
* The plugins to use for the project.
|
|
213
225
|
*/
|
|
214
226
|
readonly plugins?: PluginConfig;
|
|
227
|
+
/**
|
|
228
|
+
* Configuration for graphql-compat code generation.
|
|
229
|
+
* When specified, `codegen` will generate `.compat.ts` files from `.graphql` files.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```ts
|
|
233
|
+
* graphqlCompat: { input: ["src/∗∗/∗.graphql"] }
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
readonly graphqlCompat?: GraphqlCompatConfig;
|
|
215
237
|
/**
|
|
216
238
|
* Configuration for pre-built artifact loading.
|
|
217
239
|
* When specified, plugins will load the artifact from the file instead of building dynamically.
|
|
@@ -237,6 +259,11 @@ type ResolvedSchemaConfig = {
|
|
|
237
259
|
readonly inputDepthOverrides: Readonly<Record<string, number>>;
|
|
238
260
|
readonly typeFilter?: TypeFilterConfig;
|
|
239
261
|
};
|
|
262
|
+
type ResolvedGraphqlCompatConfig = {
|
|
263
|
+
readonly input: readonly string[];
|
|
264
|
+
readonly schema: string;
|
|
265
|
+
readonly suffix: string;
|
|
266
|
+
};
|
|
240
267
|
type ResolvedSodaGqlConfig = {
|
|
241
268
|
readonly analyzer: "ts" | "swc";
|
|
242
269
|
/**
|
|
@@ -253,6 +280,11 @@ type ResolvedSodaGqlConfig = {
|
|
|
253
280
|
readonly styles: ResolvedStylesConfig;
|
|
254
281
|
readonly codegen: ResolvedCodegenConfig;
|
|
255
282
|
readonly plugins: PluginConfig;
|
|
283
|
+
/**
|
|
284
|
+
* Resolved graphql-compat configuration.
|
|
285
|
+
* Only present when graphqlCompat is specified in the config.
|
|
286
|
+
*/
|
|
287
|
+
readonly graphqlCompat?: ResolvedGraphqlCompatConfig;
|
|
256
288
|
/**
|
|
257
289
|
* Resolved artifact configuration.
|
|
258
290
|
* Only present when artifact.path is specified in the config.
|
|
@@ -320,6 +352,12 @@ declare const DEFAULT_CONFIG_FILENAMES: readonly ["soda-gql.config.ts", "soda-gq
|
|
|
320
352
|
* Find config file by walking up directory tree.
|
|
321
353
|
*/
|
|
322
354
|
declare function findConfigFile(startDir?: string): string | null;
|
|
355
|
+
/**
|
|
356
|
+
* Find all config files by walking down from rootDir.
|
|
357
|
+
* Discovers every soda-gql config file in the directory tree,
|
|
358
|
+
* skipping node_modules, dist, and dot-prefixed directories.
|
|
359
|
+
*/
|
|
360
|
+
declare function findAllConfigFiles(rootDir: string): readonly string[];
|
|
323
361
|
/**
|
|
324
362
|
* Load config with Result type (for library use).
|
|
325
363
|
*/
|
|
@@ -336,5 +374,5 @@ declare function loadConfigFrom(dir: string): Result<ResolvedSodaGqlConfig, Conf
|
|
|
336
374
|
*/
|
|
337
375
|
declare function normalizeConfig(config: SodaGqlConfig, configPath: string): Result<ResolvedSodaGqlConfig, ConfigError>;
|
|
338
376
|
//#endregion
|
|
339
|
-
export { type ArtifactConfig, type ConfigError, type ConfigErrorCode, type PluginConfig, type ResolvedArtifactConfig, type ResolvedSodaGqlConfig, type ResolvedTsconfigPaths, type SchemaConfig, type SodaGqlConfig, type SodaGqlConfigContainer, type TypeCategory, type TypeFilterConfig, type TypeFilterRule, configError, defineConfig, findConfigFile, loadConfig, loadConfigFrom, normalizeConfig, validateConfig };
|
|
377
|
+
export { type ArtifactConfig, type ConfigError, type ConfigErrorCode, type GraphqlCompatConfig, type PluginConfig, type ResolvedArtifactConfig, type ResolvedGraphqlCompatConfig, type ResolvedSodaGqlConfig, type ResolvedTsconfigPaths, type SchemaConfig, type SodaGqlConfig, type SodaGqlConfigContainer, type TypeCategory, type TypeFilterConfig, type TypeFilterRule, configError, defineConfig, findAllConfigFiles, findConfigFile, loadConfig, loadConfigFrom, normalizeConfig, validateConfig };
|
|
340
378
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/errors.ts","../src/types.ts","../src/helper.ts","../src/loader.ts","../src/normalize.ts"],"sourcesContent":[],"mappings":";;;KAAY,eAAA;KAEA,WAAA;iBACK;EAHL,SAAA,OAAA,EAAe,MAAA;EAEf,SAAA,QAAW,CAAA,EAAA,MACN;EAMJ,SAAA,KAeX,CAAA,EAAA,OAAA;CAf0B;AAAA,cAAf,WAAe,EAAA,CAAA;EAAA,IAAA;EAAA,OAAA;EAAA,QAAA;EAAA;CAAA,EAAA;EAAA,IAAA,EAMpB,eANoB;EAAA,OAAA,EAAA,MAAA;EAMpB,QAAA,CAAA,EAAA,MAAA;EAIJ,KAAA,CAAA,EAAA,OAAA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AA,EAAA,MAAA,CAAA,EE0DG,MF1DH,CE0DU,qBF1DV,EE0DiC,WF1DjC,CAAA;;;ADpD1C;AAEA;AAOA;;AAA4B,iBIoKZ,eAAA,CJpKY,MAAA,EIoKY,aJpKZ,EAAA,UAAA,EAAA,MAAA,CAAA,EIoKgD,MJpKhD,CIoKuD,qBJpKvD,EIoK8E,WJpK9E,CAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -103,6 +103,18 @@ type TypeFilterConfig = ((context: {
|
|
|
103
103
|
}) => boolean) | {
|
|
104
104
|
readonly exclude: readonly TypeFilterRule[];
|
|
105
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* Configuration for graphql-compat code generation.
|
|
108
|
+
* When specified, `codegen` will generate `.compat.ts` files from `.graphql` files.
|
|
109
|
+
*/
|
|
110
|
+
type GraphqlCompatConfig = {
|
|
111
|
+
/** Glob patterns for .graphql/.gql files */
|
|
112
|
+
readonly input: readonly string[];
|
|
113
|
+
/** Schema name to use (required if multiple schemas configured) */
|
|
114
|
+
readonly schema?: string;
|
|
115
|
+
/** Output file suffix (default: ".compat.ts") */
|
|
116
|
+
readonly suffix?: string;
|
|
117
|
+
};
|
|
106
118
|
type StylesConfig = {
|
|
107
119
|
/**
|
|
108
120
|
* Whether to include file extensions in import paths.
|
|
@@ -212,6 +224,16 @@ type SodaGqlConfig = {
|
|
|
212
224
|
* The plugins to use for the project.
|
|
213
225
|
*/
|
|
214
226
|
readonly plugins?: PluginConfig;
|
|
227
|
+
/**
|
|
228
|
+
* Configuration for graphql-compat code generation.
|
|
229
|
+
* When specified, `codegen` will generate `.compat.ts` files from `.graphql` files.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```ts
|
|
233
|
+
* graphqlCompat: { input: ["src/∗∗/∗.graphql"] }
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
readonly graphqlCompat?: GraphqlCompatConfig;
|
|
215
237
|
/**
|
|
216
238
|
* Configuration for pre-built artifact loading.
|
|
217
239
|
* When specified, plugins will load the artifact from the file instead of building dynamically.
|
|
@@ -237,6 +259,11 @@ type ResolvedSchemaConfig = {
|
|
|
237
259
|
readonly inputDepthOverrides: Readonly<Record<string, number>>;
|
|
238
260
|
readonly typeFilter?: TypeFilterConfig;
|
|
239
261
|
};
|
|
262
|
+
type ResolvedGraphqlCompatConfig = {
|
|
263
|
+
readonly input: readonly string[];
|
|
264
|
+
readonly schema: string;
|
|
265
|
+
readonly suffix: string;
|
|
266
|
+
};
|
|
240
267
|
type ResolvedSodaGqlConfig = {
|
|
241
268
|
readonly analyzer: "ts" | "swc";
|
|
242
269
|
/**
|
|
@@ -253,6 +280,11 @@ type ResolvedSodaGqlConfig = {
|
|
|
253
280
|
readonly styles: ResolvedStylesConfig;
|
|
254
281
|
readonly codegen: ResolvedCodegenConfig;
|
|
255
282
|
readonly plugins: PluginConfig;
|
|
283
|
+
/**
|
|
284
|
+
* Resolved graphql-compat configuration.
|
|
285
|
+
* Only present when graphqlCompat is specified in the config.
|
|
286
|
+
*/
|
|
287
|
+
readonly graphqlCompat?: ResolvedGraphqlCompatConfig;
|
|
256
288
|
/**
|
|
257
289
|
* Resolved artifact configuration.
|
|
258
290
|
* Only present when artifact.path is specified in the config.
|
|
@@ -320,6 +352,12 @@ declare const DEFAULT_CONFIG_FILENAMES: readonly ["soda-gql.config.ts", "soda-gq
|
|
|
320
352
|
* Find config file by walking up directory tree.
|
|
321
353
|
*/
|
|
322
354
|
declare function findConfigFile(startDir?: string): string | null;
|
|
355
|
+
/**
|
|
356
|
+
* Find all config files by walking down from rootDir.
|
|
357
|
+
* Discovers every soda-gql config file in the directory tree,
|
|
358
|
+
* skipping node_modules, dist, and dot-prefixed directories.
|
|
359
|
+
*/
|
|
360
|
+
declare function findAllConfigFiles(rootDir: string): readonly string[];
|
|
323
361
|
/**
|
|
324
362
|
* Load config with Result type (for library use).
|
|
325
363
|
*/
|
|
@@ -336,5 +374,5 @@ declare function loadConfigFrom(dir: string): Result<ResolvedSodaGqlConfig, Conf
|
|
|
336
374
|
*/
|
|
337
375
|
declare function normalizeConfig(config: SodaGqlConfig, configPath: string): Result<ResolvedSodaGqlConfig, ConfigError>;
|
|
338
376
|
//#endregion
|
|
339
|
-
export { type ArtifactConfig, type ConfigError, type ConfigErrorCode, type PluginConfig, type ResolvedArtifactConfig, type ResolvedSodaGqlConfig, type ResolvedTsconfigPaths, type SchemaConfig, type SodaGqlConfig, type SodaGqlConfigContainer, type TypeCategory, type TypeFilterConfig, type TypeFilterRule, configError, defineConfig, findConfigFile, loadConfig, loadConfigFrom, normalizeConfig, validateConfig };
|
|
377
|
+
export { type ArtifactConfig, type ConfigError, type ConfigErrorCode, type GraphqlCompatConfig, type PluginConfig, type ResolvedArtifactConfig, type ResolvedGraphqlCompatConfig, type ResolvedSodaGqlConfig, type ResolvedTsconfigPaths, type SchemaConfig, type SodaGqlConfig, type SodaGqlConfigContainer, type TypeCategory, type TypeFilterConfig, type TypeFilterRule, configError, defineConfig, findAllConfigFiles, findConfigFile, loadConfig, loadConfigFrom, normalizeConfig, validateConfig };
|
|
340
378
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/errors.ts","../src/types.ts","../src/helper.ts","../src/loader.ts","../src/normalize.ts"],"sourcesContent":[],"mappings":";;;KAAY,eAAA;KAEA,WAAA;iBACK;EAHL,SAAA,OAAA,EAAe,MAAA;EAEf,SAAA,QAAW,CAAA,EAAA,MACN;EAMJ,SAAA,KAeX,CAAA,EAAA,OAAA;CAf0B;AAAA,cAAf,WAAe,EAAA,CAAA;EAAA,IAAA;EAAA,OAAA;EAAA,QAAA;EAAA;CAAA,EAAA;EAAA,IAAA,EAMpB,eANoB;EAAA,OAAA,EAAA,MAAA;EAMpB,QAAA,CAAA,EAAA,MAAA;EAIJ,KAAA,CAAA,EAAA,OAAA;CAKF,EAAA,GALE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AAA,EE0DG,MF1DH,CE0DU,qBF1DV,EE0DiC,WF1DjC,CAAA;;;ADpD1C;AAEA;AAOA;;AAA4B,iBIoKZ,eAAA,CJpKY,MAAA,EIoKY,aJpKZ,EAAA,UAAA,EAAA,MAAA,CAAA,EIoKgD,MJpKhD,CIoKuD,qBJpKvD,EIoK8E,WJpK9E,CAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -2,11 +2,10 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import { defineSchemaFor, readTsconfigPaths, resolveRelativeImportWithExistenceCheck } from "@soda-gql/common";
|
|
3
3
|
import { Result, err, ok } from "neverthrow";
|
|
4
4
|
import z from "zod";
|
|
5
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
6
6
|
import { dirname, join, resolve } from "node:path";
|
|
7
7
|
import { dirname as dirname$1, resolve as resolve$1 } from "node:path/posix";
|
|
8
8
|
import { Script } from "node:vm";
|
|
9
|
-
import { transformSync } from "@swc/core";
|
|
10
9
|
|
|
11
10
|
//#region rolldown:runtime
|
|
12
11
|
var __defProp = Object.defineProperty;
|
|
@@ -85,6 +84,11 @@ const SchemaConfigSchema = defineSchemaFor()({
|
|
|
85
84
|
});
|
|
86
85
|
const StylesConfigSchema = defineSchemaFor()({ importExtension: z.boolean().optional() });
|
|
87
86
|
const CodegenConfigSchema = defineSchemaFor()({ chunkSize: z.number().int().positive().optional() });
|
|
87
|
+
const GraphqlCompatConfigSchema = defineSchemaFor()({
|
|
88
|
+
input: z.array(z.string().min(1)),
|
|
89
|
+
schema: z.string().min(1).optional(),
|
|
90
|
+
suffix: z.string().min(1).optional()
|
|
91
|
+
});
|
|
88
92
|
const ArtifactConfigSchema = defineSchemaFor()({ path: z.string().min(1).optional() });
|
|
89
93
|
const SodaGqlConfigSchema = defineSchemaFor()({
|
|
90
94
|
analyzer: z.enum(["ts", "swc"]).optional(),
|
|
@@ -97,6 +101,7 @@ const SodaGqlConfigSchema = defineSchemaFor()({
|
|
|
97
101
|
styles: StylesConfigSchema.optional(),
|
|
98
102
|
codegen: CodegenConfigSchema.optional(),
|
|
99
103
|
plugins: z.record(z.string(), z.unknown()).optional(),
|
|
104
|
+
graphqlCompat: GraphqlCompatConfigSchema.optional(),
|
|
100
105
|
artifact: ArtifactConfigSchema.optional()
|
|
101
106
|
});
|
|
102
107
|
function validateConfig(config) {
|
|
@@ -112,12 +117,26 @@ function validateConfig(config) {
|
|
|
112
117
|
|
|
113
118
|
//#endregion
|
|
114
119
|
//#region packages/config/src/evaluation.ts
|
|
120
|
+
/** Lazily resolve @swc/core from the config file's directory, falling back to package resolution. */
|
|
121
|
+
const resolveSwc = (configPath) => {
|
|
122
|
+
try {
|
|
123
|
+
const localRequire = createRequire(configPath);
|
|
124
|
+
return localRequire("@swc/core").transformSync;
|
|
125
|
+
} catch (primaryError) {
|
|
126
|
+
if (typeof import.meta.url !== "string") {
|
|
127
|
+
throw primaryError;
|
|
128
|
+
}
|
|
129
|
+
const packageRequire = createRequire(import.meta.url);
|
|
130
|
+
return packageRequire("@swc/core").transformSync;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
115
133
|
/**
|
|
116
134
|
* Load and execute TypeScript config file synchronously using SWC + VM.
|
|
117
135
|
*/
|
|
118
136
|
function executeConfigFile(configPath) {
|
|
119
137
|
const filePath = resolve$1(configPath);
|
|
120
138
|
try {
|
|
139
|
+
const transformSync = resolveSwc(filePath);
|
|
121
140
|
const source = readFileSync(filePath, "utf-8");
|
|
122
141
|
const result = transformSync(source, {
|
|
123
142
|
filename: filePath,
|
|
@@ -159,9 +178,10 @@ function executeConfigFile(configPath) {
|
|
|
159
178
|
}
|
|
160
179
|
return ok(config);
|
|
161
180
|
} catch (error) {
|
|
181
|
+
const message = error instanceof Error && error.message.includes("Cannot find module '@swc/core'") ? "@swc/core not found. Install it in your project: bun add -D @swc/core" : `Failed to load config: ${error instanceof Error ? error.message : String(error)}`;
|
|
162
182
|
return err(configError({
|
|
163
183
|
code: "CONFIG_LOAD_FAILED",
|
|
164
|
-
message
|
|
184
|
+
message,
|
|
165
185
|
filePath,
|
|
166
186
|
cause: error
|
|
167
187
|
}));
|
|
@@ -247,6 +267,36 @@ function normalizeTsconfigPaths(tsconfigPath, configDir) {
|
|
|
247
267
|
return ok(result.value);
|
|
248
268
|
}
|
|
249
269
|
/**
|
|
270
|
+
* Normalize graphql-compat config to resolved form.
|
|
271
|
+
* Resolves glob patterns and validates schema name.
|
|
272
|
+
*/
|
|
273
|
+
function normalizeGraphqlCompat(graphqlCompat, schemaNames, configDir) {
|
|
274
|
+
if (!graphqlCompat) {
|
|
275
|
+
return ok(undefined);
|
|
276
|
+
}
|
|
277
|
+
let schemaName = graphqlCompat.schema;
|
|
278
|
+
if (!schemaName) {
|
|
279
|
+
if (schemaNames.length !== 1 || !schemaNames[0]) {
|
|
280
|
+
return err(configError({
|
|
281
|
+
code: "CONFIG_VALIDATION_FAILED",
|
|
282
|
+
message: "graphqlCompat.schema is required when multiple schemas are configured"
|
|
283
|
+
}));
|
|
284
|
+
}
|
|
285
|
+
schemaName = schemaNames[0];
|
|
286
|
+
}
|
|
287
|
+
if (!schemaNames.includes(schemaName)) {
|
|
288
|
+
return err(configError({
|
|
289
|
+
code: "CONFIG_VALIDATION_FAILED",
|
|
290
|
+
message: `graphqlCompat.schema "${schemaName}" not found in schemas config`
|
|
291
|
+
}));
|
|
292
|
+
}
|
|
293
|
+
return ok({
|
|
294
|
+
input: graphqlCompat.input.map((p) => resolvePattern(p, configDir)),
|
|
295
|
+
schema: schemaName,
|
|
296
|
+
suffix: graphqlCompat.suffix ?? ".compat.ts"
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
250
300
|
* Normalize codegen config to resolved form with defaults.
|
|
251
301
|
*/
|
|
252
302
|
function normalizeCodegen(codegen) {
|
|
@@ -279,6 +329,12 @@ function normalizeConfig(config, configPath) {
|
|
|
279
329
|
return err(combinedResult.error);
|
|
280
330
|
}
|
|
281
331
|
const normalizedSchemas = Object.fromEntries(combinedResult.value);
|
|
332
|
+
const schemaNames = Object.keys(config.schemas);
|
|
333
|
+
const graphqlCompatResult = normalizeGraphqlCompat(config.graphqlCompat, schemaNames, configDir);
|
|
334
|
+
if (graphqlCompatResult.isErr()) {
|
|
335
|
+
return err(graphqlCompatResult.error);
|
|
336
|
+
}
|
|
337
|
+
const graphqlCompat = graphqlCompatResult.value;
|
|
282
338
|
const resolved = {
|
|
283
339
|
analyzer,
|
|
284
340
|
baseDir: configDir,
|
|
@@ -290,6 +346,7 @@ function normalizeConfig(config, configPath) {
|
|
|
290
346
|
styles: { importExtension: config.styles?.importExtension ?? false },
|
|
291
347
|
codegen: normalizeCodegen(config.codegen),
|
|
292
348
|
plugins: config.plugins ?? {},
|
|
349
|
+
...graphqlCompat ? { graphqlCompat } : {},
|
|
293
350
|
...artifact ? { artifact } : {},
|
|
294
351
|
...tsconfigPaths ? { tsconfigPaths } : {}
|
|
295
352
|
};
|
|
@@ -320,6 +377,43 @@ function findConfigFile(startDir = process.cwd()) {
|
|
|
320
377
|
}
|
|
321
378
|
return null;
|
|
322
379
|
}
|
|
380
|
+
const SKIP_DIRS = new Set(["node_modules", "dist"]);
|
|
381
|
+
/**
|
|
382
|
+
* Find all config files by walking down from rootDir.
|
|
383
|
+
* Discovers every soda-gql config file in the directory tree,
|
|
384
|
+
* skipping node_modules, dist, and dot-prefixed directories.
|
|
385
|
+
*/
|
|
386
|
+
function findAllConfigFiles(rootDir) {
|
|
387
|
+
const results = [];
|
|
388
|
+
const walk = (dir) => {
|
|
389
|
+
for (const filename of DEFAULT_CONFIG_FILENAMES) {
|
|
390
|
+
const configPath = join(dir, filename);
|
|
391
|
+
if (existsSync(configPath)) {
|
|
392
|
+
results.push(configPath);
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
let entries;
|
|
397
|
+
try {
|
|
398
|
+
entries = readdirSync(dir);
|
|
399
|
+
} catch {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
for (const entry of entries) {
|
|
403
|
+
if (SKIP_DIRS.has(entry) || entry.startsWith(".")) {
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
const fullPath = join(dir, entry);
|
|
407
|
+
try {
|
|
408
|
+
if (statSync(fullPath).isDirectory()) {
|
|
409
|
+
walk(fullPath);
|
|
410
|
+
}
|
|
411
|
+
} catch {}
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
walk(rootDir);
|
|
415
|
+
return results;
|
|
416
|
+
}
|
|
323
417
|
/**
|
|
324
418
|
* Load config with Result type (for library use).
|
|
325
419
|
*/
|
|
@@ -359,6 +453,7 @@ function loadConfigFrom(dir) {
|
|
|
359
453
|
var src_exports = /* @__PURE__ */ __export({
|
|
360
454
|
configError: () => configError,
|
|
361
455
|
defineConfig: () => defineConfig,
|
|
456
|
+
findAllConfigFiles: () => findAllConfigFiles,
|
|
362
457
|
findConfigFile: () => findConfigFile,
|
|
363
458
|
loadConfig: () => loadConfig,
|
|
364
459
|
loadConfigFrom: () => loadConfigFrom,
|
|
@@ -367,5 +462,5 @@ var src_exports = /* @__PURE__ */ __export({
|
|
|
367
462
|
});
|
|
368
463
|
|
|
369
464
|
//#endregion
|
|
370
|
-
export { configError, defineConfig, findConfigFile, loadConfig, loadConfigFrom, normalizeConfig, validateConfig };
|
|
465
|
+
export { configError, defineConfig, findAllConfigFiles, findConfigFile, loadConfig, loadConfigFrom, normalizeConfig, validateConfig };
|
|
371
466
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["config: SodaGqlConfig","InjectConfigSchema: z.ZodType<InjectConfig>","SchemaInputSchema: z.ZodType<SchemaInput>","TypeFilterConfigSchema: z.ZodType<TypeFilterConfig | undefined>","resolve","mod: { exports: unknown }","configModule","dirname","resolved: ResolvedSodaGqlConfig"],"sources":["../src/errors.ts","../src/helper.ts","../src/evaluation.ts","../src/normalize.ts","../src/loader.ts","../src/index.ts"],"sourcesContent":["export type ConfigErrorCode = \"CONFIG_NOT_FOUND\" | \"CONFIG_LOAD_FAILED\" | \"CONFIG_VALIDATION_FAILED\" | \"CONFIG_INVALID_PATH\";\n\nexport type ConfigError = {\n readonly code: ConfigErrorCode;\n readonly message: string;\n readonly filePath?: string;\n readonly cause?: unknown;\n};\n\nexport const configError = ({\n code,\n message,\n filePath,\n cause,\n}: {\n code: ConfigErrorCode;\n message: string;\n filePath?: string;\n cause?: unknown;\n}): ConfigError => ({\n code,\n message,\n filePath,\n cause,\n});\n","import { defineSchemaFor } from \"@soda-gql/common\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport z from \"zod\";\nimport { type ConfigError, configError } from \"./errors\";\nimport type {\n ArtifactConfig,\n CodegenConfig,\n InjectConfig,\n SchemaConfig,\n SchemaInput,\n SodaGqlConfig,\n StylesConfig,\n TypeFilterConfig,\n} from \"./types\";\n\n/**\n * Thin wrapper class to simplify the validation of exported value from config file.\n * As we use SWC + VM to execute the config file, the exported value is not typed.\n * This wrapper class ensures the exported value is a valid soda-gql config object.\n */\nexport class SodaGqlConfigContainer {\n private constructor(public readonly config: SodaGqlConfig) {}\n\n public static create(config: SodaGqlConfig): SodaGqlConfigContainer {\n return new SodaGqlConfigContainer(config);\n }\n}\n\n/**\n * Type-safe helper for defining soda-gql configuration.\n * Supports both static and dynamic (async) configs.\n *\n * @example Static config with object inject\n * ```ts\n * import { defineConfig } from \"@soda-gql/config\";\n *\n * export default defineConfig({\n * outdir: \"./graphql-system\",\n * include: [\"./src/**\\/*.ts\"],\n * schemas: {\n * default: {\n * schema: \"./schema.graphql\",\n * inject: { scalars: \"./scalars.ts\" },\n * },\n * },\n * });\n * ```\n *\n * @example Static config with string inject (single file)\n * ```ts\n * export default defineConfig({\n * outdir: \"./graphql-system\",\n * include: [\"./src/**\\/*.ts\"],\n * schemas: {\n * default: {\n * schema: \"./schema.graphql\",\n * inject: \"./inject.ts\", // exports scalar, adapter?\n * },\n * },\n * });\n * ```\n */\nexport function defineConfig(config: SodaGqlConfig): SodaGqlConfigContainer;\nexport function defineConfig(config: () => SodaGqlConfig): SodaGqlConfigContainer;\nexport function defineConfig(config: SodaGqlConfig | (() => SodaGqlConfig)): SodaGqlConfigContainer {\n const validated = validateConfig(typeof config === \"function\" ? config() : config);\n if (validated.isErr()) {\n throw validated.error;\n }\n return SodaGqlConfigContainer.create(validated.value);\n}\n\n// InjectConfig is a union type (string | object), so we define the schema directly\n// rather than using defineSchemaFor which requires object types\nconst InjectConfigSchema: z.ZodType<InjectConfig> = z.union([\n z.string().min(1),\n z.object({\n scalars: z.string().min(1),\n adapter: z.string().min(1).optional(),\n }),\n]);\n\n// SchemaInput supports string, array of strings, or function returning array of strings\n// Function return value validation is deferred to normalize time\nconst SchemaInputSchema: z.ZodType<SchemaInput> = z.union([\n z.string().min(1),\n z.array(z.string().min(1)).min(1),\n z.custom<() => readonly string[]>((val) => typeof val === \"function\"),\n]);\n\n// TypeCategory enum for type filtering\nconst TypeCategorySchema = z.enum([\"object\", \"input\", \"enum\", \"union\", \"scalar\"]);\n\n// TypeFilterRule validates pattern and optional category\nconst TypeFilterRuleSchema = z.object({\n pattern: z.string().min(1),\n category: z.union([TypeCategorySchema, z.array(TypeCategorySchema).min(1)]).optional(),\n});\n\n// TypeFilterConfig supports function or object with exclude rules\n// Function signature validation is deferred to runtime (compileTypeFilter)\nconst TypeFilterConfigSchema: z.ZodType<TypeFilterConfig | undefined> = z\n .union([\n z.custom<TypeFilterConfig>((val) => typeof val === \"function\"),\n z.object({\n exclude: z.array(TypeFilterRuleSchema).min(1),\n }),\n ])\n .optional();\n\nconst SchemaConfigSchema = defineSchemaFor<SchemaConfig>()({\n schema: SchemaInputSchema,\n inject: InjectConfigSchema,\n defaultInputDepth: z.number().int().positive().max(10).optional(),\n inputDepthOverrides: z.record(z.string(), z.number().int().positive()).optional(),\n typeFilter: TypeFilterConfigSchema,\n});\n\nconst StylesConfigSchema = defineSchemaFor<StylesConfig>()({\n importExtension: z.boolean().optional(),\n});\n\nconst CodegenConfigSchema = defineSchemaFor<CodegenConfig>()({\n chunkSize: z.number().int().positive().optional(),\n});\n\nconst ArtifactConfigSchema = defineSchemaFor<ArtifactConfig>()({\n path: z.string().min(1).optional(),\n});\n\nconst SodaGqlConfigSchema = defineSchemaFor<SodaGqlConfig>()({\n analyzer: z.enum([\"ts\", \"swc\"]).optional(),\n outdir: z.string().min(1),\n graphqlSystemAliases: z.array(z.string()).optional(),\n tsconfigPath: z.string().min(1).optional(),\n include: z.array(z.string().min(1)),\n exclude: z.array(z.string().min(1)).optional(),\n schemas: z.record(z.string(), SchemaConfigSchema),\n styles: StylesConfigSchema.optional(),\n codegen: CodegenConfigSchema.optional(),\n plugins: z.record(z.string(), z.unknown()).optional(),\n artifact: ArtifactConfigSchema.optional(),\n});\n\nexport function validateConfig(config: unknown): Result<SodaGqlConfig, ConfigError> {\n const result = SodaGqlConfigSchema.safeParse(config);\n\n if (!result.success) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: `Invalid config: ${result.error.message}`,\n }),\n );\n }\n\n return ok(result.data satisfies SodaGqlConfig);\n}\n","import { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path/posix\";\nimport { Script } from \"node:vm\";\nimport { resolveRelativeImportWithExistenceCheck } from \"@soda-gql/common\";\nimport { transformSync } from \"@swc/core\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport { type ConfigError, configError } from \"./errors\";\nimport { SodaGqlConfigContainer } from \"./helper\";\n// TODO: split config package into definition and evaluation parts\nimport * as configModule from \"./index\";\nimport type { SodaGqlConfig } from \"./types\";\n\n/**\n * Load and execute TypeScript config file synchronously using SWC + VM.\n */\nexport function executeConfigFile(configPath: string): Result<SodaGqlConfig, ConfigError> {\n const filePath = resolve(configPath);\n try {\n // Read the config file\n const source = readFileSync(filePath, \"utf-8\");\n\n // Transform TypeScript to CommonJS using SWC\n const result = transformSync(source, {\n filename: filePath,\n jsc: {\n parser: {\n syntax: \"typescript\",\n },\n },\n module: {\n type: \"commonjs\",\n },\n sourceMaps: false,\n minify: false,\n });\n\n // Create CommonJS context\n const mod: { exports: unknown } = { exports: {} };\n\n const requireInner = createRequire(filePath);\n const require = (specifier: string) => {\n if (specifier === \"@soda-gql/config\") {\n return configModule;\n }\n\n // Handle external modules normally\n if (!specifier.startsWith(\".\")) {\n return requireInner(specifier);\n }\n\n // Resolve relative imports with existence check\n const resolvedPath = resolveRelativeImportWithExistenceCheck({ filePath, specifier });\n if (!resolvedPath) {\n throw new Error(`Module not found: ${specifier}`);\n }\n return requireInner(resolvedPath);\n };\n\n // Execute in VM context\n new Script(result.code, { filename: filePath }).runInNewContext({\n require,\n module: mod,\n exports: mod.exports,\n __dirname: dirname(filePath),\n __filename: filePath,\n console,\n process,\n });\n\n const config =\n mod.exports &&\n typeof mod.exports === \"object\" &&\n \"default\" in mod.exports &&\n mod.exports.default instanceof SodaGqlConfigContainer\n ? mod.exports.default.config\n : null;\n\n if (!config) {\n throw new Error(\"Invalid config module\");\n }\n\n return ok(config);\n } catch (error) {\n return err(\n configError({\n code: \"CONFIG_LOAD_FAILED\",\n message: `Failed to load config: ${error instanceof Error ? error.message : String(error)}`,\n filePath: filePath,\n cause: error,\n }),\n );\n }\n}\n","import { dirname, resolve } from \"node:path\";\nimport { readTsconfigPaths } from \"@soda-gql/common\";\nimport { err, ok, Result } from \"neverthrow\";\nimport { type ConfigError, configError } from \"./errors\";\nimport type {\n InjectConfig,\n ResolvedArtifactConfig,\n ResolvedCodegenConfig,\n ResolvedInjectConfig,\n ResolvedSodaGqlConfig,\n ResolvedTsconfigPaths,\n SchemaInput,\n SodaGqlConfig,\n} from \"./types\";\n\n/**\n * Normalize schema input to resolved array form.\n * String is converted to single-element array.\n * Function is executed to get the array.\n * All paths are resolved relative to config directory.\n */\nfunction normalizeSchemaInput(schema: SchemaInput, configDir: string): Result<readonly string[], ConfigError> {\n // Execute function if provided\n const paths = typeof schema === \"function\" ? schema() : schema;\n // Normalize single string to array\n const pathArray = typeof paths === \"string\" ? [paths] : paths;\n\n // Runtime validation: empty array check\n if (pathArray.length === 0) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: \"Schema paths cannot be empty\",\n }),\n );\n }\n\n return ok(pathArray.map((p) => resolve(configDir, p)));\n}\n\n/**\n * Normalize inject config to resolved object form.\n * String form is converted to object with same path for all fields.\n */\nfunction normalizeInject(inject: InjectConfig, configDir: string): ResolvedInjectConfig {\n if (typeof inject === \"string\") {\n const resolvedPath = resolve(configDir, inject);\n return {\n scalars: resolvedPath,\n adapter: resolvedPath,\n };\n }\n return {\n scalars: resolve(configDir, inject.scalars),\n ...(inject.adapter ? { adapter: resolve(configDir, inject.adapter) } : {}),\n };\n}\n\n/**\n * Resolve a glob pattern relative to the config directory.\n * Handles negation patterns (e.g., \"!./path/to/exclude\") by preserving the \"!\" prefix.\n */\nfunction resolvePattern(pattern: string, configDir: string): string {\n if (pattern.startsWith(\"!\")) {\n // Preserve the negation prefix, resolve the rest\n return `!${resolve(configDir, pattern.slice(1))}`;\n }\n return resolve(configDir, pattern);\n}\n\n/**\n * Normalize artifact config to resolved form.\n * Returns undefined if no path is specified.\n */\nfunction normalizeArtifact(artifact: SodaGqlConfig[\"artifact\"], configDir: string): ResolvedArtifactConfig | undefined {\n if (!artifact?.path) {\n return undefined;\n }\n return {\n path: resolve(configDir, artifact.path),\n };\n}\n\n/**\n * Normalize tsconfig paths configuration.\n * Reads tsconfig.json and extracts paths if defined.\n * Returns undefined if no tsconfigPath is specified or no paths are defined.\n */\nfunction normalizeTsconfigPaths(\n tsconfigPath: string | undefined,\n configDir: string,\n): Result<ResolvedTsconfigPaths | undefined, ConfigError> {\n if (!tsconfigPath) {\n return ok(undefined);\n }\n\n const resolvedPath = resolve(configDir, tsconfigPath);\n const result = readTsconfigPaths(resolvedPath);\n\n if (result.isErr()) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: result.error.message,\n }),\n );\n }\n\n // Return undefined if no paths defined in tsconfig\n if (result.value === null) {\n return ok(undefined);\n }\n\n return ok(result.value);\n}\n\n/**\n * Normalize codegen config to resolved form with defaults.\n */\nfunction normalizeCodegen(codegen: SodaGqlConfig[\"codegen\"]): ResolvedCodegenConfig {\n return {\n chunkSize: codegen?.chunkSize ?? 100,\n };\n}\n\n/**\n * Resolve and normalize config with defaults.\n * Paths in the config are resolved relative to the config file's directory.\n */\nexport function normalizeConfig(config: SodaGqlConfig, configPath: string): Result<ResolvedSodaGqlConfig, ConfigError> {\n const configDir = dirname(configPath);\n // Default analyzer to \"ts\"\n const analyzer = config.analyzer ?? \"ts\";\n\n // Default graphqlSystemAliases to [\"@/graphql-system\"]\n const graphqlSystemAliases = config.graphqlSystemAliases ?? [\"@/graphql-system\"];\n\n // Default exclude to empty array\n const exclude = config.exclude ?? [];\n\n // Normalize artifact config (only if path is specified)\n const artifact = normalizeArtifact(config.artifact, configDir);\n\n // Normalize tsconfig paths (only if path is specified and paths exist)\n const tsconfigPathsResult = normalizeTsconfigPaths(config.tsconfigPath, configDir);\n if (tsconfigPathsResult.isErr()) {\n return err(tsconfigPathsResult.error);\n }\n const tsconfigPaths = tsconfigPathsResult.value;\n\n // Normalize schemas with error handling\n const schemaEntries = Object.entries(config.schemas).map(([name, schemaConfig]) =>\n normalizeSchemaInput(schemaConfig.schema, configDir).map(\n (schema) =>\n [\n name,\n {\n schema,\n inject: normalizeInject(schemaConfig.inject, configDir),\n defaultInputDepth: schemaConfig.defaultInputDepth ?? 3,\n inputDepthOverrides: schemaConfig.inputDepthOverrides ?? {},\n ...(schemaConfig.typeFilter ? { typeFilter: schemaConfig.typeFilter } : {}),\n },\n ] as const,\n ),\n );\n\n const combinedResult = Result.combine(schemaEntries);\n if (combinedResult.isErr()) {\n return err(combinedResult.error);\n }\n const normalizedSchemas = Object.fromEntries(combinedResult.value);\n\n const resolved: ResolvedSodaGqlConfig = {\n analyzer,\n baseDir: configDir,\n outdir: resolve(configDir, config.outdir),\n graphqlSystemAliases,\n include: config.include.map((pattern) => resolvePattern(pattern, configDir)),\n exclude: exclude.map((pattern) => resolvePattern(pattern, configDir)),\n schemas: normalizedSchemas,\n styles: {\n importExtension: config.styles?.importExtension ?? false,\n },\n codegen: normalizeCodegen(config.codegen),\n plugins: config.plugins ?? {},\n ...(artifact ? { artifact } : {}),\n ...(tsconfigPaths ? { tsconfigPaths } : {}),\n };\n\n return ok(resolved);\n}\n","import { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport type { Result } from \"neverthrow\";\nimport { err } from \"neverthrow\";\nimport type { ConfigError } from \"./errors\";\nimport { configError } from \"./errors\";\nimport { executeConfigFile } from \"./evaluation\";\nimport { normalizeConfig } from \"./normalize\";\nimport type { ResolvedSodaGqlConfig } from \"./types\";\n\nexport const DEFAULT_CONFIG_FILENAMES = [\n \"soda-gql.config.ts\",\n \"soda-gql.config.mts\",\n \"soda-gql.config.js\",\n \"soda-gql.config.mjs\",\n] as const;\n\n/**\n * Find config file by walking up directory tree.\n */\nexport function findConfigFile(startDir: string = process.cwd()): string | null {\n let currentDir = startDir;\n while (currentDir !== dirname(currentDir)) {\n for (const filename of DEFAULT_CONFIG_FILENAMES) {\n const configPath = join(currentDir, filename);\n if (existsSync(configPath)) {\n return configPath;\n }\n }\n currentDir = dirname(currentDir);\n }\n return null;\n}\n\n/**\n * Load config with Result type (for library use).\n */\nexport function loadConfig(configPath: string | undefined): Result<ResolvedSodaGqlConfig, ConfigError> {\n const resolvedPath = configPath ?? findConfigFile();\n\n if (!resolvedPath) {\n return err(configError({ code: \"CONFIG_NOT_FOUND\", message: \"Config file not found\" }));\n }\n\n try {\n const result = executeConfigFile(resolvedPath);\n if (result.isErr()) {\n return err(result.error);\n }\n return normalizeConfig(result.value, resolvedPath);\n } catch (error) {\n return err(\n configError({\n code: \"CONFIG_LOAD_FAILED\",\n message: `Failed to load config: ${error instanceof Error ? error.message : String(error)}`,\n filePath: resolvedPath,\n cause: error,\n }),\n );\n }\n}\n\n/**\n * Load config from specific directory.\n */\nexport function loadConfigFrom(dir: string): Result<ResolvedSodaGqlConfig, ConfigError> {\n const configPath = findConfigFile(dir);\n return loadConfig(configPath ?? undefined);\n}\n","export type { ConfigError, ConfigErrorCode } from \"./errors\";\nexport { configError } from \"./errors\";\nexport {\n defineConfig,\n type SodaGqlConfigContainer,\n validateConfig,\n} from \"./helper\";\nexport { findConfigFile, loadConfig, loadConfigFrom } from \"./loader\";\nexport { normalizeConfig } from \"./normalize\";\nexport type {\n ArtifactConfig,\n PluginConfig,\n ResolvedArtifactConfig,\n ResolvedSodaGqlConfig,\n ResolvedTsconfigPaths,\n SchemaConfig,\n SodaGqlConfig,\n TypeCategory,\n TypeFilterConfig,\n TypeFilterRule,\n} from \"./types\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAa,eAAe,EAC1B,MACA,SACA,UACA,aAMkB;CAClB;CACA;CACA;CACA;CACD;;;;;;;;;ACJD,IAAa,yBAAb,MAAa,uBAAuB;CAClC,AAAQ,YAAY,AAAgBA,QAAuB;EAAvB;;CAEpC,OAAc,OAAO,QAA+C;AAClE,SAAO,IAAI,uBAAuB,OAAO;;;AAwC7C,SAAgB,aAAa,QAAuE;CAClG,MAAM,YAAY,eAAe,OAAO,WAAW,aAAa,QAAQ,GAAG,OAAO;AAClF,KAAI,UAAU,OAAO,EAAE;AACrB,QAAM,UAAU;;AAElB,QAAO,uBAAuB,OAAO,UAAU,MAAM;;AAKvD,MAAMC,qBAA8C,EAAE,MAAM,CAC1D,EAAE,QAAQ,CAAC,IAAI,EAAE,EACjB,EAAE,OAAO;CACP,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE;CAC1B,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,UAAU;CACtC,CAAC,CACH,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4E;CACrG,MAAM,eAAe,cAAc,gBAAgB;AAEnD,KAAI,CAAC,cAAc;AACjB,SAAO,IAAI,YAAY;GAAE,MAAM;GAAoB,SAAS;GAAyB,CAAC,CAAC;;AAGzF,KAAI;EACF,MAAM,SAAS,kBAAkB,aAAa;AAC9C,MAAI,OAAO,OAAO,EAAE;AAClB,UAAO,IAAI,OAAO,MAAM;;AAE1B,SAAO,gBAAgB,OAAO,OAAO,aAAa;UAC3C,OAAO;AACd,SAAO,IACL,YAAY;GACV,MAAM;GACN,SAAS,0BAA0B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;GACzF,UAAU;GACV,OAAO;GACR,CAAC,CACH;;;;;;AAOL,SAAgB,eAAe,KAAyD;CACtF,MAAM,aAAa,eAAe,IAAI;AACtC,QAAO,WAAW,cAAc,UAAU"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["config: SodaGqlConfig","InjectConfigSchema: z.ZodType<InjectConfig>","SchemaInputSchema: z.ZodType<SchemaInput>","TypeFilterConfigSchema: z.ZodType<TypeFilterConfig | undefined>","resolve","mod: { exports: unknown }","configModule","dirname","resolved: ResolvedSodaGqlConfig","results: string[]","entries: string[]"],"sources":["../src/errors.ts","../src/helper.ts","../src/evaluation.ts","../src/normalize.ts","../src/loader.ts","../src/index.ts"],"sourcesContent":["export type ConfigErrorCode = \"CONFIG_NOT_FOUND\" | \"CONFIG_LOAD_FAILED\" | \"CONFIG_VALIDATION_FAILED\" | \"CONFIG_INVALID_PATH\";\n\nexport type ConfigError = {\n readonly code: ConfigErrorCode;\n readonly message: string;\n readonly filePath?: string;\n readonly cause?: unknown;\n};\n\nexport const configError = ({\n code,\n message,\n filePath,\n cause,\n}: {\n code: ConfigErrorCode;\n message: string;\n filePath?: string;\n cause?: unknown;\n}): ConfigError => ({\n code,\n message,\n filePath,\n cause,\n});\n","import { defineSchemaFor } from \"@soda-gql/common\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport z from \"zod\";\nimport { type ConfigError, configError } from \"./errors\";\nimport type {\n ArtifactConfig,\n CodegenConfig,\n GraphqlCompatConfig,\n InjectConfig,\n SchemaConfig,\n SchemaInput,\n SodaGqlConfig,\n StylesConfig,\n TypeFilterConfig,\n} from \"./types\";\n\n/**\n * Thin wrapper class to simplify the validation of exported value from config file.\n * As we use SWC + VM to execute the config file, the exported value is not typed.\n * This wrapper class ensures the exported value is a valid soda-gql config object.\n */\nexport class SodaGqlConfigContainer {\n private constructor(public readonly config: SodaGqlConfig) {}\n\n public static create(config: SodaGqlConfig): SodaGqlConfigContainer {\n return new SodaGqlConfigContainer(config);\n }\n}\n\n/**\n * Type-safe helper for defining soda-gql configuration.\n * Supports both static and dynamic (async) configs.\n *\n * @example Static config with object inject\n * ```ts\n * import { defineConfig } from \"@soda-gql/config\";\n *\n * export default defineConfig({\n * outdir: \"./graphql-system\",\n * include: [\"./src/**\\/*.ts\"],\n * schemas: {\n * default: {\n * schema: \"./schema.graphql\",\n * inject: { scalars: \"./scalars.ts\" },\n * },\n * },\n * });\n * ```\n *\n * @example Static config with string inject (single file)\n * ```ts\n * export default defineConfig({\n * outdir: \"./graphql-system\",\n * include: [\"./src/**\\/*.ts\"],\n * schemas: {\n * default: {\n * schema: \"./schema.graphql\",\n * inject: \"./inject.ts\", // exports scalar, adapter?\n * },\n * },\n * });\n * ```\n */\nexport function defineConfig(config: SodaGqlConfig): SodaGqlConfigContainer;\nexport function defineConfig(config: () => SodaGqlConfig): SodaGqlConfigContainer;\nexport function defineConfig(config: SodaGqlConfig | (() => SodaGqlConfig)): SodaGqlConfigContainer {\n const validated = validateConfig(typeof config === \"function\" ? config() : config);\n if (validated.isErr()) {\n throw validated.error;\n }\n return SodaGqlConfigContainer.create(validated.value);\n}\n\n// InjectConfig is a union type (string | object), so we define the schema directly\n// rather than using defineSchemaFor which requires object types\nconst InjectConfigSchema: z.ZodType<InjectConfig> = z.union([\n z.string().min(1),\n z.object({\n scalars: z.string().min(1),\n adapter: z.string().min(1).optional(),\n }),\n]);\n\n// SchemaInput supports string, array of strings, or function returning array of strings\n// Function return value validation is deferred to normalize time\nconst SchemaInputSchema: z.ZodType<SchemaInput> = z.union([\n z.string().min(1),\n z.array(z.string().min(1)).min(1),\n z.custom<() => readonly string[]>((val) => typeof val === \"function\"),\n]);\n\n// TypeCategory enum for type filtering\nconst TypeCategorySchema = z.enum([\"object\", \"input\", \"enum\", \"union\", \"scalar\"]);\n\n// TypeFilterRule validates pattern and optional category\nconst TypeFilterRuleSchema = z.object({\n pattern: z.string().min(1),\n category: z.union([TypeCategorySchema, z.array(TypeCategorySchema).min(1)]).optional(),\n});\n\n// TypeFilterConfig supports function or object with exclude rules\n// Function signature validation is deferred to runtime (compileTypeFilter)\nconst TypeFilterConfigSchema: z.ZodType<TypeFilterConfig | undefined> = z\n .union([\n z.custom<TypeFilterConfig>((val) => typeof val === \"function\"),\n z.object({\n exclude: z.array(TypeFilterRuleSchema).min(1),\n }),\n ])\n .optional();\n\nconst SchemaConfigSchema = defineSchemaFor<SchemaConfig>()({\n schema: SchemaInputSchema,\n inject: InjectConfigSchema,\n defaultInputDepth: z.number().int().positive().max(10).optional(),\n inputDepthOverrides: z.record(z.string(), z.number().int().positive()).optional(),\n typeFilter: TypeFilterConfigSchema,\n});\n\nconst StylesConfigSchema = defineSchemaFor<StylesConfig>()({\n importExtension: z.boolean().optional(),\n});\n\nconst CodegenConfigSchema = defineSchemaFor<CodegenConfig>()({\n chunkSize: z.number().int().positive().optional(),\n});\n\nconst GraphqlCompatConfigSchema = defineSchemaFor<GraphqlCompatConfig>()({\n input: z.array(z.string().min(1)),\n schema: z.string().min(1).optional(),\n suffix: z.string().min(1).optional(),\n});\n\nconst ArtifactConfigSchema = defineSchemaFor<ArtifactConfig>()({\n path: z.string().min(1).optional(),\n});\n\nconst SodaGqlConfigSchema = defineSchemaFor<SodaGqlConfig>()({\n analyzer: z.enum([\"ts\", \"swc\"]).optional(),\n outdir: z.string().min(1),\n graphqlSystemAliases: z.array(z.string()).optional(),\n tsconfigPath: z.string().min(1).optional(),\n include: z.array(z.string().min(1)),\n exclude: z.array(z.string().min(1)).optional(),\n schemas: z.record(z.string(), SchemaConfigSchema),\n styles: StylesConfigSchema.optional(),\n codegen: CodegenConfigSchema.optional(),\n plugins: z.record(z.string(), z.unknown()).optional(),\n graphqlCompat: GraphqlCompatConfigSchema.optional(),\n artifact: ArtifactConfigSchema.optional(),\n});\n\nexport function validateConfig(config: unknown): Result<SodaGqlConfig, ConfigError> {\n const result = SodaGqlConfigSchema.safeParse(config);\n\n if (!result.success) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: `Invalid config: ${result.error.message}`,\n }),\n );\n }\n\n return ok(result.data satisfies SodaGqlConfig);\n}\n","import { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path/posix\";\nimport { Script } from \"node:vm\";\nimport { resolveRelativeImportWithExistenceCheck } from \"@soda-gql/common\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport { type ConfigError, configError } from \"./errors\";\nimport { SodaGqlConfigContainer } from \"./helper\";\n// TODO: split config package into definition and evaluation parts\nimport * as configModule from \"./index\";\nimport type { SodaGqlConfig } from \"./types\";\n\ntype TransformSync = typeof import(\"@swc/core\").transformSync;\n\n/** Lazily resolve @swc/core from the config file's directory, falling back to package resolution. */\nconst resolveSwc = (configPath: string): TransformSync => {\n try {\n const localRequire = createRequire(configPath);\n return localRequire(\"@swc/core\").transformSync;\n } catch (primaryError) {\n // import.meta.url is undefined in CJS bundles (esbuild replaces import.meta with {})\n if (typeof import.meta.url !== \"string\") {\n throw primaryError;\n }\n // Fall back to package-level resolution (e.g., during tests or when user relies on bundled swc)\n const packageRequire = createRequire(import.meta.url);\n return packageRequire(\"@swc/core\").transformSync;\n }\n};\n\n/**\n * Load and execute TypeScript config file synchronously using SWC + VM.\n */\nexport function executeConfigFile(configPath: string): Result<SodaGqlConfig, ConfigError> {\n const filePath = resolve(configPath);\n try {\n const transformSync = resolveSwc(filePath);\n\n // Read the config file\n const source = readFileSync(filePath, \"utf-8\");\n\n // Transform TypeScript to CommonJS using SWC\n const result = transformSync(source, {\n filename: filePath,\n jsc: {\n parser: {\n syntax: \"typescript\",\n },\n },\n module: {\n type: \"commonjs\",\n },\n sourceMaps: false,\n minify: false,\n });\n\n // Create CommonJS context\n const mod: { exports: unknown } = { exports: {} };\n\n const requireInner = createRequire(filePath);\n const require = (specifier: string) => {\n if (specifier === \"@soda-gql/config\") {\n return configModule;\n }\n\n // Handle external modules normally\n if (!specifier.startsWith(\".\")) {\n return requireInner(specifier);\n }\n\n // Resolve relative imports with existence check\n const resolvedPath = resolveRelativeImportWithExistenceCheck({ filePath, specifier });\n if (!resolvedPath) {\n throw new Error(`Module not found: ${specifier}`);\n }\n return requireInner(resolvedPath);\n };\n\n // Execute in VM context\n new Script(result.code, { filename: filePath }).runInNewContext({\n require,\n module: mod,\n exports: mod.exports,\n __dirname: dirname(filePath),\n __filename: filePath,\n console,\n process,\n });\n\n const config =\n mod.exports &&\n typeof mod.exports === \"object\" &&\n \"default\" in mod.exports &&\n mod.exports.default instanceof SodaGqlConfigContainer\n ? mod.exports.default.config\n : null;\n\n if (!config) {\n throw new Error(\"Invalid config module\");\n }\n\n return ok(config);\n } catch (error) {\n const message =\n error instanceof Error && error.message.includes(\"Cannot find module '@swc/core'\")\n ? \"@swc/core not found. Install it in your project: bun add -D @swc/core\"\n : `Failed to load config: ${error instanceof Error ? error.message : String(error)}`;\n return err(\n configError({\n code: \"CONFIG_LOAD_FAILED\",\n message,\n filePath: filePath,\n cause: error,\n }),\n );\n }\n}\n","import { dirname, resolve } from \"node:path\";\nimport { readTsconfigPaths } from \"@soda-gql/common\";\nimport { err, ok, Result } from \"neverthrow\";\nimport { type ConfigError, configError } from \"./errors\";\nimport type {\n GraphqlCompatConfig,\n InjectConfig,\n ResolvedArtifactConfig,\n ResolvedCodegenConfig,\n ResolvedGraphqlCompatConfig,\n ResolvedInjectConfig,\n ResolvedSodaGqlConfig,\n ResolvedTsconfigPaths,\n SchemaInput,\n SodaGqlConfig,\n} from \"./types\";\n\n/**\n * Normalize schema input to resolved array form.\n * String is converted to single-element array.\n * Function is executed to get the array.\n * All paths are resolved relative to config directory.\n */\nfunction normalizeSchemaInput(schema: SchemaInput, configDir: string): Result<readonly string[], ConfigError> {\n // Execute function if provided\n const paths = typeof schema === \"function\" ? schema() : schema;\n // Normalize single string to array\n const pathArray = typeof paths === \"string\" ? [paths] : paths;\n\n // Runtime validation: empty array check\n if (pathArray.length === 0) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: \"Schema paths cannot be empty\",\n }),\n );\n }\n\n return ok(pathArray.map((p) => resolve(configDir, p)));\n}\n\n/**\n * Normalize inject config to resolved object form.\n * String form is converted to object with same path for all fields.\n */\nfunction normalizeInject(inject: InjectConfig, configDir: string): ResolvedInjectConfig {\n if (typeof inject === \"string\") {\n const resolvedPath = resolve(configDir, inject);\n return {\n scalars: resolvedPath,\n adapter: resolvedPath,\n };\n }\n return {\n scalars: resolve(configDir, inject.scalars),\n ...(inject.adapter ? { adapter: resolve(configDir, inject.adapter) } : {}),\n };\n}\n\n/**\n * Resolve a glob pattern relative to the config directory.\n * Handles negation patterns (e.g., \"!./path/to/exclude\") by preserving the \"!\" prefix.\n */\nfunction resolvePattern(pattern: string, configDir: string): string {\n if (pattern.startsWith(\"!\")) {\n // Preserve the negation prefix, resolve the rest\n return `!${resolve(configDir, pattern.slice(1))}`;\n }\n return resolve(configDir, pattern);\n}\n\n/**\n * Normalize artifact config to resolved form.\n * Returns undefined if no path is specified.\n */\nfunction normalizeArtifact(artifact: SodaGqlConfig[\"artifact\"], configDir: string): ResolvedArtifactConfig | undefined {\n if (!artifact?.path) {\n return undefined;\n }\n return {\n path: resolve(configDir, artifact.path),\n };\n}\n\n/**\n * Normalize tsconfig paths configuration.\n * Reads tsconfig.json and extracts paths if defined.\n * Returns undefined if no tsconfigPath is specified or no paths are defined.\n */\nfunction normalizeTsconfigPaths(\n tsconfigPath: string | undefined,\n configDir: string,\n): Result<ResolvedTsconfigPaths | undefined, ConfigError> {\n if (!tsconfigPath) {\n return ok(undefined);\n }\n\n const resolvedPath = resolve(configDir, tsconfigPath);\n const result = readTsconfigPaths(resolvedPath);\n\n if (result.isErr()) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: result.error.message,\n }),\n );\n }\n\n // Return undefined if no paths defined in tsconfig\n if (result.value === null) {\n return ok(undefined);\n }\n\n return ok(result.value);\n}\n\n/**\n * Normalize graphql-compat config to resolved form.\n * Resolves glob patterns and validates schema name.\n */\nfunction normalizeGraphqlCompat(\n graphqlCompat: GraphqlCompatConfig | undefined,\n schemaNames: readonly string[],\n configDir: string,\n): Result<ResolvedGraphqlCompatConfig | undefined, ConfigError> {\n if (!graphqlCompat) {\n return ok(undefined);\n }\n\n let schemaName = graphqlCompat.schema;\n if (!schemaName) {\n if (schemaNames.length !== 1 || !schemaNames[0]) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: \"graphqlCompat.schema is required when multiple schemas are configured\",\n }),\n );\n }\n schemaName = schemaNames[0];\n }\n\n if (!schemaNames.includes(schemaName)) {\n return err(\n configError({\n code: \"CONFIG_VALIDATION_FAILED\",\n message: `graphqlCompat.schema \"${schemaName}\" not found in schemas config`,\n }),\n );\n }\n\n return ok({\n input: graphqlCompat.input.map((p) => resolvePattern(p, configDir)),\n schema: schemaName,\n suffix: graphqlCompat.suffix ?? \".compat.ts\",\n });\n}\n\n/**\n * Normalize codegen config to resolved form with defaults.\n */\nfunction normalizeCodegen(codegen: SodaGqlConfig[\"codegen\"]): ResolvedCodegenConfig {\n return {\n chunkSize: codegen?.chunkSize ?? 100,\n };\n}\n\n/**\n * Resolve and normalize config with defaults.\n * Paths in the config are resolved relative to the config file's directory.\n */\nexport function normalizeConfig(config: SodaGqlConfig, configPath: string): Result<ResolvedSodaGqlConfig, ConfigError> {\n const configDir = dirname(configPath);\n // Default analyzer to \"ts\"\n const analyzer = config.analyzer ?? \"ts\";\n\n // Default graphqlSystemAliases to [\"@/graphql-system\"]\n const graphqlSystemAliases = config.graphqlSystemAliases ?? [\"@/graphql-system\"];\n\n // Default exclude to empty array\n const exclude = config.exclude ?? [];\n\n // Normalize artifact config (only if path is specified)\n const artifact = normalizeArtifact(config.artifact, configDir);\n\n // Normalize tsconfig paths (only if path is specified and paths exist)\n const tsconfigPathsResult = normalizeTsconfigPaths(config.tsconfigPath, configDir);\n if (tsconfigPathsResult.isErr()) {\n return err(tsconfigPathsResult.error);\n }\n const tsconfigPaths = tsconfigPathsResult.value;\n\n // Normalize schemas with error handling\n const schemaEntries = Object.entries(config.schemas).map(([name, schemaConfig]) =>\n normalizeSchemaInput(schemaConfig.schema, configDir).map(\n (schema) =>\n [\n name,\n {\n schema,\n inject: normalizeInject(schemaConfig.inject, configDir),\n defaultInputDepth: schemaConfig.defaultInputDepth ?? 3,\n inputDepthOverrides: schemaConfig.inputDepthOverrides ?? {},\n ...(schemaConfig.typeFilter ? { typeFilter: schemaConfig.typeFilter } : {}),\n },\n ] as const,\n ),\n );\n\n const combinedResult = Result.combine(schemaEntries);\n if (combinedResult.isErr()) {\n return err(combinedResult.error);\n }\n const normalizedSchemas = Object.fromEntries(combinedResult.value);\n\n // Normalize graphql-compat config\n const schemaNames = Object.keys(config.schemas);\n const graphqlCompatResult = normalizeGraphqlCompat(config.graphqlCompat, schemaNames, configDir);\n if (graphqlCompatResult.isErr()) {\n return err(graphqlCompatResult.error);\n }\n const graphqlCompat = graphqlCompatResult.value;\n\n const resolved: ResolvedSodaGqlConfig = {\n analyzer,\n baseDir: configDir,\n outdir: resolve(configDir, config.outdir),\n graphqlSystemAliases,\n include: config.include.map((pattern) => resolvePattern(pattern, configDir)),\n exclude: exclude.map((pattern) => resolvePattern(pattern, configDir)),\n schemas: normalizedSchemas,\n styles: {\n importExtension: config.styles?.importExtension ?? false,\n },\n codegen: normalizeCodegen(config.codegen),\n plugins: config.plugins ?? {},\n ...(graphqlCompat ? { graphqlCompat } : {}),\n ...(artifact ? { artifact } : {}),\n ...(tsconfigPaths ? { tsconfigPaths } : {}),\n };\n\n return ok(resolved);\n}\n","import { existsSync, readdirSync, statSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport type { Result } from \"neverthrow\";\nimport { err } from \"neverthrow\";\nimport type { ConfigError } from \"./errors\";\nimport { configError } from \"./errors\";\nimport { executeConfigFile } from \"./evaluation\";\nimport { normalizeConfig } from \"./normalize\";\nimport type { ResolvedSodaGqlConfig } from \"./types\";\n\nexport const DEFAULT_CONFIG_FILENAMES = [\n \"soda-gql.config.ts\",\n \"soda-gql.config.mts\",\n \"soda-gql.config.js\",\n \"soda-gql.config.mjs\",\n] as const;\n\n/**\n * Find config file by walking up directory tree.\n */\nexport function findConfigFile(startDir: string = process.cwd()): string | null {\n let currentDir = startDir;\n while (currentDir !== dirname(currentDir)) {\n for (const filename of DEFAULT_CONFIG_FILENAMES) {\n const configPath = join(currentDir, filename);\n if (existsSync(configPath)) {\n return configPath;\n }\n }\n currentDir = dirname(currentDir);\n }\n return null;\n}\n\nconst SKIP_DIRS = new Set([\"node_modules\", \"dist\"]);\n\n/**\n * Find all config files by walking down from rootDir.\n * Discovers every soda-gql config file in the directory tree,\n * skipping node_modules, dist, and dot-prefixed directories.\n */\nexport function findAllConfigFiles(rootDir: string): readonly string[] {\n const results: string[] = [];\n\n const walk = (dir: string): void => {\n for (const filename of DEFAULT_CONFIG_FILENAMES) {\n const configPath = join(dir, filename);\n if (existsSync(configPath)) {\n results.push(configPath);\n break; // Only one config per directory\n }\n }\n\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n\n for (const entry of entries) {\n if (SKIP_DIRS.has(entry) || entry.startsWith(\".\")) {\n continue;\n }\n const fullPath = join(dir, entry);\n try {\n if (statSync(fullPath).isDirectory()) {\n walk(fullPath);\n }\n } catch {\n // Skip inaccessible entries\n }\n }\n };\n\n walk(rootDir);\n return results;\n}\n\n/**\n * Load config with Result type (for library use).\n */\nexport function loadConfig(configPath: string | undefined): Result<ResolvedSodaGqlConfig, ConfigError> {\n const resolvedPath = configPath ?? findConfigFile();\n\n if (!resolvedPath) {\n return err(configError({ code: \"CONFIG_NOT_FOUND\", message: \"Config file not found\" }));\n }\n\n try {\n const result = executeConfigFile(resolvedPath);\n if (result.isErr()) {\n return err(result.error);\n }\n return normalizeConfig(result.value, resolvedPath);\n } catch (error) {\n return err(\n configError({\n code: \"CONFIG_LOAD_FAILED\",\n message: `Failed to load config: ${error instanceof Error ? error.message : String(error)}`,\n filePath: resolvedPath,\n cause: error,\n }),\n );\n }\n}\n\n/**\n * Load config from specific directory.\n */\nexport function loadConfigFrom(dir: string): Result<ResolvedSodaGqlConfig, ConfigError> {\n const configPath = findConfigFile(dir);\n return loadConfig(configPath ?? undefined);\n}\n","export type { ConfigError, ConfigErrorCode } from \"./errors\";\nexport { configError } from \"./errors\";\nexport {\n defineConfig,\n type SodaGqlConfigContainer,\n validateConfig,\n} from \"./helper\";\nexport { findAllConfigFiles, findConfigFile, loadConfig, loadConfigFrom } from \"./loader\";\nexport { normalizeConfig } from \"./normalize\";\nexport type {\n ArtifactConfig,\n GraphqlCompatConfig,\n PluginConfig,\n ResolvedArtifactConfig,\n ResolvedGraphqlCompatConfig,\n ResolvedSodaGqlConfig,\n ResolvedTsconfigPaths,\n SchemaConfig,\n SodaGqlConfig,\n TypeCategory,\n TypeFilterConfig,\n TypeFilterRule,\n} from \"./types\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAa,eAAe,EAC1B,MACA,SACA,UACA,aAMkB;CAClB;CACA;CACA;CACA;CACD;;;;;;;;;ACHD,IAAa,yBAAb,MAAa,uBAAuB;CAClC,AAAQ,YAAY,AAAgBA,QAAuB;EAAvB;;CAEpC,OAAc,OAAO,QAA+C;AAClE,SAAO,IAAI,uBAAuB,OAAO;;;AAwC7C,SAAgB,a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MAAM,SAAS,kBAAkB,aAAa;AAC9C,MAAI,OAAO,OAAO,EAAE;AAClB,UAAO,IAAI,OAAO,MAAM;;AAE1B,SAAO,gBAAgB,OAAO,OAAO,aAAa;UAC3C,OAAO;AACd,SAAO,IACL,YAAY;GACV,MAAM;GACN,SAAS,0BAA0B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;GACzF,UAAU;GACV,OAAO;GACR,CAAC,CACH;;;;;;AAOL,SAAgB,eAAe,KAAyD;CACtF,MAAM,aAAa,eAAe,IAAI;AACtC,QAAO,WAAW,cAAc,UAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soda-gql/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "Centralized configuration loader and helpers for soda-gql tooling.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -38,9 +38,6 @@
|
|
|
38
38
|
"module": "./dist/index.mjs",
|
|
39
39
|
"types": "./dist/index.d.mts",
|
|
40
40
|
"exports": {
|
|
41
|
-
"./test": {
|
|
42
|
-
"@soda-gql": "./@devx-test.ts"
|
|
43
|
-
},
|
|
44
41
|
".": {
|
|
45
42
|
"@soda-gql": "./@x-index.ts",
|
|
46
43
|
"types": "./dist/index.d.mts",
|
|
@@ -48,10 +45,13 @@
|
|
|
48
45
|
"require": "./dist/index.cjs",
|
|
49
46
|
"default": "./dist/index.mjs"
|
|
50
47
|
},
|
|
48
|
+
"./test": {
|
|
49
|
+
"@soda-gql": "./@devx-test.ts"
|
|
50
|
+
},
|
|
51
51
|
"./package.json": "./package.json"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@soda-gql/common": "0.
|
|
54
|
+
"@soda-gql/common": "0.12.1",
|
|
55
55
|
"@swc/core": "^1.10.0",
|
|
56
56
|
"neverthrow": "^8.2.0",
|
|
57
57
|
"zod": "^4.1.11"
|