import { Logger } from '@vlocode/core'; import { SalesforceConnectionProvider, SalesforceSchemaService, SalesforceService } from '@vlocode/salesforce'; import { AsyncEventEmitter, CancellationToken } from '@vlocode/util'; import { DatapackLookupService } from './datapackLookupService'; import { DependencyResolutionRequest, DependencyResolutionResult } from './datapackDependencyResolver'; import { DatapackDeploymentOptions } from './datapackDeploymentOptions'; import { DatapackDeploymentRecord, DeploymentStatus } from './datapackDeploymentRecord'; import { DatapackDeploymentRecordGroup } from './datapackDeploymentRecordGroup'; import { DatapackDeploymentError as Error } from './datapackDeploymentError'; import { VlocityDatapackReference } from '@vlocode/vlocity'; import { DatapackDeploymentStatus } from './datapackDeploymentStatus'; export interface DatapackDeploymentEvents { beforeDeployRecord: Iterable; afterDeployRecord: Iterable; beforeDeployGroup: Iterable; afterDeployGroup: Iterable; beforeRetryRecord: Iterable; beforeResolveDependencies: Iterable; recordError: DatapackDeploymentRecord; cancel: DatapackDeployment; progress: DatapackDeploymentProgress; } export interface DatapackDeploymentRecordMessage { record: DatapackDeploymentRecord; type: 'error' | 'warn' | 'info'; code?: string; message: string; } export interface DatapackDeploymentProgress { readonly progress: number; readonly total: number; } declare const datapackDeploymentDefaultOptions: Required; /** * A datapack deployment task/job */ export declare class DatapackDeployment extends AsyncEventEmitter { private readonly connectionProvider; private readonly lookupService; private readonly schemaService; private readonly salesforceService; private readonly logger; readonly options: Readonly; private readonly errors; private readonly deployed; private readonly records; private readonly recordGroups; private readonly recordGroupsErrors; private readonly orgDependencyResolver; private isStarted; private timer; private cancelToken?; get deployedRecordCount(): number; get pendingRecordCount(): number; get skippedRecordCount(): number; get failedRecordCount(): number; get failedRecords(): ReadonlyArray; get deployedRecords(): ReadonlyArray; get hasErrors(): boolean; get hasWarnings(): boolean; /** * Gets the total record count in this deployment. Each record is a part of a datapack. * @returns The total number of records. */ get totalRecordCount(): number; /** * Gets the total number of datapacks in this deployment. Each datapack can contain multiple records. * Use {@link totalRecordCount} to get the total number of records. * @returns The total number of datapacks. */ get totalDatapackCount(): number; get isCancelled(): boolean; constructor(options: DatapackDeploymentOptions | undefined, connectionProvider: SalesforceConnectionProvider, lookupService: DatapackLookupService, schemaService: SalesforceSchemaService, salesforceService: SalesforceService, logger: Logger); add(...records: DatapackDeploymentRecord[]): this; /** * Deploy deployment records part of this deployment task to Salesforce. * @param cancelToken An optional cancellation token to stop the deployment */ start(cancelToken?: CancellationToken): Promise; private writeDeploymentSummaryToLog; /** * Add a Datapack level error to the deployment. * This is used to add errors that are not related to a specific record but to a whole datapack, or * to add errors that are related to a datapack for which the records could not added to the deployment. * @param datapackKey Group key of the datapack to which the error belongs * @param error Error to add to the deployment */ addError(datapackKey: string, error: Error | string): void; /** * Retrieves all datapack deployment records as {@link DatapackDeploymentRecordGroup} objects. * The return groups can be manipulated when the deployment hasn't started yet. * @returns An array of DatapackDeploymentRecordGroup objects. */ getStatus(): DatapackDeploymentStatus; /** * Retrieves all datapack deployment records as {@link DatapackDeploymentRecordGroup} objects. * The return groups can be manipulated when the deployment hasn't started yet. * @returns An array of DatapackDeploymentRecordGroup objects. */ getDatapacks(): Array; /** * Returns an array of keys from the datapacks in this deployment. * The keys returned by this method can be used to retrieve deployment records using {@link getRecords}. * * @returns {Array} An array containing all datapack keys. */ datapackKeys(): Array; /** * Retrieves the deployment messages for the datapack deployment. * * @param options - An optional object that specifies additional options for retrieving the messages. * @param options.includeCascadeFailures - A boolean indicating whether to include cascade failures in the messages. Default is false. * * @returns An array of `DatapackDeploymentRecordMessage` objects representing the deployment messages. */ getMessages(options?: { includeCascadeFailures?: boolean; }): Array; getMessagesByDatapack(options?: { includeCascadeFailures?: boolean; }): { [datapackKey: string]: Array; }; private formatDeployError; getFailedRecords(datapackKey: string): Array; /** * Gets the deployment status of a record by source key * @param sourceKey Record source key to get the deployment status for */ getRecordStatus(sourceKey: string): DeploymentStatus | undefined; /** * Gets the deployment status of a Datapack by it's source key. * - Returns the summary status of all records in the datapack. * - Returns `undefined` if the datapack is not part of the deployment. * @param datapackKey Datapack key to get the deployment status for */ getDatapackStatus(datapackKey: string): DeploymentStatus | undefined; /** * Get all records that can be deployed; i.e records that do not have any pending dependencies. */ private getDeployableRecords; /** * Check if a record has pending dependencies that are not yet deployed as part of the current deployment * @param record */ private hasPendingDependencies; private validateRecordDependencies; /** * Checks if there is a circular dependency between two datapacks. * @param datapackKeyA - The key of the first datapack. * @param datapackKeyB - The key of the second datapack. * @returns True if there is a circular dependency, false otherwise. */ private isCircularDatapackDependency; private hasCircularDependencies; /** * Resolve a dependency either based on the records we are deploying -or- pass it on to the lookup resolver. * @param dependency Dependency */ resolveDependency(dependency: VlocityDatapackReference, datapackRecord: DatapackDeploymentRecord): Promise; /** * Resolve a dependency either based on the records we are deploying -or- pass it on to the lookup resolver. * @param dependency Dependency */ resolveDependencies(dependencies: DependencyResolutionRequest[]): Promise; private resolveDependencyFromDeployment; /** * Check if a datapack has any pending records * @param datapackKey Key of the datapack */ hasPendingRecords(datapackKey: string): boolean; /** * Get all records related a specific datapack, includes main record and any child records originating from the same datapack. * @param datapackKey Key of the datapack */ getRecords(datapackKey: string): Array; private resolveExistingIds; /** * Compared the to be deployed records to the records in the org * @param records Records to deploy * @param cancelToken Cancellation token to signal the process if a cancellation is initiated */ private createDeploymentBatch; /** * Compared the to be deployed records to the records in the org * @param records Records * @param cancelToken Cancellation token to signal the process if a cancellation is initiated */ private getRecordSyncStatus; private resolveDatapackDependencies; private deployRecords; private reportWarning; private handleError; private isRetryable; private handleProgressReport; /** * Purge all records that depend on any of the records just deployed through their matching record key. Records that depend * on other records from within the same Datapack have a relation to the parent datapack through Matching source key. * This function will delete all child records that have a relationship parent record through a Matching source key * * _**Note** this function will only delete records for parents that have been update and are deployed successfully_ * @param records Records */ private purgeMatchingDependentRecords; private purgeDependentRecords; } export {}; //# sourceMappingURL=datapackDeployment.d.ts.map