{"version":3,"file":"schema-zWbVYCQW.mjs","names":[],"sources":["../src/config/schema.ts"],"sourcesContent":["import * as z from 'zod'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { LOCAL_GRAPH_MCP_ENDPOINT, validateMcpEndpoint } from './mcp-endpoint.js'\n\nfunction endpointSchema(key: 'graphMcpEndpoint') {\n  return z.string().transform((value, ctx) => {\n    try {\n      return validateMcpEndpoint(value, key)\n    } catch (err) {\n      ctx.addIssue({\n        code: z.ZodIssueCode.custom,\n        message: (err as Error).message,\n      })\n      return z.NEVER\n    }\n  })\n}\n\nexport const ConfigSchema = z.object({\n  graphMcpEndpoint:  endpointSchema('graphMcpEndpoint').default(LOCAL_GRAPH_MCP_ENDPOINT),\n  graphMcpAuthToken: z.string().optional(),\n  graphMcpMode:      z.enum(['paid', 'debug']).default('paid'),\n  walletAddress:     z.string().optional(),\n  serverPort:        z.number().int().min(1024).max(65535).default(4321),\n  dataDir:           z.string().default(path.join(os.homedir(), '.chain-insights')),\n  version:           z.string().default('1'),\n})\n\nexport type InvestigatorConfig = z.infer<typeof ConfigSchema>\n\nfunction formatConfigValidationError(error: z.ZodError): string {\n  return error.issues.map((issue) => issue.message).join('\\n')\n}\n\nexport function parseInvestigatorConfig(input: unknown): InvestigatorConfig {\n  const parsed = ConfigSchema.safeParse(input)\n  if (parsed.success) return parsed.data\n  throw new Error(formatConfigValidationError(parsed.error))\n}\n\nexport const DEFAULT_CONFIG: InvestigatorConfig = parseInvestigatorConfig({})\n\nexport const CONFIG_KEYS = [\n  'graphMcpEndpoint',\n  'graphMcpAuthToken',\n  'graphMcpMode',\n  'walletAddress',\n  'serverPort',\n  'dataDir',\n  'version',\n] as const\n\nexport type ConfigKey = typeof CONFIG_KEYS[number]\n"],"mappings":";;;;;;;;;;;;AAKA,SAAS,eAAe,KAAyB;CAC/C,OAAO,EAAE,OAAO,CAAC,CAAC,WAAW,OAAO,QAAQ;EAC1C,IAAI;GACF,OAAO,oBAAoB,OAAO,GAAG;EACv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