UNPKG

@kurrent/kurrentdb-client

Version:
34 lines (33 loc) 1.8 kB
import type { BaseOptions, AppendResult, AppendStreamState, EventData, EventType, MultiAppendResult, AppendStreamRequest, AppendRecordInput, AppendRecordsResult, ConsistencyCheck } from "../../types"; export interface AppendToStreamOptions extends BaseOptions { /** * Asks the server to check the stream is at specific revision before writing events. * @defaultValue ANY */ streamState?: AppendStreamState; /** * The batch size, in bytes. * @defaultValue 3 * 1024 * 1024 */ batchAppendSize?: number; } declare module "../../Client" { interface Client { /** * Appends events to a given stream. * @param streamName - A stream name. * @param events - Events or event to write. * @param options - Writing options. */ appendToStream<KnownEventType extends EventType = EventType>(streamName: string, events: EventData<KnownEventType> | EventData<KnownEventType>[], options?: AppendToStreamOptions): Promise<AppendResult>; multiStreamAppend<KnownEventType extends EventType = EventType>(requests: AppendStreamRequest<KnownEventType>[]): Promise<MultiAppendResult>; /** * Appends records to one or more streams atomically with cross-stream consistency checks. * Records can be interleaved across streams in any order and the global log preserves * the exact sequence from the request. * @param records - The records to append. Each record specifies its target stream. * @param checks - Optional consistency checks evaluated before commit. */ appendRecords<KnownEventType extends EventType = EventType>(records: AppendRecordInput<KnownEventType>[], checks?: ConsistencyCheck[]): Promise<AppendRecordsResult>; } }