UNPKG

@lifi/composer-sdk

Version:

Public Composer SDK for building and submitting flows

51 lines (48 loc) 2.11 kB
import { SimulationRevert, SimulateResult } from '@lifi/compose-spec'; /** * Parses a `POST /simulate` body into a {@link SimulateResult}. Returns `null` * when the body does not match the `ok`/`revert`/`error` union, letting the * caller raise a transport-level error. */ declare const parseSimulateResult: (body: unknown) => SimulateResult | null; /** * The validated members of an HTTP 206 partial compile envelope. `data` is * verified to be an object but kept untyped — compose-spec owns its full shape * (`ComposeCompilePartialData`) as a hand-authored type, so the caller narrows * it. `error` is fully validated. */ interface CompilePartialEnvelope { readonly data: Record<string, unknown>; readonly error: { readonly kind: string; readonly message: string; }; } /** Parses an HTTP 206 partial compile envelope; `null` when it does not match. */ declare const parseCompilePartialEnvelope: (body: unknown) => CompilePartialEnvelope | null; /** * A single prepared-op failure inside a `preparation_error` envelope. `kind` is * kept as `string` here — the narrowing to `GenericComposeErrorKind` happens in * `errorFromHttpResponse`, where the value is lifted onto `ComposeError`. */ interface ServerFailedPreparedOp { readonly callId: string; readonly op: string; readonly kind: string; readonly message: string; readonly path?: string; } /** Error envelope returned on non-2xx responses. */ interface ServerErrorBody { readonly error?: { readonly kind?: string; readonly message?: string; readonly path?: string; readonly details?: SimulationRevert; readonly failedOps?: readonly ServerFailedPreparedOp[]; readonly succeededOps?: readonly string[]; }; } /** Validates an already-parsed error envelope; `null` when it does not match. */ declare const parseServerErrorBody: (json: unknown) => ServerErrorBody | null; export { type CompilePartialEnvelope, type ServerErrorBody, type ServerFailedPreparedOp, parseCompilePartialEnvelope, parseServerErrorBody, parseSimulateResult };