/** * Add a value to a map of arrays. If the key exists, append the value to the array. * If not, create the map entry with that key. * * @param {*} key * @param {*} value * @param {*} multiMap */ export declare const addValue: (key: any, value: any, multiMap: any) => void; /** * Given a path, remove a node from this path within an object. * * @param {Object} payload Javascript object from which the node will be deleted. Updated by the method. * @param {String} path A string containing a decimal point delimited path specifying the node to delete. * @return {void}, obj above updated. */ export declare const deleteNodeByPath: (payload: any, path: any) => void; /** * Return the immediate parent of a path string passed in. * Useful for processing 'options' in a form, as nested fieldIds are placed in the payload at * the same level in the heirarchy as the option question they relate to. * * @param {String} path Decimal point delimited path. * @returns {String} Immediate parent of the path passed in. */ export declare const getImmediateParent: (path: any) => string | null; /** * Questions can be nested within options, eg if you answer 'yes' to a radio question, this can * reveal additional nested questions. * The path of the fields from these nested questions are at the same level as the original option * answer, so this utility derives the nested question path from the option path. * * @param {String} optionPath Decimal point delimited path * @param {String} nestedFieldId fieldId (dataname) of the nested question within the above option * @returns {String} Fully qualified path of the nested question */ export declare const getNestedQuestionPath: (optionPath: any, nestedFieldId: any) => any; /** * Pruning a collection payload may have resulted in objects that are only left with their 'id' field, which isn't data * but added by the renderer to find the activeId. If so, remove these objects entirely as they have been pruned. * * @param {Array} array Array of objects. Each object which has only 1 remaining field called 'id' should be removed. * @return {void}, array above updated. */ export declare const removeObjectWithOnlySingleIdField: (array: any) => void; /** * Helper method to establish all the payload paths (dependencies) that an entity (page or component) is * dependent on through its show_when rule. * * This will be used to build a graph of chained dependencies to establish in which order * to resolve dependencies. The exact rule is not required at this point, just the dependencies. * * The form specification allows complex show_when blocks including 1...n levels of nesting, so * recursively search through the show_when block looking for all 'field' data items. * * @param {Object} entity Entity whose show_when rule is to be searched for 'field' data items within. * @returns {Set} Set of payload paths that the entity (page or component) is dependent on. */ export declare const getDependencies: (entity: any) => Set | null; /** * Some show_when field values point to data items that are within objects provided by * external calls to refdata, eg modeOfTransport.id. These won't map directly to the path * keyed components in the allComponents map, so go back up levels in the path until we find * the component that creates this field. * * This component might not be found at all, as the dependency might be on a field that is either * provided by cop-ui (eg jobHolderStaffDetails.linemanagerEmail), or by the "addToFormData" function * (eg epmsSubmitted). These will be leaf level in the dependency chain so component is not required. * * @param {String} optionPath Decimal point delimited path * @param {String} nestedFieldId fieldId (dataname) of the nested question within the above option * @returns {String} Fully qualified path of the nested question * */ export declare const getDependencyObjectFromPath: (dependencyPath: any, allComponents: any) => any; /** * * Evaluate the show_when rule to establish if the component should be shown (and the * payload data should not be pruned). If there is no show_when rule, then return true. * * @param {*} entity A page or component that may have a show_when rule associated with it * @param {*} data The payload data used to evaluate the show_when rule * @returns {boolean} true if the show_when rule evaluate to true, or there is no show_when rule */ export declare const isShowEntity: (entity: any, data: any) => boolean; /** * * Components can be assigned to pages in 2 ways in the form specification: * * 1 - They can be included in the page's components array with the 'use' field, e.g. * { * "use": "port" * } * This "use" value will normally match a component's id, but can match its fieldId * NB. In this case, a show_when rule can be applied here, which will supercede any show_when in the component. e.g. * * { * "use": "port", * "show_when": .... * } * * 2 - The entire component can be embedded as an entry in the page's component array. * * * @param {*} componentId The id of the component to find in the form. * @param {*} componentByIdMap A map of all the form's components keyed on Id, for better performance than searching the form. * @param {*} componentByFieldIdMap A map of all the form's components keyed on fieldId, for better performance than searching the form. * @returns {Object} A cloned component object, containing the full definition of that component. */ export declare const findComponentDefinitionInForm: (pageComponentDef: any, componentByIdMap: any, componentByFieldIdMap: any) => any; /** * * When documents are added to the payload of type multifile, they are also added to a section of the payload * 'meta', specifically an array 'documents'. When we remove the multifile elements, we need to remove * the corresponding meta.document entries. * * @param {*} component The component definition being deleted that needs corresponding meta data also deleted * @param {*} collectionDataObject The payload containing the file data being deleted (for which the corresponding meta needs deleting) * @param {*} formData The entire payload, which will include the meta section * @returns {void}, as the formData will be updated in situ */ export declare const deleteCorrespondingMetaInfo: (component: any, collectionDataObject: any, formData: any) => void; /** * After the payload has been cleansed of individual data items, empty arrays and objects may remain. * Removing an array (when the payload for a collection) may leave a redundant activeId field. The active Id * fields are not part of the payload data, but added by the react renderer to track which collection object * is currently being worked on, so can be removed. * * To tidy this all up, recursively empty arrays and their associated "ActiveId" fields from a nested payload. * * This function traverses a given payload, which can be an array or an object, and performs the following operations: * 1. If an empty array is found inside an array, it is removed using `splice`. * 2. If an empty array is found inside an object: * - It is removed from the object. * - If there is a corresponding `ActiveId` field, that field is also removed. * 3. The function operates recursively to handle deeply nested structures. * * @param {any} payload - The input data structure, which can be an array or an object. * */ export declare const removeEmptyArraysAndUnusedCollectionIDs: (payload: any) => void; /** * Helper method to go through each option calling a passed in function for any nested fields. * @param {Object} component The form component representing the path being deleted * @param {Function} action The action to perform on each nested question. Varies for collections and non-collections * @return {void}, obj above updated. */ export declare const iterateOptions: (component: any, action: any) => void; /** * Delete a component's payload item from the overall payload. * A component can be defined in >1 places in the form spec. To cater for this, * if the componentsToKeep counter tells us that there is > 1 uses of this component * still unaccounted for in the form then don't delete, but reduce the count by 1. * * When the counter reaches 1 we know all other occurences of the component have been resolved * so it is safe to delete. * * * @param {*} payload The form payload from which to delete the component data * @param {*} path The payload path of the component * @param {*} component The component whose data we should attempt to delete * @param {*} componentsToKeep A list of all components with a count of their number of uses in the form */ export declare const deleteComponentData: (payload: any, path: any, component: any, componentsToKeep: any) => void; /** * * Takes a single page collection payload object and removes the payload items specified in the componentsToPrune list * as long as they don't appear in the componentsToKeep list. * * Additionally, if the component type is multifile, remove the corresponding data entries that will have been created * in the meta section of the payload by the form renderer. * * @param {Set} pathsToKeep paths that we cannot delete from the collectionDataObject * @param {Map} componentsToPrune paths that we should delete, as long as they are not in the pathsToKeep * @param {Object} collectionDataObject the payload from which to delete the paths * @param {Object} formData The form data, whose meta section may include corresponding documents entries for multifile entries */ export declare const pruneCollectionEntry: (pathsToKeep: any, componentsToPrune: any, collectionDataObject: any, formData: any) => void; export declare const toArray: (value: any) => any[];