UNPKG

1.12 kBTypeScriptView Raw
1import { Stream, Writable } from "stream";
2
3import { Record } from "./record";
4import { RecordResult } from "./record-result";
5import { Parsable } from "./record-stream";
6
7export interface BatchInfo {
8 id: string;
9 jobId: string;
10 state: string;
11 stateMessage: string;
12 numberRecordsProcessed: string;
13 numberRecordsFailed: string;
14 totalProcessingTime: string;
15}
16
17export interface BatchResultInfo {
18 id: string;
19 batchId?: string | undefined;
20 jobId?: string | undefined;
21 success?: boolean | undefined;
22 errors?: string[] | undefined;
23}
24
25export class Batch extends Writable {
26 check(callback?: (batchInfo: BatchInfo) => void): Promise<BatchInfo>;
27 execute(
28 input?: Record[] | Stream | string,
29 callback?: (err: Error, result: RecordResult[] | BatchResultInfo[]) => void,
30 ): Batch;
31 poll(interval: number, timeout: number): void;
32 retrieve(callback?: (batchInfo: BatchInfo) => void): Promise<RecordResult[] | BatchResultInfo[]>;
33 result(resultId: string): Parsable<any>;
34 then(): Promise<any>;
35 thenAll(callback: (data: any) => void): void;
36}