/// /** * */ import { EventEmitter } from 'events'; import { HttpRequest, Record, SaveResult, UpsertResult, DescribeGlobalResult, DescribeSObjectResult, DescribeTab, DescribeTheme, DescribeQuickActionResult, UpdatedResult, DeletedResult, SearchResult, OrganizationLimitsInfo, Optional, SignedRequestObject, DmlOptions, RetrieveOptions, Schema, SObjectNames, SObjectInputRecord, SObjectUpdateRecord, SObjectFieldNames, UserInfo, IdentityInfo, LimitInfo } from './types'; import { StreamPromise } from './util/promise'; import Transport from './transport'; import { Logger } from './util/logger'; import { LogLevelConfig } from './util/logger'; import OAuth2 from './oauth2'; import { OAuth2Config } from './oauth2'; import Cache, { CachedFunction } from './cache'; import SessionRefreshDelegate, { SessionRefreshFunc } from './session-refresh-delegate'; import Query from './query'; import { QueryOptions } from './query'; import SObject from './sobject'; import QuickAction from './quick-action'; import Process from './process'; import Analytics from './api/analytics'; import Apex from './api/apex'; import { Bulk } from './api/bulk'; import { BulkV2 } from './api/bulk2'; import Chatter from './api/chatter'; import Metadata from './api/metadata'; import SoapApi from './api/soap'; import Streaming from './api/streaming'; import Tooling from './api/tooling'; /** * type definitions */ export type ConnectionConfig = { version?: string; loginUrl?: string; accessToken?: string; refreshToken?: string; instanceUrl?: string; sessionId?: string; serverUrl?: string; signedRequest?: string; oauth2?: OAuth2 | OAuth2Config; maxRequest?: number; proxyUrl?: string; httpProxy?: string; logLevel?: LogLevelConfig; callOptions?: { [name: string]: string; }; refreshFn?: SessionRefreshFunc; }; export type ConnectionEstablishOptions = { accessToken?: Optional; refreshToken?: Optional; instanceUrl?: Optional; sessionId?: Optional; serverUrl?: Optional; signedRequest?: Optional; userInfo?: Optional; }; /** * */ export declare class Connection extends EventEmitter { static _logger: Logger; version: string; loginUrl: string; instanceUrl: string; accessToken: Optional; refreshToken: Optional; userInfo: Optional; limitInfo: LimitInfo; oauth2: OAuth2; sobjects: { [N in SObjectNames]?: SObject; }; cache: Cache; _callOptions: Optional<{ [name: string]: string; }>; _maxRequest: number; _logger: Logger; _logLevel: Optional; _transport: Transport; _sessionType: Optional<'soap' | 'oauth2'>; _refreshDelegate: Optional>; describe$: CachedFunction<(name: string) => Promise>; describe$$: CachedFunction<(name: string) => DescribeSObjectResult>; describeSObject: (name: string) => Promise; describeSObject$: CachedFunction<(name: string) => Promise>; describeSObject$$: CachedFunction<(name: string) => DescribeSObjectResult>; describeGlobal$: CachedFunction<() => Promise>; describeGlobal$$: CachedFunction<() => DescribeGlobalResult>; get analytics(): Analytics; get apex(): Apex; get bulk(): Bulk; get bulk2(): BulkV2; get chatter(): Chatter; get metadata(): Metadata; get soap(): SoapApi; get streaming(): Streaming; get tooling(): Tooling; /** * */ constructor(config?: ConnectionConfig); _establish(options: ConnectionEstablishOptions): void; _clearSession(): void; _resetInstance(): void; /** * Authorize the connection using OAuth2 flow. * Typically, just pass the code returned from authorization server in the first argument to complete authorization. * If you want to authorize with grant types other than `authorization_code`, you can also pass params object with the grant type. * * @returns {Promise} An object that contains the user ID, org ID and identity URL. * */ authorize(codeOrParams: string | { grant_type: string; [name: string]: string; }, params?: { [name: string]: string; }): Promise; /** * */ login(username: string, password: string): Promise; /** * Login by OAuth2 username & password flow */ loginByOAuth2(username: string, password: string): Promise; /** * Login by SOAP protocol * @deprecated The SOAP login() API will be retired in Summer '27 (API version 65.0). * Please use OAuth 2.0 Username-Password Flow instead. * For more information, see https://help.salesforce.com/s/articleView?id=release-notes.rn_api_upcoming_retirement_258rn.htm&release=258&type=5 */ loginBySoap(username: string, password: string): Promise; /** * Logout the current session */ logout(revoke?: boolean): Promise; /** * Logout the current session by revoking access token via OAuth2 session revoke */ logoutByOAuth2(revoke?: boolean): Promise; /** * Logout the session by using SOAP web service API */ logoutBySoap(revoke?: boolean): Promise; /** * Send REST API request with given HTTP request info, with connected session information. * * Endpoint URL can be absolute URL ('https://na1.salesforce.com/services/data/v32.0/sobjects/Account/describe') * , relative path from root ('/services/data/v32.0/sobjects/Account/describe') * , or relative path from version root ('/sobjects/Account/describe'). */ request(request: string | HttpRequest, options?: Object): StreamPromise; /** * Send HTTP GET request * * Endpoint URL can be absolute URL ('https://na1.salesforce.com/services/data/v32.0/sobjects/Account/describe') * , relative path from root ('/services/data/v32.0/sobjects/Account/describe') * , or relative path from version root ('/sobjects/Account/describe'). */ requestGet(url: string, options?: Object): StreamPromise; /** * Send HTTP POST request with JSON body, with connected session information * * Endpoint URL can be absolute URL ('https://na1.salesforce.com/services/data/v32.0/sobjects/Account/describe') * , relative path from root ('/services/data/v32.0/sobjects/Account/describe') * , or relative path from version root ('/sobjects/Account/describe'). */ requestPost(url: string, body: Object, options?: Object): StreamPromise; /** * Send HTTP PUT request with JSON body, with connected session information * * Endpoint URL can be absolute URL ('https://na1.salesforce.com/services/data/v32.0/sobjects/Account/describe') * , relative path from root ('/services/data/v32.0/sobjects/Account/describe') * , or relative path from version root ('/sobjects/Account/describe'). */ requestPut(url: string, body: Object, options?: Object): StreamPromise; /** * Send HTTP PATCH request with JSON body * * Endpoint URL can be absolute URL ('https://na1.salesforce.com/services/data/v32.0/sobjects/Account/describe') * , relative path from root ('/services/data/v32.0/sobjects/Account/describe') * , or relative path from version root ('/sobjects/Account/describe'). */ requestPatch(url: string, body: Object, options?: Object): StreamPromise; /** * Send HTTP DELETE request * * Endpoint URL can be absolute URL ('https://na1.salesforce.com/services/data/v32.0/sobjects/Account/describe') * , relative path from root ('/services/data/v32.0/sobjects/Account/describe') * , or relative path from version root ('/sobjects/Account/describe'). */ requestDelete(url: string, options?: Object): StreamPromise; /** @private **/ _baseUrl(): string; /** * Convert path to absolute url * @private */ _normalizeUrl(url: string): string; /** * */ query(soql: string, options?: Partial): Query, T, 'QueryResult'>; /** * Execute search by SOSL * * @param {String} sosl - SOSL string * @param {Callback.>} [callback] - Callback function * @returns {Promise.>} */ search(sosl: string): StreamPromise; /** * */ queryMore(locator: string, options?: QueryOptions): Query, T, "QueryResult">; _ensureVersion(majorVersion: number): boolean; _supports(feature: string): boolean; /** * Retrieve specified records */ retrieve>(type: N, ids: string, options?: RetrieveOptions): Promise; retrieve>(type: N, ids: string[], options?: RetrieveOptions): Promise; retrieve>(type: N, ids: string | string[], options?: RetrieveOptions): Promise; /** @private */ _retrieveSingle(type: string, id: string, options: RetrieveOptions): Promise; /** @private */ _retrieveParallel(type: string, ids: string[], options: RetrieveOptions): Promise; /** @private */ _retrieveMany(type: string, ids: string[], options: RetrieveOptions): Promise; /** * Create records */ create, InputRecord extends SObjectInputRecord = SObjectInputRecord>(type: N, records: InputRecord[], options?: DmlOptions): Promise; create, InputRecord extends SObjectInputRecord = SObjectInputRecord>(type: N, record: InputRecord, options?: DmlOptions): Promise; create, InputRecord extends SObjectInputRecord = SObjectInputRecord>(type: N, records: InputRecord | InputRecord[], options?: DmlOptions): Promise; /** @private */ _createSingle(type: string, record: Record, options: DmlOptions): Promise; /** @private */ _createParallel(type: string, records: Record[], options: DmlOptions): Promise; /** @private */ _createMany(type: string, records: Record[], options: DmlOptions): Promise; /** * Synonym of Connection#create() */ insert: { , InputRecord extends Partial> = Partial>>(type: N, records: InputRecord[], options?: DmlOptions): Promise; , InputRecord_1 extends Partial> = Partial>>(type: N_1, record: InputRecord_1, options?: DmlOptions): Promise; , InputRecord_2 extends Partial> = Partial>>(type: N_2, records: InputRecord_2 | InputRecord_2[], options?: DmlOptions): Promise; }; /** * Update records */ update, UpdateRecord extends SObjectUpdateRecord = SObjectUpdateRecord>(type: N, records: UpdateRecord[], options?: DmlOptions): Promise; update, UpdateRecord extends SObjectUpdateRecord = SObjectUpdateRecord>(type: N, record: UpdateRecord, options?: DmlOptions): Promise; update, UpdateRecord extends SObjectUpdateRecord = SObjectUpdateRecord>(type: N, records: UpdateRecord | UpdateRecord[], options?: DmlOptions): Promise; /** @private */ _updateSingle(type: string, record: Record, options: DmlOptions): Promise; /** @private */ _updateParallel(type: string, records: Record[], options: DmlOptions): Promise; /** @private */ _updateMany(type: string, records: Record[], options: DmlOptions): Promise; /** * Upsert records */ upsert, InputRecord extends SObjectInputRecord = SObjectInputRecord, FieldNames extends SObjectFieldNames = SObjectFieldNames>(type: N, records: InputRecord[], extIdField: FieldNames, options?: DmlOptions): Promise; upsert, InputRecord extends SObjectInputRecord = SObjectInputRecord, FieldNames extends SObjectFieldNames = SObjectFieldNames>(type: N, record: InputRecord, extIdField: FieldNames, options?: DmlOptions): Promise; upsert, InputRecord extends SObjectInputRecord = SObjectInputRecord, FieldNames extends SObjectFieldNames = SObjectFieldNames>(type: N, records: InputRecord | InputRecord[], extIdField: FieldNames, options?: DmlOptions): Promise; /** @private */ _upsertMany(type: string, records: Record | Record[], extIdField: string, options?: DmlOptions): Promise; /** @private */ _upsertParallel(type: string, records: Record | Record[], extIdField: string, options?: DmlOptions): Promise; /** * Delete records */ destroy>(type: N, ids: string[], options?: DmlOptions): Promise; destroy>(type: N, id: string, options?: DmlOptions): Promise; destroy>(type: N, ids: string | string[], options?: DmlOptions): Promise; /** @private */ _destroySingle(type: string, id: string, options: DmlOptions): Promise; /** @private */ _destroyParallel(type: string, ids: string[], options: DmlOptions): Promise; /** @private */ _destroyMany(type: string, ids: string[], options: DmlOptions): Promise; /** * Synonym of Connection#destroy() */ delete: { >(type: N, ids: string[], options?: DmlOptions): Promise; >(type: N_1, id: string, options?: DmlOptions): Promise; >(type: N_2, ids: string | string[], options?: DmlOptions): Promise; }; /** * Synonym of Connection#destroy() */ del: { >(type: N, ids: string[], options?: DmlOptions): Promise; >(type: N_1, id: string, options?: DmlOptions): Promise; >(type: N_2, ids: string | string[], options?: DmlOptions): Promise; }; /** * Describe SObject metadata */ describe(type: string): Promise; /** * Describe global SObjects */ describeGlobal(): Promise; /** * Get SObject instance */ sobject>(type: string | N): SObject; /** * Get identity information of current user */ identity(options?: { headers?: { [name: string]: string; }; }): Promise; /** * List recently viewed records */ recent(type?: string | number, limit?: number): Promise; /** * Retrieve updated records */ updated(type: string, start: string | Date, end: string | Date): Promise; /** * Retrieve deleted records */ deleted(type: string, start: string | Date, end: string | Date): Promise; /** * Returns a list of all tabs */ tabs(): Promise; /** * Returns current system limit in the organization */ limits(): Promise; /** * Returns a theme info */ theme(): Promise; /** * Returns all registered global quick actions */ quickActions(): Promise; /** * Get reference for specified global quick action */ quickAction(actionName: string): QuickAction; /** * Module which manages process rules and approval processes */ process: Process; private isLightningInstance; } export default Connection;