Skip to content

Commit

Permalink
Update jsforce interfaces, function definitions (DefinitelyTyped#37021)
Browse files Browse the repository at this point in the history
* make type optional in create, update, upsert
implement RetrieveRequest, associated interfaces

* fix spacing
  • Loading branch information
kenhuman authored and breeze9527 committed Jan 27, 2020
1 parent fe6f827 commit 433e097
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 36 deletions.
173 changes: 137 additions & 36 deletions types/jsforce/api/metadata.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,40 @@ 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 RetrieveResult {
Expand Down Expand Up @@ -135,43 +168,111 @@ export class Metadata {

constructor(conn: Connection);

checkDeployStatus(id: string, includeDetails?: boolean, callback?: Callback<DeployResult>): Promise<DeployResult>

checkRetrieveStatus(id: string, callback?: Callback<RetrieveResult>): Promise<RetrieveResult>

checkStatus(ids: string | string[], callback?: Callback<AsyncResult | Array<AsyncResult>>): AsyncResultLocator<AsyncResult | Array<AsyncResult>>

create(type: string, metadata: MetadataInfo | Array<MetadataInfo>, callback?: Callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>

createAsync(type: string, metadata: MetadataInfo | Array<MetadataInfo>, callback?: Callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>

createSync(type: string, metadata: MetadataInfo | Array<MetadataInfo>, callback?: Callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>;

delete(type: string, fullNames: string | string[], callback?: Callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>;

deleteAsync(type: string, metadata: string | string[] | MetadataInfo | Array<MetadataInfo>, callback?: Callback<AsyncResult | Array<AsyncResult>>): AsyncResultLocator<AsyncResult | Array<AsyncResult>>

deleteSync(type: string, fullNames: string | string[], callback?: Callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>;

deploy(zipInput: Stream | Buffer | string, options: DeployOptions, callback?:Callback<AsyncResult>): DeployResultLocator<AsyncResult>;
checkDeployStatus(
id: string,
includeDetails?: boolean,
callback?: Callback<DeployResult>
): Promise<DeployResult>;

checkRetrieveStatus(id: string, callback?: Callback<RetrieveResult>): Promise<RetrieveResult>;

checkStatus(
ids: string | string[],
callback?: Callback<AsyncResult | Array<AsyncResult>>
): AsyncResultLocator<AsyncResult | Array<AsyncResult>>;

create(
type: string,
metadata: MetadataInfo | Array<MetadataInfo>,
callback?: Callback<SaveResult | Array<SaveResult>>
): Promise<SaveResult | Array<SaveResult>>;

createAsync(
type: string,
metadata: MetadataInfo | Array<MetadataInfo>,
callback?: Callback<SaveResult | Array<SaveResult>>
): Promise<SaveResult | Array<SaveResult>>;

createSync(
type: string,
metadata: MetadataInfo | Array<MetadataInfo>,
callback?: Callback<SaveResult | Array<SaveResult>>
): Promise<SaveResult | Array<SaveResult>>;

delete(
type: string,
fullNames: string | string[],
callback?: Callback<SaveResult | Array<SaveResult>>
): Promise<SaveResult | Array<SaveResult>>;

deleteAsync(
type: string,
metadata: string | string[] | MetadataInfo | Array<MetadataInfo>,
callback?: Callback<AsyncResult | Array<AsyncResult>>
): AsyncResultLocator<AsyncResult | Array<AsyncResult>>;

deleteSync(
type: string,
fullNames: string | string[],
callback?: Callback<SaveResult | Array<SaveResult>>
): Promise<SaveResult | Array<SaveResult>>;

deploy(
zipInput: Stream | Buffer | string,
options: DeployOptions,
callback?: Callback<AsyncResult>
): DeployResultLocator<AsyncResult>;

describe(version?: string, callback?: Callback<DescribeMetadataResult>): Promise<DescribeMetadataResult>;

list(queries: ListMetadataQuery | Array<ListMetadataQuery>, version?: string, callback?: Callback<Array<FileProperties>>): Promise<Array<FileProperties>>;

read(type: string, fullNames: string | string[], callback?: Callback<MetadataInfo | Array<MetadataInfo>>): Promise<MetadataInfo | Array<MetadataInfo>>;

readSync(type: string, fullNames: string | string[], callback?: Callback<MetadataInfo | Array<MetadataInfo>>): Promise<MetadataInfo | Array<MetadataInfo>>;

rename(type: string, oldFullName: string, newFullName: string, callback?: Callback<SaveResult>): Promise<SaveResult>

retrieve(request: RetrieveRequest, callback: Callback<AsyncResult>): RetrieveResultLocator<AsyncResult>

update(type: string, updateMetadata: MetadataInfo | Array<MetadataInfo>, callback?: Callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>

updateAsync(type: string, updateMetadata: MetadataInfo, callback?: Callback<AsyncResult | Array<AsyncResult>>): AsyncResultLocator<AsyncResult | Array<AsyncResult>>

updateSync(type: string, updateMetadata: MetadataInfo | Array<MetadataInfo>, callback?: Callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>

upsert(type: string, metadata: MetadataInfo | Array<MetadataInfo>, callback?: Callback<UpsertResult | Array<UpsertResult>>): Promise<UpsertResult | Array<UpsertResult>>
list(
queries: ListMetadataQuery | Array<ListMetadataQuery>,
version?: string,
callback?: Callback<Array<FileProperties>>
): Promise<Array<FileProperties>>;

read(
type: string,
fullNames: string | string[],
callback?: Callback<MetadataInfo | Array<MetadataInfo>>
): Promise<MetadataInfo | Array<MetadataInfo>>;

readSync(
type: string,
fullNames: string | string[],
callback?: Callback<MetadataInfo | Array<MetadataInfo>>
): Promise<MetadataInfo | Array<MetadataInfo>>;

rename(
type: string,
oldFullName: string,
newFullName: string,
callback?: Callback<SaveResult>
): Promise<SaveResult>;

retrieve(request: RetrieveRequest, callback?: Callback<AsyncResult>): RetrieveResultLocator<AsyncResult>;

update(
type: string,
updateMetadata: MetadataInfo | Array<MetadataInfo>,
callback?: Callback<SaveResult | Array<SaveResult>>
): Promise<SaveResult | Array<SaveResult>>;

updateAsync(
type: string,
updateMetadata: MetadataInfo,
callback?: Callback<AsyncResult | Array<AsyncResult>>
): AsyncResultLocator<AsyncResult | Array<AsyncResult>>;

updateSync(
type: string,
updateMetadata: MetadataInfo | Array<MetadataInfo>,
callback?: Callback<SaveResult | Array<SaveResult>>
): Promise<SaveResult | Array<SaveResult>>;

upsert(
type: string,
metadata: MetadataInfo | Array<MetadataInfo>,
callback?: Callback<UpsertResult | Array<UpsertResult>>
): Promise<UpsertResult | Array<UpsertResult>>;
}
6 changes: 6 additions & 0 deletions types/jsforce/connection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,20 @@ export abstract class BaseConnection extends EventEmitter {
queryMore<T>(locator: string, options?: ExecuteOptions, callback?: (err: Error, result: QueryResult<T>) => void): Promise<QueryResult<T>>;
create<T>(type: string, records: Record<T> | Array<Record<T>>, options?: RestApiOptions,
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
create<T>(records: Record<T> | Array<Record<T>>, options?: RestApiOptions,
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
insert<T>(type: string, records: Record<T> | Array<Record<T>>, options?: RestApiOptions,
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
retrieve<T>(type: string, ids: string | string[], options?: RestApiOptions,
callback?: (err: Error, result: Record<T> | Array<Record<T>>) => void): Promise<(Record<T> | Array<Record<T>>)>;
update<T>(type: string, records: Record<T> | Array<Record<T>>, options?: RestApiOptions,
callback?: (err: Error, result: RecordResult | Array<Record<T>>) => void): Promise<(RecordResult | RecordResult[])>;
update<T>(records: Record<T> | Array<Record<T>>, options?: RestApiOptions,
callback?: (err: Error, result: RecordResult | Array<Record<T>>) => void): Promise<(RecordResult | RecordResult[])>;
upsert<T>(type: string, records: Record<T> | Array<Record<T>>, extIdField: string, options?: RestApiOptions,
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
upsert<T>(records: Record<T> | Array<Record<T>>, extIdField: string, options?: RestApiOptions,
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
del<T>(type: string, ids: string | string[], options?: RestApiOptions,
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
delete<T>(type: string, ids: string | string[], options?: RestApiOptions,
Expand Down
1 change: 1 addition & 0 deletions types/jsforce/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// Abraham White <https://github.com/whiteabelincoln>
// Borys Kupar <https://github.com/borys-kupar>
// Andrés Catalán <https://github.com/catalandres>
// Ken Human <https://github.com/kenhuman>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

Expand Down

0 comments on commit 433e097

Please sign in to comment.