import { DescribeSObjectResult, SalesforceLookupService, SalesforceSchemaService } from "@vlocode/salesforce"; import { VlocityDatapackReference, VlocityDatapackSObject, VlocityMatchingKeyService } from "@vlocode/vlocity"; import { Logger } from "@vlocode/core"; import { DatapackExpandResult, DatapackExpander } from "./datapackExpander"; import { DatapackExportDefinitionStore } from "./exportDefinitionStore"; export type ObjectRef = string | { objectType: string; scope?: string; }; interface ExportDatapack { readonly id: string; readonly objectType: string; readonly scope?: string; readonly schema: DescribeSObjectResult; data: VlocityDatapackSObject; references: Record; children: Record; /** * Map of foreign SourceKeys that this datapack depends; * keys are the SourceKeys and values are the Id's of the foreign objects. */ foreignKeys: Record; /** * Map of SourceKeys that are provided by this datapack and any embedded child datapacks. * The keys are the SourceKeys and the values are the Id's of the objects. */ sourceKeys: Record; parent?: ExportDatapack; } interface ExportContext { scope?: string; parent?: ExportDatapack; } interface ExportResult { parentKeys: { key: string; id: string; }[]; datapack: VlocityDatapackSObject; objectType: string; sourceKey: string; } /** * Options for exporting datapacks. */ type DatapackExportOptions = Omit; /** * 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 {@link SalesforceLookupService} to lookup Salesforce objects and the {@link SalesforceSchemaService} * to describe Salesforce objects. * * Definitions for the export and expand process are stored in the {@link DatapackExportDefinitionStore} which is a singleton and can be accessed * from the container using `contaioner.get(DatapackExportDefinitionStore)`. * * @usage * ```typescript * 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'); * ``` */ export declare class DatapackExporter { /** * Configuration for the Datapack Exporter instance. */ readonly definitions: DatapackExportDefinitionStore; private readonly expander; private readonly lookupService; private readonly schema; private readonly vlocityMatchingKeys; private readonly logger; private readonly unwriteableFields; private readonly autoMatchingKeyFields; private datapacks; private matchingKeys; /** * Maximum depth to export objects, when the depth is reached the * exporter will stop exporting the object and export a reference instead. */ maxExportDepth: number; /** * Number of parallel exports to run when exporting related objects. Set to 1 to disable parallelism and run all exports sequentially. */ exportParallelism: number; constructor( /** * Configuration for the Datapack Exporter instance. */ definitions: DatapackExportDefinitionStore, expander: DatapackExpander, lookupService: SalesforceLookupService, schema: SalesforceSchemaService, vlocityMatchingKeys: VlocityMatchingKeyService, logger: Logger); /** * 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. * @param id The ID of the expandable object to export and expand. * @param context Optional export context. * @returns A promise that resolves to the expanded datapack result. */ exportObjectAndExpand(id: string, context?: DatapackExportOptions): Promise; /** * 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 {@link exportObject} with the parent object id. * @param id Id of the object to export */ exportObject(id: string, context?: DatapackExportOptions): Promise; private asExportResult; private buildDatapack; private getExportPath; private exportObjectFields; private exportRelatedObjects; private lookupRelatedRecords; private processFieldValues; /** * Updates the references in the given datapack to matching references when the * reference is also included as SObject datapack. * * @param datapack - The datapack to update. */ private updateLookupReferences; private convertToMatchingObject; private updateForeignKeys; private getDatapackRoot; private buildInternalLookup; private buildSObject; private buildLookup; private addReference; private addSourceKey; private addForeignKey; private evalProcessor; private evalFilter; private buildMatchingKeyObject; private getMatchingKey; private getAutoMatchingKey; private ignoreField; private tryParseAsJson; private getMatchingFields; private validateFieldList; private guessMatchingFields; } export {}; //# sourceMappingURL=datapackExporter.d.ts.map