1 | import { EventEmitter } from 'events';
|
2 | import { BatchDescribeSObjectOptions, DescribeSObjectOptions, DescribeSObjectResult, DescribeGlobalResult } from './describe-result';
|
3 | import { Query, QueryResult, ExecuteOptions } from './query';
|
4 | import { Record } from './record';
|
5 | import { RecordResult } from './record-result';
|
6 | import { SObject } from './salesforce-object';
|
7 | import { Analytics } from './api/analytics';
|
8 | import { Chatter } from './api/chatter';
|
9 | import { Metadata } from './api/metadata';
|
10 | import { Apex } from './api/apex';
|
11 | import { Bulk } from './bulk';
|
12 | import { Cache } from './cache'
|
13 | import { OAuth2, Streaming } from '.';
|
14 | import { HttpApiOptions } from './http-api'
|
15 | import { LimitsInfo } from './limits-info';
|
16 |
|
17 | export type Callback<T> = (err: Error | null, result: T) => void;
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | export interface RestApiOptions {
|
23 | headers?: { [x: string]: string }
|
24 | allowRecursive?: boolean;
|
25 | allOrNone?: boolean;
|
26 | }
|
27 |
|
28 |
|
29 |
|
30 | export interface PartialOAuth2Options {
|
31 | clientId?: string;
|
32 | clientSecret?: string;
|
33 | loginUrl?: string;
|
34 | redirectUri?: string;
|
35 | tokenServiceUrl?: string;
|
36 | authzServiceUrl?: string;
|
37 | }
|
38 |
|
39 | export interface RequestInfo {
|
40 | body?: string;
|
41 | headers?: object;
|
42 | method?: string;
|
43 | url?: string;
|
44 | }
|
45 |
|
46 | export interface ConnectionOptions extends PartialOAuth2Options {
|
47 | accessToken?: string;
|
48 | callOptions?: Object;
|
49 | instanceUrl?: string;
|
50 | loginUrl?: string;
|
51 | logLevel?: string;
|
52 | maxRequest?: number;
|
53 | oauth2?: Partial<PartialOAuth2Options>;
|
54 | proxyUrl?: string;
|
55 | httpProxy?: string;
|
56 | redirectUri?: string;
|
57 | refreshToken?: string;
|
58 | refreshFn?: (conn: Connection, callback: Callback<UserInfo>) => Promise<UserInfo>;
|
59 | serverUrl?: string;
|
60 | sessionId?: string;
|
61 | signedRequest?: string | Object;
|
62 | version?: string;
|
63 | }
|
64 |
|
65 | export interface UserInfo {
|
66 | id: string;
|
67 | organizationId: string;
|
68 | url: string;
|
69 | }
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | export interface IdentityInfo {
|
78 | id: string;
|
79 | asserted_user: boolean;
|
80 | user_id: string;
|
81 | organization_id: string;
|
82 | username: string;
|
83 | nick_name: string;
|
84 | display_name: string;
|
85 | email: string;
|
86 | email_verified: boolean;
|
87 | first_name: string | null;
|
88 | last_name: string;
|
89 | timezone: string;
|
90 | photos: {
|
91 | picture: string;
|
92 | thumbnail: string;
|
93 | };
|
94 | addr_street: string | null;
|
95 | addr_city: string | null;
|
96 | addr_state: string | null;
|
97 | addr_country: string | null;
|
98 | addr_zip: string | null;
|
99 | mobile_phone: string | null;
|
100 | mobile_phone_verified: boolean;
|
101 | is_lightning_login_user: boolean;
|
102 | status: {
|
103 | created_date: Date | null;
|
104 | body: string | null;
|
105 | };
|
106 | urls: {
|
107 | enterprise: string;
|
108 | metadata: string;
|
109 | partner: string;
|
110 | rest: string;
|
111 | sobjects: string;
|
112 | search: string;
|
113 | query: string;
|
114 | recent: string;
|
115 | tooling_soap: string;
|
116 | tooling_rest: string;
|
117 | profile: string;
|
118 | feeds: string;
|
119 | groups: string;
|
120 | users: string;
|
121 | feed_items: string;
|
122 | feed_elements: string;
|
123 | custom_domain?: string;
|
124 | };
|
125 | active: boolean;
|
126 | user_type: string;
|
127 | language: string;
|
128 | locale: string;
|
129 | utcOffset: number;
|
130 | last_modified_date: Date;
|
131 | is_app_installed: boolean;
|
132 |
|
133 | [key: string]: any;
|
134 | }
|
135 |
|
136 | export abstract class RestApi {
|
137 | get(path: string, options: object, callback: () => object): Promise<object>;
|
138 | post(path: string, body: object, options: object, callback: () => object): Promise<object>;
|
139 | put(path: string, body: object, options: object, callback: () => object): Promise<object>;
|
140 | patch(path: string, body: object, options: object, callback: () => object): Promise<object>;
|
141 | del(path: string, options: object, callback: () => object): Promise<object>;
|
142 | }
|
143 |
|
144 | export interface ExecuteAnonymousResult {
|
145 | compiled: boolean;
|
146 | compileProblem: string;
|
147 | success: boolean;
|
148 | line: number;
|
149 | column: number;
|
150 | exceptionMessage: string;
|
151 | exceptionStackTrace: string;
|
152 | }
|
153 |
|
154 | export type ConnectionEvent = "refresh";
|
155 |
|
156 | export interface SearchResult<T> {
|
157 | searchRecords: Record<T>[];
|
158 | }
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 | export abstract class BaseConnection extends EventEmitter {
|
180 | _baseUrl(): string;
|
181 | request<T = object>(info: RequestInfo | string, options?: HttpApiOptions, callback?: (err: Error, Object: T) => void): Promise<T>;
|
182 | query<T>(soql: string, options?: ExecuteOptions, callback?: (err: Error, result: QueryResult<T>) => void): Query<QueryResult<T>>;
|
183 | queryMore<T>(locator: string, options?: ExecuteOptions, callback?: (err: Error, result: QueryResult<T>) => void): Promise<QueryResult<T>>;
|
184 | create<T>(type: string, records: Record<T> | Array<Record<T>>, options?: RestApiOptions,
|
185 | callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
186 | create<T>(records: Record<T> | Array<Record<T>>, options?: RestApiOptions,
|
187 | callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
188 | insert<T>(type: string, records: Record<T> | Array<Record<T>>, options?: RestApiOptions,
|
189 | callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
190 | retrieve<T>(type: string, ids: string | string[], options?: RestApiOptions,
|
191 | callback?: (err: Error, result: Record<T> | Array<Record<T>>) => void): Promise<(Record<T> | Array<Record<T>>)>;
|
192 | update<T>(type: string, records: Record<T> | Array<Record<T>>, options?: RestApiOptions,
|
193 | callback?: (err: Error, result: RecordResult | Array<Record<T>>) => void): Promise<(RecordResult | RecordResult[])>;
|
194 | update<T>(records: Record<T> | Array<Record<T>>, options?: RestApiOptions,
|
195 | callback?: (err: Error, result: RecordResult | Array<Record<T>>) => void): Promise<(RecordResult | RecordResult[])>;
|
196 | upsert<T>(type: string, records: Record<T> | Array<Record<T>>, extIdField: string, options?: RestApiOptions,
|
197 | callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
198 | upsert<T>(records: Record<T> | Array<Record<T>>, extIdField: string, options?: RestApiOptions,
|
199 | callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
200 | del<T>(type: string, ids: string | string[], options?: RestApiOptions,
|
201 | callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
202 | delete<T>(type: string, ids: string | string[], options?: RestApiOptions,
|
203 | callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
204 | destroy<T>(type: string, ids: string | string[], options?: RestApiOptions,
|
205 | callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
206 | describe$: {
|
207 | /** Returns a value from the cache if it exists, otherwise calls Connection.describe */
|
208 | (type: string|DescribeSObjectOptions, callback?: (err: Error, result: DescribeSObjectResult) => void): DescribeSObjectResult;
|
209 | clear(): void;
|
210 | }
|
211 | describe(type: string|DescribeSObjectOptions, callback?: (err: Error, result: DescribeSObjectResult) => void): Promise<DescribeSObjectResult>;
|
212 | batchDescribe(options: BatchDescribeSObjectOptions, callback?: (err: Error, result: DescribeSObjectResult[]) => void): Promise<DescribeSObjectResult[]>;
|
213 | describeGlobal$: {
|
214 | /** Returns a value from the cache if it exists, otherwise calls Connection.describeGlobal */
|
215 | (callback?: (err: Error, result: DescribeGlobalResult) => void): DescribeGlobalResult;
|
216 | clear(): void;
|
217 | }
|
218 | describeGlobal<T>(callback?: (err: Error, result: DescribeGlobalResult) => void): Promise<DescribeGlobalResult>;
|
219 | // we want any object to be accepted if the user doesn't decide to give an explicit type
|
220 | sobject<T = object>(resource: string): SObject<T>;
|
221 | recent(callback?: (err: Error, result: RecordResult[]) => void): Promise<(RecordResult[])>;
|
222 | recent(param: number | string, callback?: (err: Error, result: RecordResult[]) => void): Promise<(RecordResult[])>;
|
223 | recent(type: string, limit: number, callback?: (err: Error, result: RecordResult[]) => void): Promise<(RecordResult[])>;
|
224 | search<T>(sosl: string, callback?: (err: Error, result: SearchResult<T>) => void): Promise<(SearchResult<T>)>;
|
225 | }
|
226 |
|
227 | export class Connection extends BaseConnection {
|
228 | constructor(params: ConnectionOptions)
|
229 |
|
230 | tooling: Tooling;
|
231 | analytics: Analytics;
|
232 | apex: Apex;
|
233 | chatter: Chatter;
|
234 | metadata: Metadata;
|
235 | bulk: Bulk;
|
236 | oauth2: OAuth2;
|
237 | streaming: Streaming;
|
238 | cache: Cache;
|
239 |
|
240 | // Specific to Connection
|
241 | instanceUrl: string;
|
242 | version: string;
|
243 | accessToken: string;
|
244 | refreshToken?: string;
|
245 | userInfo?: UserInfo;
|
246 | initialize(options?: ConnectionOptions): void;
|
247 | queryAll<T>(soql: string, options?: object, callback?: (err: Error, result: QueryResult<T>) => void): Query<QueryResult<T>>;
|
248 | authorize(code: string, callback?: (err: Error, res: UserInfo) => void): Promise<UserInfo>;
|
249 | login(user: string, password: string, callback?: (err: Error, res: UserInfo) => void): Promise<UserInfo>;
|
250 | loginByOAuth2(user: string, password: string, callback?: (err: Error, res: UserInfo) => void): Promise<UserInfo>;
|
251 | loginBySoap(user: string, password: string, callback?: (err: Error, res: UserInfo) => void): Promise<UserInfo>;
|
252 | logout(revoke: boolean, callback?: (err: Error, res: undefined) => void): Promise<void>;
|
253 | logout(callback?: (err: Error, res: undefined) => void): Promise<void>;
|
254 | logoutByOAuth2(revoke: boolean, callback?: (err: Error, res: undefined) => void): Promise<void>;
|
255 | logoutByOAuth2(callback?: (err: Error, res: undefined) => void): Promise<void>;
|
256 | logoutBySoap(revoke: boolean, callback?: (err: Error, res: undefined) => void): Promise<void>;
|
257 | logoutBySoap(callback?: (err: Error, res: undefined) => void): Promise<void>;
|
258 | limits(callback?: (err: Error, res: undefined) => void): Promise<LimitsInfo>;
|
259 | identity(callback?: (err: Error, res: IdentityInfo) => void): Promise<IdentityInfo>;
|
260 | }
|
261 |
|
262 | export class Tooling extends BaseConnection {
|
263 | _logger: any;
|
264 |
|
265 | // Specific to tooling
|
266 | executeAnonymous(body: string, callback?: (err: Error, res: any) => void): Promise<ExecuteAnonymousResult>;
|
267 | }
|
268 |
|
\ | No newline at end of file |