Configuration for the Datapack Exporter instance.
Private ReadonlydataPrivatedatapacksPrivatedeferredPrivatedeferredReadonlydefinitionsConfiguration for the Datapack Exporter instance.
Private ReadonlyexpanderThe 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.
Number of parallel exports to run when exporting embedded objects. Set to 1 to disable parallelism and run all exports sequentially.
PrivateexportPrivategeneratedCurrent generated source key to Salesforce record id. Keys start as deterministic temporary values and are rewritten after the export graph is fully resolved.
Private ReadonlyloggerPrivatelookupPrivatematchingOwner 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.
PrivatematchingPrivate ReadonlymatchingMaximum depth to export objects, when the depth is reached the exporter will stop exporting the object and export a reference instead.
PrivatependingPrivate ReadonlysalesforcePrivatesourcePrivate ReadonlystandardStandard 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.
Static ReadonlyUNWRITABLE_PrivateaddPrivateaddAdd a matching reference when the referenced id is already part of the current export graph
(the root datapack or one of its embedded children); otherwise returns undefined.
PrivateaddPrivateaddPrivateasOptionalcontext: ExportContextPrivateasPrivateautoPrivatebuildPrivatebuildPrivatebuildAdd a lookup reference to the datapack, resolved lazily. When the referenced id is part of the current export graph a local matching reference is added immediately; otherwise a placeholder is stamped with the raw id and resolved in one batch by resolveDeferredLookups.
PrivatebuildPrivatebuildBuild 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.
PrivatebuildOptionaldeferLookups: booleanPrivatebuildPrivatecollectPrivatecollectPrivateconvertPrivateenqueueOptionalcontext: ExportContextPrivateevalPrivateevalPrivateevalPrivateexpandOptionalcontext: DatapackExportOptionsPrivateexportGenerate 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 embedded objects if needed by calling exportObject with the parent object id.
Optionalcontext: DatapackExportOptionsExports and expands and expands an object identified by its ID. Optionally, you can provide a scope to export the object with a specific configuration.
Optionalcontext: DatapackExportOptionsOptional export context.
A promise that resolves to the expanded datapack result.
PrivateexportPrivateexportPrivatefinalizeRun 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.
PrivatefinalizeFinalize 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).
PrivategetOptionalscope: stringPrivategetPrivategetPrivategetGets 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.
The object to get the value from, typically the datapack data object.
The property path to get the value from, can include dot notation and multiple options separated by | or ;.
PrivategetPrivategetOptionalscope: stringOptionaloptions: { allowGeneratedKey?: boolean; datapackType?: string; resolving?: Set<string> }PrivategetPrivategetResolve 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.
PrivategetPrivateignorePrivateinferOptionalscope: stringPrivateisPrivateisPrivatelookupPrivatelookupPrivatelookupOptionallimit: numberPrivatenormalizePrivateprefetchWarm 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.
PrivateprocessOptionaloptions: ExportProcessOptionsPrivateprocessPrivatereplacePrivateresolveOptionaloptions: ExportProcessOptionsPrivateresolvePrivateresolveResolve 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.
Optionaloptions: ExportProcessOptionsPrivateresolveResolve a lookup reference immediately by querying the record and building its full matching key object. Used while resolveDeferredLookups is draining the deferred lookups.
PrivatesetPrivatestripPrivatetryPrivateupdatePrivateupdateUpdates the references in the given datapack to matching references when the reference is also included as SObject datapack.
The datapack to update.
The
DatapackExporterclass 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).Example