import { RecordError } from '@vlocode/salesforce'; import { VlocityDatapackLookupReference, VlocityDatapackMatchingReference, VlocityDatapackReference } from '@vlocode/vlocity'; import { DatapackDependencyResolver } from './datapackDependencyResolver'; export declare enum DeploymentStatus { Pending = 0, InProgress = 1, Retry = 2, Deployed = 3, Failed = 4, Skipped = 5 } export declare enum DeploymentAction { None = 0, Update = 1, Insert = 2, Skip = 3 } export type DeployedDatapackDeploymentRecord = DatapackDeploymentRecord & { recordId: string; }; export declare class DatapackDeploymentRecord { readonly datapackType: string; readonly sobjectType: string; readonly sourceKey: string; readonly datapackKey: string; upsertFields: string[] | undefined; readonly values: object; private readonly _warnings; private readonly _dependencies; private readonly _unresolvedDependencies; private readonly _deployTimer; private _status; private _statusDetail?; private _error?; private _existingId?; private _datapackAction; /** * True if looking up existing records to update is skipped causing the deployment * to always create a new object using insert */ skipLookup: boolean; /** * Number of times the record has been retried for deployment. * This is used to determine if the record should be skipped after a certain number of retries. */ retryCount: number; /** * Namespace normalized SObjectName; contains the SObjectType without the namespace prefix. */ readonly normalizedSObjectType: string; get status(): DeploymentStatus; get isDeployed(): boolean; /** * Gets a value indicating whether the deployment is pending or in retry status. * @returns {boolean} True if the deployment is pending or in retry status, otherwise false. */ get isPending(): boolean; get isPendingRetry(): boolean; get isStarted(): boolean; get isFailed(): boolean; get isUpdate(): boolean; get isInsert(): boolean; get isSkipped(): boolean; /** * Checks if the deployment record failed due to a cascade failure. A cascade failure occurs when a record * cannot be deployed because it is dependent on another record that failed to deploy. * @returns {boolean} True if the deployment record represents a cascade failure, false otherwise. */ get isCascadeFailure(): boolean; get hasWarnings(): boolean; /** * Gets the record ID of the deployed record if the record is deployed. * Otherwise the ID of the record that will be updated. * For new records this will be undefined. * * To change the record ID of a record use the `setAction` method with the `DeploymentAction.Update` action. */ get recordId(): string | undefined; /** * When the record is not deployed this property contains the last reported state detail. */ get statusMessage(): string | undefined; /** * Gets the error message associated with the deployment record. * @returns The error message, or undefined if there is no error. */ get errorMessage(): string | undefined; get errorCode(): string | undefined; /** * Gets the error associated with the deployment record. * @returns The error object or undefined if there is no error. */ get error(): Error | RecordError | undefined; get warnings(): ReadonlyArray; get deployTime(): number; get hasUnresolvedDependencies(): boolean; get action(): DeploymentAction; constructor(datapackType: string, sobjectType: string, sourceKey: string, datapackKey: string, upsertFields?: string[] | undefined, values?: object); static fromValues(sobjectType: string, values: object, options?: { upsertFields?: string[]; recordKey?: string; }): DatapackDeploymentRecord; /** * Namespace and case normalized check to determine if the current datapack is of the specified type. * @param sobjectType SObject type with or without namespace prefix * @returns */ isSObjectOfType(sobjectType: string): boolean; /** * Get a value in the underlying record data * @param field field name * @returns value of the field */ value(field: string): any; /** * Set the value in the underlying record data. To remove a field from the record pass the value as `undefined` * @param field field name * @param value value to set or `undefined` to remove the field * @returns true if set or false if not set */ value(field: string, value: unknown | undefined): boolean; updateStatus(status: DeploymentStatus, detail?: string | Error | RecordError): void; retry({ incrementCounter }: { incrementCounter?: boolean | undefined; }): void; setFailed(error: string | Error | RecordError): void; setError(error: string | Error | RecordError): void; addWarning(message: string): void; setAction(action: DeploymentAction): void; setAction(action: DeploymentAction.Update, updateId: string): void; setAction(action: DeploymentAction.Skip, updateId?: string): void; hasGlobalKey(): boolean; getGlobalKey(): any; private getGlobalKeyField; addLookup(field: string, dependency: VlocityDatapackReference): void; getLookup(field: string): VlocityDatapackLookupReference | undefined; addDependency(dependency: VlocityDatapackReference | DatapackDeploymentRecord): any; /** * Add a lookup dependency to this record based on only a source key string. * @param sourceKey Dependencies source key in the following format: `/` */ addLookupDependency(sourceKey: string): void; /** * Add a lookup dependency to this record based on a SObject type and the source key string. * @param sobjectType SObject type of the record on which this record is dependent. Replace vlocity namespace with the namespace placeholder. * @param sourceKey String that describes the records source key; should be prefixed with the record sobject type otherwise it is automatically prepended */ addLookupDependency(sobjectType: string, sourceKey: string): void; /** * Add a lookup dependency to this record is based on a SObject type and the matching key values of the record. * @param sobjectType SObject type of the record on which this record is dependent. Replace vlocity namespace with the namespace placeholder. * @param matchingKeyValues Object describing the matching key values that are concatenated into the source key * so the source key matches the following format: `/` */ addLookupDependency(sobjectType: string, matchingKeyValues: Record): void; /** * Validate dependency integrity by checking if mandator fields are set * @param dependency Dependency to check */ private validateRecordDependency; /** * Checks if the specified record is a dependency for this record and returns the dependency data and lookup field on this record * @param record Record to check * @returns The dependency info and lookup field as defined for this record */ isDependentOn(record: DatapackDeploymentRecord): { field: string; dependency: VlocityDatapackReference; } | undefined; getDependencySourceKeys(): Iterable; /** * Get all dependencies on which this record depends; returns resolved and unresolved dependencies * @returns Array with all dependencies */ getDependencies(): VlocityDatapackReference[]; /** * Get embedded dependencies that are **not** resolved through lookup but instead are provided as part of the datapack. * These dependencies of datapack type **VlocityMatchingKeyObject**. * Does not included dependencies that are added through the {@link addDependency} function as these are not linked through a field. * @returns Array with dependencies */ getMatchingDependencies(): { field: string; dependency: VlocityDatapackReference; }[]; /** * Get dependencies that are resolved through a lookup and **not** provided as part of the datapack. * These dependencies of datapack type **VlocityLookupMatchingKey** * @returns Array with dependencies */ getLookupDependencies(): { field: string; dependency: VlocityDatapackReference; }[]; /** * Retrieves the unresolved dependencies of the datapack deployment record. * @param type - The type of dependencies to retrieve. Can be 'lookup', 'matching', or 'all'. Default is 'all'. * @returns An array of unresolved dependencies. */ getUnresolvedDependencies(): { field: string; dependency: VlocityDatapackReference; }[]; getUnresolvedDependencies(type: 'all'): { field: string; dependency: VlocityDatapackReference; }[]; getUnresolvedDependencies(type: 'lookup'): { field: string; dependency: VlocityDatapackLookupReference; }[]; getUnresolvedDependencies(type: 'matching'): { field: string; dependency: VlocityDatapackMatchingReference; }[]; /** * Check if a field that is dependent on another record is resolved. * @param field name of the field * @returns */ isResolved(field: string): boolean; /** * Resolves the dependencies of the datapack deployment record. * Rethrows any error that occurs during dependency resolution from the resolver. * @param resolver - The datapack dependency resolver. * @returns A promise that resolves to a boolean indicating whether all dependencies have been resolved. */ resolveDependencies(resolver: DatapackDependencyResolver): Promise; /** * Check if this record type matches the specified SObject type filter. Matches are always case * insensitive and will be matched against the full and normalized SObject (without namespace prefix) type. * Matching will first be done against the normal sobject type and only after that against the normalized sobject type. * @param filter SObjectType as string or RegEx * @returns `true` if the record SObject type matches the filter otherwise `false` */ isMatch(filter: string | RegExp): boolean; } //# sourceMappingURL=datapackDeploymentRecord.d.ts.map