//#region src/protocol.d.ts /** * The protocol types — the shapes that cross package and process * boundaries. Types-only consumers import `@prisma/cli-engine/protocol` * and drag no engine code. */ /** * A recorded finding: pure data, never thrown, no stack. Field-for-field * the error envelope minus `ok`; the two shapes never diverge. * `nextActions` is always present (empty when there are none); the * remaining optional fields are wire fields whose absence is data. */ interface Diagnostic { readonly code: `${string}.${string}`; readonly severity: "error" | "warn" | "info"; readonly summary: string; readonly why?: string; readonly nextActions: readonly NextAction[]; readonly where?: { readonly path?: string; readonly line?: number; }; readonly meta?: Record; readonly docsUrl?: string; } /** * The typed agent-facing follow-up action. */ interface NextAction { readonly kind: "run-command" | "open-url" | "user-choice" | "edit-file" | "done"; readonly label: string; readonly command?: string; readonly commands?: readonly string[]; /** The address an `open-url` action sends the user to. A URL is not * a command: putting one in `command` tells a consumer to execute * it. */ readonly url?: string; readonly reason?: string; } /** * The serialized form of a CliStructuredError. */ type CliErrorEnvelope = { readonly ok: false; } & Diagnostic; /** The mark a structured error carries so it can be recognized without * its prototype. A registry symbol resolves to one symbol across every * copy of this package in an install, so an error built by another copy * carries the same key this one looks for. */ declare const STRUCTURED_ERROR: unique symbol; /** * Structured CLI error carrying everything an error envelope needs. * `code` is a dotted `NAMESPACE.SUBCODE` string; the namespace prefix is * the error's category. */ declare class CliStructuredError extends Error { readonly [STRUCTURED_ERROR]: true; readonly code: `${string}.${string}`; readonly severity: Diagnostic["severity"]; readonly why: string | undefined; readonly nextActions: readonly NextAction[]; /** Accompanying findings when the failure had several. This error is * the primary one; these are reported alongside it, so a command can * fail with everything it found instead of only the first thing. */ readonly diagnostics: readonly Diagnostic[]; readonly where: { readonly path?: string; readonly line?: number; } | undefined; readonly meta: Record | undefined; readonly docsUrl: string | undefined; constructor(code: `${string}.${string}`, summary: string, options?: { readonly severity?: Diagnostic["severity"]; readonly why?: string; readonly nextActions?: readonly NextAction[]; readonly diagnostics?: readonly Diagnostic[]; readonly where?: { readonly path?: string; readonly line?: number; }; readonly meta?: Record; readonly docsUrl?: string; readonly cause?: unknown; }); /** * Converts this error to an error envelope for output formatting. */ toEnvelope(): CliErrorEnvelope; /** * Recognizes a structured error across module boundaries, where * instanceof fails because each copy of this package has its own * class. The brand answers it outright. The duck-typed check behind * it is the fallback for an error from a copy old enough to predate * the brand: rejecting those would turn a real failure into an * engine-bug report, so it has to keep working. * * Neither branch asks what the value's prototype is. Nothing in * settlement needs an Error — it reads `code` and `nextActions` and * calls `toEnvelope` — so a prototype chain, which is local to the * copy that made it, is not the thing worth checking. */ static is(error: unknown): error is CliStructuredError; } /** * A successful result containing a value. */ interface Ok { readonly ok: true; readonly value: T; assertOk(): T; assertNotOk(): never; } /** * An unsuccessful result containing failure details. */ interface NotOk { readonly ok: false; readonly failure: F; assertOk(): never; assertNotOk(): F; } /** * A discriminated union representing either success (Ok) or failure * (NotOk). The standard way to return expected failures as values * rather than throwing. */ type Result = Ok | NotOk; /** * Creates a successful result. */ declare function ok(value: T): Ok; /** * Creates an unsuccessful result. */ declare function notOk(failure: F): NotOk; /** * Returns the singleton successful void result. */ declare function okVoid(): Ok; //#endregion export { NotOk as a, STRUCTURED_ERROR as c, okVoid as d, NextAction as i, notOk as l, CliStructuredError as n, Ok as o, Diagnostic as r, Result as s, CliErrorEnvelope as t, ok as u };