///
///
///
/**
* @file Manages Salesforce Metadata API
* @author Shinichi Tomita
*/
import { EventEmitter } from 'events';
import { Readable } from 'stream';
import Connection from '../connection';
import { Schema, SoapSchemaDef, SoapSchema } from '../types';
import { Metadata, SaveResult, UpsertResult, ListMetadataQuery, FileProperties, DescribeMetadataResult, RetrieveRequest, DeployOptions, RetrieveResult, DeployResult, AsyncResult, ApiSchemaTypes, CancelDeployResult } from './metadata/schema';
export * from './metadata/schema';
/**
*
*/
type MetadataType_ = K extends keyof ApiSchemaTypes ? ApiSchemaTypes[K] extends Metadata ? K : never : never;
export type MetadataType = MetadataType_;
export type MetadataDefinition = Metadata extends M ? T extends keyof ApiSchemaTypes & MetadataType ? ApiSchemaTypes[T] extends Metadata ? ApiSchemaTypes[T] : Metadata : Metadata : M;
type DeepPartial = T extends any[] ? Array> : T extends object ? {
[K in keyof T]?: DeepPartial;
} : T;
export type InputMetadataDefinition = DeepPartial>;
/**
* Class for Salesforce Metadata API
*/
export declare class MetadataApi {
_conn: Connection;
/**
* Polling interval in milliseconds
*/
pollInterval: number;
/**
* Polling timeout in milliseconds
*/
pollTimeout: number;
/**
*
*/
constructor(conn: Connection);
/**
* Call Metadata API SOAP endpoint
*
* @private
*/
_invoke(method: string, message: object, schema?: SoapSchema | SoapSchemaDef): Promise;
/**
* Add one or more new metadata components to the organization.
*/
create = InputMetadataDefinition>(type: T, metadata: MD[]): Promise;
create = InputMetadataDefinition>(type: T, metadata: MD): Promise;
create = InputMetadataDefinition>(type: T, metadata: MD | MD[]): Promise;
/**
* Read specified metadata components in the organization.
*/
read = MetadataDefinition>(type: T, fullNames: string[]): Promise;
read = MetadataDefinition>(type: T, fullNames: string): Promise;
read = MetadataDefinition>(type: T, fullNames: string | string[]): Promise;
/**
* Update one or more metadata components in the organization.
*/
update = InputMetadataDefinition>(type: T, metadata: Array>): Promise;
update = InputMetadataDefinition>(type: T, metadata: Partial): Promise;
update = InputMetadataDefinition>(type: T, metadata: Partial | Array>): Promise;
/**
* Upsert one or more components in your organization's data.
*/
upsert = InputMetadataDefinition>(type: T, metadata: MD[]): Promise;
upsert = InputMetadataDefinition>(type: T, metadata: MD): Promise;
upsert = InputMetadataDefinition>(type: T, metadata: MD | MD[]): Promise;
/**
* Deletes specified metadata components in the organization.
*/
delete(type: string, fullNames: string[]): Promise;
delete(type: string, fullNames: string): Promise;
delete(type: string, fullNames: string | string[]): Promise;
/**
* Rename fullname of a metadata component in the organization
*/
rename(type: string, oldFullName: string, newFullName: string): Promise;
/**
* Retrieves the metadata which describes your organization, including Apex classes and triggers,
* custom objects, custom fields on standard objects, tab sets that define an app,
* and many other components.
*/
describe(asOfVersion?: string): Promise;
/**
* Retrieves property information about metadata components in your organization
*/
list(queries: ListMetadataQuery | ListMetadataQuery[], asOfVersion?: string): Promise;
/**
* Checks the status of asynchronous metadata calls
*/
checkStatus(asyncProcessId: string): AsyncResultLocator;
/**
* Retrieves XML file representations of components in an organization
*/
retrieve(request: Partial): RetrieveResultLocator;
/**
* Checks the status of declarative metadata call retrieve() and returns the zip file contents
*/
checkRetrieveStatus(asyncProcessId: string): Promise;
/**
* Will deploy a recently validated deploy request
*
* @param options.id = the deploy ID that's been validated already from a previous checkOnly deploy request
* @param options.rest = a boolean whether or not to use the REST API
* @returns the deploy ID of the recent validation request
*/
deployRecentValidation(options: {
id: string;
rest?: boolean;
}): Promise;
/**
* Deploy components into an organization using zipped file representations
* using the REST Metadata API instead of SOAP
*/
deployRest(zipInput: Buffer, options?: Partial): DeployResultLocator;
/**
* Deploy components into an organization using zipped file representations
*/
deploy(zipInput: Readable | Buffer | string, options?: Partial): DeployResultLocator;
/**
* Checks the status of declarative metadata call deploy(), using either
* SOAP or REST APIs. SOAP is the default.
*/
checkDeployStatus(asyncProcessId: string, includeDetails?: boolean, rest?: boolean): Promise;
cancelDeploy(id: string): Promise;
}
/**
* The locator class for Metadata API asynchronous call result
*/
export declare class AsyncResultLocator extends EventEmitter {
_meta: MetadataApi;
_promise: Promise;
_id: string | undefined;
/**
*
*/
constructor(meta: MetadataApi, promise: Promise);
/**
* Promise/A+ interface
* http://promises-aplus.github.io/promises-spec/
*
* @method Metadata~AsyncResultLocator#then
*/
then(onResolve?: ((result: AsyncResult) => U | Promise) | null | undefined, onReject?: ((err: Error) => V | Promise) | null | undefined): Promise;
/**
* Check the status of async request
*/
check(): Promise;
/**
* Polling until async call status becomes complete or error
*/
poll(interval: number, timeout: number): void;
/**
* Check and wait until the async requests become in completed status
*/
complete(): Promise;
}
/**
* The locator class to track retreive() Metadata API call result
*/
export declare class RetrieveResultLocator extends AsyncResultLocator {
/**
* Poll checkRetrieveStatus() until the retrieve operation completes,
* then return the RetrieveResult.
*/
complete(): Promise;
/**
* Change the retrieved result to Node.js readable stream
*/
stream(): Readable;
}
/**
* The locator class to track deploy() Metadata API call result
*
* @protected
* @class Metadata~DeployResultLocator
* @extends Metadata~AsyncResultLocator
* @param {Metadata} meta - Metadata API object
* @param {Promise.} result - Promise object for async result of deploy() call
*/
export declare class DeployResultLocator extends AsyncResultLocator {
/**
* Poll checkDeployStatus() until the deploy operation completes,
* then return the DeployResult.
*/
complete(includeDetails?: boolean): Promise;
}
export default MetadataApi;