The DatapackExporter class is responsible for exporting and expanding Salesforce objects into datapacks. It provides methods for exporting objects, expanding objects, and generating datapack exports.

The exporter uses the SalesforceLookupService to lookup Salesforce objects and the SalesforceSchemaService to describe Salesforce objects.

Definitions for the export and expand process are stored in the DatapackExportDefinitionStore which is a singleton and can be accessed from the container using contaioner.get(DatapackExportDefinitionStore).

Usage

const exporter = container.get(DatapackExporter);
// Export a datapack into an object, this object can be written to a JSON file as is
const datapack = await exporter.exportObject('001000000000000');
// Expand the object into multiple files which can be written to the file system or a zip archive
const expanded = await exporter.exportExpandObject('001000000000000');

Hierarchy

  • DatapackExporter

Constructors

Properties

autoMatchingKeyFields: string[] = ...
datapacks: Record<string, ExportDatapack> = {}

Configuration for the Datapack Exporter instance.

exportParallelism: number = 5

Number of parallel exports to run when exporting related objects. Set to 1 to disable parallelism and run all exports sequentially.

logger: Logger
matchingKeys: Record<string, string> = {}
maxExportDepth: number = 10

Maximum depth to export objects, when the depth is reached the exporter will stop exporting the object and export a reference instead.

unwriteableFields: string[] = ...
vlocityMatchingKeys: VlocityMatchingKeyService

Methods

  • Generate a datapack export for an object by the object id. Returns the datapack object in conslidated form without expanding. Als returns the parent keys of the datapack including the id's of the parent objects to allow exporting related objects if needed by calling exportObject with the parent object id.

    Parameters

    • id: string

      Id of the object to export

    • Optional context: DatapackExportOptions

    Returns Promise<ExportResult>

  • Exports and expands and expands an object identified by its ID. Optionally, you can provide a scope to export the object with a specific configuration.

    Parameters

    • id: string

      The ID of the expandable object to export and expand.

    • Optional context: DatapackExportOptions

      Optional export context.

    Returns Promise<DatapackExpandResult>

    A promise that resolves to the expanded datapack result.

  • Updates the references in the given datapack to matching references when the reference is also included as SObject datapack.

    Parameters

    • datapack: ExportDatapack

      The datapack to update.

    Returns void