import { DatapackDeploymentRecord } from './datapackDeploymentRecord'; import { VlocityDatapack } from '@vlocode/vlocity'; import { DatapackDeploymentEvent } from './datapackDeploymentEvent'; export declare enum DatapackDeploymentSpecFunctions { preprocess = 0, afterRecordConversion = 1, beforeDependencyResolution = 2, beforeDeploy = 3, afterDeploy = 4, beforeDeployRecord = 5, afterDeployRecord = 6 } export interface DeploymentSpecExecuteOptions { /** * Arguments passed to the spec function for execution */ args: [...TArgs]; /** * If true, errors will be ignored and the deployment will continue */ ignoreErrors?: boolean; /** * Determines the severity of spec function errors; if set to 'error' record will be marked as failed, * if set to 'warn' the record will be marked as successful but a warning will be logged. */ errorSeverity?: 'error' | 'warn'; } /** * A deployment spec contains Datapack specific logic and allows hooking into the deployment process to manipulate what get's deployed and execute post-deployment activation logic. * * Implementers can implement any of the specified functions in this interface, all functions are optional and only the implemented functions are executed. * * For many standard datapacks spec logic is implemented under the {@link ./deploymentSpecs} folder. */ export interface DatapackDeploymentSpec { /** * This function executes before a datapack is converted into a set of {@link DatapackDeploymentRecord}'s and allow changing the datapack * data, correct faulty field values that would otherwise cause errors during record conversion or remove certain fields that should not be deployed. * * This hook can also be used to override certain fields with autogenerated values; i.e. setting the element order and level field of OmniScript elements * @param datapack Datapack object */ preprocess?(datapack: VlocityDatapack): Promise | unknown; /** * This hook is almost identical to the {@link DatapackDeploymentSpec.preprocess} hook except that executes after a datapack is converted into 1 or more Salesforce records. * * The list of records past into this hook contains all the records generated for a single datapack; it is not possible to remove/drop any record but individual records can be manipulated, * * __Note__ At this point dependencies are not yet resolved * @param records */ afterRecordConversion?(records: ReadonlyArray): Promise | unknown; /** * @deprecated reserved for future use */ beforeDependencyResolution?(records: ReadonlyArray): Promise | unknown; /** * This hook is called before deploying the first record in a datapack, and is only called once very datapack in the deployment. * - Use this hook to execute and pre-deployment actions. This action is comparable with the `pre-step` job from the Vlocity tools library. * - Use the {@link DatapackDeploymentEvent.getRecords} function to get a list of records for a specific SObject type. * * The `type` argument passed to {@link DatapackDeploymentEvent.getRecords} should not be prefixed with a namespace. * I.e; to get a list of `OmniScript__c` records in the deployment use: * * ```js * DatapackDeploymentEvent.getRecords('OmniScript__c') * ``` * instead of * ```js * DatapackDeploymentEvent.getRecords('vlocity_cmt__OmniScript__c') * ``` * * The event object also exposes {@link DatapackDeploymentEvent.getDeployedRecords}; in the {@link beforeDeploy} this * will always return an empty array. * * @param event event object */ beforeDeploy?(event: DatapackDeploymentEvent): Promise | unknown; /** * This hook is called after all records of a datapack are deployed and will only be called once for every datapack in the deployment. * Use this hook to execute datapack activation logic. It is comparable to `post-step` in Vlocity tools * and should also execute any activation logic if required. * * Use the {@link DatapackDeploymentEvent.getDeployedRecords} function to get a list of deployed records for a specific SObject type. * This excludes any records that didn't get deployed. * * The `type` argument passed to {@link DatapackDeploymentEvent.getRecords} should not be prefixed with a namespace even if the object * you try to access has a namespace; see also {@link beforeDeploy}. * * @param event event object */ afterDeploy?(event: DatapackDeploymentEvent): Promise | unknown; /** * Executed just before the records are being deployed; the event contains a readonly array of records. At this stage values for the records can still be manipulated. * This hook point should only be used to run logic that depends on all dependencies on individual record level are resolved. * * Note: this runs on record level and use {@link beforeDeploy} to run datapack activation processes. * @param event Array of records that is going to be deployed */ beforeDeployRecord?(event: ReadonlyArray): Promise | unknown; /** * Executes after a group of records is deployed, at this stage it is not possible to change any field value anymore. * The hook point can be used to run post-deployment validations or post-deployment activation processes. * * Note: this runs on record level and use {@link afterDeploy} to run datapack activation processes. * @param event Array of records that got deployed; contains both the failed and success records. */ afterDeployRecord?(event: ReadonlyArray): Promise | unknown; /** * Executed before a record is retried; this hook point can be used to run any logic that should be executed * before a record is retried such as updating the record values ot changing the upsert fields. * * This hook point is called **before** dependency resolution. * * @param event Array of records that is going to be retried */ beforeRetryRecord?(event: ReadonlyArray): Promise | unknown; /** * Executed when a record fails to deploy; this hook point can be used to run any logic that should be executed * when a record fails to deploy such as updating the record values or changing the upsert fields. * @param event DatapackDeploymentRecord that failed to deploy * @param error Error that caused the record to fail; this can be a standard error or a {@link RecordError} object */ onRecordError?(event: ReadonlyArray): Promise | unknown; } /** * Groups multiple spec implementation together and executes them in sequence, specs can be added to the group and * only for the exposed methods on the specs the group will expose implementations. * * The order of execution of the specs is determine by the order in which they are added to the group. */ export declare class DatapackDeploymentSpecGroup implements DatapackDeploymentSpec { private specFns; /** * Initialize a group of specs that are called im the order that they are added to the group. * @param specs optional list of specs */ constructor(specs?: DatapackDeploymentSpec[]); /** * Adds a deployment spec to a group of specs; the spec can be partially implemented by in which case * only the implemented spec functions will be registered in the group. * @param spec Spec object to register in the spec group */ add(spec: Partial): void; private call; preprocess?(datapack: VlocityDatapack): Promise | unknown; afterRecordConversion?(records: ReadonlyArray): Promise | unknown; beforeDependencyResolution?(records: ReadonlyArray): Promise | unknown; beforeDeploy?(event: DatapackDeploymentEvent): Promise | unknown; afterDeploy?(event: DatapackDeploymentEvent): Promise | unknown; beforeDeployRecord?(event: ReadonlyArray): Promise | unknown; afterDeployRecord?(event: ReadonlyArray): Promise | unknown; } //# sourceMappingURL=datapackDeploymentSpec.d.ts.map