import { defineCodes, SuaveplanError, type SuaveplanErrorOptions, } from "@suaveplan/error"; /** * Frozen registry of every error code surfaced by `@suaveplan/api-manifest`. * * Every code MUST be thrown (or attached to a warning) by at least one * production code path; a spec-conformance test enforces this invariant. */ export const MANIFEST_CODES = defineCodes("MANIFEST", [ "PARSE_FAILED", "DEPENDENCY_CYCLE", "MISSING_DEPENDENCY", "DEPENDENCY_VERSION_MISMATCH", "CAPABILITY_REQUIRED_MISSING", "CAPABILITY_VERSION_MISMATCH", "OPTIONAL_CAPABILITY_MISSING", "INVALID_SAGA_OWNERSHIP", "SANDBOX_REQUIRES_BUDGETS", "INVALID_ERROR_STATUS_MAP", "OPENAPI_REQUIRES_GRAPHQL_OR_ROUTES", ] as const); /** Literal union of every error code emitted by this package. */ export type ManifestCode = (typeof MANIFEST_CODES)[keyof typeof MANIFEST_CODES]; /** * Typed error class for `@suaveplan/api-manifest` failures. * * Extends `SuaveplanError` so callers can `instanceof ManifestError` to * narrow the code union while retaining the base class's cause chain, * context, redaction, and OTel span-event adapter. */ export class ManifestError extends SuaveplanError { public constructor( code: ManifestCode, messageKey: string, options?: SuaveplanErrorOptions ) { super(code, messageKey, options); this.name = "ManifestError"; } }