/** * State object for Salesforce Bulk API 2.0 operations * @typedef {Object} Bulk2QueryState * @property {Array} data - The processed records or query results from the Bulk API operation * @property {Array} references - Array of previous state data objects used in the job * @private */ /** * @typedef {Object} Bulk2LoadState - State object for bulk insert operations * @property {Object} data - The processed records or results from the bulk insert operation * @property {Object} data.successfulResults - Array of successful results * @property {Object} data.failedResults - Array of failed results * @property {Object} data.unprocessedRecords - Array of unprocessed records * @property {Array} references - Array of previous state data objects used in the job * @private */ /** * Options for configuring Salesforce Bulk API 2.0 queries * @typedef {Object} QueryOptions * @public * @property {boolean} [scanAll=false] - Whether to scan through all records including deleted and archived ones * @property {number} [pollInterval=1000] - Polling interval in milliseconds. Default: 1000 (1 second) * @property {number} [pollTimeout=30000] - Polling timeout in milliseconds. Default: 30000 (30 seconds) */ /** * @typedef {Object} Bulk2LoadOptions - Bulk insert options * @property {number} [pollInterval=1000] - Polling interval in milliseconds. Default: 1000 (1 second) * @property {number} [pollTimeout=30000] - Polling timeout in milliseconds. Default: 30000 (30 seconds) * @property {boolean} [failOnError=true] - Fail the operation on error * @public */ /** * Executes a bulk query using Salesforce Bulk API 2.0 * @public * @example Bulk query records * bulk2.query('SELECT Id, Name FROM Account'); * @example Bulk query with `scanAll` enabled * bulk2.query('SELECT Id, Name FROM Account', { scanAll: true }); * @example Query with custom options * bulk2.query( * 'SELECT Id, Name FROM Account', * { * scanAll: true, * pollInterval: 1000, * pollTimeout: 3000, * } * ); * @function * @param {string} query - SOQL query string to execute * @param {QueryOptions} options - Query options * @state {Bulk2QueryState} * @returns {Operation} */ export function query(query: string, options: QueryOptions): Operation; /** * Bulk inserts records using Salesforce Bulk API 2.0 * @public * @example Bulk insert continue on error * bulk2.insert('Account', [{ Name: 'Coco' }, { Name: 'Melon' }], { * failOnError: false, * }); * @example Bulk insert with custom polling options * bulk2.insert('Account', [{ Name: 'Coco' }, { Name: 'Melon' }], { * pollInterval: 1000, * pollTimeout: 3000, * }); * @function * @param {string} sObject - The Salesforce object type * @param {Array} records - Array of records to insert * @param {Bulk2LoadOptions} [options] - Bulk insert options * @state {Bulk2LoadState} * @returns {Operation} */ export function insert(sObject: string, records: any[], options?: Bulk2LoadOptions): Operation; /** * Bulk updates records using Salesforce Bulk API 2.0 * @public * @example Bulk update records * bulk2.update("Account", [ * { Id: "0010500000fxbcuAAA", Name: "Updated Account #1" }, * { Id: "0010500000fxbcvAAA", Name: "Updated Account #2" }, * ]); * @example Bulk update records continue on error * bulk2.update( * "Account", * [ * { Id: "0010500000fxbcuAAA", Name: "Updated Account #1" }, * { Id: "0010500000fxbcvAAA", Name: "Updated Account #2" }, * ], * { * failOnError: false, * } * ); * @function * @param {string} sObject - The Salesforce object type * @param {Array} records - Array of records to update * @param {Bulk2LoadOptions} [options] - Bulk update options * @state {Bulk2LoadState} * @returns {Operation} */ export function update(sObject: string, records: any[], options?: Bulk2LoadOptions): Operation; /** * Bulk upserts records using Salesforce Bulk API 2.0 * @public * @example Bulk upsert records * bulk2.upsert("UpsertTable__c", "ExtId__c", [ * { Name: "Record #1", ExtId__c : 'ID-0000001' }, * { Name: "Record #2", ExtId__c : 'ID-0000002' }, * ]); * @example Bulk upsert records with custom polling options * bulk2.upsert( * "UpsertTable__c", * "ExtId__c", * [ * { Name: "Record #1", ExtId__c : 'ID-0000001' }, * { Name: "Record #2", ExtId__c : 'ID-0000002' }, * ], * { * pollInterval: 1000, * pollTimeout: 3000, * } * ); * @example Bulk upsert records continue on error * bulk2.upsert( * "UpsertTable__c", * "ExtId__c", * [ * { Name: "Record #1", ExtId__c : 'ID-0000001' }, * { Name: "Record #2", ExtId__c : 'ID-0000002' }, * ], * { * failOnError: false, * } * ); * @function * @param {string} sObject - The Salesforce object type * @param {string} externalIdFieldName - External ID field name for upsert matching * @param {Array} records - Array of records to upsert * @param {Bulk2LoadOptions} [options] - Bulk upsert options * @state {Bulk2LoadState} * @returns {Operation} */ export function upsert(sObject: string, externalIdFieldName: string, records: any[], options?: Bulk2LoadOptions): Operation; /** * Bulk deletes records using Salesforce Bulk API 2.0 * @public * @example Bulk delete records * bulk2.destroy("Account", [ * "0010500000fxbcuAAA", * "0010500000fxbcvAAA", * ]); * @example Bulk delete records with custom polling options * bulk2.destroy( * "Account", * [ * "0010500000fxbcuAAA", * "0010500000fxbcvAAA", * ], * { * pollInterval: 1000, * pollTimeout: 3000, * } * ); * @example Bulk delete records continue on error * bulk2.destroy( * "Account", * [ * "0010500000fxbcuAAA", * "0010500000fxbcvAAA", * ], * { * failOnError: false, * } * ); * @function * @param {string} sObject - The Salesforce object type * @param {Array} records - Array of records to delete * @param {Bulk2LoadOptions} [options] - Bulk delete options * @state {Bulk2LoadState} * @returns {Operation} */ export function destroy(sObject: string, records: any[], options?: Bulk2LoadOptions): Operation; /** * State object for Salesforce Bulk API 2.0 operations */ export type Bulk2QueryState = { /** * - The processed records or query results from the Bulk API operation */ data: any[]; /** * - Array of previous state data objects used in the job */ references: any[]; }; /** * - State object for bulk insert operations */ export type Bulk2LoadState = { /** * - The processed records or results from the bulk insert operation */ data: { successfulResults: any; failedResults: any; unprocessedRecords: any; }; /** * - Array of previous state data objects used in the job */ references: any[]; }; /** * Options for configuring Salesforce Bulk API 2.0 queries */ export type QueryOptions = any; /** * - Bulk insert options */ export type Bulk2LoadOptions = { /** * - Polling interval in milliseconds. Default: 1000 (1 second) */ pollInterval?: number; /** * - Polling timeout in milliseconds. Default: 30000 (30 seconds) */ pollTimeout?: number; /** * - Fail the operation on error */ failOnError?: boolean; };