import { Callback, Connection } from '../connection'; import { EventEmitter } from 'events'; import { Stream } from 'stream'; import { Buffer } from 'buffer'; import { PicklistEntry } from '../describe-result'; interface DeployMessage { changed: boolean columnNumber: number componentType: string created: boolean createdDate: string deleted: boolean fileName: string fullName: string id: string lineNumber: number problem: string problemType: string success: boolean } interface DeployDetails { componentFailures?: DeployMessage[] componentSuccesses?: DeployMessage[] retrieveResult?: RetrieveResult runTestResult?: object } interface DeployResult { id: string; checkOnly: boolean; completedDate: string; createdDate: string; details?: DeployDetails[]; done: boolean; errorMessage?: string; errorStatusCode?: string; ignoreWarnings?: boolean; lastModifiedDate: string; numberComponentErrors: number; numberComponentsDeployed: number; numberComponentsTotal: number; numberTestErrors: number; numberTestsCompleted: number; numberTestsTotal: number; rollbackOnError?: boolean; startDate: string; status: string; success: boolean; } interface MetadataObject { childXmlNames?: string[]; directoryName?: string; inFolder?: boolean; metaFile?: boolean; suffix?: string; xmlName: string; } interface DescribeMetadataResult { metadataObjects: MetadataObject[]; organizationNamespace: string; partialSaveAllowed: boolean; testRequired: boolean; } interface FileProperties { type: string; createdById: string; createdByName: string; createdDate: string; fileName: string; fullName: string; id: string; lastModifiedById: string; lastModifiedByName: string; lastModifiedDate: string; manageableState?: string; namespacePrefix?: string; } interface ListMetadataQuery { type: string; folder?: string; } interface MetadataInfo { fullName: string; } interface Package { apiAccessLevel?: "Unrestricted" | "Restricted"; description?: string; fullName?: string; namespacePrefix?: string; objectPermissions?: ProfileObjectPermissions[]; postInstallClass?: string; setupWeblink?: string; types: PackageTypeMembers[]; uninstallClass?: string; version: string; } interface PackageTypeMembers { members: string[]; name: string; } interface ProfileObjectPermissions { allowCreate?: boolean; allowDelete?: boolean; allowEdit?: boolean; allowRead?: boolean; modifyAllRecords?: boolean; object: string; viewAllRecords?: boolean; } interface RetrieveRequest { apiVersion?: string; packageNames?: string[]; singlePackage?: boolean; specificFiles?: string[]; unpackaged?: Package; } interface RetrieveMessage { fileName: string; problem: string; } interface RetrieveResult { done?: string; errorMessage?: string; errorStatusCode?: string; fileProperties: FileProperties[]; id: string; messages: RetrieveMessage[]; status?: string; success?: string; zipFile: string; } interface SaveResult { success: boolean; fullName: string; } interface UpdateMetadataInfo { currentName: string; metadata: MetadataInfo; } interface UpsertResult { success: boolean; fullName: string; created: boolean; } interface AsyncResult { done: boolean; id: string; state: string; statusCode?: string; message?: string; } interface DeployOptions { allowMissingFiles?: boolean; autoUpdatePackage?: boolean; checkOnly?: boolean; ignoreWarnings?: boolean; performRetrieve?: boolean; purgeOnDelete?: boolean; rollbackOnError?: boolean; runAllTests?: boolean; runTests?: string[]; singlePackage?: boolean; } interface ValueTypeField { fields: ValueTypeField[]; foreignKeyDomain: string; isForeignKey: boolean; isNameField: boolean; minOccurs: number; name: string; picklistValues: PicklistEntry[]; soapType: string; valueRequired: boolean; } interface DescribeValueTypeResult { apiCreatable: boolean; apiDeletable: boolean; apiReadable: boolean; apiUpdatable: boolean; parentField: ValueTypeField; valueTypeFields: ValueTypeField[]; } export class AsyncResultLocator extends EventEmitter implements PromiseLike { check(callback?: Callback): Promise complete(callback?: Callback): Promise poll(interval: number, timeout: number): void; then(onfulfilled?: ((value: T) => (PromiseLike | TResult1)) | null | undefined, onrejected?: ((reason: any) => (PromiseLike | TResult2)) | null | undefined): Promise; finally(onfinally?: () => void): Promise; } export class DeployResultLocator extends AsyncResultLocator { complete(includeDetails?: boolean, callback?: Callback): Promise // The following overload is not really implemented but if we don't include it typescript // will not allow us to say this class extends AsyncResultLocator complete(callback?: Callback): Promise } export class RetrieveResultLocator extends AsyncResultLocator {} export class Metadata { pollInterval: number; pollTimeout: number; constructor(conn: Connection); checkDeployStatus( id: string, includeDetails?: boolean, callback?: Callback ): Promise; checkRetrieveStatus(id: string, callback?: Callback): Promise; checkStatus( ids: string | string[], callback?: Callback> ): AsyncResultLocator>; create( type: string, metadata: MetadataInfo | Array, callback?: Callback> ): Promise>; createAsync( type: string, metadata: MetadataInfo | Array, callback?: Callback> ): Promise>; createSync( type: string, metadata: MetadataInfo | Array, callback?: Callback> ): Promise>; delete( type: string, fullNames: string | string[], callback?: Callback> ): Promise>; deleteAsync( type: string, metadata: string | string[] | MetadataInfo | Array, callback?: Callback> ): AsyncResultLocator>; deleteSync( type: string, fullNames: string | string[], callback?: Callback> ): Promise>; deploy( zipInput: Stream | Buffer | string, options: DeployOptions, callback?:Callback ): DeployResultLocator; deployRecentValidation( validationId: string, callback?:Callback ): DeployResultLocator; describe(version?: string, callback?: Callback): Promise; describeValueType( type: string, version?: string, callback?: Callback ): Promise list( queries: ListMetadataQuery | Array, version?: string, callback?: Callback> ): Promise>; read( type: string, fullNames: string | string[], callback?: Callback> ): Promise>; readSync( type: string, fullNames: string | string[], callback?: Callback> ): Promise>; rename( type: string, oldFullName: string, newFullName: string, callback?: Callback ): Promise; retrieve(request: RetrieveRequest, callback: Callback): RetrieveResultLocator update( type: string, updateMetadata: MetadataInfo | Array, callback?: Callback> ): Promise>; updateAsync( type: string, updateMetadata: MetadataInfo, callback?: Callback> ): AsyncResultLocator>; updateSync( type: string, updateMetadata: MetadataInfo | Array, callback?: Callback> ): Promise>; upsert( type: string, metadata: MetadataInfo | Array, callback?: Callback> ): Promise>; }