@soda-gql/config 0.5.3 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -90,6 +90,7 @@ const SchemaConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({
90
90
  inputDepthOverrides: zod.default.record(zod.default.string(), zod.default.number().int().positive()).optional()
91
91
  });
92
92
  const StylesConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({ importExtension: zod.default.boolean().optional() });
93
+ const ArtifactConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({ path: zod.default.string().min(1).optional() });
93
94
  const SodaGqlConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({
94
95
  analyzer: zod.default.enum(["ts", "swc"]).optional(),
95
96
  outdir: zod.default.string().min(1),
@@ -98,7 +99,8 @@ const SodaGqlConfigSchema = (0, __soda_gql_common.defineSchemaFor)()({
98
99
  exclude: zod.default.array(zod.default.string().min(1)).optional(),
99
100
  schemas: zod.default.record(zod.default.string(), SchemaConfigSchema),
100
101
  styles: StylesConfigSchema.optional(),
101
- plugins: zod.default.record(zod.default.string(), zod.default.unknown()).optional()
102
+ plugins: zod.default.record(zod.default.string(), zod.default.unknown()).optional(),
103
+ artifact: ArtifactConfigSchema.optional()
102
104
  });
103
105
  function validateConfig(config) {
104
106
  const result = SodaGqlConfigSchema.safeParse(config);
@@ -189,6 +191,16 @@ function normalizeInject(inject, configDir) {
189
191
  };
190
192
  }
191
193
  /**
194
+ * Normalize artifact config to resolved form.
195
+ * Returns undefined if no path is specified.
196
+ */
197
+ function normalizeArtifact(artifact, configDir) {
198
+ if (!artifact?.path) {
199
+ return undefined;
200
+ }
201
+ return { path: (0, node_path.resolve)(configDir, artifact.path) };
202
+ }
203
+ /**
192
204
  * Resolve and normalize config with defaults.
193
205
  * Paths in the config are resolved relative to the config file's directory.
194
206
  */
@@ -197,6 +209,7 @@ function normalizeConfig(config, configPath) {
197
209
  const analyzer = config.analyzer ?? "ts";
198
210
  const graphqlSystemAliases = config.graphqlSystemAliases ?? ["@/graphql-system"];
199
211
  const exclude = config.exclude ?? [];
212
+ const artifact = normalizeArtifact(config.artifact, configDir);
200
213
  const resolved = {
201
214
  analyzer,
202
215
  outdir: (0, node_path.resolve)(configDir, config.outdir),
@@ -210,7 +223,8 @@ function normalizeConfig(config, configPath) {
210
223
  inputDepthOverrides: schemaConfig.inputDepthOverrides ?? {}
211
224
  }])),
212
225
  styles: { importExtension: config.styles?.importExtension ?? false },
213
- plugins: config.plugins ?? {}
226
+ plugins: config.plugins ?? {},
227
+ ...artifact ? { artifact } : {}
214
228
  };
215
229
  return (0, neverthrow.ok)(resolved);
216
230
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["config: SodaGqlConfig","InjectConfigSchema: z.ZodType<InjectConfig>","z","mod: { exports: unknown }","require","configModule","Script","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 { InjectConfig, SchemaConfig, 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\nconst SchemaConfigSchema = defineSchemaFor<SchemaConfig>()({\n schema: z.string().min(1),\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 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});\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 type { Result } from \"neverthrow\";\nimport { ok } from \"neverthrow\";\nimport type { ConfigError } from \"./errors\";\nimport type { InjectConfig, ResolvedInjectConfig, ResolvedSodaGqlConfig, SodaGqlConfig } from \"./types\";\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 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 const resolved: ResolvedSodaGqlConfig = {\n analyzer,\n outdir: resolve(configDir, config.outdir),\n graphqlSystemAliases,\n include: config.include.map((pattern) => resolve(configDir, pattern)),\n exclude: exclude.map((pattern) => resolve(configDir, pattern)),\n schemas: Object.fromEntries(\n Object.entries(config.schemas).map(([name, schemaConfig]) => [\n name,\n {\n schema: resolve(configDir, schemaConfig.schema),\n inject: normalizeInject(schemaConfig.inject, configDir),\n defaultInputDepth: schemaConfig.defaultInputDepth ?? 3,\n inputDepthOverrides: schemaConfig.inputDepthOverrides ?? {},\n },\n ]),\n ),\n styles: {\n importExtension: config.styles?.importExtension ?? false,\n },\n plugins: config.plugins ?? {},\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 PluginConfig,\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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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","mod: { exports: unknown }","require","configModule","Script","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, 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\nconst SchemaConfigSchema = defineSchemaFor<SchemaConfig>()({\n schema: z.string().min(1),\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 type { Result } from \"neverthrow\";\nimport { ok } from \"neverthrow\";\nimport type { ConfigError } from \"./errors\";\nimport type { InjectConfig, ResolvedArtifactConfig, ResolvedInjectConfig, ResolvedSodaGqlConfig, SodaGqlConfig } from \"./types\";\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 * 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 const resolved: ResolvedSodaGqlConfig = {\n analyzer,\n outdir: resolve(configDir, config.outdir),\n graphqlSystemAliases,\n include: config.include.map((pattern) => resolve(configDir, pattern)),\n exclude: exclude.map((pattern) => resolve(configDir, pattern)),\n schemas: Object.fromEntries(\n Object.entries(config.schemas).map(([name, schemaConfig]) => [\n name,\n {\n schema: resolve(configDir, schemaConfig.schema),\n inject: normalizeInject(schemaConfig.inject, configDir),\n defaultInputDepth: schemaConfig.defaultInputDepth ?? 3,\n inputDepthOverrides: schemaConfig.inputDepthOverrides ?? {},\n },\n ]),\n ),\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,OA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,gBAAgB,aAAa,QAAQ,UAAU;GACvD,mBAAmB,aAAa,qBAAqB;GACrD,qBAAqB,aAAa,uBAAuB,EAAE;GAC5D,CACF,CAAC,CACH;EACD,QAAQ,EACN,iBAAiB,OAAO,QAAQ,mBAAmB,OACpD;EACD,SAAS,OAAO,WAAW,EAAE;EAC7B,GAAI,WAAW,EAAE,UAAU,GAAG,EAAE;EACjC;AAED,2BAAU,SAAS;;;;;ACrErB,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"}
package/dist/index.d.cts CHANGED
@@ -74,6 +74,25 @@ type ResolvedStylesConfig = {
74
74
  readonly importExtension: boolean;
75
75
  };
76
76
  type PluginConfig = Record<string, unknown>;
77
+ /**
78
+ * Configuration for pre-built artifact loading.
79
+ * When specified, plugins will load the artifact from the file instead of building dynamically.
80
+ */
81
+ type ArtifactConfig = {
82
+ /**
83
+ * Path to pre-built artifact JSON file.
84
+ * This path is resolved relative to the config file's directory.
85
+ *
86
+ * @example "./dist/soda-gql-artifact.json"
87
+ */
88
+ readonly path?: string;
89
+ };
90
+ /**
91
+ * Resolved artifact configuration with absolute path.
92
+ */
93
+ type ResolvedArtifactConfig = {
94
+ readonly path: string;
95
+ };
77
96
  type SodaGqlConfig = {
78
97
  /**
79
98
  * The analyzer to use for the project.
@@ -120,6 +139,19 @@ type SodaGqlConfig = {
120
139
  * The plugins to use for the project.
121
140
  */
122
141
  readonly plugins?: PluginConfig;
142
+ /**
143
+ * Configuration for pre-built artifact loading.
144
+ * When specified, plugins will load the artifact from the file instead of building dynamically.
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * // Use pre-built artifact in CI/production
149
+ * artifact: process.env.CI
150
+ * ? { path: "./dist/soda-gql-artifact.json" }
151
+ * : undefined
152
+ * ```
153
+ */
154
+ readonly artifact?: ArtifactConfig;
123
155
  };
124
156
  type ResolvedInjectConfig = {
125
157
  readonly scalars: string;
@@ -140,6 +172,11 @@ type ResolvedSodaGqlConfig = {
140
172
  readonly schemas: Readonly<Record<string, ResolvedSchemaConfig>>;
141
173
  readonly styles: ResolvedStylesConfig;
142
174
  readonly plugins: PluginConfig;
175
+ /**
176
+ * Resolved artifact configuration.
177
+ * Only present when artifact.path is specified in the config.
178
+ */
179
+ readonly artifact?: ResolvedArtifactConfig;
143
180
  };
144
181
  //#endregion
145
182
  //#region packages/config/src/helper.d.ts
@@ -213,5 +250,5 @@ declare function loadConfigFrom(dir: string): Result<ResolvedSodaGqlConfig, Conf
213
250
  */
214
251
  declare function normalizeConfig(config: SodaGqlConfig, configPath: string): Result<ResolvedSodaGqlConfig, ConfigError>;
215
252
  //#endregion
216
- export { type ConfigError, type ConfigErrorCode, type PluginConfig, type ResolvedSodaGqlConfig, type SchemaConfig, type SodaGqlConfig, type SodaGqlConfigContainer, configError, defineConfig, findConfigFile, loadConfig, loadConfigFrom, normalizeConfig, validateConfig };
253
+ 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 };
217
254
  //# sourceMappingURL=index.d.cts.map
@@ -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;;KCNU,YAAA;;EARA;AAQZ;;;;;AA4BA;EAWY,SAAA,MAAA,EA9BO,YA8Ba;EAKpB;AAGZ;;;;;;EA6CiC,SAAA,iBAAA,CAAA,EAAA,MAAA;EAIrB;AAMZ;;;;;EAQY,SAAA,mBAAqB,CAAA,EAtFA,QAsFA,CAtFS,MAsFT,CAAA,MAAA,EAAA,MAAA,CAAA,CAAA;CAMW;AAAf,KAxFjB,YAAA,GAwFiB;EAAT;;;;;;;AC3HpB,CAAA;AAC8C,KD6Cl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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,iBIgCZ,eAAA,CJhCY,MAAA,EIgCY,aJhCZ,EAAA,UAAA,EAAA,MAAA,CAAA,EIgCgD,MJhChD,CIgCuD,qBJhCvD,EIgC8E,WJhC9E,CAAA"}
package/dist/index.d.mts CHANGED
@@ -74,6 +74,25 @@ type ResolvedStylesConfig = {
74
74
  readonly importExtension: boolean;
75
75
  };
76
76
  type PluginConfig = Record<string, unknown>;
77
+ /**
78
+ * Configuration for pre-built artifact loading.
79
+ * When specified, plugins will load the artifact from the file instead of building dynamically.
80
+ */
81
+ type ArtifactConfig = {
82
+ /**
83
+ * Path to pre-built artifact JSON file.
84
+ * This path is resolved relative to the config file's directory.
85
+ *
86
+ * @example "./dist/soda-gql-artifact.json"
87
+ */
88
+ readonly path?: string;
89
+ };
90
+ /**
91
+ * Resolved artifact configuration with absolute path.
92
+ */
93
+ type ResolvedArtifactConfig = {
94
+ readonly path: string;
95
+ };
77
96
  type SodaGqlConfig = {
78
97
  /**
79
98
  * The analyzer to use for the project.
@@ -120,6 +139,19 @@ type SodaGqlConfig = {
120
139
  * The plugins to use for the project.
121
140
  */
122
141
  readonly plugins?: PluginConfig;
142
+ /**
143
+ * Configuration for pre-built artifact loading.
144
+ * When specified, plugins will load the artifact from the file instead of building dynamically.
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * // Use pre-built artifact in CI/production
149
+ * artifact: process.env.CI
150
+ * ? { path: "./dist/soda-gql-artifact.json" }
151
+ * : undefined
152
+ * ```
153
+ */
154
+ readonly artifact?: ArtifactConfig;
123
155
  };
124
156
  type ResolvedInjectConfig = {
125
157
  readonly scalars: string;
@@ -140,6 +172,11 @@ type ResolvedSodaGqlConfig = {
140
172
  readonly schemas: Readonly<Record<string, ResolvedSchemaConfig>>;
141
173
  readonly styles: ResolvedStylesConfig;
142
174
  readonly plugins: PluginConfig;
175
+ /**
176
+ * Resolved artifact configuration.
177
+ * Only present when artifact.path is specified in the config.
178
+ */
179
+ readonly artifact?: ResolvedArtifactConfig;
143
180
  };
144
181
  //#endregion
145
182
  //#region packages/config/src/helper.d.ts
@@ -213,5 +250,5 @@ declare function loadConfigFrom(dir: string): Result<ResolvedSodaGqlConfig, Conf
213
250
  */
214
251
  declare function normalizeConfig(config: SodaGqlConfig, configPath: string): Result<ResolvedSodaGqlConfig, ConfigError>;
215
252
  //#endregion
216
- export { type ConfigError, type ConfigErrorCode, type PluginConfig, type ResolvedSodaGqlConfig, type SchemaConfig, type SodaGqlConfig, type SodaGqlConfigContainer, configError, defineConfig, findConfigFile, loadConfig, loadConfigFrom, normalizeConfig, validateConfig };
253
+ 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 };
217
254
  //# sourceMappingURL=index.d.mts.map
@@ -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,EA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ACC;;;;;sBAKE;;;;AD/KtB;AAEA;AAOA;;;AAA4B,cEEf,sBAAA,CFFe;EAAA,SAAA,MAAA,EEGkB,aFHlB;EAMpB,QAAA,WAAA,CAAA;EAIJ,OAAA,MAAA,CAAA,MAAA,EEL2B,aFK3B,CAAA,EEL2C,sBFK3C;;;;;ACTJ;AAQA;;;;;AA4BA;AAWA;AAKA;AAMA;AAaA;AAKA;;;;;;;;AA8DA;AAMA;;;;;AAQA;;;;;;AAasB,iBC1HN,YAAA,CD0HM,MAAA,EC1He,aD0Hf,CAAA,EC1H+B,sBD0H/B;AAAsB,iBCzH5B,YAAA,CDyH4B,MAAA,EAAA,GAAA,GCzHD,aDyHC,CAAA,ECzHe,sBDyHf;iBC3E5B,cAAA,mBAAiC,OAAO,eAAe;;;AFpG3D,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,iBIgCZ,eAAA,CJhCY,MAAA,EIgCY,aJhCZ,EAAA,UAAA,EAAA,MAAA,CAAA,EIgCgD,MJhChD,CIgCuD,qBJhCvD,EIgC8E,WJhC9E,CAAA"}
package/dist/index.mjs CHANGED
@@ -66,6 +66,7 @@ const SchemaConfigSchema = defineSchemaFor()({
66
66
  inputDepthOverrides: z.record(z.string(), z.number().int().positive()).optional()
67
67
  });
68
68
  const StylesConfigSchema = defineSchemaFor()({ importExtension: z.boolean().optional() });
69
+ const ArtifactConfigSchema = defineSchemaFor()({ path: z.string().min(1).optional() });
69
70
  const SodaGqlConfigSchema = defineSchemaFor()({
70
71
  analyzer: z.enum(["ts", "swc"]).optional(),
71
72
  outdir: z.string().min(1),
@@ -74,7 +75,8 @@ const SodaGqlConfigSchema = defineSchemaFor()({
74
75
  exclude: z.array(z.string().min(1)).optional(),
75
76
  schemas: z.record(z.string(), SchemaConfigSchema),
76
77
  styles: StylesConfigSchema.optional(),
77
- plugins: z.record(z.string(), z.unknown()).optional()
78
+ plugins: z.record(z.string(), z.unknown()).optional(),
79
+ artifact: ArtifactConfigSchema.optional()
78
80
  });
79
81
  function validateConfig(config) {
80
82
  const result = SodaGqlConfigSchema.safeParse(config);
@@ -165,6 +167,16 @@ function normalizeInject(inject, configDir) {
165
167
  };
166
168
  }
167
169
  /**
170
+ * Normalize artifact config to resolved form.
171
+ * Returns undefined if no path is specified.
172
+ */
173
+ function normalizeArtifact(artifact, configDir) {
174
+ if (!artifact?.path) {
175
+ return undefined;
176
+ }
177
+ return { path: resolve(configDir, artifact.path) };
178
+ }
179
+ /**
168
180
  * Resolve and normalize config with defaults.
169
181
  * Paths in the config are resolved relative to the config file's directory.
170
182
  */
@@ -173,6 +185,7 @@ function normalizeConfig(config, configPath) {
173
185
  const analyzer = config.analyzer ?? "ts";
174
186
  const graphqlSystemAliases = config.graphqlSystemAliases ?? ["@/graphql-system"];
175
187
  const exclude = config.exclude ?? [];
188
+ const artifact = normalizeArtifact(config.artifact, configDir);
176
189
  const resolved = {
177
190
  analyzer,
178
191
  outdir: resolve(configDir, config.outdir),
@@ -186,7 +199,8 @@ function normalizeConfig(config, configPath) {
186
199
  inputDepthOverrides: schemaConfig.inputDepthOverrides ?? {}
187
200
  }])),
188
201
  styles: { importExtension: config.styles?.importExtension ?? false },
189
- plugins: config.plugins ?? {}
202
+ plugins: config.plugins ?? {},
203
+ ...artifact ? { artifact } : {}
190
204
  };
191
205
  return ok(resolved);
192
206
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["config: SodaGqlConfig","InjectConfigSchema: z.ZodType<InjectConfig>","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 { InjectConfig, SchemaConfig, 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\nconst SchemaConfigSchema = defineSchemaFor<SchemaConfig>()({\n schema: z.string().min(1),\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 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});\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 type { Result } from \"neverthrow\";\nimport { ok } from \"neverthrow\";\nimport type { ConfigError } from \"./errors\";\nimport type { InjectConfig, ResolvedInjectConfig, ResolvedSodaGqlConfig, SodaGqlConfig } from \"./types\";\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 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 const resolved: ResolvedSodaGqlConfig = {\n analyzer,\n outdir: resolve(configDir, config.outdir),\n graphqlSystemAliases,\n include: config.include.map((pattern) => resolve(configDir, pattern)),\n exclude: exclude.map((pattern) => resolve(configDir, pattern)),\n schemas: Object.fromEntries(\n Object.entries(config.schemas).map(([name, schemaConfig]) => [\n name,\n {\n schema: resolve(configDir, schemaConfig.schema),\n inject: normalizeInject(schemaConfig.inject, configDir),\n defaultInputDepth: schemaConfig.defaultInputDepth ?? 3,\n inputDepthOverrides: schemaConfig.inputDepthOverrides ?? {},\n },\n ]),\n ),\n styles: {\n importExtension: config.styles?.importExtension ?? false,\n },\n plugins: config.plugins ?? {},\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 PluginConfig,\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,EACjB,EAAE,OAAO;CACP,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE;CAC1B,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,UAAU;CACtC,CAAC,CACH,CAAC;AAEF,MAAM,qBAAqB,iBAA+B,CAAC;CACzD,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE;CACzB,QAAQ;CACR,mBAAmB,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,UAAU;CACjE,qBAAqB,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,UAAU;CAClF,CAAC;AAEF,MAAM,qBAAqB,iBAA+B,CAAC,EACzD,iBAAiB,EAAE,SAAS,CAAC,UAAU,EACxC,CAAC;AAEF,MAAM,sBAAsB,iBAAgC,CAAC;CAC3D,UAAU,EAAE,KAAK,CAAC,MAAM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"version":3,"file":"index.mjs","names":["config: SodaGqlConfig","InjectConfigSchema: z.ZodType<InjectConfig>","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, 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\nconst SchemaConfigSchema = defineSchemaFor<SchemaConfig>()({\n schema: z.string().min(1),\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 type { Result } from \"neverthrow\";\nimport { ok } from \"neverthrow\";\nimport type { ConfigError } from \"./errors\";\nimport type { InjectConfig, ResolvedArtifactConfig, ResolvedInjectConfig, ResolvedSodaGqlConfig, SodaGqlConfig } from \"./types\";\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 * 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 const resolved: ResolvedSodaGqlConfig = {\n analyzer,\n outdir: resolve(configDir, config.outdir),\n graphqlSystemAliases,\n include: config.include.map((pattern) => resolve(configDir, pattern)),\n exclude: exclude.map((pattern) => resolve(configDir, pattern)),\n schemas: Object.fromEntries(\n Object.entries(config.schemas).map(([name, schemaConfig]) => [\n name,\n {\n schema: resolve(configDir, schemaConfig.schema),\n inject: normalizeInject(schemaConfig.inject, configDir),\n defaultInputDepth: schemaConfig.defaultInputDepth ?? 3,\n inputDepthOverrides: schemaConfig.inputDepthOverrides ?? {},\n },\n ]),\n ),\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,EACjB,EAAE,OAAO;CACP,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE;CAC1B,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,UAAU;CACtC,CA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;;AAKD,SAAgB,eAAe,WAAmB,QAAQ,KAAK,EAAiB;CAC9E,IAAI,aAAa;AACjB,QAAO,eAAe,QAAQ,WAAW,EAAE;AACzC,OAAK,MAAM,YAAY,0BAA0B;GAC/C,MAAM,aAAa,KAAK,YAAY,SAAS;AAC7C,OAAI,WAAW,WAAW,EAAE;AAC1B,WAAO;;;AAGX,eAAa,QAAQ,WAAW;;AAElC,QAAO;;;;;AAMT,SAAgB,WAAW,YAA4E;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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soda-gql/config",
3
- "version": "0.5.3",
3
+ "version": "0.8.0",
4
4
  "description": "Centralized configuration loader and helpers for soda-gql tooling.",
5
5
  "type": "module",
6
6
  "private": false,
@@ -49,11 +49,12 @@
49
49
  "./package.json": "./package.json"
50
50
  },
51
51
  "dependencies": {
52
- "@soda-gql/common": "0.5.3",
52
+ "@soda-gql/common": "~0.8.0",
53
53
  "@swc/core": "^1.10.0",
54
54
  "neverthrow": "^8.2.0",
55
55
  "zod": "^4.1.11"
56
56
  },
57
57
  "devDependencies": {},
58
- "peerDependencies": {}
58
+ "peerDependencies": {},
59
+ "optionalDependencies": {}
59
60
  }