@soda-gql/config 0.11.9 → 0.11.11
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 +40 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +44 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +41 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -95,15 +95,18 @@ const SchemaConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({
|
|
|
95
95
|
inputDepthOverrides: zod.default.record(zod.default.string(), zod.default.number().int().positive()).optional()
|
|
96
96
|
});
|
|
97
97
|
const StylesConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({ importExtension: zod.default.boolean().optional() });
|
|
98
|
+
const CodegenConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({ chunkSize: zod.default.number().int().positive().optional() });
|
|
98
99
|
const ArtifactConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({ path: zod.default.string().min(1).optional() });
|
|
99
100
|
const SodaGqlConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({
|
|
100
101
|
analyzer: zod.default.enum(["ts", "swc"]).optional(),
|
|
101
102
|
outdir: zod.default.string().min(1),
|
|
102
103
|
graphqlSystemAliases: zod.default.array(zod.default.string()).optional(),
|
|
104
|
+
tsconfigPath: zod.default.string().min(1).optional(),
|
|
103
105
|
include: zod.default.array(zod.default.string().min(1)),
|
|
104
106
|
exclude: zod.default.array(zod.default.string().min(1)).optional(),
|
|
105
107
|
schemas: zod.default.record(zod.default.string(), SchemaConfigSchema),
|
|
106
108
|
styles: StylesConfigSchema.optional(),
|
|
109
|
+
codegen: CodegenConfigSchema.optional(),
|
|
107
110
|
plugins: zod.default.record(zod.default.string(), zod.default.unknown()).optional(),
|
|
108
111
|
artifact: ArtifactConfigSchema.optional()
|
|
109
112
|
});
|
|
@@ -233,6 +236,34 @@ function normalizeArtifact(artifact, configDir) {
|
|
|
233
236
|
return { path: (0, node_path.resolve)(configDir, artifact.path) };
|
|
234
237
|
}
|
|
235
238
|
/**
|
|
239
|
+
* Normalize tsconfig paths configuration.
|
|
240
|
+
* Reads tsconfig.json and extracts paths if defined.
|
|
241
|
+
* Returns undefined if no tsconfigPath is specified or no paths are defined.
|
|
242
|
+
*/
|
|
243
|
+
function normalizeTsconfigPaths(tsconfigPath, configDir) {
|
|
244
|
+
if (!tsconfigPath) {
|
|
245
|
+
return (0, neverthrow.ok)(undefined);
|
|
246
|
+
}
|
|
247
|
+
const resolvedPath = (0, node_path.resolve)(configDir, tsconfigPath);
|
|
248
|
+
const result = (0, __soda_gql_common.readTsconfigPaths)(resolvedPath);
|
|
249
|
+
if (result.isErr()) {
|
|
250
|
+
return (0, neverthrow.err)(configError({
|
|
251
|
+
code: "CONFIG_VALIDATION_FAILED",
|
|
252
|
+
message: result.error.message
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
255
|
+
if (result.value === null) {
|
|
256
|
+
return (0, neverthrow.ok)(undefined);
|
|
257
|
+
}
|
|
258
|
+
return (0, neverthrow.ok)(result.value);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Normalize codegen config to resolved form with defaults.
|
|
262
|
+
*/
|
|
263
|
+
function normalizeCodegen(codegen) {
|
|
264
|
+
return { chunkSize: codegen?.chunkSize ?? 100 };
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
236
267
|
* Resolve and normalize config with defaults.
|
|
237
268
|
* Paths in the config are resolved relative to the config file's directory.
|
|
238
269
|
*/
|
|
@@ -242,6 +273,11 @@ function normalizeConfig(config, configPath) {
|
|
|
242
273
|
const graphqlSystemAliases = config.graphqlSystemAliases ?? ["@/graphql-system"];
|
|
243
274
|
const exclude = config.exclude ?? [];
|
|
244
275
|
const artifact = normalizeArtifact(config.artifact, configDir);
|
|
276
|
+
const tsconfigPathsResult = normalizeTsconfigPaths(config.tsconfigPath, configDir);
|
|
277
|
+
if (tsconfigPathsResult.isErr()) {
|
|
278
|
+
return (0, neverthrow.err)(tsconfigPathsResult.error);
|
|
279
|
+
}
|
|
280
|
+
const tsconfigPaths = tsconfigPathsResult.value;
|
|
245
281
|
const schemaEntries = Object.entries(config.schemas).map(([name, schemaConfig]) => normalizeSchemaInput(schemaConfig.schema, configDir).map((schema) => [name, {
|
|
246
282
|
schema,
|
|
247
283
|
inject: normalizeInject(schemaConfig.inject, configDir),
|
|
@@ -255,14 +291,17 @@ function normalizeConfig(config, configPath) {
|
|
|
255
291
|
const normalizedSchemas = Object.fromEntries(combinedResult.value);
|
|
256
292
|
const resolved = {
|
|
257
293
|
analyzer,
|
|
294
|
+
baseDir: configDir,
|
|
258
295
|
outdir: (0, node_path.resolve)(configDir, config.outdir),
|
|
259
296
|
graphqlSystemAliases,
|
|
260
297
|
include: config.include.map((pattern) => resolvePattern(pattern, configDir)),
|
|
261
298
|
exclude: exclude.map((pattern) => resolvePattern(pattern, configDir)),
|
|
262
299
|
schemas: normalizedSchemas,
|
|
263
300
|
styles: { importExtension: config.styles?.importExtension ?? false },
|
|
301
|
+
codegen: normalizeCodegen(config.codegen),
|
|
264
302
|
plugins: config.plugins ?? {},
|
|
265
|
-
...artifact ? { artifact } : {}
|
|
303
|
+
...artifact ? { artifact } : {},
|
|
304
|
+
...tsconfigPaths ? { tsconfigPaths } : {}
|
|
266
305
|
};
|
|
267
306
|
return (0, neverthrow.ok)(resolved);
|
|
268
307
|
}
|
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>","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 { ArtifactConfig, InjectConfig, SchemaConfig, SchemaInput, SodaGqlConfig, StylesConfig } 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\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});\n\nconst StylesConfigSchema = defineSchemaFor<StylesConfig>()({\n importExtension: z.boolean().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 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 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 { err, ok, Result } from \"neverthrow\";\nimport { type ConfigError, configError } from \"./errors\";\nimport type {\n InjectConfig,\n ResolvedArtifactConfig,\n ResolvedInjectConfig,\n ResolvedSodaGqlConfig,\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 * 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 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 },\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 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 plugins: config.plugins ?? {},\n ...(artifact ? { artifact } : {}),\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 SchemaConfig,\n SodaGqlConfig,\n} from \"./types\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAa,eAAe,EAC1B,MACA,SACA,UACA,aAMkB;CAClB;CACA;CACA;CACA;CACD;;;;;;;;;ACbD,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,qBAA8CC,YAAE,MAAM,CAC1DA,YAAE,QAAQ,CAAC,IAAI,EAAE,EACjBA,YAAE,OAAO;CACP,SAASA,YAAE,QAAQ,CAAC,IAAI,EAAE;CAC1B,SAASA,YAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,UAAU;CACtC,CAAC,CACH,CAAC;AAIF,MAAMC,oBAA4CD,YAAE,MAAM;CACxDA,YAAE,QAAQ,CAAC,IAAI,EAAE;CACjBA,YAAE,MAAMA,YAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;CACjCA,YAAE,QAAiC,QAAQ,OAAO,QAAQ,WAAW;CACtE,CAAC;AAEF,MAAM,6DAAoD,CAAC;CACzD,QAAQ;CACR,QAAQ;CACR,mBAAmBA,YAAE,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,UAAU;CACjE,qBAAqBA,YAAE,OAAOA,YAAE,QAAQ,EAAEA,YAAE,QAAQ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C5E,SAAS,QAAQ,KAAK,YAAY,eAAe,SAAS,UAAU,CAAC;EACrE,SAAS;EACT,QAAQ,EACN,iBAAiB,OAAO,QAAQ,mBAAmB,OACpD;EACD,SAAS,OAAO,WAAW,EAAE;EAC7B,GAAI,WAAW,EAAE,UAAU,GAAG,EAAE;EACjC;AAED,2BAAU,SAAS;;;;;AC5HrB,MAAa,2BAA2B;CACtC;CACA;CACA;CACA;CACD;;;;AAKD,SAAgB,eAAe,WAAmB,QAAQ,KAAK,EAAiB;CAC9E,IAAI,aAAa;AACjB,QAAO,sCAAuB,WAAW,EAAE;AACzC,OAAK,MAAM,YAAY,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>","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} 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\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});\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 },\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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AM,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"}
|
package/dist/index.d.cts
CHANGED
|
@@ -79,9 +79,19 @@ type StylesConfig = {
|
|
|
79
79
|
*/
|
|
80
80
|
readonly importExtension?: boolean;
|
|
81
81
|
};
|
|
82
|
+
type CodegenConfig = {
|
|
83
|
+
/**
|
|
84
|
+
* Number of definitions per chunk file.
|
|
85
|
+
* @default 100
|
|
86
|
+
*/
|
|
87
|
+
readonly chunkSize?: number;
|
|
88
|
+
};
|
|
82
89
|
type ResolvedStylesConfig = {
|
|
83
90
|
readonly importExtension: boolean;
|
|
84
91
|
};
|
|
92
|
+
type ResolvedCodegenConfig = {
|
|
93
|
+
readonly chunkSize: number;
|
|
94
|
+
};
|
|
85
95
|
type PluginConfig = Record<string, unknown>;
|
|
86
96
|
/**
|
|
87
97
|
* Configuration for pre-built artifact loading.
|
|
@@ -102,6 +112,16 @@ type ArtifactConfig = {
|
|
|
102
112
|
type ResolvedArtifactConfig = {
|
|
103
113
|
readonly path: string;
|
|
104
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* Resolved tsconfig.json paths configuration.
|
|
117
|
+
* Contains absolute paths for all path mappings.
|
|
118
|
+
*/
|
|
119
|
+
type ResolvedTsconfigPaths = {
|
|
120
|
+
/** Absolute base URL for path resolution */
|
|
121
|
+
readonly baseUrl: string;
|
|
122
|
+
/** Path mappings with absolute paths */
|
|
123
|
+
readonly paths: Readonly<Record<string, readonly string[]>>;
|
|
124
|
+
};
|
|
105
125
|
type SodaGqlConfig = {
|
|
106
126
|
/**
|
|
107
127
|
* The analyzer to use for the project.
|
|
@@ -122,6 +142,13 @@ type SodaGqlConfig = {
|
|
|
122
142
|
* @example ["@/graphql-system"]
|
|
123
143
|
*/
|
|
124
144
|
readonly graphqlSystemAliases?: readonly string[];
|
|
145
|
+
/**
|
|
146
|
+
* Path to tsconfig.json for path alias resolution.
|
|
147
|
+
* When specified, compilerOptions.paths will be used to resolve import aliases.
|
|
148
|
+
*
|
|
149
|
+
* @example "./tsconfig.json"
|
|
150
|
+
*/
|
|
151
|
+
readonly tsconfigPath?: string;
|
|
125
152
|
/**
|
|
126
153
|
* The files to include in the project.
|
|
127
154
|
*
|
|
@@ -144,6 +171,10 @@ type SodaGqlConfig = {
|
|
|
144
171
|
* Output styles configuration for generated code.
|
|
145
172
|
*/
|
|
146
173
|
readonly styles?: StylesConfig;
|
|
174
|
+
/**
|
|
175
|
+
* Codegen-specific configuration.
|
|
176
|
+
*/
|
|
177
|
+
readonly codegen?: CodegenConfig;
|
|
147
178
|
/**
|
|
148
179
|
* The plugins to use for the project.
|
|
149
180
|
*/
|
|
@@ -174,18 +205,30 @@ type ResolvedSchemaConfig = {
|
|
|
174
205
|
};
|
|
175
206
|
type ResolvedSodaGqlConfig = {
|
|
176
207
|
readonly analyzer: "ts" | "swc";
|
|
208
|
+
/**
|
|
209
|
+
* The base directory for the project (config file's directory).
|
|
210
|
+
* All relative paths in artifacts are resolved relative to this directory.
|
|
211
|
+
* This enables portable artifacts that can be shared across different machines.
|
|
212
|
+
*/
|
|
213
|
+
readonly baseDir: string;
|
|
177
214
|
readonly outdir: string;
|
|
178
215
|
readonly graphqlSystemAliases: readonly string[];
|
|
179
216
|
readonly include: readonly string[];
|
|
180
217
|
readonly exclude: readonly string[];
|
|
181
218
|
readonly schemas: Readonly<Record<string, ResolvedSchemaConfig>>;
|
|
182
219
|
readonly styles: ResolvedStylesConfig;
|
|
220
|
+
readonly codegen: ResolvedCodegenConfig;
|
|
183
221
|
readonly plugins: PluginConfig;
|
|
184
222
|
/**
|
|
185
223
|
* Resolved artifact configuration.
|
|
186
224
|
* Only present when artifact.path is specified in the config.
|
|
187
225
|
*/
|
|
188
226
|
readonly artifact?: ResolvedArtifactConfig;
|
|
227
|
+
/**
|
|
228
|
+
* Resolved tsconfig paths configuration.
|
|
229
|
+
* Only present when tsconfigPath is specified and the tsconfig contains paths.
|
|
230
|
+
*/
|
|
231
|
+
readonly tsconfigPaths?: ResolvedTsconfigPaths;
|
|
189
232
|
};
|
|
190
233
|
//#endregion
|
|
191
234
|
//#region packages/config/src/helper.d.ts
|
|
@@ -259,5 +302,5 @@ declare function loadConfigFrom(dir: string): Result<ResolvedSodaGqlConfig, Conf
|
|
|
259
302
|
*/
|
|
260
303
|
declare function normalizeConfig(config: SodaGqlConfig, configPath: string): Result<ResolvedSodaGqlConfig, ConfigError>;
|
|
261
304
|
//#endregion
|
|
262
|
-
export { type ArtifactConfig, type ConfigError, type ConfigErrorCode, type PluginConfig, type ResolvedArtifactConfig, type ResolvedSodaGqlConfig, type SchemaConfig, type SodaGqlConfig, type SodaGqlConfigContainer, configError, defineConfig, findConfigFile, loadConfig, loadConfigFrom, normalizeConfig, validateConfig };
|
|
305
|
+
export { type ArtifactConfig, type ConfigError, type ConfigErrorCode, type PluginConfig, type ResolvedArtifactConfig, type ResolvedSodaGqlConfig, type ResolvedTsconfigPaths, type SchemaConfig, type SodaGqlConfig, type SodaGqlConfigContainer, configError, defineConfig, findConfigFile, loadConfig, loadConfigFrom, normalizeConfig, validateConfig };
|
|
263
306
|
//# 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;CAKF,EAAA,GALE,WAKF;;;;;;AAxBF;AAEA;AAOA;;;;;AAMQ,KCLI,YAAA,GDKJ,MAAA,GAAA;EAIJ,SAAA,OAAA,EAAA,MAAA;EAKF,SAAA,OAAA,CAAA,EAAA,MAAA;;;;ACdF;AAeA;AAGA;;;;AAwBiC,KA3BrB,WAAA,GA2BqB,MAAA,GAAA,SAAA,MAAA,EAAA,GAAA,CAAA,GAAA,GAAA,SAAA,MAAA,EAAA,CAAA;AAAQ,KAxB7B,YAAA,GAwB6B;EAI7B,SAAA,MAAY,EA3BL,WA2BK;EAWZ;
|
|
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,OA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IwHgD,MJxHhD,CIwHuD,qBJxHvD,EIwH8E,WJxH9E,CAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -79,9 +79,19 @@ type StylesConfig = {
|
|
|
79
79
|
*/
|
|
80
80
|
readonly importExtension?: boolean;
|
|
81
81
|
};
|
|
82
|
+
type CodegenConfig = {
|
|
83
|
+
/**
|
|
84
|
+
* Number of definitions per chunk file.
|
|
85
|
+
* @default 100
|
|
86
|
+
*/
|
|
87
|
+
readonly chunkSize?: number;
|
|
88
|
+
};
|
|
82
89
|
type ResolvedStylesConfig = {
|
|
83
90
|
readonly importExtension: boolean;
|
|
84
91
|
};
|
|
92
|
+
type ResolvedCodegenConfig = {
|
|
93
|
+
readonly chunkSize: number;
|
|
94
|
+
};
|
|
85
95
|
type PluginConfig = Record<string, unknown>;
|
|
86
96
|
/**
|
|
87
97
|
* Configuration for pre-built artifact loading.
|
|
@@ -102,6 +112,16 @@ type ArtifactConfig = {
|
|
|
102
112
|
type ResolvedArtifactConfig = {
|
|
103
113
|
readonly path: string;
|
|
104
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* Resolved tsconfig.json paths configuration.
|
|
117
|
+
* Contains absolute paths for all path mappings.
|
|
118
|
+
*/
|
|
119
|
+
type ResolvedTsconfigPaths = {
|
|
120
|
+
/** Absolute base URL for path resolution */
|
|
121
|
+
readonly baseUrl: string;
|
|
122
|
+
/** Path mappings with absolute paths */
|
|
123
|
+
readonly paths: Readonly<Record<string, readonly string[]>>;
|
|
124
|
+
};
|
|
105
125
|
type SodaGqlConfig = {
|
|
106
126
|
/**
|
|
107
127
|
* The analyzer to use for the project.
|
|
@@ -122,6 +142,13 @@ type SodaGqlConfig = {
|
|
|
122
142
|
* @example ["@/graphql-system"]
|
|
123
143
|
*/
|
|
124
144
|
readonly graphqlSystemAliases?: readonly string[];
|
|
145
|
+
/**
|
|
146
|
+
* Path to tsconfig.json for path alias resolution.
|
|
147
|
+
* When specified, compilerOptions.paths will be used to resolve import aliases.
|
|
148
|
+
*
|
|
149
|
+
* @example "./tsconfig.json"
|
|
150
|
+
*/
|
|
151
|
+
readonly tsconfigPath?: string;
|
|
125
152
|
/**
|
|
126
153
|
* The files to include in the project.
|
|
127
154
|
*
|
|
@@ -144,6 +171,10 @@ type SodaGqlConfig = {
|
|
|
144
171
|
* Output styles configuration for generated code.
|
|
145
172
|
*/
|
|
146
173
|
readonly styles?: StylesConfig;
|
|
174
|
+
/**
|
|
175
|
+
* Codegen-specific configuration.
|
|
176
|
+
*/
|
|
177
|
+
readonly codegen?: CodegenConfig;
|
|
147
178
|
/**
|
|
148
179
|
* The plugins to use for the project.
|
|
149
180
|
*/
|
|
@@ -174,18 +205,30 @@ type ResolvedSchemaConfig = {
|
|
|
174
205
|
};
|
|
175
206
|
type ResolvedSodaGqlConfig = {
|
|
176
207
|
readonly analyzer: "ts" | "swc";
|
|
208
|
+
/**
|
|
209
|
+
* The base directory for the project (config file's directory).
|
|
210
|
+
* All relative paths in artifacts are resolved relative to this directory.
|
|
211
|
+
* This enables portable artifacts that can be shared across different machines.
|
|
212
|
+
*/
|
|
213
|
+
readonly baseDir: string;
|
|
177
214
|
readonly outdir: string;
|
|
178
215
|
readonly graphqlSystemAliases: readonly string[];
|
|
179
216
|
readonly include: readonly string[];
|
|
180
217
|
readonly exclude: readonly string[];
|
|
181
218
|
readonly schemas: Readonly<Record<string, ResolvedSchemaConfig>>;
|
|
182
219
|
readonly styles: ResolvedStylesConfig;
|
|
220
|
+
readonly codegen: ResolvedCodegenConfig;
|
|
183
221
|
readonly plugins: PluginConfig;
|
|
184
222
|
/**
|
|
185
223
|
* Resolved artifact configuration.
|
|
186
224
|
* Only present when artifact.path is specified in the config.
|
|
187
225
|
*/
|
|
188
226
|
readonly artifact?: ResolvedArtifactConfig;
|
|
227
|
+
/**
|
|
228
|
+
* Resolved tsconfig paths configuration.
|
|
229
|
+
* Only present when tsconfigPath is specified and the tsconfig contains paths.
|
|
230
|
+
*/
|
|
231
|
+
readonly tsconfigPaths?: ResolvedTsconfigPaths;
|
|
189
232
|
};
|
|
190
233
|
//#endregion
|
|
191
234
|
//#region packages/config/src/helper.d.ts
|
|
@@ -259,5 +302,5 @@ declare function loadConfigFrom(dir: string): Result<ResolvedSodaGqlConfig, Conf
|
|
|
259
302
|
*/
|
|
260
303
|
declare function normalizeConfig(config: SodaGqlConfig, configPath: string): Result<ResolvedSodaGqlConfig, ConfigError>;
|
|
261
304
|
//#endregion
|
|
262
|
-
export { type ArtifactConfig, type ConfigError, type ConfigErrorCode, type PluginConfig, type ResolvedArtifactConfig, type ResolvedSodaGqlConfig, type SchemaConfig, type SodaGqlConfig, type SodaGqlConfigContainer, configError, defineConfig, findConfigFile, loadConfig, loadConfigFrom, normalizeConfig, validateConfig };
|
|
305
|
+
export { type ArtifactConfig, type ConfigError, type ConfigErrorCode, type PluginConfig, type ResolvedArtifactConfig, type ResolvedSodaGqlConfig, type ResolvedTsconfigPaths, type SchemaConfig, type SodaGqlConfig, type SodaGqlConfigContainer, configError, defineConfig, findConfigFile, loadConfig, loadConfigFrom, normalizeConfig, validateConfig };
|
|
263
306
|
//# 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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WA;AASA;AAKA;AAKA;AAMA;AAaA;AAQA;AAQA;;;;;;;;;AAyEA;AAMA;;;;;AAQY,iBCnJI,YAAA,CDmJiB,MAAA,ECnJI,aDmJJ,CAAA,ECnJoB,sBDmJpB;AAYW,iBC9J5B,YAAA,CD8J4B,MAAA,EAAA,GAAA,GC9JD,aD8JC,CAAA,EC9Je,sBD8Jf;AAAf,iBClGb,cAAA,CDkGa,MAAA,EAAA,OAAA,CAAA,EClGoB,MDkGpB,CClG2B,aDkG3B,EClG0C,WDkG1C,CAAA;;;AD5NjB,cGUC,wBHVc,EAAA,SAAA,CAAA,oBAAA,EAAA,qBAAA,EAAA,oBAAA,EAAA,qBAAA,CAAA;AAE3B;AAOA;;AAA4B,iBGWZ,cAAA,CHXY,QAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA,GAAA,IAAA;;;;AAUxB,iBGkBY,UAAA,CHlBZ,UAAA,EAAA,MAAA,GAAA,SAAA,CAAA,EGkBwD,MHlBxD,CGkB+D,qBHlB/D,EGkBsF,WHlBtF,CAAA;;;;iBG8CY,cAAA,eAA6B,OAAO,uBAAuB;;;AHjE3E;AAEA;AAOA;;AAA4B,iBIwHZ,eAAA,CJxHY,MAAA,EIwHY,aJxHZ,EAAA,UAAA,EAAA,MAAA,CAAA,EIwHgD,MJxHhD,CIwHuD,qBJxHvD,EIwH8E,WJxH9E,CAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { defineSchemaFor, resolveRelativeImportWithExistenceCheck } from "@soda-gql/common";
|
|
2
|
+
import { defineSchemaFor, readTsconfigPaths, resolveRelativeImportWithExistenceCheck } from "@soda-gql/common";
|
|
3
3
|
import { Result, err, ok } from "neverthrow";
|
|
4
4
|
import z from "zod";
|
|
5
5
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -71,15 +71,18 @@ const SchemaConfigSchema = defineSchemaFor()({
|
|
|
71
71
|
inputDepthOverrides: z.record(z.string(), z.number().int().positive()).optional()
|
|
72
72
|
});
|
|
73
73
|
const StylesConfigSchema = defineSchemaFor()({ importExtension: z.boolean().optional() });
|
|
74
|
+
const CodegenConfigSchema = defineSchemaFor()({ chunkSize: z.number().int().positive().optional() });
|
|
74
75
|
const ArtifactConfigSchema = defineSchemaFor()({ path: z.string().min(1).optional() });
|
|
75
76
|
const SodaGqlConfigSchema = defineSchemaFor()({
|
|
76
77
|
analyzer: z.enum(["ts", "swc"]).optional(),
|
|
77
78
|
outdir: z.string().min(1),
|
|
78
79
|
graphqlSystemAliases: z.array(z.string()).optional(),
|
|
80
|
+
tsconfigPath: z.string().min(1).optional(),
|
|
79
81
|
include: z.array(z.string().min(1)),
|
|
80
82
|
exclude: z.array(z.string().min(1)).optional(),
|
|
81
83
|
schemas: z.record(z.string(), SchemaConfigSchema),
|
|
82
84
|
styles: StylesConfigSchema.optional(),
|
|
85
|
+
codegen: CodegenConfigSchema.optional(),
|
|
83
86
|
plugins: z.record(z.string(), z.unknown()).optional(),
|
|
84
87
|
artifact: ArtifactConfigSchema.optional()
|
|
85
88
|
});
|
|
@@ -209,6 +212,34 @@ function normalizeArtifact(artifact, configDir) {
|
|
|
209
212
|
return { path: resolve(configDir, artifact.path) };
|
|
210
213
|
}
|
|
211
214
|
/**
|
|
215
|
+
* Normalize tsconfig paths configuration.
|
|
216
|
+
* Reads tsconfig.json and extracts paths if defined.
|
|
217
|
+
* Returns undefined if no tsconfigPath is specified or no paths are defined.
|
|
218
|
+
*/
|
|
219
|
+
function normalizeTsconfigPaths(tsconfigPath, configDir) {
|
|
220
|
+
if (!tsconfigPath) {
|
|
221
|
+
return ok(undefined);
|
|
222
|
+
}
|
|
223
|
+
const resolvedPath = resolve(configDir, tsconfigPath);
|
|
224
|
+
const result = readTsconfigPaths(resolvedPath);
|
|
225
|
+
if (result.isErr()) {
|
|
226
|
+
return err(configError({
|
|
227
|
+
code: "CONFIG_VALIDATION_FAILED",
|
|
228
|
+
message: result.error.message
|
|
229
|
+
}));
|
|
230
|
+
}
|
|
231
|
+
if (result.value === null) {
|
|
232
|
+
return ok(undefined);
|
|
233
|
+
}
|
|
234
|
+
return ok(result.value);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Normalize codegen config to resolved form with defaults.
|
|
238
|
+
*/
|
|
239
|
+
function normalizeCodegen(codegen) {
|
|
240
|
+
return { chunkSize: codegen?.chunkSize ?? 100 };
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
212
243
|
* Resolve and normalize config with defaults.
|
|
213
244
|
* Paths in the config are resolved relative to the config file's directory.
|
|
214
245
|
*/
|
|
@@ -218,6 +249,11 @@ function normalizeConfig(config, configPath) {
|
|
|
218
249
|
const graphqlSystemAliases = config.graphqlSystemAliases ?? ["@/graphql-system"];
|
|
219
250
|
const exclude = config.exclude ?? [];
|
|
220
251
|
const artifact = normalizeArtifact(config.artifact, configDir);
|
|
252
|
+
const tsconfigPathsResult = normalizeTsconfigPaths(config.tsconfigPath, configDir);
|
|
253
|
+
if (tsconfigPathsResult.isErr()) {
|
|
254
|
+
return err(tsconfigPathsResult.error);
|
|
255
|
+
}
|
|
256
|
+
const tsconfigPaths = tsconfigPathsResult.value;
|
|
221
257
|
const schemaEntries = Object.entries(config.schemas).map(([name, schemaConfig]) => normalizeSchemaInput(schemaConfig.schema, configDir).map((schema) => [name, {
|
|
222
258
|
schema,
|
|
223
259
|
inject: normalizeInject(schemaConfig.inject, configDir),
|
|
@@ -231,14 +267,17 @@ function normalizeConfig(config, configPath) {
|
|
|
231
267
|
const normalizedSchemas = Object.fromEntries(combinedResult.value);
|
|
232
268
|
const resolved = {
|
|
233
269
|
analyzer,
|
|
270
|
+
baseDir: configDir,
|
|
234
271
|
outdir: resolve(configDir, config.outdir),
|
|
235
272
|
graphqlSystemAliases,
|
|
236
273
|
include: config.include.map((pattern) => resolvePattern(pattern, configDir)),
|
|
237
274
|
exclude: exclude.map((pattern) => resolvePattern(pattern, configDir)),
|
|
238
275
|
schemas: normalizedSchemas,
|
|
239
276
|
styles: { importExtension: config.styles?.importExtension ?? false },
|
|
277
|
+
codegen: normalizeCodegen(config.codegen),
|
|
240
278
|
plugins: config.plugins ?? {},
|
|
241
|
-
...artifact ? { artifact } : {}
|
|
279
|
+
...artifact ? { artifact } : {},
|
|
280
|
+
...tsconfigPaths ? { tsconfigPaths } : {}
|
|
242
281
|
};
|
|
243
282
|
return ok(resolved);
|
|
244
283
|
}
|
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>","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 { ArtifactConfig, InjectConfig, SchemaConfig, SchemaInput, SodaGqlConfig, StylesConfig } 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\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});\n\nconst StylesConfigSchema = defineSchemaFor<StylesConfig>()({\n importExtension: z.boolean().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 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 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 { err, ok, Result } from \"neverthrow\";\nimport { type ConfigError, configError } from \"./errors\";\nimport type {\n InjectConfig,\n ResolvedArtifactConfig,\n ResolvedInjectConfig,\n ResolvedSodaGqlConfig,\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 * 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 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 },\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 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 plugins: config.plugins ?? {},\n ...(artifact ? { artifact } : {}),\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 SchemaConfig,\n SodaGqlConfig,\n} from \"./types\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAa,eAAe,EAC1B,MACA,SACA,UACA,aAMkB;CAClB;CACA;CACA;CACA;CACD;;;;;;;;;ACbD,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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rG,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>","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} 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\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});\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 },\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} from \"./types\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAa,eAAe,EAC1B,MACA,SACA,UACA,aAMkB;CAClB;CACA;CACA;CACA;CACD;;;;;;;;;ACLD,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,EA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ACV,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.11.
|
|
3
|
+
"version": "0.11.11",
|
|
4
4
|
"description": "Centralized configuration loader and helpers for soda-gql tooling.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"./package.json": "./package.json"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@soda-gql/common": "0.11.
|
|
54
|
+
"@soda-gql/common": "0.11.11",
|
|
55
55
|
"@swc/core": "^1.10.0",
|
|
56
56
|
"neverthrow": "^8.2.0",
|
|
57
57
|
"zod": "^4.1.11"
|