import { JobMetadata, JobStatus } from '../model/index'; import { FSRequestOptions } from '../http'; export interface BatchRequester { requestCreateJob(request: { body: REQ; idempotencyKey?: string; }): Promise; requestImports(id: string, pageToken?: string): Promise; requestImportErrors(id: string, pageToken?: string): Promise; requestJobStatus(id: string): Promise; } export interface BatchJobOptions { pollInterval?: number; maxRetry?: number; } export declare const DefaultBatchJobOpts: Required; export interface BatchJob { readonly options: Required & FSRequestOptions; request: REQUEST; readonly metadata?: JobMetadata; readonly imports: IMPORT[]; readonly failedImports: FAILURE[]; errors: Error[]; add(...requests: SINGLE_REQ[]): this; execute(): void; restart(jobId?: string): void; getId(): string | undefined; getStatus(): JobStatus | undefined; getImports(): IMPORT[]; getFailedImports(): FAILURE[]; on(type: 'created', callback: (job: this) => void): this; on(type: 'processing', callback: (job: this) => void): this; on(type: 'done', callback: (imported: IMPORT[], failed: FAILURE[]) => void): this; on(type: 'error', callback: (error: Error) => void): this; on(type: 'abort', callback: (errors: Error[]) => void): this; } export declare class BatchJobImpl implements BatchJob { private requester; readonly options: Required & FSRequestOptions; request: REQUEST; metadata?: JobMetadata | undefined; imports: IMPORT[]; failedImports: FAILURE[]; errors: Error[]; private _createdCallbacks; private _processingCallbacks; private _doneCallbacks; private _abortCallbacks; private _errorCallbacks; private _executionStatus; private _interval?; private _statusPromise?; private _nextPollDelay; private _numRetries; constructor(request: REQUEST, requester: BatchRequester, opts?: BatchJobOptions & FSRequestOptions); restart(jobId?: string): void; getId(): string | undefined; getStatus(): JobStatus | undefined; getImports(): IMPORT[]; getFailedImports(): FAILURE[]; add(...requests: SINGLE_REQ[]): this; execute(): void; on(type: 'created', callback: (job: this) => void): this; on(type: 'processing', callback: (job: this) => void): this; on(type: 'done', callback: (imported: IMPORT[], failed: FAILURE[]) => void): this; on(type: 'error', callback: (error: Error) => void): this; on(type: 'abort', callback: (errors: Error[]) => void): this; private setMetadata; private startPolling; private stopPolling; private handleJobCreated; private handleProcessing; private handleCompleted; private handleCompletedWithFailure; private handleError; private handleAbort; private requestImportsWithPaging; private requestImportErrorsWithPaging; private withPageToken; }