mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
querying and update enhancements
This commit is contained in:
20
types/jsforce/connection.d.ts
vendored
20
types/jsforce/connection.d.ts
vendored
@@ -1,21 +1,26 @@
|
||||
import { SObjectCreateOptions } from './create-options';
|
||||
import { DescribeSObjectResult } from './describe-result';
|
||||
import { Query } from './query';
|
||||
import { Query, QueryResult } from './query';
|
||||
import { RecordResult } from './record-result';
|
||||
import { SObject } from './salesforce-object';
|
||||
|
||||
export interface ConnectionOptions {
|
||||
// These are pulled out because according to http://jsforce.github.io/jsforce/doc/connection.js.html#line49
|
||||
//the oauth options can either be in the `oauth2` proeprty OR spread across the main connection
|
||||
interface OAuth2Options {
|
||||
clientId: string;
|
||||
clientSecret: string;
|
||||
loginUrl: string;
|
||||
redirectUri?: string;
|
||||
}
|
||||
|
||||
export interface ConnectionOptions extends Partial<OAuth2Options> {
|
||||
accessToken?: string;
|
||||
callOptions?: Object;
|
||||
instanceUrl?: string;
|
||||
loginUrl?: string;
|
||||
logLevel?: string;
|
||||
maxRequest?: number;
|
||||
oauth2?: {
|
||||
clientId: string,
|
||||
clientSecret: string,
|
||||
redirectUri?: string,
|
||||
};
|
||||
oauth2?: OAuth2Options;
|
||||
proxyUrl?: string;
|
||||
redirectUri?: string;
|
||||
refreshToken?: string;
|
||||
@@ -37,6 +42,7 @@ export class Connection {
|
||||
constructor(params: ConnectionOptions)
|
||||
|
||||
accessToken: string;
|
||||
query<T>(soql: string, callback?: (err: Error, result: QueryResult<T>) => void): QueryResult<T>;
|
||||
sobject(resource: string): SObject;
|
||||
login(user: string, password: string, callback?: (err: Error, res: UserInfo) => void): Promise<UserInfo>;
|
||||
loginByOAuth2(user: string, password: string, callback?: (err: Error, res: UserInfo) => void): Promise<UserInfo>;
|
||||
|
||||
10
types/jsforce/query.d.ts
vendored
10
types/jsforce/query.d.ts
vendored
@@ -7,7 +7,14 @@ export interface ExecuteOptions {
|
||||
scanAll?: number;
|
||||
}
|
||||
|
||||
export class Query<T> {
|
||||
export interface QueryResult<T> {
|
||||
done: boolean;
|
||||
nextRecordsUrl?: string;
|
||||
totalSize: number;
|
||||
records: T[];
|
||||
}
|
||||
|
||||
export class Query<T> extends Promise<T> {
|
||||
end(): Query<T>;
|
||||
filter(filter: Object): Query<T>;
|
||||
include(include: string): Query<T>;
|
||||
@@ -27,7 +34,6 @@ export class Query<T> {
|
||||
map(callback: (currentValue: Object) => void): Promise<any>;
|
||||
scanAll(value: boolean): Query<T>;
|
||||
select(fields: Object | string[] | string): Query<T>;
|
||||
then(onSuccess?: Function, onRejected?: Function): Promise<any>;
|
||||
thenCall(callback?: (err: Error, records: T) => void): Query<T>;
|
||||
toSOQL(callback: (err: Error, soql: string) => void): Promise<string>;
|
||||
update(mapping: any, type: string, callback: (err: Error, records: RecordResult[]) => void): Promise<RecordResult[]>;
|
||||
|
||||
14
types/jsforce/record-result.d.ts
vendored
14
types/jsforce/record-result.d.ts
vendored
@@ -1,7 +1,13 @@
|
||||
import { SalesforceId } from './salesforce-id';
|
||||
|
||||
export interface RecordResult {
|
||||
id: SalesforceId;
|
||||
success: boolean;
|
||||
anys: Object[];
|
||||
interface ErrorResult {
|
||||
errors: string[];
|
||||
success: false;
|
||||
}
|
||||
|
||||
interface SuccessResult {
|
||||
id: SalesforceId;
|
||||
success: true;
|
||||
}
|
||||
|
||||
export type RecordResult = SuccessResult | ErrorResult;
|
||||
|
||||
3
types/jsforce/salesforce-object.d.ts
vendored
3
types/jsforce/salesforce-object.d.ts
vendored
@@ -10,7 +10,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;
|
||||
update<T>(record: Partial<T>, options?: Object, callback?: (err: Error, ret: RecordResult) => void): Promise<RecordResult>;
|
||||
update<T>(records: Partial<T>[], options?: Object, callback?: (err: Error, ret: RecordResult[]) => void): Promise<RecordResult[]>;
|
||||
retrieve(ids: string | string[], callback?: (err: Error, ret: Record | Record[]) => void): Promise<Record | Record[]>;
|
||||
retrieve(ids: string | string[], options?: Object, callback?: (err: Error, ret: Record | Record[]) => void): Promise<Record | Record[]>;
|
||||
upsert(records: Record | Record[], extIdField: SalesforceId, options?: Object, callback?: (err: Error, ret: RecordResult) => void): Promise<RecordResult | RecordResult[]>;
|
||||
|
||||
Reference in New Issue
Block a user