diff --git a/types/jsforce/connection.d.ts b/types/jsforce/connection.d.ts index f3864eb5d8..612bf6fc84 100644 --- a/types/jsforce/connection.d.ts +++ b/types/jsforce/connection.d.ts @@ -5,17 +5,30 @@ import { RecordResult } from './record-result'; import { SObject } from './salesforce-object'; export interface ConnectionOptions { - instanceUrl?: string; accessToken?: string; - refreshToken?: string; + callOptions?: Object; + instanceUrl?: string; + loginUrl?: string; + logLevel?: string; + maxRequest?: number; oauth2?: { clientId: string, clientSecret: string, redirectUri?: string, }; - sessionId?: string; - serverUrl?: string; + proxyUrl?: string; redirectUri?: string; + refreshToken?: string; + serverUrl?: string; + sessionId?: string; + signedRequest?: string | Object; + version?: string; +} + +export interface UserInfo { + id: string; + organizationId: string; + url: string; } export type ConnectionEvent = "refresh"; @@ -23,6 +36,13 @@ export type ConnectionEvent = "refresh"; export class Connection { constructor(params: ConnectionOptions) + accessToken: string; sobject(resource: string): SObject; + login(user: string, password: string, callback?: (err: Error, res: UserInfo) => void): Promise; + loginByOAuth2(user: string, password: string, callback?: (err: Error, res: UserInfo) => void): Promise; + loginBySoap(user: string, password: string, callback?: (err: Error, res: UserInfo) => void): Promise; + logout(callback?: (err: Error, res: undefined) => void): Promise; + logoutByOAuth2(callback?: (err: Error, res: undefined) => void): Promise; + logoutBySoap(callback?: (err: Error, res: undefined) => void): Promise; on(eventName: ConnectionEvent, callback: Function): void; } diff --git a/types/jsforce/index.d.ts b/types/jsforce/index.d.ts index bf8f98b574..fc7bd017b2 100644 --- a/types/jsforce/index.d.ts +++ b/types/jsforce/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for jsforce 1.8 // Project: https://github.com/jsforce/jsforce // Definitions by: Dolan Miu +// Kamil Ejsymont // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as fs from 'fs'; @@ -9,6 +10,7 @@ import * as express from 'express'; import * as glob from 'glob'; export { Date } from './date-enum'; +export { Record } from './record'; export { RecordResult } from './record-result'; export { Connection } from './connection'; export { SObject } from './salesforce-object'; diff --git a/types/jsforce/jsforce-tests.ts b/types/jsforce/jsforce-tests.ts index 70a41ec934..3c1657711d 100644 --- a/types/jsforce/jsforce-tests.ts +++ b/types/jsforce/jsforce-tests.ts @@ -32,8 +32,8 @@ salesforceConnection.sobject("ContentVersion").create({ salesforceConnection.sobject("ContentVersion").retrieve("world", { test: "test" -}, (err: Error, ret: sf.RecordResult) => { - if (err || !ret.success) { +}, (err: Error, ret: sf.Record) => { + if (err) { return; } }); diff --git a/types/jsforce/query.d.ts b/types/jsforce/query.d.ts index 0d716c28da..42d258a48d 100644 --- a/types/jsforce/query.d.ts +++ b/types/jsforce/query.d.ts @@ -8,7 +8,9 @@ export interface ExecuteOptions { } export class Query { + end(): Query; filter(filter: Object): Query; + include(include: string): Query; hint(hint: Object): Query; limit(value: number): Query; maxFetch(value: number): Query; @@ -22,6 +24,7 @@ export class Query { delete(callback?: (err: Error, ret: RecordResult) => void): any; destroy(callback?: (err: Error, ret: RecordResult) => void): Promise; explain(callback?: (err: Error, info: ExplainInfo) => void): Promise; + map(callback: (currentValue: Object) => void): Promise; scanAll(value: boolean): Query; select(fields: Object | string[] | string): Query; then(onSuccess?: Function, onRejected?: Function): Promise; diff --git a/types/jsforce/record.d.ts b/types/jsforce/record.d.ts new file mode 100644 index 0000000000..3bfec4c65b --- /dev/null +++ b/types/jsforce/record.d.ts @@ -0,0 +1,6 @@ +import { SalesforceId } from './salesforce-id'; + +export interface Record { + Id: SalesforceId; + attributes: Object[]; +} diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index 12c9b97cf7..31da3a2c92 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -3,6 +3,7 @@ import * as stream from 'stream'; import { SObjectCreateOptions } from './create-options'; import { DescribeSObjectResult } from './describe-result'; import { Query } from './query'; +import { Record } from './record'; import { RecordResult } from './record-result'; import { Connection } from './connection'; import { SalesforceId } from './salesforce-id'; @@ -10,8 +11,8 @@ import { SalesforceId } from './salesforce-id'; export class SObject { record(options: any, callback?: (err: Error, ret: any) => void): void; update(options: SObjectCreateOptions, callback?: (err: Error, ret: any) => void): void; - retrieve(ids: string | string[], callback?: (err: Error, ret: any) => void): void; - retrieve(ids: string | string[], options?: Object, callback?: (err: Error, ret: any) => void): void; + retrieve(ids: string | string[], callback?: (err: Error, ret: Record | Record[]) => void): Promise; + retrieve(ids: string | string[], options?: Object, callback?: (err: Error, ret: Record | Record[]) => void): Promise; upsert(records: Record | Record[], extIdField: SalesforceId, options?: Object, callback?: (err: Error, ret: RecordResult) => void): Promise; upsertBulk(input?: Record[] | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; describeGlobal(callback: (err: Error, res: any) => void): void;