{"version":3,"sources":["../../../src/v0/schemas/errors.ts"],"sourcesContent":["/**\n * Error schema definitions for API error responses\n * Following JSON:API error object specification\n */\n\nimport { z } from \"zod\";\n\n/**\n * An application-specific error code, expressed as a string value.\n */\nexport const ErrorCodeSchema = z\n  .string()\n  .describe(\"An application-specific error code, expressed as a string value.\");\n\n/**\n * Identifies the source of the error within the request payload, if relevant.\n */\nexport const ErrorSourceSchema = z\n  .object({\n    pointer: z\n      .string()\n      .optional()\n      .describe(\n        \"A JSON Pointer [RFC6901](https://tools.ietf.org/html/rfc6901) to the associated entity in the request document [e.g. `/data` for a primary data object, or `/data/attributes/title` for a specific attribute].\",\n      ),\n    parameter: z\n      .string()\n      .optional()\n      .describe(\n        \"A string indicating which URI query parameter caused the error.\",\n      ),\n    header: z\n      .string()\n      .optional()\n      .describe(\"A string indicating the header that caused the error.\"),\n  })\n  .strict()\n  .nullable()\n  .describe(\n    \"Identifies the source of the error within the request payload, if relevant.\",\n  );\n\n/**\n * An error object provides additional information about problems encountered while performing an operation.\n * Error objects MUST be returned as an array keyed by `errors` in the top level of a JSON:API document.\n */\nexport const ErrorObjectSchema = z\n  .object({\n    id: z\n      .string()\n      .nullable()\n      .optional()\n      .describe(\n        \"A unique identifier for this particular occurrence of the problem.\",\n      ),\n    links: z\n      .object({\n        about: z\n          .string()\n          .url()\n          .describe(\n            \"A link that leads to further details about this particular occurrence of the problem.\",\n          ),\n      })\n      .strict()\n      .nullable()\n      .optional()\n      .describe(\"Relevant links about the error\"),\n    status: z\n      .string()\n      .optional()\n      .describe(\n        \"The HTTP status code applicable to this problem, expressed as a string value.\",\n      ),\n    code: ErrorCodeSchema.optional(),\n    title: z\n      .string()\n      .optional()\n      .describe(\n        \"A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.\",\n      ),\n    detail: z\n      .string()\n      .optional()\n      .describe(\n        \"A human-readable explanation specific to this occurrence of the problem. Like `title`, this field's value can be localized.\",\n      ),\n    source: ErrorSourceSchema.optional(),\n  })\n  .strict()\n  .describe(\n    \"An error object provides additional information about problems encountered while performing an operation. Error objects MUST be returned as an array keyed by `errors` in the top level of a JSON:API document.\",\n  );\n\n/**\n * A JSON:API error response document containing an array of error objects.\n */\nexport const ErrorsResponseSchema = z\n  .object({\n    errors: z\n      .array(ErrorObjectSchema)\n      .describe(\"A collection of the errors returned.\"),\n  })\n  .describe(\n    \"A JSON:API error response document containing an array of error objects.\",\n  );\n\n// Export TypeScript types\nexport type ErrorCode = z.infer<typeof ErrorCodeSchema>;\nexport type ErrorSource = z.infer<typeof ErrorSourceSchema>;\nexport type ErrorObject = z.infer<typeof ErrorObjectSchema>;\nexport type ErrorsResponse = z.infer<typeof ErrorsResponseSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,iBAAkB;AAKX,IAAM,kBAAkB,aAC5B,OAAO,EACP,SAAS,kEAAkE;AAKvE,IAAM,oBAAoB,aAC9B,OAAO;AAAA,EACN,SAAS,aACN,OAAO,EACP,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,WAAW,aACR,OAAO,EACP,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,QAAQ,aACL,OAAO,EACP,SAAS,EACT,SAAS,uDAAuD;AACrE,CAAC,EACA,OAAO,EACP,SAAS,EACT;AAAA,EACC;AACF;AAMK,IAAM,oBAAoB,aAC9B,OAAO;AAAA,EACN,IAAI,aACD,OAAO,EACP,SAAS,EACT,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,OAAO,aACJ,OAAO;AAAA,IACN,OAAO,aACJ,OAAO,EACP,IAAI,EACJ;AAAA,MACC;AAAA,IACF;AAAA,EACJ,CAAC,EACA,OAAO,EACP,SAAS,EACT,SAAS,EACT,SAAS,gCAAgC;AAAA,EAC5C,QAAQ,aACL,OAAO,EACP,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,MAAM,gBAAgB,SAAS;AAAA,EAC/B,OAAO,aACJ,OAAO,EACP,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,QAAQ,aACL,OAAO,EACP,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,QAAQ,kBAAkB,SAAS;AACrC,CAAC,EACA,OAAO,EACP;AAAA,EACC;AACF;AAKK,IAAM,uBAAuB,aACjC,OAAO;AAAA,EACN,QAAQ,aACL,MAAM,iBAAiB,EACvB,SAAS,sCAAsC;AACpD,CAAC,EACA;AAAA,EACC;AACF;","names":[]}