@lifi/composer-sdk
Version:
Public Composer SDK for building and submitting flows
59 lines • 2.38 kB
text/typescript
import { DeliveryErrorDetails, Shortfall, SimulateResult, SimulationRevert } from "@lifi/compose-spec";
//#region src/responseSchemas.d.ts
/**
* 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.
*/
export declare const parseSimulateResult: (body: unknown) => SimulateResult | null;
/**
* The validated members of an HTTP 206 partial compile envelope. `data` is
* verified to be an object at runtime but left `unknown` here — compose-spec
* owns its full shape (`ComposeCompilePartialData`) as a hand-authored type, so
* the caller narrows it in one step. `error` is fully validated.
*/
export interface CompilePartialEnvelope {
readonly data: unknown;
readonly error: {
readonly kind: string;
readonly message: string;
};
}
/** Parses an HTTP 206 partial compile envelope; `null` when it does not match. */
export 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`.
*/
export interface ServerFailedPreparedOp {
readonly callId: string;
readonly op: string;
readonly kind: string;
readonly message: string;
readonly path?: string;
readonly port?: string;
readonly fix?: string;
readonly shortfall?: Shortfall;
}
/** Error envelope returned on non-2xx responses. */
export interface ServerErrorBody {
readonly error?: {
readonly kind?: string;
readonly message?: string;
readonly path?: string;
readonly port?: string;
readonly fix?: string;
readonly shortfall?: Shortfall;
readonly sdkVersion?: string;
readonly serverVersion?: string;
readonly minimumSdkVersion?: string;
readonly details?: SimulationRevert | DeliveryErrorDetails;
readonly failedOps?: readonly ServerFailedPreparedOp[];
readonly succeededOps?: readonly string[];
};
}
/** Validates an already-parsed error envelope; `null` when it does not match. */
export declare const parseServerErrorBody: (json: unknown) => ServerErrorBody | null;
//#endregion
//# sourceMappingURL=responseSchemas.d.cts.map