@salesforce/source-deploy-retrieve
Version:
JavaScript library to run Salesforce metadata deploys and retrieves
64 lines (63 loc) • 3.07 kB
TypeScript
import { Connection, Logger, PollingClient } from '@salesforce/core';
import { SfdxFileFormat } from '../convert/types';
import { ComponentSet } from '../collections/componentSet';
import { AsyncResult, MetadataRequestStatus, MetadataTransferResult } from './types';
export type MetadataTransferOptions = {
usernameOrConnection: string | Connection;
components?: ComponentSet;
apiVersion?: string;
id?: string;
};
export declare abstract class MetadataTransfer<Status extends MetadataRequestStatus, Result extends MetadataTransferResult, Options extends MetadataTransferOptions> {
protected components?: ComponentSet;
protected logger: Logger;
protected canceled: boolean;
protected mdapiTempDir?: string;
private transferId;
private event;
private usernameOrConnection;
private apiVersion?;
constructor({ usernameOrConnection, components, apiVersion, id }: Options);
get id(): Options['id'];
/**
* Send the metadata transfer request to the org.
*
* @returns AsyncResult from the deploy or retrieve response.
*/
start(): Promise<AsyncResult>;
/**
* Poll for the status of the metadata transfer request.
* Default frequency is 100 ms.
* Default timeout is 60 minutes.
*
* @param options Polling options; frequency, timeout, polling function.
* @returns The result of the deploy or retrieve.
*/
pollStatus(options?: Partial<PollingClient.Options>): Promise<Result>;
/**
* Poll for the status of the metadata transfer request.
* Default frequency is based on the number of SourceComponents, n, in the transfer, it ranges from 100ms -> n
* Default timeout is 60 minutes.
*
* @param frequency Polling frequency in milliseconds.
* @param timeout Polling timeout in seconds.
* @returns The result of the deploy or retrieve.
*/
pollStatus(frequency?: number, timeout?: number): Promise<Result>;
onUpdate(subscriber: (result: Status) => void): void;
onFinish(subscriber: (result: Result) => void): void;
onCancel(subscriber: (result: Status | undefined) => void): void;
onError(subscriber: (result: Error) => void): void;
protected maybeSaveTempDirectory(target: SfdxFileFormat, cs?: ComponentSet): Promise<void>;
protected getConnection(): Promise<Connection>;
private isRetryableError;
private poll;
abstract checkStatus(): Promise<Status>;
abstract cancel(): Promise<void>;
protected abstract pre(): Promise<AsyncResult>;
protected abstract post(result: Status): Promise<Result>;
}
/** there's an options object OR 2 raw number param, there's defaults including freq based on the CS size */
export declare const normalizePollingInputs: (frequencyOrOptions?: number | Partial<PollingClient.Options>, timeout?: number, componentSetSize?: number) => Pick<PollingClient.Options, "frequency" | "timeout">;
/** based on the size of the components, pick a reasonable polling frequency */
export declare const calculatePollingFrequency: (size: number) => number;