@lifi/composer-sdk
Version:
Public Composer SDK for building and submitting flows
37 lines (34 loc) • 1.54 kB
text/typescript
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;
/** Error envelope returned on non-2xx responses. */
interface ServerErrorBody {
readonly error?: {
readonly kind?: string;
readonly message?: string;
readonly path?: string;
readonly details?: SimulationRevert;
};
}
/** Validates an already-parsed error envelope; `null` when it does not match. */
declare const parseServerErrorBody: (json: unknown) => ServerErrorBody | null;
export { type CompilePartialEnvelope, type ServerErrorBody, parseCompilePartialEnvelope, parseServerErrorBody, parseSimulateResult };