vlocode-project - v2.4.3
    Preparing search index...

    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 SalesforceService facade to lookup and 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).

    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');
    Index

    Constructors

    Properties

    datapacks: Map<string, ExportDatapack> = ...
    deferredEmbedded: DeferredEmbedded[] = []
    deferredLookups: Map<VlocityDatapackReference, DeferredLookup> = ...

    Configuration for the Datapack Exporter instance.

    exportChunkSize: number = 200

    The number of IDs to export in a single chunk when exporting multiple objects. This can be used to reduce the number of API calls when exporting large numbers of objects.

    exportParallelism: number = 5

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

    exportQueue: ExportRequest[] = []
    generatedSourceKeys: Map<string, string> = ...

    Current generated source key to Salesforce record id. Keys start as deterministic temporary values and are rewritten after the export graph is fully resolved.

    logger: Logger
    lookupCache: Map<string, Record<string, any> | null> = ...
    matchingKeyOwners: Map<string, string> = ...

    Owner record id per assigned matching key for O(1) uniqueness checks (reverse of matchingKeys). Keyed by matching key so re-computing the same record's key concurrently is idempotent while a second record resolving to the same key is detected as a collision.

    matchingKeys: Map<string, string> = ...
    matchingKeyService: MatchingKeyService
    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.

    pendingFinalize: { context: ExportContext; datapack: ExportDatapack }[] = []
    salesforce: SalesforceService
    sourceKeyById: Map<string, string> = ...
    standardObjects: Set<string> = ...

    Standard setup objects that are never exported as datapacks; lookups to these objects are kept as matching key references without tracking them as foreign keys. Their matching key fields are defined by the MatchingKeyService built-in defaults.

    UNWRITABLE_FIELDS: string[] = ...

    Methods

    • Build the matching key value for a record by joining the values of the matching key fields. Reference fields resolve to the matching key of the referenced record so source keys are deterministic and portable across orgs instead of depending on which records happened to have their matching key computed earlier in the export.

      Parameters

      • describe: DescribeSObjectResult
      • fields: readonly string[]
      • data: object
      • scope: string | undefined
      • resolving: Set<string>

      Returns Promise<string>

    • Parameters

      • record: Record<string, any>
      • scope: string | undefined
      • pending: Map<string, string | undefined>

      Returns Promise<void>

    • Parameters

      • datapack: ExportDatapack
      • record: Record<string, any>
      • context: ExportContext

      Returns Promise<void>

    • Run the deferred finalization for every datapack built since the last drain. Processed in reverse build order so embedded children are finalized before their parents, matching the original depth-first post-order now that embedded objects are built breadth-first.

      Returns Promise<void>

    • Finalize source keys for generated records. Only embedded records can be generated — top-level datapacks require a matching key (enforced in buildDatapack). Embedded generated records are only referenced from within their own datapack: referenced ones keep their auto-generated source key, unreferenced ones drop it entirely (the deploy side synthesizes one).

      Returns void

    • Gets a value from the datapack based on the property path. The property path can include dot notation for nested properties and can also include multiple options separated by | or ; to try multiple paths.

      If a node in the path is an array each element of the array will be traversed and the results will be returned as an array. For example, if the path is Contacts.Name and Contacts is an array of contact records, the result will be an array of names for each contact.

      Parameters

      • obj: any

        The object to get the value from, typically the datapack data object.

      • prop: string

        The property path to get the value from, can include dot notation and multiple options separated by | or ;.

      Returns any

    • Parameters

      • describe: DescribeSObjectResult
      • data: object
      • Optionalscope: string
      • Optionaloptions: { allowGeneratedKey?: boolean; datapackType?: string; resolving?: Set<string> }

      Returns Promise<string>

    • Resolve the matching key of a record referenced from a matching key field. Returns undefined when the referenced record cannot be found, resolves to an auto-generated key or is part of a circular reference chain; the caller falls back to the raw record id in those cases.

      Parameters

      • id: string
      • scope: string | undefined
      • resolving: Set<string>

      Returns Promise<string | undefined>

    • Warm the lookup and matching key caches for records referenced from matching key fields. Reference fields resolve to the referenced record's matching key (see buildMatchingKey); without warming, every cache miss while building a chunk fans out into a single-record query. Each level of uncached referenced records is fetched in one batched lookup instead, following the reference chain until no new records are discovered.

      Parameters

      • items: { record: Record<string, any>; scope?: string }[]

      Returns Promise<void>

    • Resolve all deferred embedded objects. Filters for the same object type are batched into a single query and the results grouped back to each parent datapack. Building the children queues their own embedded objects, which are drained as the next wave until no deferred lookups remain.

      Parameters

      Returns Promise<void>

    • 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