UNPKG

@eleva-io/erp-sdk

Version:

SDK oficial para el ERP de Eleva

244 lines 8.11 kB
import { z } from 'zod'; import { CatalogDetails, ErrorKind } from './catalog_types'; /** * Generic HTTP-level error codes shared across all API domains. * Domain-specific codes live in `catalog_api.ts`. */ export declare enum BASE_ERROR_CODES { /** Input data failed schema or business-rule validation. */ VALIDATION = "VALIDATION", /** The request is malformed or contains invalid parameters. */ BAD_REQUEST = "BAD_REQUEST", /** Credentials are missing, expired, or invalid. */ AUTHENTICATION = "AUTHENTICATION", /** Authenticated but lacks the required permissions. */ UNAUTHORIZED = "UNAUTHORIZED", /** The requested resource does not exist. */ NOT_FOUND = "NOT_FOUND", /** Server cannot produce a response matching the `Accept` header. */ NOT_ACCEPTABLE = "NOT_ACCEPTABLE", /** Operation would violate a uniqueness or integrity constraint. */ CONFLICT = "CONFLICT", /** Resource existed but has been permanently removed (unlike 404, retrying is futile). */ GONE = "GONE", /** Request is syntactically valid but semantically unprocessable (e.g. invalid state transition). */ UNPROCESSABLE_ENTITY = "UNPROCESSABLE_ENTITY", /** A required field was omitted from the request. */ MANDATORY_FIELD = "MANDATORY_FIELD", /** Unexpected server-side error (`SYSTEM` message sanitised before being sent to clients). */ INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR", /** Upstream gateway received an invalid response from the origin server (`SYSTEM`). */ BAD_GATEWAY = "BAD_GATEWAY", /** Service is temporarily unavailable (`SYSTEM`). */ SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE" } /** Maps every `BASE_ERROR_CODES` member to its HTTP status, kind, default message, and details schema. */ export declare const BASE_ERRORS_CATALOG: { VALIDATION: { kind: ErrorKind.DOMAIN; status: number; details: z.ZodObject<{ errors: z.ZodArray<z.ZodObject<{ /** Dot-separated field path (e.g. `"address.zipCode"`) or `"root"` for top-level issues. */ validation: z.ZodString; /** Zod issue code (e.g. `"invalid_type"`, `"too_small"`). */ code: z.ZodString; message: z.ZodString; path: z.ZodArray<z.ZodString, "many">; }, "strip", z.ZodTypeAny, { code: string; message: string; path: string[]; validation: string; }, { code: string; message: string; path: string[]; validation: string; }>, "many">; }, "strip", z.ZodTypeAny, { errors: { code: string; message: string; path: string[]; validation: string; }[]; }, { errors: { code: string; message: string; path: string[]; validation: string; }[]; }>; message: string; }; BAD_REQUEST: { kind: ErrorKind.DOMAIN; status: number; details: z.ZodObject<{ field: z.ZodOptional<z.ZodString>; reason: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { field?: string | undefined; reason?: string | undefined; }, { field?: string | undefined; reason?: string | undefined; }>; message: string; }; AUTHENTICATION: { kind: ErrorKind.DOMAIN; status: number; details: z.ZodObject<{ reason: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { reason?: string | undefined; }, { reason?: string | undefined; }>; message: string; }; UNAUTHORIZED: { kind: ErrorKind.DOMAIN; status: number; details: z.ZodObject<{ requiredScope: z.ZodOptional<z.ZodString>; resource: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { requiredScope?: string | undefined; resource?: string | undefined; }, { requiredScope?: string | undefined; resource?: string | undefined; }>; message: string; }; NOT_FOUND: { kind: ErrorKind.DOMAIN; status: number; details: z.ZodObject<{ entity: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { entity?: string | undefined; }, { entity?: string | undefined; }>; message: string; }; NOT_ACCEPTABLE: { kind: ErrorKind.DOMAIN; status: number; details: z.ZodObject<{ acceptedTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; }, "strip", z.ZodTypeAny, { acceptedTypes?: string[] | undefined; }, { acceptedTypes?: string[] | undefined; }>; message: string; }; /** Each item in the array identifies one conflicting field. */ CONFLICT: { kind: ErrorKind.DOMAIN; status: number; details: z.ZodArray<z.ZodObject<{ key: z.ZodString; value: z.ZodString; cause: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; key: string; cause: string; }, { value: string; key: string; cause: string; }>, "many">; message: string; }; GONE: { kind: ErrorKind.DOMAIN; status: number; details: z.ZodObject<{ since: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { since?: string | undefined; }, { since?: string | undefined; }>; message: string; }; UNPROCESSABLE_ENTITY: { kind: ErrorKind.DOMAIN; status: number; details: z.ZodObject<{ field: z.ZodOptional<z.ZodString>; reason: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { field?: string | undefined; reason?: string | undefined; }, { field?: string | undefined; reason?: string | undefined; }>; message: string; }; MANDATORY_FIELD: { kind: ErrorKind.DOMAIN; status: number; details: z.ZodObject<{ field: z.ZodString; }, "strip", z.ZodTypeAny, { field: string; }, { field: string; }>; message: string; }; INTERNAL_SERVER_ERROR: { kind: ErrorKind.SYSTEM; status: number; details: z.ZodObject<{ reason: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { reason?: string | undefined; }, { reason?: string | undefined; }>; message: string; }; BAD_GATEWAY: { kind: ErrorKind.SYSTEM; status: number; details: z.ZodObject<{ upstream: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { upstream?: string | undefined; }, { upstream?: string | undefined; }>; message: string; }; SERVICE_UNAVAILABLE: { kind: ErrorKind.SYSTEM; status: number; details: z.ZodObject<{ retryAfter: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { retryAfter?: number | undefined; }, { retryAfter?: number | undefined; }>; message: string; }; }; /** * Strongly-typed `details` shape for a given `BASE_ERROR_CODES` member. * @example * type ConflictDetails = BaseErrorDetails<BASE_ERROR_CODES.CONFLICT> * // Array<{ key: string; value: string; cause: string }> */ export type BaseErrorDetails<C extends BASE_ERROR_CODES> = CatalogDetails<C, typeof BASE_ERRORS_CATALOG>; //# sourceMappingURL=catalog_base.d.ts.map