import type { ComponentMetadataConfig } from '../interpreter/types'; import type { Basic, Nested, NestedObject, Primitive } from '../types'; import type { PropertyInfo } from '../globals'; import type { C11nEnv } from '../interpreter/c11n-env'; /** * helper functions */ declare class Utils { /** * Merges all source properties to target and returns the target object * @param source object to be merged * @param target target object */ static mergeDeep(source: any, target: any): any; /** * Checks if refPath is a direct property of sourceObject. * @param sourceObject The object to query * @param refPath The path to check. * @returns Returns true if path exists, else false. */ static hasIn(sourceObject: any, refPath: string | string[]): boolean; static getIn(sourceObject: any, refPath: any, defaultValue?: any): any; static setIn(sourceObject: any, refPath: any, objectToSet: any): any; static deleteIn(sourceObject: any, refPath: any): boolean; /** * Checks wether obj is empty or not. * @param obj input obj */ static isObjectEmpty(obj: object): boolean; /** * Checks if value is an empty object, collection, map, or set. * @param value input value */ static isEmpty(value: any): boolean; /** * Clones passed object. * @param obj object to clone */ static deepClone(obj?: {}): any; /** * Copies the source object to target object * it is a shallow copy. * @param source source to copy * @param target target */ static copy(source: { [key: string]: any; }, target: { [key: string]: any; }): void; /** * Checks wether reference is valid property * reference or not. * @param ref property string to check */ static isPropertyRef(ref: string): boolean; /** * Checks whether when is configured in the component or not. * @param config component metadata */ static isWhenExist(config: NonNullable): boolean; /** * Helper function to get the When name if when is configured on the component. If when is not configured it will return empty string. * @param config * @returns all the whens configured on the field. */ static getWhenNames(config?: ComponentMetadataConfig): string[]; /** * Helper function to check whether expression is configured * in the component or not. * @param config component metadata */ static isExpressionExist(config: NonNullable): boolean; static buildDataObject(dataObject: { [key: string]: any; }, context: string): { [key: string]: any; }; /** * Builds form submit object. Object will be * in json format. * @param propRef property reference * @param resultObj json object * @param value value to update to property. */ static buildObject: (propRef: string, resultObj: any, value: any) => void; /** * get hashed crc32 string * @param value string to be hashed * @returns hashed string */ static getHashedString(value: string): string; /** * extract the property name * @param value string from which name to be extracted * @returns returns the property name without @P * @example Example for getPropertyName(value) * getPropertyName("@P .prop1") * this will return "prop1" */ static getPropertyName(value: string): string; /** * extract the property name * @param dependency string/object from which name to be extracted * @returns returns the property name * @example Example for getPropertyNameFromDependency(value) * getPropertyNameFromDependency({ mode: 'multiRecord', propertyName: 'caseInfo.content.PartnerOffering.ProductAreas[0].PegaProdMulti' }) * this will return "caseInfo.content.PartnerOffering.ProductAreas[0].PegaProdMulti" */ static getPropertyNameFromDependency(dependency: string | { [key: string]: any; }): string; /** * This method will check whether the supplied jsonstring is valid Json after parsed. * @param jsonstring - string which results a Valid JSON * @returns this will return false if the supplied string is not valid json string else return * the parsed JSON Object */ static isValidJson(jsonstring: string): boolean | object; /** * Compares 2 objects for equality. * It does deep comparison. * @param object1 object 1 to be compared * @param object2 object 2 compare against */ static isEqual(object1: object, object2: object): boolean; /** * Check if object1 contains object2. * It does deep comparison. * @param object1 object 1 contains object2 * @param object2 object 2 object that needs to be checked */ static isContains(object1: { [key: string]: any; }, object2: { [key: string]: any; }): boolean; /** * Removes property from existingDependentPropertiesSet. * It does deep comparison. * @param existingDependentPropertiesSet set containing existing properties * @param propertyName property name that needs to be removed */ static removeExistingDependentProperty(existingDependentPropertiesSet: PropertyInfo[], propertyName: string): void; static getFullPropertyReference(splitPropertyArray: string[]): string; /** * Iterates over the object and calls the callback on reaching * to the leaf of object with two parameters - path and value, * where path value will be array such as ['root', 'branch', 'leaf'] and value can be of any type * @function iterateLeafNodes * @param sourceObj object to iterate * @param callback function which will be executed on reaching leaf node * @example Example for iterateLeafNodes * const data = {Name: 'James Bond', department: {id: '007', type: 'agent'}}; * iterateLeafNodes(data, (path, value) => { if (path.pop() === 'Name' && value === 'James Bond') { sendOnMission(value); } }); */ static iterateLeafNodes(sourceObj: NestedObject, callback: (path: (number | string)[], value: Nested | Basic) => void): void; /** * Resolves string boolean values of config object properties to boolean values * @param configObject config props object of a component * @private * @returns configObject of a component */ static resolveStringBooleans(configObject: { [key: string]: unknown; }): { [key: string]: unknown; }; /** * API to generate UUID * @returns a unique Id */ static generateUniqueID(): string; static unflatten(data: object): NestedObject; static flatten(data: Nested | Primitive, path: string | undefined, resultObj: { [key: string]: Primitive; }): void; static buildInstructionPageReference(pageReference: string, property: string): string; /** * [convertPageRefToInterestPage] * Description : Converts pageReference to clipboardpage notation * @param pageReference pageReference * @returns pageReference to interestPage format * @example Example for convertPageRefToInterestPage() * Example usage - Utils.convertPageRefToInterestPage('.Employees[4].Assets[5]') * returns - .Employees(5).Assets(6) */ static convertPageRefToClipboardPageNotation(pageReference: string): string; /** * [convertClipboardPageToPageRefNotation] * Description : Converts clipboard page notation to pageReference notation * @param pageReference pageReference * @returns pageReference format * @example Example for convertClipboardPageToPageRefNotation() * Example usage - Utils.convertClipboardPageToPageRefNotation(' .Employees(5).Assets(6)') * returns - .Employees[4].Assets[5] */ static convertClipboardPageToPageRefNotation(pageReference: string): string; static isString(value: T): value is T & string; static rejectPendingActions(actionQueue: { type?: string; payload: { class: string; actionID: string; assignmentID: string; caseID: string; containerName: string; containerItemID: string; isCaseWideAction: boolean; doDeleteCaseSummary: boolean; isInCreateStage: boolean; businessID: string; isModalAction: true; outcome: string; context: string; pageReference: string; actionMgrID: string; }; }[]): boolean; /** * Checks whether the passed valueWithAnnotation has a valid annotation after extracting * the annotation from it. * * @param {string} valueWithAnnotation value with annotation to be checked */ static isValidAnnotation(valueWithAnnotation: string): boolean; static trimDotForProperty(key: string): string; static convertObjectWithStringToBoolean(features: { [key: string]: string | boolean | number; }): { [key: string]: string | number | boolean; } | undefined; static rearrangeProperties(propertiesToReArrange: string[], clientData: NestedObject): void; /** *This API will return the etag associated with the assignment context * @param contextName - - name of the context * @returns */ static getETag(contextName?: string | null): any; private static readonly PAGELIST_PATH_REGEX; /** * Checks if the given property path is a valid pagelist property. * A valid pagelist property contains one or more digits between dots. * * @param {string} property - The property path to check. * @returns {boolean} - Returns true if the property path is a valid pagelist property, otherwise false. * * @example * // returns true * isValidPageListProperty('caseInfo.content.Employee.1.Name'); */ static isValidPageListProperty(property: string): boolean; static generateDataPageHashWithParameters(parameters: Record, dataPageName: string, c11nEnv: C11nEnv): string; /** * Parses a Pega DateTime string in the format 'YYYYMMDDTHHmmss.SSS' (optionally ending with ' GMT') * and returns the corresponding timestamp in milliseconds. * * @example Example for parsePegaDateTime() * // Returns a timestamp for the given Pega DateTime string * const timestamp = AssetLoader.parsePegaDateTime('20240623T153045.123 GMT'); * * @param {string | null | undefined} dateTimeStr - The Pega DateTime string to parse. * @returns {number | null} The timestamp in milliseconds, or null if parsing fails. * @function */ static parsePegaDateTimeToTimestamp(dateTimeStr: string | null | undefined): number | null; static containsEncodedPattern: (str: string) => boolean; } export default Utils;