Salesforce Bulk API 2.0 client that supports both ingest (update, insert, upsert) operations as well as query operations.

Usage sample for querying account data:

const bulk = new BulkClient(connection); // Where connection is a Existing `SalesforceConnection` object
const job = await bulk.query('select Id, Name from Account');

for await (const record of job.records()) {
// Results are converted back to JSON objects for easy access
console.info(JSON.stringify(record, undefined, 4));
}

Usage sample for inserting account data:

const accounts = [
{ Name: 'CB Corp.' }
];

const bulk = new BulkClient(connection); // Where connection is a Existing `SalesforceConnection` object
const job = await bulk.insert('Account', accounts);

for (const record of await job.getSuccessfulRecords()) {
this.logger.info(JSON.stringify(record, undefined, 4));
}

for (const record of await job.getUnprocessedRecords()) {
this.logger.warn(JSON.stringify(record, undefined, 4));
}

for (const record of await job.getFailedRecords()) {
this.logger.error(JSON.stringify(record, undefined, 4));
}

Hierarchy

  • BulkClient

Constructors

Properties

apiVersion: string

Override the APi version used for the bulk requests. When set the apiVersion is preferred over the API version of the current connection version

ingestEndpoint: "/services/data/v{apiVersion}/jobs/ingest" = ...

Default ingest endpoint url format where apiVersion is replaced by the API version of the client or connection controlling which fields and objects are accessible through the bulk API

queryEndpoint: "/services/data/v{apiVersion}/jobs/query" = ...

Default ingest endpoint url format where apiVersion is replaced by the API version of the client or connection controlling which fields and objects are accessible through the bulk API

Methods

  • Creates a job representing a bulk operation and its associated data that is sent to Salesforce for asynchronous processing. Provide job data via an Upload Job Data request or as part of a multipart create job request.

    Type Parameters

    • TRecord extends object = any

    Parameters

    • request: IngestJobCreateRequest

      Bulk API request

    • Optional data: TRecord[]

      Data to upload

    Returns Promise<BulkIngestJob<TRecord>>

  • Creates a query job and

    Type Parameters

    • TRecord extends object = any

    Parameters

    • query: string

      SOQL query for the job

    • Optional options: {
          includeDeletedRecords?: boolean;
      }
      • Optional includeDeletedRecords?: boolean

    Returns Promise<BulkQueryJob<TRecord>>

    Query job that can be awaited

  • Update data using the Bulk API 2.0

    Type Parameters

    • TRecord extends object = any

    Parameters

    • objectType: string

      SObject Type

    • data: TRecord[]

      Data to update

    • externalIdFieldName: string = 'Id'

      optional external ID field to use for updates

    • Optional token: CancellationToken

      optional cancellation token

    Returns Promise<BulkIngestJob<TRecord>>

  • Update or insert data using the Bulk API 2.0

    Type Parameters

    • TRecord extends object = any

    Parameters

    • objectType: string

      SObject Type

    • data: TRecord[]

      Data to update

    • externalIdFieldName: string = 'Id'

      optional external ID field to use for upserts

    • Optional token: CancellationToken

      optional cancellation token

    Returns Promise<BulkIngestJob<TRecord>>