{"version":3,"file":"map-result.mjs","names":[],"sources":["../../../../../../../@warlock.js/seal/src/standard-schema/map-result.ts"],"sourcesContent":["import type { ValidationResult } from \"../types\";\nimport type { StandardSchemaV1 } from \"./types\";\n\n/**\n * Maps a Seal ValidationResult to a Standard Schema result shape.\n *\n * Seal error paths are dot-notation strings (e.g. \"address.city\").\n * Standard Schema expects an array of path segments: [{ key: \"address\" }, { key: \"city\" }].\n *\n * @example\n * ```ts\n * const result = await validator.validate(value, context);\n * return mapToStandardResult(result);\n * // Success → { value: <data> }\n * // Failure → { issues: [{ message: \"...\", path: [{ key: \"...\" }] }] }\n * ```\n */\nexport function mapToStandardResult(\n  result: ValidationResult,\n): StandardSchemaV1.Result<unknown> {\n  if (result.isValid) {\n    return { value: result.data };\n  }\n\n  return {\n    issues: result.errors.map(e => ({\n      message: e.error,\n      path: e.input\n        ? e.input.split(\".\").map(key => ({ key }))\n        : undefined,\n    })),\n  };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,SAAgB,oBACd,QACkC;CAClC,IAAI,OAAO,SACT,OAAO,EAAE,OAAO,OAAO,KAAK;CAG9B,OAAO,EACL,QAAQ,OAAO,OAAO,KAAI,OAAM;EAC9B,SAAS,EAAE;EACX,MAAM,EAAE,QACJ,EAAE,MAAM,MAAM,GAAG,CAAC,CAAC,KAAI,SAAQ,EAAE,IAAI,EAAE,IACvC;CACN,EAAE,EACJ;AACF"}